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
,OperandValueSolver
,StartInstructionValueSolver
,TokenFieldSolver
public abstract class AbstractExpressionSolver<T extends PatternExpression> extends java.lang.Object
The root type of an expression solver
-
-
Field Summary
Fields Modifier and Type Field Description protected DbgTimer
dbg
protected RecursiveDescentSolver
solver
-
Constructor Summary
Constructors Constructor Description AbstractExpressionSolver(java.lang.Class<T> tcls)
Construct a solver that can solve expression of the given type
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract int
getInstructionLength(T exp, java.util.Map<java.lang.Integer,java.lang.Object> res)
Determines the length of the subconstructor that would be returned had the expression not depended on an undefined symbol.abstract MaskedLong
getValue(T exp, java.util.Map<java.lang.String,java.lang.Long> vals, java.util.Map<java.lang.Integer,java.lang.Object> res, AssemblyResolvedConstructor cur)
Attempt to get a constant value for the expressionprotected void
register(RecursiveDescentSolver general)
Register this particular solver with the general expression solverabstract AssemblyResolution
solve(T exp, MaskedLong goal, java.util.Map<java.lang.String,java.lang.Long> vals, java.util.Map<java.lang.Integer,java.lang.Object> res, AssemblyResolvedConstructor cur, java.util.Set<SolverHint> hints, java.lang.String description)
Attempt to solve an expression for a given valueabstract MaskedLong
valueForResolution(T exp, AssemblyResolvedConstructor rc)
Compute the value of the expression given the (possibly-intermediate) resolution
-
-
-
Field Detail
-
solver
protected RecursiveDescentSolver solver
-
dbg
protected final DbgTimer dbg
-
-
Constructor Detail
-
AbstractExpressionSolver
public AbstractExpressionSolver(java.lang.Class<T> tcls)
Construct a solver that can solve expression of the given type- Parameters:
tcls
- the type of expressions it can solve
-
-
Method Detail
-
solve
public abstract AssemblyResolution solve(T exp, MaskedLong goal, java.util.Map<java.lang.String,java.lang.Long> vals, java.util.Map<java.lang.Integer,java.lang.Object> res, AssemblyResolvedConstructor cur, java.util.Set<SolverHint> hints, java.lang.String description) throws NeedsBackfillException
Attempt to solve an expression for a given value- Parameters:
exp
- the expression to solvegoal
- the desired value of the expressionvals
- values of defined symbolsres
- the results of subconstructor resolutions (used for lengths)hints
- 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, java.util.Map<java.lang.String,java.lang.Long> vals, java.util.Map<java.lang.Integer,java.lang.Object> res, AssemblyResolvedConstructor cur) throws NeedsBackfillException
Attempt to get a constant value for the expression- Parameters:
exp
- the expressionvals
- values of defined symbolsres
- the results of subconstructor resolutions (used for lengths)- Returns:
- the constant value, or null if it depends on a variable
- Throws:
NeedsBackfillException
- if the expression refers to an undefined symbol
-
getInstructionLength
public abstract int getInstructionLength(T exp, java.util.Map<java.lang.Integer,java.lang.Object> res)
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 expressionres
- the results of subconstructor resolutions (used for lengths)- Returns:
- the length of filled in token field(s).
-
valueForResolution
public abstract MaskedLong valueForResolution(T exp, AssemblyResolvedConstructor rc)
Compute the value of the expression given the (possibly-intermediate) resolution- Parameters:
exp
- the expression to evaluaterc
- the resolution on which to evaluate it- Returns:
- the result
-
register
protected void register(RecursiveDescentSolver general)
Register this particular solver with the general expression solver- Parameters:
general
- the general solver
-
-