Class AbstractExpressionSolver<T extends PatternExpression>
java.lang.Object
ghidra.app.plugin.assembler.sleigh.expr.AbstractExpressionSolver<T>
- Type Parameters:
T
- the type of expression solved (the operator)
- Direct Known Subclasses:
AbstractBinaryExpressionSolver
,AbstractUnaryExpressionSolver
,ConstantValueSolver
,ContextFieldSolver
,EndInstructionValueSolver
,Next2InstructionValueSolver
,OperandValueSolver
,StartInstructionValueSolver
,TokenFieldSolver
The root type of an expression solver
-
Field Summary
-
Constructor Summary
ConstructorDescriptionAbstractExpressionSolver
(Class<T> tcls) Construct a solver that can solve expression of the given type -
Method Summary
Modifier and TypeMethodDescriptionabstract int
getInstructionLength
(T exp) Determines the length of the subconstructor that would be returned had the expression not depended on an undefined symbol.abstract MaskedLong
Attempt to get a constant value for the expressionprotected void
register
(RecursiveDescentSolver general) Register this particular solver with the general expression solverabstract AssemblyResolution
solve
(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 valueabstract MaskedLong
valueForResolution
(T exp, Map<String, Long> vals, AssemblyResolvedPatterns rc) Compute the value of the expression given the (possibly-intermediate) resolution
-
Field Details
-
solver
-
dbg
-
-
Constructor Details
-
AbstractExpressionSolver
Construct a solver that can solve expression of the given type- Parameters:
tcls
- the type of expressions it can solve
-
-
Method Details
-
solve
public abstract AssemblyResolution solve(AbstractAssemblyResolutionFactory<?, ?> factory, T exp, MaskedLong goal, Map<String, throws NeedsBackfillExceptionLong> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) Attempt to solve an expression for a given value- 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
-
getValue
public abstract MaskedLong getValue(T exp, Map<String, Long> vals, AssemblyResolvedPatterns cur) throws NeedsBackfillExceptionAttempt to get a constant value for the expression- 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
-
getInstructionLength
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
- Parameters:
exp
- the expression- Returns:
- the length of filled in token field(s).
-
valueForResolution
public abstract MaskedLong valueForResolution(T exp, Map<String, Long> vals, AssemblyResolvedPatterns rc) Compute the value of the expression given the (possibly-intermediate) resolution- Parameters:
exp
- the expression to evaluatevals
- values of defined symbolsrc
- the resolution on which to evaluate it- Returns:
- the result
-
register
Register this particular solver with the general expression solver- Parameters:
general
- the general solver
-