Beispiel #1
1
  protected void computeEdgeAndThreadNo() {
    Iterator it = iterator();
    int numberOfEdge = 0;
    while (it.hasNext()) {
      List succList = (List) getSuccsOf(it.next());

      numberOfEdge = numberOfEdge + succList.size();
    }
    numberOfEdge = numberOfEdge + startToThread.size();

    System.err.println("**number of edges: " + numberOfEdge);

    System.err.println("**number of threads: " + (startToThread.size() + 1));

    /*	Set keySet = startToThread.keySet();
    Iterator keyIt = keySet.iterator();
    while (keyIt.hasNext()){
    List list = (List)startToThread.get(keyIt.next());
    System.out.println("********start thread:");
    Iterator itit = list.iterator();
    while (itit.hasNext()){
    System.out.println(it.next());
    }
    }
    */

  }
Beispiel #2
0
  /**
   * Given an abstract dispatch to an object of type c and a method m, gives a list of possible
   * receiver methods.
   */
  public List resolveAbstractDispatch(SootClass c, SootMethod m) {
    c.checkLevel(SootClass.HIERARCHY);
    m.getDeclaringClass().checkLevel(SootClass.HIERARCHY);
    checkState();

    Iterator<SootClass> classesIt = null;

    if (c.isInterface()) {
      classesIt = getImplementersOf(c).iterator();
      HashSet<SootClass> classes = new HashSet<SootClass>();
      while (classesIt.hasNext()) classes.addAll(getSubclassesOfIncluding(classesIt.next()));
      classesIt = classes.iterator();
    } else classesIt = getSubclassesOfIncluding(c).iterator();

    ArraySet s = new ArraySet();

    while (classesIt.hasNext()) {
      SootClass cl = classesIt.next();
      if (Modifier.isAbstract(cl.getModifiers())) continue;
      s.add(resolveConcreteDispatch(cl, m));
    }

    List l = new ArrayList();
    l.addAll(s);
    return Collections.unmodifiableList(l);
  }
  public StronglyConnectedComponentsBV(BitVector typeVariableList, TypeResolverBV resolver)
      throws TypeException {
    this.resolver = resolver;
    variables = typeVariableList;

    black = new TreeSet();
    finished = new LinkedList();

    for (BitSetIterator i = variables.iterator(); i.hasNext(); ) {
      TypeVariableBV var = resolver.typeVariableForId(i.next());

      if (!black.contains(var)) {
        black.add(var);
        dfsg_visit(var);
      }
    }

    black = new TreeSet();

    for (Iterator i = finished.iterator(); i.hasNext(); ) {
      TypeVariableBV var = (TypeVariableBV) i.next();

      if (!black.contains(var)) {
        current_tree = new LinkedList();
        forest.add(current_tree);
        black.add(var);
        dfsgt_visit(var);
      }
    }

    for (Iterator i = forest.iterator(); i.hasNext(); ) {
      LinkedList list = (LinkedList) i.next();
      TypeVariableBV previous = null;
      StringBuffer s = null;
      if (DEBUG) {
        s = new StringBuffer("scc:\n");
      }

      for (Iterator j = list.iterator(); j.hasNext(); ) {
        TypeVariableBV current = (TypeVariableBV) j.next();

        if (DEBUG) {
          s.append(" " + current + "\n");
        }

        if (previous == null) {
          previous = current;
        } else {
          try {
            previous = previous.union(current);
          } catch (TypeException e) {
            if (DEBUG) {
              G.v().out.println(s);
            }
            throw e;
          }
        }
      }
    }
  }
Beispiel #4
0
  /**
   * Indicates whether this ThrowableSet includes some exception that might be caught by a handler
   * argument of the type <code>catcher</code>.
   *
   * @param catcher type of the handler parameter to be tested.
   * @return <code>true</code> if this set contains an exception type that might be caught by <code>
   *     catcher</code>, false if it does not.
   */
  public boolean catchableAs(RefType catcher) {
    if (INSTRUMENTING) {
      Manager.v().catchableAsQueries++;
    }

    FastHierarchy h = Scene.v().getOrMakeFastHierarchy();

    if (exceptionsExcluded.size() > 0) {
      if (INSTRUMENTING) {
        Manager.v().catchableAsFromSearch++;
      }
      for (Iterator i = exceptionsExcluded.iterator(); i.hasNext(); ) {
        AnySubType exclusion = (AnySubType) i.next();
        if (h.canStoreType(catcher, exclusion.getBase())) {
          return false;
        }
      }
    }

    if (exceptionsIncluded.contains(catcher)) {
      if (INSTRUMENTING) {
        if (exceptionsExcluded.size() == 0) {
          Manager.v().catchableAsFromMap++;
        } else {
          Manager.v().catchableAsFromSearch++;
        }
      }
      return true;
    } else {
      if (INSTRUMENTING) {
        if (exceptionsExcluded.size() == 0) {
          Manager.v().catchableAsFromSearch++;
        }
      }
      for (Iterator i = exceptionsIncluded.iterator(); i.hasNext(); ) {
        RefLikeType thrownType = (RefLikeType) i.next();
        if (thrownType instanceof RefType) {
          if (thrownType == catcher) {
            // assertion failure.
            throw new IllegalStateException(
                "ThrowableSet.catchableAs(RefType): exceptions.contains() failed to match contained RefType "
                    + catcher);
          } else if (h.canStoreType(thrownType, catcher)) {
            return true;
          }
        } else {
          RefType thrownBase = ((AnySubType) thrownType).getBase();
          // At runtime, thrownType might be instantiated by any
          // of thrownBase's subtypes, so:
          if (h.canStoreType(thrownBase, catcher) || h.canStoreType(catcher, thrownBase)) {
            return true;
          }
        }
      }
      return false;
    }
  }
Beispiel #5
0
  /** Prints the given <code>JimpleBody</code> to the specified <code>PrintWriter</code>. */
  private void printLocalsInBody(Body body, UnitPrinter up) {
    // Print out local variables
    {
      Map typeToLocals = new DeterministicHashMap(body.getLocalCount() * 2 + 1, 0.7f);

      // Collect locals
      {
        Iterator localIt = body.getLocals().iterator();

        while (localIt.hasNext()) {
          Local local = (Local) localIt.next();

          List localList;

          Type t = local.getType();

          if (typeToLocals.containsKey(t)) localList = (List) typeToLocals.get(t);
          else {
            localList = new ArrayList();
            typeToLocals.put(t, localList);
          }

          localList.add(local);
        }
      }

      // Print locals
      {
        Iterator typeIt = typeToLocals.keySet().iterator();

        while (typeIt.hasNext()) {
          Type type = (Type) typeIt.next();

          List localList = (List) typeToLocals.get(type);
          Object[] locals = localList.toArray();
          up.type(type);
          up.literal(" ");

          for (int k = 0; k < locals.length; k++) {
            if (k != 0) up.literal(", ");

            up.local((Local) locals[k]);
          }

          up.literal(";");
          up.newline();
        }
      }

      if (!typeToLocals.isEmpty()) {
        up.newline();
      }
    }
  }
Beispiel #6
0
  public void computeMonitorObjs() {
    Set maps = monitor.entrySet();
    for (Iterator iter = maps.iterator(); iter.hasNext(); ) {
      Map.Entry entry = (Map.Entry) iter.next();

      FlowSet fs = (FlowSet) entry.getValue();
      Iterator it = fs.iterator();
      while (it.hasNext()) {
        Object obj = it.next();
        if (!monitorObjs.contains(obj)) monitorObjs.add(obj);
      }
    }
  }
Beispiel #7
0
 protected void buildPreds() {
   buildPredecessor(mainPegChain);
   Set maps = getStartToThread().entrySet();
   for (Iterator iter = maps.iterator(); iter.hasNext(); ) {
     Map.Entry entry = (Map.Entry) iter.next();
     List runMethodChainList = (List) entry.getValue();
     Iterator it = runMethodChainList.iterator();
     while (it.hasNext()) {
       Chain chain = (Chain) it.next();
       //	System.out.println("chain is null: "+(chain == null));
       buildPredecessor(chain);
     }
   }
 }
Beispiel #8
0
 /** Returns a string representation of this <code>ThrowableSet</code>. */
 public String toString() {
   StringBuffer buffer = new StringBuffer(this.toBriefString());
   buffer.append(":\n  ");
   for (Iterator i = exceptionsIncluded.iterator(); i.hasNext(); ) {
     buffer.append('+');
     Object o = i.next();
     buffer.append(o == null ? "null" : o.toString());
     // buffer.append(i.next().toString());
   }
   for (Iterator i = exceptionsExcluded.iterator(); i.hasNext(); ) {
     buffer.append('-');
     buffer.append(i.next().toString());
   }
   return buffer.toString();
 }
Beispiel #9
0
  protected void testStartToThread() {
    System.out.println("=====test startToThread ");
    Set maps = startToThread.entrySet();
    for (Iterator iter = maps.iterator(); iter.hasNext(); ) {
      Map.Entry entry = (Map.Entry) iter.next();
      JPegStmt key = (JPegStmt) entry.getKey();
      Tag tag = (Tag) key.getTags().get(0);
      System.out.println("---key=  " + tag + " " + key);
      /*	    List list = (List)entry.getValue();
      if (list.size()>0){

      System.out.println("**thread set:");
      Iterator it = list.iterator();
      while (it.hasNext()){
      Chain chain =(Chain)it.next();
      Iterator chainIt = chain.iterator();

      System.out.println("the size of chain is: "+chain.size());
      while (chainIt.hasNext()){
      JPegStmt stmt = (JPegStmt)chainIt.next();
      System.out.println(stmt);
      }
      }
      }
      */
    }
    System.out.println("=========startToThread--ends--------");
  }
Beispiel #10
0
  private void insertAfter(JPegStmt node, JPegStmt after) {
    // System.out.println("node: "+node);
    // System.out.println("after: "+after);
    //		System.out.println("succs of node: "+getSuccsOf(node));

    // this must be done first because the succs of node will be chanaged lately
    List succOfAfter = new ArrayList();
    succOfAfter.addAll(getSuccsOf(node));
    unitToSuccs.put(after, succOfAfter);

    Iterator succsIt = getSuccsOf(node).iterator();
    while (succsIt.hasNext()) {
      Object succ = succsIt.next();
      List pred = getPredsOf(succ);
      pred.remove(node);
      pred.add(after);
    }

    List succOfNode = new ArrayList();
    succOfNode.add(after);
    unitToSuccs.put(node, succOfNode);

    List predOfAfter = new ArrayList();
    predOfAfter.add(node);
    unitToPreds.put(after, predOfAfter);

    //	buildPredecessor(Chain pegChain);
  }
Beispiel #11
0
  /**
   * Utility method used in the construction of {@link UnitGraph}s, to be called only after the
   * unitToPreds and unitToSuccs maps have been built.
   *
   * <p><code>UnitGraph</code> provides an implementation of <code>buildHeadsAndTails()</code> which
   * defines the graph's set of heads to include the first {@link Unit} in the graph's body,
   * together with any other <tt>Unit</tt> which has no predecessors. It defines the graph's set of
   * tails to include all <tt>Unit</tt>s with no successors. Subclasses of <code>UnitGraph</code>
   * may override this method to change the criteria for classifying a node as a head or tail.
   */
  protected void buildHeadsAndTails() {
    List tailList = new ArrayList();
    List headList = new ArrayList();

    for (Iterator unitIt = unitChain.iterator(); unitIt.hasNext(); ) {
      Unit s = (Unit) unitIt.next();
      List succs = (List) unitToSuccs.get(s);
      if (succs.size() == 0) {
        tailList.add(s);
      }
      List preds = (List) unitToPreds.get(s);
      if (preds.size() == 0) {
        headList.add(s);
      }
    }

    // Add the first Unit, even if it is the target of
    // a branch.
    Unit entryPoint = (Unit) unitChain.getFirst();
    if (!headList.contains(entryPoint)) {
      headList.add(entryPoint);
    }

    tails = Collections.unmodifiableList(tailList);
    heads = Collections.unmodifiableList(headList);
  }
Beispiel #12
0
    /**
     * Returns a <code>ThrowableSet</code> representing the set of exceptions included in <code>
     * include</code> minus the set of exceptions included in <code>exclude</code>. Creates a new
     * <code>ThrowableSet</code> only if there was not already one whose contents correspond to
     * <code>include</code> - <code>exclude</code>.
     *
     * @param include A set of {@link RefLikeType} objects representing exception types included in
     *     the result; may be <code>null</code> if there are no included types.
     * @param exclude A set of {@link AnySubType} objects representing exception types excluded from
     *     the result; may be <code>null</code> if there are no excluded types.
     * @return a <code>ThrowableSet</code> representing the set of exceptions corresponding to
     *     <code>include</code> - <code>exclude</code>.
     */
    private ThrowableSet registerSetIfNew(Set include, Set exclude) {
      if (INSTRUMENTING) {
        registrationCalls++;
      }
      if (include == null) {
        include = Collections.EMPTY_SET;
      }
      if (exclude == null) {
        exclude = Collections.EMPTY_SET;
      }
      int size = include.size() + exclude.size();
      Integer sizeKey = new Integer(size);

      List sizeList = (List) sizeToSets.get(sizeKey);
      if (sizeList == null) {
        sizeList = new LinkedList();
        sizeToSets.put(sizeKey, sizeList);
      }
      for (Iterator i = sizeList.iterator(); i.hasNext(); ) {
        ThrowableSet set = (ThrowableSet) i.next();
        if (set.exceptionsIncluded.equals(include) && set.exceptionsExcluded.equals(exclude)) {
          return set;
        }
      }
      if (INSTRUMENTING) {
        registeredSets++;
      }
      ThrowableSet result = new ThrowableSet(include, exclude);
      sizeList.add(result);
      return result;
    }
Beispiel #13
0
  protected int processModifiers(List l) {
    int modifier = 0;
    Iterator it = l.iterator();

    while (it.hasNext()) {
      Object t = it.next();
      if (t instanceof AAbstractModifier) modifier |= Modifier.ABSTRACT;
      else if (t instanceof AFinalModifier) modifier |= Modifier.FINAL;
      else if (t instanceof ANativeModifier) modifier |= Modifier.NATIVE;
      else if (t instanceof APublicModifier) modifier |= Modifier.PUBLIC;
      else if (t instanceof AProtectedModifier) modifier |= Modifier.PROTECTED;
      else if (t instanceof APrivateModifier) modifier |= Modifier.PRIVATE;
      else if (t instanceof AStaticModifier) modifier |= Modifier.STATIC;
      else if (t instanceof ASynchronizedModifier) modifier |= Modifier.SYNCHRONIZED;
      else if (t instanceof ATransientModifier) modifier |= Modifier.TRANSIENT;
      else if (t instanceof AVolatileModifier) modifier |= Modifier.VOLATILE;
      else if (t instanceof AEnumModifier) modifier |= Modifier.ENUM;
      else if (t instanceof AAnnotationModifier) modifier |= Modifier.ANNOTATION;
      else
        throw new RuntimeException(
            "Impossible: modifier unknown - Have you added a new modifier and not updated this file?");
    }

    return modifier;
  }
Beispiel #14
0
  protected void testPegChain(Chain chain) {
    System.out.println("******** chain********");
    Iterator it = chain.iterator();
    while (it.hasNext()) {
      /*Object o = it.next();
      System.out.println(o);
      if (!(o instanceof JPegStmt))  System.out.println("not instanceof JPegStmt: "+o);
      JPegStmt s = (JPegStmt)o;
      */
      JPegStmt stmt = (JPegStmt) it.next();
      System.out.println(stmt.toString());
      /*if (stmt.getName().equals("start")){

      System.out.println("find start method in : " + stmt.toString() );
      List list =(List)startToThread.get(stmt);
      Iterator chainIt = list.iterator();
      while (chainIt.hasNext()){
      Chain chain = (Chain)chainIt.next();
      Iterator subit = chain.iterator();
      while (subit.hasNext()){
      System.out.println("**" + ((JPegStmt)subit.next()).toString());
      }
      }
      System.out.println("$$$$$$returing to main chain");
      }
      */
    }
  }
 public void go() {
   Iterator methods = cg.sourceMethods();
   while (methods.hasNext()) {
     SootMethod m = (SootMethod) methods.next();
     dfsVisit(m);
   }
 }
Beispiel #16
0
 protected void testList(List list) {
   //		System.out.println("test list");
   Iterator listIt = list.iterator();
   while (listIt.hasNext()) {
     System.out.println(listIt.next());
   }
 }
Beispiel #17
0
  /**
   * Utility method that produces a new map from the {@link Unit}s of this graph's body to the union
   * of the values stored in the two argument {@link Map}s, used to combine the maps of exceptional
   * and unexceptional predecessors and successors into maps of all predecessors and successors. The
   * values stored in both argument maps must be {@link List}s of {@link Unit}s, which are assumed
   * not to contain any duplicate <tt>Unit</tt>s.
   *
   * @param mapA The first map to be combined.
   * @param mapB The second map to be combined.
   */
  protected Map combineMapValues(Map mapA, Map mapB) {
    // The duplicate screen
    Map result = new HashMap(mapA.size() * 2 + 1, 0.7f);
    for (Iterator chainIt = unitChain.iterator(); chainIt.hasNext(); ) {
      Unit unit = (Unit) chainIt.next();
      List listA = (List) mapA.get(unit);
      if (listA == null) {
        listA = Collections.EMPTY_LIST;
      }
      List listB = (List) mapB.get(unit);
      if (listB == null) {
        listB = Collections.EMPTY_LIST;
      }

      int resultSize = listA.size() + listB.size();
      if (resultSize == 0) {
        result.put(unit, Collections.EMPTY_LIST);
      } else {
        List resultList = new ArrayList(resultSize);
        Iterator listIt = null;
        // As a minor optimization of the duplicate screening,
        // copy the longer list first.
        if (listA.size() >= listB.size()) {
          resultList.addAll(listA);
          listIt = listB.iterator();
        } else {
          resultList.addAll(listB);
          listIt = listA.iterator();
        }
        while (listIt.hasNext()) {
          Object element = listIt.next();
          // It is possible for there to be both an exceptional
          // and an unexceptional edge connecting two Units
          // (though probably not in a class generated by
          // javac), so we need to screen for duplicates. On the
          // other hand, we expect most of these lists to have
          // only one or two elements, so it doesn't seem worth
          // the cost to build a Set to do the screening.
          if (!resultList.contains(element)) {
            resultList.add(element);
          }
        }
        result.put(unit, Collections.unmodifiableList(resultList));
      }
    }
    return result;
  }
Beispiel #18
0
 public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
   Unit u = Baf.v().newLoadInst(getType(), context.getBafLocalOfJimpleLocal(this));
   out.add(u);
   Iterator it = context.getCurrentUnit().getTags().iterator();
   while (it.hasNext()) {
     u.addTag((Tag) it.next());
   }
 }
Beispiel #19
0
 // helper function
 protected void testIterator() {
   System.out.println("********begin test iterator*******");
   Iterator testIt = iterator();
   while (testIt.hasNext()) {
     System.out.println(testIt.next());
   }
   System.out.println("********end test iterator*******");
   System.out.println("=======size is: " + size());
 }
Beispiel #20
0
  public void convertToBaf(JimpleToBafContext context, List out) {
    Unit u = Baf.v().newStaticGetInst(fieldRef);
    out.add(u);

    Iterator it = context.getCurrentUnit().getTags().iterator();
    while (it.hasNext()) {
      u.addTag((Tag) it.next());
    }
  }
 private void dfsVisit(SootMethod m) {
   if (visited.contains(m)) return;
   visited.add(m);
   Iterator targets = new Targets(cg.edgesOutOf(m));
   while (targets.hasNext()) {
     SootMethod target = (SootMethod) targets.next();
     dfsVisit(target);
   }
   order.add(m);
 }
Beispiel #22
0
 protected void testSet(Set set, String name) {
   System.out.println("$test set " + name);
   Iterator setIt = set.iterator();
   while (setIt.hasNext()) {
     Object s = setIt.next();
     // JPegStmt s = (JPegStmt)setIt.next();
     // Tag tag = (Tag)s.getTags().get(0);
     System.out.println(s);
   }
 }
Beispiel #23
0
  /**
   * Utility method for <tt>UnitGraph</tt> constructors. It computes the edges corresponding to
   * unexceptional control flow.
   *
   * @param unitToSuccs A {@link Map} from {@link Unit}s to {@link List}s of {@link Unit}s. This is
   *     an ``out parameter''; callers must pass an empty {@link Map}.
   *     <tt>buildUnexceptionalEdges</tt> will add a mapping for every <tt>Unit</tt> in the body to
   *     a list of its unexceptional successors.
   * @param unitToPreds A {@link Map} from {@link Unit}s to {@link List}s of {@link Unit}s. This is
   *     an ``out parameter''; callers must pass an empty {@link Map}.
   *     <tt>buildUnexceptionalEdges</tt> will add a mapping for every <tt>Unit</tt> in the body to
   *     a list of its unexceptional predecessors.
   */
  protected void buildUnexceptionalEdges(Map unitToSuccs, Map unitToPreds) {

    // Initialize the predecessor sets to empty
    for (Iterator unitIt = unitChain.iterator(); unitIt.hasNext(); ) {
      unitToPreds.put(unitIt.next(), new ArrayList());
    }

    Iterator unitIt = unitChain.iterator();
    Unit currentUnit, nextUnit;

    nextUnit = unitIt.hasNext() ? (Unit) unitIt.next() : null;

    while (nextUnit != null) {
      currentUnit = nextUnit;
      nextUnit = unitIt.hasNext() ? (Unit) unitIt.next() : null;

      List successors = new ArrayList();

      if (currentUnit.fallsThrough()) {
        // Add the next unit as the successor
        if (nextUnit != null) {
          successors.add(nextUnit);
          ((List) unitToPreds.get(nextUnit)).add(currentUnit);
        }
      }

      if (currentUnit.branches()) {
        for (Iterator targetIt = currentUnit.getUnitBoxes().iterator(); targetIt.hasNext(); ) {
          Unit target = ((UnitBox) targetIt.next()).getUnit();
          // Arbitrary bytecode can branch to the same
          // target it falls through to, so we screen for duplicates:
          if (!successors.contains(target)) {
            successors.add(target);
            ((List) unitToPreds.get(target)).add(currentUnit);
          }
        }
      }

      // Store away successors
      unitToSuccs.put(currentUnit, successors);
    }
  }
Beispiel #24
0
  /** Returns a list of possible targets for the given method and set of receiver types. */
  public List resolveAbstractDispatch(List classes, SootMethod m) {
    m.getDeclaringClass().checkLevel(SootClass.HIERARCHY);
    ArraySet s = new ArraySet();
    Iterator classesIt = classes.iterator();

    while (classesIt.hasNext()) s.addAll(resolveAbstractDispatch((SootClass) classesIt.next(), m));

    List l = new ArrayList();
    l.addAll(s);
    return Collections.unmodifiableList(l);
  }
Beispiel #25
0
 protected void testUnitToPeg(HashMap unitToPeg) {
   System.out.println("=====test unitToPeg ");
   Set maps = unitToPeg.entrySet();
   for (Iterator iter = maps.iterator(); iter.hasNext(); ) {
     Map.Entry entry = (Map.Entry) iter.next();
     System.out.println("---key=  " + entry.getKey());
     JPegStmt s = (JPegStmt) entry.getValue();
     System.out.println("--value= " + s);
   }
   System.out.println("=========unitToPeg--ends--------");
 }
Beispiel #26
0
 /**
  * Utility method that replaces the values of a {@link Map}, which must be instances of {@link
  * List}, with unmodifiable equivalents.
  *
  * @param map The map whose values are to be made unmodifiable.
  */
 protected static void makeMappedListsUnmodifiable(Map map) {
   for (Iterator it = map.entrySet().iterator(); it.hasNext(); ) {
     Map.Entry entry = (Map.Entry) it.next();
     List value = (List) entry.getValue();
     if (value.size() == 0) {
       entry.setValue(Collections.EMPTY_LIST);
     } else {
       entry.setValue(Collections.unmodifiableList(value));
     }
   }
 }
Beispiel #27
0
  public void testWaitingNodes() {
    System.out.println("------waiting---begin");
    Set maps = waitingNodes.entrySet();
    for (Iterator iter = maps.iterator(); iter.hasNext(); ) {
      Map.Entry entry = (Map.Entry) iter.next();
      System.out.println("---key=  " + entry.getKey());
      FlowSet fs = (FlowSet) entry.getValue();
      if (fs.size() > 0) {

        System.out.println("**waiting nodes set:");
        Iterator it = fs.iterator();
        while (it.hasNext()) {
          JPegStmt unit = (JPegStmt) it.next();

          System.out.println(unit.toString());
        }
      }
    }
    System.out.println("------------waitingnodes---ends--------");
  }
Beispiel #28
0
 public String toString() {
   Iterator it = unitChain.iterator();
   StringBuffer buf = new StringBuffer();
   while (it.hasNext()) {
     Unit u = (Unit) it.next();
     buf.append("// preds: " + getPredsOf(u) + "\n");
     buf.append(u.toString() + '\n');
     buf.append("// succs " + getSuccsOf(u) + "\n");
   }
   return buf.toString();
 }
Beispiel #29
0
 protected void testSynch() {
   Iterator<List> it = synch.iterator();
   System.out.println("========test synch======");
   while (it.hasNext()) {
     // JPegStmt s = (JPegStmt)it.next();
     // Tag tag = (Tag)s.getTags().get(0);
     // System.out.println(tag+" "+s);
     System.out.println(it.next());
   }
   System.out.println("========end test synch======");
 }
Beispiel #30
0
  public boolean addPeg(PegGraph pg, Chain chain) {
    if (!pg.removeBeginNode()) return false;
    //		System.out.println("adding one peg into another");

    //		System.out.println("after removeBeginNode===");
    //	pg.testPegChain();
    // System.out.println(pg);

    // put every node of peg into this
    Iterator mainIt = pg.mainIterator();

    while (mainIt.hasNext()) {
      JPegStmt s = (JPegStmt) mainIt.next();
      //			System.out.println("add to mainPegChain: "+s);
      mainPegChain.addLast(s);
      //			if (chain.contains(s)){
      //				System.err.println("error! chain contains: "+s);
      //				System.exit(1);
      //			}
      //			else
      //				chain.addLast(s);

    }
    Iterator it = pg.iterator();
    while (it.hasNext()) {
      JPegStmt s = (JPegStmt) it.next();
      // System.out.println("add to allNodes: "+s);
      if (allNodes.contains(s)) {
        System.err.println("error! allNodes contains: " + s);
        System.exit(1);
      } else allNodes.add(s);
    }
    //	testPegChain();
    //	testIterator();
    unitToSuccs.putAll(pg.getUnitToSuccs());
    unitToPreds.putAll(pg.getUnitToPreds());
    //	testUnitToSucc();
    // testUnitToPred();
    //		buildMaps(pg); // RLH
    return true;
  }