new InstructionSequenceReplacer(patternConstants, instructionSequencePair[PATTERN_INDEX], instructionSequencePair[REPLACEMENT_INDEX],
/** * Returns the value of the specified matched branch offset. */ protected int matchedBranchOffset(int offset, int branchOffset) { // Special case: is it a label? if (isLabel(branchOffset)) { // Then make sure we reference a unique label, because // there may be other matching sequences. return uniqueLabel(branchOffset); } // Otherwise, just return the matched branch offset. return instructionSequenceMatcher.matchedBranchOffset(offset, branchOffset); }
return Boolean.toString((wasConstant(argument) ? ((IntegerConstant)matchedConstant(programClass, argument)).getValue() : matchedArgument(argument)) != 0); return Character.toString((char)(wasConstant(argument) ? ((IntegerConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument))); return Integer.toString(wasConstant(argument) ? ((IntegerConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument)); return Long.toString(wasConstant(argument) ? ((LongConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument)); return Float.toString(wasConstant(argument) ? ((FloatConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument)); return Double.toString(wasConstant(argument) ? ((DoubleConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument));
public void visitLookUpSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LookUpSwitchInstruction lookUpSwitchInstruction) { replacementInstruction = new LookUpSwitchInstruction(lookUpSwitchInstruction.opcode, matchedBranchOffset(offset, lookUpSwitchInstruction.defaultOffset), instructionSequenceMatcher.matchedArguments(lookUpSwitchInstruction.cases), matchedJumpOffsets(offset, lookUpSwitchInstruction.jumpOffsets)); }
/** * Returns the matched argument for the given pattern argument. */ protected int matchedArgument(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int argument) { return matchedArgument(clazz, argument); }
final int DOUBLE_VALUE = constantPoolEditor.addConstant(new MethodrefConstant(X, constantPoolEditor.addNameAndTypeConstant("doubleValue", "()D"), null, null)); final InstructionSequenceReplacer.Label TRY_START = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label TRY_END = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label CATCH_END = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label CATCH_EXCEPTION = InstructionSequenceReplacer.catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(ClassConstants.NAME_JAVA_LANG_EXCEPTION, null));
public void visitCatchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Catch catch_) { // Convert this pseudo-instruction into a corresponding // pseudo-instruction for the code attribute editor. // Then make sure we create and reference unique labels, // because there may be other matching sequences. replacementInstruction = codeAttributeEditor.catch_(uniqueLabel(catch_.identifier), uniqueLabel(catch_.startOfffset), uniqueLabel(catch_.endOffset), matchedConstantIndex((ProgramClass)clazz, catch_.catchType)); } }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { replacementInstruction = new BranchInstruction(branchInstruction.opcode, matchedBranchOffset(offset, branchInstruction.branchOffset)); }
argumentAsString(programClass, constantIndex & 0xf, A) + argumentAsString(programClass, (constantIndex >>> 4) & 0xf, B), null, null);
catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_CLASS_NOT_FOUND_EXCEPTION, null)); NO_SUCH_METHOD_EXCEPTION = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_NO_SUCH_METHOD_EXCEPTION, null)); NO_SUCH_FIELD_EXCEPTION = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_NO_SUCH_FIELD_EXCEPTION, null)); IO_EXCEPTION = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_IO_EXCEPTION, null)); RUNTIME_EXCEPTION = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_RUNTIME_EXCEPTION, null)); UNSATISFIED_LINK_ERROR = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_UNSATISFIED_LINK_ERROR, null));
public void visitLookUpSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LookUpSwitchInstruction lookUpSwitchInstruction) { replacementInstruction = new LookUpSwitchInstruction(lookUpSwitchInstruction.opcode, matchedBranchOffset(offset, lookUpSwitchInstruction.defaultOffset), instructionSequenceMatcher.matchedArguments(lookUpSwitchInstruction.cases), matchedJumpOffsets(offset, lookUpSwitchInstruction.jumpOffsets)); }
/** * Returns the matched argument for the given pattern argument. */ protected int matchedArgument(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int argument) { return matchedArgument(clazz, argument); }
final int DOUBLE_VALUE = constantPoolEditor.addConstant(new MethodrefConstant(X, constantPoolEditor.addNameAndTypeConstant("doubleValue", "()D"), null, null)); final InstructionSequenceReplacer.Label TRY_START = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label TRY_END = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label CATCH_END = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label CATCH_EXCEPTION = InstructionSequenceReplacer.catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(ClassConstants.NAME_JAVA_LANG_EXCEPTION, null));
public void visitCatchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Catch catch_) { // Convert this pseudo-instruction into a corresponding // pseudo-instruction for the code attribute editor. // Then make sure we create and reference unique labels, // because there may be other matching sequences. replacementInstruction = codeAttributeEditor.catch_(uniqueLabel(catch_.identifier), uniqueLabel(catch_.startOfffset), uniqueLabel(catch_.endOffset), matchedConstantIndex((ProgramClass)clazz, catch_.catchType)); } }
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) { replacementInstruction = new BranchInstruction(branchInstruction.opcode, matchedBranchOffset(offset, branchInstruction.branchOffset)); }
argumentAsString(programClass, constantIndex & 0xf, A) + argumentAsString(programClass, (constantIndex >>> 4) & 0xf, B), null, null);
catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_CLASS_NOT_FOUND_EXCEPTION, null)); NO_SUCH_METHOD_EXCEPTION = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_NO_SUCH_METHOD_EXCEPTION, null)); NO_SUCH_FIELD_EXCEPTION = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_NO_SUCH_FIELD_EXCEPTION, null)); IO_EXCEPTION = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_IO_EXCEPTION, null)); RUNTIME_EXCEPTION = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_RUNTIME_EXCEPTION, null)); UNSATISFIED_LINK_ERROR = catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant(NAME_UNSATISFIED_LINK_ERROR, null));
return Boolean.toString((wasConstant(argument) ? ((IntegerConstant)matchedConstant(programClass, argument)).getValue() : matchedArgument(argument)) != 0); return Character.toString((char)(wasConstant(argument) ? ((IntegerConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument))); return Integer.toString(wasConstant(argument) ? ((IntegerConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument)); return Long.toString(wasConstant(argument) ? ((LongConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument)); return Float.toString(wasConstant(argument) ? ((FloatConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument)); return Double.toString(wasConstant(argument) ? ((DoubleConstant)(matchedConstant(programClass, argument))).getValue() : matchedArgument(argument));