Class PatternMatcher.Builder

java.lang.Object
ftbsc.lll.utils.PatternMatcher.Builder
Enclosing class:
PatternMatcher

public static class PatternMatcher.Builder extends Object
The Builder object for PatternMatcher.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

      public PatternMatcher build()
      Builds the pattern defined so far.
      Returns:
      the built PatternMatcher
    • reverse

      public PatternMatcher.Builder reverse()
      Sets the pattern to match starting from the end.
      Returns:
      the builder's state after the operation
    • check

      public PatternMatcher.Builder check(Predicate<org.objectweb.asm.tree.AbstractInsnNode> predicate)
      Adds a custom predicate to the list. Also used internally.
      Parameters:
      predicate - the predicate to add
      Returns:
      the builder's state after the operation
    • any

      public PatternMatcher.Builder any()
      Wildcard, matches any kind of node.
      Returns:
      the builder's state after the operation
    • opcode

      public PatternMatcher.Builder opcode(int opcode)
      Matches a specific opcode.
      Parameters:
      opcode - opcode to match
      Returns:
      the builder's state after the operation
    • opcodes

      public PatternMatcher.Builder opcodes(int... opcodes)
      Matches a list of opcodes.
      Parameters:
      opcodes - list of opcodes to match
      Returns:
      the builder's state after the operation
    • method

      public PatternMatcher.Builder method()
      Matches a method invocation of any kind: one of INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
      Returns:
      the builder's state after the operation
    • field

      public PatternMatcher.Builder field()
      Matches a field invocation of any kind: one of GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
      Returns:
      the builder's state after the operation
    • jump

      public PatternMatcher.Builder jump()
      Matches any kind of jump instruction.
      Returns:
      the builder's state after the operation
    • label

      public PatternMatcher.Builder label()
      Matches any kind of label.
      Returns:
      the builder's state after the operation
    • node

      public PatternMatcher.Builder node(int opcode, Object... args)
      Matches the given opcode and the exact given arguments. Partial argument matches are not supported: all arguments must be provided for the check to succeed. The expected order of arguments is the one used in the relevant node constructor; where possible, a proxy can substitute the parent/name/descriptor arguments. Lists may be used in place of arrays; varargs will also be supported where the relevant node constructor accepted them. Raw labels may be used in place of LabelNodes. Matches made using method are the safest, but other tests are generally faster, although the difference will likely be negligible in nearly all use cases.
      Parameters:
      opcode - the opcode
      args - the arguments (you may use proxies in place of name/descriptors)
      Returns:
      the builder's state after the operation
    • ignoreLabels

      public PatternMatcher.Builder ignoreLabels()
      Tells the pattern matcher to ignore LABEL nodes.
      Returns:
      the builder's state after the operation
    • ignoreFrames

      public PatternMatcher.Builder ignoreFrames()
      Tells the pattern matcher to ignore FRAME nodes.
      Returns:
      the builder's state after the operation
    • ignoreLineNumbers

      public PatternMatcher.Builder ignoreLineNumbers()
      Tells the pattern matcher to ignore LINENUMBER nodes.
      Returns:
      the builder's state after the operation
    • ignoreNoOps

      public PatternMatcher.Builder ignoreNoOps()
      Tells the pattern matcher to ignore all no-ops.
      Returns:
      the builder's state after the operation