Class AbstractAppender<T>

java.lang.Object
ghidra.app.util.pcode.AbstractAppender<T>
Type Parameters:
T - the type of output of the formatter
Direct Known Subclasses:
PcodeFrame.MyAppender, PcodeProgram.MyAppender

public abstract class AbstractAppender<T> extends Object
A base implementation of Appender suitable for most cases.
  • Field Details

    • language

      protected final Language language
    • indent

      protected final boolean indent
  • Constructor Details

    • AbstractAppender

      public AbstractAppender(Language language, boolean indent)
      Create a new appender.
      Parameters:
      language - the language of the p-code ops to format
      indent - whether or not to indent
  • Method Details

    • getLanguage

      public Language getLanguage()
    • appendAddressWordOffcut

      public void appendAddressWordOffcut(long wordOffset, long offcut)
    • appendCharacter

      public void appendCharacter(char c)
    • appendIndent

      public void appendIndent()
    • appendLabel

      public void appendLabel(String label)
    • appendLineLabelRef

      public void appendLineLabelRef(long label)
    • appendMnemonic

      public void appendMnemonic(int opcode)
    • appendRawVarnode

      public void appendRawVarnode(AddressSpace space, long offset, long size)
    • appendRegister

      public void appendRegister(Register register)
    • appendScalar

      public void appendScalar(long value)
    • appendSpace

      public void appendSpace(AddressSpace space)
    • appendString

      protected void appendString(String string)
      Append a plain string.

      By default, all append method delegate to this, so either it must be implemented, or every other append method must be overridden to avoid ever invoking this method. The default implementation throws an assertion error.

      Parameters:
      string - the string to append
    • appendUnique

      public void appendUnique(long offset)
    • appendUserop

      public void appendUserop(int id)
    • stringifyLineLabel

      protected String stringifyLineLabel(long label)
      Covert the given line label to a string as it should be conventionally displayed.
      Parameters:
      label - the label number
      Returns:
      the display string, e.g., <L1>
    • stringifyOpMnemonic

      protected String stringifyOpMnemonic(int opcode)
      Convert the given opcode to a string as it should be conventionally displayed.
      Parameters:
      opcode - the opcode
      Returns:
      the display string, i.e., its mnemonic
    • stringifyRawVarnode

      protected String stringifyRawVarnode(AddressSpace space, long offset, long size)
      Convert the given varnode to its raw conventional form.
      Parameters:
      space - the address space
      offset - the offset in the space
      size - the size in bytes
      Returns:
      the raw display string
    • stringifyRegister

      protected String stringifyRegister(Register register)
      Convert the given register to a string as it should be conventionally displayed.
      Parameters:
      register - the register
      Returns:
      the display string, i.e., its name
    • stringifyScalarValue

      protected String stringifyScalarValue(long value)
      Convert the given scalar to a string as it should be conventionally displayed.
      Parameters:
      value - the value
      Returns:
      the display string, i.e., its decimal value if small, or hex value is large
    • stringifySpace

      protected String stringifySpace(AddressSpace space)
      Convert the given address space to a string as it should be conventionally displayed.
      Parameters:
      space - the address space
      Returns:
      the display string, i.e., its name
    • stringifyUnique

      protected String stringifyUnique(long offset)
      Convert a given unique variable to a string as it should be conventionally displayed.
      Parameters:
      offset - the variable's offset
      Returns:
      the display string, e.g., $U1234
    • stringifyUseropUnchecked

      protected String stringifyUseropUnchecked(Language language, int id)
      Lookup a given userop name
      Parameters:
      language - the language containing the userop
      id - the userop id
      Returns:
      the display string, i.e., its name, or null if it doesn't exist
    • stringifyUserop

      protected String stringifyUserop(Language language, int id)
      Convert a given userop to a string as it should be conventionally displayed.
      Parameters:
      language - the langauge containing the userop
      id - the userop id
      Returns:
      the display string, i.e., its name or "unknown"
    • stringifyWordOffcut

      protected String stringifyWordOffcut(long wordOffset, long offcut)
      Convert a given word-offcut style address to a string as it should be conventionally displayed.
      Parameters:
      wordOffset - the offset of the word in memory
      offcut - the byte "offcut" within the word
      Returns:
      the display string, e.g., 0x1234.1
    • appendLineLabel

      default void appendLineLabel(long label)
      Append a line label, usually meant to be on its own line
      Parameters:
      label - the label number
    • finish

      T finish()
      Finish formatting and return the final result
      Returns:
      the final result