Commit 52e78cef authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

WiP: refactoring to separate out 'outermost' intentions. tests broken

parent 0d1d81ab
......@@ -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);
}
......
import java.util.*;
aspect NoIntentionForTypedefs {
aspect NoIntentionForTypeOrSampledefs {
inh boolean TypeInstance.addIntentions();
eq Decl.getTypeInstance().addIntentions() = false;
eq SampleDecl.getTypeInstance().addIntentions() = true;
eq StructType.getField(int i).addIntentions() = true;
}
......
......@@ -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();
}
......
......@@ -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: create sorted list of intentions
//TODO: refactor 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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment