⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 processor.java

📁 ProGuard 是一个免费的 Java类文件的压缩
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * ProGuard -- shrinking, optimization, obfuscation, and preverification *             of Java bytecode. * * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package proguard.evaluation;import proguard.classfile.*;import proguard.classfile.attribute.CodeAttribute;import proguard.classfile.constant.*;import proguard.classfile.constant.visitor.ConstantVisitor;import proguard.classfile.instruction.*;import proguard.classfile.instruction.visitor.InstructionVisitor;import proguard.classfile.util.*;import proguard.evaluation.value.*;/** * This InstructionVisitor executes the instructions that it visits on a given * local variable frame and stack. * * @author Eric Lafortune */public class Processorextends      SimplifiedVisitorimplements   InstructionVisitor,             ConstantVisitor{    private Variables      variables;    private Stack          stack;    private ValueFactory   valueFactory;    private BranchUnit     branchUnit;    private InvocationUnit invocationUnit;    // Fields acting as parameters for the ConstantVisitor methods.    private boolean handleClassConstantAsClassValue;    private Value   cpValue;    /**     * Creates a new processor that operates on the given environment.     * @param variables      the local variable frame.     * @param stack          the local stack.     * @param branchUnit     the class that can affect the program counter.     * @param invocationUnit the class that can access other program members.     */    public Processor(Variables      variables,                     Stack          stack,                     ValueFactory   valueFactory,                     BranchUnit     branchUnit,                     InvocationUnit invocationUnit)    {        this.variables      = variables;        this.stack          = stack;        this.valueFactory   = valueFactory;        this.branchUnit     = branchUnit;        this.invocationUnit = invocationUnit;    }    // Implementations for InstructionVisitor.    public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)    {        switch (simpleInstruction.opcode)        {            case InstructionConstants.OP_NOP:                break;            case InstructionConstants.OP_ACONST_NULL:                stack.push(valueFactory.createReferenceValueNull());                break;            case InstructionConstants.OP_ICONST_M1:            case InstructionConstants.OP_ICONST_0:            case InstructionConstants.OP_ICONST_1:            case InstructionConstants.OP_ICONST_2:            case InstructionConstants.OP_ICONST_3:            case InstructionConstants.OP_ICONST_4:            case InstructionConstants.OP_ICONST_5:            case InstructionConstants.OP_BIPUSH:            case InstructionConstants.OP_SIPUSH:                stack.push(valueFactory.createIntegerValue(simpleInstruction.constant));                break;            case InstructionConstants.OP_LCONST_0:            case InstructionConstants.OP_LCONST_1:                stack.push(valueFactory.createLongValue(simpleInstruction.constant));                break;            case InstructionConstants.OP_FCONST_0:            case InstructionConstants.OP_FCONST_1:            case InstructionConstants.OP_FCONST_2:                stack.push(valueFactory.createFloatValue((float)simpleInstruction.constant));                break;            case InstructionConstants.OP_DCONST_0:            case InstructionConstants.OP_DCONST_1:                stack.push(valueFactory.createDoubleValue((double)simpleInstruction.constant));                break;            case InstructionConstants.OP_IALOAD:            case InstructionConstants.OP_BALOAD:            case InstructionConstants.OP_CALOAD:            case InstructionConstants.OP_SALOAD:                stack.ipop();                stack.apop();                stack.push(valueFactory.createIntegerValue());                break;            case InstructionConstants.OP_LALOAD:                stack.ipop();                stack.apop();                stack.push(valueFactory.createLongValue());                break;            case InstructionConstants.OP_FALOAD:                stack.ipop();                stack.apop();                stack.push(valueFactory.createFloatValue());                break;            case InstructionConstants.OP_DALOAD:                stack.ipop();                stack.apop();                stack.push(valueFactory.createDoubleValue());                break;            case InstructionConstants.OP_AALOAD:            {                IntegerValue   arrayIndex     = stack.ipop();                ReferenceValue arrayReference = stack.apop();                stack.push(arrayReference.arrayLoad(arrayIndex, valueFactory));                break;            }            case InstructionConstants.OP_IASTORE:            case InstructionConstants.OP_BASTORE:            case InstructionConstants.OP_CASTORE:            case InstructionConstants.OP_SASTORE:                stack.ipop();                stack.ipop();                stack.apop();                break;            case InstructionConstants.OP_LASTORE:                stack.lpop();                stack.ipop();                stack.apop();                break;            case InstructionConstants.OP_FASTORE:                stack.fpop();                stack.ipop();                stack.apop();                break;            case InstructionConstants.OP_DASTORE:                stack.dpop();                stack.ipop();                stack.apop();                break;            case InstructionConstants.OP_AASTORE:                stack.apop();                stack.ipop();                stack.apop();                break;            case InstructionConstants.OP_POP:                stack.pop1();                break;            case InstructionConstants.OP_POP2:                stack.pop2();                break;            case InstructionConstants.OP_DUP:                stack.dup();                break;            case InstructionConstants.OP_DUP_X1:                stack.dup_x1();                break;            case InstructionConstants.OP_DUP_X2:                stack.dup_x2();                break;            case InstructionConstants.OP_DUP2:                stack.dup2();                break;            case InstructionConstants.OP_DUP2_X1:                stack.dup2_x1();                break;            case InstructionConstants.OP_DUP2_X2:                stack.dup2_x2();                break;            case InstructionConstants.OP_SWAP:                stack.swap();                break;            case InstructionConstants.OP_IADD:                stack.push(stack.ipop().add(stack.ipop()));                break;            case InstructionConstants.OP_LADD:                stack.push(stack.lpop().add(stack.lpop()));                break;            case InstructionConstants.OP_FADD:                stack.push(stack.fpop().add(stack.fpop()));                break;            case InstructionConstants.OP_DADD:                stack.push(stack.dpop().add(stack.dpop()));                break;            case InstructionConstants.OP_ISUB:                stack.push(stack.ipop().subtractFrom(stack.ipop()));                break;            case InstructionConstants.OP_LSUB:                stack.push(stack.lpop().subtractFrom(stack.lpop()));                break;            case InstructionConstants.OP_FSUB:                stack.push(stack.fpop().subtractFrom(stack.fpop()));                break;            case InstructionConstants.OP_DSUB:                stack.push(stack.dpop().subtractFrom(stack.dpop()));                break;            case InstructionConstants.OP_IMUL:                stack.push(stack.ipop().multiply(stack.ipop()));                break;            case InstructionConstants.OP_LMUL:                stack.push(stack.lpop().multiply(stack.lpop()));                break;            case InstructionConstants.OP_FMUL:                stack.push(stack.fpop().multiply(stack.fpop()));                break;            case InstructionConstants.OP_DMUL:                stack.push(stack.dpop().multiply(stack.dpop()));                break;            case InstructionConstants.OP_IDIV:                try                {                    stack.push(stack.ipop().divideOf(stack.ipop()));                }                catch (ArithmeticException ex)                {                    stack.push(valueFactory.createIntegerValue());                    // TODO: Forward ArithmeticExceptions.                    //stack.clear();                    //stack.push(valueFactory.createReference(false));                    //branchUnit.throwException();                }                break;            case InstructionConstants.OP_LDIV:                try                {                    stack.push(stack.lpop().divideOf(stack.lpop()));                }                catch (ArithmeticException ex)                {                    stack.push(valueFactory.createLongValue());                    // TODO: Forward ArithmeticExceptions.                    //stack.clear();                    //stack.push(valueFactory.createReference(false));                    //branchUnit.throwException();                }                break;            case InstructionConstants.OP_FDIV:                stack.push(stack.fpop().divideOf(stack.fpop()));                break;            case InstructionConstants.OP_DDIV:                stack.push(stack.dpop().divideOf(stack.dpop()));                break;            case InstructionConstants.OP_IREM:                try                {                    stack.push(stack.ipop().remainderOf(stack.ipop()));                }                catch (ArithmeticException ex)                {                    stack.push(valueFactory.createIntegerValue());                    // TODO: Forward ArithmeticExceptions.                    //stack.clear();                    //stack.push(valueFactory.createReference(false));                    //branchUnit.throwException();                }                break;            case InstructionConstants.OP_LREM:                try                {                    stack.push(stack.lpop().remainderOf(stack.lpop()));                }                catch (ArithmeticException ex)                {

⌨️ 快捷键说明

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