Skip to content
Snippets Groups Projects
Commit 32370bb3 authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

preliminary refactoring of intention attributes

parent e44e0320
No related branches found
No related tags found
No related merge requests found
aspect Annotations {
syn boolean TypeInstance.hasAnnotations() = getNumAnnotation()>0;
syn boolean TypeInstance.hasIntentions() = ! intentions().isEmpty();
syn boolean TypeInstance.hasIntentions() = ! intentionSet().isEmpty();
syn boolean Annotation.isIntention() = false;
eq Intention.isIntention() = true;
......@@ -9,9 +9,9 @@ aspect Annotations {
eq TypeInstance.getAnnotation(int i).parentInstance() = this;
coll Set<Intention> TypeInstance.intentions() [new HashSet<Intention>()] with add;
coll Set<Intention> TypeInstance.intentionSet() [new HashSet<Intention>()] with add;
Intention contributes this
to TypeInstance.intentions()
to TypeInstance.intentionSet()
for parentInstance();
}
......
......
......@@ -35,7 +35,7 @@ aspect FlatSignature {
public void TypeInstance.flatSignature(SignatureList list) {
if(addIntentions()) {
debugAnnotations(this.getName()+".TypeInstance.flatSignature");
list.addString(getIntentionString(), "intentions: "+getIntentionString());
list.addIntentions(intentions(), "intentions: "+getIntentionString());
}
getDataType().flatSignature(list);
}
......@@ -78,7 +78,7 @@ aspect FlatSignature {
public void Field.flatSignature(SignatureList list) {
debugAnnotations(this.getName()+".Field.flatSignature");
list.addString(getIntentionString(), "intentions: "+getIntentionString());
list.addIntentions(intentions(), "Field: "+getIntentionString());
list.addString(getName(), signatureComment());
getDataType().flatSignature(list);
}
......
......
......@@ -22,6 +22,7 @@ abstract DataSignatureLine : SignatureLine;
ByteArraySignatureLine : DataSignatureLine ::= <Data:byte[]>;
IntSignatureLine : DataSignatureLine ::= <Data:int>;
StringSignatureLine : DataSignatureLine ::= <Data:String>;
IntentionSignatureLine : DataSignatureLine ::= <Data:java.util.Map> ;
TypeRefSignatureLine : SignatureLine ::= Decl;
Field : TypeInstance;
......
......
......@@ -172,6 +172,10 @@ aspect Signature {
return getIntBytes(getData(), version);
}
public void SignatureList.addIntentions(Set<Intention> data, String comment) {
addString(TypeInstance.getIntentionString(data), comment);
}
public void SignatureList.addString(String data, String comment) {
addSignatureLine(new StringSignatureLine(indent, comment, data));
}
......@@ -229,10 +233,15 @@ aspect Signature {
" not declared");
}
syn String ASTNode.getIntentionString() = "";
eq TypeInstance.getIntentionString() {
public String TypeInstance.getIntentionString() {
return getIntentionString(intentions());
}
public static String TypeInstance.getIntentionString(Set<Intention> intentions) {
if(intentions==null) return "";
StringBuilder sb = new StringBuilder();
Iterator<Intention> it = intentions().iterator();
Iterator<Intention> it = intentions.iterator();
while(it.hasNext()) {
Intention i = it.next();
sb.append(i.toString());
......@@ -240,6 +249,17 @@ aspect Signature {
return sb.toString();
}
syn Set<Intention> Specification.emptyIntentions() = new HashSet<Intention>();
inh Set<Intention> ASTNode.noIntentions();
eq Specification.getChild(int i).noIntentions() = emptyIntentions();
syn Set<Intention> ASTNode.intentions();
eq ASTNode.intentions() = noIntentions();
eq TypeInstance.intentions() = intentionSet();
public void TypeInstance.genSigLineForDecl(SignatureList list, boolean decl, ASTNode inst) {
// debugAnnotations(this.getName());
// list.addString(inst.getIntentionString(), "intention string");
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment