Class AssemblyResolution

java.lang.Object
ghidra.app.plugin.assembler.sleigh.sem.AssemblyResolution
All Implemented Interfaces:
Comparable<AssemblyResolution>
Direct Known Subclasses:
AssemblyResolvedBackfill, AssemblyResolvedError, AssemblyResolvedPatterns

public abstract class AssemblyResolution extends Object implements Comparable<AssemblyResolution>
The (often intermediate) result of assembly

These may represent a successful construction (AssemblyResolvedPatterns, a future field (AssemblyResolvedBackfill), or an error (AssemblyResolvedError).

This class also provides the static factory methods for constructing any of its subclasses.

  • Field Details

  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • computeHash

      protected abstract int computeHash()
    • resolved

      public static AssemblyResolvedPatterns resolved(AssemblyPatternBlock ins, AssemblyPatternBlock ctx, String description, Constructor cons, List<? extends AssemblyResolution> children, AssemblyResolution right)
      Build the result of successfully resolving a SLEIGH constructor

      NOTE: This is not used strictly for resolved SLEIGH constructors. It may also be used to store intermediates, e.g., encoded operands, during constructor resolution.

      Parameters:
      ins - the instruction pattern block
      ctx - the context pattern block
      description - a description of the resolution
      cons - the constructor, or null
      children - the children of this constructor, or null
      Returns:
      the new resolution
    • instrOnly

      public static AssemblyResolvedPatterns instrOnly(AssemblyPatternBlock ins, String description)
      Build an instruction-only successful resolution result
      Parameters:
      ins - the instruction pattern block
      description - a description of the resolution
      Returns:
      the new resolution
      See Also:
    • contextOnly

      public static AssemblyResolvedPatterns contextOnly(AssemblyPatternBlock ctx, String description)
      Build a context-only successful resolution result
      Parameters:
      ctx - the context pattern block
      description - a description of the resolution
      Returns:
      the new resolution
      See Also:
    • fromPattern

      public static AssemblyResolvedPatterns fromPattern(DisjointPattern pat, int minLen, String description, Constructor cons)
      Build a successful resolution result from a SLEIGH constructor's patterns
      Parameters:
      pat - the constructor's pattern
      description - a description of the resolution
      Returns:
      the new resolution
    • backfill

      public static AssemblyResolvedBackfill backfill(PatternExpression exp, MaskedLong goal, int inslen, String description)
      Build a backfill record to attach to a successful resolution result
      Parameters:
      exp - the expression depending on a missing symbol
      goal - the desired value of the expression
      inslen - the length of instruction portion expected in the future solution
      description - a description of the backfill record
      Returns:
      the new record
    • nop

      public static AssemblyResolvedPatterns nop(String description, List<? extends AssemblyResolution> children, AssemblyResolution right)
      Obtain a new "blank" resolved SLEIGH constructor record
      Parameters:
      description - a description of the resolution
      children - any children that will be involved in populating this record
      Returns:
      the new resolution
    • nop

      public static AssemblyResolvedPatterns nop(String description)
      Obtain a new "blank" resolved SLEIGH constructor record
      Parameters:
      description - a description of the resolution
      Returns:
      the new resolution
    • error

      public static AssemblyResolvedError error(String error, String description, List<? extends AssemblyResolution> children, AssemblyResolution right)
      Build an error resolution record
      Parameters:
      error - a description of the error
      description - a description of what the resolver was doing when the error ocurred
      children - any children involved in generating the error
      Returns:
      the new resolution
    • error

      public static AssemblyResolvedError error(String error, String description)
      Build an error resolution record
      Parameters:
      error - a description of the error
      description - a description of what the resolver was doing when the error occurred
      Returns:
      the new resolution
    • error

      public static AssemblyResolution error(String error, AssemblyResolvedPatterns res)
      Build an error resolution record, based on an intermediate SLEIGH constructor record
      Parameters:
      error - a description of the error
      res - the constructor record that was being populated when the error ocurred
      Returns:
      the new error resolution
    • isError

      public abstract boolean isError()
      Check if this record describes an error
      Returns:
      true if the record is an error
    • isBackfill

      public abstract boolean isBackfill()
      Check if this record describes a backfill
      Returns:
      true if the record is a backfill
    • lineToString

      protected abstract String lineToString()
      Display the resolution result in one line (omitting child details)
      Returns:
      the display description
    • getAllRight

      protected List<AssemblyResolution> getAllRight()
    • collectAllRight

      protected void collectAllRight(Collection<AssemblyResolution> into)
    • childrenToString

      protected String childrenToString(String indent)
      Get the child portion of toString()

      If a subclass has another, possible additional, notion of children that it would like to include in toString(), it must override this method.

      Parameters:
      indent - the current indentation
      Returns:
      the indented description for each child on its own line
      See Also:
    • toString

      public String toString(String indent)
      Used only by parents: get a multi-line description of this record, indented
      Parameters:
      indent - the current indentation
      Returns:
      the indented description
    • toString

      public String toString()
      Describe this record including indented children, grandchildren, etc., each on its own line
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(AssemblyResolution that)
      Specified by:
      compareTo in interface Comparable<AssemblyResolution>
    • hasChildren

      public boolean hasChildren()
      Check if this record has children

      If a subclass has another, possibly additional, notion of children that it would like to include in toString(), it must override this method to return true when such children are present.

      Returns:
      true if this record has children
      See Also:
    • shift

      public abstract AssemblyResolution shift(int amt)
      Shift the resolution's instruction pattern to the right, if applicable

      This also shifts any backfill and forbidden pattern records.

      Parameters:
      amt - the number of bytes to shift.
      Returns:
      the result
    • withoutRight

      public AssemblyResolution withoutRight()
      Get this same resolution, but without any right siblings
      Returns:
      the resolution
    • withRight

      public abstract AssemblyResolution withRight(AssemblyResolution right)
      Get this same resolution, but with the given right sibling
      Returns:
      the resolution
    • parent

      public abstract AssemblyResolution parent(String description, int opCount)
      Get this same resolution, pushing its right siblings down to its children