Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
LabComm
Commits
52e78cef
Commit
52e78cef
authored
May 21, 2015
by
Sven Gestegård Robertz
Browse files
WiP: refactoring to separate out 'outermost' intentions. tests broken
parent
0d1d81ab
Changes
4
Hide whitespace changes
Inline
Side-by-side
compiler/2014/Annotations.jrag
View file @
52e78cef
...
...
@@ -36,6 +36,32 @@ aspect SigAnnotations {
to Decl.allAnnotations()
for parentDecl();
// Helper attribute to get the "outermost" intentions for Decls
syn byte[] TypeInstance.intentionBytes() = getIntentionBytes(sortedIntentions());
syn byte[] Decl.getIntentionBytes() = getTypeInstance().intentionBytes();
static Comparator TypeInstance.intentionComp =
new Comparator<Intention>() {
public int compare(Intention i1, Intention i2) {
return i1.getKey().compareTo(i2.getKey());
}
};
syn List<Intention> TypeInstance.sortedIntentions() {
List<Intention> res = new List<Intention>();
//TODO: refactor out creation of sorted list of intentions
java.util.ArrayList<Intention> sorted = new ArrayList(intentionSet());
java.util.Collections.sort(sorted, intentionComp);
for(Intention i : sorted) {
res.add(i);
}
return res;
}
public DocString.DocString(byte[] bs) {
super("DOCSTRING", bs);
}
...
...
compiler/2014/FlatSignature.jrag
View file @
52e78cef
import java.util.*;
aspect NoIntentionForTypedefs {
aspect NoIntentionForType
OrSample
defs {
inh boolean TypeInstance.addIntentions();
eq Decl.getTypeInstance().addIntentions() = false;
eq SampleDecl.getTypeInstance().addIntentions() = true;
eq StructType.getField(int i).addIntentions() = true;
}
...
...
compiler/2014/Java_CodeGen.jrag
View file @
52e78cef
...
...
@@ -464,6 +464,7 @@ aspect Java_Class {
//for matching at the decoder side (which cannot know
//the type_ids of dependent types. Therefore, flat sigs
//are used for matching
Java_emitIntentions(env);
Java_emitFlatSignature(env);
if(isReferenced() || (isSampleDecl() && hasDependencies() )){
Signature signature = getSignature();
...
...
@@ -471,6 +472,20 @@ aspect Java_Class {
}
}
public void Decl.Java_emitIntentions(Java_env env){
env.println("private static byte[] intentions = new byte[] {");
env.indent();
byte[] data = getIntentionBytes();
if (data != null) {
for (int j = 0 ; j < data.length ; j++) {
env.print(data[j] + ", ");
}
}
env.unindent();
env.println("};");
env.println();
}
public void Decl.Java_emitFlatSignature(Java_env env){
env.println("private static byte[] signature = new byte[] {");
env.indent();
...
...
@@ -491,7 +506,6 @@ aspect Java_Class {
}
env.unindent();
env.println("};");
env.unindent();
env.println();
}
...
...
compiler/2014/Signature.jrag
View file @
52e78cef
...
...
@@ -99,21 +99,14 @@ aspect Signature {
return getIntBytes(getData(), version);
}
private static Comparator SignatureList.intentionComp =
new Comparator<Intention>() {
public int compare(Intention i1, Intention i2) {
return i1.getKey().compareTo(i2.getKey());
}
};
public void SignatureList.addIntentions(Set<Intention> data, String comment) {
//addString(TypeInstance.getIntentionString(data), comment);
//create IntenionSignatureLine
IntentionSignatureLine line = new IntentionSignatureLine(indent, comment, new List());
//TODO:
c
re
ate
sorted list of intentions
//TODO: re
factor out creation of
sorted list of intentions
java.util.ArrayList<Intention> sorted = new ArrayList(data);
java.util.Collections.sort(sorted, intentionComp);
java.util.Collections.sort(sorted,
TypeInstance.
intentionComp);
for(Intention i : sorted) {
line.addIntention(i);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment