ROSE  0.11.145.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Rosebud::Ast::CppStack Class Reference

Description

Information about C preprocessor conditional compilation directives.

Definition at line 130 of file Ast.h.

#include <Rosebud/Ast.h>

Inheritance diagram for Rosebud::Ast::CppStack:
Inheritance graph
[legend]
Collaboration diagram for Rosebud::Ast::CppStack:
Collaboration graph
[legend]

Classes

struct  Directive
 Conditional compilation directive. More...
 

Public Types

enum  Type {
  Type::IF,
  Type::ELSE,
  Type::END,
  Type::OTHER
}
 Type of CPP directive. More...
 
using Ptr = CppStackPtr
 Shared-ownership pointer. More...
 
using Level = std::list< Directive >
 The CPP directives that belong to the same level. More...
 
using Stack = std::vector< Level >
 A stack of nested conditional compilation directives. More...
 
- Public Types inherited from Rosebud::Ast::Node
using Ptr = NodePtr
 
- Public Types inherited from Sawyer::Tree::Vertex< Node >
using UserBase = Node
 User's base class. More...
 
using UserBasePtr = std::shared_ptr< UserBase >
 Pointer to user's base class. More...
 
using TraversalEvent = Sawyer::Tree::TraversalEvent
 Alias for traversal events. More...
 

Public Member Functions

bool printError (const FilePtr &file) const
 Print an error message for the top of the stack if there's something wrong with it. More...
 
void emitOpen (std::ostream &)
 Emit all control flow directives in this stack. More...
 
void emitClose (std::ostream &)
 Emit matching #endif for all control flow directives in this stack. More...
 
- Public Member Functions inherited from Rosebud::Ast::Node
template<class T >
std::shared_ptr< T > findAncestor ()
 
- Public Member Functions inherited from Sawyer::Tree::Vertex< Node >
UserBasePtr pointer ()
 Returns a shared pointer to this vertex. More...
 
std::shared_ptr< T > isa ()
 Tests whether this object is a certain type. More...
 
auto traverseReverse (const Visitor &visitor)
 Traverse in reverse direction from children to parents. More...
 
auto traverse (const Visitor &visitor)
 Traverse in forward direction from parents to children. More...
 
auto traversePre (const Visitor &visitor)
 Pre-order forward traversal. More...
 
auto traversePost (const Visitor &visitor)
 Post-order forward traversal. More...
 
std::shared_ptr< T > findFirstAncestor ()
 Traversal that finds the closest ancestor of type T or derived from T. More...
 
std::shared_ptr< T > findLastAncestor ()
 Traversal that finds the farthest ancestor of type T or derived from T. More...
 
std::vector< std::shared_ptr< T > > findDescendants ()
 Traversal that finds all the descendants of a particular type. More...
 
UserBasePtr child (size_t i) const
 Returns the pointer for a child. More...
 
size_t nChildren () const
 Returns the number of children. More...
 

Static Public Member Functions

static Ptr instance ()
 Allocating constructor. More...
 
static Type type (const std::string &directive)
 Type of directive. More...
 
static bool process (const FilePtr &, const Token &directive, Stack &runningStack)
 Adjust the stack based on the C preprocessor directive. More...
 

Public Attributes

Stack stack
 The stack of nested conditional compilation directives. More...
 
- Public Attributes inherited from Sawyer::Tree::Vertex< Node >
ReverseEdge parent
 Pointer to the parent in the tree. More...
 
EdgeBase * treeEdges_
 

Protected Member Functions

 CppStack ()
 Default constructor used only by derived classes. More...
 
- Protected Member Functions inherited from Sawyer::Tree::Vertex< Node >
virtual void destructorHelper ()
 

Member Typedef Documentation

Shared-ownership pointer.

Definition at line 133 of file Ast.h.

The CPP directives that belong to the same level.

E.g., a matching #if, #elif, and #else. The first element of the pair indicates the type of directive in the first element of the list. The list is never empty.

Definition at line 154 of file Ast.h.

using Rosebud::Ast::CppStack::Stack = std::vector<Level>

A stack of nested conditional compilation directives.

The earlier entries enclose the later entries.

Definition at line 159 of file Ast.h.

Member Enumeration Documentation

Type of CPP directive.

Enumerator
IF 

#if, #ifdef, or #ifndef.

ELSE 

#else or #elif

END 

#endif

OTHER 

Not a conditional compilation directive.

Definition at line 136 of file Ast.h.

Constructor & Destructor Documentation

Rosebud::Ast::CppStack::CppStack ( )
protected

Default constructor used only by derived classes.

Member Function Documentation

static Ptr Rosebud::Ast::CppStack::instance ( )
static

Allocating constructor.

static Type Rosebud::Ast::CppStack::type ( const std::string &  directive)
static

Type of directive.

static bool Rosebud::Ast::CppStack::process ( const FilePtr ,
const Token directive,
Stack runningStack 
)
static

Adjust the stack based on the C preprocessor directive.

Returns true if the stack was adjusted, false otherwise.

bool Rosebud::Ast::CppStack::printError ( const FilePtr file) const

Print an error message for the top of the stack if there's something wrong with it.

Returns true if an error was printed.

void Rosebud::Ast::CppStack::emitOpen ( std::ostream &  )

Emit all control flow directives in this stack.

void Rosebud::Ast::CppStack::emitClose ( std::ostream &  )

Emit matching #endif for all control flow directives in this stack.

Member Data Documentation

Stack Rosebud::Ast::CppStack::stack

The stack of nested conditional compilation directives.

Definition at line 163 of file Ast.h.


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