Package org.jreversepro.ast.expression

Examples of org.jreversepro.ast.expression.ArrayInstantiationExpression


   * net.sf.jrevpro.decompile.evaluator.AbstractInstructionEvaluator#evaluate
   * (net.sf.jrevpro.reflect.instruction.Instruction)
   */
  @Override
  void evaluate(Instruction ins) {
    ArrayInstantiationExpression expr = null;
    switch (ins.opcode) {
    case OPCODE_NEWARRAY: {
      int atype = ins.getArgByte();
      Expression arraySize = evalMachine.pop();
      char jvmtype = JVM_TYPE_UNDEFINED;

      switch (atype) {
      case 4:
        jvmtype = JVM_TYPE_BOOLEAN;
        break;
      case 5:
        jvmtype = JVM_TYPE_CHAR;
        break;
      case 6:
        jvmtype = JVM_TYPE_FLOAT;
        break;
      case 7:
        jvmtype = JVM_TYPE_DOUBLE;
        break;
      case 8:
        jvmtype = JVM_TYPE_BYTE;
        break;
      case 9:
        jvmtype = JVM_TYPE_SHORT;
        break;
      case 10:
        jvmtype = JVM_TYPE_INT;
        break;
      case 11:
        jvmtype = JVM_TYPE_LONG;
        break;
      default:
        throw new UnsupportedOperationException("Type  " + atype
            + " not supported as argument of opcode OPCODE_NEWARRAY");
      }
      expr = new ArrayInstantiationExpression(jvmtype, arraySize);
      break;
    }
    case OPCODE_ANEWARRAY: {
      int offset = ins.getArgUnsignedShort();
      String classType = pool.getClassName(offset);

      Expression arraySize1 = evalMachine.pop();
      expr = new ArrayInstantiationExpression(classType, arraySize1);
      break;
    }
    case OPCODE_MULTIANEWARRAY: {
      int offset = ins.getArgUnsignedShort();

      // Dimensions. Max 255.
      int dimensions = ins.getArgUnsignedByte(2);
      if (dimensions > 255) {
        throw new IllegalArgumentException(
            "OPCODE_MULTIANEWARRAY: Max. Number of dimensions is 255. Received "
                + dimensions);
      }
      Expression arrayIndices[] = new Expression[dimensions];

      // ClassType
      String classType = TypeInferrer.getJLSType(pool.getClassName(offset),
          false);

      // Get all array indices
      for (int i = dimensions - 1; i >= 0; i--) {
        arrayIndices[i] = evalMachine.pop();
      }
      expr = new ArrayInstantiationExpression(classType, Arrays
          .asList(arrayIndices));
    }

    }
    evalMachine.push(expr);
View Full Code Here

TOP

Related Classes of org.jreversepro.ast.expression.ArrayInstantiationExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.