Java Code Examples for proguard.evaluation.value.Value#isSpecific()
The following examples show how to use
proguard.evaluation.value.Value#isSpecific() .
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: EvaluationSimplifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Replaces the integer pushing instruction at the given offset by a simpler * push instruction, if possible. */ private void replaceIntegerPushInstruction(Clazz clazz, int offset, Instruction instruction, int maxVariableIndex) { Value pushedValue = partialEvaluator.getStackAfter(offset).getTop(0); if (pushedValue.isParticular()) { int value = pushedValue.integerValue().value(); if (value << 16 >> 16 == value) { replaceConstantPushInstruction(clazz, offset, instruction, InstructionConstants.OP_SIPUSH, value); } else { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor((ProgramClass)clazz); Instruction replacementInstruction = new ConstantInstruction(InstructionConstants.OP_LDC, constantPoolEditor.addIntegerConstant(value)).shrink(); replaceInstruction(clazz, offset, instruction, replacementInstruction); } } else if (pushedValue.isSpecific()) { TracedVariables variables = partialEvaluator.getVariablesBefore(offset); for (int variableIndex = 0; variableIndex < maxVariableIndex; variableIndex++) { if (pushedValue.equals(variables.load(variableIndex))) { replaceVariablePushInstruction(clazz, offset, instruction, InstructionConstants.OP_ILOAD, variableIndex); } } } }
Example 2
Source File: EvaluationSimplifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Replaces the long pushing instruction at the given offset by a simpler * push instruction, if possible. */ private void replaceLongPushInstruction(Clazz clazz, int offset, Instruction instruction, int maxVariableIndex) { Value pushedValue = partialEvaluator.getStackAfter(offset).getTop(0); if (pushedValue.isParticular()) { long value = pushedValue.longValue().value(); if (value == 0L || value == 1L) { replaceConstantPushInstruction(clazz, offset, instruction, InstructionConstants.OP_LCONST_0, (int)value); } else { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor((ProgramClass)clazz); Instruction replacementInstruction = new ConstantInstruction(InstructionConstants.OP_LDC2_W, constantPoolEditor.addLongConstant(value)).shrink(); replaceInstruction(clazz, offset, instruction, replacementInstruction); } } else if (pushedValue.isSpecific()) { TracedVariables variables = partialEvaluator.getVariablesBefore(offset); for (int variableIndex = 0; variableIndex < maxVariableIndex; variableIndex++) { if (pushedValue.equals(variables.load(variableIndex))) { replaceVariablePushInstruction(clazz, offset, instruction, InstructionConstants.OP_LLOAD, variableIndex); } } } }
Example 3
Source File: EvaluationSimplifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Replaces the float pushing instruction at the given offset by a simpler * push instruction, if possible. */ private void replaceFloatPushInstruction(Clazz clazz, int offset, Instruction instruction, int maxVariableIndex) { Value pushedValue = partialEvaluator.getStackAfter(offset).getTop(0); if (pushedValue.isParticular()) { // Make sure to distinguish between +0.0 and -0.0. float value = pushedValue.floatValue().value(); if (value == 0.0f && Float.floatToIntBits(value) == POS_ZERO_FLOAT_BITS || value == 1.0f || value == 2.0f) { replaceConstantPushInstruction(clazz, offset, instruction, InstructionConstants.OP_FCONST_0, (int)value); } else { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor((ProgramClass)clazz); Instruction replacementInstruction = new ConstantInstruction(InstructionConstants.OP_LDC, constantPoolEditor.addFloatConstant(value)).shrink(); replaceInstruction(clazz, offset, instruction, replacementInstruction); } } else if (pushedValue.isSpecific()) { TracedVariables variables = partialEvaluator.getVariablesBefore(offset); for (int variableIndex = 0; variableIndex < maxVariableIndex; variableIndex++) { if (pushedValue.equals(variables.load(variableIndex))) { replaceVariablePushInstruction(clazz, offset, instruction, InstructionConstants.OP_FLOAD, variableIndex); } } } }
Example 4
Source File: EvaluationSimplifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Replaces the double pushing instruction at the given offset by a simpler * push instruction, if possible. */ private void replaceDoublePushInstruction(Clazz clazz, int offset, Instruction instruction, int maxVariableIndex) { Value pushedValue = partialEvaluator.getStackAfter(offset).getTop(0); if (pushedValue.isParticular()) { // Make sure to distinguish between +0.0 and -0.0. double value = pushedValue.doubleValue().value(); if (value == 0.0 && Double.doubleToLongBits(value) == POS_ZERO_DOUBLE_BITS || value == 1.0) { replaceConstantPushInstruction(clazz, offset, instruction, InstructionConstants.OP_DCONST_0, (int)value); } else { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor((ProgramClass)clazz); Instruction replacementInstruction = new ConstantInstruction(InstructionConstants.OP_LDC2_W, constantPoolEditor.addDoubleConstant(value)).shrink(); replaceInstruction(clazz, offset, instruction, replacementInstruction); } } else if (pushedValue.isSpecific()) { TracedVariables variables = partialEvaluator.getVariablesBefore(offset); for (int variableIndex = 0; variableIndex < maxVariableIndex; variableIndex++) { if (pushedValue.equals(variables.load(variableIndex))) { replaceVariablePushInstruction(clazz, offset, instruction, InstructionConstants.OP_DLOAD, variableIndex); } } } }