X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=blobdiff_plain;f=Robust%2Fsrc%2FIR%2FVirtual.java;fp=Robust%2Fsrc%2FIR%2FVirtual.java;h=0000000000000000000000000000000000000000;hp=b5af490cbdce941fc069006d138e2b9f782d13b3;hb=refs%2Ftags%2Fbuildscript;hpb=ac6191b514c0e54b468623bf868134e1ce809df5 diff --git a/Robust/src/IR/Virtual.java b/Robust/src/IR/Virtual.java deleted file mode 100644 index b5af490c..00000000 --- a/Robust/src/IR/Virtual.java +++ /dev/null @@ -1,125 +0,0 @@ -package IR; -import java.util.*; -import Analysis.Locality.LocalityBinding; -import Analysis.Locality.LocalityAnalysis; - -public class Virtual { - State state; - LocalityAnalysis locality; - Hashtable methodnumber; - Hashtable classmethodcount; - Hashtable localitynumber; - - public int getMethodNumber(MethodDescriptor md) { - return methodnumber.get(md).intValue(); - } - - public int getMethodCount(ClassDescriptor md) { - return classmethodcount.get(md).intValue(); - } - - public int getLocalityNumber(LocalityBinding lb) { - return localitynumber.get(lb).intValue(); - } - - public Virtual(State state, LocalityAnalysis locality) { - this.state=state; - this.locality=locality; - classmethodcount=new Hashtable(); - if (state.DSM) - localitynumber=new Hashtable(); - else - methodnumber=new Hashtable(); - doAnalysis(); - } - - private void doAnalysis() { - Iterator classit=state.getClassSymbolTable().getDescriptorsIterator(); - while(classit.hasNext()) { - ClassDescriptor cd=(ClassDescriptor)classit.next(); - if (state.DSM) - numberLocality(cd); - else - numberMethods(cd); - } - } - - private int numberLocality(ClassDescriptor cd) { - if (classmethodcount.containsKey(cd)) - return classmethodcount.get(cd).intValue(); - ClassDescriptor superdesc=cd.getSuperDesc(); - int start=0; - if (superdesc!=null) - start=numberLocality(superdesc); - - if (locality.getClassBindings(cd)!=null) - for(Iterator lbit=locality.getClassBindings(cd).iterator(); lbit.hasNext();) { - LocalityBinding lb=lbit.next(); - MethodDescriptor md=lb.getMethod(); - //Is it a static method or constructor - if (md.isStatic()||md.getReturnType()==null) - continue; - - if (superdesc!=null) { - Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol()); - boolean foundmatch=false; - for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) { - MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); - if (md.matches(matchmd)) { - Set lbset=locality.getMethodBindings(matchmd); - if (lbset!=null) - for(Iterator suplbit=lbset.iterator(); suplbit.hasNext();) { - LocalityBinding suplb=suplbit.next(); - if (lb.contextMatches(suplb)) { - foundmatch=true; - localitynumber.put(lb, localitynumber.get(suplb)); - break; - } - } - break; - } - } - if (!foundmatch) - localitynumber.put(lb, new Integer(start++)); - } else { - localitynumber.put(lb, new Integer(start++)); - } - } - classmethodcount.put(cd, new Integer(start)); - return start; - } - - private int numberMethods(ClassDescriptor cd) { - if (classmethodcount.containsKey(cd)) - return classmethodcount.get(cd).intValue(); - ClassDescriptor superdesc=cd.getSuperDesc(); - int start=0; - if (superdesc!=null) - start=numberMethods(superdesc); - for(Iterator it=cd.getMethods(); it.hasNext();) { - MethodDescriptor md=(MethodDescriptor)it.next(); - if (md.isStatic()||md.getReturnType()==null) - continue; - if (superdesc!=null) { - Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol()); - boolean foundmatch=false; - for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) { - MethodDescriptor matchmd=(MethodDescriptor)matchit.next(); - if (md.matches(matchmd)) { - int num=((Integer)methodnumber.get(matchmd)).intValue(); - methodnumber.put(md, new Integer(num)); - foundmatch=true; - break; - } - } - if (!foundmatch) - methodnumber.put(md, new Integer(start++)); - } else { - methodnumber.put(md, new Integer(start++)); - } - } - classmethodcount.put(cd, new Integer(start)); - return start; - } -} -