Ejemplo n.º 1
0
  public void outALookupswitchStatement(ALookupswitchStatement node) {
    List lookupValues = new ArrayList();
    List targets = new ArrayList();
    UnitBox defaultTarget = null;

    if (node.getCaseStmt() != null) {
      int size = node.getCaseStmt().size();

      for (int i = 0; i < size; i++) {
        Object valueTargetPair = mProductions.removeLast();
        if (valueTargetPair instanceof UnitBox) {
          if (defaultTarget != null)
            throw new RuntimeException("error: can't ;have more than 1 default stmt");

          defaultTarget = (UnitBox) valueTargetPair;
        } else {
          Object[] pair = (Object[]) valueTargetPair;

          lookupValues.add(0, pair[0]);
          targets.add(0, pair[1]);
        }
      }
    } else {
      throw new RuntimeException("error: switch stmt has no case stmts");
    }

    Value key = (Value) mProductions.removeLast();
    Unit switchStmt = Jimple.v().newLookupSwitchStmt(key, lookupValues, targets, defaultTarget);

    mProductions.addLast(switchStmt);
  }
Ejemplo n.º 2
0
  private void addBoxToPatch(String aLabelName, UnitBox aUnitBox) {
    List patchList = (List) mLabelToPatchList.get(aLabelName);
    if (patchList == null) {
      patchList = new ArrayList();
      mLabelToPatchList.put(aLabelName, patchList);
    }

    patchList.add(aUnitBox);
  }
Ejemplo n.º 3
0
  public void outADeclaration(ADeclaration node) {
    List localNameList = (List) mProductions.removeLast();
    Type type = (Type) mProductions.removeLast();
    Iterator it = localNameList.iterator();
    List localList = new ArrayList();

    while (it.hasNext()) {
      Local l = Jimple.v().newLocal((String) it.next(), type);
      mLocals.put(l.getName(), l);
      localList.add(l);
    }
    mProductions.addLast(localList);
  }
Ejemplo n.º 4
0
  /*
    throws_clause =
    throws class_name_list;
  */
  public void outAThrowsClause(AThrowsClause node) {
    List l = (List) mProductions.removeLast();

    Iterator it = l.iterator();
    List exceptionClasses = new ArrayList(l.size());

    while (it.hasNext()) {
      String className = (String) it.next();

      exceptionClasses.add(mResolver.makeClassRef(className));
    }

    mProductions.addLast(exceptionClasses);
  }
Ejemplo n.º 5
0
  public void outAMultiNewExpr(AMultiNewExpr node) {

    LinkedList arrayDesc = node.getArrayDescriptor();

    int descCnt = arrayDesc.size();
    List sizes = new LinkedList();

    Iterator it = arrayDesc.iterator();
    while (it.hasNext()) {
      AArrayDescriptor o = (AArrayDescriptor) it.next();
      if (o.getImmediate() != null) sizes.add(0, (Value) mProductions.removeLast());
      else break;
    }

    Type type = (Type) mProductions.removeLast();
    ArrayType arrayType = ArrayType.v(type, descCnt);

    mProductions.addLast(Jimple.v().newNewMultiArrayExpr(arrayType, sizes));
  }
Ejemplo n.º 6
0
  public void outATableswitchStatement(ATableswitchStatement node) {
    List targets = new ArrayList();
    UnitBox defaultTarget = null;

    int lowIndex = 0, highIndex = 0;

    if (node.getCaseStmt() != null) {
      int size = node.getCaseStmt().size();

      for (int i = 0; i < size; i++) {
        Object valueTargetPair = mProductions.removeLast();
        if (valueTargetPair instanceof UnitBox) {
          if (defaultTarget != null)
            throw new RuntimeException("error: can't ;have more than 1 default stmt");

          defaultTarget = (UnitBox) valueTargetPair;
        } else {
          Object[] pair = (Object[]) valueTargetPair;

          if ((i == 0 && defaultTarget == null) || (i == 1 && defaultTarget != null))
            highIndex = ((IntConstant) pair[0]).value;
          if (i == (size - 1)) lowIndex = ((IntConstant) pair[0]).value;

          targets.add(0, pair[1]);
        }
      }
    } else {
      throw new RuntimeException("error: switch stmt has no case stmts");
    }

    Value key = (Value) mProductions.removeLast();
    Unit switchStmt =
        Jimple.v().newTableSwitchStmt(key, lowIndex, highIndex, targets, defaultTarget);

    mProductions.addLast(switchStmt);
  }
Ejemplo n.º 7
0
 public void outAMultiLocalNameList(AMultiLocalNameList node) {
   List l = (List) mProductions.removeLast();
   l.add(0, (String) mProductions.removeLast());
   mProductions.addLast(l);
 }
Ejemplo n.º 8
0
 public void outASingleLocalNameList(ASingleLocalNameList node) {
   List l = new ArrayList();
   l.add((String) mProductions.removeLast());
   mProductions.addLast(l);
 }
Ejemplo n.º 9
0
 public void outAMultiArgList(AMultiArgList node) {
   List l = (List) mProductions.removeLast();
   l.add(0, (Value) mProductions.removeLast());
   mProductions.addLast(l);
 }
Ejemplo n.º 10
0
  /*
    arg_list =
    {single} immediate |
    {multi}  immediate comma arg_list;
  */
  public void outASingleArgList(ASingleArgList node) {
    List l = new ArrayList();

    l.add((Value) mProductions.removeLast());
    mProductions.addLast(l);
  }
Ejemplo n.º 11
0
 public void outAMultiParameterList(AMultiParameterList node) {
   List l = (List) mProductions.removeLast();
   l.add(0, (Type) mProductions.removeLast());
   mProductions.addLast(l);
 }
Ejemplo n.º 12
0
 public void outASingleParameterList(ASingleParameterList node) {
   List l = new ArrayList();
   l.add((Type) mProductions.removeLast());
   mProductions.addLast(l);
 }