Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
LabComm
Commits
2519db57
Commit
2519db57
authored
10 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
WiP: adding annotations to signature
parent
00d6182c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
compiler/2014/Java_CodeGen.jrag
+7
-0
7 additions, 0 deletions
compiler/2014/Java_CodeGen.jrag
compiler/2014/Signature.jrag
+42
-23
42 additions, 23 deletions
compiler/2014/Signature.jrag
with
49 additions
and
23 deletions
compiler/2014/Java_CodeGen.jrag
+
7
−
0
View file @
2519db57
...
...
@@ -495,12 +495,19 @@ aspect Java_Class {
env.println();
}
public void TypeInstance.Java_emitAnnotationComment(Java_env env) {
if(hasAnnotations()) {
env.println("// "+getAnnotationString());
}
}
//XXX TODO: refactor: split into a static class ("TypeDefSingleton"?)and a (smaller) dispatcher
public void Decl.Java_emitDispatcher(Java_env env, boolean isSample) {
// String genericStr = ""; //env.versionHasMetaData()?"<"+getName()+">":"";
String genericStr = "<"+getName()+">";
env.println("private static Dispatcher dispatcher = new Dispatcher();");
env.println();
getTypeInstance().Java_emitAnnotationComment(env);
env.println("public SampleDispatcher getDispatcher() {");
env.indent();
env.println("return dispatcher;");
...
...
This diff is collapsed.
Click to expand it.
compiler/2014/Signature.jrag
+
42
−
23
View file @
2519db57
import java.util.*;
aspect Annotations {
aspect
Sig
Annotations {
inh Decl TypeInstance.parentDecl();
...
...
@@ -20,6 +20,9 @@ aspect Annotations {
public String DocString.toString() {
return "\""+getValue()+"\"";
}
syn boolean ASTNode.isTypeInstance() = false;
eq TypeInstance.isTypeInstance() = true;
}
aspect Signature {
...
...
@@ -59,14 +62,21 @@ aspect Signature {
}
public void Decl.debugAnnotations() {
System.out.println("Decl.annotations: " + getAnnotationString());
getTypeInstance().debugAnnotations(getName());
}
public void TypeInstance.debugAnnotations(String context) {
if(hasAnnotations()){
System.out.println(context+".annotations: " + getAnnotationString());
} else {
System.out.println(context+": NO ANNOTATIONS ");
}
}
// TESTING END
syn nta Signature Decl.getSignature() {
debugAnnotations();
SignatureList sl = new SignatureList();
genSigLineForDecl(sl, true);
genSigLineForDecl(sl, true
, this
);
SignatureList fsl = new SignatureList();
flatSignature(fsl);
Signature sig = new Signature();
...
...
@@ -200,79 +210,88 @@ aspect Signature {
}
public void ASTNode.genSigLineForDecl(SignatureList list, boolean decl) {
public void ASTNode.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
throw new Error(this.getClass().getName() +
".genSigLineForDecl(SignatureList list)" +
" not declared");
}
public void TypeDecl.genSigLineForDecl(SignatureList list, boolean decl) {
public void TypeInstance.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
debugAnnotations(this.getName());
getDataType().genSigLineForDecl(list, decl, this);
}
public void TypeDecl.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
//TODO intent
if(decl){
get
DataTyp
e().genSigLineForDecl(list, decl);
get
TypeInstanc
e().genSigLineForDecl(list, decl
, this
);
}else{
list.addTypeRef(this, "//TODO (from list.addTypeRef)");
}
}
public void SampleDecl.genSigLineForDecl(SignatureList list, boolean decl) {
getDataType().genSigLineForDecl(list, decl);
public void SampleDecl.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
//TODO intent
getTypeInstance().genSigLineForDecl(list, decl, this);
}
public void VoidType.genSigLineForDecl(SignatureList list, boolean decl) {
public void VoidType.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
list.addInt(LABCOMM_STRUCT, "void");
list.addInt(0, null);
}
// public void SampleRefType.genSigLineForDecl(SignatureList list, boolean decl) {
// public void SampleRefType.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
// list.addInt(LABCOMM_SAMPLE_REF, "sample");
// }
public void PrimType.genSigLineForDecl(SignatureList list, boolean decl) {
public void PrimType.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
list.addInt(getToken(), null);
}
/* For UserType, the decl parameter is ignored, as a UserType
* will always be a TypeRef
*/
public void UserType.genSigLineForDecl(SignatureList list, boolean decl) {
public void UserType.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
TypeDecl thet = lookupType(getName());
list.addTypeRef(thet, null);
}
public void ArrayType.genSigLineForDecl(SignatureList list, boolean decl) {
public void ArrayType.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
list.addInt(LABCOMM_ARRAY, signatureComment());
list.indent();
list.addInt(getNumExp(), null);
for (int i = 0 ; i < getNumExp() ; i++) {
getExp(i).genSigLineForDecl(list, false);
getExp(i).genSigLineForDecl(list, false
, null
);
}
getDataType().genSigLineForDecl(list, false);
getDataType().genSigLineForDecl(list, false
, null
);
list.unindent();
list.add(null, "}");
}
public void StructType.genSigLineForDecl(SignatureList list, boolean decl) {
public void StructType.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
list.addInt(LABCOMM_STRUCT, "struct { " + getNumField() + " fields");
list.indent();
list.addInt(getNumField(), null);
for (int i = 0 ; i < getNumField() ; i++) {
getField(i).genSigLineForDecl(list, false);
getField(i).genSigLineForDecl(list, false
, inst
);
}
list.unindent();
list.add(null, "}");
}
public void Field.genSigLineForDecl(SignatureList list, boolean decl) {
public void Field.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
list.addString(getName(), signatureComment());
getDataType().genSigLineForDecl(list, decl);
super.genSigLineForDecl(list, decl, inst);
//TODOintent
//getDataType().genSigLineForDecl(list, decl, inst);
}
public void IntegerLiteral.genSigLineForDecl(SignatureList list, boolean decl) {
public void IntegerLiteral.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
list.addInt(Integer.parseInt(getValue()), null);
}
public void VariableSize.genSigLineForDecl(SignatureList list, boolean decl) {
public void VariableSize.genSigLineForDecl(SignatureList list, boolean decl
, ASTNode inst
) {
list.addInt(0, null);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment