diff --git a/compiler/2014/Annotations.jrag b/compiler/2014/Annotations.jrag index 57c88d4df3e6bac5169bec013bf4664abf35bf56..25e145dbd70ca0db5443787bc5825e3ad3127157 100644 --- a/compiler/2014/Annotations.jrag +++ b/compiler/2014/Annotations.jrag @@ -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); } diff --git a/compiler/2014/FlatSignature.jrag b/compiler/2014/FlatSignature.jrag index c3f92b3b8858748ec7e030a6a29380f5424cfb9e..42e768aa68d4f176e016e7883b67be6910e52205 100644 --- a/compiler/2014/FlatSignature.jrag +++ b/compiler/2014/FlatSignature.jrag @@ -1,9 +1,8 @@ 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; } diff --git a/compiler/2014/Java_CodeGen.jrag b/compiler/2014/Java_CodeGen.jrag index 6a042ed24985ae9df19da67169cef971a2118563..3578002c2eefc7439a5bd7a43f465a55c7830620 100644 --- a/compiler/2014/Java_CodeGen.jrag +++ b/compiler/2014/Java_CodeGen.jrag @@ -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(); } diff --git a/compiler/2014/Signature.jrag b/compiler/2014/Signature.jrag index 79286970e6e537a263c3f39f8db344cba97e789f..bdad9bcf6ee3b9238f36fffc40dc9d89b3a707ac 100644 --- a/compiler/2014/Signature.jrag +++ b/compiler/2014/Signature.jrag @@ -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); }