From 352ed3e08eed7e552dc5c3e6badad2eb676ff3a6 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 9 Jun 2011 05:07:44 +0000 Subject: [PATCH] many changes towards classpath... --- Robust/src/IR/ClassDescriptor.java | 14 ++- Robust/src/IR/Flat/BuildFlat.java | 139 ++++++++++++++------------ Robust/src/IR/Tree/BuildIR.java | 10 +- Robust/src/IR/Tree/JavaBuilder.java | 30 ++++-- Robust/src/IR/Tree/SemanticCheck.java | 73 +++++++++----- Robust/src/IR/TypeUtil.java | 46 +++++++-- 6 files changed, 204 insertions(+), 108 deletions(-) diff --git a/Robust/src/IR/ClassDescriptor.java b/Robust/src/IR/ClassDescriptor.java index faa72242..e218c790 100644 --- a/Robust/src/IR/ClassDescriptor.java +++ b/Robust/src/IR/ClassDescriptor.java @@ -18,6 +18,8 @@ public class ClassDescriptor extends Descriptor { Vector fieldvec; SymbolTable flags; SymbolTable methods; + boolean inline=false; + ChainHashMap mandatoryImports; ChainHashMap multiImports; @@ -265,6 +267,14 @@ public class ClassDescriptor extends Descriptor { this.modifiers=modifiers; } + public void setInline() { + this.inline=true; + } + + public boolean getInline() { + return inline; + } + public void setSuper(String superclass) { this.superclass=superclass; } @@ -273,7 +283,7 @@ public class ClassDescriptor extends Descriptor { return superdesc; } - public void setSuper(ClassDescriptor scd) { + public void setSuperDesc(ClassDescriptor scd) { this.superdesc=scd; } @@ -431,7 +441,7 @@ public class ClassDescriptor extends Descriptor { } //Returns the full name/path of another class referenced from this class via imports. - public String getCannonicalImportMapName(String otherClassname) { + public String getCanonicalImportMapName(String otherClassname) { if(mandatoryImports.containsKey(otherClassname)) { return (String) mandatoryImports.get(otherClassname); } else if(multiImports.containsKey(otherClassname)) { diff --git a/Robust/src/IR/Flat/BuildFlat.java b/Robust/src/IR/Flat/BuildFlat.java index fdc78e8c..fb9ecf31 100644 --- a/Robust/src/IR/Flat/BuildFlat.java +++ b/Robust/src/IR/Flat/BuildFlat.java @@ -220,36 +220,41 @@ public class BuildFlat { NodePair np=flattenBlockNode(bn); FlatNode fn=np.getBegin(); if ((state.THREAD||state.MGC)&&currmd.getModifiers().isSynchronized()) { - MethodDescriptor memd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorEnter"); - FlatNode first = null; - FlatNode end = null; - - { - if (lockStack.size()!=1) { - throw new Error("TOO MANY THINGS ON LOCKSTACK"); - } - TempDescriptor thistd = this.lockStack.elementAt(0); - FlatCall fc = new FlatCall(memd, null, thistd, new TempDescriptor[0]); - fc.setNumLine(bn.getNumLine()); - first = end = fc; - } - - end.addNext(fn); - fn=first; - end = np.getEnd(); - if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) { - MethodDescriptor memdex=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit"); - while(!this.lockStack.isEmpty()) { - TempDescriptor thistd = this.lockStack.pop(); - FlatCall fcunlock = new FlatCall(memdex, null, thistd, new TempDescriptor[0]); - fcunlock.setNumLine(bn.getNumLine()); - end.addNext(fcunlock); - end = fcunlock; - } - FlatNode rnflat=spliceReturn(end); - rnflat.addNext(fe); + if (state.JNI) { + //XXXXXXXX: FIX THIS + this.lockStack.clear(); } else { - this.lockStack.clear(); + MethodDescriptor memd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorEnter"); + FlatNode first = null; + FlatNode end = null; + + { + if (lockStack.size()!=1) { + throw new Error("TOO MANY THINGS ON LOCKSTACK"); + } + TempDescriptor thistd = this.lockStack.elementAt(0); + FlatCall fc = new FlatCall(memd, null, thistd, new TempDescriptor[0]); + fc.setNumLine(bn.getNumLine()); + first = end = fc; + } + + end.addNext(fn); + fn=first; + end = np.getEnd(); + if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) { + MethodDescriptor memdex=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit"); + while(!this.lockStack.isEmpty()) { + TempDescriptor thistd = this.lockStack.pop(); + FlatCall fcunlock = new FlatCall(memdex, null, thistd, new TempDescriptor[0]); + fcunlock.setNumLine(bn.getNumLine()); + end.addNext(fcunlock); + end = fcunlock; + } + FlatNode rnflat=spliceReturn(end); + rnflat.addNext(fe); + } else { + this.lockStack.clear(); + } } } else if (state.DSM&&currmd.getModifiers().isAtomic()) { curran.addNext(fn); @@ -1408,19 +1413,23 @@ public class BuildFlat { rnflat.addNext(fe); FlatNode ln=rnflat; if ((state.THREAD||state.MGC)&&!this.lockStack.isEmpty()) { - FlatNode end = null; - MethodDescriptor memdex=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit"); - for(int j = this.lockStack.size(); j > 0; j--) { - TempDescriptor thistd = this.lockStack.elementAt(j-1); - FlatCall fcunlock = new FlatCall(memdex, null, thistd, new TempDescriptor[0]); - fcunlock.setNumLine(rntree.getNumLine()); - if(end != null) { - end.addNext(fcunlock); - } - end = fcunlock; + if (state.JNI) { + //XXXXXXXXX: FIX THIS + } else { + FlatNode end = null; + MethodDescriptor memdex=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit"); + for(int j = this.lockStack.size(); j > 0; j--) { + TempDescriptor thistd = this.lockStack.elementAt(j-1); + FlatCall fcunlock = new FlatCall(memdex, null, thistd, new TempDescriptor[0]); + fcunlock.setNumLine(rntree.getNumLine()); + if(end != null) { + end.addNext(fcunlock); + } + end = fcunlock; + } + end.addNext(ln); + ln=end; } - end.addNext(ln); - ln=end; } if (state.DSM&&currmd.getModifiers().isAtomic()) { FlatAtomicExitNode faen=new FlatAtomicExitNode(curran); @@ -1493,29 +1502,33 @@ public class BuildFlat { } this.lockStack.push(montmp); NodePair npblock=flattenBlockNode(sbn.getBlockNode()); - - MethodDescriptor menmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorEnter"); - FlatCall fcen=new FlatCall(menmd, null, montmp, new TempDescriptor[0]); - fcen.setNumLine(sbn.getNumLine()); - - MethodDescriptor mexmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit"); - FlatCall fcex=new FlatCall(mexmd, null, montmp, new TempDescriptor[0]); - fcex.setNumLine(sbn.getNumLine()); - - this.lockStack.pop(); - - if(first != null) { - end.addNext(fcen); - } else { - first = fcen; - } - fcen.addNext(npblock.getBegin()); - - if (npblock.getEnd()!=null&&npblock.getEnd().kind()!=FKind.FlatReturnNode) { - npblock.getEnd().addNext(fcex); - return new NodePair(first, fcex); + if (state.JNI) { + this.lockStack.pop(); + return npblock; } else { - return new NodePair(first, null); + MethodDescriptor menmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorEnter"); + FlatCall fcen=new FlatCall(menmd, null, montmp, new TempDescriptor[0]); + fcen.setNumLine(sbn.getNumLine()); + + MethodDescriptor mexmd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit"); + FlatCall fcex=new FlatCall(mexmd, null, montmp, new TempDescriptor[0]); + fcex.setNumLine(sbn.getNumLine()); + + this.lockStack.pop(); + + if(first != null) { + end.addNext(fcen); + } else { + first = fcen; + } + fcen.addNext(npblock.getBegin()); + + if (npblock.getEnd()!=null&&npblock.getEnd().kind()!=FKind.FlatReturnNode) { + npblock.getEnd().addNext(fcex); + return new NodePair(first, fcex); + } else { + return new NodePair(first, null); + } } } diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 6b94d45d..30440944 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -632,10 +632,10 @@ public class BuildIR { parseInnerClassDecl(cn,innerclassnode); return; } - - ParseNode innerinterfacenode=pn.getChild("interface_declaration"); + ParseNode innerinterfacenode=pn.getChild("interface_declaration"); if (innerinterfacenode!=null) { parseInterfaceDecl(innerinterfacenode, cn); + return; } ParseNode enumnode=pn.getChild("enum_declaration"); @@ -653,6 +653,7 @@ public class BuildIR { if(emptynode != null) { return; } + System.out.println("Unrecognized node:"+pn.PPrint(2,true)); throw new Error(); } @@ -984,10 +985,13 @@ public class BuildIR { pushChainMaps(); cnnew.setImports(mandatoryImports, multiimports); cnnew.setSuper(td.getSymbol()); + cnnew.setInline(); parseClassBody(cnnew, pn.getChild("decl").getChild("classbody")); + TypeDescriptor tdnew=state.getTypeDescriptor(cnnew.getSymbol()); + Vector args=parseArgumentList(pn); - CreateObjectNode con=new CreateObjectNode(td, false, null); + CreateObjectNode con=new CreateObjectNode(tdnew, false, null); con.setNumLine(pn.getLine()); for(int i=0; i()); FlatMethod fm=state.getMethodFlat(md); - for(FlatNode fn : fm.getNodeSet()) { + for(FlatNode fn: fm.getNodeSet()) { switch(fn.kind()) { - case FKind.FlatCall : { - FlatCall fcall=(FlatCall)fn; - processCall(md, fcall); - break; + case FKind.FlatFieldNode: { + FieldDescriptor fd=((FlatFieldNode)fn).getField(); + if (fd.isStatic()) { + ClassDescriptor cd=fd.getClassDescriptor(); + initClassDesc(cd, CDINIT); + } + break; + } + + case FKind.FlatSetFieldNode: { + FieldDescriptor fd=((FlatSetFieldNode)fn).getField(); + if (fd.isStatic()) { + ClassDescriptor cd=fd.getClassDescriptor(); + initClassDesc(cd, CDINIT); + } + break; + } + + case FKind.FlatCall: { + FlatCall fcall=(FlatCall)fn; + processCall(md, fcall); + break; } case FKind.FlatNew: { diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index 29f36b33..4e36cee0 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -38,13 +38,8 @@ public class SemanticCheck { return getClass(context, classname, INIT); } public ClassDescriptor getClass(ClassDescriptor context, String classnameIn, int fullcheck) { - String classname = classnameIn; - if (context!=null) { - classname = context.getCannonicalImportMapName(classnameIn); - } - ClassDescriptor cd=typeutil.getClass(classname, toanalyze); + ClassDescriptor cd=typeutil.getClass(context, classnameIn, toanalyze); checkClass(cd, fullcheck); - return cd; } @@ -60,17 +55,25 @@ public class SemanticCheck { if (fullcheck>=REFERENCE&&oldstatus superifv = cd.getSuperInterface(); for(int i = 0; i < superifv.size(); i++) { String superif = superifv.elementAt(i); - ClassDescriptor if_super = getClass(superif, todo); + ClassDescriptor if_super = getClass(cd, superif, todo); hs.add(if_super); } } -- 2.34.1