diff options
Diffstat (limited to 'src/proguard/evaluation')
64 files changed, 0 insertions, 12489 deletions
diff --git a/src/proguard/evaluation/BasicBranchUnit.java b/src/proguard/evaluation/BasicBranchUnit.java deleted file mode 100644 index f10e4be..0000000 --- a/src/proguard/evaluation/BasicBranchUnit.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.Clazz; -import proguard.classfile.attribute.CodeAttribute; -import proguard.evaluation.value.InstructionOffsetValue; - -/** - * This BranchUnit remembers the branch unit commands that are invoked on it. - * I doesn't consider conditions when branching. - * - * @author Eric Lafortune - */ -public class BasicBranchUnit -implements BranchUnit -{ - private boolean wasCalled; - private InstructionOffsetValue traceBranchTargets; - - - /** - * Resets the flag that tells whether any of the branch unit commands was - * called. - */ - public void resetCalled() - { - wasCalled = false; - } - - /** - * Sets the flag that tells whether any of the branch unit commands was - * called. - */ - protected void setCalled() - { - wasCalled = true; - } - - /** - * Returns whether any of the branch unit commands was called. - */ - public boolean wasCalled() - { - return wasCalled; - } - - - /** - * Sets the initial branch targets, which will be updated as the branch - * methods of the branch unit are called. - */ - public void setTraceBranchTargets(InstructionOffsetValue branchTargets) - { - this.traceBranchTargets = branchTargets; - } - - public InstructionOffsetValue getTraceBranchTargets() - { - return traceBranchTargets; - } - - - // Implementations for BranchUnit. - - public void branch(Clazz clazz, - CodeAttribute codeAttribute, - int offset, - int branchTarget) - { - // Override the branch targets. - traceBranchTargets = new InstructionOffsetValue(branchTarget); - - wasCalled = true; - } - - - public void branchConditionally(Clazz clazz, - CodeAttribute codeAttribute, - int offset, - int branchTarget, - int conditional) - { - // Accumulate the branch targets. - traceBranchTargets = - traceBranchTargets.generalize(new InstructionOffsetValue(branchTarget)).instructionOffsetValue(); - - wasCalled = true; - } - - - public void returnFromMethod() - { - // Stop processing this block. - traceBranchTargets = InstructionOffsetValue.EMPTY_VALUE; - - wasCalled = true; - } - - - public void throwException() - { - // Stop processing this block. - traceBranchTargets = InstructionOffsetValue.EMPTY_VALUE; - - wasCalled = true; - } -} diff --git a/src/proguard/evaluation/BasicInvocationUnit.java b/src/proguard/evaluation/BasicInvocationUnit.java deleted file mode 100644 index f7cc902..0000000 --- a/src/proguard/evaluation/BasicInvocationUnit.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.util.*; -import proguard.classfile.visitor.MemberVisitor; -import proguard.evaluation.value.*; - -/** - * This InvocationUnit sets up the variables for entering a method, - * and it updates the stack for the invocation of a class member, - * using simple values. - * - * @author Eric Lafortune - */ -public class BasicInvocationUnit -extends SimplifiedVisitor -implements InvocationUnit, - ConstantVisitor, - MemberVisitor -{ - protected final ValueFactory valueFactory; - - // Fields acting as parameters between the visitor methods. - private boolean isStatic; - private boolean isLoad; - private Stack stack; - private Clazz returnTypeClass; - - - /** - * Creates a new BasicInvocationUnit with the given value factory. - */ - public BasicInvocationUnit(ValueFactory valueFactory) - { - this.valueFactory = valueFactory; - } - - - // Implementations for InvocationUnit. - - public void enterMethod(Clazz clazz, Method method, Variables variables) - { - String descriptor = method.getDescriptor(clazz); - - // Initialize the parameters. - boolean isStatic = - (method.getAccessFlags() & ClassConstants.ACC_STATIC) != 0; - - // Count the number of parameters, taking into account their categories. - int parameterSize = ClassUtil.internalMethodParameterSize(descriptor, isStatic); - - // Reuse the existing parameters object, ensuring the right size. - variables.reset(parameterSize); - - // Go over the parameters again. - InternalTypeEnumeration internalTypeEnumeration = - new InternalTypeEnumeration(descriptor); - - int parameterIndex = 0; - int variableIndex = 0; - - // Put the 'this' reference in variable 0. - if (!isStatic) - { - // Get the reference value. - Value value = getMethodParameterValue(clazz, - method, - parameterIndex++, - ClassUtil.internalTypeFromClassName(clazz.getName()), - clazz); - - // Store the value in variable 0. - variables.store(variableIndex++, value); - } - - Clazz[] referencedClasses = ((ProgramMethod)method).referencedClasses; - int referencedClassIndex = 0; - - // Set up the variables corresponding to the parameter types and values. - while (internalTypeEnumeration.hasMoreTypes()) - { - String type = internalTypeEnumeration.nextType(); - - Clazz referencedClass = referencedClasses != null && - ClassUtil.isInternalClassType(type) ? - referencedClasses[referencedClassIndex++] : - null; - - // Get the parameter value. - Value value = getMethodParameterValue(clazz, - method, - parameterIndex++, - type, - referencedClass); - - // Store the value in the corresponding variable. - variables.store(variableIndex++, value); - - // Increment the variable index again for Category 2 values. - if (value.isCategory2()) - { - variableIndex++; - } - } - } - - - public void exitMethod(Clazz clazz, Method method, Value returnValue) - { - setMethodReturnValue(clazz, method, returnValue); - } - - - public void invokeMember(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction, Stack stack) - { - int constantIndex = constantInstruction.constantIndex; - - switch (constantInstruction.opcode) - { - case InstructionConstants.OP_GETSTATIC: - isStatic = true; - isLoad = true; - break; - - case InstructionConstants.OP_PUTSTATIC: - isStatic = true; - isLoad = false; - break; - - case InstructionConstants.OP_GETFIELD: - isStatic = false; - isLoad = true; - break; - - case InstructionConstants.OP_PUTFIELD: - isStatic = false; - isLoad = false; - break; - - case InstructionConstants.OP_INVOKESTATIC: - case InstructionConstants.OP_INVOKEDYNAMIC: - isStatic = true; - break; - - case InstructionConstants.OP_INVOKEVIRTUAL: - case InstructionConstants.OP_INVOKESPECIAL: - case InstructionConstants.OP_INVOKEINTERFACE: - isStatic = false; - break; - } - - // Pop the parameters and push the return value. - this.stack = stack; - clazz.constantPoolEntryAccept(constantIndex, this); - this.stack = null; - } - - - // Implementations for ConstantVisitor. - - public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant) - { - // Pop the field value, if applicable. - if (!isLoad) - { - setFieldValue(clazz, fieldrefConstant, stack.pop()); - } - - // Pop the reference value, if applicable. - if (!isStatic) - { - setFieldClassValue(clazz, fieldrefConstant, stack.apop()); - } - - // Push the field value, if applicable. - if (isLoad) - { - String type = fieldrefConstant.getType(clazz); - - stack.push(getFieldValue(clazz, fieldrefConstant, type)); - } - } - - - public void visitAnyMethodrefConstant(Clazz clazz, RefConstant methodrefConstant) - { - String type = methodrefConstant.getType(clazz); - - // Count the number of parameters. - int parameterCount = ClassUtil.internalMethodParameterCount(type); - if (!isStatic) - { - parameterCount++; - } - - // Pop the parameters and the class reference, in reverse order. - for (int parameterIndex = parameterCount-1; parameterIndex >= 0; parameterIndex--) - { - setMethodParameterValue(clazz, methodrefConstant, parameterIndex, stack.pop()); - } - - // Push the return value, if applicable. - String returnType = ClassUtil.internalMethodReturnType(type); - if (returnType.charAt(0) != ClassConstants.TYPE_VOID) - { - stack.push(getMethodReturnValue(clazz, methodrefConstant, returnType)); - } - } - - public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant) - { - String type = invokeDynamicConstant.getType(clazz); - - // Count the number of parameters. - int parameterCount = ClassUtil.internalMethodParameterCount(type); - if (!isStatic) - { - parameterCount++; - } - - // Pop the parameters and the class reference, in reverse order. - for (int parameterIndex = parameterCount-1; parameterIndex >= 0; parameterIndex--) - { - stack.pop(); - } - - // Push the return value, if applicable. - String returnType = ClassUtil.internalMethodReturnType(type); - if (returnType.charAt(0) != ClassConstants.TYPE_VOID) - { - stack.push(getMethodReturnValue(clazz, invokeDynamicConstant, returnType)); - } - } - - - /** - * Sets the class through which the specified field is accessed. - */ - protected void setFieldClassValue(Clazz clazz, - RefConstant refConstant, - ReferenceValue value) - { - // We don't care about the new value. - } - - - /** - * Returns the class though which the specified field is accessed. - */ - protected Value getFieldClassValue(Clazz clazz, - RefConstant refConstant, - String type) - { - // Try to figure out the class of the return type. - returnTypeClass = null; - refConstant.referencedMemberAccept(this); - - return valueFactory.createValue(type, - returnTypeClass, - true); - } - - - /** - * Sets the value of the specified field. - */ - protected void setFieldValue(Clazz clazz, - RefConstant refConstant, - Value value) - { - // We don't care about the new field value. - } - - - /** - * Returns the value of the specified field. - */ - protected Value getFieldValue(Clazz clazz, - RefConstant refConstant, - String type) - { - // Try to figure out the class of the return type. - returnTypeClass = null; - refConstant.referencedMemberAccept(this); - - return valueFactory.createValue(type, - returnTypeClass, - true); - } - - - /** - * Sets the value of the specified method parameter. - */ - protected void setMethodParameterValue(Clazz clazz, - RefConstant refConstant, - int parameterIndex, - Value value) - { - // We don't care about the parameter value. - } - - - /** - * Returns the value of the specified method parameter. - */ - protected Value getMethodParameterValue(Clazz clazz, - Method method, - int parameterIndex, - String type, - Clazz referencedClass) - { - return valueFactory.createValue(type, referencedClass, true); - } - - - /** - * Sets the return value of the specified method. - */ - protected void setMethodReturnValue(Clazz clazz, - Method method, - Value value) - { - // We don't care about the return value. - } - - - /** - * Returns the return value of the specified method. - */ - protected Value getMethodReturnValue(Clazz clazz, - RefConstant refConstant, - String type) - { - // Try to figure out the class of the return type. - returnTypeClass = null; - refConstant.referencedMemberAccept(this); - - return valueFactory.createValue(type, - returnTypeClass, - true); - } - - - /** - * Returns the return value of the specified method. - */ - protected Value getMethodReturnValue(Clazz clazz, - InvokeDynamicConstant invokeDynamicConstant, - String type) - { - // Try to figure out the class of the return type. - Clazz[] referencedClasses = invokeDynamicConstant.referencedClasses; - - Clazz returnTypeClass = referencedClasses == null ? null : - referencedClasses[referencedClasses.length - 1]; - - return valueFactory.createValue(type, - returnTypeClass, - true); - } - - - // Implementations for MemberVisitor. - - public void visitProgramField(ProgramClass programClass, ProgramField programField) - { - returnTypeClass = programField.referencedClass; - } - - - public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) - { - Clazz[] referencedClasses = programMethod.referencedClasses; - if (referencedClasses != null) - { - returnTypeClass = referencedClasses[referencedClasses.length - 1]; - } - } - - - public void visitLibraryField(LibraryClass programClass, LibraryField programField) - { - returnTypeClass = programField.referencedClass; - } - - - public void visitLibraryMethod(LibraryClass programClass, LibraryMethod programMethod) - { - Clazz[] referencedClasses = programMethod.referencedClasses; - if (referencedClasses != null) - { - returnTypeClass = referencedClasses[referencedClasses.length - 1]; - } - } -} diff --git a/src/proguard/evaluation/BranchUnit.java b/src/proguard/evaluation/BranchUnit.java deleted file mode 100644 index e81b61d..0000000 --- a/src/proguard/evaluation/BranchUnit.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.Clazz; -import proguard.classfile.attribute.CodeAttribute; - -/** - * This InstructionVisitor evaluates the instructions that it visits. - * - * @author Eric Lafortune - */ -public interface BranchUnit -{ - /** - * Sets the new instruction offset. - */ - public void branch(Clazz clazz, - CodeAttribute codeAttribute, - int offset, - int branchTarget); - - - /** - * Sets the new instruction offset, depending on the certainty of the - * conditional branch. - */ - public void branchConditionally(Clazz clazz, - CodeAttribute codeAttribute, - int offset, - int branchTarget, - int conditional); - - - /** - * Returns from the method with the given value. - */ - public void returnFromMethod(); - - - /** - * Handles the throwing of an exception. - */ - public void throwException(); -} diff --git a/src/proguard/evaluation/ClassConstantValueFactory.java b/src/proguard/evaluation/ClassConstantValueFactory.java deleted file mode 100644 index 62cc42c..0000000 --- a/src/proguard/evaluation/ClassConstantValueFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.constant.ClassConstant; -import proguard.evaluation.value.ValueFactory; - -/** - * This class creates java.lang.Class ReferenceValue instances that correspond - * to specified constant pool entries. - * - * @author Eric Lafortune - */ -public class ClassConstantValueFactory -extends ConstantValueFactory -{ - public ClassConstantValueFactory(ValueFactory valueFactory) - { - super(valueFactory); - } - - - // Implementations for ConstantVisitor. - - public void visitClassConstant(Clazz clazz, ClassConstant classConstant) - { - // Create a Class reference instead of a reference to the class. - value = valueFactory.createReferenceValue(ClassConstants.NAME_JAVA_LANG_CLASS, - classConstant.javaLangClassClass, - false); - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/ConstantValueFactory.java b/src/proguard/evaluation/ConstantValueFactory.java deleted file mode 100644 index 6875bde..0000000 --- a/src/proguard/evaluation/ConstantValueFactory.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.constant.*; -import proguard.classfile.constant.visitor.ConstantVisitor; -import proguard.classfile.util.SimplifiedVisitor; -import proguard.evaluation.value.*; - -/** - * This class creates Value instance that correspond to specified constant pool - * entries. - * - * @author Eric Lafortune - */ -public class ConstantValueFactory -extends SimplifiedVisitor -implements ConstantVisitor -{ - protected final ValueFactory valueFactory; - - // Field acting as a parameter for the ConstantVisitor methods. - protected Value value; - - - public ConstantValueFactory(ValueFactory valueFactory) - { - this.valueFactory = valueFactory; - } - - - /** - * Returns the Value of the constant pool element at the given index. - */ - public Value constantValue(Clazz clazz, - int constantIndex) - { - // Visit the constant pool entry to get its return value. - clazz.constantPoolEntryAccept(constantIndex, this); - - return value; - } - - - // Implementations for ConstantVisitor. - - public void visitIntegerConstant(Clazz clazz, IntegerConstant integerConstant) - { - value = valueFactory.createIntegerValue(integerConstant.getValue()); - } - - public void visitLongConstant(Clazz clazz, LongConstant longConstant) - { - value = valueFactory.createLongValue(longConstant.getValue()); - } - - public void visitFloatConstant(Clazz clazz, FloatConstant floatConstant) - { - value = valueFactory.createFloatValue(floatConstant.getValue()); - } - - public void visitDoubleConstant(Clazz clazz, DoubleConstant doubleConstant) - { - value = valueFactory.createDoubleValue(doubleConstant.getValue()); - } - - public void visitStringConstant(Clazz clazz, StringConstant stringConstant) - { - value = valueFactory.createReferenceValue(ClassConstants.NAME_JAVA_LANG_STRING, - stringConstant.javaLangStringClass, - false); - } - - public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant) - { - value = valueFactory.createReferenceValue(ClassConstants.NAME_JAVA_LANG_INVOKE_METHOD_HANDLE, - methodHandleConstant.javaLangInvokeMethodHandleClass, - false); - } - - public void visitClassConstant(Clazz clazz, ClassConstant classConstant) - { - value = valueFactory.createReferenceValue(classConstant.getName(clazz), - classConstant.referencedClass, - false); - } - - public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant) - { - value = valueFactory.createReferenceValue(ClassConstants.NAME_JAVA_LANG_INVOKE_METHOD_TYPE, - methodTypeConstant.javaLangInvokeMethodTypeClass, - false); - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/InvocationUnit.java b/src/proguard/evaluation/InvocationUnit.java deleted file mode 100644 index 0750894..0000000 --- a/src/proguard/evaluation/InvocationUnit.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.instruction.ConstantInstruction; -import proguard.evaluation.value.Value; - -/** - * This interface sets up the variables for entering a method, - * and it updates the stack for the invocation of a class member. - * - * @author Eric Lafortune - */ -public interface InvocationUnit -{ - /** - * Sets up the given variables for entering the given method. - */ - public void enterMethod(Clazz clazz, - Method method, - Variables variables); - - - /** - * Exits the given method with the given return value. - */ - public void exitMethod(Clazz clazz, - Method method, - Value returnValue); - - - /** - * Updates the given stack corresponding to the execution of the given - * field or method reference instruction. - */ - public void invokeMember(Clazz clazz, - Method method, - CodeAttribute codeAttribute, - int offset, - ConstantInstruction constantInstruction, - Stack stack); -} diff --git a/src/proguard/evaluation/Processor.java b/src/proguard/evaluation/Processor.java deleted file mode 100644 index d03b853..0000000 --- a/src/proguard/evaluation/Processor.java +++ /dev/null @@ -1,927 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.instruction.*; -import proguard.classfile.instruction.visitor.InstructionVisitor; -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 Processor -implements InstructionVisitor -{ - private final Variables variables; - private final Stack stack; - private final ValueFactory valueFactory; - private final BranchUnit branchUnit; - private final InvocationUnit invocationUnit; - private final boolean alwaysCast; - - private final ConstantValueFactory constantValueFactory; - private final ClassConstantValueFactory classConstantValueFactory; - - - /** - * 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. - * @param alwaysCast a flag that specifies whether downcasts or casts - * of null values should always be performed. - */ - public Processor(Variables variables, - Stack stack, - ValueFactory valueFactory, - BranchUnit branchUnit, - InvocationUnit invocationUnit, - boolean alwaysCast) - { - this.variables = variables; - this.stack = stack; - this.valueFactory = valueFactory; - this.branchUnit = branchUnit; - this.invocationUnit = invocationUnit; - this.alwaysCast = alwaysCast; - - constantValueFactory = new ConstantValueFactory(valueFactory); - classConstantValueFactory = new ClassConstantValueFactory(valueFactory); - } - - - // 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: - { - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - stack.push(arrayReference.integerArrayLoad(arrayIndex, valueFactory)); - break; - } - case InstructionConstants.OP_LALOAD: - { - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - stack.push(arrayReference.longArrayLoad(arrayIndex, valueFactory)); - break; - } - case InstructionConstants.OP_FALOAD: - { - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - stack.push(arrayReference.floatArrayLoad(arrayIndex, valueFactory)); - break; - } - case InstructionConstants.OP_DALOAD: - { - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - stack.push(arrayReference.doubleArrayLoad(arrayIndex, valueFactory)); - break; - } - case InstructionConstants.OP_AALOAD: - { - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - stack.push(arrayReference.referenceArrayLoad(arrayIndex, valueFactory)); - break; - } - case InstructionConstants.OP_IASTORE: - case InstructionConstants.OP_BASTORE: - case InstructionConstants.OP_CASTORE: - case InstructionConstants.OP_SASTORE: - { - Value value = stack.ipop(); - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - arrayReference.arrayStore(arrayIndex, value); - break; - } - case InstructionConstants.OP_LASTORE: - { - Value value = stack.lpop(); - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - arrayReference.arrayStore(arrayIndex, value); - break; - } - case InstructionConstants.OP_FASTORE: - { - Value value = stack.fpop(); - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - arrayReference.arrayStore(arrayIndex, value); - break; - } - case InstructionConstants.OP_DASTORE: - { - Value value = stack.dpop(); - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - arrayReference.arrayStore(arrayIndex, value); - break; - } - case InstructionConstants.OP_AASTORE: - { - Value value = stack.apop(); - IntegerValue arrayIndex = stack.ipop(); - ReferenceValue arrayReference = stack.apop(); - arrayReference.arrayStore(arrayIndex, value); - 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) - { - 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()); - 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())); - - LongValue longValue1 = stack.lpop(); - LongValue longValue2 = stack.lpop(); - stack.push(longValue2.compare(longValue1)); - 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: - 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: - ReferenceValue referenceValue = stack.apop(); - stack.push(referenceValue.arrayLength(valueFactory)); - 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(classConstantValueFactory.constantValue(clazz, constantIndex)); - 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: - case InstructionConstants.OP_INVOKEDYNAMIC: - invocationUnit.invokeMember(clazz, method, codeAttribute, offset, constantInstruction, stack); - break; - - case InstructionConstants.OP_NEW: - stack.push(constantValueFactory.constantValue(clazz, constantIndex).referenceValue()); - break; - - case InstructionConstants.OP_ANEWARRAY: - { - ReferenceValue referenceValue = constantValueFactory.constantValue(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 = - !alwaysCast && - castValue.isNull() == Value.ALWAYS ? castValue : - castValue.isNull() == Value.NEVER ? constantValueFactory.constantValue(clazz, constantIndex).referenceValue() : - constantValueFactory.constantValue(clazz, constantIndex).referenceValue().generalize(valueFactory.createReferenceValueNull()); - stack.push(castResultValue); - break; - - case InstructionConstants.OP_INSTANCEOF: - { - ReferenceValue referenceValue = constantValueFactory.constantValue(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(constantValueFactory.constantValue(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; - - 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: - variables.store(variableIndex, stack.fpop()); - break; - - case InstructionConstants.OP_DSTORE: - case InstructionConstants.OP_DSTORE_0: - case InstructionConstants.OP_DSTORE_1: - case InstructionConstants.OP_DSTORE_2: - case InstructionConstants.OP_DSTORE_3: - variables.store(variableIndex, stack.dpop()); - break; - - case InstructionConstants.OP_ASTORE: - case InstructionConstants.OP_ASTORE_0: - case InstructionConstants.OP_ASTORE_1: - case InstructionConstants.OP_ASTORE_2: - case InstructionConstants.OP_ASTORE_3: - // The operand on the stack can be a reference or a return - // address, so we'll relax the pop operation. - //variables.store(variableIndex, stack.apop()); - variables.store(variableIndex, stack.pop()); - break; - - case InstructionConstants.OP_IINC: - variables.store(variableIndex, - variables.iload(variableIndex).add( - valueFactory.createIntegerValue(variableInstruction.constant))); - break; - - case InstructionConstants.OP_RET: - // The return address should be in the last offset of the - // given instruction offset variable (even though there may - // be other offsets). - InstructionOffsetValue instructionOffsetValue = variables.oload(variableIndex); - branchUnit.branch(clazz, - codeAttribute, - offset, - instructionOffsetValue.instructionOffset(instructionOffsetValue.instructionOffsetCount()-1)); - break; - - default: - throw new IllegalArgumentException("Unknown variable instruction ["+variableInstruction.opcode+"]"); - } - } - - - public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) - { - int branchTarget = offset + branchInstruction.branchOffset; - - switch (branchInstruction.opcode) - { - case InstructionConstants.OP_IFEQ: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().equal(valueFactory.createIntegerValue(0))); - break; - - case InstructionConstants.OP_IFNE: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().notEqual(valueFactory.createIntegerValue(0))); - break; - - case InstructionConstants.OP_IFLT: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().lessThan(valueFactory.createIntegerValue(0))); - break; - - case InstructionConstants.OP_IFGE: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().greaterThanOrEqual(valueFactory.createIntegerValue(0))); - break; - - case InstructionConstants.OP_IFGT: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().greaterThan(valueFactory.createIntegerValue(0))); - break; - - case InstructionConstants.OP_IFLE: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().lessThanOrEqual(valueFactory.createIntegerValue(0))); - break; - - - case InstructionConstants.OP_IFICMPEQ: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().equal(stack.ipop())); - break; - - case InstructionConstants.OP_IFICMPNE: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().notEqual(stack.ipop())); - break; - - case InstructionConstants.OP_IFICMPLT: - // Note that the stack entries are popped in reverse order. - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().greaterThan(stack.ipop())); - break; - - case InstructionConstants.OP_IFICMPGE: - // Note that the stack entries are popped in reverse order. - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().lessThanOrEqual(stack.ipop())); - break; - - case InstructionConstants.OP_IFICMPGT: - // Note that the stack entries are popped in reverse order. - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().lessThan(stack.ipop())); - break; - - case InstructionConstants.OP_IFICMPLE: - // Note that the stack entries are popped in reverse order. - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.ipop().greaterThanOrEqual(stack.ipop())); - break; - - case InstructionConstants.OP_IFACMPEQ: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.apop().equal(stack.apop())); - break; - - case InstructionConstants.OP_IFACMPNE: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.apop().notEqual(stack.apop())); - break; - - case InstructionConstants.OP_GOTO: - case InstructionConstants.OP_GOTO_W: - branchUnit.branch(clazz, codeAttribute, offset, branchTarget); - break; - - - case InstructionConstants.OP_JSR: - case InstructionConstants.OP_JSR_W: - stack.push(new InstructionOffsetValue(offset + - branchInstruction.length(offset))); - branchUnit.branch(clazz, codeAttribute, offset, branchTarget); - break; - - case InstructionConstants.OP_IFNULL: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.apop().isNull()); - break; - - case InstructionConstants.OP_IFNONNULL: - branchUnit.branchConditionally(clazz, codeAttribute, offset, branchTarget, - stack.apop().isNotNull()); - break; - - default: - throw new IllegalArgumentException("Unknown branch instruction ["+branchInstruction.opcode+"]"); - } - } - - - public void visitTableSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, TableSwitchInstruction tableSwitchInstruction) - { - IntegerValue indexValue = stack.ipop(); - - // If there is no definite branch in any of the cases below, - // branch to the default offset. - branchUnit.branch(clazz, codeAttribute, - offset, - offset + tableSwitchInstruction.defaultOffset); - - for (int index = 0; index < tableSwitchInstruction.jumpOffsets.length; index++) - { - int conditional = indexValue.equal(valueFactory.createIntegerValue( - tableSwitchInstruction.lowCase + index)); - branchUnit.branchConditionally(clazz, codeAttribute, - offset, - offset + tableSwitchInstruction.jumpOffsets[index], - conditional); - - // If this branch is always taken, we can skip the rest. - if (conditional == Value.ALWAYS) - { - break; - } - } - } - - - public void visitLookUpSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LookUpSwitchInstruction lookUpSwitchInstruction) - { - IntegerValue indexValue = stack.ipop(); - - // If there is no definite branch in any of the cases below, - // branch to the default offset. - branchUnit.branch(clazz, codeAttribute, - offset, - offset + lookUpSwitchInstruction.defaultOffset); - - for (int index = 0; index < lookUpSwitchInstruction.jumpOffsets.length; index++) - { - int conditional = indexValue.equal(valueFactory.createIntegerValue( - lookUpSwitchInstruction.cases[index])); - branchUnit.branchConditionally(clazz, codeAttribute, - offset, - offset + lookUpSwitchInstruction.jumpOffsets[index], - conditional); - - // If this branch is always taken, we can skip the rest. - if (conditional == Value.ALWAYS) - { - break; - } - } - } -} diff --git a/src/proguard/evaluation/Stack.java b/src/proguard/evaluation/Stack.java deleted file mode 100644 index 9294853..0000000 --- a/src/proguard/evaluation/Stack.java +++ /dev/null @@ -1,560 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.evaluation.value.*; - -import java.util.Arrays; - -/** - * This class represents an operand stack that contains <code>Value</code> - * objects. - * - * @author Eric Lafortune - */ -public class Stack -{ - private static final TopValue TOP_VALUE = new TopValue(); - - - protected Value[] values; - protected int currentSize; - protected int actualMaxSize; - - - /** - * Creates a new Stack with a given maximum size, accounting for the double - * space required by Category 2 values. - */ - public Stack(int maxSize) - { - values = new Value[maxSize]; - } - - - /** - * Creates a Stack that is a copy of the given Stack. - */ - public Stack(Stack stack) - { - // Create the values array. - this(stack.values.length); - - // Copy the stack contents. - copy(stack); - } - - - /** - * Returns the actual maximum stack size that was required for all stack - * operations, accounting for the double space required by Category 2 values. - */ - public int getActualMaxSize() - { - return actualMaxSize; - } - - - /** - * Resets this Stack, so that it can be reused. - */ - public void reset(int maxSize) - { - // Is the values array large enough? - if (maxSize > values.length) - { - // Create a new one. - values = new Value[maxSize]; - } - - // Clear the sizes. - clear(); - - actualMaxSize = 0; - } - - - /** - * Copies the values of the given Stack into this Stack. - */ - public void copy(Stack other) - { - // Is the values array large enough? - if (other.values.length > values.length) - { - // Create a new one. - values = new Value[other.values.length]; - } - - // Copy the stack contents. - System.arraycopy(other.values, 0, this.values, 0, other.currentSize); - - // Copy the sizes. - currentSize = other.currentSize; - actualMaxSize = other.actualMaxSize; - } - - - /** - * Generalizes the values of this Stack with the values of the given Stack. - * The stacks must have the same current sizes. - * @return whether the generalization has made any difference. - */ - public boolean generalize(Stack other) - { - if (this.currentSize != other.currentSize) - { - throw new IllegalArgumentException("Stacks have different current sizes ["+this.currentSize+"] and ["+other.currentSize+"]"); - } - - boolean changed = false; - - // Generalize the stack values. - for (int index = 0; index < currentSize; index++) - { - Value thisValue = this.values[index]; - - if (thisValue != null) - { - Value newValue = null; - - Value otherValue = other.values[index]; - - if (otherValue != null) - { - newValue = thisValue.generalize(otherValue); - } - - changed = changed || !thisValue.equals(newValue); - - values[index] = newValue; - } - } - - // Check if the other stack extends beyond this one. - if (this.actualMaxSize < other.actualMaxSize) - { - this.actualMaxSize = other.actualMaxSize; - } - - return changed; - } - - - /** - * Clears the stack. - */ - public void clear() - { - // Clear the stack contents. - Arrays.fill(values, 0, currentSize, null); - - currentSize = 0; - } - - - /** - * Returns the number of elements currently on the stack, accounting for the - * double space required by Category 2 values. - */ - public int size() - { - return currentSize; - } - - - /** - * Gets the specified Value from the stack, without disturbing it. - * @param index the index of the stack element, counting from the bottom - * of the stack. - * @return the value at the specified position. - */ - public Value getBottom(int index) - { - return values[index]; - } - - - /** - * Sets the specified Value on the stack, without disturbing it. - * @param index the index of the stack element, counting from the bottom - * of the stack. - * @param value the value to set. - */ - public void setBottom(int index, Value value) - { - values[index] = value; - } - - - /** - * Gets the specified Value from the stack, without disturbing it. - * @param index the index of the stack element, counting from the top - * of the stack. - * @return the value at the specified position. - */ - public Value getTop(int index) - { - return values[currentSize - index - 1]; - } - - - /** - * Sets the specified Value on the stack, without disturbing it. - * @param index the index of the stack element, counting from the top - * of the stack. - * @param value the value to set. - */ - public void setTop(int index, Value value) - { - values[currentSize - index - 1] = value; - } - - - /** - * Removes the specified Value from the stack. - * @param index the index of the stack element, counting from the top - * of the stack. - */ - public void removeTop(int index) - { - System.arraycopy(values, currentSize - index, - values, currentSize - index - 1, - index); - currentSize--; - } - - - /** - * Pushes the given Value onto the stack. - */ - public void push(Value value) - { - // Account for the extra space required by Category 2 values. - if (value.isCategory2()) - { - values[currentSize++] = TOP_VALUE; - } - - // Push the value. - values[currentSize++] = value; - - // Update the maximum actual size; - if (actualMaxSize < currentSize) - { - actualMaxSize = currentSize; - } - } - - - /** - * Pops the top Value from the stack. - */ - public Value pop() - { - Value value = values[--currentSize]; - - values[currentSize] = null; - - // Account for the extra space required by Category 2 values. - if (value.isCategory2()) - { - values[--currentSize] = null; - } - - return value; - } - - - // Pop methods that provide convenient casts to the expected value types. - - /** - * Pops the top IntegerValue from the stack. - */ - public IntegerValue ipop() - { - return pop().integerValue(); - } - - - /** - * Pops the top LongValue from the stack. - */ - public LongValue lpop() - { - return pop().longValue(); - } - - - /** - * Pops the top FloatValue from the stack. - */ - public FloatValue fpop() - { - return pop().floatValue(); - } - - - /** - * Pops the top DoubleValue from the stack. - */ - public DoubleValue dpop() - { - return pop().doubleValue(); - } - - - /** - * Pops the top ReferenceValue from the stack. - */ - public ReferenceValue apop() - { - return pop().referenceValue(); - } - - - /** - * Pops the top InstructionOffsetValue from the stack. - */ - public InstructionOffsetValue opop() - { - return pop().instructionOffsetValue(); - } - - - /** - * Pops the top category 1 value from the stack. - */ - public void pop1() - { - values[--currentSize] = null; - } - - - /** - * Pops the top category 2 value from the stack (or alternatively, two - * Category 1 stack elements). - */ - public void pop2() - { - values[--currentSize] = null; - values[--currentSize] = null; - } - - - /** - * Duplicates the top Category 1 value. - */ - public void dup() - { - values[currentSize] = values[currentSize - 1].category1Value(); - - currentSize++; - - // Update the maximum actual size; - if (actualMaxSize < currentSize) - { - actualMaxSize = currentSize; - } - } - - - /** - * Duplicates the top Category 1 value, one Category 1 element down the - * stack. - */ - public void dup_x1() - { - values[currentSize] = values[currentSize - 1].category1Value(); - values[currentSize - 1] = values[currentSize - 2].category1Value(); - values[currentSize - 2] = values[currentSize ]; - - currentSize++; - - // Update the maximum actual size; - if (actualMaxSize < currentSize) - { - actualMaxSize = currentSize; - } - } - - - /** - * Duplicates the top Category 1 value, two Category 1 elements (or one - * Category 2 element) down the stack. - */ - public void dup_x2() - { - values[currentSize] = values[currentSize - 1].category1Value(); - values[currentSize - 1] = values[currentSize - 2]; - values[currentSize - 2] = values[currentSize - 3]; - values[currentSize - 3] = values[currentSize ]; - - currentSize++; - - // Update the maximum actual size; - if (actualMaxSize < currentSize) - { - actualMaxSize = currentSize; - } - } - - /** - * Duplicates the top Category 2 value (or alternatively, the equivalent - * Category 1 stack elements). - */ - public void dup2() - { - values[currentSize ] = values[currentSize - 2]; - values[currentSize + 1] = values[currentSize - 1]; - - currentSize += 2; - - // Update the maximum actual size; - if (actualMaxSize < currentSize) - { - actualMaxSize = currentSize; - } - } - - - /** - * Duplicates the top Category 2 value, one Category 1 element down the - * stack (or alternatively, the equivalent Category 1 stack values). - */ - public void dup2_x1() - { - values[currentSize + 1] = values[currentSize - 1]; - values[currentSize ] = values[currentSize - 2]; - values[currentSize - 1] = values[currentSize - 3]; - values[currentSize - 2] = values[currentSize + 1]; - values[currentSize - 3] = values[currentSize ]; - - currentSize += 2; - - // Update the maximum actual size; - if (actualMaxSize < currentSize) - { - actualMaxSize = currentSize; - } - } - - - /** - * Duplicates the top Category 2 value, one Category 2 stack element down - * the stack (or alternatively, the equivalent Category 1 stack values). - */ - public void dup2_x2() - { - values[currentSize + 1] = values[currentSize - 1]; - values[currentSize ] = values[currentSize - 2]; - values[currentSize - 1] = values[currentSize - 3]; - values[currentSize - 2] = values[currentSize - 4]; - values[currentSize - 3] = values[currentSize + 1]; - values[currentSize - 4] = values[currentSize ]; - - currentSize += 2; - - // Update the maximum actual size; - if (actualMaxSize < currentSize) - { - actualMaxSize = currentSize; - } - } - - - /** - * Swaps the top two Category 1 values. - */ - public void swap() - { - Value value1 = values[currentSize - 1].category1Value(); - Value value2 = values[currentSize - 2].category1Value(); - - values[currentSize - 1] = value2; - values[currentSize - 2] = value1; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - if (object == null || - this.getClass() != object.getClass()) - { - return false; - } - - Stack other = (Stack)object; - - if (this.currentSize != other.currentSize) - { - return false; - } - - for (int index = 0; index < currentSize; index++) - { - Value thisValue = this.values[index]; - Value otherValue = other.values[index]; - if (thisValue == null ? otherValue != null : - !thisValue.equals(otherValue)) - { - return false; - } - } - - return true; - } - - - public int hashCode() - { - int hashCode = currentSize; - - for (int index = 0; index < currentSize; index++) - { - Value value = values[index]; - if (value != null) - { - hashCode ^= value.hashCode(); - } - } - - return hashCode; - } - - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - - for (int index = 0; index < currentSize; index++) - { - Value value = values[index]; - buffer = buffer.append('[') - .append(value == null ? "empty" : value.toString()) - .append(']'); - } - - return buffer.toString(); - } -} diff --git a/src/proguard/evaluation/TracedStack.java b/src/proguard/evaluation/TracedStack.java deleted file mode 100644 index 08e30e9..0000000 --- a/src/proguard/evaluation/TracedStack.java +++ /dev/null @@ -1,374 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.evaluation.value.Value; - -/** - * This Stack saves additional information with stack elements, to keep track - * of their origins. - * <p> - * The stack stores a given producer Value along with each Value it stores. - * It then generalizes a given collected Value with the producer Value - * of each Value it loads. The producer Value and the initial collected Value - * can be set. The generalized collected Value can be retrieved, either taking - * into account dup/swap instructions as proper instructions or ignoring them. - * - * @author Eric Lafortune - */ -public class TracedStack extends Stack -{ - private Value producerValue; - private Stack producerStack; - private Stack actualProducerStack; - - - /** - * Creates a new TracedStack with a given maximum size. - */ - public TracedStack(int maxSize) - { - super(maxSize); - - producerStack = new Stack(maxSize); - actualProducerStack = new Stack(maxSize); - } - - - /** - * Creates a new TracedStack that is a copy of the given TracedStack. - */ - public TracedStack(TracedStack tracedStack) - { - super(tracedStack); - - producerStack = new Stack(tracedStack.producerStack); - actualProducerStack = new Stack(tracedStack.actualProducerStack); - } - - - /** - * Sets the Value that will be stored along with all push and pop - * instructions. - */ - public void setProducerValue(Value producerValue) - { - this.producerValue = producerValue; - } - - - /** - * Gets the specified producer Value from the stack, without disturbing it. - * @param index the index of the stack element, counting from the bottom - * of the stack. - * @return the producer value at the specified position. - */ - public Value getBottomProducerValue(int index) - { - return producerStack.getBottom(index); - } - - - /** - * Gets the specified actual producer Value from the stack, ignoring - * dup/swap instructions, without disturbing it. - * @param index the index of the stack element, counting from the bottom - * of the stack. - * @return the producer value at the specified position. - */ - public Value getBottomActualProducerValue(int index) - { - return actualProducerStack.getBottom(index); - } - - - /** - * Gets the specified producer Value from the stack, without disturbing it. - * @param index the index of the stack element, counting from the top - * of the stack. - * @return the producer value at the specified position. - */ - public Value getTopProducerValue(int index) - { - return producerStack.getTop(index); - } - - - /** - * Gets the specified actual producer Value from the stack, ignoring - * dup/swap instructions, without disturbing it. - * @param index the index of the stack element, counting from the top - * of the stack. - * @return the producer value at the specified position. - */ - public Value getTopActualProducerValue(int index) - { - return actualProducerStack.getTop(index); - } - - - // Implementations for Stack. - - public void reset(int size) - { - super.reset(size); - - producerStack.reset(size); - actualProducerStack.reset(size); - } - - public void copy(TracedStack other) - { - super.copy(other); - - producerStack.copy(other.producerStack); - actualProducerStack.copy(other.actualProducerStack); - } - - public boolean generalize(TracedStack other) - { - return - super.generalize(other) | - producerStack.generalize(other.producerStack) | - actualProducerStack.generalize(other.actualProducerStack); - } - - public void clear() - { - super.clear(); - - producerStack.clear(); - actualProducerStack.clear(); - } - - public void removeTop(int index) - { - super.removeTop(index); - - producerStack.removeTop(index); - actualProducerStack.removeTop(index); - } - - public void push(Value value) - { - super.push(value); - - producerPush(); - - // Account for the extra space required by Category 2 values. - if (value.isCategory2()) - { - producerPush(); - } - } - - public Value pop() - { - Value value = super.pop(); - - producerPop(); - - // Account for the extra space required by Category 2 values. - if (value.isCategory2()) - { - producerPop(); - } - - return value; - } - - public void pop1() - { - super.pop1(); - - producerPop(); - } - - public void pop2() - { - super.pop2(); - - producerPop(); - producerPop(); - } - - public void dup() - { - super.dup(); - - producerStack.pop(); - producerStack.push(producerValue); - producerStack.push(producerValue); - - actualProducerStack.dup(); - } - - public void dup_x1() - { - super.dup_x1(); - - producerStack.pop(); - producerStack.pop(); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - - actualProducerStack.dup_x1(); - } - - public void dup_x2() - { - super.dup_x2(); - - producerStack.pop(); - producerStack.pop(); - producerStack.pop(); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - - actualProducerStack.dup_x2(); - } - - public void dup2() - { - super.dup2(); - - producerStack.pop(); - producerStack.pop(); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - - actualProducerStack.dup2(); - } - - public void dup2_x1() - { - super.dup2_x1(); - - producerStack.pop(); - producerStack.pop(); - producerStack.pop(); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - - actualProducerStack.dup2_x1(); - } - - public void dup2_x2() - { - super.dup2_x2(); - - producerStack.pop(); - producerStack.pop(); - producerStack.pop(); - producerStack.pop(); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - producerStack.push(producerValue); - - actualProducerStack.dup2_x2(); - } - - public void swap() - { - super.swap(); - - producerStack.pop(); - producerStack.pop(); - producerStack.push(producerValue); - producerStack.push(producerValue); - - actualProducerStack.swap(); - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - if (object == null || - this.getClass() != object.getClass()) - { - return false; - } - - TracedStack other = (TracedStack)object; - - return super.equals(object) && - this.producerStack.equals(other.producerStack) && - this.actualProducerStack.equals(other.actualProducerStack); - } - - - public int hashCode() - { - return super.hashCode() ^ - producerStack.hashCode() ^ - actualProducerStack.hashCode(); - } - - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - - for (int index = 0; index < this.size(); index++) - { - Value value = this.values[index]; - Value producerValue = producerStack.getBottom(index); - Value actualProducerValue = actualProducerStack.getBottom(index); - buffer = buffer.append('[') - .append(producerValue == null ? "empty:" : - producerValue.equals(actualProducerValue) ? producerValue.toString() : - producerValue.toString() + actualProducerValue.toString()) - .append(value == null ? "empty" : value.toString()) - .append(']'); - } - - return buffer.toString(); - } - - - // Small utility methods. - - private void producerPush() - { - producerStack.push(producerValue); - actualProducerStack.push(producerValue); - } - - - private void producerPop() - { - producerStack.pop(); - actualProducerStack.pop(); - } -} diff --git a/src/proguard/evaluation/TracedVariables.java b/src/proguard/evaluation/TracedVariables.java deleted file mode 100644 index 23e3041..0000000 --- a/src/proguard/evaluation/TracedVariables.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.evaluation.value.Value; - -/** - * This Variables class saves additional information with variables, to keep - * track of their origins. - * <p> - * The Variables class stores a given producer Value along with each Value it - * stores. It then generalizes a given collected Value with the producer Value - * of each Value it loads. The producer Value and the initial collected Value - * can be set; the generalized collected Value can be retrieved. - * - * @author Eric Lafortune - */ -public class TracedVariables extends Variables -{ - public static final int NONE = -1; - - - private Value producerValue; - private Variables producerVariables; - - - /** - * Creates a new TracedVariables with a given size. - */ - public TracedVariables(int size) - { - super(size); - - producerVariables = new Variables(size); - } - - - /** - * Creates a new TracedVariables that is a copy of the given TracedVariables. - */ - public TracedVariables(TracedVariables tracedVariables) - { - super(tracedVariables); - - producerVariables = new Variables(tracedVariables.producerVariables); - } - - - /** - * Sets the Value that will be stored along with all store instructions. - */ - public void setProducerValue(Value producerValue) - { - this.producerValue = producerValue; - } - - - /** - * Gets the producer Value for the specified variable, without disturbing it. - * @param index the variable index. - * @return the producer value of the given variable. - */ - public Value getProducerValue(int index) - { - return producerVariables.getValue(index); - } - - - /** - * Sets the given producer Value for the specified variable, without - * disturbing it. - * @param index the variable index. - * @param value the producer value to set. - */ - public void setProducerValue(int index, Value value) - { - producerVariables.store(index, value); - } - - - // Implementations for Variables. - - public void reset(int size) - { - super.reset(size); - - producerVariables.reset(size); - } - - public void initialize(TracedVariables other) - { - super.initialize(other); - - producerVariables.initialize(other.producerVariables); - } - - public boolean generalize(TracedVariables other, - boolean clearConflictingOtherVariables) - { - boolean variablesChanged = super.generalize(other, clearConflictingOtherVariables); - boolean producersChanged = producerVariables.generalize(other.producerVariables, clearConflictingOtherVariables); - /* consumerVariables.generalize(other.consumerVariables)*/ - - // Clear any traces if a variable has become null. - if (variablesChanged) - { - for (int index = 0; index < size; index++) - { - if (values[index] == null) - { - producerVariables.values[index] = null; - - if (clearConflictingOtherVariables) - { - other.producerVariables.values[index] = null; - } - } - } - } - - return variablesChanged || producersChanged; - } - - - public void store(int index, Value value) - { - // Store the value itself in the variable. - super.store(index, value); - - // Store the producer value in its producer variable. - producerVariables.store(index, producerValue); - - // Account for the extra space required by Category 2 values. - if (value.isCategory2()) - { - producerVariables.store(index+1, producerValue); - } - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - if (object == null || - this.getClass() != object.getClass()) - { - return false; - } - - TracedVariables other = (TracedVariables)object; - - return super.equals(object) && - this.producerVariables.equals(other.producerVariables); - } - - - public int hashCode() - { - return super.hashCode() ^ - producerVariables.hashCode(); - } - - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - - for (int index = 0; index < this.size(); index++) - { - Value value = this.values[index]; - Value producerValue = producerVariables.getValue(index); - buffer = buffer.append('[') - .append(producerValue == null ? "empty:" : producerValue.toString()) - .append(value == null ? "empty" : value.toString()) - .append(']'); - } - - return buffer.toString(); - } -} diff --git a/src/proguard/evaluation/Variables.java b/src/proguard/evaluation/Variables.java deleted file mode 100644 index 4b3a2a4..0000000 --- a/src/proguard/evaluation/Variables.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.evaluation.value.*; - -import java.util.Arrays; - -/** - * This class represents a local variable frame that contains <code>Value</code> - * objects. Values are generalizations of all values that have been stored in - * the respective variables. - * - * @author Eric Lafortune - */ -public class Variables -{ - private static final TopValue TOP_VALUE = new TopValue(); - - - protected Value[] values; - protected int size; - - - /** - * Creates a new Variables object with a given maximum number of variables. - */ - public Variables(int size) - { - this.values = new Value[size]; - this.size = size; - } - - - /** - * Creates a Variables object that is a copy of the given Variables object. - */ - public Variables(Variables variables) - { - // Create the values array. - this(variables.size); - - // Copy the values. - initialize(variables); - } - - - /** - * Resets this Variables object, so that it can be reused. - */ - public void reset(int size) - { - // Is the values array large enough? - if (size > values.length) - { - // Create a new one. - values = new Value[size]; - } - else - { - // Clear the variables. - Arrays.fill(values, null); - } - - this.size = size; - } - - - /** - * Initializes the values of this Variables object with the values of the - * given Variables object. The other object may have fewer values, in which - * case the remaining values are left unchanged. - */ - public void initialize(Variables other) - { - if (this.size < other.size) - { - throw new IllegalArgumentException("Variable frame is too small ["+this.size+"] compared to other frame ["+other.size+"]"); - } - - // Copy the values. - System.arraycopy(other.values, 0, this.values, 0, other.size); - } - - - /** - * Generalizes the values of this Variables object with the values of the - * given Variables object. - * @param clearConflictingOtherVariables specifies whether the other - * variables should be cleared too, - * in case of conflicts. - * @return whether the generalization has made any difference. - */ - public boolean generalize(Variables other, - boolean clearConflictingOtherVariables) - { - if (this.size != other.size) - { - throw new IllegalArgumentException("Variable frames have different sizes ["+this.size+"] and ["+other.size+"]"); - } - - boolean changed = false; - - for (int index = 0; index < size; index++) - { - Value thisValue = this.values[index]; - Value otherValue = other.values[index]; - - // Occasionally, two values of different types might be present - // in the same variable in a variable frame (corresponding to - // two local variables that share the same index), at some point - // outside of their scopes. Don't generalize the variable then, - // but let it clear instead. - if (thisValue != null && - otherValue != null && - thisValue.computationalType() == otherValue.computationalType()) - { - Value newValue = thisValue.generalize(otherValue); - - changed = changed || !thisValue.equals(newValue); - - this.values[index] = newValue; - } - else - { - changed = changed || thisValue != null; - - this.values[index] = null; - - if (clearConflictingOtherVariables) - { - other.values[index] = null; - } - } - } - - return changed; - } - - - /** - * Returns the number of variables. - */ - public int size() - { - return size; - } - - - /** - * Gets the Value of the variable with the given index, without disturbing it. - */ - public Value getValue(int index) - { - if (index < 0 || - index >= size) - { - throw new IndexOutOfBoundsException("Variable index ["+index+"] out of bounds ["+size+"]"); - } - - return values[index]; - } - - - /** - * Stores the given Value at the given variable index. - */ - public void store(int index, Value value) - { - if (index < 0 || - index >= size) - { - throw new IndexOutOfBoundsException("Variable index ["+index+"] out of bounds ["+size+"]"); - } - - // Store the value. - values[index] = value; - - // Account for the extra space required by Category 2 values. - if (value.isCategory2()) - { - values[index + 1] = TOP_VALUE; - } - } - - - /** - * Loads the Value from the variable with the given index. - */ - public Value load(int index) - { - if (index < 0 || - index >= size) - { - throw new IndexOutOfBoundsException("Variable index ["+index+"] out of bounds ["+size+"]"); - } - - return values[index]; - } - - - // Load methods that provide convenient casts to the expected value types. - - /** - * Loads the IntegerValue from the variable with the given index. - */ - public IntegerValue iload(int index) - { - return load(index).integerValue(); - } - - - /** - * Loads the LongValue from the variable with the given index. - */ - public LongValue lload(int index) - { - return load(index).longValue(); - } - - - /** - * Loads the FloatValue from the variable with the given index. - */ - public FloatValue fload(int index) - { - return load(index).floatValue(); - } - - - /** - * Loads the DoubleValue from the variable with the given index. - */ - public DoubleValue dload(int index) - { - return load(index).doubleValue(); - } - - - /** - * Loads the ReferenceValue from the variable with the given index. - */ - public ReferenceValue aload(int index) - { - return load(index).referenceValue(); - } - - - /** - * Loads the InstructionOffsetValue from the variable with the given index. - */ - public InstructionOffsetValue oload(int index) - { - return load(index).instructionOffsetValue(); - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - if (object == null || - this.getClass() != object.getClass()) - { - return false; - } - - Variables other = (Variables)object; - - if (this.size != other.size) - { - return false; - } - - for (int index = 0; index < size; index++) - { - Value thisValue = this.values[index]; - Value otherValue = other.values[index]; - - // Occasionally, two values of different types might be - // present in the same variable in a variable frame - // (corresponding to two local variables that share the - // same index), at some point outside of their scopes. - // We'll ignore these. - if (thisValue != null && - otherValue != null && - thisValue.computationalType() == otherValue.computationalType() && - !thisValue.equals(otherValue)) - { - return false; - } - } - - return true; - } - - - public int hashCode() - { - int hashCode = size; - - for (int index = 0; index < size; index++) - { - Value value = values[index]; - if (value != null) - { - hashCode ^= value.hashCode(); - } - } - - return hashCode; - } - - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - - for (int index = 0; index < size; index++) - { - Value value = values[index]; - buffer = buffer.append('[') - .append(value == null ? "empty" : value.toString()) - .append(']'); - } - - return buffer.toString(); - } -} diff --git a/src/proguard/evaluation/value/ArrayReferenceValue.java b/src/proguard/evaluation/value/ArrayReferenceValue.java deleted file mode 100644 index 56f18ad..0000000 --- a/src/proguard/evaluation/value/ArrayReferenceValue.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.Clazz; - -/** - * This ReferenceValue represents a partially evaluated array. It has an array - * length and possibly array values (up to a fixed maximum number). It is not - * immutable. - * - * @author Eric Lafortune - */ -class ArrayReferenceValue extends TypedReferenceValue -{ - protected final IntegerValue arrayLength; - - - /** - * Creates a new ArrayReferenceValue. - */ - public ArrayReferenceValue(String type, - Clazz referencedClass, - IntegerValue arrayLength) - { - super(type, referencedClass, false); - - this.arrayLength = arrayLength; - } - - - // Implementations for ReferenceValue. - - public IntegerValue arrayLength(ValueFactory valueFactory) - { - return arrayLength; - } - - - // Implementations of binary methods of ReferenceValue. - - public ReferenceValue generalize(ReferenceValue other) - { - return other.generalize(this); - } - - - public int equal(ReferenceValue other) - { - return other.equal(this); - } - - -// // Implementations of binary ReferenceValue methods with -// // IdentifiedReferenceValue arguments. -// -// public ReferenceValue generalize(IdentifiedReferenceValue other) -// { -// return generalize((TypedReferenceValue)other); -// } -// -// -// public int equal(IdentifiedReferenceValue other) -// { -// return equal((TypedReferenceValue)other); -// } - - - // Implementations of binary ReferenceValue methods with - // ArrayReferenceValue arguments. - - public ReferenceValue generalize(ArrayReferenceValue other) - { - return - this.equals(other) ? this : - this.type != null && - this.type.equals(other.type) && - this.referencedClass == other.referencedClass ? new ArrayReferenceValue(this.type, - this.referencedClass, - this.arrayLength.generalize(other.arrayLength)) : - generalize((TypedReferenceValue)other); - } - - - public int equal(ArrayReferenceValue other) - { - if (this.arrayLength.equal(other.arrayLength) == NEVER) - { - return NEVER; - } - - return equal((TypedReferenceValue)other); - } - - -// // Implementations of binary ReferenceValue methods with -// // IdentifiedArrayReferenceValue arguments. -// -// public ReferenceValue generalize(IdentifiedArrayReferenceValue other) -// { -// return generalize((ArrayReferenceValue)other); -// } -// -// -// public int equal(IdentifiedArrayReferenceValue other) -// { -// return equal((ArrayReferenceValue)other); -// } -// -// -// // Implementations of binary ReferenceValue methods with -// // DetailedArrayReferenceValue arguments. -// -// public ReferenceValue generalize(DetailedArrayReferenceValue other) -// { -// return generalize((IdentifiedArrayReferenceValue)other); -// } -// -// -// public int equal(DetailedArrayReferenceValue other) -// { -// return equal((IdentifiedArrayReferenceValue)other); -// } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.arrayLength.equals(((ArrayReferenceValue)object).arrayLength); - } - - - public int hashCode() - { - return super.hashCode() ^ - arrayLength.hashCode(); - } - - - public String toString() - { - return super.toString() + '['+arrayLength+']'; - } -} diff --git a/src/proguard/evaluation/value/Category1Value.java b/src/proguard/evaluation/value/Category1Value.java deleted file mode 100644 index 777e3e3..0000000 --- a/src/proguard/evaluation/value/Category1Value.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This abstract class represents a partially evaluated Category 1 value. - * - * @author Eric Lafortune - */ -public abstract class Category1Value extends Value -{ - // Implementations for Value. - - public final Category1Value category1Value() - { - return this; - } - - public final boolean isCategory2() - { - return false; - } -} diff --git a/src/proguard/evaluation/value/Category2Value.java b/src/proguard/evaluation/value/Category2Value.java deleted file mode 100644 index 80c2183..0000000 --- a/src/proguard/evaluation/value/Category2Value.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This abstract class represents a partially evaluated Category 2 value. - * - * @author Eric Lafortune - */ -public abstract class Category2Value extends Value -{ - // Implementations for Value. - - public final Category2Value category2Value() - { - return this; - } - - public final boolean isCategory2() - { - return true; - } -} diff --git a/src/proguard/evaluation/value/ComparisonValue.java b/src/proguard/evaluation/value/ComparisonValue.java deleted file mode 100644 index e2cd94e..0000000 --- a/src/proguard/evaluation/value/ComparisonValue.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents the result of a comparisons of two scalar - * values. - * - * @author Eric Lafortune - */ -final class ComparisonValue extends SpecificIntegerValue -{ - private final Value value1; - private final Value value2; - - - /** - * Creates a new comparison integer value of the two given scalar values. - */ - public ComparisonValue(Value value1, - Value value2) - { - this.value1 = value1; - this.value2 = value2; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.value1.equals(((ComparisonValue)object).value1) && - this.value2.equals(((ComparisonValue)object).value2); - } - - - public int hashCode() - { - return super.hashCode() ^ - value1.hashCode() ^ - value2.hashCode(); - } - - - public String toString() - { - return "("+value1+"~"+ value2 +")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/CompositeDoubleValue.java b/src/proguard/evaluation/value/CompositeDoubleValue.java deleted file mode 100644 index 85b606a..0000000 --- a/src/proguard/evaluation/value/CompositeDoubleValue.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This DoubleValue represents the result of a binary operation on two double - * values. - * - * @author Eric Lafortune - */ -final class CompositeDoubleValue extends SpecificDoubleValue -{ - public static final byte ADD = '+'; - public static final byte SUBTRACT = '-'; - public static final byte MULTIPLY = '*'; - public static final byte DIVIDE = '/'; - public static final byte REMAINDER = '%'; - - - private final DoubleValue doubleValue1; - private final byte operation; - private final DoubleValue doubleValue2; - - - /** - * Creates a new composite double value of the two given double values - * and the given operation. - */ - public CompositeDoubleValue(DoubleValue doubleValue1, - byte operation, - DoubleValue doubleValue2) - { - this.doubleValue1 = doubleValue1; - this.operation = operation; - this.doubleValue2 = doubleValue2; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.doubleValue1.equals(((CompositeDoubleValue)object).doubleValue1) && - this.operation == ((CompositeDoubleValue)object).operation && - this.doubleValue2.equals(((CompositeDoubleValue)object).doubleValue2); - } - - - public int hashCode() - { - return super.hashCode() ^ - doubleValue1.hashCode() ^ - doubleValue2.hashCode(); - } - - - public String toString() - { - return "("+doubleValue1+((char)operation)+doubleValue2+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/CompositeFloatValue.java b/src/proguard/evaluation/value/CompositeFloatValue.java deleted file mode 100644 index 35f160f..0000000 --- a/src/proguard/evaluation/value/CompositeFloatValue.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This FloatValue represents the result of a binary operation on two float - * values. - * - * @author Eric Lafortune - */ -final class CompositeFloatValue extends SpecificFloatValue -{ - public static final byte ADD = '+'; - public static final byte SUBTRACT = '-'; - public static final byte MULTIPLY = '*'; - public static final byte DIVIDE = '/'; - public static final byte REMAINDER = '%'; - - - private final FloatValue floatValue1; - private final byte operation; - private final FloatValue floatValue2; - - - /** - * Creates a new composite float value of the two given float values - * and the given operation. - */ - public CompositeFloatValue(FloatValue floatValue1, - byte operation, - FloatValue floatValue2) - { - this.floatValue1 = floatValue1; - this.operation = operation; - this.floatValue2 = floatValue2; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.floatValue1.equals(((CompositeFloatValue)object).floatValue1) && - this.operation == ((CompositeFloatValue)object).operation && - this.floatValue2.equals(((CompositeFloatValue)object).floatValue2); - } - - - public int hashCode() - { - return super.hashCode() ^ - floatValue1.hashCode() ^ - floatValue2.hashCode(); - } - - - public String toString() - { - return "("+floatValue1+((char)operation)+floatValue2+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/CompositeIntegerValue.java b/src/proguard/evaluation/value/CompositeIntegerValue.java deleted file mode 100644 index de56452..0000000 --- a/src/proguard/evaluation/value/CompositeIntegerValue.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents the result of a binary operation on two integer - * values. - * - * @author Eric Lafortune - */ -final class CompositeIntegerValue extends SpecificIntegerValue -{ - public static final byte ADD = '+'; - public static final byte SUBTRACT = '-'; - public static final byte MULTIPLY = '*'; - public static final byte DIVIDE = '/'; - public static final byte REMAINDER = '%'; - public static final byte SHIFT_LEFT = '<'; - public static final byte SHIFT_RIGHT = '>'; - public static final byte UNSIGNED_SHIFT_RIGHT = '}'; - public static final byte AND = '&'; - public static final byte OR = '|'; - public static final byte XOR = '^'; - - - private final IntegerValue integerValue1; - private final byte operation; - private final IntegerValue integerValue2; - - - /** - * Creates a new composite integer value of the two given integer values - * and the given operation. - */ - public CompositeIntegerValue(IntegerValue integerValue1, - byte operation, - IntegerValue integerValue2) - { - this.integerValue1 = integerValue1; - this.operation = operation; - this.integerValue2 = integerValue2; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.integerValue1.equals(((CompositeIntegerValue)object).integerValue1) && - this.operation == ((CompositeIntegerValue)object).operation && - this.integerValue2.equals(((CompositeIntegerValue)object).integerValue2); - } - - - public int hashCode() - { - return super.hashCode() ^ - integerValue1.hashCode() ^ - integerValue2.hashCode(); - } - - - public String toString() - { - return "("+integerValue1+((char)operation)+integerValue2+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/CompositeLongValue.java b/src/proguard/evaluation/value/CompositeLongValue.java deleted file mode 100644 index 70351c8..0000000 --- a/src/proguard/evaluation/value/CompositeLongValue.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This LongValue represents the result of a binary operation on two long - * values. - * - * @author Eric Lafortune - */ -final class CompositeLongValue extends SpecificLongValue -{ - public static final byte ADD = '+'; - public static final byte SUBTRACT = '-'; - public static final byte MULTIPLY = '*'; - public static final byte DIVIDE = '/'; - public static final byte REMAINDER = '%'; - public static final byte SHIFT_LEFT = '<'; - public static final byte SHIFT_RIGHT = '>'; - public static final byte UNSIGNED_SHIFT_RIGHT = '}'; - public static final byte AND = '&'; - public static final byte OR = '|'; - public static final byte XOR = '^'; - - - private final LongValue longValue1; - private final byte operation; - private final Value longValue2; - - - /** - * Creates a new composite long value of the two given long values - * and the given operation. - */ - public CompositeLongValue(LongValue longValue1, - byte operation, - Value longValue2) - { - this.longValue1 = longValue1; - this.operation = operation; - this.longValue2 = longValue2; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.longValue1.equals(((CompositeLongValue)object).longValue1) && - this.operation == ((CompositeLongValue)object).operation && - this.longValue2.equals(((CompositeLongValue)object).longValue2); - } - - - public int hashCode() - { - return super.hashCode() ^ - longValue1.hashCode() ^ - longValue2.hashCode(); - } - - - public String toString() - { - return "("+longValue1+((char)operation)+longValue2+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ConvertedByteValue.java b/src/proguard/evaluation/value/ConvertedByteValue.java deleted file mode 100644 index 6fd96e4..0000000 --- a/src/proguard/evaluation/value/ConvertedByteValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents a byte value that is converted from an - * integer value. - * - * @author Eric Lafortune - */ -final class ConvertedByteValue extends SpecificIntegerValue -{ - private final IntegerValue value; - - - /** - * Creates a new converted byte value of the given integer value. - */ - public ConvertedByteValue(IntegerValue value) - { - this.value = value; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.value.equals(((ConvertedByteValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - value.hashCode(); - } - - - public String toString() - { - return "(byte)("+value+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ConvertedCharacterValue.java b/src/proguard/evaluation/value/ConvertedCharacterValue.java deleted file mode 100644 index 81f0500..0000000 --- a/src/proguard/evaluation/value/ConvertedCharacterValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents a character value that is converted from an - * integer value. - * - * @author Eric Lafortune - */ -final class ConvertedCharacterValue extends SpecificIntegerValue -{ - private final IntegerValue value; - - - /** - * Creates a new converted character value of the given integer value. - */ - public ConvertedCharacterValue(IntegerValue value) - { - this.value = value; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.value.equals(((ConvertedCharacterValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - value.hashCode(); - } - - - public String toString() - { - return "(char)("+value+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ConvertedDoubleValue.java b/src/proguard/evaluation/value/ConvertedDoubleValue.java deleted file mode 100644 index bd20542..0000000 --- a/src/proguard/evaluation/value/ConvertedDoubleValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This DoubleValue represents a double value that is converted from another - * scalar value. - * - * @author Eric Lafortune - */ -final class ConvertedDoubleValue extends SpecificDoubleValue -{ - private final Value value; - - - /** - * Creates a new converted double value of the given value. - */ - public ConvertedDoubleValue(Value value) - { - this.value = value; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.value.equals(((ConvertedDoubleValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - value.hashCode(); - } - - - public String toString() - { - return "(double)("+value+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ConvertedFloatValue.java b/src/proguard/evaluation/value/ConvertedFloatValue.java deleted file mode 100644 index 83e1eb1..0000000 --- a/src/proguard/evaluation/value/ConvertedFloatValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This FloatValue represents a float value that is converted from another - * scalar value. - * - * @author Eric Lafortune - */ -final class ConvertedFloatValue extends SpecificFloatValue -{ - private final Value value; - - - /** - * Creates a new converted float value of the given value. - */ - public ConvertedFloatValue(Value value) - { - this.value = value; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.value.equals(((ConvertedFloatValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - value.hashCode(); - } - - - public String toString() - { - return "(float)("+value+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ConvertedIntegerValue.java b/src/proguard/evaluation/value/ConvertedIntegerValue.java deleted file mode 100644 index c5d83b5..0000000 --- a/src/proguard/evaluation/value/ConvertedIntegerValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents a integer value that is converted from another - * scalar value. - * - * @author Eric Lafortune - */ -final class ConvertedIntegerValue extends SpecificIntegerValue -{ - private final Value value; - - - /** - * Creates a new converted integer value of the given value. - */ - public ConvertedIntegerValue(Value value) - { - this.value = value; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.value.equals(((ConvertedIntegerValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - value.hashCode(); - } - - - public String toString() - { - return "(int)("+value+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ConvertedLongValue.java b/src/proguard/evaluation/value/ConvertedLongValue.java deleted file mode 100644 index 944e8b6..0000000 --- a/src/proguard/evaluation/value/ConvertedLongValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This LongValue represents a long value that is converted from another - * scalar value. - * - * @author Eric Lafortune - */ -final class ConvertedLongValue extends SpecificLongValue -{ - private final Value value; - - - /** - * Creates a new converted long value of the given value. - */ - public ConvertedLongValue(Value value) - { - this.value = value; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.value.equals(((ConvertedLongValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - value.hashCode(); - } - - - public String toString() - { - return "(long)("+value+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ConvertedShortValue.java b/src/proguard/evaluation/value/ConvertedShortValue.java deleted file mode 100644 index 7e0472f..0000000 --- a/src/proguard/evaluation/value/ConvertedShortValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents a short value that is converted from an - * integer value. - * - * @author Eric Lafortune - */ -final class ConvertedShortValue extends SpecificIntegerValue -{ - private final IntegerValue value; - - - /** - * Creates a new converted short value of the given integer value. - */ - public ConvertedShortValue(IntegerValue value) - { - this.value = value; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.value.equals(((ConvertedShortValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - value.hashCode(); - } - - - public String toString() - { - return "(short)("+value+")"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/DetailedArrayReferenceValue.java b/src/proguard/evaluation/value/DetailedArrayReferenceValue.java deleted file mode 100644 index 73ca067..0000000 --- a/src/proguard/evaluation/value/DetailedArrayReferenceValue.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.Clazz; -import proguard.classfile.util.ClassUtil; -import proguard.util.ArrayUtil; - -/** - * This IdentifiedArrayReferenceValue represents an identified array reference - * value with its elements. - * - * @author Eric Lafortune - */ -class DetailedArrayReferenceValue extends IdentifiedArrayReferenceValue -{ - private static final int MAXIMUM_STORED_ARRAY_LENGTH = 32; - - - private final Value[] values; - - - /** - * Creates a new array reference value with the given ID. - */ - public DetailedArrayReferenceValue(String type, - Clazz referencedClass, - IntegerValue arrayLength, - ValueFactory valuefactory, - int id) - { - super(type, referencedClass, arrayLength, valuefactory, id); - - // Is the array short enough to analyze? - if (arrayLength.isParticular() && - arrayLength.value() <= MAXIMUM_STORED_ARRAY_LENGTH) - { - // Initialize the values of the array. - InitialValueFactory initialValueFactory = - new InitialValueFactory(valuefactory); - - String elementType = ClassUtil.isInternalArrayType(type) ? - type.substring(1) : - type; - - this.values = new Value[arrayLength.value()]; - - for (int index = 0; index < values.length; index++) - { - values[index] = initialValueFactory.createValue(elementType); - } - } - else - { - // Just ignore the values of the array. - this.values = null; - } - } - - - // Implementations for ReferenceValue. - - public IntegerValue integerArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - Value value = arrayLoad(indexValue, valueFactory); - return value != null ? - value.integerValue() : - super.integerArrayLoad(indexValue, valueFactory); - } - - - public LongValue longArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - Value value = arrayLoad(indexValue, valueFactory); - return value != null ? - value.longValue() : - super.longArrayLoad(indexValue, valueFactory); - } - - - public FloatValue floatArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - Value value = arrayLoad(indexValue, valueFactory); - return value != null ? - value.floatValue() : - super.floatArrayLoad(indexValue, valueFactory); - } - - - public DoubleValue doubleArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - Value value = arrayLoad(indexValue, valueFactory); - return value != null ? - value.doubleValue() : - super.doubleArrayLoad(indexValue, valueFactory); - } - - - public ReferenceValue referenceArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - Value value = arrayLoad(indexValue, valueFactory); - return value != null ? - value.referenceValue() : - super.referenceArrayLoad(indexValue, valueFactory); - } - - - /** - * Returns the specified untyped value from the given array, or null if it - * is unknown. - */ - private Value arrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - if (values != null && - indexValue.isParticular()) - { - int index = indexValue.value(); - if (index >=0 && - index < values.length) - { - return values[index]; - } - } - - return null; - } - - - public void arrayStore(IntegerValue indexValue, Value value) - { - if (values != null) - { - if (indexValue.isParticular()) - { - int index = indexValue.value(); - if (index >=0 && - index < values.length) - { - values[index] = value; - } - } - else - { - for (int index = 0; index < values.length; index++) - { - values[index].generalize(value); - } - } - } - } - - - // Implementations of binary methods of ReferenceValue. - - public ReferenceValue generalize(ReferenceValue other) - { - return other.generalize(this); - } - - - public int equal(ReferenceValue other) - { - return other.equal(this); - } - - -// // Implementations of binary ReferenceValue methods with -// // IdentifiedReferenceValue arguments. -// -// public ReferenceValue generalize(IdentifiedReferenceValue other) -// { -// return generalize((TypedReferenceValue)other); -// } -// -// -// public int equal(IdentifiedReferenceValue other) -// { -// return equal((TypedReferenceValue)other); -// } -// -// -// // Implementations of binary ReferenceValue methods with -// // ArrayReferenceValue arguments. -// -// public ReferenceValue generalize(ArrayReferenceValue other) -// { -// return generalize((TypedReferenceValue)other); -// } -// -// -// public int equal(ArrayReferenceValue other) -// { -// return equal((TypedReferenceValue)other); -// } -// -// -// // Implementations of binary ReferenceValue methods with -// // IdentifiedArrayReferenceValue arguments. -// -// public ReferenceValue generalize(IdentifiedArrayReferenceValue other) -// { -// return generalize((ArrayReferenceValue)other); -// } -// -// -// public int equal(IdentifiedArrayReferenceValue other) -// { -// return equal((ArrayReferenceValue)other); -// } -// -// -// // Implementations of binary ReferenceValue methods with -// // DetailedArrayReferenceValue arguments. -// -// public ReferenceValue generalize(DetailedArrayReferenceValue other) -// { -// return generalize((IdentifiedArrayReferenceValue)other); -// } -// -// -// public int equal(DetailedArrayReferenceValue other) -// { -// return equal((IdentifiedArrayReferenceValue)other); -// } - - - // Implementations for Value. - - public boolean isParticular() - { - if (values == null) - { - return false; - } - - for (int index = 0; index < values.length; index++) - { - if (!values[index].isParticular()) - { - return false; - } - } - - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - ArrayUtil.equalOrNull(this.values, ((DetailedArrayReferenceValue)object).values); - } - - - public int hashCode() - { - return super.hashCode() ^ - ArrayUtil.hashCodeOrNull(values); - } - - - public String toString() - { - if (values == null) - { - return super.toString(); - } - - StringBuffer buffer = new StringBuffer(super.toString()); - - buffer.append('{'); - for (int index = 0; index < values.length; index++) - { - buffer.append(values[index]); - buffer.append(index < values.length-1 ? ',' : '}'); - } - - return buffer.toString(); - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/DetailedValueFactory.java b/src/proguard/evaluation/value/DetailedValueFactory.java deleted file mode 100644 index d28b8ab..0000000 --- a/src/proguard/evaluation/value/DetailedValueFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.*; - -/** - * This identified value factory creates array reference values that also - * represent their elements, in as far as possible. - * - * @author Eric Lafortune - */ -public class DetailedValueFactory -extends IdentifiedValueFactory -{ - // Implementations for ReferenceValue. - - public ReferenceValue createArrayReferenceValue(String type, - Clazz referencedClass, - IntegerValue arrayLength) - { - return type == null ? - REFERENCE_VALUE_NULL : - new DetailedArrayReferenceValue(ClassConstants.TYPE_ARRAY + type, - referencedClass, - arrayLength, - this, - referenceID++); - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/DoubleValue.java b/src/proguard/evaluation/value/DoubleValue.java deleted file mode 100644 index 7587ed3..0000000 --- a/src/proguard/evaluation/value/DoubleValue.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.ClassConstants; - -/** - * This class represents a partially evaluated double value. - * - * @author Eric Lafortune - */ -public abstract class DoubleValue extends Category2Value -{ - /** - * Returns the specific double value, if applicable. - */ - public double value() - { - return 0.0; - } - - - // Basic unary methods. - - /** - * Returns the negated value of this DoubleValue. - */ - public abstract DoubleValue negate(); - - /** - * Converts this DoubleValue to an IntegerValue. - */ - public abstract IntegerValue convertToInteger(); - - /** - * Converts this DoubleValue to a LongValue. - */ - public abstract LongValue convertToLong(); - - /** - * Converts this DoubleValue to a FloatValue. - */ - public abstract FloatValue convertToFloat(); - - - // Basic binary methods. - - /** - * Returns the generalization of this DoubleValue and the given other - * DoubleValue. - */ - public abstract DoubleValue generalize(DoubleValue other); - - - /** - * Returns the sum of this DoubleValue and the given DoubleValue. - */ - public abstract DoubleValue add(DoubleValue other); - - /** - * Returns the difference of this DoubleValue and the given DoubleValue. - */ - public abstract DoubleValue subtract(DoubleValue other); - - /** - * Returns the difference of the given DoubleValue and this DoubleValue. - */ - public abstract DoubleValue subtractFrom(DoubleValue other); - - /** - * Returns the product of this DoubleValue and the given DoubleValue. - */ - public abstract DoubleValue multiply(DoubleValue other); - - /** - * Returns the quotient of this DoubleValue and the given DoubleValue. - */ - public abstract DoubleValue divide(DoubleValue other); - - /** - * Returns the quotient of the given DoubleValue and this DoubleValue. - */ - public abstract DoubleValue divideOf(DoubleValue other); - - /** - * Returns the remainder of this DoubleValue divided by the given DoubleValue. - */ - public abstract DoubleValue remainder(DoubleValue other); - - /** - * Returns the remainder of the given DoubleValue divided by this DoubleValue. - */ - public abstract DoubleValue remainderOf(DoubleValue other); - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this DoubleValue is - * less than, equal to, or greater than the given DoubleValue, respectively. - */ - public abstract IntegerValue compare(DoubleValue other); - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this DoubleValue is - * less than, equal to, or greater than the given DoubleValue, respectively. - */ - public final IntegerValue compareReverse(DoubleValue other) - { - return compare(other).negate(); - } - - - // Similar binary methods, but this time with more specific arguments. - - /** - * Returns the generalization of this DoubleValue and the given other - * SpecificDoubleValue. - */ - public DoubleValue generalize(SpecificDoubleValue other) - { - return generalize((DoubleValue)other); - } - - - /** - * Returns the sum of this DoubleValue and the given SpecificDoubleValue. - */ - public DoubleValue add(SpecificDoubleValue other) - { - return add((DoubleValue)other); - } - - /** - * Returns the difference of this DoubleValue and the given SpecificDoubleValue. - */ - public DoubleValue subtract(SpecificDoubleValue other) - { - return subtract((DoubleValue)other); - } - - /** - * Returns the difference of the given SpecificDoubleValue and this DoubleValue. - */ - public DoubleValue subtractFrom(SpecificDoubleValue other) - { - return subtractFrom((DoubleValue)other); - } - - /** - * Returns the product of this DoubleValue and the given SpecificDoubleValue. - */ - public DoubleValue multiply(SpecificDoubleValue other) - { - return multiply((DoubleValue)other); - } - - /** - * Returns the quotient of this DoubleValue and the given SpecificDoubleValue. - */ - public DoubleValue divide(SpecificDoubleValue other) - { - return divide((DoubleValue)other); - } - - /** - * Returns the quotient of the given SpecificDoubleValue and this - * DoubleValue. - */ - public DoubleValue divideOf(SpecificDoubleValue other) - { - return divideOf((DoubleValue)other); - } - - /** - * Returns the remainder of this DoubleValue divided by the given - * SpecificDoubleValue. - */ - public DoubleValue remainder(SpecificDoubleValue other) - { - return remainder((DoubleValue)other); - } - - /** - * Returns the remainder of the given SpecificDoubleValue and this - * DoubleValue. - */ - public DoubleValue remainderOf(SpecificDoubleValue other) - { - return remainderOf((DoubleValue)other); - } - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this DoubleValue is - * less than, equal to, or greater than the given SpecificDoubleValue, - * respectively. - */ - public IntegerValue compare(SpecificDoubleValue other) - { - return compare((DoubleValue)other); - } - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this DoubleValue is - * less than, equal to, or greater than the given SpecificDoubleValue, - * respectively. - */ - public final IntegerValue compareReverse(SpecificDoubleValue other) - { - return compare(other).negate(); - } - - - // Similar binary methods, but this time with particular arguments. - - /** - * Returns the generalization of this DoubleValue and the given other - * ParticularDoubleValue. - */ - public DoubleValue generalize(ParticularDoubleValue other) - { - return generalize((SpecificDoubleValue)other); - } - - - /** - * Returns the sum of this DoubleValue and the given ParticularDoubleValue. - */ - public DoubleValue add(ParticularDoubleValue other) - { - return add((SpecificDoubleValue)other); - } - - /** - * Returns the difference of this DoubleValue and the given ParticularDoubleValue. - */ - public DoubleValue subtract(ParticularDoubleValue other) - { - return subtract((SpecificDoubleValue)other); - } - - /** - * Returns the difference of the given ParticularDoubleValue and this DoubleValue. - */ - public DoubleValue subtractFrom(ParticularDoubleValue other) - { - return subtractFrom((SpecificDoubleValue)other); - } - - /** - * Returns the product of this DoubleValue and the given ParticularDoubleValue. - */ - public DoubleValue multiply(ParticularDoubleValue other) - { - return multiply((SpecificDoubleValue)other); - } - - /** - * Returns the quotient of this DoubleValue and the given ParticularDoubleValue. - */ - public DoubleValue divide(ParticularDoubleValue other) - { - return divide((SpecificDoubleValue)other); - } - - /** - * Returns the quotient of the given ParticularDoubleValue and this - * DoubleValue. - */ - public DoubleValue divideOf(ParticularDoubleValue other) - { - return divideOf((SpecificDoubleValue)other); - } - - /** - * Returns the remainder of this DoubleValue divided by the given - * ParticularDoubleValue. - */ - public DoubleValue remainder(ParticularDoubleValue other) - { - return remainder((SpecificDoubleValue)other); - } - - /** - * Returns the remainder of the given ParticularDoubleValue and this - * DoubleValue. - */ - public DoubleValue remainderOf(ParticularDoubleValue other) - { - return remainderOf((SpecificDoubleValue)other); - } - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this DoubleValue is - * less than, equal to, or greater than the given ParticularDoubleValue, - * respectively. - */ - public IntegerValue compare(ParticularDoubleValue other) - { - return compare((SpecificDoubleValue)other); - } - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this DoubleValue is - * less than, equal to, or greater than the given ParticularDoubleValue, - * respectively. - */ - public final IntegerValue compareReverse(ParticularDoubleValue other) - { - return compare(other).negate(); - } - - - // Implementations for Value. - - public final DoubleValue doubleValue() - { - return this; - } - - public final Value generalize(Value other) - { - return this.generalize(other.doubleValue()); - } - - public final int computationalType() - { - return TYPE_DOUBLE; - } - - public final String internalType() - { - return String.valueOf(ClassConstants.TYPE_DOUBLE); - } -} diff --git a/src/proguard/evaluation/value/FloatValue.java b/src/proguard/evaluation/value/FloatValue.java deleted file mode 100644 index ce7806e..0000000 --- a/src/proguard/evaluation/value/FloatValue.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.ClassConstants; - -/** - * This class represents a partially evaluated float value. - * - * @author Eric Lafortune - */ -public abstract class FloatValue extends Category1Value -{ - /** - * Returns the specific float value, if applicable. - */ - public float value() - { - return 0f; - } - - - // Basic unary methods. - - /** - * Returns the negated value of this FloatValue. - */ - public abstract FloatValue negate(); - - /** - * Converts this FloatValue to an IntegerValue. - */ - public abstract IntegerValue convertToInteger(); - - /** - * Converts this FloatValue to a LongValue. - */ - public abstract LongValue convertToLong(); - - /** - * Converts this FloatValue to a DoubleValue. - */ - public abstract DoubleValue convertToDouble(); - - - // Basic binary methods. - - /** - * Returns the generalization of this FloatValue and the given other - * FloatValue. - */ - public abstract FloatValue generalize(FloatValue other); - - - /** - * Returns the sum of this FloatValue and the given FloatValue. - */ - public abstract FloatValue add(FloatValue other); - - /** - * Returns the difference of this FloatValue and the given FloatValue. - */ - public abstract FloatValue subtract(FloatValue other); - - /** - * Returns the difference of the given FloatValue and this FloatValue. - */ - public abstract FloatValue subtractFrom(FloatValue other); - - /** - * Returns the product of this FloatValue and the given FloatValue. - */ - public abstract FloatValue multiply(FloatValue other); - - /** - * Returns the quotient of this FloatValue and the given FloatValue. - */ - public abstract FloatValue divide(FloatValue other); - - /** - * Returns the quotient of the given FloatValue and this FloatValue. - */ - public abstract FloatValue divideOf(FloatValue other); - - /** - * Returns the remainder of this FloatValue divided by the given FloatValue. - */ - public abstract FloatValue remainder(FloatValue other); - - /** - * Returns the remainder of the given FloatValue divided by this FloatValue. - */ - public abstract FloatValue remainderOf(FloatValue other); - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this FloatValue is - * less than, equal to, or greater than the given FloatValue, respectively. - */ - public abstract IntegerValue compare(FloatValue other); - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this FloatValue is - * less than, equal to, or greater than the given FloatValue, respectively. - */ - public final IntegerValue compareReverse(FloatValue other) - { - return compare(other).negate(); - } - - - // Similar binary methods, but this time with more specific arguments. - - /** - * Returns the generalization of this FloatValue and the given other - * SpecificFloatValue. - */ - public FloatValue generalize(SpecificFloatValue other) - { - return generalize((FloatValue)other); - } - - - /** - * Returns the sum of this FloatValue and the given SpecificFloatValue. - */ - public FloatValue add(SpecificFloatValue other) - { - return add((FloatValue)other); - } - - /** - * Returns the difference of this FloatValue and the given SpecificFloatValue. - */ - public FloatValue subtract(SpecificFloatValue other) - { - return subtract((FloatValue)other); - } - - /** - * Returns the difference of the given SpecificFloatValue and this FloatValue. - */ - public FloatValue subtractFrom(SpecificFloatValue other) - { - return subtractFrom((FloatValue)other); - } - - /** - * Returns the product of this FloatValue and the given SpecificFloatValue. - */ - public FloatValue multiply(SpecificFloatValue other) - { - return multiply((FloatValue)other); - } - - /** - * Returns the quotient of this FloatValue and the given SpecificFloatValue. - */ - public FloatValue divide(SpecificFloatValue other) - { - return divide((FloatValue)other); - } - - /** - * Returns the quotient of the given SpecificFloatValue and this - * FloatValue. - */ - public FloatValue divideOf(SpecificFloatValue other) - { - return divideOf((FloatValue)other); - } - - /** - * Returns the remainder of this FloatValue divided by the given - * SpecificFloatValue. - */ - public FloatValue remainder(SpecificFloatValue other) - { - return remainder((FloatValue)other); - } - - /** - * Returns the remainder of the given SpecificFloatValue and this - * FloatValue. - */ - public FloatValue remainderOf(SpecificFloatValue other) - { - return remainderOf((FloatValue)other); - } - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this FloatValue is - * less than, equal to, or greater than the given SpecificFloatValue, - * respectively. - */ - public IntegerValue compare(SpecificFloatValue other) - { - return compare((FloatValue)other); - } - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this FloatValue is - * less than, equal to, or greater than the given SpecificFloatValue, - * respectively. - */ - public final IntegerValue compareReverse(SpecificFloatValue other) - { - return compare(other).negate(); - } - - - // Similar binary methods, but this time with particular arguments. - - /** - * Returns the generalization of this FloatValue and the given other - * ParticularFloatValue. - */ - public FloatValue generalize(ParticularFloatValue other) - { - return generalize((SpecificFloatValue)other); - } - - - /** - * Returns the sum of this FloatValue and the given ParticularFloatValue. - */ - public FloatValue add(ParticularFloatValue other) - { - return add((SpecificFloatValue)other); - } - - /** - * Returns the difference of this FloatValue and the given ParticularFloatValue. - */ - public FloatValue subtract(ParticularFloatValue other) - { - return subtract((SpecificFloatValue)other); - } - - /** - * Returns the difference of the given ParticularFloatValue and this FloatValue. - */ - public FloatValue subtractFrom(ParticularFloatValue other) - { - return subtractFrom((SpecificFloatValue)other); - } - - /** - * Returns the product of this FloatValue and the given ParticularFloatValue. - */ - public FloatValue multiply(ParticularFloatValue other) - { - return multiply((SpecificFloatValue)other); - } - - /** - * Returns the quotient of this FloatValue and the given ParticularFloatValue. - */ - public FloatValue divide(ParticularFloatValue other) - { - return divide((SpecificFloatValue)other); - } - - /** - * Returns the quotient of the given ParticularFloatValue and this - * FloatValue. - */ - public FloatValue divideOf(ParticularFloatValue other) - { - return divideOf((SpecificFloatValue)other); - } - - /** - * Returns the remainder of this FloatValue divided by the given - * ParticularFloatValue. - */ - public FloatValue remainder(ParticularFloatValue other) - { - return remainder((SpecificFloatValue)other); - } - - /** - * Returns the remainder of the given ParticularFloatValue and this - * FloatValue. - */ - public FloatValue remainderOf(ParticularFloatValue other) - { - return remainderOf((SpecificFloatValue)other); - } - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this FloatValue is - * less than, equal to, or greater than the given ParticularFloatValue, - * respectively. - */ - public IntegerValue compare(ParticularFloatValue other) - { - return compare((SpecificFloatValue)other); - } - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this FloatValue is - * less than, equal to, or greater than the given ParticularFloatValue, - * respectively. - */ - public final IntegerValue compareReverse(ParticularFloatValue other) - { - return compare(other).negate(); - } - - - // Implementations for Value. - - public final FloatValue floatValue() - { - return this; - } - - public final Value generalize(Value other) - { - return this.generalize(other.floatValue()); - } - - public final int computationalType() - { - return TYPE_FLOAT; - } - - public final String internalType() - { - return String.valueOf(ClassConstants.TYPE_FLOAT); - } -} diff --git a/src/proguard/evaluation/value/IdentifiedArrayReferenceValue.java b/src/proguard/evaluation/value/IdentifiedArrayReferenceValue.java deleted file mode 100644 index 3b597a1..0000000 --- a/src/proguard/evaluation/value/IdentifiedArrayReferenceValue.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.Clazz; - -/** - * This ArrayReferenceValue represents an array reference value that is - * identified by a unique ID. - * - * @author Eric Lafortune - */ -class IdentifiedArrayReferenceValue extends ArrayReferenceValue -{ - private final ValueFactory valuefactory; - private final int id; - - - /** - * Creates a new array reference value with the given ID. - */ - public IdentifiedArrayReferenceValue(String type, - Clazz referencedClass, - IntegerValue arrayLength, - ValueFactory valuefactory, - int id) - { - super(type, referencedClass, arrayLength); - - this.valuefactory = valuefactory; - this.id = id; - } - - - // Implementations of binary methods of ReferenceValue. - - public ReferenceValue generalize(ReferenceValue other) - { - return other.generalize(this); - } - - - public int equal(ReferenceValue other) - { - return other.equal(this); - } - - -// // Implementations of binary ReferenceValue methods with -// // IdentifiedReferenceValue arguments. -// -// public ReferenceValue generalize(IdentifiedReferenceValue other) -// { -// return generalize((TypedReferenceValue)other); -// } -// -// -// public int equal(IdentifiedReferenceValue other) -// { -// return equal((TypedReferenceValue)other); -// } -// -// -// // Implementations of binary ReferenceValue methods with -// // ArrayReferenceValue arguments. -// -// public ReferenceValue generalize(ArrayReferenceValue other) -// { -// return generalize((TypedReferenceValue)other); -// } -// -// -// public int equal(ArrayReferenceValue other) -// { -// return equal((TypedReferenceValue)other); -// } -// -// - // Implementations of binary ReferenceValue methods with - // IdentifiedArrayReferenceValue arguments. - -// public ReferenceValue generalize(IdentifiedArrayReferenceValue other) -// { -// return generalize((ArrayReferenceValue)other); -// } - - - public int equal(IdentifiedArrayReferenceValue other) - { - return this.equals(other) ? ALWAYS : - this.equal((TypedReferenceValue)other); - } - - -// // Implementations of binary ReferenceValue methods with -// // DetailedArrayReferenceValue arguments. -// -// public ReferenceValue generalize(DetailedArrayReferenceValue other) -// { -// return generalize((IdentifiedArrayReferenceValue)other); -// } -// -// -// public int equal(DetailedArrayReferenceValue other) -// { -// return equal((IdentifiedArrayReferenceValue)other); -// } - - - // Implementations for Value. - - public boolean isSpecific() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.valuefactory.equals(((IdentifiedArrayReferenceValue)object).valuefactory) && - this.id == ((IdentifiedArrayReferenceValue)object).id; - } - - - public int hashCode() - { - return super.hashCode() ^ - valuefactory.hashCode() ^ - id; - } - - - public String toString() - { - return super.toString() + '#' + id; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/IdentifiedDoubleValue.java b/src/proguard/evaluation/value/IdentifiedDoubleValue.java deleted file mode 100644 index 6740a2c..0000000 --- a/src/proguard/evaluation/value/IdentifiedDoubleValue.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This DoubleValue represents a double value that is identified by a unique ID. - * - * @author Eric Lafortune - */ -final class IdentifiedDoubleValue extends SpecificDoubleValue -{ - private final ValueFactory valuefactory; - private final int id; - - - /** - * Creates a new double value with the given ID. - */ - public IdentifiedDoubleValue(ValueFactory valuefactory, int id) - { - this.valuefactory = valuefactory; - this.id = id; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.valuefactory.equals(((IdentifiedDoubleValue)object).valuefactory) && - this.id == ((IdentifiedDoubleValue)object).id; - } - - - public int hashCode() - { - return super.hashCode() ^ - valuefactory.hashCode() ^ - id; - } - - - public String toString() - { - return "d"+id; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/IdentifiedFloatValue.java b/src/proguard/evaluation/value/IdentifiedFloatValue.java deleted file mode 100644 index 62e4b2b..0000000 --- a/src/proguard/evaluation/value/IdentifiedFloatValue.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This FloatValue represents a float value that is identified by a unique ID. - * - * @author Eric Lafortune - */ -final class IdentifiedFloatValue extends SpecificFloatValue -{ - private final ValueFactory valuefactory; - private final int id; - - - /** - * Creates a new float value with the given ID. - */ - public IdentifiedFloatValue(ValueFactory valuefactory, int id) - { - this.valuefactory = valuefactory; - this.id = id; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.valuefactory.equals(((IdentifiedFloatValue)object).valuefactory) && - this.id == ((IdentifiedFloatValue)object).id; - } - - - public int hashCode() - { - return super.hashCode() ^ - valuefactory.hashCode() ^ - id; - } - - - public String toString() - { - return "f"+id; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/IdentifiedIntegerValue.java b/src/proguard/evaluation/value/IdentifiedIntegerValue.java deleted file mode 100644 index ac1d033..0000000 --- a/src/proguard/evaluation/value/IdentifiedIntegerValue.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents a integer value that is identified by a unique ID. - * - * @author Eric Lafortune - */ -final class IdentifiedIntegerValue extends SpecificIntegerValue -{ - private final ValueFactory valuefactory; - private final int id; - - - /** - * Creates a new integer value with the given ID. - */ - public IdentifiedIntegerValue(ValueFactory valuefactory, int id) - { - this.valuefactory = valuefactory; - this.id = id; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.valuefactory.equals(((IdentifiedIntegerValue)object).valuefactory) && - this.id == ((IdentifiedIntegerValue)object).id; - } - - - public int hashCode() - { - return super.hashCode() ^ - valuefactory.hashCode() ^ - id; - } - - - public String toString() - { - return "i"+id; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/IdentifiedLongValue.java b/src/proguard/evaluation/value/IdentifiedLongValue.java deleted file mode 100644 index b670ae6..0000000 --- a/src/proguard/evaluation/value/IdentifiedLongValue.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This LongValue represents a long value that is identified by a unique ID. - * - * @author Eric Lafortune - */ -final class IdentifiedLongValue extends SpecificLongValue -{ - private final ValueFactory valuefactory; - private final int id; - - - /** - * Creates a new long value with the given ID. - */ - public IdentifiedLongValue(ValueFactory valuefactory, int id) - { - this.valuefactory = valuefactory; - this.id = id; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.valuefactory.equals(((IdentifiedLongValue)object).valuefactory) && - this.id == ((IdentifiedLongValue)object).id; - } - - - public int hashCode() - { - return super.hashCode() ^ - valuefactory.hashCode() ^ - id; - } - - - public String toString() - { - return "l"+id; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/IdentifiedReferenceValue.java b/src/proguard/evaluation/value/IdentifiedReferenceValue.java deleted file mode 100644 index 7f0196b..0000000 --- a/src/proguard/evaluation/value/IdentifiedReferenceValue.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.Clazz; - -/** - * This TypedReferenceValue represents a reference value that is identified by a - * unique ID. - * - * @author Eric Lafortune - */ -class IdentifiedReferenceValue extends TypedReferenceValue -{ - private final ValueFactory valuefactory; - private final int id; - - - /** - * Creates a new reference value with the given ID. - */ - public IdentifiedReferenceValue(String type, - Clazz referencedClass, - boolean mayBeNull, - ValueFactory valuefactory, - int id) - { - super(type, referencedClass, mayBeNull); - - this.valuefactory = valuefactory; - this.id = id; - } - - - // Implementations of binary methods of ReferenceValue. - - public ReferenceValue generalize(ReferenceValue other) - { - return other.generalize(this); - } - - - public int equal(ReferenceValue other) - { - return other.equal(this); - } - - - // Implementations of binary ReferenceValue methods with - // IdentifiedReferenceValue arguments. - -// public ReferenceValue generalize(IdentifiedReferenceValue other) -// { -// return generalize((TypedReferenceValue)other); -// } - - - public int equal(IdentifiedReferenceValue other) - { - return this.equals(other) ? ALWAYS : - this.equal((TypedReferenceValue)other); - } - - -// // Implementations of binary ReferenceValue methods with -// // ArrayReferenceValue arguments. -// -// public ReferenceValue generalize(ArrayReferenceValue other) -// { -// return generalize((TypedReferenceValue)other); -// } -// -// -// public int equal(ArrayReferenceValue other) -// { -// return equal((TypedReferenceValue)other); -// } -// -// -// // Implementations of binary ReferenceValue methods with -// // IdentifiedArrayReferenceValue arguments. -// -// public ReferenceValue generalize(IdentifiedArrayReferenceValue other) -// { -// return generalize((ArrayReferenceValue)other); -// } -// -// -// public int equal(IdentifiedArrayReferenceValue other) -// { -// return equal((ArrayReferenceValue)other); -// } -// -// -// // Implementations of binary ReferenceValue methods with -// // DetailedArrayReferenceValue arguments. -// -// public ReferenceValue generalize(DetailedArrayReferenceValue other) -// { -// return generalize((IdentifiedArrayReferenceValue)other); -// } -// -// -// public int equal(DetailedArrayReferenceValue other) -// { -// return equal((IdentifiedArrayReferenceValue)other); -// } - - - // Implementations for Value. - - public boolean isSpecific() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.valuefactory.equals(((IdentifiedReferenceValue)object).valuefactory) && - this.id == ((IdentifiedReferenceValue)object).id; - } - - - public int hashCode() - { - return super.hashCode() ^ - valuefactory.hashCode() ^ - id; - } - - - public String toString() - { - return super.toString()+'#'+id; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/IdentifiedValueFactory.java b/src/proguard/evaluation/value/IdentifiedValueFactory.java deleted file mode 100644 index 6bd1d5d..0000000 --- a/src/proguard/evaluation/value/IdentifiedValueFactory.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.*; - -/** - * This particular value factory attaches a unique ID to any unknown values. - * - * @author Eric Lafortune - */ -public class IdentifiedValueFactory -extends ParticularValueFactory -{ - protected int integerID; - protected int longID; - protected int floatID; - protected int doubleID; - protected int referenceID; - - - // Implementations for ValueFactory. - - public IntegerValue createIntegerValue() - { - return new IdentifiedIntegerValue(this, integerID++); - } - - - public LongValue createLongValue() - { - return new IdentifiedLongValue(this, longID++); - } - - - public FloatValue createFloatValue() - { - return new IdentifiedFloatValue(this, floatID++); - } - - - public DoubleValue createDoubleValue() - { - return new IdentifiedDoubleValue(this, doubleID++); - } - - - public ReferenceValue createReferenceValue(String type, - Clazz referencedClass, - boolean mayBeNull) - { - return type == null ? - REFERENCE_VALUE_NULL : - new IdentifiedReferenceValue(type, - referencedClass, - mayBeNull, - this, - referenceID++); - } - - - public ReferenceValue createArrayReferenceValue(String type, - Clazz referencedClass, - IntegerValue arrayLength) - { - return type == null ? - REFERENCE_VALUE_NULL : - new IdentifiedArrayReferenceValue(ClassConstants.TYPE_ARRAY + type, - referencedClass, - arrayLength, - this, - referenceID++); - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/InitialValueFactory.java b/src/proguard/evaluation/value/InitialValueFactory.java deleted file mode 100644 index 4b2cf29..0000000 --- a/src/proguard/evaluation/value/InitialValueFactory.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.ClassConstants; - -/** - * This value factory creates initial values for fields and array elements, - * with the help of a given value factory. Note that this class itself doesn't - * implement ValueFactory. - * - * @author Eric Lafortune - */ -public class InitialValueFactory -{ - private final ValueFactory valueFactory; - - - /** - * Creates a new InitialValueFactory. - * @param valueFactory the value factory that will actually create the - * values. - */ - public InitialValueFactory(ValueFactory valueFactory) - { - this.valueFactory = valueFactory; - } - - - /** - * Creates an initial value (0, 0L, 0.0f, 0.0, null) of the given type. - */ - public Value createValue(String type) - { - switch (type.charAt(0)) - { - case ClassConstants.TYPE_BOOLEAN: - case ClassConstants.TYPE_BYTE: - case ClassConstants.TYPE_CHAR: - case ClassConstants.TYPE_SHORT: - case ClassConstants.TYPE_INT: - return valueFactory.createIntegerValue(0); - - case ClassConstants.TYPE_LONG: - return valueFactory.createLongValue(0L); - - case ClassConstants.TYPE_FLOAT: - return valueFactory.createFloatValue(0.0f); - - case ClassConstants.TYPE_DOUBLE: - return valueFactory.createDoubleValue(0.0); - - case ClassConstants.TYPE_CLASS_START: - case ClassConstants.TYPE_ARRAY: - return valueFactory.createReferenceValueNull(); - - default: - throw new IllegalArgumentException("Invalid type ["+type+"]"); - } - } -} diff --git a/src/proguard/evaluation/value/InstructionOffsetValue.java b/src/proguard/evaluation/value/InstructionOffsetValue.java deleted file mode 100644 index 7cb953e..0000000 --- a/src/proguard/evaluation/value/InstructionOffsetValue.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.ClassConstants; - -/** - * This class represents a partially evaluated instruction offset. It can - * contain 0 or more specific instruction offsets. - * - * @author Eric Lafortune - */ -public class InstructionOffsetValue extends Category1Value -{ - public static final InstructionOffsetValue EMPTY_VALUE = new InstructionOffsetValue(); - - - private int[] values; - - - private InstructionOffsetValue() - { - } - - - public InstructionOffsetValue(int value) - { - this.values = new int[] { value }; - } - - - public InstructionOffsetValue(int[] values) - { - this.values = values; - } - - - public int instructionOffsetCount() - { - return values == null ? 0 : values.length; - } - - - public int instructionOffset(int index) - { - return values[index]; - } - - - /** - * Returns whether the given value is present in this list of instruction - * offsets. - */ - public boolean contains(int value) - { - if (values != null) - { - for (int index = 0; index < values.length; index++) - { - if (values[index] == value) - { - return true; - } - } - } - - return false; - } - - - /** - * Returns the minimum value from this list of instruction offsets. - * Returns <code>Integer.MAX_VALUE</code> if the list is empty. - */ - public int minimumValue() - { - int minimumValue = Integer.MAX_VALUE; - - if (values != null) - { - for (int index = 0; index < values.length; index++) - { - int value = values[index]; - - if (minimumValue > value) - { - minimumValue = value; - } - } - } - - return minimumValue; - } - - - /** - * Returns the maximum value from this list of instruction offsets. - * Returns <code>Integer.MIN_VALUE</code> if the list is empty. - */ - public int maximumValue() - { - int maximumValue = Integer.MIN_VALUE; - - if (values != null) - { - for (int index = 0; index < values.length; index++) - { - int value = values[index]; - - if (maximumValue < value) - { - maximumValue = value; - } - } - } - - return maximumValue; - } - - - /** - * Returns the generalization of this InstructionOffsetValue and the given - * other InstructionOffsetValue. The values of the other InstructionOffsetValue - * are guaranteed to remain at the end of the list, in the same order. - */ - public final Value generalize(InstructionOffsetValue other) - { - // If the values array of either is null, we can return the other one. - int[] thisValues = this.values; - if (thisValues == null) - { - return other; - } - - int[] otherValues = other.values; - if (otherValues == null) - { - return this; - } - - // Compute the length of the union of the arrays. - int newLength = thisValues.length; - for (int index = 0; index < otherValues.length; index++) - { - if (!this.contains(otherValues[index])) - { - newLength++; - } - } - - // If the length of the union array is equal to the length of the other - // values array, we can return it. - if (newLength == otherValues.length) - { - return other; - } - - // If the length of the union array is equal to the length of this - // values array, we can return it. We have to make sure that the other - // values are at the end. We'll just test one special case, with a - // single other value. - if (newLength == this.values.length && - otherValues.length == 1 && - thisValues[thisValues.length-1] == otherValues[0]) - { - return this; - } - - // Create the union array. - int newIndex = 0; - int[] newValues = new int[newLength]; - - // Is the length of the union array is equal to the sum of the lengths? - if (newLength == thisValues.length + otherValues.length) - { - // We can just copy all values, because they are unique. - System.arraycopy(thisValues, 0, newValues, 0, thisValues.length); - - newIndex = thisValues.length; - } - else - { - // Copy the values that are different from the other array. - for (int index = 0; index < thisValues.length; index++) - { - if (!other.contains(thisValues[index])) - { - newValues[newIndex++] = thisValues[index]; - } - } - } - - // Copy the values from the other array. - System.arraycopy(otherValues, 0, newValues, newIndex, otherValues.length); - - return new InstructionOffsetValue(newValues); - } - - - // Implementations for Value. - - public final InstructionOffsetValue instructionOffsetValue() - { - return this; - } - - public boolean isSpecific() - { - return true; - } - - public boolean isParticular() - { - return true; - } - - public final Value generalize(Value other) - { - return this.generalize(other.instructionOffsetValue()); - } - - public final int computationalType() - { - return TYPE_INSTRUCTION_OFFSET; - } - - public final String internalType() - { - return String.valueOf(ClassConstants.TYPE_INT); - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - if (object == null || - this.getClass() != object.getClass()) - { - return false; - } - - InstructionOffsetValue other = (InstructionOffsetValue)object; - if (this.values == other.values) - { - return true; - } - - if (this.values == null || - other.values == null || - this.values.length != other.values.length) - { - return false; - } - - for (int index = 0; index < other.values.length; index++) - { - if (!this.contains(other.values[index])) - { - return false; - } - } - - return true; - } - - - public int hashCode() - { - int hashCode = this.getClass().hashCode(); - - if (values != null) - { - for (int index = 0; index < values.length; index++) - { - hashCode ^= values[index]; - } - } - - return hashCode; - } - - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - - if (values != null) - { - for (int index = 0; index < values.length; index++) - { - if (index > 0) - { - buffer.append(','); - } - buffer.append(values[index]); - } - } - - return buffer.append(':').toString(); - } -} diff --git a/src/proguard/evaluation/value/IntegerValue.java b/src/proguard/evaluation/value/IntegerValue.java deleted file mode 100644 index 148c0ea..0000000 --- a/src/proguard/evaluation/value/IntegerValue.java +++ /dev/null @@ -1,1002 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.ClassConstants; - -/** - * This class represents a partially evaluated integer value. - * - * @author Eric Lafortune - */ -public abstract class IntegerValue extends Category1Value -{ - /** - * Returns the specific integer value, if applicable. - */ - public int value() - { - return 0; - } - - - // Basic unary methods. - - /** - * Returns the negated value of this IntegerValue. - */ - public abstract IntegerValue negate(); - - /** - * Converts this IntegerValue to a byte IntegerValue. - */ - public abstract IntegerValue convertToByte(); - - /** - * Converts this IntegerValue to a character IntegerValue. - */ - public abstract IntegerValue convertToCharacter(); - - /** - * Converts this IntegerValue to a short IntegerValue. - */ - public abstract IntegerValue convertToShort(); - - /** - * Converts this IntegerValue to a LongValue. - */ - public abstract LongValue convertToLong(); - - /** - * Converts this IntegerValue to a FloatValue. - */ - public abstract FloatValue convertToFloat(); - - /** - * Converts this IntegerValue to a DoubleValue. - */ - public abstract DoubleValue convertToDouble(); - - - // Basic binary methods. - - /** - * Returns the generalization of this IntegerValue and the given other - * IntegerValue. - */ - public abstract IntegerValue generalize(IntegerValue other); - - /** - * Returns the sum of this IntegerValue and the given IntegerValue. - */ - public abstract IntegerValue add(IntegerValue other); - - /** - * Returns the difference of this IntegerValue and the given IntegerValue. - */ - public abstract IntegerValue subtract(IntegerValue other); - - /** - * Returns the difference of the given IntegerValue and this IntegerValue. - */ - public abstract IntegerValue subtractFrom(IntegerValue other); - - /** - * Returns the product of this IntegerValue and the given IntegerValue. - */ - public abstract IntegerValue multiply(IntegerValue other) - throws ArithmeticException; - - /** - * Returns the quotient of this IntegerValue and the given IntegerValue. - */ - public abstract IntegerValue divide(IntegerValue other) - throws ArithmeticException; - - /** - * Returns the quotient of the given IntegerValue and this IntegerValue. - */ - public abstract IntegerValue divideOf(IntegerValue other) - throws ArithmeticException; - - /** - * Returns the remainder of this IntegerValue divided by the given - * IntegerValue. - */ - public abstract IntegerValue remainder(IntegerValue other) - throws ArithmeticException; - - /** - * Returns the remainder of the given IntegerValue divided by this - * IntegerValue. - */ - public abstract IntegerValue remainderOf(IntegerValue other) - throws ArithmeticException; - - /** - * Returns this IntegerValue, shifted left by the given IntegerValue. - */ - public abstract IntegerValue shiftLeft(IntegerValue other); - - /** - * Returns this IntegerValue, shifted right by the given IntegerValue. - */ - public abstract IntegerValue shiftRight(IntegerValue other); - - /** - * Returns this unsigned IntegerValue, shifted left by the given - * IntegerValue. - */ - public abstract IntegerValue unsignedShiftRight(IntegerValue other); - - /** - * Returns the given IntegerValue, shifted left by this IntegerValue. - */ - public abstract IntegerValue shiftLeftOf(IntegerValue other); - - /** - * Returns the given IntegerValue, shifted right by this IntegerValue. - */ - public abstract IntegerValue shiftRightOf(IntegerValue other); - - /** - * Returns the given unsigned IntegerValue, shifted left by this - * IntegerValue. - */ - public abstract IntegerValue unsignedShiftRightOf(IntegerValue other); - - /** - * Returns the given LongValue, shifted left by this IntegerValue. - */ - public abstract LongValue shiftLeftOf(LongValue other); - - /** - * Returns the given LongValue, shifted right by this IntegerValue. - */ - public abstract LongValue shiftRightOf(LongValue other); - - /** - * Returns the given unsigned LongValue, shifted right by this IntegerValue. - */ - public abstract LongValue unsignedShiftRightOf(LongValue other); - - /** - * Returns the logical <i>and</i> of this IntegerValue and the given - * IntegerValue. - */ - public abstract IntegerValue and(IntegerValue other); - - /** - * Returns the logical <i>or</i> of this IntegerValue and the given - * IntegerValue. - */ - public abstract IntegerValue or(IntegerValue other); - - /** - * Returns the logical <i>xor</i> of this IntegerValue and the given - * IntegerValue. - */ - public abstract IntegerValue xor(IntegerValue other); - - /** - * Returns whether this IntegerValue and the given IntegerValue are equal: - * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public abstract int equal(IntegerValue other); - - /** - * Returns whether this IntegerValue is less than the given IntegerValue: - * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public abstract int lessThan(IntegerValue other); - - /** - * Returns whether this IntegerValue is less than or equal to the given - * IntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public abstract int lessThanOrEqual(IntegerValue other); - - - // Derived binary methods. - - /** - * Returns whether this IntegerValue and the given IntegerValue are different: - * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public final int notEqual(IntegerValue other) - { - return -equal(other); - } - - /** - * Returns whether this IntegerValue is greater than the given IntegerValue: - * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public final int greaterThan(IntegerValue other) - { - return -lessThanOrEqual(other); - } - - /** - * Returns whether this IntegerValue is greater than or equal to the given IntegerValue: - * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public final int greaterThanOrEqual(IntegerValue other) - { - return -lessThan(other); - } - - - // Similar binary methods, but this time with unknown arguments. - - /** - * Returns the generalization of this IntegerValue and the given other - * UnknownIntegerValue. - */ - public IntegerValue generalize(UnknownIntegerValue other) - { - return generalize((IntegerValue)other); - } - - - /** - * Returns the sum of this IntegerValue and the given UnknownIntegerValue. - */ - public IntegerValue add(UnknownIntegerValue other) - { - return add((IntegerValue)other); - } - - /** - * Returns the difference of this IntegerValue and the given UnknownIntegerValue. - */ - public IntegerValue subtract(UnknownIntegerValue other) - { - return subtract((IntegerValue)other); - } - - /** - * Returns the difference of the given UnknownIntegerValue and this IntegerValue. - */ - public IntegerValue subtractFrom(UnknownIntegerValue other) - { - return subtractFrom((IntegerValue)other); - } - - /** - * Returns the product of this IntegerValue and the given UnknownIntegerValue. - */ - public IntegerValue multiply(UnknownIntegerValue other) - { - return multiply((IntegerValue)other); - } - - /** - * Returns the quotient of this IntegerValue and the given - * UnknownIntegerValue. - */ - public IntegerValue divide(UnknownIntegerValue other) - { - return divide((IntegerValue)other); - } - - /** - * Returns the quotient of the given UnknownIntegerValue and this - * IntegerValue. - */ - public IntegerValue divideOf(UnknownIntegerValue other) - { - return divideOf((IntegerValue)other); - } - - /** - * Returns the remainder of this IntegerValue divided by the given - * UnknownIntegerValue. - */ - public IntegerValue remainder(UnknownIntegerValue other) - { - return remainder((IntegerValue)other); - } - - /** - * Returns the remainder of the given UnknownIntegerValue divided by this - * IntegerValue. - */ - public IntegerValue remainderOf(UnknownIntegerValue other) - { - return remainderOf((IntegerValue)other); - } - - /** - * Returns this IntegerValue, shifted left by the given UnknownIntegerValue. - */ - public IntegerValue shiftLeft(UnknownIntegerValue other) - { - return shiftLeft((IntegerValue)other); - } - - /** - * Returns this IntegerValue, shifted right by the given UnknownIntegerValue. - */ - public IntegerValue shiftRight(UnknownIntegerValue other) - { - return shiftRight((IntegerValue)other); - } - - /** - * Returns this unsigned IntegerValue, shifted right by the given - * UnknownIntegerValue. - */ - public IntegerValue unsignedShiftRight(UnknownIntegerValue other) - { - return unsignedShiftRight((IntegerValue)other); - } - - /** - * Returns the given UnknownIntegerValue, shifted left by this IntegerValue. - */ - public IntegerValue shiftLeftOf(UnknownIntegerValue other) - { - return shiftLeftOf((IntegerValue)other); - } - - /** - * Returns the given UnknownIntegerValue, shifted right by this IntegerValue. - */ - public IntegerValue shiftRightOf(UnknownIntegerValue other) - { - return shiftRightOf((IntegerValue)other); - } - - /** - * Returns the given unsigned UnknownIntegerValue, shifted right by this - * IntegerValue. - */ - public IntegerValue unsignedShiftRightOf(UnknownIntegerValue other) - { - return unsignedShiftRightOf((IntegerValue)other); - } - - /** - * Returns the given UnknownLongValue, shifted left by this IntegerValue. - */ - public LongValue shiftLeftOf(UnknownLongValue other) - { - return shiftLeftOf((LongValue)other); - } - - /** - * Returns the given UnknownLongValue, shifted right by this IntegerValue. - */ - public LongValue shiftRightOf(UnknownLongValue other) - { - return shiftRightOf((LongValue)other); - } - - /** - * Returns the given unsigned UnknownLongValue, shifted right by this - * IntegerValue. - */ - public LongValue unsignedShiftRightOf(UnknownLongValue other) - { - return unsignedShiftRightOf((LongValue)other); - } - - /** - * Returns the logical <i>and</i> of this IntegerValue and the given - * UnknownIntegerValue. - */ - public IntegerValue and(UnknownIntegerValue other) - { - return and((IntegerValue)other); - } - - /** - * Returns the logical <i>or</i> of this IntegerValue and the given - * UnknownIntegerValue. - */ - public IntegerValue or(UnknownIntegerValue other) - { - return or((IntegerValue)other); - } - - /** - * Returns the logical <i>xor</i> of this IntegerValue and the given - * UnknownIntegerValue. - */ - public IntegerValue xor(UnknownIntegerValue other) - { - return xor((IntegerValue)other); - } - - /** - * Returns whether this IntegerValue and the given UnknownIntegerValue are - * equal: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public int equal(UnknownIntegerValue other) - { - return equal((IntegerValue)other); - } - - /** - * Returns whether this IntegerValue is less than the given - * UnknownIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public int lessThan(UnknownIntegerValue other) - { - return lessThan((IntegerValue)other); - } - - /** - * Returns whether this IntegerValue is less than or equal to the given - * UnknownIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public int lessThanOrEqual(UnknownIntegerValue other) - { - return lessThanOrEqual((IntegerValue)other); - } - - - // Derived binary methods. - - /** - * Returns whether this IntegerValue and the given UnknownIntegerValue are - * different: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public final int notEqual(UnknownIntegerValue other) - { - return -equal(other); - } - - /** - * Returns whether this IntegerValue is greater than the given - * UnknownIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public final int greaterThan(UnknownIntegerValue other) - { - return -lessThanOrEqual(other); - } - - /** - * Returns whether this IntegerValue is greater than or equal to the given - * UnknownIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public final int greaterThanOrEqual(UnknownIntegerValue other) - { - return -lessThan(other); - } - - - // Similar binary methods, but this time with specific arguments. - - /** - * Returns the generalization of this IntegerValue and the given other - * SpecificIntegerValue. - */ - public IntegerValue generalize(SpecificIntegerValue other) - { - return generalize((IntegerValue)other); - } - - - /** - * Returns the sum of this IntegerValue and the given SpecificIntegerValue. - */ - public IntegerValue add(SpecificIntegerValue other) - { - return add((IntegerValue)other); - } - - /** - * Returns the difference of this IntegerValue and the given SpecificIntegerValue. - */ - public IntegerValue subtract(SpecificIntegerValue other) - { - return subtract((IntegerValue)other); - } - - /** - * Returns the difference of the given SpecificIntegerValue and this IntegerValue. - */ - public IntegerValue subtractFrom(SpecificIntegerValue other) - { - return subtractFrom((IntegerValue)other); - } - - /** - * Returns the product of this IntegerValue and the given SpecificIntegerValue. - */ - public IntegerValue multiply(SpecificIntegerValue other) - { - return multiply((IntegerValue)other); - } - - /** - * Returns the quotient of this IntegerValue and the given - * SpecificIntegerValue. - */ - public IntegerValue divide(SpecificIntegerValue other) - { - return divide((IntegerValue)other); - } - - /** - * Returns the quotient of the given SpecificIntegerValue and this - * IntegerValue. - */ - public IntegerValue divideOf(SpecificIntegerValue other) - { - return divideOf((IntegerValue)other); - } - - /** - * Returns the remainder of this IntegerValue divided by the given - * SpecificIntegerValue. - */ - public IntegerValue remainder(SpecificIntegerValue other) - { - return remainder((IntegerValue)other); - } - - /** - * Returns the remainder of the given SpecificIntegerValue divided by this - * IntegerValue. - */ - public IntegerValue remainderOf(SpecificIntegerValue other) - { - return remainderOf((IntegerValue)other); - } - - /** - * Returns this IntegerValue, shifted left by the given SpecificIntegerValue. - */ - public IntegerValue shiftLeft(SpecificIntegerValue other) - { - return shiftLeft((IntegerValue)other); - } - - /** - * Returns this IntegerValue, shifted right by the given SpecificIntegerValue. - */ - public IntegerValue shiftRight(SpecificIntegerValue other) - { - return shiftRight((IntegerValue)other); - } - - /** - * Returns this unsigned IntegerValue, shifted right by the given - * SpecificIntegerValue. - */ - public IntegerValue unsignedShiftRight(SpecificIntegerValue other) - { - return unsignedShiftRight((IntegerValue)other); - } - - /** - * Returns the given SpecificIntegerValue, shifted left by this IntegerValue. - */ - public IntegerValue shiftLeftOf(SpecificIntegerValue other) - { - return shiftLeftOf((IntegerValue)other); - } - - /** - * Returns the given SpecificIntegerValue, shifted right by this IntegerValue. - */ - public IntegerValue shiftRightOf(SpecificIntegerValue other) - { - return shiftRightOf((IntegerValue)other); - } - - /** - * Returns the given unsigned SpecificIntegerValue, shifted right by this - * IntegerValue. - */ - public IntegerValue unsignedShiftRightOf(SpecificIntegerValue other) - { - return unsignedShiftRightOf((IntegerValue)other); - } - - /** - * Returns the given SpecificLongValue, shifted left by this IntegerValue. - */ - public LongValue shiftLeftOf(SpecificLongValue other) - { - return shiftLeftOf((LongValue)other); - } - - /** - * Returns the given SpecificLongValue, shifted right by this IntegerValue. - */ - public LongValue shiftRightOf(SpecificLongValue other) - { - return shiftRightOf((LongValue)other); - } - - /** - * Returns the given unsigned SpecificLongValue, shifted right by this - * IntegerValue. - */ - public LongValue unsignedShiftRightOf(SpecificLongValue other) - { - return unsignedShiftRightOf((LongValue)other); - } - - /** - * Returns the logical <i>and</i> of this IntegerValue and the given - * SpecificIntegerValue. - */ - public IntegerValue and(SpecificIntegerValue other) - { - return and((IntegerValue)other); - } - - /** - * Returns the logical <i>or</i> of this IntegerValue and the given - * SpecificIntegerValue. - */ - public IntegerValue or(SpecificIntegerValue other) - { - return or((IntegerValue)other); - } - - /** - * Returns the logical <i>xor</i> of this IntegerValue and the given - * SpecificIntegerValue. - */ - public IntegerValue xor(SpecificIntegerValue other) - { - return xor((IntegerValue)other); - } - - /** - * Returns whether this IntegerValue and the given SpecificIntegerValue are - * equal: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public int equal(SpecificIntegerValue other) - { - return equal((IntegerValue)other); - } - - /** - * Returns whether this IntegerValue is less than the given - * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public int lessThan(SpecificIntegerValue other) - { - return lessThan((IntegerValue)other); - } - - /** - * Returns whether this IntegerValue is less than or equal to the given - * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public int lessThanOrEqual(SpecificIntegerValue other) - { - return lessThanOrEqual((IntegerValue)other); - } - - - // Derived binary methods. - - /** - * Returns whether this IntegerValue and the given SpecificIntegerValue are - * different: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public final int notEqual(SpecificIntegerValue other) - { - return -equal(other); - } - - /** - * Returns whether this IntegerValue is greater than the given - * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public final int greaterThan(SpecificIntegerValue other) - { - return -lessThanOrEqual(other); - } - - /** - * Returns whether this IntegerValue is greater than or equal to the given - * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public final int greaterThanOrEqual(SpecificIntegerValue other) - { - return -lessThan(other); - } - - - // Similar binary methods, but this time with particular arguments. - - /** - * Returns the generalization of this IntegerValue and the given other - * ParticularIntegerValue. - */ - public IntegerValue generalize(ParticularIntegerValue other) - { - return generalize((SpecificIntegerValue)other); - } - - - /** - * Returns the sum of this IntegerValue and the given ParticularIntegerValue. - */ - public IntegerValue add(ParticularIntegerValue other) - { - return add((SpecificIntegerValue)other); - } - - /** - * Returns the difference of this IntegerValue and the given ParticularIntegerValue. - */ - public IntegerValue subtract(ParticularIntegerValue other) - { - return subtract((SpecificIntegerValue)other); - } - - /** - * Returns the difference of the given ParticularIntegerValue and this IntegerValue. - */ - public IntegerValue subtractFrom(ParticularIntegerValue other) - { - return subtractFrom((SpecificIntegerValue)other); - } - - /** - * Returns the product of this IntegerValue and the given ParticularIntegerValue. - */ - public IntegerValue multiply(ParticularIntegerValue other) - { - return multiply((SpecificIntegerValue)other); - } - - /** - * Returns the quotient of this IntegerValue and the given - * ParticularIntegerValue. - */ - public IntegerValue divide(ParticularIntegerValue other) - { - return divide((SpecificIntegerValue)other); - } - - /** - * Returns the quotient of the given ParticularIntegerValue and this - * IntegerValue. - */ - public IntegerValue divideOf(ParticularIntegerValue other) - { - return divideOf((SpecificIntegerValue)other); - } - - /** - * Returns the remainder of this IntegerValue divided by the given - * ParticularIntegerValue. - */ - public IntegerValue remainder(ParticularIntegerValue other) - { - return remainder((SpecificIntegerValue)other); - } - - /** - * Returns the remainder of the given ParticularIntegerValue divided by this - * IntegerValue. - */ - public IntegerValue remainderOf(ParticularIntegerValue other) - { - return remainderOf((SpecificIntegerValue)other); - } - - /** - * Returns this IntegerValue, shifted left by the given ParticularIntegerValue. - */ - public IntegerValue shiftLeft(ParticularIntegerValue other) - { - return shiftLeft((SpecificIntegerValue)other); - } - - /** - * Returns this IntegerValue, shifted right by the given ParticularIntegerValue. - */ - public IntegerValue shiftRight(ParticularIntegerValue other) - { - return shiftRight((SpecificIntegerValue)other); - } - - /** - * Returns this unsigned IntegerValue, shifted right by the given - * ParticularIntegerValue. - */ - public IntegerValue unsignedShiftRight(ParticularIntegerValue other) - { - return unsignedShiftRight((SpecificIntegerValue)other); - } - - /** - * Returns the given ParticularIntegerValue, shifted left by this IntegerValue. - */ - public IntegerValue shiftLeftOf(ParticularIntegerValue other) - { - return shiftLeftOf((SpecificIntegerValue)other); - } - - /** - * Returns the given ParticularIntegerValue, shifted right by this IntegerValue. - */ - public IntegerValue shiftRightOf(ParticularIntegerValue other) - { - return shiftRightOf((SpecificIntegerValue)other); - } - - /** - * Returns the given unsigned ParticularIntegerValue, shifted right by this - * IntegerValue. - */ - public IntegerValue unsignedShiftRightOf(ParticularIntegerValue other) - { - return unsignedShiftRightOf((SpecificIntegerValue)other); - } - - /** - * Returns the given ParticularLongValue, shifted left by this IntegerValue. - */ - public LongValue shiftLeftOf(ParticularLongValue other) - { - return shiftLeftOf((SpecificLongValue)other); - } - - /** - * Returns the given ParticularLongValue, shifted right by this IntegerValue. - */ - public LongValue shiftRightOf(ParticularLongValue other) - { - return shiftRightOf((SpecificLongValue)other); - } - - /** - * Returns the given unsigned ParticularLongValue, shifted right by this - * IntegerValue. - */ - public LongValue unsignedShiftRightOf(ParticularLongValue other) - { - return unsignedShiftRightOf((SpecificLongValue)other); - } - - /** - * Returns the logical <i>and</i> of this IntegerValue and the given - * ParticularIntegerValue. - */ - public IntegerValue and(ParticularIntegerValue other) - { - return and((SpecificIntegerValue)other); - } - - /** - * Returns the logical <i>or</i> of this IntegerValue and the given - * ParticularIntegerValue. - */ - public IntegerValue or(ParticularIntegerValue other) - { - return or((SpecificIntegerValue)other); - } - - /** - * Returns the logical <i>xor</i> of this IntegerValue and the given - * ParticularIntegerValue. - */ - public IntegerValue xor(ParticularIntegerValue other) - { - return xor((SpecificIntegerValue)other); - } - - /** - * Returns whether this IntegerValue and the given ParticularIntegerValue are - * equal: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public int equal(ParticularIntegerValue other) - { - return equal((SpecificIntegerValue)other); - } - - /** - * Returns whether this IntegerValue is less than the given - * ParticularIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public int lessThan(ParticularIntegerValue other) - { - return lessThan((SpecificIntegerValue)other); - } - - /** - * Returns whether this IntegerValue is less than or equal to the given - * ParticularIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public int lessThanOrEqual(ParticularIntegerValue other) - { - return lessThanOrEqual((SpecificIntegerValue)other); - } - - - // Derived binary methods. - - /** - * Returns whether this IntegerValue and the given ParticularIntegerValue are - * different: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public final int notEqual(ParticularIntegerValue other) - { - return -equal(other); - } - - /** - * Returns whether this IntegerValue is greater than the given - * ParticularIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public final int greaterThan(ParticularIntegerValue other) - { - return -lessThanOrEqual(other); - } - - /** - * Returns whether this IntegerValue is greater than or equal to the given - * ParticularIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or - * <code>ALWAYS</code>. - */ - public final int greaterThanOrEqual(ParticularIntegerValue other) - { - return -lessThan(other); - } - - - // Implementations for Value. - - public final IntegerValue integerValue() - { - return this; - } - - public final Value generalize(Value other) - { - return this.generalize(other.integerValue()); - } - - public final int computationalType() - { - return TYPE_INTEGER; - } - - public final String internalType() - { - return String.valueOf(ClassConstants.TYPE_INT); - } -} diff --git a/src/proguard/evaluation/value/LongValue.java b/src/proguard/evaluation/value/LongValue.java deleted file mode 100644 index e8f9e12..0000000 --- a/src/proguard/evaluation/value/LongValue.java +++ /dev/null @@ -1,554 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.ClassConstants; - -/** - * This class represents a partially evaluated long value. - * - * @author Eric Lafortune - */ -public abstract class LongValue extends Category2Value -{ - /** - * Returns the specific long value, if applicable. - */ - public long value() - { - return 0; - } - - - // Basic unary methods. - - /** - * Returns the negated value of this LongValue. - */ - public abstract LongValue negate(); - - - /** - * Converts this LongValue to an IntegerValue. - */ - public abstract IntegerValue convertToInteger(); - - /** - * Converts this LongValue to a FloatValue. - */ - public abstract FloatValue convertToFloat(); - - /** - * Converts this LongValue to a DoubleValue. - */ - public abstract DoubleValue convertToDouble(); - - - // Basic binary methods. - - /** - * Returns the generalization of this LongValue and the given other - * LongValue. - */ - public LongValue generalize(LongValue other) - { - return other.generalize(this); - } - - /** - * Returns the sum of this LongValue and the given LongValue. - */ - public LongValue add(LongValue other) - { - return other.add(this); - } - - /** - * Returns the difference of this LongValue and the given LongValue. - */ - public LongValue subtract(LongValue other) - { - return other.subtractFrom(this); - } - - /** - * Returns the difference of the given LongValue and this LongValue. - */ - public LongValue subtractFrom(LongValue other) - { - return other.subtract(this); - } - - /** - * Returns the product of this LongValue and the given LongValue. - */ - public LongValue multiply(LongValue other) - throws ArithmeticException - { - return other.multiply(this); - } - - /** - * Returns the quotient of this LongValue and the given LongValue. - */ - public LongValue divide(LongValue other) - throws ArithmeticException - { - return other.divideOf(this); - } - - /** - * Returns the quotient of the given LongValue and this LongValue. - */ - public LongValue divideOf(LongValue other) - throws ArithmeticException - { - return other.divide(this); - } - - /** - * Returns the remainder of this LongValue divided by the given - * LongValue. - */ - public LongValue remainder(LongValue other) - throws ArithmeticException - { - return other.remainderOf(this); - } - - /** - * Returns the remainder of the given LongValue divided by this - * LongValue. - */ - public LongValue remainderOf(LongValue other) - throws ArithmeticException - { - return other.remainder(this); - } - - /** - * Returns this LongValue, shifted left by the given IntegerValue. - */ - public LongValue shiftLeft(IntegerValue other) - { - return other.shiftLeftOf(this); - } - - /** - * Returns this LongValue, shifted right by the given IntegerValue. - */ - public LongValue shiftRight(IntegerValue other) - { - return other.shiftRightOf(this); - } - - /** - * Returns this unsigned LongValue, shifted left by the given - * IntegerValue. - */ - public LongValue unsignedShiftRight(IntegerValue other) - { - return other.unsignedShiftRightOf(this); - } - - /** - * Returns the logical <i>and</i> of this LongValue and the given - * LongValue. - */ - public LongValue and(LongValue other) - { - return other.and(this); - } - - /** - * Returns the logical <i>or</i> of this LongValue and the given - * LongValue. - */ - public LongValue or(LongValue other) - { - return other.or(this); - } - - /** - * Returns the logical <i>xor</i> of this LongValue and the given - * LongValue. - */ - public LongValue xor(LongValue other) - { - return other.xor(this); - } - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this LongValue is - * less than, equal to, or greater than the given LongValue, respectively. - */ - public IntegerValue compare(LongValue other) - { - return other.compareReverse(this); - } - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this LongValue is - * less than, equal to, or greater than the given LongValue, respectively. - */ - public final IntegerValue compareReverse(LongValue other) - { - return compare(other).negate(); - } - - - // Similar binary methods, but this time with more specific arguments. - - /** - * Returns the generalization of this LongValue and the given other - * SpecificLongValue. - */ - public LongValue generalize(SpecificLongValue other) - { - return this; - } - - - /** - * Returns the sum of this LongValue and the given SpecificLongValue. - */ - public LongValue add(SpecificLongValue other) - { - return this; - } - - /** - * Returns the difference of this LongValue and the given SpecificLongValue. - */ - public LongValue subtract(SpecificLongValue other) - { - return this; - } - - /** - * Returns the difference of the given SpecificLongValue and this LongValue. - */ - public LongValue subtractFrom(SpecificLongValue other) - { - return this; - } - - /** - * Returns the product of this LongValue and the given SpecificLongValue. - */ - public LongValue multiply(SpecificLongValue other) - { - return this; - } - - /** - * Returns the quotient of this LongValue and the given - * SpecificLongValue. - */ - public LongValue divide(SpecificLongValue other) - { - return this; - } - - /** - * Returns the quotient of the given SpecificLongValue and this - * LongValue. - */ - public LongValue divideOf(SpecificLongValue other) - { - return this; - } - - /** - * Returns the remainder of this LongValue divided by the given - * SpecificLongValue. - */ - public LongValue remainder(SpecificLongValue other) - { - return this; - } - - /** - * Returns the remainder of the given SpecificLongValue divided by this - * LongValue. - */ - public LongValue remainderOf(SpecificLongValue other) - { - return this; - } - - /** - * Returns this LongValue, shifted left by the given SpecificLongValue. - */ - public LongValue shiftLeft(SpecificLongValue other) - { - return this; - } - - /** - * Returns this LongValue, shifted right by the given SpecificLongValue. - */ - public LongValue shiftRight(SpecificLongValue other) - { - return this; - } - - /** - * Returns this unsigned LongValue, shifted right by the given - * SpecificLongValue. - */ - public LongValue unsignedShiftRight(SpecificLongValue other) - { - return this; - } - - /** - * Returns the logical <i>and</i> of this LongValue and the given - * SpecificLongValue. - */ - public LongValue and(SpecificLongValue other) - { - return this; - } - - /** - * Returns the logical <i>or</i> of this LongValue and the given - * SpecificLongValue. - */ - public LongValue or(SpecificLongValue other) - { - return this; - } - - /** - * Returns the logical <i>xor</i> of this LongValue and the given - * SpecificLongValue. - */ - public LongValue xor(SpecificLongValue other) - { - return this; - } - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this LongValue is - * less than, equal to, or greater than the given SpecificLongValue, - * respectively. - */ - public IntegerValue compare(SpecificLongValue other) - { - return new ComparisonValue(this, other); - } - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this LongValue is - * less than, equal to, or greater than the given SpecificLongValue, - * respectively. - */ - public final IntegerValue compareReverse(SpecificLongValue other) - { - return compare(other).negate(); - } - - - // Similar binary methods, but this time with particular arguments. - - /** - * Returns the generalization of this LongValue and the given other - * ParticularLongValue. - */ - public LongValue generalize(ParticularLongValue other) - { - return generalize((SpecificLongValue)other); - } - - - /** - * Returns the sum of this LongValue and the given ParticularLongValue. - */ - public LongValue add(ParticularLongValue other) - { - return add((SpecificLongValue)other); - } - - /** - * Returns the difference of this LongValue and the given ParticularLongValue. - */ - public LongValue subtract(ParticularLongValue other) - { - return subtract((SpecificLongValue)other); - } - - /** - * Returns the difference of the given ParticularLongValue and this LongValue. - */ - public LongValue subtractFrom(ParticularLongValue other) - { - return subtractFrom((SpecificLongValue)other); - } - - /** - * Returns the product of this LongValue and the given ParticularLongValue. - */ - public LongValue multiply(ParticularLongValue other) - { - return multiply((SpecificLongValue)other); - } - - /** - * Returns the quotient of this LongValue and the given - * ParticularLongValue. - */ - public LongValue divide(ParticularLongValue other) - { - return divide((SpecificLongValue)other); - } - - /** - * Returns the quotient of the given ParticularLongValue and this - * LongValue. - */ - public LongValue divideOf(ParticularLongValue other) - { - return divideOf((SpecificLongValue)other); - } - - /** - * Returns the remainder of this LongValue divided by the given - * ParticularLongValue. - */ - public LongValue remainder(ParticularLongValue other) - { - return remainder((SpecificLongValue)other); - } - - /** - * Returns the remainder of the given ParticularLongValue divided by this - * LongValue. - */ - public LongValue remainderOf(ParticularLongValue other) - { - return remainderOf((SpecificLongValue)other); - } - - /** - * Returns this LongValue, shifted left by the given ParticularIntegerValue. - */ - public LongValue shiftLeft(ParticularIntegerValue other) - { - return shiftLeft((SpecificIntegerValue)other); - } - - /** - * Returns this LongValue, shifted right by the given ParticularIntegerValue. - */ - public LongValue shiftRight(ParticularIntegerValue other) - { - return shiftRight((SpecificIntegerValue)other); - } - - /** - * Returns this unsigned LongValue, shifted right by the given - * ParticularIntegerValue. - */ - public LongValue unsignedShiftRight(ParticularIntegerValue other) - { - return unsignedShiftRight((SpecificIntegerValue)other); - } - - /** - * Returns the logical <i>and</i> of this LongValue and the given - * ParticularLongValue. - */ - public LongValue and(ParticularLongValue other) - { - return and((SpecificLongValue)other); - } - - /** - * Returns the logical <i>or</i> of this LongValue and the given - * ParticularLongValue. - */ - public LongValue or(ParticularLongValue other) - { - return or((SpecificLongValue)other); - } - - /** - * Returns the logical <i>xor</i> of this LongValue and the given - * ParticularLongValue. - */ - public LongValue xor(ParticularLongValue other) - { - return xor((SpecificLongValue)other); - } - - /** - * Returns an IntegerValue with value -1, 0, or 1, if this LongValue is - * less than, equal to, or greater than the given ParticularLongValue, - * respectively. - */ - public IntegerValue compare(ParticularLongValue other) - { - return compare((SpecificLongValue)other); - } - - - // Derived binary methods. - - /** - * Returns an IntegerValue with value 1, 0, or -1, if this LongValue is - * less than, equal to, or greater than the given ParticularLongValue, - * respectively. - */ - public final IntegerValue compareReverse(ParticularLongValue other) - { - return compare(other).negate(); - } - - - // Implementations for Value. - - public final LongValue longValue() - { - return this; - } - - public final Value generalize(Value other) - { - return this.generalize(other.longValue()); - } - - public final int computationalType() - { - return TYPE_LONG; - } - - public final String internalType() - { - return String.valueOf(ClassConstants.TYPE_INT); - } -} diff --git a/src/proguard/evaluation/value/NegatedDoubleValue.java b/src/proguard/evaluation/value/NegatedDoubleValue.java deleted file mode 100644 index 25de608..0000000 --- a/src/proguard/evaluation/value/NegatedDoubleValue.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This DoubleValue represents a double value that is negated. - * - * @author Eric Lafortune - */ -final class NegatedDoubleValue extends SpecificDoubleValue -{ - private final DoubleValue doubleValue; - - - /** - * Creates a new negated double value of the given double value. - */ - public NegatedDoubleValue(DoubleValue doubleValue) - { - this.doubleValue = doubleValue; - } - - - // Implementations of unary methods of DoubleValue. - - public DoubleValue negate() - { - return doubleValue; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.doubleValue.equals(((NegatedDoubleValue)object).doubleValue); - } - - - public int hashCode() - { - return super.hashCode() ^ - doubleValue.hashCode(); - } - - - public String toString() - { - return "-"+doubleValue; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/NegatedFloatValue.java b/src/proguard/evaluation/value/NegatedFloatValue.java deleted file mode 100644 index 7a05579..0000000 --- a/src/proguard/evaluation/value/NegatedFloatValue.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This FloatValue represents a float value that is negated. - * - * @author Eric Lafortune - */ -final class NegatedFloatValue extends SpecificFloatValue -{ - private final FloatValue floatValue; - - - /** - * Creates a new negated float value of the given float value. - */ - public NegatedFloatValue(FloatValue floatValue) - { - this.floatValue = floatValue; - } - - - // Implementations of unary methods of FloatValue. - - public FloatValue negate() - { - return floatValue; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.floatValue.equals(((NegatedFloatValue)object).floatValue); - } - - - public int hashCode() - { - return super.hashCode() ^ - floatValue.hashCode(); - } - - - public String toString() - { - return "-"+floatValue; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/NegatedIntegerValue.java b/src/proguard/evaluation/value/NegatedIntegerValue.java deleted file mode 100644 index cbbabdd..0000000 --- a/src/proguard/evaluation/value/NegatedIntegerValue.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents a integer value that is negated. - * - * @author Eric Lafortune - */ -final class NegatedIntegerValue extends SpecificIntegerValue -{ - private final IntegerValue integerValue; - - - /** - * Creates a new negated integer value of the given integer value. - */ - public NegatedIntegerValue(IntegerValue integerValue) - { - this.integerValue = integerValue; - } - - - // Implementations of unary methods of IntegerValue. - - public IntegerValue negate() - { - return integerValue; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.integerValue.equals(((NegatedIntegerValue)object).integerValue); - } - - - public int hashCode() - { - return super.hashCode() ^ - integerValue.hashCode(); - } - - - public String toString() - { - return "-"+integerValue; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/NegatedLongValue.java b/src/proguard/evaluation/value/NegatedLongValue.java deleted file mode 100644 index bb9f729..0000000 --- a/src/proguard/evaluation/value/NegatedLongValue.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This LongValue represents a long value that is negated. - * - * @author Eric Lafortune - */ -final class NegatedLongValue extends SpecificLongValue -{ - private final LongValue longValue; - - - /** - * Creates a new negated long value of the given long value. - */ - public NegatedLongValue(LongValue longValue) - { - this.longValue = longValue; - } - - - // Implementations of unary methods of LongValue. - - public LongValue negate() - { - return longValue; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return this == object || - super.equals(object) && - this.longValue.equals(((NegatedLongValue)object).longValue); - } - - - public int hashCode() - { - return super.hashCode() ^ - longValue.hashCode(); - } - - - public String toString() - { - return "-"+longValue; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ParticularDoubleValue.java b/src/proguard/evaluation/value/ParticularDoubleValue.java deleted file mode 100644 index d97eb5f..0000000 --- a/src/proguard/evaluation/value/ParticularDoubleValue.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This DoubleValue represents a particular double value. - * - * @author Eric Lafortune - */ -final class ParticularDoubleValue extends SpecificDoubleValue -{ - private final double value; - - - /** - * Creates a new particular double value. - */ - public ParticularDoubleValue(double value) - { - this.value = value; - } - - - // Implementations for DoubleValue. - - public double value() - { - return value; - } - - - // Implementations of unary methods of DoubleValue. - - public DoubleValue negate() - { - return new ParticularDoubleValue(-value); - } - - public IntegerValue convertToInteger() - { - return new ParticularIntegerValue((int)value); - } - - public LongValue convertToLong() - { - return new ParticularLongValue((long)value); - } - - public FloatValue convertToFloat() - { - return new ParticularFloatValue((float)value); - } - - - // Implementations of binary methods of DoubleValue. - - public DoubleValue generalize(DoubleValue other) - { - return other.generalize(this); - } - - public DoubleValue add(DoubleValue other) - { - // Careful: -0.0 + 0.0 == 0.0 - //return value == 0.0 ? other : other.add(this); - return other.add(this); - } - - public DoubleValue subtract(DoubleValue other) - { - // Careful: -0.0 + 0.0 == 0.0 - //return value == 0.0 ? other.negate() : other.subtractFrom(this); - return other.subtractFrom(this); - } - - public DoubleValue subtractFrom(DoubleValue other) - { - // Careful: -0.0 + 0.0 == 0.0 - //return value == 0.0 ? other : other.subtract(this); - return other.subtract(this); - } - - public DoubleValue multiply(DoubleValue other) - { - return other.multiply(this); - } - - public DoubleValue divide(DoubleValue other) - { - return other.divideOf(this); - } - - public DoubleValue divideOf(DoubleValue other) - { - return other.divide(this); - } - - public DoubleValue remainder(DoubleValue other) - { - return other.remainderOf(this); - } - - public DoubleValue remainderOf(DoubleValue other) - { - return other.remainder(this); - } - - public IntegerValue compare(DoubleValue other) - { - return other.compareReverse(this); - } - - - // Implementations of binary DoubleValue methods with ParticularDoubleValue - // arguments. - - public DoubleValue generalize(ParticularDoubleValue other) - { - // Also handle NaN and Infinity. - return Double.doubleToRawLongBits(this.value) == - Double.doubleToRawLongBits(other.value) ? - this : ValueFactory.DOUBLE_VALUE; - } - - public DoubleValue add(ParticularDoubleValue other) - { - return new ParticularDoubleValue(this.value + other.value); - } - - public DoubleValue subtract(ParticularDoubleValue other) - { - return new ParticularDoubleValue(this.value - other.value); - } - - public DoubleValue subtractFrom(ParticularDoubleValue other) - { - return new ParticularDoubleValue(other.value - this.value); - } - - public DoubleValue multiply(ParticularDoubleValue other) - { - return new ParticularDoubleValue(this.value * other.value); - } - - public DoubleValue divide(ParticularDoubleValue other) - { - return new ParticularDoubleValue(this.value / other.value); - } - - public DoubleValue divideOf(ParticularDoubleValue other) - { - return new ParticularDoubleValue(other.value / this.value); - } - - public DoubleValue remainder(ParticularDoubleValue other) - { - return new ParticularDoubleValue(this.value % other.value); - } - - public DoubleValue remainderOf(ParticularDoubleValue other) - { - return new ParticularDoubleValue(other.value % this.value); - } - - public IntegerValue compare(ParticularDoubleValue other) - { - return this.value < other.value ? ParticularValueFactory.INTEGER_VALUE_M1 : - this.value == other.value ? ParticularValueFactory.INTEGER_VALUE_0 : - ParticularValueFactory.INTEGER_VALUE_1; - } - - - // Implementations for Value. - - public boolean isParticular() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - // Also handle NaN and Infinity. - return super.equals(object) && - Double.doubleToLongBits(this.value) == - Double.doubleToLongBits(((ParticularDoubleValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - (int)Double.doubleToLongBits(value); - } - - - public String toString() - { - return value+"d"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ParticularFloatValue.java b/src/proguard/evaluation/value/ParticularFloatValue.java deleted file mode 100644 index 9084b36..0000000 --- a/src/proguard/evaluation/value/ParticularFloatValue.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This FloatValue represents a particular float value. - * - * @author Eric Lafortune - */ -final class ParticularFloatValue extends SpecificFloatValue -{ - private final float value; - - - /** - * Creates a new particular float value. - */ - public ParticularFloatValue(float value) - { - this.value = value; - } - - - // Implementations for FloatValue. - - public float value() - { - return value; - } - - - // Implementations of unary methods of FloatValue. - - public FloatValue negate() - { - return new ParticularFloatValue(-value); - } - - public IntegerValue convertToInteger() - { - return new ParticularIntegerValue((int)value); - } - - public LongValue convertToLong() - { - return new ParticularLongValue((long)value); - } - - public DoubleValue convertToDouble() - { - return new ParticularDoubleValue((float)value); - } - - - // Implementations of binary methods of FloatValue. - - public FloatValue generalize(FloatValue other) - { - return other.generalize(this); - } - - public FloatValue add(FloatValue other) - { - // Careful: -0.0 + 0.0 == 0.0 - //return value == 0.0 ? other : other.add(this); - return other.add(this); - } - - public FloatValue subtract(FloatValue other) - { - // Careful: -0.0 + 0.0 == 0.0 - //return value == 0.0 ? other.negate() : other.subtractFrom(this); - return other.subtractFrom(this); - } - - public FloatValue subtractFrom(FloatValue other) - { - // Careful: -0.0 + 0.0 == 0.0 - //return value == 0.0 ? other : other.subtract(this); - return other.subtract(this); - } - - public FloatValue multiply(FloatValue other) - { - return other.multiply(this); - } - - public FloatValue divide(FloatValue other) - { - return other.divideOf(this); - } - - public FloatValue divideOf(FloatValue other) - { - return other.divide(this); - } - - public FloatValue remainder(FloatValue other) - { - return other.remainderOf(this); - } - - public FloatValue remainderOf(FloatValue other) - { - return other.remainder(this); - } - - public IntegerValue compare(FloatValue other) - { - return other.compareReverse(this); - } - - - // Implementations of binary FloatValue methods with ParticularFloatValue - // arguments. - - public FloatValue generalize(ParticularFloatValue other) - { - // Also handle NaN and Infinity. - return Float.floatToRawIntBits(this.value) == - Float.floatToRawIntBits(other.value) ? - this : ValueFactory.FLOAT_VALUE; - } - - public FloatValue add(ParticularFloatValue other) - { - return new ParticularFloatValue(this.value + other.value); - } - - public FloatValue subtract(ParticularFloatValue other) - { - return new ParticularFloatValue(this.value - other.value); - } - - public FloatValue subtractFrom(ParticularFloatValue other) - { - return new ParticularFloatValue(other.value - this.value); - } - - public FloatValue multiply(ParticularFloatValue other) - { - return new ParticularFloatValue(this.value * other.value); - } - - public FloatValue divide(ParticularFloatValue other) - { - return new ParticularFloatValue(this.value / other.value); - } - - public FloatValue divideOf(ParticularFloatValue other) - { - return new ParticularFloatValue(other.value / this.value); - } - - public FloatValue remainder(ParticularFloatValue other) - { - return new ParticularFloatValue(this.value % other.value); - } - - public FloatValue remainderOf(ParticularFloatValue other) - { - return new ParticularFloatValue(other.value % this.value); - } - - public IntegerValue compare(ParticularFloatValue other) - { - return this.value < other.value ? ParticularValueFactory.INTEGER_VALUE_M1 : - this.value == other.value ? ParticularValueFactory.INTEGER_VALUE_0 : - ParticularValueFactory.INTEGER_VALUE_1; - } - - - // Implementations for Value. - - public boolean isParticular() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - // Also handle NaN and Infinity. - return super.equals(object) && - Float.floatToIntBits(this.value) == - Float.floatToIntBits(((ParticularFloatValue)object).value); - } - - - public int hashCode() - { - return super.hashCode() ^ - Float.floatToIntBits(value); - } - - - public String toString() - { - return value+"f"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ParticularIntegerValue.java b/src/proguard/evaluation/value/ParticularIntegerValue.java deleted file mode 100644 index 86f8a22..0000000 --- a/src/proguard/evaluation/value/ParticularIntegerValue.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents a particular integer value. - * - * @author Eric Lafortune - */ -final class ParticularIntegerValue extends SpecificIntegerValue -{ - private final int value; - - - /** - * Creates a new particular integer value. - */ - public ParticularIntegerValue(int value) - { - this.value = value; - } - - - // Implementations for IntegerValue. - - public int value() - { - return value; - } - - - // Implementations of unary methods of IntegerValue. - - public IntegerValue negate() - { - return new ParticularIntegerValue(-value); - } - - public IntegerValue convertToByte() - { - int byteValue = (byte)value; - - return byteValue == value ? - this : - new ParticularIntegerValue(byteValue); - } - - public IntegerValue convertToCharacter() - { - int charValue = (char)value; - - return charValue == value ? - this : - new ParticularIntegerValue(charValue); - } - - public IntegerValue convertToShort() - { - int shortValue = (short)value; - - return shortValue == value ? - this : - new ParticularIntegerValue(shortValue); - } - - public LongValue convertToLong() - { - return new ParticularLongValue((long)value); - } - - public FloatValue convertToFloat() - { - return new ParticularFloatValue((float)value); - } - - public DoubleValue convertToDouble() - { - return new ParticularDoubleValue((double)value); - } - - - // Implementations of binary methods of IntegerValue. - - public IntegerValue generalize(IntegerValue other) - { - return other.generalize(this); - } - - public IntegerValue add(IntegerValue other) - { - return other.add(this); - } - - public IntegerValue subtract(IntegerValue other) - { - return other.subtractFrom(this); - } - - public IntegerValue subtractFrom(IntegerValue other) - { - return other.subtract(this); - } - - public IntegerValue multiply(IntegerValue other) - { - return other.multiply(this); - } - - public IntegerValue divide(IntegerValue other) - throws ArithmeticException - { - return other.divideOf(this); - } - - public IntegerValue divideOf(IntegerValue other) - throws ArithmeticException - { - return other.divide(this); - } - - public IntegerValue remainder(IntegerValue other) - throws ArithmeticException - { - return other.remainderOf(this); - } - - public IntegerValue remainderOf(IntegerValue other) - throws ArithmeticException - { - return other.remainder(this); - } - - public IntegerValue shiftLeft(IntegerValue other) - { - return other.shiftLeftOf(this); - } - - public IntegerValue shiftLeftOf(IntegerValue other) - { - return other.shiftLeft(this); - } - - public IntegerValue shiftRight(IntegerValue other) - { - return other.shiftRightOf(this); - } - - public IntegerValue shiftRightOf(IntegerValue other) - { - return other.shiftRight(this); - } - - public IntegerValue unsignedShiftRight(IntegerValue other) - { - return other.unsignedShiftRightOf(this); - } - - public IntegerValue unsignedShiftRightOf(IntegerValue other) - { - return other.unsignedShiftRight(this); - } - - public LongValue shiftLeftOf(LongValue other) - { - return other.shiftLeft(this); - } - - public LongValue shiftRightOf(LongValue other) - { - return other.shiftRight(this); - } - - public LongValue unsignedShiftRightOf(LongValue other) - { - return other.unsignedShiftRight(this); - } - - public IntegerValue and(IntegerValue other) - { - return other.and(this); - } - - public IntegerValue or(IntegerValue other) - { - return other.or(this); - } - - public IntegerValue xor(IntegerValue other) - { - return other.xor(this); - } - - public int equal(IntegerValue other) - { - return other.equal(this); - } - - public int lessThan(IntegerValue other) - { - return other.greaterThan(this); - } - - public int lessThanOrEqual(IntegerValue other) - { - return other.greaterThanOrEqual(this); - } - - - // Implementations of binary IntegerValue methods with ParticularIntegerValue - // arguments. - - public IntegerValue generalize(ParticularIntegerValue other) - { - return generalize((SpecificIntegerValue)other); - } - - public IntegerValue add(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value + other.value); - } - - public IntegerValue subtract(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value - other.value); - } - - public IntegerValue subtractFrom(ParticularIntegerValue other) - { - return new ParticularIntegerValue(other.value - this.value); - } - - public IntegerValue multiply(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value * other.value); - } - - public IntegerValue divide(ParticularIntegerValue other) - throws ArithmeticException - { - return new ParticularIntegerValue(this.value / other.value); - } - - public IntegerValue divideOf(ParticularIntegerValue other) - throws ArithmeticException - { - return new ParticularIntegerValue(other.value / this.value); - } - - public IntegerValue remainder(ParticularIntegerValue other) - throws ArithmeticException - { - return new ParticularIntegerValue(this.value % other.value); - } - - public IntegerValue remainderOf(ParticularIntegerValue other) - throws ArithmeticException - { - return new ParticularIntegerValue(other.value % this.value); - } - - public IntegerValue shiftLeft(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value << other.value); - } - - public IntegerValue shiftRight(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value >> other.value); - } - - public IntegerValue unsignedShiftRight(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value >>> other.value); - } - - public IntegerValue shiftLeftOf(ParticularIntegerValue other) - { - return new ParticularIntegerValue(other.value << this.value); - } - - public IntegerValue shiftRightOf(ParticularIntegerValue other) - { - return new ParticularIntegerValue(other.value >> this.value); - } - - public IntegerValue unsignedShiftRightOf(ParticularIntegerValue other) - { - return new ParticularIntegerValue(other.value >>> this.value); - } - - public LongValue shiftLeftOf(ParticularLongValue other) - { - return new ParticularLongValue(other.value() << this.value); - } - - public LongValue shiftRightOf(ParticularLongValue other) - { - return new ParticularLongValue(other.value() >> this.value); - } - - public LongValue unsignedShiftRightOf(ParticularLongValue other) - { - return new ParticularLongValue(other.value() >>> this.value); - } - - public IntegerValue and(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value & other.value); - } - - public IntegerValue or(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value | other.value); - } - - public IntegerValue xor(ParticularIntegerValue other) - { - return new ParticularIntegerValue(this.value ^ other.value); - } - - public int equal(ParticularIntegerValue other) - { - return this.value == other.value ? ALWAYS : NEVER; - } - - public int lessThan(ParticularIntegerValue other) - { - return this.value < other.value ? ALWAYS : NEVER; - } - - public int lessThanOrEqual(ParticularIntegerValue other) - { - return this.value <= other.value ? ALWAYS : NEVER; - } - - - // Implementations for Value. - - public boolean isParticular() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return super.equals(object) && - this.value == ((ParticularIntegerValue)object).value; - } - - - public int hashCode() - { - return this.getClass().hashCode() ^ - value; - } - - - public String toString() - { - return Integer.toString(value); - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ParticularLongValue.java b/src/proguard/evaluation/value/ParticularLongValue.java deleted file mode 100644 index 7e7cc20..0000000 --- a/src/proguard/evaluation/value/ParticularLongValue.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This LongValue represents a particular long value. - * - * @author Eric Lafortune - */ -final class ParticularLongValue extends SpecificLongValue -{ - private final long value; - - - /** - * Creates a new particular long value. - */ - public ParticularLongValue(long value) - { - this.value = value; - } - - - // Implementations for LongValue. - - public long value() - { - return value; - } - - - // Implementations of unary methods of LongValue. - - public LongValue negate() - { - return new ParticularLongValue(-value); - } - - public IntegerValue convertToInteger() - { - return new ParticularIntegerValue((int)value); - } - - public FloatValue convertToFloat() - { - return new ParticularFloatValue((float)value); - } - - public DoubleValue convertToDouble() - { - return new ParticularDoubleValue((double)value); - } - - - // Implementations of binary methods of LongValue. - - public LongValue generalize(LongValue other) - { - return other.generalize(this); - } - - public LongValue add(LongValue other) - { - return other.add(this); - } - - public LongValue subtract(LongValue other) - { - return other.subtractFrom(this); - } - - public LongValue subtractFrom(LongValue other) - { - return other.subtract(this); - } - - public LongValue multiply(LongValue other) - { - return other.multiply(this); - } - - public LongValue divide(LongValue other) - throws ArithmeticException - { - return other.divideOf(this); - } - - public LongValue divideOf(LongValue other) - throws ArithmeticException - { - return other.divide(this); - } - - public LongValue remainder(LongValue other) - throws ArithmeticException - { - return other.remainderOf(this); - } - - public LongValue remainderOf(LongValue other) - throws ArithmeticException - { - return other.remainder(this); - } - - public LongValue shiftLeft(IntegerValue other) - { - return other.shiftLeftOf(this); - } - - public LongValue shiftRight(IntegerValue other) - { - return other.shiftRightOf(this); - } - - public LongValue unsignedShiftRight(IntegerValue other) - { - return other.unsignedShiftRightOf(this); - } - - public LongValue and(LongValue other) - { - return other.and(this); - } - - public LongValue or(LongValue other) - { - return other.or(this); - } - - public LongValue xor(LongValue other) - { - return other.xor(this); - } - - public IntegerValue compare(LongValue other) - { - return other.compareReverse(this); - } - - - // Implementations of binary LongValue methods with ParticularLongValue - // arguments. - - public LongValue generalize(ParticularLongValue other) - { - return generalize((SpecificLongValue)other); - } - - public LongValue add(ParticularLongValue other) - { - return new ParticularLongValue(this.value + other.value); - } - - public LongValue subtract(ParticularLongValue other) - { - return new ParticularLongValue(this.value - other.value); - } - - public LongValue subtractFrom(ParticularLongValue other) - { - return new ParticularLongValue(other.value - this.value); - } - - public LongValue multiply(ParticularLongValue other) - { - return new ParticularLongValue(this.value * other.value); - } - - public LongValue divide(ParticularLongValue other) - throws ArithmeticException - { - return new ParticularLongValue(this.value / other.value); - } - - public LongValue divideOf(ParticularLongValue other) - throws ArithmeticException - { - return new ParticularLongValue(other.value / this.value); - } - - public LongValue remainder(ParticularLongValue other) - throws ArithmeticException - { - return new ParticularLongValue(this.value % other.value); - } - - public LongValue remainderOf(ParticularLongValue other) - throws ArithmeticException - { - return new ParticularLongValue(other.value % this.value); - } - - public LongValue shiftLeft(ParticularIntegerValue other) - { - return new ParticularLongValue(this.value << other.value()); - } - - public LongValue shiftRight(ParticularIntegerValue other) - { - return new ParticularLongValue(this.value >> other.value()); - } - - public LongValue unsignedShiftRight(ParticularIntegerValue other) - { - return new ParticularLongValue(this.value >>> other.value()); - } - - public LongValue and(ParticularLongValue other) - { - return new ParticularLongValue(this.value & other.value); - } - - public LongValue or(ParticularLongValue other) - { - return new ParticularLongValue(this.value | other.value); - } - - public LongValue xor(ParticularLongValue other) - { - return new ParticularLongValue(this.value ^ other.value); - } - - - // Implementations for Value. - - public boolean isParticular() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return super.equals(object) && - this.value == ((ParticularLongValue)object).value; - } - - - public int hashCode() - { - return this.getClass().hashCode() ^ - (int)value; - } - - - public String toString() - { - return value+"L"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/ParticularValueFactory.java b/src/proguard/evaluation/value/ParticularValueFactory.java deleted file mode 100644 index f28c10e..0000000 --- a/src/proguard/evaluation/value/ParticularValueFactory.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.*; - -/** - * This value factory creates particular values. - * - * @author Eric Lafortune - */ -public class ParticularValueFactory -extends ValueFactory -{ - // Shared copies of Value objects, to avoid creating a lot of objects. - static final IntegerValue INTEGER_VALUE_M1 = new ParticularIntegerValue(-1); - static final IntegerValue INTEGER_VALUE_0 = new ParticularIntegerValue(0); - static final IntegerValue INTEGER_VALUE_1 = new ParticularIntegerValue(1); - static final IntegerValue INTEGER_VALUE_2 = new ParticularIntegerValue(2); - static final IntegerValue INTEGER_VALUE_3 = new ParticularIntegerValue(3); - static final IntegerValue INTEGER_VALUE_4 = new ParticularIntegerValue(4); - static final IntegerValue INTEGER_VALUE_5 = new ParticularIntegerValue(5); - static final LongValue LONG_VALUE_0 = new ParticularLongValue(0); - static final LongValue LONG_VALUE_1 = new ParticularLongValue(1); - static final FloatValue FLOAT_VALUE_0 = new ParticularFloatValue(0.0f); - static final FloatValue FLOAT_VALUE_1 = new ParticularFloatValue(1.0f); - static final FloatValue FLOAT_VALUE_2 = new ParticularFloatValue(2.0f); - static final DoubleValue DOUBLE_VALUE_0 = new ParticularDoubleValue(0.0); - static final DoubleValue DOUBLE_VALUE_1 = new ParticularDoubleValue(1.0); - - - private static int POS_ZERO_FLOAT_BITS = Float.floatToIntBits(0.0f); - private static long POS_ZERO_DOUBLE_BITS = Double.doubleToLongBits(0.0); - - - // Implementations for ValueFactory. - - public IntegerValue createIntegerValue(int value) - { - switch (value) - { - case -1: return INTEGER_VALUE_M1; - case 0: return INTEGER_VALUE_0; - case 1: return INTEGER_VALUE_1; - case 2: return INTEGER_VALUE_2; - case 3: return INTEGER_VALUE_3; - case 4: return INTEGER_VALUE_4; - case 5: return INTEGER_VALUE_5; - default: return new ParticularIntegerValue(value); - } - } - - - public LongValue createLongValue(long value) - { - return value == 0L ? LONG_VALUE_0 : - value == 1L ? LONG_VALUE_1 : - new ParticularLongValue(value); - } - - - public FloatValue createFloatValue(float value) - { - // Make sure to distinguish between +0.0 and -0.0. - return value == 0.0f && Float.floatToIntBits(value) == POS_ZERO_FLOAT_BITS - ? FLOAT_VALUE_0 : - value == 1.0f ? FLOAT_VALUE_1 : - value == 2.0f ? FLOAT_VALUE_2 : - new ParticularFloatValue(value); - } - - - public DoubleValue createDoubleValue(double value) - { - // Make sure to distinguish between +0.0 and -0.0. - return value == 0.0 && Double.doubleToLongBits(value) == POS_ZERO_DOUBLE_BITS - ? DOUBLE_VALUE_0 : - value == 1.0 ? DOUBLE_VALUE_1 : - new ParticularDoubleValue(value); - } - - - public ReferenceValue createArrayReferenceValue(String type, - Clazz referencedClass, - IntegerValue arrayLength) - { - return type == null ? - REFERENCE_VALUE_NULL : - new ArrayReferenceValue(ClassConstants.TYPE_ARRAY + type, - referencedClass, - arrayLength); - } -} diff --git a/src/proguard/evaluation/value/ReferenceValue.java b/src/proguard/evaluation/value/ReferenceValue.java deleted file mode 100644 index 1f87382..0000000 --- a/src/proguard/evaluation/value/ReferenceValue.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.Clazz; - -/** - * This class represents a partially evaluated reference value. - * - * @author Eric Lafortune - */ -public abstract class ReferenceValue extends Category1Value -{ - /** - * Returns the type. - */ - public abstract String getType(); -; - - /** - * Returns the class that is referenced by the type. - */ - public abstract Clazz getReferencedClass(); - - - // Basic unary methods. - - /** - * Returns whether the type is <code>null</code>. - */ - public abstract int isNull(); - - - /** - * Returns whether the type is an instance of the given type. - */ - public abstract int instanceOf(String otherType, Clazz otherReferencedClass); - - - /** - * Returns a generalization of this ReferenceValue that may be null, - * depending on the flag. - */ - public abstract ReferenceValue generalizeMayBeNull(boolean mayBeNull); - - - /** - * Returns the length of the array, assuming this type is an array. - */ - public IntegerValue arrayLength(ValueFactory valueFactory) - { - return valueFactory.createIntegerValue(); - } - - - /** - * Returns the value of the array at the given index, assuming this type - * is an integer array. - */ - public IntegerValue integerArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - return valueFactory.createIntegerValue(); - } - - - /** - * Returns the value of the array at the given index, assuming this type - * is an long array. - */ - public LongValue longArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - return valueFactory.createLongValue(); - } - - - /** - * Returns the value of the array at the given index, assuming this type - * is an float array. - */ - public FloatValue floatArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - return valueFactory.createFloatValue(); - } - - - /** - * Returns the value of the array at the given index, assuming this type - * is an double array. - */ - public DoubleValue doubleArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - return valueFactory.createDoubleValue(); - } - - - /** - * Returns the value of the array at the given index, assuming this type - * is a reference array. - */ - public abstract ReferenceValue referenceArrayLoad(IntegerValue indexValue, ValueFactory valueFactory); - - - /** - * Stores the given value at the given index in the given array, assuming - * this type is an array. - */ - public void arrayStore(IntegerValue indexValue, Value value) - { - } - - - // Basic binary methods. - - /** - * Returns the generalization of this ReferenceValue and the given other - * ReferenceValue. - */ - public abstract ReferenceValue generalize(ReferenceValue other); - - - /** - * Returns whether this ReferenceValue is equal to the given other - * ReferenceValue. - * @return <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public abstract int equal(ReferenceValue other); - - - // Derived unary methods. - - /** - * Returns whether this ReferenceValue is not <code>null</code>. - * @return <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public final int isNotNull() - { - return -isNull(); - } - - - // Derived binary methods. - - /** - * Returns whether this ReferenceValue and the given ReferenceValue are different. - * @return <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public final int notEqual(ReferenceValue other) - { - return -equal(other); - } - - - // Similar binary methods, but this time with typed reference arguments. - - /** - * Returns the generalization of this ReferenceValue and the given other - * TypedReferenceValue. - */ - public ReferenceValue generalize(TypedReferenceValue other) - { - return generalize((ReferenceValue)other); - } - - - /** - * Returns whether this ReferenceValue is equal to the given other - * TypedReferenceValue. - * @return <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public int equal(TypedReferenceValue other) - { - return equal((ReferenceValue)other); - } - - - // Similar binary methods, but this time with identified reference - // arguments. - - /** - * Returns the generalization of this ReferenceValue and the given other - * IdentifiedReferenceValue. - */ - public ReferenceValue generalize(IdentifiedReferenceValue other) - { - return generalize((TypedReferenceValue)other); - } - - - /** - * Returns whether this ReferenceValue is equal to the given other - * IdentifiedReferenceValue. - * @return <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public int equal(IdentifiedReferenceValue other) - { - return equal((TypedReferenceValue)other); - } - - - // Similar binary methods, but this time with array reference arguments. - - /** - * Returns the generalization of this ReferenceValue and the given other - * ArrayReferenceValue. - */ - public ReferenceValue generalize(ArrayReferenceValue other) - { - return generalize((TypedReferenceValue)other); - } - - - /** - * Returns whether this ReferenceValue is equal to the given other - * ArrayReferenceValue. - * @return <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public int equal(ArrayReferenceValue other) - { - return equal((TypedReferenceValue)other); - } - - - // Similar binary methods, but this time with identified array reference - // arguments. - - /** - * Returns the generalization of this ReferenceValue and the given other - * IdentifiedArrayReferenceValue. - */ - public ReferenceValue generalize(IdentifiedArrayReferenceValue other) - { - return generalize((ArrayReferenceValue)other); - } - - - /** - * Returns whether this ReferenceValue is equal to the given other - * IdentifiedArrayReferenceValue. - * @return <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public int equal(IdentifiedArrayReferenceValue other) - { - return equal((ArrayReferenceValue)other); - } - - - // Similar binary methods, but this time with detailed array reference - // arguments. - - /** - * Returns the generalization of this ReferenceValue and the given other - * DetailedArrayReferenceValue. - */ - public ReferenceValue generalize(DetailedArrayReferenceValue other) - { - return generalize((IdentifiedArrayReferenceValue)other); - } - - - /** - * Returns whether this ReferenceValue is equal to the given other - * DetailedArrayReferenceValue. - * @return <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>. - */ - public int equal(DetailedArrayReferenceValue other) - { - return equal((IdentifiedArrayReferenceValue)other); - } - - - // Implementations for Value. - - public final ReferenceValue referenceValue() - { - return this; - } - - public final Value generalize(Value other) - { - return this.generalize(other.referenceValue()); - } - - public final int computationalType() - { - return TYPE_REFERENCE; - } -} diff --git a/src/proguard/evaluation/value/SpecificDoubleValue.java b/src/proguard/evaluation/value/SpecificDoubleValue.java deleted file mode 100644 index 5ee2db2..0000000 --- a/src/proguard/evaluation/value/SpecificDoubleValue.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This DoubleValue represents a specific double value. - * - * @author Eric Lafortune - */ -abstract class SpecificDoubleValue extends DoubleValue -{ - // Implementations of unary methods of DoubleValue. - - public DoubleValue negate() - { - return new NegatedDoubleValue(this); - } - - public IntegerValue convertToInteger() - { - return new ConvertedIntegerValue(this); - } - - public LongValue convertToLong() - { - return new ConvertedLongValue(this); - } - - public FloatValue convertToFloat() - { - return new ConvertedFloatValue(this); - } - - - // Implementations of binary methods of DoubleValue. - - public DoubleValue generalize(DoubleValue other) - { - return other.generalize(this); - } - - public DoubleValue add(DoubleValue other) - { - return other.add(this); - } - - public DoubleValue subtract(DoubleValue other) - { - return other.subtractFrom(this); - } - - public DoubleValue subtractFrom(DoubleValue other) - { - return other.subtract(this); - } - - public DoubleValue multiply(DoubleValue other) - { - return other.multiply(this); - } - - public DoubleValue divide(DoubleValue other) - { - return other.divideOf(this); - } - - public DoubleValue divideOf(DoubleValue other) - { - return other.divide(this); - } - - public DoubleValue remainder(DoubleValue other) - { - return other.remainderOf(this); - } - - public DoubleValue remainderOf(DoubleValue other) - { - return other.remainder(this); - } - - public IntegerValue compare(DoubleValue other) - { - return other.compareReverse(this); - } - - - // Implementations of binary DoubleValue methods with SpecificDoubleValue - // arguments. - - public DoubleValue generalize(SpecificDoubleValue other) - { - return this.equals(other) ? this : ValueFactory.DOUBLE_VALUE; - } - - public DoubleValue add(SpecificDoubleValue other) - { - return new CompositeDoubleValue(this, CompositeDoubleValue.ADD, other); - } - - public DoubleValue subtract(SpecificDoubleValue other) - { - return new CompositeDoubleValue(this, CompositeDoubleValue.SUBTRACT, other); - } - - public DoubleValue subtractFrom(SpecificDoubleValue other) - { - return new CompositeDoubleValue(other, CompositeDoubleValue.SUBTRACT, this); - } - - public DoubleValue multiply(SpecificDoubleValue other) - { - return new CompositeDoubleValue(this, CompositeDoubleValue.MULTIPLY, other); - } - - public DoubleValue divide(SpecificDoubleValue other) - { - return new CompositeDoubleValue(this, CompositeDoubleValue.DIVIDE, other); - } - - public DoubleValue divideOf(SpecificDoubleValue other) - { - return new CompositeDoubleValue(other, CompositeDoubleValue.DIVIDE, this); - } - - public DoubleValue remainder(SpecificDoubleValue other) - { - return new CompositeDoubleValue(this, CompositeDoubleValue.REMAINDER, other); - } - - public DoubleValue remainderOf(SpecificDoubleValue other) - { - return new CompositeDoubleValue(other, CompositeDoubleValue.REMAINDER, this); - } - - public IntegerValue compare(SpecificDoubleValue other) - { - return ValueFactory.INTEGER_VALUE; - - // Not handling NaN properly. - //return this.equals(other) ? - // ParticularValueFactory.INTEGER_VALUE_0 : - // new ComparisonValue(this, other); - } - - - // Implementations for Value. - - public boolean isSpecific() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } -} diff --git a/src/proguard/evaluation/value/SpecificFloatValue.java b/src/proguard/evaluation/value/SpecificFloatValue.java deleted file mode 100644 index 66e245a..0000000 --- a/src/proguard/evaluation/value/SpecificFloatValue.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This FloatValue represents a specific float value. - * - * @author Eric Lafortune - */ -abstract class SpecificFloatValue extends FloatValue -{ - // Implementations of unary methods of FloatValue. - - public FloatValue negate() - { - return new NegatedFloatValue(this); - } - - public IntegerValue convertToInteger() - { - return new ConvertedIntegerValue(this); - } - - public LongValue convertToLong() - { - return new ConvertedLongValue(this); - } - - public DoubleValue convertToDouble() - { - return new ConvertedDoubleValue(this); - } - - - // Implementations of binary methods of FloatValue. - - public FloatValue generalize(FloatValue other) - { - return other.generalize(this); - } - - public FloatValue add(FloatValue other) - { - return other.add(this); - } - - public FloatValue subtract(FloatValue other) - { - return other.subtractFrom(this); - } - - public FloatValue subtractFrom(FloatValue other) - { - return other.subtract(this); - } - - public FloatValue multiply(FloatValue other) - { - return other.multiply(this); - } - - public FloatValue divide(FloatValue other) - { - return other.divideOf(this); - } - - public FloatValue divideOf(FloatValue other) - { - return other.divide(this); - } - - public FloatValue remainder(FloatValue other) - { - return other.remainderOf(this); - } - - public FloatValue remainderOf(FloatValue other) - { - return other.remainder(this); - } - - public IntegerValue compare(FloatValue other) - { - return other.compareReverse(this); - } - - - // Implementations of binary FloatValue methods with SpecificFloatValue - // arguments. - - public FloatValue generalize(SpecificFloatValue other) - { - return this.equals(other) ? this : ValueFactory.FLOAT_VALUE; - } - - public FloatValue add(SpecificFloatValue other) - { - return new CompositeFloatValue(this, CompositeFloatValue.ADD, other); - } - - public FloatValue subtract(SpecificFloatValue other) - { - return new CompositeFloatValue(this, CompositeFloatValue.SUBTRACT, other); - } - - public FloatValue subtractFrom(SpecificFloatValue other) - { - return new CompositeFloatValue(other, CompositeFloatValue.SUBTRACT, this); - } - - public FloatValue multiply(SpecificFloatValue other) - { - return new CompositeFloatValue(this, CompositeFloatValue.MULTIPLY, other); - } - - public FloatValue divide(SpecificFloatValue other) - { - return new CompositeFloatValue(this, CompositeFloatValue.DIVIDE, other); - } - - public FloatValue divideOf(SpecificFloatValue other) - { - return new CompositeFloatValue(other, CompositeFloatValue.DIVIDE, this); - } - - public FloatValue remainder(SpecificFloatValue other) - { - return new CompositeFloatValue(this, CompositeFloatValue.REMAINDER, other); - } - - public FloatValue remainderOf(SpecificFloatValue other) - { - return new CompositeFloatValue(other, CompositeFloatValue.REMAINDER, this); - } - - public IntegerValue compare(SpecificFloatValue other) - { - return ValueFactory.INTEGER_VALUE; - - // Not handling NaN properly. - //return this.equals(other) ? - // ParticularValueFactory.INTEGER_VALUE_0 : - // new ComparisonValue(this, other); - } - - - // Implementations for Value. - - public boolean isSpecific() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } -} diff --git a/src/proguard/evaluation/value/SpecificIntegerValue.java b/src/proguard/evaluation/value/SpecificIntegerValue.java deleted file mode 100644 index 352e385..0000000 --- a/src/proguard/evaluation/value/SpecificIntegerValue.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This IntegerValue represents a specific integer value. - * - * @author Eric Lafortune - */ -abstract class SpecificIntegerValue extends IntegerValue -{ - // Implementations of unary methods of IntegerValue. - - public IntegerValue negate() - { - return new NegatedIntegerValue(this); - } - - public IntegerValue convertToByte() - { - return new ConvertedByteValue(this); - } - - public IntegerValue convertToCharacter() - { - return new ConvertedCharacterValue(this); - } - - public IntegerValue convertToShort() - { - return new ConvertedShortValue(this); - } - - public LongValue convertToLong() - { - return new ConvertedLongValue(this); - } - - public FloatValue convertToFloat() - { - return new ConvertedFloatValue(this); - } - - public DoubleValue convertToDouble() - { - return new ConvertedDoubleValue(this); - } - - - // Implementations of binary methods of IntegerValue. - - public IntegerValue generalize(IntegerValue other) - { - return other.generalize(this); - } - - public IntegerValue add(IntegerValue other) - { - return other.add(this); - } - - public IntegerValue subtract(IntegerValue other) - { - return other.subtractFrom(this); - } - - public IntegerValue subtractFrom(IntegerValue other) - { - return other.subtract(this); - } - - public IntegerValue multiply(IntegerValue other) - { - return other.multiply(this); - } - - public IntegerValue divide(IntegerValue other) - throws ArithmeticException - { - return other.divideOf(this); - } - - public IntegerValue divideOf(IntegerValue other) - throws ArithmeticException - { - return other.divide(this); - } - - public IntegerValue remainder(IntegerValue other) - throws ArithmeticException - { - return other.remainderOf(this); - } - - public IntegerValue remainderOf(IntegerValue other) - throws ArithmeticException - { - return other.remainder(this); - } - - public IntegerValue shiftLeft(IntegerValue other) - { - return other.shiftLeftOf(this); - } - - public IntegerValue shiftLeftOf(IntegerValue other) - { - return other.shiftLeft(this); - } - - public IntegerValue shiftRight(IntegerValue other) - { - return other.shiftRightOf(this); - } - - public IntegerValue shiftRightOf(IntegerValue other) - { - return other.shiftRight(this); - } - - public IntegerValue unsignedShiftRight(IntegerValue other) - { - return other.unsignedShiftRightOf(this); - } - - public IntegerValue unsignedShiftRightOf(IntegerValue other) - { - return other.unsignedShiftRight(this); - } - - public LongValue shiftLeftOf(LongValue other) - { - return other.shiftLeft(this); - } - - public LongValue shiftRightOf(LongValue other) - { - return other.shiftRight(this); - } - - public LongValue unsignedShiftRightOf(LongValue other) - { - return other.unsignedShiftRight(this); - } - - public IntegerValue and(IntegerValue other) - { - return other.and(this); - } - - public IntegerValue or(IntegerValue other) - { - return other.or(this); - } - - public IntegerValue xor(IntegerValue other) - { - return other.xor(this); - } - - public int equal(IntegerValue other) - { - return other.equal(this); - } - - public int lessThan(IntegerValue other) - { - return other.greaterThan(this); - } - - public int lessThanOrEqual(IntegerValue other) - { - return other.greaterThanOrEqual(this); - } - - - // Implementations of binary IntegerValue methods with SpecificIntegerValue - // arguments. - - public IntegerValue generalize(SpecificIntegerValue other) - { - return this.equals(other) ? this : ValueFactory.INTEGER_VALUE; - } - - public IntegerValue add(SpecificIntegerValue other) - { - return new CompositeIntegerValue(this, CompositeIntegerValue.ADD, other); - } - - public IntegerValue subtract(SpecificIntegerValue other) - { - return this.equals(other) ? - ParticularValueFactory.INTEGER_VALUE_0 : - new CompositeIntegerValue(this, CompositeIntegerValue.SUBTRACT, other); - } - - public IntegerValue subtractFrom(SpecificIntegerValue other) - { - return this.equals(other) ? - ParticularValueFactory.INTEGER_VALUE_0 : - new CompositeIntegerValue(other, CompositeIntegerValue.SUBTRACT, this); - } - - public IntegerValue multiply(SpecificIntegerValue other) - { - return new CompositeIntegerValue(this, CompositeIntegerValue.MULTIPLY, other); - } - - public IntegerValue divide(SpecificIntegerValue other) - throws ArithmeticException - { - return new CompositeIntegerValue(this, CompositeIntegerValue.DIVIDE, other); - } - - public IntegerValue divideOf(SpecificIntegerValue other) - throws ArithmeticException - { - return new CompositeIntegerValue(other, CompositeIntegerValue.DIVIDE, this); - } - - public IntegerValue remainder(SpecificIntegerValue other) - throws ArithmeticException - { - return new CompositeIntegerValue(this, CompositeIntegerValue.REMAINDER, other); - } - - public IntegerValue remainderOf(SpecificIntegerValue other) - throws ArithmeticException - { - return new CompositeIntegerValue(other, CompositeIntegerValue.REMAINDER, this); - } - - public IntegerValue shiftLeft(SpecificIntegerValue other) - { - return new CompositeIntegerValue(this, CompositeIntegerValue.SHIFT_LEFT, other); - } - - public IntegerValue shiftRight(SpecificIntegerValue other) - { - return new CompositeIntegerValue(this, CompositeIntegerValue.SHIFT_RIGHT, other); - } - - public IntegerValue unsignedShiftRight(SpecificIntegerValue other) - { - return new CompositeIntegerValue(this, CompositeIntegerValue.UNSIGNED_SHIFT_RIGHT, other); - } - - public IntegerValue shiftLeftOf(SpecificIntegerValue other) - { - return new CompositeIntegerValue(other, CompositeIntegerValue.SHIFT_LEFT, this); - } - - public IntegerValue shiftRightOf(SpecificIntegerValue other) - { - return new CompositeIntegerValue(other, CompositeIntegerValue.SHIFT_RIGHT, this); - } - - public IntegerValue unsignedShiftRightOf(SpecificIntegerValue other) - { - return new CompositeIntegerValue(other, CompositeIntegerValue.UNSIGNED_SHIFT_RIGHT, this); - } - - public LongValue shiftLeftOf(SpecificLongValue other) - { - return new CompositeLongValue(other, CompositeLongValue.SHIFT_LEFT, this); - } - - public LongValue shiftRightOf(SpecificLongValue other) - { - return new CompositeLongValue(other, CompositeLongValue.SHIFT_RIGHT, this); - } - - public LongValue unsignedShiftRightOf(SpecificLongValue other) - { - return new CompositeLongValue(other, CompositeLongValue.UNSIGNED_SHIFT_RIGHT, this); - } - - public IntegerValue and(SpecificIntegerValue other) - { - return this.equals(other) ? - this : - new CompositeIntegerValue(other, CompositeIntegerValue.AND, this); - } - - public IntegerValue or(SpecificIntegerValue other) - { - return this.equals(other) ? - this : - new CompositeIntegerValue(other, CompositeIntegerValue.OR, this); - } - - public IntegerValue xor(SpecificIntegerValue other) - { - return this.equals(other) ? - ParticularValueFactory.INTEGER_VALUE_0 : - new CompositeIntegerValue(other, CompositeIntegerValue.XOR, this); - } - - public int equal(SpecificIntegerValue other) - { - return this.equals(other) ? ALWAYS : MAYBE; - } - - public int lessThan(SpecificIntegerValue other) - { - return this.equals(other) ? NEVER : MAYBE; - } - - public int lessThanOrEqual(SpecificIntegerValue other) - { - return this.equals(other) ? ALWAYS : MAYBE; - } - - - // Implementations for Value. - - public boolean isSpecific() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } -} diff --git a/src/proguard/evaluation/value/SpecificLongValue.java b/src/proguard/evaluation/value/SpecificLongValue.java deleted file mode 100644 index 162f9fe..0000000 --- a/src/proguard/evaluation/value/SpecificLongValue.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This LongValue represents a specific long value. - * - * @author Eric Lafortune - */ -abstract class SpecificLongValue extends LongValue -{ - // Implementations of unary methods of LongValue. - - public LongValue negate() - { - return new NegatedLongValue(this); - } - - public IntegerValue convertToInteger() - { - return new ConvertedIntegerValue(this); - } - - public FloatValue convertToFloat() - { - return new ConvertedFloatValue(this); - } - - public DoubleValue convertToDouble() - { - return new ConvertedDoubleValue(this); - } - - - // Implementations of binary methods of LongValue. - - public LongValue generalize(LongValue other) - { - return other.generalize(this); - } - - public LongValue add(LongValue other) - { - return other.add(this); - } - - public LongValue subtract(LongValue other) - { - return other.subtractFrom(this); - } - - public LongValue subtractFrom(LongValue other) - { - return other.subtract(this); - } - - public LongValue multiply(LongValue other) - { - return other.multiply(this); - } - - public LongValue divide(LongValue other) - throws ArithmeticException - { - return other.divideOf(this); - } - - public LongValue divideOf(LongValue other) - throws ArithmeticException - { - return other.divide(this); - } - - public LongValue remainder(LongValue other) - throws ArithmeticException - { - return other.remainderOf(this); - } - - public LongValue remainderOf(LongValue other) - throws ArithmeticException - { - return other.remainder(this); - } - - public LongValue shiftLeft(IntegerValue other) - { - return other.shiftLeftOf(this); - } - - public LongValue shiftRight(IntegerValue other) - { - return other.shiftRightOf(this); - } - - public LongValue unsignedShiftRight(IntegerValue other) - { - return other.unsignedShiftRightOf(this); - } - - public LongValue and(LongValue other) - { - return other.and(this); - } - - public LongValue or(LongValue other) - { - return other.or(this); - } - - public LongValue xor(LongValue other) - { - return other.xor(this); - } - - public IntegerValue compare(LongValue other) - { - return other.compareReverse(this); - } - - - // Implementations of binary LongValue methods with SpecificLongValue - // arguments. - - public LongValue generalize(SpecificLongValue other) - { - return this.equals(other) ? this : ValueFactory.LONG_VALUE; - } - - public LongValue add(SpecificLongValue other) - { - return new CompositeLongValue(this, CompositeLongValue.ADD, other); - } - - public LongValue subtract(SpecificLongValue other) - { - return this.equals(other) ? - ParticularValueFactory.LONG_VALUE_0 : - new CompositeLongValue(this, CompositeLongValue.SUBTRACT, other); - } - - public LongValue subtractFrom(SpecificLongValue other) - { - return this.equals(other) ? - ParticularValueFactory.LONG_VALUE_0 : - new CompositeLongValue(other, CompositeLongValue.SUBTRACT, this); - } - - public LongValue multiply(SpecificLongValue other) - { - return new CompositeLongValue(this, CompositeLongValue.MULTIPLY, other); - } - - public LongValue divide(SpecificLongValue other) - throws ArithmeticException - { - return new CompositeLongValue(this, CompositeLongValue.DIVIDE, other); - } - - public LongValue divideOf(SpecificLongValue other) - throws ArithmeticException - { - return new CompositeLongValue(other, CompositeLongValue.DIVIDE, this); - } - - public LongValue remainder(SpecificLongValue other) - throws ArithmeticException - { - return new CompositeLongValue(this, CompositeLongValue.REMAINDER, other); - } - - public LongValue remainderOf(SpecificLongValue other) - throws ArithmeticException - { - return new CompositeLongValue(other, CompositeLongValue.REMAINDER, this); - } - - public LongValue shiftLeft(SpecificLongValue other) - { - return new CompositeLongValue(this, CompositeLongValue.SHIFT_LEFT, other); - } - - public LongValue shiftRight(SpecificLongValue other) - { - return new CompositeLongValue(this, CompositeLongValue.SHIFT_RIGHT, other); - } - - public LongValue unsignedShiftRight(SpecificLongValue other) - { - return new CompositeLongValue(this, CompositeLongValue.UNSIGNED_SHIFT_RIGHT, other); - } - - public LongValue and(SpecificLongValue other) - { - return this.equals(other) ? - this : - new CompositeLongValue(other, CompositeLongValue.AND, this); - } - - public LongValue or(SpecificLongValue other) - { - return this.equals(other) ? - this : - new CompositeLongValue(other, CompositeLongValue.OR, this); - } - - public LongValue xor(SpecificLongValue other) - { - return this.equals(other) ? - ParticularValueFactory.LONG_VALUE_0 : - new CompositeLongValue(other, CompositeLongValue.XOR, this); - } - - public IntegerValue compare(SpecificLongValue other) - { - return new ComparisonValue(this, other); - } - - - // Implementations for Value. - - public boolean isSpecific() - { - return true; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } -} diff --git a/src/proguard/evaluation/value/TopValue.java b/src/proguard/evaluation/value/TopValue.java deleted file mode 100644 index 4422f69..0000000 --- a/src/proguard/evaluation/value/TopValue.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This class represents a partially evaluated top value. A top value is the - * dummy value that takes up the extra space when storing a long value or a - * double value. - * - * @author Eric Lafortune - */ -public class TopValue extends Category1Value -{ - // Implementations for Value. - - public boolean isSpecific() - { - return true; - } - - public boolean isParticular() - { - return true; - } - - public final Value generalize(Value other) - { - return this.getClass() == other.getClass() ? this : null; - } - - public final int computationalType() - { - return TYPE_TOP; - } - - public final String internalType() - { - return null; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } - - - public String toString() - { - return "T"; - } -} diff --git a/src/proguard/evaluation/value/TypedReferenceValue.java b/src/proguard/evaluation/value/TypedReferenceValue.java deleted file mode 100644 index 4f8629c..0000000 --- a/src/proguard/evaluation/value/TypedReferenceValue.java +++ /dev/null @@ -1,613 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.*; -import proguard.classfile.util.ClassUtil; -import proguard.classfile.visitor.ClassCollector; - -import java.util.*; - -/** - * This ReferenceValue represents a partially evaluated reference value. - * It has a type and a flag that indicates whether the value could be - * <code>null</code>. If the type is <code>null</code>, the value is - * <code>null</code>. - * - * @author Eric Lafortune - */ -public class TypedReferenceValue extends ReferenceValue -{ - private static final boolean DEBUG = false; - - - protected final String type; - protected final Clazz referencedClass; - protected final boolean mayBeNull; - - - /** - * Creates a new TypedReferenceValue. - */ - public TypedReferenceValue(String type, - Clazz referencedClass, - boolean mayBeNull) - { - this.type = type; - this.referencedClass = referencedClass; - this.mayBeNull = mayBeNull; - } - - - // Implementations for ReferenceValue. - - public String getType() - { - return type; - } - - - public Clazz getReferencedClass() - { - return referencedClass; - } - - - // Implementations of unary methods of ReferenceValue. - - public int isNull() - { - return type == null ? ALWAYS : - mayBeNull ? MAYBE : - NEVER; - } - - - public int instanceOf(String otherType, Clazz otherReferencedClass) - { - String thisType = this.type; - - // If this type is null, it is never an instance of any class. - if (thisType == null) - { - return NEVER; - } - - // Start taking into account the type dimensions. - int thisDimensionCount = ClassUtil.internalArrayTypeDimensionCount(thisType); - int otherDimensionCount = ClassUtil.internalArrayTypeDimensionCount(otherType); - int commonDimensionCount = Math.min(thisDimensionCount, otherDimensionCount); - - // Strip any common array prefixes. - thisType = thisType.substring(commonDimensionCount); - otherType = otherType.substring(commonDimensionCount); - - // If either stripped type is a primitive type, we can tell right away. - if (commonDimensionCount > 0 && - (ClassUtil.isInternalPrimitiveType(thisType.charAt(0)) || - ClassUtil.isInternalPrimitiveType(otherType.charAt(0)))) - { - return !thisType.equals(otherType) ? NEVER : - mayBeNull ? MAYBE : - ALWAYS; - } - - // Strip the class type prefix and suffix of this type, if any. - if (thisDimensionCount == commonDimensionCount) - { - thisType = ClassUtil.internalClassNameFromClassType(thisType); - } - - // Strip the class type prefix and suffix of the other type, if any. - if (otherDimensionCount == commonDimensionCount) - { - otherType = ClassUtil.internalClassNameFromClassType(otherType); - } - - // If this type is an array type, and the other type is not - // java.lang.Object, java.lang.Cloneable, or java.io.Serializable, - // this type can never be an instance. - if (thisDimensionCount > otherDimensionCount && - !ClassUtil.isInternalArrayInterfaceName(otherType)) - { - return NEVER; - } - - // If the other type is an array type, and this type is not - // java.lang.Object, java.lang.Cloneable, or java.io.Serializable, - // this type can never be an instance. - if (thisDimensionCount < otherDimensionCount && - !ClassUtil.isInternalArrayInterfaceName(thisType)) - { - return NEVER; - } - - // If this type may be null, it might not be an instance of any class. - if (mayBeNull) - { - return MAYBE; - } - - // If this type is equal to the other type, or if the other type is - // java.lang.Object, this type is always an instance. - if (thisType.equals(otherType) || - ClassConstants.NAME_JAVA_LANG_OBJECT.equals(otherType)) - { - return ALWAYS; - } - - // If this type is an array type, it's ok. - if (thisDimensionCount > otherDimensionCount) - { - return ALWAYS; - } - - // If the other type is an array type, it might be ok. - if (thisDimensionCount < otherDimensionCount) - { - return MAYBE; - } - - // If the value extends the type, we're sure. - return referencedClass != null && - otherReferencedClass != null && - referencedClass.extendsOrImplements(otherReferencedClass) ? - ALWAYS : - MAYBE; - } - - - public ReferenceValue generalizeMayBeNull(boolean mayBeNull) - { - return this.mayBeNull == mayBeNull ? - this : - new TypedReferenceValue(type, referencedClass, true); - } - - - public ReferenceValue referenceArrayLoad(IntegerValue indexValue, ValueFactory valueFactory) - { - return - type == null ? ValueFactory.REFERENCE_VALUE_NULL : - !ClassUtil.isInternalArrayType(type) ? ValueFactory.REFERENCE_VALUE_JAVA_LANG_OBJECT_MAYBE_NULL : - valueFactory.createValue(type.substring(1), - referencedClass, - true).referenceValue(); - } - - - // Implementations of binary methods of ReferenceValue. - - public ReferenceValue generalize(ReferenceValue other) - { - return other.generalize(this); - } - - - public int equal(ReferenceValue other) - { - return other.equal(this); - } - - - // Implementations of binary ReferenceValue methods with TypedReferenceValue - // arguments. - - public ReferenceValue generalize(TypedReferenceValue other) - { - // If both types are identical, the generalization is the same too. - if (this.equals(other)) - { - return this; - } - - String thisType = this.type; - String otherType = other.type; - - // If both types are nul, the generalization is null too. - if (thisType == null && otherType == null) - { - return ValueFactory.REFERENCE_VALUE_NULL; - } - - // If this type is null, the generalization is the other type, maybe null. - if (thisType == null) - { - return other.generalizeMayBeNull(true); - } - - // If the other type is null, the generalization is this type, maybe null. - if (otherType == null) - { - return this.generalizeMayBeNull(true); - } - - boolean mayBeNull = this.mayBeNull || other.mayBeNull; - - // If the two types are equal, the generalization remains the same, maybe null. - if (thisType.equals(otherType)) - { - return typedReferenceValue(this, mayBeNull); - } - - // Start taking into account the type dimensions. - int thisDimensionCount = ClassUtil.internalArrayTypeDimensionCount(thisType); - int otherDimensionCount = ClassUtil.internalArrayTypeDimensionCount(otherType); - int commonDimensionCount = Math.min(thisDimensionCount, otherDimensionCount); - - if (thisDimensionCount == otherDimensionCount) - { - // See if we can take into account the referenced classes. - Clazz thisReferencedClass = this.referencedClass; - Clazz otherReferencedClass = other.referencedClass; - - if (thisReferencedClass != null && - otherReferencedClass != null) - { - // Is one class simply an extension of the other one? - if (thisReferencedClass.extendsOrImplements(otherReferencedClass)) - { - return typedReferenceValue(other, mayBeNull); - } - - if (otherReferencedClass.extendsOrImplements(thisReferencedClass)) - { - return typedReferenceValue(this, mayBeNull); - } - - // Do the classes have a non-trivial common superclass? - Clazz commonClass = findCommonClass(thisReferencedClass, - otherReferencedClass, - false); - - if (commonClass.getName().equals(ClassConstants.NAME_JAVA_LANG_OBJECT)) - { - // Otherwise, do the classes have a common interface? - Clazz commonInterface = findCommonClass(thisReferencedClass, - otherReferencedClass, - true); - if (commonInterface != null) - { - commonClass = commonInterface; - } - } - - return new TypedReferenceValue(commonDimensionCount == 0 ? - commonClass.getName() : - ClassUtil.internalArrayTypeFromClassName(commonClass.getName(), - commonDimensionCount), - commonClass, - mayBeNull); - } - } - else if (thisDimensionCount > otherDimensionCount) - { - // See if the other type is an interface type of arrays. - if (ClassUtil.isInternalArrayInterfaceName(ClassUtil.internalClassNameFromClassType(otherType))) - { - return typedReferenceValue(other, mayBeNull); - } - } - else if (thisDimensionCount < otherDimensionCount) - { - // See if this type is an interface type of arrays. - if (ClassUtil.isInternalArrayInterfaceName(ClassUtil.internalClassNameFromClassType(thisType))) - { - return typedReferenceValue(this, mayBeNull); - } - } - - // Reduce the common dimension count if either type is an array of - // primitives type of this dimension. - if (commonDimensionCount > 0 && - (ClassUtil.isInternalPrimitiveType(otherType.charAt(commonDimensionCount))) || - ClassUtil.isInternalPrimitiveType(thisType.charAt(commonDimensionCount))) - { - commonDimensionCount--; - } - - // Fall back on a basic Object or array of Objects type. - return - commonDimensionCount != 0 ? - new TypedReferenceValue(ClassUtil.internalArrayTypeFromClassName(ClassConstants.NAME_JAVA_LANG_OBJECT, commonDimensionCount), - null, - mayBeNull) : - mayBeNull ? - ValueFactory.REFERENCE_VALUE_JAVA_LANG_OBJECT_MAYBE_NULL : - ValueFactory.REFERENCE_VALUE_JAVA_LANG_OBJECT_NOT_NULL; - } - - - /** - * Returns the most specific common superclass or interface of the given - * classes. - * @param class1 the first class. - * @param class2 the second class. - * @param interfaces specifies whether to look for a superclass or for an - * interface. - * @return the common class. - */ - private Clazz findCommonClass(Clazz class1, - Clazz class2, - boolean interfaces) - { - // Collect the superclasses or the interfaces of this class. - Set superClasses1 = new HashSet(); - class1.hierarchyAccept(!interfaces, - !interfaces, - interfaces, - false, - new ClassCollector(superClasses1)); - - int superClasses1Count = superClasses1.size(); - if (superClasses1Count == 0) - { - if (interfaces) - { - return null; - } - else if (class1.getSuperName() != null) - { - throw new IllegalArgumentException("Can't find any super classes of ["+class1.getName()+"] (not even immediate super class ["+class1.getSuperName()+"])"); - } - } - - // Collect the superclasses or the interfaces of the other class. - Set superClasses2 = new HashSet(); - class2.hierarchyAccept(!interfaces, - !interfaces, - interfaces, - false, - new ClassCollector(superClasses2)); - - int superClasses2Count = superClasses2.size(); - if (superClasses2Count == 0) - { - if (interfaces) - { - return null; - } - else if (class2.getSuperName() != null) - { - throw new IllegalArgumentException("Can't find any super classes of ["+class2.getName()+"] (not even immediate super class ["+class2.getSuperName()+"])"); - } - } - - if (DEBUG) - { - System.out.println("ReferenceValue.generalize this ["+class1.getName()+"] with other ["+class2.getName()+"] (interfaces = "+interfaces+")"); - System.out.println(" This super classes: "+superClasses1); - System.out.println(" Other super classes: "+superClasses2); - } - - // Find the common superclasses. - superClasses1.retainAll(superClasses2); - - if (DEBUG) - { - System.out.println(" Common super classes: "+superClasses1); - } - - if (interfaces && superClasses1.isEmpty()) - { - return null; - } - - // Find a class that is a subclass of all common superclasses, - // or that at least has the maximum number of common superclasses. - Clazz commonClass = null; - - int maximumSuperClassCount = -1; - - // Go over all common superclasses to find it. In case of - // multiple subclasses, keep the lowest one alphabetically, - // in order to ensure that the choice is deterministic. - Iterator commonSuperClasses = superClasses1.iterator(); - while (commonSuperClasses.hasNext()) - { - Clazz commonSuperClass = (Clazz)commonSuperClasses.next(); - - int superClassCount = superClassCount(commonSuperClass, superClasses1); - if (maximumSuperClassCount < superClassCount || - (maximumSuperClassCount == superClassCount && - commonClass != null && - commonClass.getName().compareTo(commonSuperClass.getName()) > 0)) - { - commonClass = commonSuperClass; - maximumSuperClassCount = superClassCount; - } - } - - if (commonClass == null) - { - throw new IllegalArgumentException("Can't find common super class of ["+ - class1.getName() +"] (with "+superClasses1Count +" known super classes) and ["+ - class2.getName()+"] (with "+superClasses2Count+" known super classes)"); - } - - if (DEBUG) - { - System.out.println(" Best common class: ["+commonClass.getName()+"]"); - } - - return commonClass; - } - - - /** - * Returns the given reference value that may or may not be null, ensuring - * that it is a TypedReferenceValue, not a subclass. - */ - private static ReferenceValue typedReferenceValue(TypedReferenceValue referenceValue, - boolean mayBeNull) - { - return referenceValue.getClass() == TypedReferenceValue.class ? - referenceValue.generalizeMayBeNull(mayBeNull) : - new TypedReferenceValue(referenceValue.type, - referenceValue.referencedClass, - mayBeNull); - } - - - /** - * Returns if the number of superclasses of the given class in the given - * set of classes. - */ - private int superClassCount(Clazz subClass, Set classes) - { - int count = 0; - - Iterator iterator = classes.iterator(); - - while (iterator.hasNext()) - { - Clazz clazz = (Clazz)iterator.next(); - if (subClass.extendsOrImplements(clazz)) - { - count++; - } - } - - return count; - } - - - public int equal(TypedReferenceValue other) - { - return this.type == null && other.type == null ? ALWAYS : MAYBE; - } - - - // Implementations of binary ReferenceValue methods with - // IdentifiedReferenceValue arguments. - - public ReferenceValue generalize(IdentifiedReferenceValue other) - { - return generalize((TypedReferenceValue)other); - } - - - public int equal(IdentifiedReferenceValue other) - { - return equal((TypedReferenceValue)other); - } - - - // Implementations of binary ReferenceValue methods with - // ArrayReferenceValue arguments. - - public ReferenceValue generalize(ArrayReferenceValue other) - { - return generalize((TypedReferenceValue)other); - } - - - public int equal(ArrayReferenceValue other) - { - return equal((TypedReferenceValue)other); - } - - - // Implementations of binary ReferenceValue methods with - // IdentifiedArrayReferenceValue arguments. - - public ReferenceValue generalize(IdentifiedArrayReferenceValue other) - { - return generalize((ArrayReferenceValue)other); - } - - - public int equal(IdentifiedArrayReferenceValue other) - { - return equal((ArrayReferenceValue)other); - } - - - // Implementations of binary ReferenceValue methods with - // DetailedArrayReferenceValue arguments. - - public ReferenceValue generalize(DetailedArrayReferenceValue other) - { - return generalize((IdentifiedArrayReferenceValue)other); - } - - - public int equal(DetailedArrayReferenceValue other) - { - return equal((IdentifiedArrayReferenceValue)other); - } - - - // Implementations for Value. - - public boolean isParticular() - { - return type == null; - } - - - public final String internalType() - { - return - type == null ? ClassConstants.TYPE_JAVA_LANG_OBJECT : - ClassUtil.isInternalArrayType(type) ? type : - ClassConstants.TYPE_CLASS_START + - type + - ClassConstants.TYPE_CLASS_END; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - if (this == object) - { - return true; - } - - if (object == null || - this.getClass() != object.getClass()) - { - return false; - } - - TypedReferenceValue other = (TypedReferenceValue)object; - return this.type == null ? other.type == null : - (this.mayBeNull == other.mayBeNull && - this.type.equals(other.type)); - } - - - public int hashCode() - { - return this.getClass().hashCode() ^ - (type == null ? 0 : type.hashCode() ^ (mayBeNull ? 0 : 1)); - } - - - public String toString() - { - return type == null ? - "null" : - type + (referencedClass == null ? "?" : "") + (mayBeNull ? "" : "!"); - } -} diff --git a/src/proguard/evaluation/value/UnknownDoubleValue.java b/src/proguard/evaluation/value/UnknownDoubleValue.java deleted file mode 100644 index ad2f511..0000000 --- a/src/proguard/evaluation/value/UnknownDoubleValue.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This class represents a partially evaluated double value. - * - * @author Eric Lafortune - */ -public class UnknownDoubleValue extends DoubleValue -{ - // Basic unary methods. - - public DoubleValue negate() - { - return this; - } - - public IntegerValue convertToInteger() - { - return ValueFactory.INTEGER_VALUE; - } - - public LongValue convertToLong() - { - return ValueFactory.LONG_VALUE; - } - - public FloatValue convertToFloat() - { - return ValueFactory.FLOAT_VALUE; - } - - - // Basic binary methods. - - public DoubleValue generalize(DoubleValue other) - { - return this; - } - - public DoubleValue add(DoubleValue other) - { - return this; - } - - public DoubleValue subtract(DoubleValue other) - { - return this; - } - - public DoubleValue subtractFrom(DoubleValue other) - { - return this; - } - - public DoubleValue multiply(DoubleValue other) - { - return this; - } - - public DoubleValue divide(DoubleValue other) - { - return this; - } - - public DoubleValue divideOf(DoubleValue other) - { - return this; - } - - public DoubleValue remainder(DoubleValue other) - { - return this; - } - - public DoubleValue remainderOf(DoubleValue other) - { - return this; - } - - public IntegerValue compare(DoubleValue other) - { - return ValueFactory.INTEGER_VALUE; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } - - - public String toString() - { - return "d"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/UnknownFloatValue.java b/src/proguard/evaluation/value/UnknownFloatValue.java deleted file mode 100644 index f6f2047..0000000 --- a/src/proguard/evaluation/value/UnknownFloatValue.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This class represents a partially evaluated float value. - * - * @author Eric Lafortune - */ -public class UnknownFloatValue extends FloatValue -{ - // Basic unary methods. - - public FloatValue negate() - { - return this; - } - - public IntegerValue convertToInteger() - { - return ValueFactory.INTEGER_VALUE; - } - - public LongValue convertToLong() - { - return ValueFactory.LONG_VALUE; - } - - public DoubleValue convertToDouble() - { - return ValueFactory.DOUBLE_VALUE; - } - - - // Basic binary methods. - - public FloatValue generalize(FloatValue other) - { - return this; - } - - public FloatValue add(FloatValue other) - { - return this; - } - - public FloatValue subtract(FloatValue other) - { - return this; - } - - public FloatValue subtractFrom(FloatValue other) - { - return this; - } - - public FloatValue multiply(FloatValue other) - { - return this; - } - - public FloatValue divide(FloatValue other) - { - return this; - } - - public FloatValue divideOf(FloatValue other) - { - return this; - } - - public FloatValue remainder(FloatValue other) - { - return this; - } - - public FloatValue remainderOf(FloatValue other) - { - return this; - } - - public IntegerValue compare(FloatValue other) - { - return ValueFactory.INTEGER_VALUE; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } - - - public String toString() - { - return "f"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/UnknownIntegerValue.java b/src/proguard/evaluation/value/UnknownIntegerValue.java deleted file mode 100644 index 5c05721..0000000 --- a/src/proguard/evaluation/value/UnknownIntegerValue.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This class represents a partially evaluated integer value. - * - * @author Eric Lafortune - */ -public class UnknownIntegerValue extends IntegerValue -{ - // Basic unary methods. - - public IntegerValue negate() - { - return this; - } - - public IntegerValue convertToByte() - { - return this; - } - - public IntegerValue convertToCharacter() - { - return this; - } - - public IntegerValue convertToShort() - { - return this; - } - - public LongValue convertToLong() - { - return ValueFactory.LONG_VALUE; - } - - public FloatValue convertToFloat() - { - return ValueFactory.FLOAT_VALUE; - } - - public DoubleValue convertToDouble() - { - return ValueFactory.DOUBLE_VALUE; - } - - - // Basic binary methods. - - public IntegerValue generalize(IntegerValue other) - { - return this; - } - - - public IntegerValue add(IntegerValue other) - { - return this; - } - - public IntegerValue subtract(IntegerValue other) - { - return this; - } - - public IntegerValue subtractFrom(IntegerValue other) - { - return this; - } - - public IntegerValue multiply(IntegerValue other) - throws ArithmeticException - { - return this; - } - - public IntegerValue divide(IntegerValue other) - throws ArithmeticException - { - return this; - } - - public IntegerValue divideOf(IntegerValue other) - throws ArithmeticException - { - return this; - } - - public IntegerValue remainder(IntegerValue other) - throws ArithmeticException - { - return this; - } - - public IntegerValue remainderOf(IntegerValue other) - throws ArithmeticException - { - return this; - } - - public IntegerValue shiftLeft(IntegerValue other) - { - return this; - } - - public IntegerValue shiftLeftOf(IntegerValue other) - { - return this; - } - - public IntegerValue shiftRight(IntegerValue other) - { - return this; - } - - public IntegerValue shiftRightOf(IntegerValue other) - { - return this; - } - - public IntegerValue unsignedShiftRight(IntegerValue other) - { - return this; - } - - public IntegerValue unsignedShiftRightOf(IntegerValue other) - { - return this; - } - - public LongValue shiftLeftOf(LongValue other) - { - return ValueFactory.LONG_VALUE; - } - - public LongValue shiftRightOf(LongValue other) - { - return ValueFactory.LONG_VALUE; - } - - public LongValue unsignedShiftRightOf(LongValue other) - { - return ValueFactory.LONG_VALUE; - } - - public IntegerValue and(IntegerValue other) - { - return this; - } - - public IntegerValue or(IntegerValue other) - { - return this; - } - - public IntegerValue xor(IntegerValue other) - { - return this; - } - - public int equal(IntegerValue other) - { - return MAYBE; - } - - public int lessThan(IntegerValue other) - { - return MAYBE; - } - - public int lessThanOrEqual(IntegerValue other) - { - return MAYBE; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } - - - public String toString() - { - return "i"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/UnknownLongValue.java b/src/proguard/evaluation/value/UnknownLongValue.java deleted file mode 100644 index ced2d1f..0000000 --- a/src/proguard/evaluation/value/UnknownLongValue.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This class represents a partially evaluated long value. - * - * @author Eric Lafortune - */ -public class UnknownLongValue extends LongValue -{ - // Basic unary methods. - - public LongValue negate() - { - return this; - } - - public IntegerValue convertToInteger() - { - return ValueFactory.INTEGER_VALUE; - } - - public FloatValue convertToFloat() - { - return ValueFactory.FLOAT_VALUE; - } - - public DoubleValue convertToDouble() - { - return ValueFactory.DOUBLE_VALUE; - } - - - // Basic binary methods. - - public LongValue generalize(LongValue other) - { - return this; - } - - public LongValue add(LongValue other) - { - return this; - } - - public LongValue subtract(LongValue other) - { - return this; - } - - public LongValue subtractFrom(LongValue other) - { - return this; - } - - public LongValue multiply(LongValue other) - throws ArithmeticException - { - return this; - } - - public LongValue divide(LongValue other) - throws ArithmeticException - { - return this; - } - - public LongValue divideOf(LongValue other) - throws ArithmeticException - { - return this; - } - - public LongValue remainder(LongValue other) - throws ArithmeticException - { - return this; - } - - public LongValue remainderOf(LongValue other) - throws ArithmeticException - { - return this; - } - - public LongValue shiftLeft(IntegerValue other) - { - return this; - } - - public LongValue shiftRight(IntegerValue other) - { - return this; - } - - public LongValue unsignedShiftRight(IntegerValue other) - { - return this; - } - - public LongValue and(LongValue other) - { - return this; - } - - public LongValue or(LongValue other) - { - return this; - } - - public LongValue xor(LongValue other) - { - return this; - } - - public IntegerValue compare(LongValue other) - { - return ValueFactory.INTEGER_VALUE; - } - - - // Implementations for Object. - - public boolean equals(Object object) - { - return object != null && - this.getClass() == object.getClass(); - } - - - public int hashCode() - { - return this.getClass().hashCode(); - } - - - public String toString() - { - return "l"; - } -}
\ No newline at end of file diff --git a/src/proguard/evaluation/value/Value.java b/src/proguard/evaluation/value/Value.java deleted file mode 100644 index 5cfd02c..0000000 --- a/src/proguard/evaluation/value/Value.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -/** - * This abstract class represents a partially evaluated value. - * - * @author Eric Lafortune - */ -public abstract class Value -{ - public static final int NEVER = -1; - public static final int MAYBE = 0; - public static final int ALWAYS = 1; - - public static final int TYPE_INTEGER = 1; - public static final int TYPE_LONG = 2; - public static final int TYPE_FLOAT = 3; - public static final int TYPE_DOUBLE = 4; - public static final int TYPE_REFERENCE = 5; - public static final int TYPE_INSTRUCTION_OFFSET = 6; - public static final int TYPE_TOP = 7; - - - /** - * Returns this Value as a Category1Value. - */ - public Category1Value category1Value() - { - throw new IllegalArgumentException("Value \"" + this.toString() + "\" is not a Category 1 value [" + this.getClass().getName() + "]"); - } - - /** - * Returns this Value as a Category2Value. - */ - public Category2Value category2Value() - { - throw new IllegalArgumentException("Value \"" + this.toString() + "\" is not a Category 2 value [" + this.getClass().getName() + "]"); - } - - - /** - * Returns this Value as an IntegerValue. - */ - public IntegerValue integerValue() - { - throw new IllegalArgumentException("Value \"" + this.toString() + "\" is not an integer value [" + this.getClass().getName() + "]"); - } - - /** - * Returns this Value as a LongValue. - */ - public LongValue longValue() - { - throw new IllegalArgumentException("Value \"" + this.toString() + "\" is not a long value [" + this.getClass().getName() + "]"); - } - - /** - * Returns this Value as a FloatValue. - */ - public FloatValue floatValue() - { - throw new IllegalArgumentException("Value \"" + this.toString() + "\" is not a float value [" + this.getClass().getName() + "]"); - } - - /** - * Returns this Value as a DoubleValue. - */ - public DoubleValue doubleValue() - { - throw new IllegalArgumentException("Value \"" + this.toString() + "\" is not a double value [" + this.getClass().getName() + "]"); - } - - /** - * Returns this Value as a ReferenceValue. - */ - public ReferenceValue referenceValue() - { - throw new IllegalArgumentException("Value \"" + this.toString() + "\" is not a reference value [" + this.getClass().getName() + "]"); - } - - /** - * Returns this Value as an InstructionOffsetValue. - */ - public InstructionOffsetValue instructionOffsetValue() - { - throw new IllegalArgumentException("Value \"" + this.toString() + "\" is not an instruction offset value [" + this.getClass().getName() + "]"); - } - - - /** - * Returns whether this Value represents a single specific (but possibly - * unknown) value. - */ - public boolean isSpecific() - { - return false; - } - - - /** - * Returns whether this Value represents a single particular (known) - * value. - */ - public boolean isParticular() - { - return false; - } - - - /** - * Returns the generalization of this Value and the given other Value. - */ - public abstract Value generalize(Value other); - - - /** - * Returns whether the computational type of this Value is a category 2 type. - * This means that it takes up the space of two category 1 types on the - * stack, for instance. - */ - public abstract boolean isCategory2(); - - - /** - * Returns the computational type of this Value. - * @return <code>TYPE_INTEGER</code>, - * <code>TYPE_LONG</code>, - * <code>TYPE_FLOAT</code>, - * <code>TYPE_DOUBLE</code>, - * <code>TYPE_REFERENCE</code>, or - * <code>TYPE_INSTRUCTION_OFFSET</code>. - */ - public abstract int computationalType(); - - - /** - * Returns the internal type of this Value. - * @return <code>ClassConstants.TYPE_BOOLEAN</code>, - * <code>ClassConstants.TYPE_BYTE</code>, - * <code>ClassConstants.TYPE_CHAR</code>, - * <code>ClassConstants.TYPE_SHORT</code>, - * <code>ClassConstants.TYPE_INT</code>, - * <code>ClassConstants.TYPE_LONG</code>, - * <code>ClassConstants.TYPE_FLOAT</code>, - * <code>ClassConstants.TYPE_DOUBLE</code>, - * <code>ClassConstants.TYPE_CLASS_START ... ClassConstants.TYPE_CLASS_END</code>, or - * an array type containing any of these types (always as String). - */ - public abstract String internalType(); -} diff --git a/src/proguard/evaluation/value/ValueFactory.java b/src/proguard/evaluation/value/ValueFactory.java deleted file mode 100644 index cb9e657..0000000 --- a/src/proguard/evaluation/value/ValueFactory.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * ProGuard -- shrinking, optimization, obfuscation, and preverification - * of Java bytecode. - * - * Copyright (c) 2002-2014 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.value; - -import proguard.classfile.*; -import proguard.classfile.util.ClassUtil; - -/** - * This class provides methods to create and reuse Value objects. - * - * @author Eric Lafortune - */ -public class ValueFactory -{ - // Shared copies of Value objects, to avoid creating a lot of objects. - static final IntegerValue INTEGER_VALUE = new UnknownIntegerValue(); - static final LongValue LONG_VALUE = new UnknownLongValue(); - static final FloatValue FLOAT_VALUE = new UnknownFloatValue(); - static final DoubleValue DOUBLE_VALUE = new UnknownDoubleValue(); - - static final ReferenceValue REFERENCE_VALUE_NULL = new TypedReferenceValue(null, null, true); - static final ReferenceValue REFERENCE_VALUE_JAVA_LANG_OBJECT_MAYBE_NULL = new TypedReferenceValue(ClassConstants.NAME_JAVA_LANG_OBJECT, null, true); - static final ReferenceValue REFERENCE_VALUE_JAVA_LANG_OBJECT_NOT_NULL = new TypedReferenceValue(ClassConstants.NAME_JAVA_LANG_OBJECT, null, false); - - - /** - * Creates a new Value of the given type. - * The type must be a fully specified internal type for primitives, classes, - * or arrays. - */ - public Value createValue(String type, Clazz referencedClass, boolean mayBeNull) - { - switch (type.charAt(0)) - { - case ClassConstants.TYPE_VOID: return null; - case ClassConstants.TYPE_BOOLEAN: - case ClassConstants.TYPE_BYTE: - case ClassConstants.TYPE_CHAR: - case ClassConstants.TYPE_SHORT: - case ClassConstants.TYPE_INT: return createIntegerValue(); - case ClassConstants.TYPE_LONG: return createLongValue(); - case ClassConstants.TYPE_FLOAT: return createFloatValue(); - case ClassConstants.TYPE_DOUBLE: return createDoubleValue(); - default: return createReferenceValue(ClassUtil.isInternalArrayType(type) ? - type : - ClassUtil.internalClassNameFromClassType(type), - referencedClass, - mayBeNull); - } - } - - /** - * Creates a new IntegerValue with an undefined value. - */ - public IntegerValue createIntegerValue() - { - return INTEGER_VALUE; - } - - /** - * Creates a new IntegerValue with a given particular value. - */ - public IntegerValue createIntegerValue(int value) - { - return createIntegerValue(); - } - - - /** - * Creates a new LongValue with an undefined value. - */ - public LongValue createLongValue() - { - return LONG_VALUE; - } - - /** - * Creates a new LongValue with a given particular value. - */ - public LongValue createLongValue(long value) - { - return createLongValue(); - } - - - /** - * Creates a new FloatValue with an undefined value. - */ - public FloatValue createFloatValue() - { - return FLOAT_VALUE; - } - - /** - * Creates a new FloatValue with a given particular value. - */ - public FloatValue createFloatValue(float value) - { - return createFloatValue(); - } - - - /** - * Creates a new DoubleValue with an undefined value. - */ - public DoubleValue createDoubleValue() - { - return DOUBLE_VALUE; - } - - /** - * Creates a new DoubleValue with a given particular value. - */ - public DoubleValue createDoubleValue(double value) - { - return createDoubleValue(); - } - - - /** - * Creates a new ReferenceValue that represents <code>null</code>. - */ - public ReferenceValue createReferenceValueNull() - { - return REFERENCE_VALUE_NULL; - } - - - /** - * Creates a new ReferenceValue of the given type. The type must be an - * internal class name or an array type. If the type is <code>null</code>, - * the ReferenceValue represents <code>null</code>. - */ - public ReferenceValue createReferenceValue(String type, - Clazz referencedClass, - boolean mayBeNull) - { - return type == null ? REFERENCE_VALUE_NULL : - !type.equals(ClassConstants.NAME_JAVA_LANG_OBJECT) ? new TypedReferenceValue(type, referencedClass, mayBeNull) : - mayBeNull ? REFERENCE_VALUE_JAVA_LANG_OBJECT_MAYBE_NULL : - REFERENCE_VALUE_JAVA_LANG_OBJECT_NOT_NULL; - } - - - /** - * Creates a new ReferenceValue for arrays of the given type and length. - * The type must be a fully specified internal type for primitives, classes, - * or arrays. - */ - public ReferenceValue createArrayReferenceValue(String type, - Clazz referencedClass, - IntegerValue arrayLength) - { - return createReferenceValue(ClassConstants.TYPE_ARRAY + type, - referencedClass, - false); - } -} diff --git a/src/proguard/evaluation/value/package.html b/src/proguard/evaluation/value/package.html deleted file mode 100644 index 71e1b13..0000000 --- a/src/proguard/evaluation/value/package.html +++ /dev/null @@ -1,3 +0,0 @@ -<body> -This package contains classes that represent partial evaluation values. -</body> |