Class AbstractExpressionSolver<T extends PatternExpression>

    • 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 solve
        goal - the desired value of the expression
        vals - values of defined symbols
        res - the results of subconstructor resolutions (used for lengths)
        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,
                                            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 expression
        vals - values of defined symbols
        res - 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 expression
        res - 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 evaluate
        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