Package zz.jinterp.JPrimitive

Examples of zz.jinterp.JPrimitive.JInt


 
    public static int __floatToRawIntBits(float value) { return 0; }
  public JObject _floatToRawIntBits(JFrame aParentFrame, JInstance aTarget, JObject[] aArgs)
  {
    JFloat value = (JFloat) aArgs[0];
    return new JInt(Float.floatToRawIntBits(value.v));
  }
View Full Code Here


  public static int __floatToIntBits(float value) { return 0; }
  public JObject _floatToIntBits(JFrame aParentFrame, JInstance aTarget, JObject[] aArgs)
  {
    JFloat value = (JFloat) aArgs[0];
    return new JInt(Float.floatToIntBits(value.v));
  }
View Full Code Here

  }

  public static float __intBitsToFloat(int bits) { return 0; }
  public JObject _intBitsToFloat(JFrame aParentFrame, JInstance aTarget, JObject[] aArgs)
  {
    JInt bits = (JInt) aArgs[0];
    return new JFloat(Float.intBitsToFloat(bits.v));
  }
View Full Code Here

 
  public static void __arraycopy(Object src, int srcPos, Object dest, int destPos, int length) {}
  public JObject _arraycopy(JFrame aParentFrame, JInstance aTarget, JObject[] aArgs)
  {
    JArray src = (JArray) aArgs[0];
    JInt srcPos = (JInt) aArgs[1];
    JArray dest = (JArray) aArgs[2];
    JInt destPos = (JInt) aArgs[3];
    JInt len = (JInt) aArgs[4];
   
    for(int i=0;i<len.v;i++) dest.set(i+destPos.v, src.get(i+srcPos.v));
   
    return JPrimitive.VOID;
  }
View Full Code Here

    }

    @Override
    public void visitIincInsn(int aVar, int aIncrement)
    {
      JInt i = (JInt) local(aVar);
      local(aVar, new JInt(i.v+aIncrement));
      itsInstructionPointer++;
    }
View Full Code Here

      case DALOAD:
      case AALOAD:
      case BALOAD:
      case CALOAD:
      case SALOAD: {
        JInt index = (JInt) pop();
        JArray array = (JArray) pop();
        push(array.get(index.v));
      } break;
       
      case IASTORE:
      case LASTORE:
      case FASTORE:
      case DASTORE:
      case AASTORE: {
        JObject value = pop();
        JInt index = (JInt) pop();
        JArray array = (JArray) pop();
        array.set(index.v, value);
      } break;
       
      case BASTORE: {
        JPrimitive value = (JPrimitive) pop();
        JInt index = (JInt) pop();
        JArray array = (JArray) pop();
        array.set(index.v, new JByte((byte) value.intValue()));
      } break;
     
      case CASTORE: {
        JPrimitive value = (JPrimitive) pop();
        JInt index = (JInt) pop();
        JArray array = (JArray) pop();
        array.set(index.v, new JChar((char) value.intValue()));
      } break;
     
      case SASTORE: {
        JPrimitive value = (JPrimitive) pop();
        JInt index = (JInt) pop();
        JArray array = (JArray) pop();
        array.set(index.v, new JShort((short) value.intValue()));
      } break;
       
      case POP:
        pop();
        break;
       
      case POP2:
        throw new UnsupportedOperationException();
       
      case DUP: {
        JObject o = pop();
        push(o);
        push(o);
      } break;
       
      case DUP_X1: {
        JObject o1 = pop();
        JObject o2 = pop();
        push(o1);
        push(o2);
        push(o1);
      } break;
       
      case DUP_X2:
        throw new UnsupportedOperationException();
       
      case DUP2:
        throw new UnsupportedOperationException();
       
      case DUP2_X1:
        throw new UnsupportedOperationException();
       
      case DUP2_X2:
        throw new UnsupportedOperationException();
       
      case SWAP: {
        JObject o1 = pop();
        JObject o2 = pop();
        push(o1);
        push(o2);
      } break;
       
      case IADD:
      case LADD:
      case FADD:
      case DADD: {
        JNumber n2 = (JNumber) pop();
        JNumber n1 = (JNumber) pop();
        push(n1.add(n2));
      } break;
       
      case ISUB:
      case LSUB:
      case FSUB:
      case DSUB: {
        JNumber n2 = (JNumber) pop();
        JNumber n1 = (JNumber) pop();
        push(n1.sub(n2));
      } break;
       
      case IMUL:
      case LMUL:
      case FMUL:
      case DMUL: {
        JNumber n2 = (JNumber) pop();
        JNumber n1 = (JNumber) pop();
        push(n1.mul(n2));
      } break;
       
      case IDIV:
      case LDIV:
      case FDIV:
      case DDIV: {
        JNumber n2 = (JNumber) pop();
        JNumber n1 = (JNumber) pop();
        push(n1.div(n2));
      } break;
       
      case IREM:
      case LREM:
      case FREM:
      case DREM: {
        JNumber n2 = (JNumber) pop();
        JNumber n1 = (JNumber) pop();
        push(n1.rem(n2));
      } break;
       
      case INEG:
      case LNEG:
      case FNEG:
      case DNEG: {
        JNumber n = (JNumber) pop();
        push(n.neg());
      } break;
       
      case ISHL:
      case LSHL: {
        JInt n2 = (JInt) pop();
        JBitNumber n1 = (JBitNumber) pop();
        push(n1.shl(n2.v));
      } break;
       
      case ISHR:
      case LSHR: {
        JInt n2 = (JInt) pop();
        JBitNumber n1 = (JBitNumber) pop();
        push(n1.shr(n2.v));
      } break;
       
      case IUSHR:
      case LUSHR: {
        JInt n2 = (JInt) pop();
        JBitNumber n1 = (JBitNumber) pop();
        push(n1.ushr(n2.v));
      } break;
       
      case IAND:
      case LAND: {
        JBitNumber n2 = (JBitNumber) pop();
        JBitNumber n1 = (JBitNumber) pop();
        push(n1.and(n2));
      } break;
       
      case IOR:
      case LOR: {
        JBitNumber n2 = (JBitNumber) pop();
        JBitNumber n1 = (JBitNumber) pop();
        push(n1.or(n2));
      } break;
       
      case IXOR:
      case LXOR: {
        JBitNumber n2 = (JBitNumber) pop();
        JBitNumber n1 = (JBitNumber) pop();
        push(n1.xor(n2));
      } break;
       
      case I2L: {
        JInt i = (JInt) pop();
        push(new JLong(i.v));
      } break;
       
      case I2F: {
        JInt i = (JInt) pop();
        push(new JFloat(i.v));
      } break;
       
      case I2D: {
        JInt i = (JInt) pop();
        push(new JDouble(i.v));
      } break;
       
      case L2I: {
        JLong i = (JLong) pop();
        push(new JInt((int) i.v));
      } break;
       
      case L2F: {
        JLong i = (JLong) pop();
        push(new JFloat(i.v));
      } break;
       
      case L2D: {
        JLong i = (JLong) pop();
        push(new JDouble(i.v));
      } break;
       
      case F2I: {
        JFloat i = (JFloat) pop();
        push(new JInt((int) i.v));
      } break;
       
      case F2L: {
        JFloat i = (JFloat) pop();
        push(new JLong((long) i.v));
      } break;
       
      case F2D: {
        JFloat i = (JFloat) pop();
        push(new JDouble(i.v));
      } break;
       
      case D2I: {
        JDouble i = (JDouble) pop();
        push(new JInt((int) i.v));
      } break;
       
      case D2L: {
        JDouble i = (JDouble) pop();
        push(new JLong((long) i.v));
      } break;
       
      case D2F: {
        JDouble i = (JDouble) pop();
        push(new JFloat((float) i.v));
      } break;
       
      case I2B: {
        JInt i = (JInt) pop();
        push(new JByte((byte) i.v));
      } break;
       
      case I2C: {
        JInt i = (JInt) pop();
        push(new JChar((char) i.v));
      } break;
       
      case I2S: {
        JInt i = (JInt) pop();
        push(new JShort((short) i.v));
      } break;
       
      case LCMP: {
        JLong l2 = (JLong) pop();
        JLong l1 = (JLong) pop();
        if (l1.v > l2.v) push(JInt._1);
        else if (l1.v == l2.v) push(JInt._0);
        else push(JInt._M1);
      } break;
       
      case FCMPL: {
        JFloat f2 = (JFloat) pop();
        JFloat f1 = (JFloat) pop();
        if (Float.isNaN(f1.v) || Float.isNaN(f2.v)) push(JInt._M1);
        else if (f1.v > f2.v) push(JInt._1);
        else if (f1.v == f2.v) push(JInt._0);
        else push(JInt._M1);
      } break;
       
      case FCMPG: {
        JFloat f2 = (JFloat) pop();
        JFloat f1 = (JFloat) pop();
        if (Float.isNaN(f1.v) || Float.isNaN(f2.v)) push(JInt._1);
        else if (f1.v > f2.v) push(JInt._1);
        else if (f1.v == f2.v) push(JInt._0);
        else push(JInt._M1);
      } break;
       
      case DCMPL: {
        JDouble d2 = (JDouble) pop();
        JDouble d1 = (JDouble) pop();
        if (Double.isNaN(d1.v) || Double.isNaN(d2.v)) push(JInt._M1);
        else if (d1.v > d2.v) push(JInt._1);
        else if (d1.v == d2.v) push(JInt._0);
        else push(JInt._M1);
      } break;
       
      case DCMPG: {
        JDouble d2 = (JDouble) pop();
        JDouble d1 = (JDouble) pop();
        if (Double.isNaN(d1.v) || Double.isNaN(d2.v)) push(JInt._1);
        else if (d1.v > d2.v) push(JInt._1);
        else if (d1.v == d2.v) push(JInt._0);
        else push(JInt._M1);
      } break;
       
      case IRETURN:
      case LRETURN:
      case FRETURN:
      case DRETURN:
      case ARETURN:
        itsReturnValue = pop();
        itsInstructionPointer = -1;
        return;
       
      case RETURN:
        itsReturnValue = JPrimitive.VOID;
        itsInstructionPointer = -1;
        return;
       
      case ARRAYLENGTH: {
        JArray array = (JArray) pop();
        push(new JInt(array.getSize()));
      } break;
       
      case ATHROW: {
        JInstance theException = (JInstance) pop();
        throwEx(theException);
View Full Code Here

    {
      switch(aOpcode)
      {
      case BIPUSH:
      case SIPUSH:
        push(new JInt(aOperand));
        break;
       
      case NEWARRAY: {
        JInt size = (JInt) pop();
        push(new SimpleArray(size.v));
      } break;
       
      default:
        throw new UnsupportedOperationException();
View Full Code Here

        JClass theClass = getInterpreter().getClass(aType);
        push(theClass.newInstance());
      } break;
       
      case ANEWARRAY:{
        JInt size = (JInt) pop();
        push(new SimpleArray(size.v));
      } break;
       
      case CHECKCAST: {
        JInstance o = (JInstance) pop();
        JClass theClass = getInterpreter().getClass(aType);
        boolean theResult = theClass.isAssignableFrom(o.getType());
        if (theResult) push(o);
        else throwEx(getInterpreter().new_ClassCastException(this, "Cannot cast "+o.getType()+" to "+aType));
      } break;
               
      case INSTANCEOF: {
        JInstance o = (JInstance) pop();
        JClass theClass = getInterpreter().getClass(aType);
        boolean theResult = theClass.isAssignableFrom(o.getType());
        push(new JInt(theResult ? 1 : 0));
      } break;
       
      default:
        throw new UnsupportedOperationException();
View Full Code Here

  {
    JObject[] args = interp.toJObjects(10, 11);
    JObject theResult = interp.invoke(null, "zz/jinterp/SimpleClass", "ari", "(II)I", null, args);
    if (theResult instanceof JInt)
    {
      JInt theInt = (JInt) theResult;
      Assert.assertEquals(theInt.v, SimpleClass.ari(10, 11));
    }
    else Assert.fail();
  }
View Full Code Here

  {
    JObject[] args = {};
    JObject theResult = interp.invoke(null, "zz/jinterp/SimpleClass", "s", "()I", null, args);
    if (theResult instanceof JInt)
    {
      JInt theInt = (JInt) theResult;
      Assert.assertEquals(theInt.v, SimpleClass.s());
    }
    else Assert.fail();
  }
View Full Code Here

TOP

Related Classes of zz.jinterp.JPrimitive.JInt

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.