private void evalLoad(Type expected, int index, Frame frame, Subroutine subroutine) throws BadBytecode { Type type = frame.getLocal(index); verifyAssignable(expected, type); simplePush(type, frame); access(index, type, subroutine); }
private void evalLDC(int index, Frame frame) throws BadBytecode { int tag = constPool.getTag(index); Type type; switch (tag) { case ConstPool.CONST_String: type = STRING_TYPE; break; case ConstPool.CONST_Integer: type = Type.INTEGER; break; case ConstPool.CONST_Float: type = Type.FLOAT; break; case ConstPool.CONST_Long: type = Type.LONG; break; case ConstPool.CONST_Double: type = Type.DOUBLE; break; case ConstPool.CONST_Class: type = CLASS_TYPE; break; default: throw new BadBytecode("bad LDC [pos = " + lastPos + "]: " + tag); } simplePush(type, frame); }
private void evalArrayLoad(Type expectedComponent, Frame frame) throws BadBytecode { Type index = frame.pop(); Type array = frame.pop(); // Special case, an array defined by aconst_null // TODO - we might need to be more inteligent about this if (array == Type.UNINIT) { verifyAssignable(Type.INTEGER, index); if (expectedComponent == Type.OBJECT) { simplePush(Type.UNINIT, frame); } else { simplePush(expectedComponent, frame); } return; } Type component = array.getComponent(); if (component == null) throw new BadBytecode("Not an array! [pos = " + lastPos + "]: " + component); component = zeroExtend(component); verifyAssignable(expectedComponent, component); verifyAssignable(Type.INTEGER, index); simplePush(component, frame); }
private void evalShift(Type expected, Frame frame) throws BadBytecode { Type value2 = simplePop(frame); Type value1 = simplePop(frame); verifyAssignable(Type.INTEGER, value2); verifyAssignable(expected, value1); simplePush(value1, frame); }
private void evalLoad(Type expected, int index, Frame frame, Subroutine subroutine) throws BadBytecode { Type type = frame.getLocal(index); verifyAssignable(expected, type); simplePush(type, frame); access(index, type, subroutine); }
private void evalBinaryMath(Type expected, Frame frame) throws BadBytecode { Type value2 = simplePop(frame); Type value1 = simplePop(frame); verifyAssignable(expected, value2); verifyAssignable(expected, value1); simplePush(value1, frame); }
private void evalLDC(int index, Frame frame) throws BadBytecode { int tag = constPool.getTag(index); Type type; switch (tag) { case ConstPool.CONST_String: type = STRING_TYPE; break; case ConstPool.CONST_Integer: type = Type.INTEGER; break; case ConstPool.CONST_Float: type = Type.FLOAT; break; case ConstPool.CONST_Long: type = Type.LONG; break; case ConstPool.CONST_Double: type = Type.DOUBLE; break; case ConstPool.CONST_Class: type = CLASS_TYPE; break; default: throw new BadBytecode("bad LDC [pos = " + lastPos + "]: " + tag); } simplePush(type, frame); }
private void evalArrayLoad(Type expectedComponent, Frame frame) throws BadBytecode { Type index = frame.pop(); Type array = frame.pop(); // Special case, an array defined by aconst_null // TODO - we might need to be more inteligent about this if (array == Type.UNINIT) { verifyAssignable(Type.INTEGER, index); if (expectedComponent == Type.OBJECT) { simplePush(Type.UNINIT, frame); } else { simplePush(expectedComponent, frame); } return; } Type component = array.getComponent(); if (component == null) throw new BadBytecode("Not an array! [pos = " + lastPos + "]: " + component); component = zeroExtend(component); verifyAssignable(expectedComponent, component); verifyAssignable(Type.INTEGER, index); simplePush(component, frame); }
private void evalShift(Type expected, Frame frame) throws BadBytecode { Type value2 = simplePop(frame); Type value1 = simplePop(frame); verifyAssignable(Type.INTEGER, value2); verifyAssignable(expected, value1); simplePush(value1, frame); }
private void evalBinaryMath(Type expected, Frame frame) throws BadBytecode { Type value2 = simplePop(frame); Type value1 = simplePop(frame); verifyAssignable(expected, value2); verifyAssignable(expected, value1); simplePush(value1, frame); }
private void evalGetField(int opcode, int index, Frame frame) throws BadBytecode { String desc = constPool.getFieldrefType(index); Type type = zeroExtend(typeFromDesc(desc)); if (opcode == GETFIELD) { Type objectType = resolveClassInfo(constPool.getFieldrefClassName(index)); verifyAssignable(objectType, simplePop(frame)); } simplePush(type, frame); }
private void evalInvokeDynamic(int opcode, int index, Frame frame) throws BadBytecode { String desc = constPool.getInvokeDynamicType(index); Type[] types = paramTypesFromDesc(desc); int i = types.length; while (i > 0) verifyAssignable(zeroExtend(types[--i]), simplePop(frame)); // simplePop(frame); // assume CosntPool#REF_invokeStatic Type returnType = returnTypeFromDesc(desc); if (returnType != Type.VOID) simplePush(zeroExtend(returnType), frame); }
private void evalNewObjectArray(int pos, CodeIterator iter, Frame frame) throws BadBytecode { // Convert to x[] format Type type = resolveClassInfo(constPool.getClassInfo(iter.u16bitAt(pos + 1))); String name = type.getCtClass().getName(); int opcode = iter.byteAt(pos); int dimensions; if (opcode == MULTIANEWARRAY) { dimensions = iter.byteAt(pos + 3); } else { name = name + "[]"; dimensions = 1; } while (dimensions-- > 0) { verifyAssignable(Type.INTEGER, simplePop(frame)); } simplePush(getType(name), frame); }
private void evalGetField(int opcode, int index, Frame frame) throws BadBytecode { String desc = constPool.getFieldrefType(index); Type type = zeroExtend(typeFromDesc(desc)); if (opcode == GETFIELD) { Type objectType = resolveClassInfo(constPool.getFieldrefClassName(index)); verifyAssignable(objectType, simplePop(frame)); } simplePush(type, frame); }
private void evalInvokeDynamic(int opcode, int index, Frame frame) throws BadBytecode { String desc = constPool.getInvokeDynamicType(index); Type[] types = paramTypesFromDesc(desc); int i = types.length; while (i > 0) verifyAssignable(zeroExtend(types[--i]), simplePop(frame)); // simplePop(frame); // assume CosntPool#REF_invokeStatic Type returnType = returnTypeFromDesc(desc); if (returnType != Type.VOID) simplePush(zeroExtend(returnType), frame); }
private void evalNewObjectArray(int pos, CodeIterator iter, Frame frame) throws BadBytecode { // Convert to x[] format Type type = resolveClassInfo(constPool.getClassInfo(iter.u16bitAt(pos + 1))); String name = type.getCtClass().getName(); int opcode = iter.byteAt(pos); int dimensions; if (opcode == MULTIANEWARRAY) { dimensions = iter.byteAt(pos + 3); } else { name = name + "[]"; dimensions = 1; } while (dimensions-- > 0) { verifyAssignable(Type.INTEGER, simplePop(frame)); } simplePush(getType(name), frame); }
private void evalInvokeMethod(int opcode, int index, Frame frame) throws BadBytecode { String desc = constPool.getMethodrefType(index); Type[] types = paramTypesFromDesc(desc); int i = types.length; while (i > 0) verifyAssignable(zeroExtend(types[--i]), simplePop(frame)); if (opcode != INVOKESTATIC) { Type objectType = resolveClassInfo(constPool.getMethodrefClassName(index)); verifyAssignable(objectType, simplePop(frame)); } Type returnType = returnTypeFromDesc(desc); if (returnType != Type.VOID) simplePush(zeroExtend(returnType), frame); }
private void evalInvokeIntfMethod(int opcode, int index, Frame frame) throws BadBytecode { String desc = constPool.getInterfaceMethodrefType(index); Type[] types = paramTypesFromDesc(desc); int i = types.length; while (i > 0) verifyAssignable(zeroExtend(types[--i]), simplePop(frame)); String classInfo = constPool.getInterfaceMethodrefClassName(index); Type objectType = resolveClassInfo(classInfo); verifyAssignable(objectType, simplePop(frame)); Type returnType = returnTypeFromDesc(desc); if (returnType != Type.VOID) simplePush(zeroExtend(returnType), frame); }
private void evalInvokeIntfMethod(int opcode, int index, Frame frame) throws BadBytecode { String desc = constPool.getInterfaceMethodrefType(index); Type[] types = paramTypesFromDesc(desc); int i = types.length; while (i > 0) verifyAssignable(zeroExtend(types[--i]), simplePop(frame)); String classInfo = constPool.getInterfaceMethodrefClassName(index); Type objectType = resolveClassInfo(classInfo); verifyAssignable(objectType, simplePop(frame)); Type returnType = returnTypeFromDesc(desc); if (returnType != Type.VOID) simplePush(zeroExtend(returnType), frame); }
private void evalInvokeMethod(int opcode, int index, Frame frame) throws BadBytecode { String desc = constPool.getMethodrefType(index); Type[] types = paramTypesFromDesc(desc); int i = types.length; while (i > 0) verifyAssignable(zeroExtend(types[--i]), simplePop(frame)); if (opcode != INVOKESTATIC) { Type objectType = resolveClassInfo(constPool.getMethodrefClassName(index)); verifyAssignable(objectType, simplePop(frame)); } Type returnType = returnTypeFromDesc(desc); if (returnType != Type.VOID) simplePush(zeroExtend(returnType), frame); }