Esempio n. 1
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();
      }
    }
  }
Esempio n. 2
0
  public void toString(UnitPrinter up) {
    up.literal("new");
    up.literal(" ");
    up.type(getBaseType().baseType);
    for (ValueBox element : sizeBoxes) {
      up.literal("[");
      element.toString(up);
      up.literal("]");
    }

    for (int i = getSizeCount(); i < getBaseType().numDimensions; i++) up.literal("[]");
  }
  public void toString(UnitPrinter up) {
    up.literal(Jimple.v().STATICINVOKE);
    up.literal(" ");
    up.methodRef(methodRef);
    up.literal("(");

    for (int i = 0; i < argBoxes.size(); i++) {
      if (i != 0) up.literal(", ");

      getArgBox(i).toString(up);
    }

    up.literal(")");
  }
Esempio n. 4
0
 public void toString(UnitPrinter up) {
   up.local(this);
 }
Esempio n. 5
0
 public void toString(UnitPrinter up) {
   up.fieldRef(fieldRef);
 }
Esempio n. 6
0
  public void toString(UnitPrinter up) {
    label_toString(up);

    up.literal("switch");
    up.literal(" ");
    up.literal("(");
    keyBox.toString(up);
    up.literal(")");
    up.newline();

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

    Iterator<Object> it = indexList.iterator();
    while (it.hasNext()) {

      Object index = it.next();

      up.incIndent();

      if (index instanceof String) up.literal("default");
      else {
        up.literal("case");
        up.literal(" ");
        up.literal(index.toString());
      }

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

      List<Object> subBody = index2BodyList.get(index);

      if (subBody != null) {
        up.incIndent();
        body_toString(up, subBody);

        if (it.hasNext()) up.newline();
        up.decIndent();
      }
      up.decIndent();
    }

    up.literal("}");
    up.newline();
  }
Esempio n. 7
0
 public void toString(UnitPrinter up) {
   up.startValueBox(this);
   value.toString(up);
   up.endValueBox(this);
 }
Esempio n. 8
0
 public void toString(UnitPrinter up) {
   up.literal(Jimple.THROW);
   up.literal(" ");
   opBox.toString(up);
 }