public static class

EPatternCompiler.EPattern

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.compiler.EPatternCompiler.EPattern

Class Overview

IR expression multi-pattern, consisting of one or more inputs, and zero or one output (for replacement).

 Triggers for leaves:
   $      any (terminals and non-terminals)
   T      terminals (imm, var, range)
   N      non-terminals (mem, slice)
   V      variables
   #      immediates
   @x     special immediates; currently supported: @LASTBITn = (bitsize-1) of expression n
          (important: take note that n does not refer to the leaf itself, it refers to another previously matched leaf.)
   DIGITS a specific immediate (an optional id can be specified in curly braces after the value)
 
 Suffixes:
  {n}     Assign the id n to the leaf (must be the first suffix)
  [H1]    Select the first half of an expression (for a 32-bit leaf, the [0:16[ bits)
  [H2]    Select the second half of an expression (for a 32-bit leaf, the [16:32[ bits)
 
 Examples:
   $0     match any expression, assign the id 0
   V1     match any EVar, assign the id 1
   #2     match any immediate; assign the id 2 to it
   10     match an immediate holding the value 10, of any size; do not assign an id to it (will not be in the matchmap)
   10{2}  match an immediate holding the value 10; assign the id 2 to it
 
 Use parentheses. The parser is relatively simple and does not know about operator precedence.
 Therefore, an excess of parens around expressions is better than the reverse.
 
 Associativity for ADD, MUL, AND, OR, XOR: use the syntax (a OP b OP c OP d) instead of specific grouping like ((a OP b) OP (c OP d))
 to allow the matcher to try all possible combinations for associative and commutative operators.
 
 Immediate literals: should always start with a digit. Therefore, to use write in base 16, use the 0x prefix.
 Negative literals are allowed but must be enclosed in parens, e.g. (-3).
 
 Special BOL characters for multi-line patterns:
 > at beginning of line indicates the trigger (if unspecified,
   the most appropriate trigger statement will be determined heuristically)
 X at beginning of line indicates that the input expression should not be
   discarded during a replacement (if any). It can only be used for leading
   and trailing statements of an input pattern. Gaps are not allowed.
 
 When compiling an output pattern for replacement, immediates can reference existing matched-item ids,
 in which case their bitsize will be the one of the matched item.
 When an output pattern uses id-less immediates, the pattern-replacer engine will attempt to infer its bitsize
 from the surrounding expression. (Not recommended.)
 
Flexible matching:
 => (x + imm) will also be matched as (x - (-imm))
 => (x - imm) will also be matched as (x + (-imm))
 => (x * 2) will also be matched as (x << 1), and conversely, for all powers of 2
 => (x >= y) will also be matched as (y <= x), and the same goes for all inequality operators
 => (x OP y) with OP being a commutative operator will also be matched as (y OP x)
 => (x OP y OP z) can be used for associative operators +-&|^ and will match on any possible grouping
 

Summary

Nested Classes
class EPatternCompiler.EPattern.P Internal multi-pattern holding an input or output pattern block. 
Public Methods
EPatternCompiler.EPattern addInput(int flags, String... strings)
EPatternCompiler.EPattern addInput(String... strings)
static EPatternCompiler.EPattern cc(String... inputStrings)
Convenience method to quickly create and compile a single-input, no-output pattern.
static EPatternCompiler.EPattern cc(int inputFlags, String... inputStrings)
Convenience method to quickly create and compile a single-input, no-output pattern.
EPatternCompiler.EPattern compile()
EPatternCompiler.EPattern compile(int flags)
EPatternCompiler.EPattern compile(EPatternCompiler compiler)
static EPatternCompiler.EPattern create(String name)
static EPatternCompiler.EPattern create()
IEPatternReplacer getCustomReplacer()
EPatternCompiler.EPattern.P getInput(int index)
List<EPatternCompiler.EPattern.P> getInputs()
String getName()
EPatternCompiler.EPattern.P getOutput()
IEMatchVerifier getVerifier()
boolean hasOutput()
boolean isCompiled()
boolean isPureInputExpression()
EPatternCompiler.EPattern setCustomReplacer(IEPatternReplacer replacer)
EPatternCompiler.EPattern setInput(int flags, String str)
EPatternCompiler.EPattern setInput(String str)
EPatternCompiler.EPattern setOutput(String... strings)
EPatternCompiler.EPattern setOutput(int flags, String... strings)
EPatternCompiler.EPattern setVerifier(IEMatchVerifier verifier)
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public EPatternCompiler.EPattern addInput (int flags, String... strings)

public EPatternCompiler.EPattern addInput (String... strings)

public static EPatternCompiler.EPattern cc (String... inputStrings)

Convenience method to quickly create and compile a single-input, no-output pattern.

public static EPatternCompiler.EPattern cc (int inputFlags, String... inputStrings)

Convenience method to quickly create and compile a single-input, no-output pattern.

public EPatternCompiler.EPattern compile ()

public EPatternCompiler.EPattern compile (int flags)

public EPatternCompiler.EPattern compile (EPatternCompiler compiler)

public static EPatternCompiler.EPattern create (String name)

public static EPatternCompiler.EPattern create ()

public IEPatternReplacer getCustomReplacer ()

public EPatternCompiler.EPattern.P getInput (int index)

public List<EPatternCompiler.EPattern.P> getInputs ()

public String getName ()

public EPatternCompiler.EPattern.P getOutput ()

public IEMatchVerifier getVerifier ()

public boolean hasOutput ()

public boolean isCompiled ()

public boolean isPureInputExpression ()

public EPatternCompiler.EPattern setCustomReplacer (IEPatternReplacer replacer)

public EPatternCompiler.EPattern setInput (int flags, String str)

public EPatternCompiler.EPattern setInput (String str)

public EPatternCompiler.EPattern setOutput (String... strings)

public EPatternCompiler.EPattern setOutput (int flags, String... strings)

public EPatternCompiler.EPattern setVerifier (IEMatchVerifier verifier)

public String toString ()