# Class: com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern

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)
   N      non-terminals
   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
 
```

## Method: addInput
- parameter: `strings`, type: `java.lang.String[]`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Add an input pattern.
parameter: strings: input pattern lines
return: this pattern

## Method: addInput
- parameter: `flags`, type: `int`
- parameter: `strings`, type: `java.lang.String[]`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Add an input pattern.
parameter: flags: input pattern flags
parameter: strings: input pattern lines
return: this pattern

## Method: compile
- parameter: `compiler`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Compile this pattern with the provided compiler.
parameter: compiler: compiler to use, or null for the default compiler
return: this compiled pattern

## Method: compile
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Compile this pattern with the default compiler.
return: this compiled pattern

## Method: compile
- parameter: `flags`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Compile this pattern with temporary compiler flags.
parameter: flags: compiler flags
return: this compiled pattern

## Method: getCustomReplacer
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.IDPatternReplacer`

Description: Retrieve the custom replacer.
return: the custom replacer, or null if none is defined

## Method: getInput
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern.P`

Description: Retrieve an input pattern.
parameter: index: zero\-based input index
return: the input pattern

## Method: getInputs
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern.P>`

Description: Retrieve the input patterns.
return: the input patterns

## Method: getName
- return type: `java.lang.String`

Description: Retrieve the pattern name.
return: the pattern name, or null if unnamed

## Method: getOutput
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern.P`

Description: Retrieve the output replacement pattern.
return: the output pattern, or null if none is defined

## Method: getVerifier
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.IDMatchVerifier`

Description: Retrieve the match verifier.
return: the verifier, or null if none is defined

## Method: hasOutput
- return type: `boolean`

Description: Determine whether this pattern has an output replacement.
return: true if an output replacement is defined

## Method: isCompiled
- return type: `boolean`

Description: Determine whether this pattern was compiled.
return: true if this pattern was compiled

## Method: isPureInputExpression
- return type: `boolean`

Description: Indicate if a pattern has only pure input expressions \(meaning no assignment and only 1 expression\). Otherwise, at least an input contains full statement OR/AND several items.
return: true if all inputs are pure expressions

## Method: isPureOuputExpression
- return type: `boolean`

Description: Indicate if the result of a pattern replacement is a pure expression \(only an expression is replaced\). Otherwise, the result will modify one or more statements.
return: true if the output is a pure expression

## Method: setCustomReplacer
- parameter: `replacer`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.IDPatternReplacer`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Set a custom replacer called for successful matches.
parameter: replacer: optional custom replacer
return: this pattern

## Method: setInput
- parameter: `str`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Set the sole input pattern.
parameter: str: input pattern line
return: this pattern

## Method: setInput
- parameter: `flags`, type: `int`
- parameter: `str`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Set the sole input pattern.
parameter: flags: input pattern flags
parameter: str: input pattern line
return: this pattern

## Method: setOutput
- parameter: `strings`, type: `java.lang.String[]`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Set the output replacement pattern.
parameter: strings: output pattern lines
return: this pattern

## Method: setOutput
- parameter: `flags`, type: `int`
- parameter: `strings`, type: `java.lang.String[]`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Set the output replacement pattern.
parameter: flags: output pattern flags
parameter: strings: output pattern lines
return: this pattern

## Method: setVerifier
- parameter: `verifier`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.IDMatchVerifier`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Set a verifier called on candidate matches.
parameter: verifier: optional match verifier
return: this pattern

## Method: toString
- return type: `java.lang.String`


## Static Method: cc
- parameter: `inputStrings`, type: `java.lang.String[]`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Convenience method to quickly create and compile a single\-input, no\-output pattern.
parameter: inputStrings: input pattern lines
return: the compiled pattern

## Static Method: cc
- parameter: `inputFlags`, type: `int`
- parameter: `inputStrings`, type: `java.lang.String[]`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Convenience method to quickly create and compile a single\-input, no\-output pattern.
parameter: inputFlags: input pattern flags
parameter: inputStrings: input pattern lines
return: the compiled pattern

## Static Method: create
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Create an unnamed pattern.
return: a new pattern

## Static Method: create
- parameter: `name`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`

Description: Create a pattern.
parameter: name: optional pattern name
return: a new pattern

