Class AbstractBinaryExpressionSolver<T extends BinaryExpression>
java.lang.Object
ghidra.app.plugin.assembler.sleigh.expr.AbstractExpressionSolver<T>
ghidra.app.plugin.assembler.sleigh.expr.AbstractBinaryExpressionSolver<T>
- Type Parameters:
T
- the type of expression solved (the operator)
- Direct Known Subclasses:
AndExpressionSolver
,DivExpressionSolver
,LeftShiftExpressionSolver
,MultExpressionSolver
,OrExpressionSolver
,PlusExpressionSolver
,RightShiftExpressionSolver
,SubExpressionSolver
,XorExpressionSolver
public abstract class AbstractBinaryExpressionSolver<T extends BinaryExpression>
extends AbstractExpressionSolver<T>
A solver that handles expressions of the form
A [OP] B
-
Field Summary
Fields inherited from class ghidra.app.plugin.assembler.sleigh.expr.AbstractExpressionSolver
dbg, solver
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract MaskedLong
compute
(MaskedLong lval, MaskedLong rval) Compute the result of applying the operator to the two given valuesabstract MaskedLong
computeLeft
(MaskedLong rval, MaskedLong goal) Compute the left-hand-side value given that the result and the right are knowncomputeRight
(MaskedLong lval, MaskedLong goal) Compute the right-hand-side value given that the result and the left are knownint
getInstructionLength
(T exp) Determines the length of the subconstructor that would be returned had the expression not depended on an undefined symbol.Attempt to get a constant value for the expressionsolve
(AbstractAssemblyResolutionFactory<?, ?> factory, T exp, MaskedLong goal, Map<String, Long> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) Attempt to solve an expression for a given valueprotected AssemblyResolution
solveLeftSide
(AbstractAssemblyResolutionFactory<?, ?> factory, PatternExpression lexp, MaskedLong rval, MaskedLong goal, Map<String, Long> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) protected AssemblyResolution
solveRightSide
(AbstractAssemblyResolutionFactory<?, ?> factory, PatternExpression rexp, MaskedLong lval, MaskedLong goal, Map<String, Long> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) protected AssemblyResolution
solveTwoSided
(AbstractAssemblyResolutionFactory<?, ?> factory, T exp, MaskedLong goal, Map<String, Long> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) valueForResolution
(T exp, Map<String, Long> vals, AssemblyResolvedPatterns rc) Compute the value of the expression given the (possibly-intermediate) resolutionMethods inherited from class ghidra.app.plugin.assembler.sleigh.expr.AbstractExpressionSolver
register
-
Constructor Details
-
AbstractBinaryExpressionSolver
-
-
Method Details
-
solve
public AssemblyResolution solve(AbstractAssemblyResolutionFactory<?, ?> factory, T exp, MaskedLong goal, Map<String, throws NeedsBackfillExceptionLong> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) Description copied from class:AbstractExpressionSolver
Attempt to solve an expression for a given value- Specified by:
solve
in classAbstractExpressionSolver<T extends BinaryExpression>
- Parameters:
exp
- the expression to solvegoal
- the desired value of the expressionvals
- values of defined symbolshints
- describes techniques applied by calling solversdescription
- the description to give to resolved solutions- Returns:
- the resolution
- Throws:
NeedsBackfillException
- if the expression refers to an undefined symbol
-
solveLeftSide
protected AssemblyResolution solveLeftSide(AbstractAssemblyResolutionFactory<?, ?> factory, PatternExpression lexp, MaskedLong rval, MaskedLong goal, Map<String, throws NeedsBackfillException, SolverExceptionLong> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) -
solveRightSide
protected AssemblyResolution solveRightSide(AbstractAssemblyResolutionFactory<?, ?> factory, PatternExpression rexp, MaskedLong lval, MaskedLong goal, Map<String, throws NeedsBackfillException, SolverExceptionLong> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) -
solveTwoSided
protected AssemblyResolution solveTwoSided(AbstractAssemblyResolutionFactory<?, ?> factory, T exp, MaskedLong goal, Map<String, throws NeedsBackfillException, SolverExceptionLong> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) -
getValue
public MaskedLong getValue(T exp, Map<String, Long> vals, AssemblyResolvedPatterns cur) throws NeedsBackfillExceptionDescription copied from class:AbstractExpressionSolver
Attempt to get a constant value for the expression- Specified by:
getValue
in classAbstractExpressionSolver<T extends BinaryExpression>
- Parameters:
exp
- the expressionvals
- values of defined symbols- Returns:
- the constant value, or null if it depends on a variable
- Throws:
NeedsBackfillException
- if the expression refers to an undefined symbol
-
computeLeft
Compute the left-hand-side value given that the result and the right are known- Parameters:
rval
- the right-hand-side valuegoal
- the result- Returns:
- the left-hand-side value solution
- Throws:
SolverException
- if the expression cannot be solved
-
computeRight
Compute the right-hand-side value given that the result and the left are knownNOTE: Assumes commutativity by default
- Parameters:
lval
- the left-hand-side valuegoal
- the result- Returns:
- the right-hand-side value solution
- Throws:
SolverException
- if the expression cannot be solved
-
compute
Compute the result of applying the operator to the two given values- Parameters:
lval
- the left-hand-side valuerval
- the right-hand-side value- Returns:
- the result
-
getInstructionLength
Description copied from class:AbstractExpressionSolver
Determines the length of the subconstructor that would be returned had the expression not depended on an undefined symbol.This is used by the backfilling process to ensure values are written to the correct offset
- Specified by:
getInstructionLength
in classAbstractExpressionSolver<T extends BinaryExpression>
- Parameters:
exp
- the expression- Returns:
- the length of filled in token field(s).
-
valueForResolution
Description copied from class:AbstractExpressionSolver
Compute the value of the expression given the (possibly-intermediate) resolution- Specified by:
valueForResolution
in classAbstractExpressionSolver<T extends BinaryExpression>
- Parameters:
exp
- the expression to evaluatevals
- values of defined symbolsrc
- the resolution on which to evaluate it- Returns:
- the result
-