Package bytecodeparser.analysis.stack.Constant

Examples of bytecodeparser.analysis.stack.Constant.IntegerConstant


  public void simulate(Stack stack) {
    int size = -1;
    if(dimensions == 1) {
      StackElement se = stack.pop();
      if(se instanceof IntegerConstant) {
        IntegerConstant ic = (IntegerConstant) se;
        size = ic.getValue();
      }
    } else {
      for(int i = 0; i < dimensions; i++)
        stack.pop();
    }
View Full Code Here


  public void simulate(Stack stack) {
    ConstantPushOpcode cpop = this.op.as(ConstantPushOpcode.class);
    if(cpop.getParameterTypes().length == 0) {
      switch(cpop.baseCode) {
        case Opcode.ICONST_0:
          stack.push(new IntegerConstant(cpop.getCode() - cpop.baseCode));
          break;
        case Opcode.LCONST_0:
          stack.push2(new LongConstant(new Long(new Integer(cpop.getCode() - cpop.baseCode))));
          break;
        case Opcode.FCONST_0:
          stack.push(new FloatConstant(new Float(cpop.getCode() - cpop.baseCode)));
          break;
        case Opcode.DCONST_0:
          stack.push2(new DoubleConstant(new Double(cpop.getCode() - cpop.baseCode)));
          break;
        default:
          throw new RuntimeException("unsupported basecode=" + cpop.baseCode + "(" + cpop.getName() + ")");
      }
    } else {
      OpParameterType type = cpop.getParameterTypes()[0];
      int value = cpop.decode(context, index).parameterValues[0];
      if(type == OpParameterType.S1 || type == OpParameterType.S2) {
        for(int i = 0; i < getPops().length; i++) {
          stack.pop(getPops()[i]);
        }
        stack.push(new IntegerConstant(cpop.decode(context, index).parameterValues[0]));
      } else if(type == OpParameterType.U1 || type == OpParameterType.U2) {
        Object o = context.behavior.getMethodInfo().getConstPool().getLdcValue(value);
        if(o == null) {
          ConstPool cp = context.behavior.getMethodInfo().getConstPool();
          for(Method m : ConstPool.class.getDeclaredMethods()) {
            if(m.getName().equals("getItem")) {
              m.setAccessible(true);
              try {
                Object _o = m.invoke(cp, new Integer(value));
                stack.push(new WhateverConstant(_o));
              } catch (Exception e) {
                throw new RuntimeException(e);
              }
            }
          }
          return;
        }
        if(pushes[0].equals(StackElementLength.DOUBLE) && !(o instanceof Long) && !(o instanceof Double))
          throw new RuntimeException("Constant push of type " + op.getName() + " should push a double-size element but is not! (o = " + o + ")");
        if(o instanceof Integer)
          stack.push(new IntegerConstant((Integer)o));
        else if(o instanceof Long)
          stack.push2(new LongConstant((Long)o));
        else if(o instanceof Float)
          stack.push(new FloatConstant((Float)o));
        else if(o instanceof Double)
View Full Code Here

TOP

Related Classes of bytecodeparser.analysis.stack.Constant.IntegerConstant

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.