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

public abstract class AbstractExpressionSolver<T extends PatternExpression> extends Object
The root type of an expression solver
  • Field Details

  • Constructor Details

    • AbstractExpressionSolver

      public AbstractExpressionSolver(Class<T> tcls)
      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,Long> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description) throws NeedsBackfillException
      Attempt to solve an expression for a given value
      Parameters:
      exp - the expression to solve
      goal - the desired value of the expression
      vals - values of defined symbols
      hints - describes techniques applied by calling solvers
      description - 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 NeedsBackfillException
      Attempt to get a constant value for the expression
      Parameters:
      exp - the expression
      vals - 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

      public abstract int getInstructionLength(T exp)
      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 evaluate
      vals - values of defined symbols
      rc - 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