类 InstructionSequenceMatcher
- java.lang.Object
-
- proguard.classfile.util.InstructionSequenceMatcher
-
- 所有已实现的接口:
ConstantVisitor,InstructionVisitor
public class InstructionSequenceMatcher extends java.lang.Object implements InstructionVisitor, ConstantVisitor
ThisInstructionVisitorchecks 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 intAstatic intBstatic intCstatic intDstatic intEstatic intFstatic intGstatic intHstatic intIstatic intJstatic intKstatic intLstatic intMprotected booleanmatchingConstantstatic intNstatic intOstatic intPprotected ConstantpatternConstantprotected Constant[]patternConstantsprotected Instruction[]patternInstructionsstatic intQstatic intRstatic intXstatic intYstatic intZ
-
构造器概要
构造器 构造器 说明 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.intinstructionCount()Returns the number of instructions in the pattern sequence.booleanisMatching()Returns whether the complete pattern sequence has been matched.static voidmain(java.lang.String[] args)Small 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
protected final Constant[] patternConstants
-
patternInstructions
protected final Instruction[] patternInstructions
-
patternConstant
protected Constant patternConstant
-
matchingConstant
protected boolean matchingConstant
-
-
构造器详细资料
-
InstructionSequenceMatcher
public InstructionSequenceMatcher(Constant[] patternConstants, Instruction[] patternInstructions)
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
public void visitIntegerConstant(Clazz clazz, IntegerConstant integerConstant)
- 指定者:
visitIntegerConstant在接口中ConstantVisitor
-
visitLongConstant
public void visitLongConstant(Clazz clazz, LongConstant longConstant)
- 指定者:
visitLongConstant在接口中ConstantVisitor
-
visitFloatConstant
public void visitFloatConstant(Clazz clazz, FloatConstant floatConstant)
- 指定者:
visitFloatConstant在接口中ConstantVisitor
-
visitDoubleConstant
public void visitDoubleConstant(Clazz clazz, DoubleConstant doubleConstant)
- 指定者:
visitDoubleConstant在接口中ConstantVisitor
-
visitPrimitiveArrayConstant
public void visitPrimitiveArrayConstant(Clazz clazz, PrimitiveArrayConstant primitiveArrayConstant)
- 指定者:
visitPrimitiveArrayConstant在接口中ConstantVisitor
-
visitStringConstant
public void visitStringConstant(Clazz clazz, StringConstant stringConstant)
- 指定者:
visitStringConstant在接口中ConstantVisitor
-
visitUtf8Constant
public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant)
- 指定者:
visitUtf8Constant在接口中ConstantVisitor
-
visitDynamicConstant
public void visitDynamicConstant(Clazz clazz, DynamicConstant dynamicConstant)
- 指定者:
visitDynamicConstant在接口中ConstantVisitor
-
visitInvokeDynamicConstant
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
- 指定者:
visitInvokeDynamicConstant在接口中ConstantVisitor
-
visitMethodHandleConstant
public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant)
- 指定者:
visitMethodHandleConstant在接口中ConstantVisitor
-
visitAnyRefConstant
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
从接口复制的说明:ConstantVisitorVisits any RefConstant instance. The more specific default implementations of this interface delegate to this method.- 指定者:
visitAnyRefConstant在接口中ConstantVisitor
-
visitClassConstant
public void visitClassConstant(Clazz clazz, ClassConstant classConstant)
- 指定者:
visitClassConstant在接口中ConstantVisitor
-
visitMethodTypeConstant
public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant)
- 指定者:
visitMethodTypeConstant在接口中ConstantVisitor
-
visitNameAndTypeConstant
public void visitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant)
- 指定者:
visitNameAndTypeConstant在接口中ConstantVisitor
-
matchingOpcodes
protected boolean matchingOpcodes(Instruction instruction1, Instruction instruction2)
-
matchingArguments
protected boolean matchingArguments(int argument1, int argument2)
-
matchingArguments
protected boolean matchingArguments(int[] arguments1, int[] arguments2)
-
matchingConstantIndices
protected boolean matchingConstantIndices(Clazz clazz, int constantIndex1, int constantIndex2)
-
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
public static void main(java.lang.String[] args)
Small sample application that illustrates the use of this class.
-
-