+ // debugDoLoopCheck();
+ }
+
+ private void debugDoLoopCheck() {
+ GlobalFieldType gft = new GlobalFieldType(callgraph, state, tu.getMain());
+ LoopOptimize lo = new LoopOptimize(gft, tu);
+
+ SymbolTable classtable = state.getClassSymbolTable();
+
+ List<ClassDescriptor> toanalyzeList = new ArrayList<ClassDescriptor>();
+ List<MethodDescriptor> toanalyzeMethodList = new ArrayList<MethodDescriptor>();
+
+ toanalyzeList.addAll(classtable.getValueSet());
+ Collections.sort(toanalyzeList, new Comparator<ClassDescriptor>() {
+ public int compare(ClassDescriptor o1, ClassDescriptor o2) {
+ return o1.getClassName().compareTo(o2.getClassName());
+ }
+ });
+
+ for (int i = 0; i < toanalyzeList.size(); i++) {
+ ClassDescriptor cd = toanalyzeList.get(i);
+
+ SymbolTable methodtable = cd.getMethodTable();
+ toanalyzeMethodList.clear();
+ toanalyzeMethodList.addAll(methodtable.getValueSet());
+ Collections.sort(toanalyzeMethodList, new Comparator<MethodDescriptor>() {
+ public int compare(MethodDescriptor o1, MethodDescriptor o2) {
+ return o1.getSymbol().compareTo(o2.getSymbol());
+ }
+ });
+
+ for (int mdIdx = 0; mdIdx < toanalyzeMethodList.size(); mdIdx++) {
+ MethodDescriptor md = toanalyzeMethodList.get(mdIdx);
+ if (needTobeAnnotated(md)) {
+ lo.analyze(state.getMethodFlat(md));
+ doLoopTerminationCheck(lo, state.getMethodFlat(md));
+ }
+ }
+
+ }
+
+ }
+
+ public void addTrustMethod(MethodDescriptor md) {
+ trustWorthyMDSet.add(md);
+ }
+
+ public boolean isTrustMethod(MethodDescriptor md) {
+ return trustWorthyMDSet.contains(md);
+ }
+
+ private void computeLinearTypeCheckMethodSet() {
+
+ Set<MethodDescriptor> allCalledSet = callgraph.getMethodCalls(tu.getMain());
+ linearTypeCheckMethodSet.addAll(allCalledSet);
+
+ Set<MethodDescriptor> trustedSet = new HashSet<MethodDescriptor>();
+
+ for (Iterator iterator = trustWorthyMDSet.iterator(); iterator.hasNext();) {
+ MethodDescriptor trustMethod = (MethodDescriptor) iterator.next();
+ Set<MethodDescriptor> calledFromTrustMethodSet = callgraph.getMethodCalls(trustMethod);
+ trustedSet.add(trustMethod);
+ trustedSet.addAll(calledFromTrustMethodSet);
+ }
+
+ linearTypeCheckMethodSet.removeAll(trustedSet);
+
+ // if a method is called only by trusted method, no need to check linear
+ // type & flow down rule
+ for (Iterator iterator = trustedSet.iterator(); iterator.hasNext();) {
+ MethodDescriptor md = (MethodDescriptor) iterator.next();
+ Set<MethodDescriptor> callerSet = callgraph.getCallerSet(md);
+ if (!trustedSet.containsAll(callerSet) && !trustWorthyMDSet.contains(md)) {
+ linearTypeCheckMethodSet.add(md);
+ }
+ }
+
+ }
+
+ private void doLinearTypeCheck() {
+ LinearTypeCheck checker = new LinearTypeCheck(this, state);
+ checker.linearTypeCheck();