package IR.Tree;
import IR.*;
import Util.Lattice;
+import Util.Pair;
import java.io.File;
import java.util.*;
}
ParseNode ipn = pn.getChild("imports").getChild("import_decls_list");
- if (ipn != null) {
+ if ((ipn != null) && !state.MGC) {
ParseNodeVector pnv = ipn.getChildren();
for (int i = 0; i < pnv.size(); i++) {
ParseNode pnimport = pnv.elementAt(i);
ParseNode ppn=pn.getChild("packages").getChild("package");
String packageName = null;
- if (ppn!=null) {
+ if ((ppn!=null) && !state.MGC){
NameDescriptor nd = parseClassName(ppn.getChild("name"));
packageName = nd.getPathFromRootToHere();
//Trick -> import the package directory as a multi-import and it'll
Lattice<String> locOrder =
new Lattice<String>("_top_","_bottom_");
Set<String> spinLocSet=new HashSet<String>();
+ String thisLoc=null;
for (int i = 0; i < pnv.size(); i++) {
ParseNode loc = pnv.elementAt(i);
if(isNode(loc,"location_property")) {
- String spinLoc=loc.getChildren().elementAt(0).getLabel();
- spinLocSet.add(spinLoc);
+ if(loc.getFirstChild().getLabel().equals("location_multi")){
+ String spinLoc=loc.getFirstChild().getFirstChild().getLabel();
+ spinLocSet.add(spinLoc);
+ }else{
+ thisLoc=loc.getFirstChild().getFirstChild().getLabel();
+ }
} else {
- String lowerLoc=loc.getChildren().elementAt(0).getLabel();
- String higherLoc= loc.getChildren().elementAt(1).getLabel();
- locOrder.put(higherLoc, lowerLoc);
- if (locOrder.isIntroducingCycle(higherLoc)) {
- throw new Error("Error: the order relation " + lowerLoc + " < " + higherLoc
- + " introduces a cycle.");
+ if(loc.getChildren().size()==1){
+ String locIentifier=loc.getChildren().elementAt(0).getLabel();
+ locOrder.put(locIentifier);
+ }else{
+ String lowerLoc=loc.getChildren().elementAt(0).getLabel();
+ String higherLoc= loc.getChildren().elementAt(1).getLabel();
+ locOrder.put(higherLoc, lowerLoc);
+ if (locOrder.isIntroducingCycle(higherLoc)) {
+ throw new Error("Error: the order relation " + lowerLoc + " < " + higherLoc
+ + " introduces a cycle.");
+ }
}
}
}
locID + "' is not defined in the hierarchy of the class '"+cd +"'.");
}
}
- state.addLocationPropertySet(cd, spinLocSet);
+ state.addLocationProperty(new Pair(cd,"spin"), spinLocSet);
+ }
+ if(thisLoc!=null){
+ state.addLocationProperty(new Pair(cd,"this"), thisLoc);
}
state.addLocationOrder(cd, locOrder);
}
ParseNode tn=pn.getChild("type");
TypeDescriptor t=parseTypeDescriptor(tn);
- assignAnnotationsToType(m,t);
ParseNode vn=pn.getChild("variables").getChild("variable_declarators_list");
ParseNodeVector pnv=vn.getChildren();
boolean isglobal=pn.getChild("global")!=null;
}
cn.addField(new FieldDescriptor(m, arrayt, identifier, en, isglobal));
+ assignAnnotationsToType(m,arrayt);
}
}
blockstatements.add(tdn);
} else if (isNode(pn,"local_variable_declaration")) {
- ParseNode mn=pn.getChild("modifiers");
TypeDescriptor t=parseTypeDescriptor(pn);
- if(mn!=null) {
- Modifiers m=parseModifiersList(mn);
- assignAnnotationsToType(m, t);
- }
ParseNode vn=pn.getChild("variable_declarators_list");
ParseNodeVector pnv=vn.getChildren();
for(int i=0; i<pnv.size(); i++) {
DeclarationNode dn=new DeclarationNode(new VarDescriptor(arrayt, identifier),en);
dn.setNumLine(tmp.getLine());
+
+ ParseNode mn=pn.getChild("modifiers");
+ if(mn!=null) {
+ // here, modifers parse node has the list of annotations
+ Modifiers m=parseModifiersList(mn);
+ assignAnnotationsToType(m, arrayt);
+ }
blockstatements.add(dn);
}