Package ghidra.app.util.pcode
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
A base implementation of
Appender
suitable for most cases.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
appendAddressWordOffcut
(long wordOffset, long offcut) void
appendCharacter
(char c) void
void
appendLabel
(String label) default void
appendLineLabel
(long label) Append a line label, usually meant to be on its own linevoid
appendLineLabelRef
(long label) void
appendMnemonic
(int opcode) void
appendRawVarnode
(AddressSpace space, long offset, long size) void
appendRegister
(Register register) void
appendScalar
(long value) void
appendSpace
(AddressSpace space) protected void
appendString
(String string) Append a plain string.void
appendUnique
(long offset) void
appendUserop
(int id) finish()
Finish formatting and return the final resultprotected String
stringifyLineLabel
(long label) Covert the given line label to a string as it should be conventionally displayed.protected String
stringifyOpMnemonic
(int opcode) Convert the given opcode to a string as it should be conventionally displayed.protected String
stringifyRawVarnode
(AddressSpace space, long offset, long size) Convert the given varnode to its raw conventional form.protected String
stringifyRegister
(Register register) Convert the given register to a string as it should be conventionally displayed.protected String
stringifyScalarValue
(long value) Convert the given scalar to a string as it should be conventionally displayed.protected String
stringifySpace
(AddressSpace space) Convert the given address space to a string as it should be conventionally displayed.protected String
stringifyUnique
(long offset) Convert a given unique variable to a string as it should be conventionally displayed.protected String
stringifyUserop
(Language language, int id) Convert a given userop to a string as it should be conventionally displayed.protected String
stringifyUseropUnchecked
(Language language, int id) Lookup a given userop nameprotected String
stringifyWordOffcut
(long wordOffset, long offcut) Convert a given word-offcut style address to a string as it should be conventionally displayed.
-
Field Details
-
language
-
indent
protected final boolean indent
-
-
Constructor Details
-
AbstractAppender
Create a new appender.- Parameters:
language
- the language of the p-code ops to formatindent
- whether or not to indent
-
-
Method Details
-
getLanguage
-
appendAddressWordOffcut
public void appendAddressWordOffcut(long wordOffset, long offcut) -
appendCharacter
public void appendCharacter(char c) -
appendIndent
public void appendIndent() -
appendLabel
-
appendLineLabelRef
public void appendLineLabelRef(long label) -
appendMnemonic
public void appendMnemonic(int opcode) -
appendRawVarnode
-
appendRegister
-
appendScalar
public void appendScalar(long value) -
appendSpace
-
appendString
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
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
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
Convert the given varnode to its raw conventional form.- Parameters:
space
- the address spaceoffset
- the offset in the spacesize
- the size in bytes- Returns:
- the raw display string
-
stringifyRegister
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
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
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
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
Lookup a given userop name- Parameters:
language
- the language containing the useropid
- the userop id- Returns:
- the display string, i.e., its name, or null if it doesn't exist
-
stringifyUserop
Convert a given userop to a string as it should be conventionally displayed.- Parameters:
language
- the langauge containing the useropid
- the userop id- Returns:
- the display string, i.e., its name or "unknown"
-
stringifyWordOffcut
Convert a given word-offcut style address to a string as it should be conventionally displayed.- Parameters:
wordOffset
- the offset of the word in memoryoffcut
- 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
-