Java Code Examples for proguard.evaluation.value.Value#TYPE_REFERENCE
The following examples show how to use
proguard.evaluation.value.Value#TYPE_REFERENCE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemberDescriptorSpecializer.java From proguard with GNU General Public License v2.0 | 6 votes |
public void visitProgramField(ProgramClass programClass, ProgramField programField) { Value parameterValue = StoringInvocationUnit.getFieldValue(programField); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programField.referencedClass != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass)); System.out.println(" "+programField.referencedClass.getName()+" -> "+referencedClass.getName()); } programField.referencedClass = referencedClass; // Visit the field, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramField(programClass, programField); } } } }
Example 2
Source File: MemberDescriptorSpecializer.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitProgramField(ProgramClass programClass, ProgramField programField) { Value parameterValue = StoringInvocationUnit.getFieldValue(programField); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programField.referencedClass != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass)); System.out.println(" "+programField.referencedClass.getName()+" -> "+referencedClass.getName()); } programField.referencedClass = referencedClass; // Visit the field, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramField(programClass, programField); } } } }
Example 3
Source File: MemberDescriptorSpecializer.java From proguard with GNU General Public License v2.0 | 6 votes |
public void visitProgramField(ProgramClass programClass, ProgramField programField) { Value parameterValue = StoringInvocationUnit.getFieldValue(programField); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programField.referencedClass != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass)); System.out.println(" "+programField.referencedClass.getName()+" -> "+referencedClass.getName()); } programField.referencedClass = referencedClass; // Visit the field, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramField(programClass, programField); } } } }
Example 4
Source File: MemberDescriptorSpecializer.java From bazel with Apache License 2.0 | 6 votes |
public void visitProgramField(ProgramClass programClass, ProgramField programField) { Value parameterValue = StoringInvocationUnit.getFieldValue(programField); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programField.referencedClass != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass)); System.out.println(" "+programField.referencedClass.getName()+" -> "+referencedClass.getName()); } programField.referencedClass = referencedClass; // Visit the field, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramField(programClass, programField); } } } }
Example 5
Source File: EvaluationShrinker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Returns the opcode of a push instruction corresponding to the given * computational type. * @param computationalType the computational type to be pushed on the stack. */ private byte pushOpcode(int computationalType) { switch (computationalType) { case Value.TYPE_INTEGER: return InstructionConstants.OP_ICONST_0; case Value.TYPE_LONG: return InstructionConstants.OP_LCONST_0; case Value.TYPE_FLOAT: return InstructionConstants.OP_FCONST_0; case Value.TYPE_DOUBLE: return InstructionConstants.OP_DCONST_0; case Value.TYPE_REFERENCE: case Value.TYPE_INSTRUCTION_OFFSET: return InstructionConstants.OP_ACONST_NULL; } throw new IllegalArgumentException("No push opcode for computational type ["+computationalType+"]"); }
Example 6
Source File: EvaluationSimplifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Replaces the push instruction at the given offset by a simpler push * instruction, if possible. */ private void replaceAnyPushInstruction(Clazz clazz, int offset, Instruction instruction) { Value pushedValue = partialEvaluator.getStackAfter(offset).getTop(0); if (pushedValue.isParticular()) { switch (pushedValue.computationalType()) { case Value.TYPE_INTEGER: replaceIntegerPushInstruction(clazz, offset, instruction); break; case Value.TYPE_LONG: replaceLongPushInstruction(clazz, offset, instruction); break; case Value.TYPE_FLOAT: replaceFloatPushInstruction(clazz, offset, instruction); break; case Value.TYPE_DOUBLE: replaceDoublePushInstruction(clazz, offset, instruction); break; case Value.TYPE_REFERENCE: replaceReferencePushInstruction(clazz, offset, instruction); break; } } }
Example 7
Source File: MemberDescriptorSpecializer.java From proguard with GNU General Public License v2.0 | 4 votes |
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) { // All parameters of non-static methods are shifted by one in the local // variable frame. boolean isStatic = (programMethod.getAccessFlags() & AccessConstants.STATIC) != 0; int parameterStart = isStatic ? 0 : 1; int parameterCount = ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass), isStatic); int classIndex = 0; // Go over the parameters. for (int parameterIndex = parameterStart; parameterIndex < parameterCount; parameterIndex++) { Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programMethod.referencedClasses[classIndex] != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass)); System.out.println(" "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName()); } programMethod.referencedClasses[classIndex] = referencedClass; // Visit the method, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramMethod(programClass, programMethod); } } classIndex++; } } }
Example 8
Source File: CodePreverifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Creates and returns the verification type corresponding to the given * value. If necessary, a class constant is added to the constant pool of * the given class. */ private VerificationType correspondingVerificationType(ProgramClass programClass, ProgramMethod programMethod, CodeAttribute codeAttribute, int offset, boolean isVariable0, Value value, Value producerValue) { if (value == null) { return VerificationTypeFactory.createTopType(); } int type = value.computationalType(); switch (type) { case Value.TYPE_INSTRUCTION_OFFSET: case Value.TYPE_INTEGER: return VerificationTypeFactory.createIntegerType(); case Value.TYPE_LONG: return VerificationTypeFactory.createLongType(); case Value.TYPE_FLOAT: return VerificationTypeFactory.createFloatType(); case Value.TYPE_DOUBLE: return VerificationTypeFactory.createDoubleType(); case Value.TYPE_TOP: return VerificationTypeFactory.createTopType(); case Value.TYPE_REFERENCE: // Is it a Null type? ReferenceValue referenceValue = value.referenceValue(); if (referenceValue.isNull() == Value.ALWAYS) { return VerificationTypeFactory.createNullType(); } // Does the reference type have a single producer? if (offset != PartialEvaluator.AT_METHOD_ENTRY) { InstructionOffsetValue producers = producerValue.instructionOffsetValue(); if (producers.instructionOffsetCount() == 1) { int producerOffset = producers.instructionOffset(0); // Follow any dup or swap instructions. while (producerOffset != PartialEvaluator.AT_METHOD_ENTRY && isDupOrSwap(codeAttribute.code[producerOffset])) { producers = partialEvaluator.getStackBefore(producerOffset).getTopProducerValue(0).instructionOffsetValue(); producerOffset = producers.instructionOffset(0); } // Are we in an instance initialization method, // before the super initialization, loading "this"? if (partialEvaluator.isInitializer() && offset <= partialEvaluator.superInitializationOffset() && (isVariable0 || producerOffset > PartialEvaluator.AT_METHOD_ENTRY && codeAttribute.code[producerOffset] == InstructionConstants.OP_ALOAD_0)) { // It's an UninitializedThis type. return VerificationTypeFactory.createUninitializedThisType(); } // Is the reference type newly created and still // uninitialized? if (producerOffset > PartialEvaluator.AT_METHOD_ENTRY && offset <= partialEvaluator.initializationOffset(producerOffset)) { // It's an Uninitialized type. return VerificationTypeFactory.createUninitializedType(producerOffset); } } } // It's an ordinary Object type. return VerificationTypeFactory.createObjectType(createClassConstant(programClass, referenceValue)); } throw new IllegalArgumentException("Unknown computational type ["+type+"]"); }
Example 9
Source File: MemberDescriptorSpecializer.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) { // All parameters of non-static methods are shifted by one in the local // variable frame. int firstParameterIndex = (programMethod.getAccessFlags() & ClassConstants.INTERNAL_ACC_STATIC) != 0 ? 0 : 1; int parameterCount = ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass)); int classIndex = 0; // Go over the parameters. for (int parameterIndex = firstParameterIndex; parameterIndex < parameterCount; parameterIndex++) { Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programMethod.referencedClasses[classIndex] != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass)); System.out.println(" "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName()); } programMethod.referencedClasses[classIndex] = referencedClass; // Visit the method, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramMethod(programClass, programMethod); } } classIndex++; } } }
Example 10
Source File: MemberDescriptorSpecializer.java From proguard with GNU General Public License v2.0 | 4 votes |
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) { // All parameters of non-static methods are shifted by one in the local // variable frame. int firstParameterIndex = (programMethod.getAccessFlags() & ClassConstants.ACC_STATIC) != 0 ? 0 : 1; int parameterCount = ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass)); int classIndex = 0; // Go over the parameters. for (int parameterIndex = firstParameterIndex; parameterIndex < parameterCount; parameterIndex++) { Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programMethod.referencedClasses[classIndex] != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass)); System.out.println(" "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName()); } programMethod.referencedClasses[classIndex] = referencedClass; // Visit the method, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramMethod(programClass, programMethod); } } classIndex++; } } }
Example 11
Source File: MemberDescriptorSpecializer.java From bazel with Apache License 2.0 | 4 votes |
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) { // All parameters of non-static methods are shifted by one in the local // variable frame. int firstParameterIndex = (programMethod.getAccessFlags() & ClassConstants.ACC_STATIC) != 0 ? 0 : 1; int parameterCount = ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass)); int classIndex = 0; // Go over the parameters. for (int parameterIndex = firstParameterIndex; parameterIndex < parameterCount; parameterIndex++) { Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programMethod.referencedClasses[classIndex] != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass)); System.out.println(" "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName()); } programMethod.referencedClasses[classIndex] = referencedClass; // Visit the method, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramMethod(programClass, programMethod); } } classIndex++; } } }