decompiler  1.0.0
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ghidra::Emit Class Referenceabstract

Interface for emitting the Decompiler's formal output: source code. More...

#include <prettyprint.hh>

Inheritance diagram for ghidra::Emit:
ghidra::EmitMarkup ghidra::EmitNoMarkup ghidra::EmitPrettyPrint

Public Types

enum  syntax_highlight {
  keyword_color = 0, comment_color = 1, type_color = 2, funcname_color = 3,
  var_color = 4, const_color = 5, param_color = 6, global_color = 7,
  no_color = 8, error_color = 9, special_color = 10
}
 Possible types of syntax highlighting. More...
 

Public Member Functions

 Emit (void)
 
virtual ~Emit (void)
 Destructor.
 
virtual int4 beginDocument (void)=0
 Begin a whole document of output. More...
 
virtual void endDocument (int4 id)=0
 End a whole document of output. More...
 
virtual int4 beginFunction (const Funcdata *fd)=0
 Begin a whole declaration and body of a function. More...
 
virtual void endFunction (int4 id)=0
 End a whole declaration and body of a function. More...
 
virtual int4 beginBlock (const FlowBlock *bl)=0
 Begin a control-flow element. More...
 
virtual void endBlock (int4 id)=0
 End a control-flow element. More...
 
virtual void tagLine (void)=0
 Force a line break. More...
 
virtual void tagLine (int4 indent)=0
 Force a line break and indent level. More...
 
virtual int4 beginReturnType (const Varnode *vn)=0
 Begin a return type declaration. More...
 
virtual void endReturnType (int4 id)=0
 End a return type declaration. More...
 
virtual int4 beginVarDecl (const Symbol *sym)=0
 Begin a variable declaration. More...
 
virtual void endVarDecl (int4 id)=0
 End a variable declaration. More...
 
virtual int4 beginStatement (const PcodeOp *op)=0
 Begin a source code statement. More...
 
virtual void endStatement (int4 id)=0
 End a source code statement. More...
 
virtual int4 beginFuncProto (void)=0
 Begin a function prototype declaration. More...
 
virtual void endFuncProto (int4 id)=0
 End a function prototype declaration. More...
 
virtual void tagVariable (const string &name, syntax_highlight hl, const Varnode *vn, const PcodeOp *op)=0
 Emit a variable token. More...
 
virtual void tagOp (const string &name, syntax_highlight hl, const PcodeOp *op)=0
 Emit an operation token. More...
 
virtual void tagFuncName (const string &name, syntax_highlight hl, const Funcdata *fd, const PcodeOp *op)=0
 Emit a function identifier. More...
 
virtual void tagType (const string &name, syntax_highlight hl, const Datatype *ct)=0
 Emit a data-type identifier. More...
 
virtual void tagField (const string &name, syntax_highlight hl, const Datatype *ct, int4 off, const PcodeOp *op)=0
 Emit an identifier for a field within a structured data-type. More...
 
virtual void tagComment (const string &name, syntax_highlight hl, const AddrSpace *spc, uintb off)=0
 Emit a comment string as part of the generated source code. More...
 
virtual void tagLabel (const string &name, syntax_highlight hl, const AddrSpace *spc, uintb off)=0
 Emit a code label identifier. More...
 
virtual void print (const string &data, syntax_highlight hl=no_color)=0
 Emit other (more unusual) syntax as part of source code generation. More...
 
virtual int4 openParen (const string &paren, int4 id=0)=0
 Emit an open parenthesis. More...
 
virtual void closeParen (const string &paren, int4 id)=0
 Emit a close parenthesis. More...
 
virtual int4 openGroup (void)
 Start a group of things that are printed together. More...
 
virtual void closeGroup (int4 id)
 End a group of things that are printed together. More...
 
virtual void clear (void)
 Reset the emitter to its initial state.
 
virtual void setOutputStream (ostream *t)=0
 Set the output stream for the emitter.
 
virtual ostream * getOutputStream (void) const =0
 Get the current output stream.
 
virtual void spaces (int4 num, int4 bump=0)
 Emit a sequence of space characters as part of source code. More...
 
virtual int4 startIndent (void)
 Start a new indent level. More...
 
virtual void stopIndent (int4 id)
 End an indent level. More...
 
virtual int4 startComment (void)
 Start a comment block within the emitted source code. More...
 
virtual void stopComment (int4 id)
 End a comment block. More...
 
virtual void flush (void)
 Flush any remaining character data. More...
 
virtual void setMaxLineSize (int4 mls)
 Provide a maximum line size to the pretty printer. More...
 
virtual int4 getMaxLineSize (void) const
 Get the current maximum line size. More...
 
virtual void setCommentFill (const string &fill)
 Set the comment fill characters for when line breaks are forced. More...
 
virtual bool emitsMarkup (void) const =0
 Determine if this is an XML markup emitter. More...
 
virtual void resetDefaults (void)
 (Re)set the default emitting options
 
int4 getParenLevel (void) const
 Get the current parentheses depth. More...
 
int4 getIndentIncrement (void) const
 Get the number of characters indented per level of nesting. More...
 
void setIndentIncrement (int4 val)
 Set the number of characters indented per level of nesting. More...
 
void setPendingPrint (PendPrint *pend)
 Set a pending print callback. More...
 
void cancelPendingPrint (void)
 Cancel any pending print callback. More...
 
bool hasPendingPrint (PendPrint *pend) const
 Check if the given print callback is still pending. More...
 

Static Public Attributes

static const string EMPTY_STRING = ""
 An empty string.
 

Protected Member Functions

void resetDefaultsInternal (void)
 Set options to default values for EmitMarkup.
 
void emitPending (void)
 Emit any pending print commands.
 

Protected Attributes

int4 indentlevel
 Current indent level (in fixed width characters)
 
int4 parenlevel
 Current depth of parentheses.
 
int4 indentincrement
 Change in indentlevel per level of nesting.
 
PendPrintpendPrint
 Pending print callback.
 

Detailed Description

Interface for emitting the Decompiler's formal output: source code.

There are two basic functions being implemented through this interface:

Markup: allows recording of the natural grouping of the high-level tokens and directly links the nodes of the abstract syntax tree to the emitted tokens.

Pretty printing: Line breaks and additional white space characters are inserted within the emitted source code to enforce a maximum number of characters per line while minimizing breaks in important groups of syntax. Where extra line breaks are necessary, additional indenting is provided to reduce the impact on readability.

All printing must be surrounded by at least one begin and end tag pair:

Additional printing groups can be specified with tag pairs:

The tag* functions, emit the actual language tokens, supplying appropriate markup.

For an implementation that actually does pretty printing, see EmitPrettyPrint.

Member Enumeration Documentation

◆ syntax_highlight

Possible types of syntax highlighting.

Values must match constants in ClangToken

Enumerator
keyword_color 

Keyword in the high-level language.

comment_color 

Comments.

type_color 

Data-type identifiers.

funcname_color 

Function identifiers.

var_color 

Local variable identifiers.

const_color 

Constant values.

param_color 

Function parameters.

global_color 

Global variable identifiers.

no_color 

Un-highlighted.

error_color 

Indicates a warning or error state.

special_color 

A token with special/highlighted meaning.

Constructor & Destructor Documentation

◆ Emit()

ghidra::Emit::Emit ( void  )
inline

Constructor

References resetDefaultsInternal().

Member Function Documentation

◆ beginBlock()

virtual int4 ghidra::Emit::beginBlock ( const FlowBlock bl)
pure virtual

Begin a control-flow element.

Inform the emitter that a new control-flow section is starting. This is a source code unit usually surrounded with curly braces '{' and '}'.

Parameters
blis the block structure object associated with the section
Returns
an id associated with the section

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitBlockCondition(), ghidra::PrintC::emitBlockDoWhile(), ghidra::PrintC::emitBlockGraph(), ghidra::PrintC::emitBlockIf(), ghidra::PrintC::emitBlockInfLoop(), ghidra::PrintC::emitBlockLs(), ghidra::PrintC::emitBlockSwitch(), ghidra::PrintC::emitBlockWhileDo(), ghidra::PrintC::emitForLoop(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ beginDocument()

virtual int4 ghidra::Emit::beginDocument ( void  )
pure virtual

Begin a whole document of output.

Inform the emitter that generation of the source code document has begun

Returns
an id associated with the document

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::docAllGlobals(), ghidra::PrintC::docSingleGlobal(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ beginFuncProto()

virtual int4 ghidra::Emit::beginFuncProto ( void  )
pure virtual

Begin a function prototype declaration.

Inform the emitter that a function prototype is starting.

Returns
an id associated with the prototype

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitFunctionDeclaration(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ beginFunction()

virtual int4 ghidra::Emit::beginFunction ( const Funcdata fd)
pure virtual

Begin a whole declaration and body of a function.

Inform the emitter that generation of a function body has begun

Returns
an id associated with the function body

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::docFunction(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ beginReturnType()

virtual int4 ghidra::Emit::beginReturnType ( const Varnode vn)
pure virtual

Begin a return type declaration.

Inform the emitter that generation of a function's return type is starting.

Parameters
vn(if non-null) is the storage location for the return value
Returns
an id associated with the return type

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::emitPrototypeOutput(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ beginStatement()

virtual int4 ghidra::Emit::beginStatement ( const PcodeOp op)
pure virtual

Begin a source code statement.

Inform the emitter that a source code statement is beginning.

Parameters
opis the root p-code operation of the statement
Returns
an id associated with the statement

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitBlockBasic(), ghidra::PrintC::emitForLoop(), ghidra::PrintC::emitGotoStatement(), ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::emitStatement(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ beginVarDecl()

virtual int4 ghidra::Emit::beginVarDecl ( const Symbol sym)
pure virtual

Begin a variable declaration.

Inform the emitter that a variable declaration has started.

Parameters
symis the symbol being declared
Returns
an id associated with the declaration

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::emitVarDecl(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ cancelPendingPrint()

void ghidra::Emit::cancelPendingPrint ( void  )
inline

Cancel any pending print callback.

If there is any print callback pending, cancel it

Referenced by ghidra::PrintC::emitBlockIf().

◆ closeGroup()

virtual void ghidra::Emit::closeGroup ( int4  id)
inlinevirtual

End a group of things that are printed together.

Inform the emitter that a printing group is ending.

Parameters
idis the id associated with the group (as returned by openGroup)

Reimplemented in ghidra::EmitPrettyPrint.

Referenced by ghidra::PrintC::emitFunctionDeclaration(), ghidra::PrintC::opCbranch(), and ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint().

◆ closeParen()

virtual void ghidra::Emit::closeParen ( const string &  paren,
int4  id 
)
pure virtual

Emit a close parenthesis.

This method emits the parenthesis character itself and ends the printing unit that was started by the matching open parenthesis.

Parameters
parenis the close parenthesis character to emit
idis the id associated with the matching open parenthesis (as returned by openParen)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitBlockCondition(), ghidra::PrintC::emitBlockInfLoop(), ghidra::PrintC::emitBlockWhileDo(), ghidra::PrintC::emitForLoop(), ghidra::PrintC::emitFunctionDeclaration(), ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::opBranchind(), ghidra::PrintC::opCbranch(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ emitsMarkup()

virtual bool ghidra::Emit::emitsMarkup ( void  ) const
pure virtual

Determine if this is an XML markup emitter.

Returns
true if this produces an XML markup of its emitted source code

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintLanguage::emitsMarkup(), ghidra::EmitPrettyPrint::emitsMarkup(), and setCommentFill().

◆ endBlock()

virtual void ghidra::Emit::endBlock ( int4  id)
pure virtual

◆ endDocument()

virtual void ghidra::Emit::endDocument ( int4  id)
pure virtual

End a whole document of output.

Inform the emitter that generation of the source code document is finished

Parameters
idis the id associated with the document (as returned by beginDocument)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::docAllGlobals(), ghidra::PrintC::docSingleGlobal(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ endFuncProto()

virtual void ghidra::Emit::endFuncProto ( int4  id)
pure virtual

End a function prototype declaration.

Inform the emitter that a function prototype is ending.

Parameters
idis the id associated with the prototype (as returned by beginFuncProto)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitFunctionDeclaration(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ endFunction()

virtual void ghidra::Emit::endFunction ( int4  id)
pure virtual

End a whole declaration and body of a function.

Inform the emitter that generation of a function body has ended

Parameters
idis the id associated with the function body (as returned by beginFunction)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::docFunction(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ endReturnType()

virtual void ghidra::Emit::endReturnType ( int4  id)
pure virtual

End a return type declaration.

Inform the emitter that generation of a function's return type is ending.

Parameters
idis the id associated with the return type (as returned by beginReturnType)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::emitPrototypeOutput(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ endStatement()

virtual void ghidra::Emit::endStatement ( int4  id)
pure virtual

End a source code statement.

Inform the emitter that a source code statement is ending.

Parameters
idis the id associated with the statement (as returned by beginStatement)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitBlockBasic(), ghidra::PrintC::emitForLoop(), ghidra::PrintC::emitGotoStatement(), ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::emitStatement(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ endVarDecl()

virtual void ghidra::Emit::endVarDecl ( int4  id)
pure virtual

End a variable declaration.

Inform the emitter that a variable declaration has ended.

Parameters
idis the id associated with the declaration (as returned by beginVarDecl)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::emitVarDecl(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ flush()

virtual void ghidra::Emit::flush ( void  )
inlinevirtual

Flush any remaining character data.

Depending on the particular emitter, tokens and syntax that have been submitted to the emitter may be held internally for a time before getting output to the final stream. This routine makes sure submitted syntax is fully output.

Reimplemented in ghidra::EmitPrettyPrint.

Referenced by ghidra::PrintC::docAllGlobals(), ghidra::PrintC::docFunction(), ghidra::PrintC::docSingleGlobal(), ghidra::EmitPrettyPrint::flush(), and ghidra::EmitPrettyPrint::getOutputStream().

◆ getIndentIncrement()

int4 ghidra::Emit::getIndentIncrement ( void  ) const
inline

Get the number of characters indented per level of nesting.

Returns
the number of characters

References indentincrement.

◆ getMaxLineSize()

virtual int4 ghidra::Emit::getMaxLineSize ( void  ) const
inlinevirtual

Get the current maximum line size.

If the emitter respects a maximum line size, return that size.

Returns
the maximum line size or -1 if the emitter does not have a maximum

Reimplemented in ghidra::EmitPrettyPrint.

◆ getParenLevel()

int4 ghidra::Emit::getParenLevel ( void  ) const
inline

Get the current parentheses depth.

Returns
the current number of open parenthetical groups

References parenlevel.

◆ hasPendingPrint()

bool ghidra::Emit::hasPendingPrint ( PendPrint pend) const
inline

Check if the given print callback is still pending.

Parameters
pendis the given print callback to check
Returns
true if the specific print callback is pending

Referenced by ghidra::PrintC::emitBlockIf().

◆ openGroup()

virtual int4 ghidra::Emit::openGroup ( void  )
inlinevirtual

Start a group of things that are printed together.

Inform the emitter that a new printing group is starting.

Returns
an id associated with the group

Reimplemented in ghidra::EmitPrettyPrint.

Referenced by ghidra::PrintC::emitFunctionDeclaration(), ghidra::PrintC::opCbranch(), and ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint().

◆ openParen()

virtual int4 ghidra::Emit::openParen ( const string &  paren,
int4  id = 0 
)
pure virtual

Emit an open parenthesis.

This method emits the parenthesis character itself and also starts a printing unit of the source code being surrounded by the parentheses.

Parameters
parenis the open parenthesis character to emit
idis an id to associate with the parenthesis
Returns
an id associated with the parenthesis

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitBlockCondition(), ghidra::PrintC::emitBlockInfLoop(), ghidra::PrintC::emitBlockWhileDo(), ghidra::PrintC::emitForLoop(), ghidra::PrintC::emitFunctionDeclaration(), ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::opBranchind(), ghidra::PrintC::opCbranch(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ print()

virtual void ghidra::Emit::print ( const string &  data,
syntax_highlight  hl = no_color 
)
pure virtual

◆ setCommentFill()

virtual void ghidra::Emit::setCommentFill ( const string &  fill)
inlinevirtual

Set the comment fill characters for when line breaks are forced.

If the pretty printer forces a line break in the middle of a comment, this string is emitted to provide proper syntax and indenting to continue the comment.

Parameters
fillis the set of fill characters

Reimplemented in ghidra::EmitPrettyPrint.

References emitsMarkup().

◆ setIndentIncrement()

void ghidra::Emit::setIndentIncrement ( int4  val)
inline

Set the number of characters indented per level of nesting.

Parameters
valis the desired number of characters to indent

Referenced by ghidra::PrintLanguage::setIndentIncrement().

◆ setMaxLineSize()

virtual void ghidra::Emit::setMaxLineSize ( int4  mls)
inlinevirtual

Provide a maximum line size to the pretty printer.

The emitter may insert line breaks to enforce this maximum.

Parameters
mlsis the number of characters to set for the maximum line size

Reimplemented in ghidra::EmitPrettyPrint.

Referenced by ghidra::EmitPrettyPrint::getOutputStream(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ghidra::PrintLanguage::setMaxLineSize().

◆ setPendingPrint()

void ghidra::Emit::setPendingPrint ( PendPrint pend)
inline

Set a pending print callback.

The callback will be issued prior to the the next call to tagLine() unless a the method cancelPendingPrint() is called first.

Parameters
pendis the callback to be issued

Referenced by ghidra::PrintC::emitBlockIf().

◆ spaces()

void ghidra::Emit::spaces ( int4  num,
int4  bump = 0 
)
virtual

◆ startComment()

virtual int4 ghidra::Emit::startComment ( void  )
inlinevirtual

Start a comment block within the emitted source code.

Inform the emitter that a set of comment tokens/lines is starting.

Returns
an id associated with the comment block

Reimplemented in ghidra::EmitPrettyPrint.

Referenced by ghidra::EmitPrettyPrint::getOutputStream().

◆ startIndent()

virtual int4 ghidra::Emit::startIndent ( void  )
inlinevirtual

◆ stopComment()

virtual void ghidra::Emit::stopComment ( int4  id)
inlinevirtual

End a comment block.

Inform the emitter that a set of comment tokens/lines is ending.

Parameters
idis the id associated with the block (as returned by startComment)

Reimplemented in ghidra::EmitPrettyPrint.

Referenced by ghidra::EmitPrettyPrint::getOutputStream().

◆ stopIndent()

virtual void ghidra::Emit::stopIndent ( int4  id)
inlinevirtual

End an indent level.

Inform the emitter that the current nesting has ended, and we are returning to the previous level.

Parameters
idis the id associated with the nesting (as returned by startIndent)

Reimplemented in ghidra::EmitPrettyPrint.

References indentincrement.

Referenced by ghidra::PrintC::docFunction(), ghidra::PrintC::emitBlockDoWhile(), ghidra::PrintC::emitBlockIf(), ghidra::PrintC::emitBlockInfLoop(), ghidra::PrintC::emitBlockSwitch(), ghidra::PrintC::emitBlockWhileDo(), ghidra::PrintC::emitEnumDefinition(), ghidra::PrintC::emitForLoop(), ghidra::PrintC::emitStructDefinition(), and ghidra::EmitPrettyPrint::getOutputStream().

◆ tagComment()

virtual void ghidra::Emit::tagComment ( const string &  name,
syntax_highlight  hl,
const AddrSpace spc,
uintb  off 
)
pure virtual

Emit a comment string as part of the generated source code.

Individual comments can be broken up and emitted using multiple calls to this method, but ultimately the comment delimiters and the body of the comment are both emitted with this method, which may provide addition markup.

Parameters
nameis the character data for the comment
hlindicates how the comment should be highlighted
spcis the address space of the address where the comment is attached
offis the offset of the address where the comment is attached

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ tagField()

virtual void ghidra::Emit::tagField ( const string &  name,
syntax_highlight  hl,
const Datatype ct,
int4  off,
const PcodeOp op 
)
pure virtual

Emit an identifier for a field within a structured data-type.

A string representing an individual component of a structured data-type is emitted, possibly with additional markup.

Parameters
nameis the character data for the identifier
hlindicates how the identifier should be highlighted
ctis the data-type associated with the field
offis the (byte) offset of the field within its structured data-type
opis the PcodeOp associated with the field (usually PTRSUB or SUBPIECE)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ tagFuncName()

virtual void ghidra::Emit::tagFuncName ( const string &  name,
syntax_highlight  hl,
const Funcdata fd,
const PcodeOp op 
)
pure virtual

Emit a function identifier.

An identifier string representing the symbol name of the function is emitted, possible with additional markup.

Parameters
nameis the character data for the identifier
hlindicates how the identifier should be highlighted
fdis the function
opis the CALL operation associated within the syntax tree or null for a declaration

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitFunctionDeclaration(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ tagLabel()

virtual void ghidra::Emit::tagLabel ( const string &  name,
syntax_highlight  hl,
const AddrSpace spc,
uintb  off 
)
pure virtual

Emit a code label identifier.

A string describing a control-flow destination, as appropriate for the source language is output, possibly with additional markup.

Parameters
nameis the character data of the label
hlindicates how the label should be highlighted
spcis the address space of the code address being labeled
offis the offset of the code address being labeled

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitLabel(), ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ tagLine() [1/2]

virtual void ghidra::Emit::tagLine ( void  )
pure virtual

◆ tagLine() [2/2]

virtual void ghidra::Emit::tagLine ( int4  indent)
pure virtual

Force a line break and indent level.

Tell the emitter that a new line is desired at a specific indent level. The indent level is overridden only for the line, then it returns to its previous value.

Parameters
indentis the desired indent level for the new line

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

◆ tagOp()

virtual void ghidra::Emit::tagOp ( const string &  name,
syntax_highlight  hl,
const PcodeOp op 
)
pure virtual

Emit an operation token.

The string representing the operation as appropriate for the source language is emitted, possibly with additional markup.

Parameters
nameis the character data for the emitted representation
hlindicates how the token should be highlighted
opis the PcodeOp object associated with the operation with the syntax tree

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::PrintC::emitBlockDoWhile(), ghidra::PrintC::emitBlockIf(), ghidra::PrintC::emitBlockInfLoop(), ghidra::PrintC::emitBlockWhileDo(), ghidra::PrintC::emitForLoop(), ghidra::EmitMarkup::EmitMarkup(), ghidra::PrintC::opBranch(), ghidra::PrintC::opBranchind(), ghidra::PrintC::opCbranch(), ghidra::PrintC::opReturn(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ tagType()

virtual void ghidra::Emit::tagType ( const string &  name,
syntax_highlight  hl,
const Datatype ct 
)
pure virtual

Emit a data-type identifier.

A string representing the name of a data-type, as appropriate for the source language is emitted, possibly with additional markup.

Parameters
nameis the character data for the identifier
hlindicates how the identifier should be highlighted
ctis the data-type description object

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().

◆ tagVariable()

virtual void ghidra::Emit::tagVariable ( const string &  name,
syntax_highlight  hl,
const Varnode vn,
const PcodeOp op 
)
pure virtual

Emit a variable token.

An identifier string representing the variable is output, possibly with additional markup.

Parameters
nameis the character data for the identifier
hlindicates how the identifier should be highlighted
vnis the Varnode representing the variable within the syntax tree
opis a p-code operation related to the use of the variable (may be null)

Implemented in ghidra::EmitPrettyPrint, ghidra::EmitNoMarkup, and ghidra::EmitMarkup.

Referenced by ghidra::EmitMarkup::EmitMarkup(), ghidra::TokenSplit::print(), ghidra::EmitPrettyPrint::resetDefaultsPrettyPrint(), and ~Emit().


The documentation for this class was generated from the following files: