Class AbstractDExpressionOptimizer
java.lang.Object
com.pnfsoftware.jeb.core.AbstractPlugin
com.pnfsoftware.jeb.core.units.code.android.ir.AbstractDOptimizer
com.pnfsoftware.jeb.core.units.code.android.ir.AbstractDExpressionOptimizer
- All Implemented Interfaces:
IPlugin,IDOptimizer
Skeleton for a top-down, recursive,
IDExpression optimizer. Expressions are provided in
depth-first, pre-order way: parent expressions are provided before their constituting children.
By default, IDInstructions are not candidates for optimization (although they can be).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IDInstructionThis field holds a reference to the top-level parent statement of the expression currently being optimized.protected booleanCopy the type of an expression to the replacement expression (viaIDExpression.setType) over to the replacement expression.
Default value: false.protected booleanDo not process left-side ofstatement.
Default value: false.protected booleanOptimize only the constituents of statements, not the statements themselves.
Default value: true.Fields inherited from class com.pnfsoftware.jeb.core.units.code.android.ir.AbstractDOptimizer
cfg, ctx, ctxlist, decomp, dex, dfa, g, logger, of, tfFields inherited from interface com.pnfsoftware.jeb.core.units.code.android.ir.IDOptimizer
DEOBFUSCATOR, INLINER, REORDERER, SLOW -
Constructor Summary
ConstructorsConstructorDescriptionCreate astandardexpression optimizer.Create an expression optimizer.AbstractDExpressionOptimizer(DOptimizerType type, String name) Create an expression optimizer. -
Method Summary
Modifier and TypeMethodDescriptionprotected IDExpressiondoSubstitution(IDExpression e, SubstitutionDefinition... substitutions) Attempt to apply the first matchingSubstitutionDefinitionon anIDExpressionexpression.protected abstract DORAttempt to optimize expressions.intperform()An optimizer must implement this method.performOnExpression(IDExpression exp, IDMethodContext ctx) Run this optimizer on a standalone expression.Methods inherited from class com.pnfsoftware.jeb.core.units.code.android.ir.AbstractDOptimizer
addTag, analyzeChains, analyzeChains, assignLocalFields, checkInterrupted, cleanGraph, cleanGraph, debugDump, debugVerify, getName, getPluginInformation, getPriority, getTags, getType, invalidateChains, isCollectionOptimizer, isEnabled, perform, performOnCollection, removeTag, resetLocalFields, setEnabled, setName, setPriority, setTypeMethods inherited from class com.pnfsoftware.jeb.core.AbstractPlugin
dispose, getData, setData
-
Field Details
-
skipStatementProcessing
protected boolean skipStatementProcessingOptimize only the constituents of statements, not the statements themselves.
Default value: true. -
skipLeftSideOfAssignment
protected boolean skipLeftSideOfAssignmentDo not process left-side ofstatement.
Default value: false. -
currentStatement
This field holds a reference to the top-level parent statement of the expression currently being optimized. -
portSourceType
protected boolean portSourceTypeCopy the type of an expression to the replacement expression (viaIDExpression.setType) over to the replacement expression.
Default value: false.
-
-
Constructor Details
-
AbstractDExpressionOptimizer
public AbstractDExpressionOptimizer()Create astandardexpression optimizer. -
AbstractDExpressionOptimizer
Create an expression optimizer.- Parameters:
type- optimizer type, or null to useDOptimizerType.NORMAL
-
AbstractDExpressionOptimizer
Create an expression optimizer.- Parameters:
type- optimizer type, or null to useDOptimizerType.NORMALname- optional optimizer name
-
-
Method Details
-
perform
public int perform()Description copied from class:AbstractDOptimizerAn optimizer must implement this method. This method is called by a master optimizer to perform the optimization on theselectedtarget.Note that the optimizer is responsible for returning a legal method context, e.g.: the method IR instructions must be consistent with the CFG; the CFG must adhere to certain rules (see
cleanGraph); if the data flow analysis is no longer valid, it should be invalidated (seeresetDFA); etc.- Specified by:
performin classAbstractDOptimizer- Returns:
- the number of optimizations performed, 0 if none
-
performOnExpression
Run this optimizer on a standalone expression.- Parameters:
exp- expression to optimizectx- method context- Returns:
- replacement expression, or null if the input expression was not optimized
-
optimizeExpression
Attempt to optimize expressions. Sub-expressions may be examined. The implementor should not attempt to modify parent or cousins expressions.- Parameters:
e- IR expression- Returns:
- the new (optimized) expression as well as DFA update hints, or null if the expression could not be optimized
-
doSubstitution
Attempt to apply the first matchingSubstitutionDefinitionon anIDExpressionexpression.- Parameters:
e- the target IR expression to be matched and modifiedsubstitutions- a list of candidate substitutions- Returns:
- null if no substitution was performed, else the new expression
-