Class AssemblyTreeResolver

  • public class AssemblyTreeResolver
    extends java.lang.Object
    The workhorse of semantic resolution for the assembler This class takes a parse tree and some additional information (start address, context, etc.) and attempts to determine possible encodings using the semantics associated with each branch of the given parse tree. Details of this process are described in SleighAssemblerBuilder.
    See Also:
    • Constructor Detail

      • AssemblyTreeResolver

        public AssemblyTreeResolver​(SleighLanguage lang,
                                    long instStart,
                                    AssemblyParseBranch tree,
                                    AssemblyPatternBlock context,
                                    AssemblyContextGraph ctxGraph)
        Construct a resolver for the given parse tree
        lang -
        instStart - the byte offset where the instruction will start
        tree - the parse tree
        context - the context expected at instStart
        ctxGraph - the context transition graph used to resolve purely-recursive productions
    • Method Detail

      • resolve

        public AssemblyResolutionResults resolve()
        Resolve the tree for the given parameters
        a set of resolutions (encodings and errors)
      • applyRecursionPath

        protected AssemblyResolutionResults applyRecursionPath​(java.util.Deque<AssemblyConstructorSemantic> path,
                                                               AssemblyParseBranch branch,
                                                               AssemblyProduction rec,
                                                               AssemblyResolvedConstructor child)
        Apply constructors as indicated by a path returned by the context resolution graph Please note: The path given will be emptied during processing.
        path - the path to apply
        branch - the branch corresponding to the production whose LHS has a purely-recursive definition.
        rec - the purely-recursive production
        child - the intermediate result to apply the constructors to
        the results
      • resolveBranchRecursive

        protected AssemblyResolutionResults resolveBranchRecursive​(AssemblyParseBranch branch,
                                                                   AssemblyProduction rec)
        Resolve a branch where the production's LHS has a purely-recursive definition
        branch - the branch
        rec - the purely-recursive definition
        the results
      • resolveSelectedChildren

        protected AssemblyResolutionResults resolveSelectedChildren​(AssemblyProduction prod,
                                                                    java.util.List<AssemblyParseTreeNode> substs,
                                                          <AssemblyResolvedConstructor> sel,
                                                                    java.util.Collection<AssemblyConstructorSemantic> semantics)
        Resolve the given branch, having selected a particular combination of subconstructor results
        prod - the production
        substs - the braches and tokens corrresponding to the symbols of the production's RHS
        sel - the selected subconstructor results
        semantics - the collection of possible constructors for this production
        the results
      • resolveBranchNonRecursive

        protected AssemblyResolutionResults resolveBranchNonRecursive​(AssemblyParseBranch branch)
        Resolve a branch without considering any purely-recursive productions This method is used either when the LHS has no purely-recursive definition, or before considering the purely-recursive definition when it is present.
        branch - the branch
        the results
      • computeOffset

        public static int computeOffset​(OperandSymbol opsym,
                                        Constructor cons,
                                        java.util.Map<java.lang.Integer,​java.lang.Object> res)
        Compute the offset of an operand encoded in the instruction block
        opsym - the operand symbol
        cons - the constructor containing the operand
        res - the selected subconstructor encodings
        the offset (right shift) to apply to the encoded operand
      • solveOrBackfill

        protected static AssemblyResolution solveOrBackfill​(PatternExpression 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.lang.String description)
        Attempt to solve an expression
        exp - the expression to solve
        goal - the desired value of the expression
        vals - any defined symbols
        res - the selected subconstructor encodings
        cur - the resolved constructor so far
        description - a description of the result
        the encoded solution, or a backfill record