decompiler  1.0.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
Comment Class Reference

A comment attached to a specific function and code address. More...

#include <comment.hh>

Public Types

enum  comment_type {
  user1 = 1, user2 = 2, user3 = 4, header = 8,
  warning = 16, warningheader = 32
}
 Possible properties associated with a comment. More...
 

Public Member Functions

 Comment (uint4 tp, const Address &fad, const Address &ad, int4 uq, const string &txt)
 Constructor. More...
 
 Comment (void)
 Constructor for use with restoreXml.
 
uint4 getType (void) const
 Get the properties associated with the comment.
 
const AddressgetFuncAddr (void) const
 Get the address of the function containing the comment.
 
const AddressgetAddr (void) const
 Get the address to which the instruction is attached.
 
int4 getUniq (void) const
 Get the sub-sorting index.
 
const string & getText (void) const
 Get the body of the comment.
 
void saveXml (ostream &s) const
 Save the comment to an XML stream. More...
 
void restoreXml (const Element *el, const AddrSpaceManager *manage)
 Restore the comment from XML. More...
 

Static Public Member Functions

static uint4 encodeCommentType (const string &name)
 Convert name string to comment property. More...
 
static string decodeCommentType (uint4 val)
 Convert comment property to string. More...
 

Private Attributes

uint4 type
 The properties associated with the comment.
 
Address funcaddr
 Address of the function containing the comment.
 
Address addr
 Address associated with the comment.
 
int4 uniq
 Sub-identifier for uniqueness.
 
string text
 The body of the comment.
 

Friends

class CommentDatabaseInternal
 

Detailed Description

A comment attached to a specific function and code address.

Things contains the actual character data of the comment. It is fundamentally attached to a specific function and to the address of an instruction (within the function's body). Comments can be categorized as a header (or not) depending on whether it should be displayed as part of the general description of the function or not. Other properties can be assigned to a comment, to allow the user to specify the subset of all comments they want to display.

Member Enumeration Documentation

Possible properties associated with a comment.

Enumerator
user1 

The first user defined property.

user2 

The second user defined property.

user3 

The third user defined property.

header 

The comment should be displayed in the function header.

warning 

The comment is auto-generated to alert the user.

warningheader 

The comment is auto-generated and should be in the header.

Constructor & Destructor Documentation

Comment::Comment ( uint4  tp,
const Address fad,
const Address ad,
int4  uq,
const string &  txt 
)

Constructor.

Parameters
tpis the set of properties to associate with the comment (or 0 for no properties)
fadis the Address of the function containing the comment
adis the Address of the instruction associated with the comment
uqis used internally to sub-sort comments at the same address
txtis the body of the comment

Member Function Documentation

string Comment::decodeCommentType ( uint4  val)
static

Convert comment property to string.

Parameters
valis a single comment property
Returns
the string representation of the property

References header, user1, user2, user3, warning, and warningheader.

Referenced by getText(), and saveXml().

uint4 Comment::encodeCommentType ( const string &  name)
static

Convert name string to comment property.

Parameters
nameis a string representation of a single comment property
Returns
the enumerated property type

References header, user1, user2, user3, warning, and warningheader.

Referenced by OptionCommentHeader::apply(), OptionCommentInstruction::apply(), getText(), and restoreXml().

void Comment::restoreXml ( const Element el,
const AddrSpaceManager manage 
)

Restore the comment from XML.

The comment is parsed from a <comment> tag.

Parameters
elis the <comment> element
manageis a manager for resolving address space references

References addr, encodeCommentType(), funcaddr, Element::getAttributeValue(), Element::getChildren(), Address::restoreXml(), text, and type.

Referenced by getText(), CommentDatabaseInternal::restoreXml(), and CommentDatabase::~CommentDatabase().

void Comment::saveXml ( ostream &  s) const

Save the comment to an XML stream.

The single comment is saved as a <comment> tag.

Parameters
sis the output stream

References a_v(), addr, decodeCommentType(), funcaddr, Address::getOffset(), Address::getSpace(), AddrSpace::saveXmlAttributes(), text, type, and xml_escape().

Referenced by getText(), and CommentDatabase::~CommentDatabase().


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