类 InstructionSequenceMatcher
java.lang.Object
proguard.classfile.util.InstructionSequenceMatcher
- 所有已实现的接口:
ConstantVisitor,InstructionVisitor
public class InstructionSequenceMatcher
extends Object
implements InstructionVisitor, ConstantVisitor
This
InstructionVisitor checks whether a given pattern instruction sequence occurs in the
instructions that are visited. The arguments of the instruction sequence can be wildcards that
are matched.-
字段概要
字段修饰符和类型字段说明static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected booleanstatic final intstatic final intstatic final intprotected Constantprotected final Constant[]protected final Instruction[]static final intstatic final intstatic final intstatic final intstatic final int -
构造器概要
构造器构造器说明InstructionSequenceMatcher(Constant[] patternConstants, Instruction[] patternInstructions) Creates a new InstructionSequenceMatcher.InstructionSequenceMatcher(Constant[] patternConstants, Instruction[] patternInstructions, boolean matchSubclasses) Creates a new InstructionSequenceMatcher. -
方法概要
修饰符和类型方法说明protected booleanfinalMatch(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) Performs a final check on the candidate sequence to match, after the pattern has been successfully fully matched with the sequence.intReturns the number of instructions in the pattern sequence.booleanReturns whether the complete pattern sequence has been matched.static voidSmall sample application that illustrates the use of this class.intmatchedArgument(int argument) Returns the value of the specified matched argument (wildcard or not).int[]matchedArguments(int[] arguments) Returns the values of the specified matched arguments (wildcard or not).intmatchedBranchOffset(int offset, int branchOffset) Returns the value of the specified matched branch offset (wildcard or not).intmatchedConstantIndex(int constantIndex) Returns the index of the specified matched constant (wildcard or not).intmatchedInstructionOffset(int index) Returns the matched instruction offset of the specified pattern instruction.int[]matchedJumpOffsets(int offset, int[] jumpOffsets) Returns the values of the specified matched jump offsets (wildcard or not).protected booleanmatchingArguments(int[] arguments1, int[] arguments2) protected booleanmatchingArguments(int argument1, int argument2) protected booleanmatchingBranchOffsets(int offset, int branchOffset1, int branchOffset2) protected booleanmatchingConstantIndices(Clazz clazz, int constantIndex1, int constantIndex2) protected booleanmatchingJumpOffsets(int offset, int[] jumpOffsets1, int[] jumpOffsets2) protected booleanmatchingOpcodes(Instruction instruction1, Instruction instruction2) voidreset()Starts matching from the first instruction again next time.voidvisitAnyRefConstant(Clazz clazz, RefConstant refConstant) Visits any RefConstant instance.voidvisitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) voidvisitClassConstant(Clazz clazz, ClassConstant classConstant) voidvisitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction) voidvisitDoubleConstant(Clazz clazz, DoubleConstant doubleConstant) voidvisitDynamicConstant(Clazz clazz, DynamicConstant dynamicConstant) voidvisitFloatConstant(Clazz clazz, FloatConstant floatConstant) voidvisitIntegerConstant(Clazz clazz, IntegerConstant integerConstant) voidvisitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant) voidvisitLongConstant(Clazz clazz, LongConstant longConstant) voidvisitLookUpSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LookUpSwitchInstruction lookUpSwitchInstruction) voidvisitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant) voidvisitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant) voidvisitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant) voidvisitPrimitiveArrayConstant(Clazz clazz, PrimitiveArrayConstant primitiveArrayConstant) voidvisitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction) voidvisitStringConstant(Clazz clazz, StringConstant stringConstant) voidvisitTableSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, TableSwitchInstruction tableSwitchInstruction) voidvisitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) voidvisitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction) booleanwasConstant(int argument) Returns whether the specified wildcard argument was a constant from the constant pool in the most recent match.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 proguard.classfile.constant.visitor.ConstantVisitor
visitAnyConstant, visitAnyMethodrefConstant, visitFieldrefConstant, visitInterfaceMethodrefConstant, visitMethodrefConstant, visitModuleConstant, visitPackageConstant从接口继承的方法 proguard.classfile.instruction.visitor.InstructionVisitor
visitAnyInstruction, visitAnySwitchInstruction
-
字段详细资料
-
X
public static final int X- 另请参阅:
-
Y
public static final int Y- 另请参阅:
-
Z
public static final int Z- 另请参阅:
-
A
public static final int A- 另请参阅:
-
B
public static final int B- 另请参阅:
-
C
public static final int C- 另请参阅:
-
D
public static final int D- 另请参阅:
-
E
public static final int E- 另请参阅:
-
F
public static final int F- 另请参阅:
-
G
public static final int G- 另请参阅:
-
H
public static final int H- 另请参阅:
-
I
public static final int I- 另请参阅:
-
J
public static final int J- 另请参阅:
-
K
public static final int K- 另请参阅:
-
L
public static final int L- 另请参阅:
-
M
public static final int M- 另请参阅:
-
N
public static final int N- 另请参阅:
-
O
public static final int O- 另请参阅:
-
P
public static final int P- 另请参阅:
-
Q
public static final int Q- 另请参阅:
-
R
public static final int R- 另请参阅:
-
patternConstants
-
patternInstructions
-
patternConstant
-
matchingConstant
protected boolean matchingConstant
-
-
构造器详细资料
-
InstructionSequenceMatcher
Creates a new InstructionSequenceMatcher.- 参数:
patternConstants- any constants referenced by the pattern instruction.patternInstructions- the pattern instruction sequence.
-
InstructionSequenceMatcher
public InstructionSequenceMatcher(Constant[] patternConstants, Instruction[] patternInstructions, boolean matchSubclasses) Creates a new InstructionSequenceMatcher.- 参数:
patternConstants- any constants referenced by the pattern instruction.patternInstructions- the pattern instruction sequence.matchSubclasses- whether constant references on subclasses are matching when the pattern contains a constant of a superclass. (default: false)
-
-
方法详细资料
-
reset
public void reset()Starts matching from the first instruction again next time. -
isMatching
public boolean isMatching()Returns whether the complete pattern sequence has been matched. -
instructionCount
public int instructionCount()Returns the number of instructions in the pattern sequence. -
matchedInstructionOffset
public int matchedInstructionOffset(int index) Returns the matched instruction offset of the specified pattern instruction. -
wasConstant
public boolean wasConstant(int argument) Returns whether the specified wildcard argument was a constant from the constant pool in the most recent match. -
matchedArgument
public int matchedArgument(int argument) Returns the value of the specified matched argument (wildcard or not). -
matchedArguments
public int[] matchedArguments(int[] arguments) Returns the values of the specified matched arguments (wildcard or not). -
matchedConstantIndex
public int matchedConstantIndex(int constantIndex) Returns the index of the specified matched constant (wildcard or not). -
matchedBranchOffset
public int matchedBranchOffset(int offset, int branchOffset) Returns the value of the specified matched branch offset (wildcard or not). -
matchedJumpOffsets
public int[] matchedJumpOffsets(int offset, int[] jumpOffsets) Returns the values of the specified matched jump offsets (wildcard or not). -
visitSimpleInstruction
public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction) - 指定者:
visitSimpleInstruction在接口中InstructionVisitor
-
visitVariableInstruction
public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction) - 指定者:
visitVariableInstruction在接口中InstructionVisitor
-
visitConstantInstruction
public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction) - 指定者:
visitConstantInstruction在接口中InstructionVisitor
-
visitBranchInstruction
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction) - 指定者:
visitBranchInstruction在接口中InstructionVisitor
-
visitTableSwitchInstruction
public void visitTableSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, TableSwitchInstruction tableSwitchInstruction) -
visitLookUpSwitchInstruction
public void visitLookUpSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LookUpSwitchInstruction lookUpSwitchInstruction) -
visitIntegerConstant
- 指定者:
visitIntegerConstant在接口中ConstantVisitor
-
visitLongConstant
- 指定者:
visitLongConstant在接口中ConstantVisitor
-
visitFloatConstant
- 指定者:
visitFloatConstant在接口中ConstantVisitor
-
visitDoubleConstant
- 指定者:
visitDoubleConstant在接口中ConstantVisitor
-
visitPrimitiveArrayConstant
- 指定者:
visitPrimitiveArrayConstant在接口中ConstantVisitor
-
visitStringConstant
- 指定者:
visitStringConstant在接口中ConstantVisitor
-
visitUtf8Constant
- 指定者:
visitUtf8Constant在接口中ConstantVisitor
-
visitDynamicConstant
- 指定者:
visitDynamicConstant在接口中ConstantVisitor
-
visitInvokeDynamicConstant
- 指定者:
visitInvokeDynamicConstant在接口中ConstantVisitor
-
visitMethodHandleConstant
- 指定者:
visitMethodHandleConstant在接口中ConstantVisitor
-
visitAnyRefConstant
从接口复制的说明:ConstantVisitorVisits any RefConstant instance. The more specific default implementations of this interface delegate to this method.- 指定者:
visitAnyRefConstant在接口中ConstantVisitor
-
visitClassConstant
- 指定者:
visitClassConstant在接口中ConstantVisitor
-
visitMethodTypeConstant
- 指定者:
visitMethodTypeConstant在接口中ConstantVisitor
-
visitNameAndTypeConstant
- 指定者:
visitNameAndTypeConstant在接口中ConstantVisitor
-
matchingOpcodes
-
matchingArguments
protected boolean matchingArguments(int argument1, int argument2) -
matchingArguments
protected boolean matchingArguments(int[] arguments1, int[] arguments2) -
matchingConstantIndices
-
matchingBranchOffsets
protected boolean matchingBranchOffsets(int offset, int branchOffset1, int branchOffset2) -
matchingJumpOffsets
protected boolean matchingJumpOffsets(int offset, int[] jumpOffsets1, int[] jumpOffsets2) -
finalMatch
protected boolean finalMatch(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) Performs a final check on the candidate sequence to match, after the pattern has been successfully fully matched with the sequence. Subclasses may override this method to implement additional constraints on the matched sequences. -
main
Small sample application that illustrates the use of this class.
-