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

IR pattern search and replace. 

 Current limitation: matching is limited by basic block boundaries.

## Constructor: DPatternMatcher
- parameter: `pattern`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.android.controlflow.CFG<com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction>`
- parameter: `ctx`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext`

Description: Create a matcher for a control\-flow graph.
parameter: pattern: compiled pattern
parameter: cfg: input CFG
parameter: ctx: method context

## Constructor: DPatternMatcher
- parameter: `pattern`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternCompiler.DPattern`
- parameter: `exp`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- parameter: `ctx`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext`

Description: Create a matcher for a single expression.
parameter: pattern: compiled pattern
parameter: exp: input expression
parameter: ctx: method context

## Method: getContext
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext`

Description: Retrieve the method context used by this matcher.
return: the method context

## Method: getIRDepthsMap
- return type: `java.util.Map<com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression,java.lang.Integer>`

Description: Retrieve the expression depth map used during matching.
return: the expression depth map, or null if none was set

## Method: getInputCfg
- return type: `com.pnfsoftware.jeb.core.units.code.android.controlflow.CFG<com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction>`

Description: Retrieve the input control\-flow graph.
return: the input CFG, or null for expression\-only matching

## Method: getInputExpression
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`

Description: Retrieve the input expression.
return: the input expression, or null for CFG matching

## Method: getMatchAddress
- parameter: `result`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result`
- parameter: `index`, type: `int`
- return type: `long`

Description: Retrieve the address of a matched pattern line.
parameter: result: match result
parameter: index: line index relative to the matched input pattern; negative values are relative            to the pattern end
return: the IR address of the matched line

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

Description: Retrieve the pattern used by this matcher.
return: the pattern

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

Description: Determine whether deep associativity matching is allowed.
return: true if deep associativity matching is allowed

## Method: replace
- parameter: `r`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result`
- parameter: `preferBuiltinReplacer`, type: `boolean`
- return type: `boolean`

Description: Replace a previously found match.
parameter: r: match result to replace
parameter: preferBuiltinReplacer: true to use the built\-in replacer before any custom replacer
return: true if replacement succeeded

## Method: search
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result`

Description: Search for the first match.
return: the first match, or null if none was found

## Method: search
- parameter: `lastResult`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result`

Description: Search for the next match.
parameter: lastResult: previous match, or null to start from the beginning
return: the next match, or null if none was found

## Method: searchAndReplace
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result`

Description: Search for the first match and replace it.
return: the replacement result, or null if no match was found

## Method: searchAndReplace
- parameter: `lastResult`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result`

Description: Search for the next match and replace it.
parameter: lastResult: previous replacement result, or null to start from the beginning
return: the replacement result, or null if no match was found

## Method: searchAndReplaceAll
- return type: `int`

Description: Search and replace all matches.
return: the number of replacements

## Method: searchAndReplaceAll
- parameter: `aresult`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DPatternMatcher.Result[]`
- return type: `int`

Description: Search and replace all matches.
parameter: aresult: \(optional\) last successful search\-and\-replace
return: the number of replacements

## Method: setAllowDeepAssociativity
- parameter: `allowDeepAssociativity`, type: `boolean`

Description: Allow to modify inner expression to check alternative associativity. For example, matching `V0 * (#1 + $2)` on `r0 * ((r1 + 4) + r2)` will attempt any associativity, matching on 

```

 V0 = r0
 #1 = 4
 $2 = (r1 + r2)
 
```
 even if \(r1 \+ r2\) * does not* exists in inner expression.
parameter: allowDeepAssociativity: true to allow deep associativity matching

## Method: setIRDepthsMap
- parameter: `iRDepthsMap`, type: `java.util.Map<com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression,java.lang.Integer>`

Description: Set precomputed expression depths used during matching.
parameter: iRDepthsMap: expression depth map

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


