processor.java

来自「proguard 一个java的混淆器」· Java 代码 · 共 980 行 · 第 1/3 页

JAVA
980
字号
                    stack.push(valueFactory.createLongValue());                    // TODO: Forward ArithmeticExceptions.                    //stack.clear();                    //stack.push(valueFactory.createReference(false));                    //branchUnit.throwException();                }                break;            case InstructionConstants.OP_FREM:                stack.push(stack.fpop().remainderOf(stack.fpop()));                break;            case InstructionConstants.OP_DREM:                stack.push(stack.dpop().remainderOf(stack.dpop()));                break;            case InstructionConstants.OP_INEG:                stack.push(stack.ipop().negate());                break;            case InstructionConstants.OP_LNEG:                stack.push(stack.lpop().negate());                break;            case InstructionConstants.OP_FNEG:                stack.push(stack.fpop().negate());                break;            case InstructionConstants.OP_DNEG:                stack.push(stack.dpop().negate());                break;            case InstructionConstants.OP_ISHL:                stack.push(stack.ipop().shiftLeftOf(stack.ipop()));                break;            case InstructionConstants.OP_LSHL:                stack.push(stack.ipop().shiftLeftOf(stack.lpop()));                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(valueFactory));                break;            case InstructionConstants.OP_I2F:                stack.push(stack.ipop().convertToFloat(valueFactory));                break;            case InstructionConstants.OP_I2D:                stack.push(stack.ipop().convertToDouble(valueFactory));                break;            case InstructionConstants.OP_L2I:                stack.push(stack.lpop().convertToInteger(valueFactory));                break;            case InstructionConstants.OP_L2F:                stack.push(stack.lpop().convertToFloat(valueFactory));                break;            case InstructionConstants.OP_L2D:                stack.push(stack.lpop().convertToDouble(valueFactory));                break;            case InstructionConstants.OP_F2I:                stack.push(stack.fpop().convertToInteger(valueFactory));                break;            case InstructionConstants.OP_F2L:                stack.push(stack.fpop().convertToLong(valueFactory));                break;            case InstructionConstants.OP_F2D:                stack.push(stack.fpop().convertToDouble(valueFactory));                break;            case InstructionConstants.OP_D2I:                stack.push(stack.dpop().convertToInteger(valueFactory));                break;            case InstructionConstants.OP_D2L:                stack.push(stack.dpop().convertToLong(valueFactory));                break;            case InstructionConstants.OP_D2F:                stack.push(stack.dpop().convertToFloat(valueFactory));                break;            case InstructionConstants.OP_I2B:                stack.push(stack.ipop().convertToByte(valueFactory));                break;            case InstructionConstants.OP_I2C:                stack.push(stack.ipop().convertToCharacter(valueFactory));                break;            case InstructionConstants.OP_I2S:                stack.push(stack.ipop().convertToShort(valueFactory));                break;            case InstructionConstants.OP_LCMP://                stack.push(stack.lpop().compareReverse(stack.lpop()));                LongValue longValue1 = stack.lpop();                LongValue longValue2 = stack.lpop();                stack.push(longValue2.compare(longValue1, valueFactory));                break;            case InstructionConstants.OP_FCMPL:                FloatValue floatValue1 = stack.fpop();                FloatValue floatValue2 = stack.fpop();                stack.push(floatValue2.compare(floatValue1, valueFactory));                break;            case InstructionConstants.OP_FCMPG:                stack.push(stack.fpop().compareReverse(stack.fpop(), valueFactory));                break;            case InstructionConstants.OP_DCMPL:                DoubleValue doubleValue1 = stack.dpop();                DoubleValue doubleValue2 = stack.dpop();                stack.push(doubleValue2.compare(doubleValue1, valueFactory));                break;            case InstructionConstants.OP_DCMPG:                stack.push(stack.dpop().compareReverse(stack.dpop(), valueFactory));                break;            case InstructionConstants.OP_IRETURN:                invocationUnit.exitMethod(clazz, method, stack.ipop());                branchUnit.returnFromMethod();                break;            case InstructionConstants.OP_LRETURN:                invocationUnit.exitMethod(clazz, method, stack.lpop());                branchUnit.returnFromMethod();                break;            case InstructionConstants.OP_FRETURN:                invocationUnit.exitMethod(clazz, method, stack.fpop());                branchUnit.returnFromMethod();                break;            case InstructionConstants.OP_DRETURN:                invocationUnit.exitMethod(clazz, method, stack.dpop());                branchUnit.returnFromMethod();                break;            case InstructionConstants.OP_ARETURN:                invocationUnit.exitMethod(clazz, method, stack.apop());                branchUnit.returnFromMethod();                break;            case InstructionConstants.OP_RETURN:                branchUnit.returnFromMethod();                break;            case InstructionConstants.OP_NEWARRAY:                IntegerValue arrayLength = stack.ipop();                stack.push(valueFactory.createArrayReferenceValue(String.valueOf(InstructionUtil.internalTypeFromArrayType((byte)simpleInstruction.constant)),                                                                  null,                                                                  arrayLength));                break;            case InstructionConstants.OP_ARRAYLENGTH:                stack.apop();                stack.push(valueFactory.createIntegerValue());                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 visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)    {        int constantIndex = constantInstruction.constantIndex;        switch (constantInstruction.opcode)        {            case InstructionConstants.OP_LDC:            case InstructionConstants.OP_LDC_W:            case InstructionConstants.OP_LDC2_W:                stack.push(cpValue(clazz, constantIndex, true));                break;            case InstructionConstants.OP_GETSTATIC:            case InstructionConstants.OP_PUTSTATIC:            case InstructionConstants.OP_GETFIELD:            case InstructionConstants.OP_PUTFIELD:            case InstructionConstants.OP_INVOKEVIRTUAL:            case InstructionConstants.OP_INVOKESPECIAL:            case InstructionConstants.OP_INVOKESTATIC:            case InstructionConstants.OP_INVOKEINTERFACE:                invocationUnit.invokeMember(clazz, method, codeAttribute, offset, constantInstruction, stack);                break;            case InstructionConstants.OP_NEW:                stack.push(cpValue(clazz, constantIndex).referenceValue());                break;            case InstructionConstants.OP_ANEWARRAY:            {                ReferenceValue referenceValue = cpValue(clazz, constantIndex).referenceValue();                stack.push(valueFactory.createArrayReferenceValue(referenceValue.internalType(),                                                                  referenceValue.getReferencedClass(),                                                                  stack.ipop()));                break;            }            case InstructionConstants.OP_CHECKCAST:                // TODO: Check cast.                ReferenceValue castValue = stack.apop();                ReferenceValue castResultValue =                    castValue.isNull() == Value.ALWAYS ? castValue :                    castValue.isNull() == Value.NEVER  ? cpValue(clazz, constantIndex).referenceValue() :                                                         cpValue(clazz, constantIndex).referenceValue().generalize(valueFactory.createReferenceValueNull());                stack.push(castResultValue);                break;            case InstructionConstants.OP_INSTANCEOF:            {                ReferenceValue referenceValue = cpValue(clazz, constantIndex).referenceValue();                int instanceOf = stack.apop().instanceOf(referenceValue.getType(),                                                         referenceValue.getReferencedClass());                stack.push(instanceOf == Value.NEVER  ? valueFactory.createIntegerValue(0) :                           instanceOf == Value.ALWAYS ? valueFactory.createIntegerValue(1) :                                                        valueFactory.createIntegerValue());                break;            }            case InstructionConstants.OP_MULTIANEWARRAY:            {                int dimensionCount = constantInstruction.constant;                for (int dimension = 0; dimension < dimensionCount; dimension++)                {                    // TODO: Use array lengths.                    IntegerValue arrayLength = stack.ipop();                }                stack.push(cpValue(clazz, constantIndex).referenceValue());                break;            }            default:                throw new IllegalArgumentException("Unknown constant pool instruction ["+constantInstruction.opcode+"]");        }    }    public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, 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;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?