📄 processor.java
字号:
break; case InstructionConstants.OP_ISHR: stack.push(stack.ipop().shiftRightOf(stack.ipop())); break; case InstructionConstants.OP_LSHR: stack.push(stack.ipop().shiftRightOf(stack.lpop())); break; case InstructionConstants.OP_IUSHR: stack.push(stack.ipop().unsignedShiftRightOf(stack.ipop())); break; case InstructionConstants.OP_LUSHR: stack.push(stack.ipop().unsignedShiftRightOf(stack.lpop())); break; case InstructionConstants.OP_IAND: stack.push(stack.ipop().and(stack.ipop())); break; case InstructionConstants.OP_LAND: stack.push(stack.lpop().and(stack.lpop())); break; case InstructionConstants.OP_IOR: stack.push(stack.ipop().or(stack.ipop())); break; case InstructionConstants.OP_LOR: stack.push(stack.lpop().or(stack.lpop())); break; case InstructionConstants.OP_IXOR: stack.push(stack.ipop().xor(stack.ipop())); break; case InstructionConstants.OP_LXOR: stack.push(stack.lpop().xor(stack.lpop())); break; case InstructionConstants.OP_I2L: stack.push(stack.ipop().convertToLong()); break; case InstructionConstants.OP_I2F: stack.push(stack.ipop().convertToFloat()); break; case InstructionConstants.OP_I2D: stack.push(stack.ipop().convertToDouble()); break; case InstructionConstants.OP_L2I: stack.push(stack.lpop().convertToInteger()); break; case InstructionConstants.OP_L2F: stack.push(stack.lpop().convertToFloat()); break; case InstructionConstants.OP_L2D: stack.push(stack.lpop().convertToDouble()); break; case InstructionConstants.OP_F2I: stack.push(stack.fpop().convertToInteger()); break; case InstructionConstants.OP_F2L: stack.push(stack.fpop().convertToLong()); break; case InstructionConstants.OP_F2D: stack.push(stack.fpop().convertToDouble()); break; case InstructionConstants.OP_D2I: stack.push(stack.dpop().convertToInteger()); break; case InstructionConstants.OP_D2L: stack.push(stack.dpop().convertToLong()); break; case InstructionConstants.OP_D2F: stack.push(stack.dpop().convertToFloat()); break; case InstructionConstants.OP_I2B: stack.push(stack.ipop().convertToByte()); break; case InstructionConstants.OP_I2C: stack.push(stack.ipop().convertToCharacter()); break; case InstructionConstants.OP_I2S: stack.push(stack.ipop().convertToShort()); break; case InstructionConstants.OP_LCMP: stack.push(stack.lpop().compareReverse(stack.lpop())); break; case InstructionConstants.OP_FCMPL: FloatValue floatValue1 = stack.fpop(); FloatValue floatValue2 = stack.fpop(); stack.push(floatValue2.compare(floatValue1)); break; case InstructionConstants.OP_FCMPG: stack.push(stack.fpop().compareReverse(stack.fpop())); break; case InstructionConstants.OP_DCMPL: DoubleValue doubleValue1 = stack.dpop(); DoubleValue doubleValue2 = stack.dpop(); stack.push(doubleValue2.compare(doubleValue1)); break; case InstructionConstants.OP_DCMPG: stack.push(stack.dpop().compareReverse(stack.dpop())); break; case InstructionConstants.OP_IRETURN: branchUnit.returnFromMethod(stack.ipop()); break; case InstructionConstants.OP_LRETURN: branchUnit.returnFromMethod(stack.lpop()); break; case InstructionConstants.OP_FRETURN: branchUnit.returnFromMethod(stack.fpop()); break; case InstructionConstants.OP_DRETURN: branchUnit.returnFromMethod(stack.dpop()); break; case InstructionConstants.OP_ARETURN: branchUnit.returnFromMethod(stack.apop()); break; case InstructionConstants.OP_RETURN: branchUnit.returnFromMethod(null); break; case InstructionConstants.OP_NEWARRAY: stack.ipop(); stack.push(ReferenceValueFactory.create(false)); break; case InstructionConstants.OP_ARRAYLENGTH: stack.apop(); stack.push(IntegerValueFactory.create()); break; case InstructionConstants.OP_ATHROW: ReferenceValue exceptionReferenceValue = stack.apop(); stack.clear(); stack.push(exceptionReferenceValue); branchUnit.throwException(); break; case InstructionConstants.OP_MONITORENTER: case InstructionConstants.OP_MONITOREXIT: stack.apop(); break; default: throw new IllegalArgumentException("Unknown simple instruction ["+simpleInstruction.opcode+"]"); } } public void visitCpInstruction(ClassFile classFile, MethodInfo methodInfo, CodeAttrInfo codeAttrInfo, int offset, CpInstruction cpInstruction) { int cpIndex = cpInstruction.cpIndex; switch (cpInstruction.opcode) { case InstructionConstants.OP_LDC: case InstructionConstants.OP_LDC_W: case InstructionConstants.OP_LDC2_W: case InstructionConstants.OP_GETSTATIC: stack.push(cpValue(classFile, cpIndex)); break; case InstructionConstants.OP_PUTSTATIC: stack.pop(); break; case InstructionConstants.OP_GETFIELD: stack.apop(); stack.push(cpValue(classFile, cpIndex)); break; case InstructionConstants.OP_PUTFIELD: stack.pop(); stack.apop(); break; case InstructionConstants.OP_INVOKEVIRTUAL: case InstructionConstants.OP_INVOKESPECIAL: case InstructionConstants.OP_INVOKESTATIC: case InstructionConstants.OP_INVOKEINTERFACE: Value cpValue = cpValue(classFile, cpIndex); int parameterCount = parameterCount(classFile, cpIndex); for (int counter = 0; counter < parameterCount; counter++) { stack.pop(); } if (cpInstruction.opcode != InstructionConstants.OP_INVOKESTATIC) { stack.apop(); } if (cpValue != null) { stack.push(cpValue); } break; case InstructionConstants.OP_NEW: stack.push(cpValue(classFile, cpIndex)); break; case InstructionConstants.OP_ANEWARRAY: stack.ipop(); stack.push(ReferenceValueFactory.create(referencedClassFile(classFile, cpIndex), 1, false)); break; case InstructionConstants.OP_CHECKCAST: // TODO: Check cast. stack.push(stack.apop()); break; case InstructionConstants.OP_INSTANCEOF: int instanceOf = stack.apop().instanceOf(referencedClassFile(classFile, cpIndex), referencedTypeDimensionCount(classFile, cpIndex)); stack.push(instanceOf == Value.NEVER ? IntegerValueFactory.create(0) : instanceOf == Value.ALWAYS ? IntegerValueFactory.create(1) : IntegerValueFactory.create()); break; case InstructionConstants.OP_MULTIANEWARRAY: int dimensionCount = cpInstruction.constant; for (int dimension = 0; dimension < dimensionCount; dimension++) { stack.ipop(); } stack.push(cpValue(classFile, cpIndex)); break; default: throw new IllegalArgumentException("Unknown constant pool instruction ["+cpInstruction.opcode+"]"); } } public void visitVariableInstruction(ClassFile classFile, MethodInfo methodInfo, CodeAttrInfo codeAttrInfo, int offset, VariableInstruction variableInstruction) { int variableIndex = variableInstruction.variableIndex; switch (variableInstruction.opcode) { case InstructionConstants.OP_ILOAD: case InstructionConstants.OP_ILOAD_0: case InstructionConstants.OP_ILOAD_1: case InstructionConstants.OP_ILOAD_2: case InstructionConstants.OP_ILOAD_3: stack.push(variables.iload(variableIndex)); break; case InstructionConstants.OP_LLOAD: case InstructionConstants.OP_LLOAD_0: case InstructionConstants.OP_LLOAD_1: case InstructionConstants.OP_LLOAD_2: case InstructionConstants.OP_LLOAD_3: stack.push(variables.lload(variableIndex)); break; case InstructionConstants.OP_FLOAD: case InstructionConstants.OP_FLOAD_0: case InstructionConstants.OP_FLOAD_1: case InstructionConstants.OP_FLOAD_2: case InstructionConstants.OP_FLOAD_3: stack.push(variables.fload(variableIndex)); break; case InstructionConstants.OP_DLOAD: case InstructionConstants.OP_DLOAD_0: case InstructionConstants.OP_DLOAD_1: case InstructionConstants.OP_DLOAD_2: case InstructionConstants.OP_DLOAD_3: stack.push(variables.dload(variableIndex)); break; case InstructionConstants.OP_ALOAD: case InstructionConstants.OP_ALOAD_0: case InstructionConstants.OP_ALOAD_1: case InstructionConstants.OP_ALOAD_2: case InstructionConstants.OP_ALOAD_3: stack.push(variables.aload(variableIndex)); break; case InstructionConstants.OP_ISTORE: case InstructionConstants.OP_ISTORE_0: case InstructionConstants.OP_ISTORE_1: case InstructionConstants.OP_ISTORE_2: case InstructionConstants.OP_ISTORE_3: variables.store(variableIndex, stack.ipop()); break; case InstructionConstants.OP_LSTORE: case InstructionConstants.OP_LSTORE_0: case InstructionConstants.OP_LSTORE_1: case InstructionConstants.OP_LSTORE_2: case InstructionConstants.OP_LSTORE_3: variables.store(variableIndex, stack.lpop()); break; case InstructionConstants.OP_FSTORE: case InstructionConstants.OP_FSTORE_0: case InstructionConstants.OP_FSTORE_1: case InstructionConstants.OP_FSTORE_2: case InstructionConstants.OP_FSTORE_3:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -