Beispiel #1
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();
  }
Beispiel #2
0
  public String toString() {
    StringBuffer b = new StringBuffer();

    b.append(label_toString());

    b.append("switch (");
    b.append(get_Key());
    b.append(")");
    b.append(NEWLINE);

    b.append("{");
    b.append(NEWLINE);

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

      Object index = it.next();

      b.append(TAB);

      if (index instanceof String) b.append("default");
      else {
        b.append("case ");
        b.append(((Integer) index).toString());
      }

      b.append(":");
      b.append(NEWLINE);

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

      if (subBody != null) {
        b.append(body_toString(subBody));

        if (it.hasNext()) b.append(NEWLINE);
      }
    }

    b.append("}");
    b.append(NEWLINE);

    return b.toString();
  }
Beispiel #3
0
  public void replaceIndex2BodyList(Map<Object, List<Object>> index2BodyList) {
    this.index2BodyList = index2BodyList;

    subBodies = new ArrayList<Object>();
    Iterator<Object> it = indexList.iterator();
    while (it.hasNext()) {
      List body = index2BodyList.get(it.next());

      if (body != null) subBodies.add(body);
    }
  }
Beispiel #4
0
  public ASTSwitchNode(
      SETNodeLabel label,
      Value key,
      List<Object> indexList,
      Map<Object, List<Object>> index2BodyList) {
    super(label);

    this.keyBox = Jimple.v().newRValueBox(key);
    this.indexList = indexList;
    this.index2BodyList = index2BodyList;

    Iterator<Object> it = indexList.iterator();
    while (it.hasNext()) {
      List body = index2BodyList.get(it.next());

      if (body != null) subBodies.add(body);
    }
  }