decompiler  1.0.0
Public Member Functions | Private Attributes | List of all members
ghidra::EmitNoMarkup Class Reference

A trivial emitter that outputs syntax straight to the stream. More...

#include <prettyprint.hh>

Inheritance diagram for ghidra::EmitNoMarkup:
ghidra::Emit

Public Member Functions

 EmitNoMarkup (void)
 Constructor.
 
virtual int4 beginDocument (void)
 Begin a whole document of output. More...
 
virtual void endDocument (int4 id)
 End a whole document of output. More...
 
virtual int4 beginFunction (const Funcdata *fd)
 Begin a whole declaration and body of a function. More...
 
virtual void endFunction (int4 id)
 End a whole declaration and body of a function. More...
 
virtual int4 beginBlock (const FlowBlock *bl)
 Begin a control-flow element. More...
 
virtual void endBlock (int4 id)
 End a control-flow element. More...
 
virtual void tagLine (void)
 Force a line break. More...
 
virtual void tagLine (int4 indent)
 Force a line break and indent level. More...
 
virtual int4 beginReturnType (const Varnode *vn)
 Begin a return type declaration. More...
 
virtual void endReturnType (int4 id)
 End a return type declaration. More...
 
virtual int4 beginVarDecl (const Symbol *sym)
 Begin a variable declaration. More...
 
virtual void endVarDecl (int4 id)
 End a variable declaration. More...
 
virtual int4 beginStatement (const PcodeOp *op)
 Begin a source code statement. More...
 
virtual void endStatement (int4 id)
 End a source code statement. More...
 
virtual int4 beginFuncProto (void)
 Begin a function prototype declaration. More...
 
virtual void endFuncProto (int4 id)
 End a function prototype declaration. More...
 
virtual void tagVariable (const string &name, syntax_highlight hl, const Varnode *vn, const PcodeOp *op)
 Emit a variable token. More...
 
virtual void tagOp (const string &name, syntax_highlight hl, const PcodeOp *op)
 Emit an operation token. More...
 
virtual void tagFuncName (const string &name, syntax_highlight hl, const Funcdata *fd, const PcodeOp *op)
 Emit a function identifier. More...
 
virtual void tagType (const string &name, syntax_highlight hl, const Datatype *ct)
 Emit a data-type identifier. More...
 
virtual void tagField (const string &name, syntax_highlight hl, const Datatype *ct, int4 off, const PcodeOp *op)
 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)
 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)
 Emit a code label identifier. More...
 
virtual void print (const string &data, syntax_highlight hl=no_color)
 Emit other (more unusual) syntax as part of source code generation. More...
 
virtual int4 openParen (const string &paren, int4 id=0)
 Emit an open parenthesis. More...
 
virtual void closeParen (const string &paren, int4 id)
 Emit a close parenthesis. More...
 
virtual void setOutputStream (ostream *t)
 Set the output stream for the emitter.
 
virtual ostream * getOutputStream (void) const
 Get the current output stream.
 
virtual bool emitsMarkup (void) const
 Determine if this is an XML markup emitter. More...
 
- Public Member Functions inherited from ghidra::Emit
 Emit (void)
 
virtual ~Emit (void)
 Destructor.
 
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 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 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...
 

Private Attributes

ostream * s
 The stream to output tokens to.
 

Additional Inherited Members

- Public Types inherited from ghidra::Emit
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...
 
- Static Public Attributes inherited from ghidra::Emit
static const string EMPTY_STRING = ""
 An empty string.
 
- Protected Member Functions inherited from ghidra::Emit
void resetDefaultsInternal (void)
 Set options to default values for EmitMarkup.
 
void emitPending (void)
 Emit any pending print commands.
 
- Protected Attributes inherited from ghidra::Emit
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

A trivial emitter that outputs syntax straight to the stream.

This emitter does neither pretty printing nor markup. It dumps any tokens straight to the final output stream. It can be used as the low-level back-end for EmitPrettyPrint.

Member Function Documentation

◆ beginBlock()

virtual int4 ghidra::EmitNoMarkup::beginBlock ( const FlowBlock bl)
inlinevirtual

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

Implements ghidra::Emit.

◆ beginDocument()

virtual int4 ghidra::EmitNoMarkup::beginDocument ( void  )
inlinevirtual

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

Implements ghidra::Emit.

◆ beginFuncProto()

virtual int4 ghidra::EmitNoMarkup::beginFuncProto ( void  )
inlinevirtual

Begin a function prototype declaration.

Inform the emitter that a function prototype is starting.

Returns
an id associated with the prototype

Implements ghidra::Emit.

◆ beginFunction()

virtual int4 ghidra::EmitNoMarkup::beginFunction ( const Funcdata fd)
inlinevirtual

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

Implements ghidra::Emit.

◆ beginReturnType()

virtual int4 ghidra::EmitNoMarkup::beginReturnType ( const Varnode vn)
inlinevirtual

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

Implements ghidra::Emit.

◆ beginStatement()

virtual int4 ghidra::EmitNoMarkup::beginStatement ( const PcodeOp op)
inlinevirtual

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

Implements ghidra::Emit.

◆ beginVarDecl()

virtual int4 ghidra::EmitNoMarkup::beginVarDecl ( const Symbol sym)
inlinevirtual

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

Implements ghidra::Emit.

◆ closeParen()

virtual void ghidra::EmitNoMarkup::closeParen ( const string &  paren,
int4  id 
)
inlinevirtual

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)

Implements ghidra::Emit.

References ghidra::Emit::parenlevel.

◆ emitsMarkup()

virtual bool ghidra::EmitNoMarkup::emitsMarkup ( void  ) const
inlinevirtual

Determine if this is an XML markup emitter.

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

Implements ghidra::Emit.

◆ endBlock()

virtual void ghidra::EmitNoMarkup::endBlock ( int4  id)
inlinevirtual

End a control-flow element.

Inform the emitter that a control-flow section is ending.

Parameters
idis the id associated with the section (as returned by beginBlock)

Implements ghidra::Emit.

◆ endDocument()

virtual void ghidra::EmitNoMarkup::endDocument ( int4  id)
inlinevirtual

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)

Implements ghidra::Emit.

◆ endFuncProto()

virtual void ghidra::EmitNoMarkup::endFuncProto ( int4  id)
inlinevirtual

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)

Implements ghidra::Emit.

◆ endFunction()

virtual void ghidra::EmitNoMarkup::endFunction ( int4  id)
inlinevirtual

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)

Implements ghidra::Emit.

◆ endReturnType()

virtual void ghidra::EmitNoMarkup::endReturnType ( int4  id)
inlinevirtual

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)

Implements ghidra::Emit.

◆ endStatement()

virtual void ghidra::EmitNoMarkup::endStatement ( int4  id)
inlinevirtual

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)

Implements ghidra::Emit.

◆ endVarDecl()

virtual void ghidra::EmitNoMarkup::endVarDecl ( int4  id)
inlinevirtual

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)

Implements ghidra::Emit.

◆ openParen()

virtual int4 ghidra::EmitNoMarkup::openParen ( const string &  paren,
int4  id = 0 
)
inlinevirtual

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

Implements ghidra::Emit.

References ghidra::Emit::parenlevel.

◆ print()

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

Emit other (more unusual) syntax as part of source code generation.

This method is used to emit syntax not covered by the other methods, such as spaces, semi-colons, braces, and other punctuation.

Parameters
datais the character data of the syntax being emitted
hlindicates how the syntax should be highlighted

Implements ghidra::Emit.

◆ tagComment()

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

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

Implements ghidra::Emit.

◆ tagField()

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

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)

Implements ghidra::Emit.

◆ tagFuncName()

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

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

Implements ghidra::Emit.

◆ tagLabel()

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

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

Implements ghidra::Emit.

◆ tagLine() [1/2]

virtual void ghidra::EmitNoMarkup::tagLine ( void  )
inlinevirtual

Force a line break.

Tell the emitter that a new line is desired at the current indent level

Implements ghidra::Emit.

◆ tagLine() [2/2]

virtual void ghidra::EmitNoMarkup::tagLine ( int4  indent)
inlinevirtual

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

Implements ghidra::Emit.

◆ tagOp()

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

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

Implements ghidra::Emit.

◆ tagType()

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

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

Implements ghidra::Emit.

◆ tagVariable()

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

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)

Implements ghidra::Emit.


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