decompiler
1.0.0
|
A token/command object in the pretty printing stream. More...
#include <prettyprint.hh>
Public Types | |
enum | printclass { begin, end, tokenstring, tokenbreak, begin_indent, end_indent, begin_comment, end_comment, ignore } |
An enumeration denoting the general class of a token. More... | |
enum | tag_type { docu_b, docu_e, func_b, func_e, bloc_b, bloc_e, rtyp_b, rtyp_e, vard_b, vard_e, stat_b, stat_e, prot_b, prot_e, vari_t, op_t, fnam_t, type_t, field_t, comm_t, label_t, synt_t, opar_t, cpar_t, oinv_t, cinv_t, spac_t, bump_t, line_t } |
The exhaustive list of possible token types. More... | |
Public Member Functions | |
TokenSplit (void) | |
Constructor. | |
int4 | beginDocument (void) |
Create a "begin document" command. More... | |
void | endDocument (int4 id) |
Create an "end document" command. More... | |
int4 | beginFunction (const Funcdata *f) |
Create a "begin function body" command. More... | |
void | endFunction (int4 id) |
Create an "end function body" command. More... | |
int4 | beginBlock (const FlowBlock *b) |
Create a "begin control-flow element" command. More... | |
void | endBlock (int4 id) |
Create an "end control-flow element" command. More... | |
int4 | beginReturnType (const Varnode *v) |
Create a "begin return type declaration" command. More... | |
void | endReturnType (int4 id) |
Create an "end return type declaration" command. More... | |
int4 | beginVarDecl (const Symbol *sym) |
Create a "begin variable declaration" command. More... | |
void | endVarDecl (int4 id) |
Create an "end variable declaration" command. More... | |
int4 | beginStatement (const PcodeOp *o) |
Create a "begin source code statement" command. More... | |
void | endStatement (int4 id) |
Create an "end source code statement" command. More... | |
int4 | beginFuncProto (void) |
Create a "begin function prototype declaration" command. More... | |
void | endFuncProto (int4 id) |
Create an "end function prototype declaration" command. More... | |
void | tagVariable (const string &name, EmitMarkup::syntax_highlight h, const Varnode *v, const PcodeOp *o) |
Create a variable identifier token. More... | |
void | tagOp (const string &name, EmitMarkup::syntax_highlight h, const PcodeOp *o) |
Create an operator token. More... | |
void | tagFuncName (const string &name, EmitMarkup::syntax_highlight h, const Funcdata *f, const PcodeOp *o) |
Create a function identifier token. More... | |
void | tagType (const string &name, EmitMarkup::syntax_highlight h, const Datatype *ct) |
Create a data-type identifier token. More... | |
void | tagField (const string &name, EmitMarkup::syntax_highlight h, const Datatype *ct, int4 o, const PcodeOp *inOp) |
Create an identifier for a field within a structured data-type. More... | |
void | tagComment (const string &name, EmitMarkup::syntax_highlight h, const AddrSpace *s, uintb o) |
Create a comment string in the generated source code. More... | |
void | tagLabel (const string &name, EmitMarkup::syntax_highlight h, const AddrSpace *s, uintb o) |
Create a code label identifier token. More... | |
void | print (const string &data, EmitMarkup::syntax_highlight h) |
Create a token for other (more unusual) syntax in source code. More... | |
void | openParen (const string &paren, int4 id) |
Create an open parenthesis. More... | |
void | closeParen (const string &paren, int4 id) |
Create a close parenthesis. More... | |
int4 | openGroup (void) |
Create a "start a printing group" command. More... | |
void | closeGroup (int4 id) |
Create an "end a printing group" command. More... | |
int4 | startIndent (int4 bump) |
Create a "start a new indent level" command. More... | |
void | stopIndent (int4 id) |
Create an "end an indent level" command. More... | |
int4 | startComment (void) |
Create a "start a comment block" command. More... | |
void | stopComment (int4 id) |
Create an "end a comment block" command. More... | |
void | spaces (int4 num, int4 bump) |
Create a whitespace token. More... | |
void | tagLine (void) |
Create a line break token. | |
void | tagLine (int4 indent) |
Create a line break token with special indentation. | |
void | print (Emit *emit) const |
Send this token to emitter. More... | |
int4 | getIndentBump (void) const |
Get the extra indent after a line break. | |
int4 | getNumSpaces (void) const |
Get the number of characters of whitespace. | |
int4 | getSize (void) const |
Get the number of content characters. | |
void | setSize (int4 sz) |
Set the number of content characters. | |
printclass | getClass (void) const |
Get the print class of this. | |
tag_type | getTag (void) const |
Get this tag type. | |
Private Attributes | |
tag_type | tagtype |
Type of token. | |
printclass | delimtype |
The general class of the token. | |
string | tok |
Characters of token (if any) | |
EmitMarkup::syntax_highlight | hl |
Highlighting for token. | |
const PcodeOp * | op |
Pcode-op associated with this token. | |
union { | |
const Varnode * vn | |
Associated Varnode. | |
const FlowBlock * bl | |
Associated Control-flow. | |
const Funcdata * fd | |
Associated Function. | |
const Datatype * ct | |
Associated Data-type. | |
const AddrSpace * spc | |
Associated Address. | |
const Symbol * symbol | |
Associated Symbol being displayed. | |
} | ptr_second |
Additional markup associated with the token. | |
uintb | off |
Offset associated either with address or field markup. | |
int4 | indentbump |
Amount to indent if a line breaks. | |
int4 | numspaces |
Number of spaces in a whitespace token (tokenbreak) | |
int4 | size |
Number of content characters or other size information. | |
int4 | count |
Associated id (for matching begin/end pairs) | |
Static Private Attributes | |
static int4 | countbase = 0 |
Static counter for uniquely assigning begin/end pair ids. | |
A token/command object in the pretty printing stream.
The pretty printing algorithm (see EmitPrettyPrint) works on the stream of tokens, constituting the content actually being output, plus additional embedded commands made up begin/end or open/close pairs that delimit the (hierarchy of) groups of tokens that should be printed as a unit. Instances of this class represent all the possible elements of this stream.
All instances exhibit a broad printclass that generally reflects whether the token is one of the begin/end delimiters or is actual content. Instances also have a tag_type that indicate the specific function of the token within the stream, which mirror the begin/end/open/close/tag methods on the emitter classes (EmitMarkup).
An enumeration denoting the general class of a token.
The exhaustive list of possible token types.
|
inline |
Create a "begin control-flow element" command.
b | is the block structure object associated with the section |
Referenced by ghidra::EmitPrettyPrint::beginBlock().
|
inline |
Create a "begin document" command.
Referenced by ghidra::EmitPrettyPrint::beginDocument().
|
inline |
Create a "begin function prototype declaration" command.
Referenced by ghidra::EmitPrettyPrint::beginFuncProto().
|
inline |
Create a "begin function body" command.
Referenced by ghidra::EmitPrettyPrint::beginFunction().
|
inline |
Create a "begin return type declaration" command.
v | (if non-null) is the storage location for the return value |
Referenced by ghidra::EmitPrettyPrint::beginReturnType().
|
inline |
Create a "begin source code statement" command.
o | is the root p-code operation of the statement |
Referenced by ghidra::EmitPrettyPrint::beginStatement().
|
inline |
Create a "begin variable declaration" command.
sym | is the symbol being declared |
Referenced by ghidra::EmitPrettyPrint::beginVarDecl().
|
inline |
Create an "end a printing group" command.
id | is the id associated with the group (as returned by openGroup) |
Referenced by ghidra::EmitPrettyPrint::closeGroup().
|
inline |
Create a close parenthesis.
paren | is the close parenthesis character to emit |
id | is the id associated with the matching open parenthesis (as returned by openParen) |
Referenced by ghidra::EmitPrettyPrint::closeParen().
|
inline |
Create an "end control-flow element" command.
id | is the id associated with the section (as returned by beginBlock) |
Referenced by ghidra::EmitPrettyPrint::endBlock().
|
inline |
Create an "end document" command.
id | is the id associated with the document (as returned by beginDocument) |
Referenced by ghidra::EmitPrettyPrint::endDocument().
|
inline |
Create an "end function prototype declaration" command.
id | is the id associated with the prototype (as returned by beginFuncProto) |
Referenced by ghidra::EmitPrettyPrint::endFuncProto().
|
inline |
Create an "end function body" command.
id | is the id associated with the function body (as returned by beginFunction) |
Referenced by ghidra::EmitPrettyPrint::endFunction().
|
inline |
Create an "end return type declaration" command.
id | is the id associated with the return type (as returned by beginReturnType) |
Referenced by ghidra::EmitPrettyPrint::endReturnType().
|
inline |
Create an "end source code statement" command.
id | is the id associated with the statement (as returned by beginStatement) |
Referenced by ghidra::EmitPrettyPrint::endStatement().
|
inline |
Create an "end variable declaration" command.
id | is the id associated with the declaration (as returned by beginVarDecl) |
Referenced by ghidra::EmitPrettyPrint::endVarDecl().
|
inline |
Create a "start a printing group" command.
Referenced by ghidra::EmitPrettyPrint::openGroup().
|
inline |
Create an open parenthesis.
paren | is the open parenthesis character to emit |
id | is an id to associate with the parenthesis |
Referenced by ghidra::EmitPrettyPrint::openParen().
|
inline |
Create a token for other (more unusual) syntax in source code.
data | is the character data of the syntax being emitted |
h | indicates how the syntax should be highlighted |
Referenced by ghidra::EmitPrettyPrint::checkbreak(), ghidra::EmitPrettyPrint::checkend(), and ghidra::EmitPrettyPrint::print().
void ghidra::TokenSplit::print | ( | Emit * | emit | ) | const |
Send this token to emitter.
Emit markup or content corresponding to this token on a low-level emitter. The API method matching the token type is called, feeding it content contained in the object.
emit | is the low-level emitter to output to |
References ghidra::Emit::beginBlock(), ghidra::Emit::beginDocument(), ghidra::Emit::beginFuncProto(), ghidra::Emit::beginFunction(), ghidra::Emit::beginReturnType(), ghidra::Emit::beginStatement(), ghidra::Emit::beginVarDecl(), ghidra::Emit::closeParen(), ghidra::Emit::endBlock(), ghidra::Emit::endDocument(), ghidra::Emit::endFuncProto(), ghidra::Emit::endFunction(), ghidra::Emit::endReturnType(), ghidra::Emit::endStatement(), ghidra::Emit::endVarDecl(), ghidra::Emit::openParen(), ghidra::Emit::print(), ghidra::Emit::spaces(), ghidra::Emit::tagComment(), ghidra::Emit::tagField(), ghidra::Emit::tagFuncName(), ghidra::Emit::tagLabel(), ghidra::Emit::tagOp(), ghidra::Emit::tagType(), and ghidra::Emit::tagVariable().
|
inline |
Create a whitespace token.
num | is the number of space characters to emit |
bump | is the number of characters to indent if the spaces force a line break |
Referenced by ghidra::EmitPrettyPrint::checkstart(), ghidra::EmitPrettyPrint::checkstring(), and ghidra::EmitPrettyPrint::spaces().
|
inline |
Create a "start a comment block" command.
Referenced by ghidra::EmitPrettyPrint::startComment().
|
inline |
Create a "start a new indent level" command.
bump | the number of additional characters to indent |
Referenced by ghidra::EmitPrettyPrint::startIndent().
|
inline |
Create an "end a comment block" command.
id | is the id associated with the block (as returned by startComment) |
Referenced by ghidra::EmitPrettyPrint::stopComment().
|
inline |
Create an "end an indent level" command.
id | is the id associated with the nesting (as returned by startIndent) |
Referenced by ghidra::EmitPrettyPrint::stopIndent().
|
inline |
Create a comment string in the generated source code.
name | is the character data for the comment |
h | indicates how the comment should be highlighted |
s | is the address space of the address where the comment is attached |
o | is the offset of the address where the comment is attached |
Referenced by ghidra::EmitPrettyPrint::tagComment().
|
inline |
Create an identifier for a field within a structured data-type.
name | is the character data for the identifier |
h | indicates how the identifier should be highlighted |
ct | is the data-type associated with the field |
o | is the (byte) offset of the field within its structured data-type |
inOp | is the PcodeOp associated with the field (usually PTRSUB or SUBPIECE) |
Referenced by ghidra::EmitPrettyPrint::tagField().
|
inline |
Create a function identifier token.
name | is the character data for the identifier |
h | indicates how the identifier should be highlighted |
f | is the function |
o | is the CALL operation associated within the syntax tree or null for a declaration |
Referenced by ghidra::EmitPrettyPrint::tagFuncName().
|
inline |
Create a code label identifier token.
name | is the character data of the label |
h | indicates how the label should be highlighted |
s | is the address space of the code address being labeled |
o | is the offset of the code address being labeled |
Referenced by ghidra::EmitPrettyPrint::tagLabel().
|
inline |
Create an operator token.
name | is the character data for the emitted representation |
h | indicates how the token should be highlighted |
o | is the PcodeOp object associated with the operation with the syntax tree |
Referenced by ghidra::EmitPrettyPrint::tagOp().
|
inline |
Create a data-type identifier token.
name | is the character data for the identifier |
h | indicates how the identifier should be highlighted |
ct | is the data-type description object |
Referenced by ghidra::EmitPrettyPrint::tagType().
|
inline |
Create a variable identifier token.
name | is the character data for the identifier |
h | indicates how the identifier should be highlighted |
v | is the Varnode representing the variable within the syntax tree |
o | is a p-code operation related to the use of the variable (may be null) |
Referenced by ghidra::EmitPrettyPrint::tagVariable().