Package ghidra.app.plugin.assembler.sleigh.expr

# Class ConstantValueSolver

java.lang.Object
ghidra.app.plugin.assembler.sleigh.expr.AbstractExpressionSolver<ConstantValue>
ghidra.app.plugin.assembler.sleigh.expr.ConstantValueSolver

public class ConstantValueSolver extends AbstractExpressionSolver<ConstantValue>
"Solves" constant expressions

Essentially, this either evaluates successfully when asked for a constant value, or checks that the goal is equal to the constant. Otherwise, there is no solution.

- ## Field Summary

  ### Fields inherited from class ghidra.app.plugin.assembler.sleigh.expr.AbstractExpressionSolver

  `dbg, solver`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConstantValueSolver()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getInstructionLength(ConstantValue cv)`
  Determines the length of the subconstructor that would be returned had the expression not depended on an undefined symbol.
  `MaskedLong`
  `getValue(ConstantValue cv, Map<String,Long> vals, AssemblyResolvedPatterns cur)`
  Attempt to get a constant value for the expression
  `AssemblyResolution`
  `solve(ConstantValue cv, MaskedLong goal, Map<String,Long> vals, AssemblyResolvedPatterns cur, Set<SolverHint> hints, String description)`
  Attempt to solve an expression for a given value
  `MaskedLong`
  `valueForResolution(ConstantValue cv, Map<String,Long> vals, AssemblyResolvedPatterns rc)`
  Compute the value of the expression given the (possibly-intermediate) resolution

  ### Methods inherited from class ghidra.app.plugin.assembler.sleigh.expr.AbstractExpressionSolver

  `register`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ConstantValueSolver

    public ConstantValueSolver()

- ## Method Details

  - ### solve

    public AssemblyResolution solve(ConstantValue cv, MaskedLong goal, Map<String,Long> 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 class `AbstractExpressionSolver<ConstantValue>`
    Parameters:
      `cv` - 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

  - ### getValue

    public MaskedLong getValue(ConstantValue cv, Map<String,Long> vals, AssemblyResolvedPatterns cur)
    Description copied from class: `AbstractExpressionSolver`
    Attempt to get a constant value for the expression
    Specified by:
      `getValue` in class `AbstractExpressionSolver<ConstantValue>`
    Parameters:
      `cv` - the expression
      `vals` - values of defined symbols
    Returns:
      the constant value, or null if it depends on a variable

  - ### getInstructionLength

    public int getInstructionLength(ConstantValue cv)
    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 class `AbstractExpressionSolver<ConstantValue>`
    Parameters:
      `cv` - the expression
    Returns:
      the length of filled in token field(s).

  - ### valueForResolution

    public MaskedLong valueForResolution(ConstantValue cv, Map<String,Long> vals, AssemblyResolvedPatterns rc)
    Description copied from class: `AbstractExpressionSolver`
    Compute the value of the expression given the (possibly-intermediate) resolution
    Specified by:
      `valueForResolution` in class `AbstractExpressionSolver<ConstantValue>`
    Parameters:
      `cv` - the expression to evaluate
      `vals` - values of defined symbols
      `rc` - the resolution on which to evaluate it
    Returns:
      the result