X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FIR%2FTree%2FBuildIR.java;h=c8efb8e7bc29898770e26fdbb7b1bb8a90733140;hb=d396c42d2a86460c7e220d21e5219049c177c5cf;hp=7d7121e5390793897b017950173bedc7f2b9b959;hpb=9d964ce6a3a8c09b353cbcd553cef5113d6a4438;p=IRC.git diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 7d7121e5..c8efb8e7 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -1,161 +1,245 @@ package IR.Tree; import IR.*; +import Util.Lattice; +import Util.Pair; +import java.io.File; import java.util.*; - - +import java.io.*; +import java.lang.Throwable; public class BuildIR { State state; - + private boolean isRunningRecursiveInnerClass; private int m_taskexitnum; public BuildIR(State state) { this.state=state; this.m_taskexitnum = 0; + this.isRunningRecursiveInnerClass = false; } - public void buildtree(ParseNode pn, Set toanalyze) { - parseFile(pn, toanalyze); + public void buildtree(ParseNode pn, Set toanalyze, String sourcefile) { + parseFile(pn, toanalyze, sourcefile); + + // numering the interfaces + int if_num = 0; + Iterator it_classes = state.getClassSymbolTable().getValueSet().iterator(); + while(it_classes.hasNext()) { + ClassDescriptor cd = (ClassDescriptor)it_classes.next(); + if(cd.isInterface()) { + cd.setInterfaceId(if_num++); + } + } } - Vector singleimports; - Vector multiimports; - NameDescriptor packages; + //This is all single imports and a subset of the + //multi imports that have been resolved. + ChainHashMap mandatoryImports; + //maps class names in file to full name + //Note may map a name to an ERROR. + ChainHashMap multiimports; + String packageName; + + String currsourcefile; + Set analyzeset; + + void pushChainMaps() { + mandatoryImports=mandatoryImports.makeChild(); + multiimports=multiimports.makeChild(); + } + + void popChainMaps() { + mandatoryImports=mandatoryImports.getParent(); + multiimports=multiimports.getParent(); + } /** Parse the classes in this file */ - public void parseFile(ParseNode pn, Set toanalyze) { - singleimports=new Vector(); - multiimports=new Vector(); + public void parseFile(ParseNode pn, Set toanalyze, String sourcefile) { + mandatoryImports = new ChainHashMap(); + multiimports = new ChainHashMap(); + currsourcefile=sourcefile; + analyzeset=toanalyze; + + if(state.JNI) { + //add java.lang as our default multi-import + this.addMultiImport(sourcefile, "java.lang", false); + } - ParseNode ipn=pn.getChild("imports").getChild("import_decls_list"); - if (ipn!=null) { - ParseNodeVector pnv=ipn.getChildren(); - for(int i=0; i import the package directory as a multi-import and it'll + //automatically recognize files in the same directory. + addMultiImport(sourcefile, packageName, true); } + ParseNode tpn=pn.getChild("type_declaration_list"); - if (tpn!=null) { - ParseNodeVector pnv=tpn.getChildren(); - for(int i=0; i md2pos = new HashMap(); + while(methodit.hasNext()) { + MethodDescriptor currmd=(MethodDescriptor)methodit.next(); + if(currmd.isConstructor()) { + BlockNode bn=state.getMethodBody(currmd); + // if there are super(...) invokation, the initializers should be invoked after that + int i = 0; + for(; i < bn.size(); i++) { + if(Kind.BlockExpressionNode==bn.get(i).kind() + &&(((BlockExpressionNode)bn.get(i)).getExpression() instanceof MethodInvokeNode) + &&((MethodInvokeNode)(((BlockExpressionNode)bn.get(i)).getExpression())).getMethodName().equals("super")) { + break; } - state.addClass(ecd); + } + if(i==bn.size()) { + md2pos.put(currmd, 0); + } else { + md2pos.put(currmd, i+1); } } - } else if ((state.MGC) && isNode(type_pn,"enum_declaration")) { - // TODO add version for normal Java later - ClassDescriptor cn = parseEnumDecl(null, type_pn); - if (toanalyze!=null) - toanalyze.add(cn); - state.addClass(cn); - } else { - throw new Error(type_pn.getLabel()); - } + } + int pos = 0; + for(int i=0; i annotations=modifiers.getAnnotations(); + for(int i=0; i