PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::MacroUnit Class Reference

#include <Puma/MacroUnit.h>

+ Inheritance diagram for Puma::MacroUnit:

Description

Specialized unit for preprocessor macro expansions.

Public Member Functions

 MacroUnit ()
 Construct an empty macro unit.
 
 MacroUnit (const Unit &unit)
 Construct a macro unit.
 
virtual ~MacroUnit ()
 Destructor.
 
virtual bool isMacroExp () const
 Check if this is a macro expansion unit.
 
void CallingUnit (Unit *unit)
 Set the unit containing the macro call.
 
UnitCallingUnit () const
 Get the unit containing the macro call.
 
void MacroBegin (Token *token)
 Set the first token of the macro call in the calling unit.
 
void MacroEnd (Token *token)
 Set the last token of the macro call in the calling unit.
 
TokenMacroBegin () const
 Get the first token of the macro call in the calling unit.
 
TokenMacroEnd () const
 Get the last token of the macro call in the calling unit.
 
TokenExpansionBegin (Token *token) const
 Get the first token of the whole macro expansion in the source file if the given token is the first token of this expansion or nested expansion (macro generated macro call).
 
TokenExpansionEnd (Token *token) const
 Get the last token of the whole macro expansion in the source file if the given token is the last token of this expansion or nested expansion (macro generated macro call).
 
- Public Member Functions inherited from Puma::Unit
 Unit ()
 Constructor.
 
 Unit (const List &list)
 Copy-constructor.
 
virtual ~Unit ()
 Destructor.
 
virtual void name (const char *name)
 Set the name of the unit (usually the file name).
 
char * name () const
 Get the name of the unit (usually the file name).
 
virtual void print (std::ostream &os) const
 Print the tokens of the unit on the given stream.
 
virtual bool isFile () const
 Check if this is a unit for a file.
 
virtual bool isTemplateInstance () const
 Check if this is a unit for a template instance.
 
UnitStatestate ()
 Get the state of the unit.
 
char * toString () const
 Serialize the tokens of the unit.
 
Tokenfirst () const
 Get the first token in the unit.
 
Tokenlast () const
 Get the last token in the unit.
 
Tokennext (const Token *token) const
 Get the next token of the given token.
 
Tokenprev (const Token *token) const
 Get the previous token of the given token.
 
- Public Member Functions inherited from Puma::List
 List ()
 Constructor.
 
 List (const List &copy)
 Copy-constructor.
 
 ~List ()
 Destructor.
 
Listoperator= (const List &copy)
 Assignment operator.
 
Listoperator+= (const List &list)
 Append the given list.
 
List operator+ (const List &list)
 Create a new list containing the elements of this list followed by the elements of the given list.
 
void clear ()
 Destroy the list elements.
 
void append (ListElement &element)
 Append an element to the list.
 
void prepend (ListElement &element)
 Prepend an element to the list.
 
void insert (ListElement *at, ListElement &element)
 Insert an element at the given list position.
 
void remove (ListElement *element)
 Remove the given element from the list.
 
void kill (ListElement *from, ListElement *to=(ListElement *) 0)
 Remove and destroy all elements between the given list elements.
 
void cut (List &out, ListElement *from, ListElement *to=(ListElement *) 0)
 Cut all elements between the given list elements.
 
Listcopy (ListElement *from=(ListElement *) 0, ListElement *to=(ListElement *) 0)
 Copy all elements between the given list elements.
 
void paste (ListElement *at, const List &l)
 Insert copies of the elements of the given list at the given list position.
 
void paste_before (ListElement *at, const List &l)
 Insert copies of the elements of the given list before the given list position.
 
void move (ListElement *at, List &l)
 Insert the elements of the given list at the given list position.
 
void move_before (ListElement *at, List &l)
 Insert the elements of the given list before the given list position.
 
bool empty () const
 Check if the list is empty.
 
const ListElementfirst () const
 Get the first element in the list.
 
const ListElementlast () const
 Get the last element in the list.
 
const ListElementnext (const ListElement *element) const
 Get the next element of the given element.
 
const ListElementprev (const ListElement *element) const
 Get the previous element of the given element.
 
- Public Member Functions inherited from Puma::Printable
virtual ~Printable ()
 Destructor.
 

Constructor & Destructor Documentation

◆ MacroUnit() [1/2]

Puma::MacroUnit::MacroUnit ( )
inline

Construct an empty macro unit.

◆ MacroUnit() [2/2]

Puma::MacroUnit::MacroUnit ( const Unit & unit)
inline

Construct a macro unit.

Parameters
unitThe unit containing the macro expansion.

◆ ~MacroUnit()

virtual Puma::MacroUnit::~MacroUnit ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ CallingUnit() [1/2]

Unit * Puma::MacroUnit::CallingUnit ( ) const
inline

Get the unit containing the macro call.

Returns
A pointer to the unit, or NULL if not set.

◆ CallingUnit() [2/2]

void Puma::MacroUnit::CallingUnit ( Unit * unit)
inline

Set the unit containing the macro call.

Parameters
unitThe unit.

◆ ExpansionBegin()

Token * Puma::MacroUnit::ExpansionBegin ( Token * token) const

Get the first token of the whole macro expansion in the source file if the given token is the first token of this expansion or nested expansion (macro generated macro call).

Parameters
tokenThe token.
Returns
The first token, or NULL otherwise.

◆ ExpansionEnd()

Token * Puma::MacroUnit::ExpansionEnd ( Token * token) const

Get the last token of the whole macro expansion in the source file if the given token is the last token of this expansion or nested expansion (macro generated macro call).

Parameters
tokenThe token.
Returns
The last token, or NULL otherwise.

◆ isMacroExp()

virtual bool Puma::MacroUnit::isMacroExp ( ) const
inlinevirtual

Check if this is a macro expansion unit.

Returns
Always returns true.

Reimplemented from Puma::Unit.

◆ MacroBegin() [1/2]

Token * Puma::MacroUnit::MacroBegin ( ) const
inline

Get the first token of the macro call in the calling unit.

Returns
A pointer to the token.

◆ MacroBegin() [2/2]

void Puma::MacroUnit::MacroBegin ( Token * token)
inline

Set the first token of the macro call in the calling unit.

Parameters
tokenThe first token.

◆ MacroEnd() [1/2]

Token * Puma::MacroUnit::MacroEnd ( ) const
inline

Get the last token of the macro call in the calling unit.

Returns
A pointer to the token.

◆ MacroEnd() [2/2]

void Puma::MacroUnit::MacroEnd ( Token * token)
inline

Set the last token of the macro call in the calling unit.

Parameters
tokenThe last token.