Class DExpressionMatcher
java.lang.Object
com.pnfsoftware.jeb.core.units.code.android.ir.compiler.DExpressionMatcher
Match an IR expression against an IR template.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDExpressionMatcher(IDMethodContext ctx, INode template) Create an IRE matcher.DExpressionMatcher(IDMethodContext ctx, INode template, Map<Integer, Object> initmap) Create an IRE matcher. -
Method Summary
Modifier and TypeMethodDescriptionRetrieve the expression depth map used during matching.Retrieve the match map:
- Key= leaf id
- Value= matched IRE (IDExpression) for leaves or operator (OperationType) for operator groups.booleanDetermine whether deep associativity matching is allowed.booleanDetermine whether an expression matches the template.voidreset()Reset this matcher and clear current matches.voidreset(boolean keepMatches) Reset this matcher.voidsetAllowDeepAssociativity(boolean allowDeepAssociativity) Use an operator's associativity to achieve better matching.voidsetIRDepthsMap(Map<IDExpression, Integer> IRDepthsMap) Set precomputed expression depths used during matching.toString()
-
Field Details
-
verbose
public static boolean verboseEnable verbose matcher diagnostics.
-
-
Constructor Details
-
DExpressionMatcher
Create an IRE matcher.- Parameters:
ctx- IR method contexttemplate- the template to match an expression againstinitmap- an optional, initial match map
-
DExpressionMatcher
Create an IRE matcher.- Parameters:
ctx- IR method contexttemplate- the template to match an expression against
-
-
Method Details
-
setAllowDeepAssociativity
public void setAllowDeepAssociativity(boolean allowDeepAssociativity) Use an operator's associativity to achieve better matching. For example, matchingV0 * (#1 + $2)onr0 * ((r1 + 4) + r2)could match on:V0 = r0 #1 = 4 $2 = (r1 + r2)
even if (r1 + r2) does not exists in inner expression.- Parameters:
allowDeepAssociativity- true to allow deep associativity matching
-
isAllowDeepAssociativity
public boolean isAllowDeepAssociativity()Determine whether deep associativity matching is allowed.- Returns:
- true if deep associativity matching is allowed
-
setIRDepthsMap
Set precomputed expression depths used during matching.- Parameters:
IRDepthsMap- expression depth map
-
getIRDepthsMap
Retrieve the expression depth map used during matching.- Returns:
- the expression depth map, or null if none was set
-
getMatchMap
Retrieve the match map:
- Key= leaf id
- Value= matched IRE (IDExpression) for leaves or operator (OperationType) for operator groups.- Returns:
- the match map
-
reset
public void reset(boolean keepMatches) Reset this matcher.- Parameters:
keepMatches- true to keep the current match map
-
reset
public void reset()Reset this matcher and clear current matches. -
isMatch
Determine whether an expression matches the template.- Parameters:
e- expression to test- Returns:
- true if the expression matches
-
toString
-