SgScopeStatement¶
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
Synopsis¶
Declared in <src/frontend/SageIII/Cxx_Grammar.h> (not stored in Git)
class [[visibility("default")]] SgScopeStatement
: public SgStatement Description¶
Scopes are an important aspect of language design. They allow declarations to have a local context and so promote good programming style. Scope statments in C++ include a number of different kinds of statements; the SgScopeStatement is a base class for these. Each scope statement contains a symbol table and the SgScopeStatements role is mostly to provide this symbol table and an interface to accessing it.
- Internal: This is a base class for scope statements. Control-flow bodies use SgStatement edges. Conditions may be expressions wrapped in expression statements or declaration statements.
Data members
SgScopeStatement::p_symbol_table¶
This pointer is always valid and stores the symbl table.
- Internal: The symbol table implementation was changed in fall of 2004, by Alin. It is not simple and leverages STL and provides more features.
Member functions
SgScopeStatement::get_symbol_table()¶
Returns a pointer to the locally strored SgSymbolTable.
- Return: Returns a pointer.
SgScopeStatement::set_symbol_table(SgSymbolTable *symbolTable)¶
Sets the pointer to the locally strored SgSymbolTable.
- Return: Returns void.
SgScopeStatement::get_qualified_name() const¶
Returns SgName (a string) representing the name of the current scope. See discussion of mangled names in the documentation.
- Return: Returns SgName (a string).
SgScopeStatement::copy(const SgCopyHelp & help)¶
Makes a copy (deap of shallow depending on SgCopyHelp).
- Return: Returns pointer to copy of SgScopeStatement.
SgScopeStatement::insert_symbol(const SgName & name, SgSymbol *symbol)¶
Puts a SgSymbol object into the local symbol table.
- Return: Returns void.
SgScopeStatement::lookup_symbol(const SgName & name)¶
returns boolean value if symbol exists.
- Return: Returns SgSymbol pointer.
SgScopeStatement::containsOnlyDeclarations()¶
boolean member function to distinquish if getStatementList() or getDeclarationList() is appropriate for the SgScopeStatment IR node.
- Return: bool.
SgScopeStatement::getDeclarationList()¶
Gets reference to internal STL list of pointers to SgDeclarationStatement objects (only defined for scopes containing declarations, see bool containsOnlyDeclarations()). This function is useful for SgScopeStatement objects that contain declarations, including SgClassDefinition, SgTemplateInstantiationDefn, SgGlobal, and SgNamespaceDefinitionStatement. To test if a scope contains only declarations use "bool containsOnlyDeclarations()". Because this function returns a reference to the list (instead of a list of pointers to the declarations or statements) any modification of the list is a modification of the AST.
- Return: STL list of pointers to SgDeclarationStatement objects.
SgScopeStatement::getStatementList()¶
Gets reference to internal STL list of pointers to SgStatement objects (only defined for scopes containing statements, see bool containsOnlyDeclarations()). This function is useful for SgScopeStatement objects that contain non-declarations (lists of SgStatement instead of lists of SgDeclarationStatement IR nodes). Because this function returns a reference to the list (instead of a list of pointers to the declarations or statements) any modification of the list is a modification of the AST.
- Return: STL list of pointers to SgStatement objects.
SgScopeStatement::generateStatementList()¶
Builds list of pointers to SgStatement objects (useful for all SgScopeStatement objects, independent of whether they contain lists of SgDeclarationStatements or lists of SgStatements). This function is useful for any SgScopeStatement object, but since it returns by value any modification of the list is not reflected in the AST.
- Todo: This runtion should return a const value so that it would be more clear that it could not be modified (since such modifications would not be reflected in the AST).
- Return: STL list of pointers to SgStatement objects (returns by value).
Base Classes¶
| Name | Description |
|---|---|
SgStatement | This class represents the notion of a statement. |
Type Aliases¶
| Name |
|---|
base_node_type |
Enums¶
| Name | Description |
|---|---|
Unnamed enum | static variant value |
Member Functions¶
| Name | Description |
|---|---|
SgScopeStatementSgScopeStatement(Sg_File_Info* file_info = NULL); [constructor] | Default constructor |
~SgScopeStatementvirtual ~SgScopeStatement(); [destructor] [virtual] | Destructor |
acceptvirtual void accept(ROSE_VisitorPattern& visitor) override; [virtual] | support for the classic visitor pattern done in GoF |
appendDestructorOwnedNodesvirtual void appendDestructorOwnedNodes(std::vector<SgNode*>& nodes) const override; [virtual] | |
append_statementvoid append_statement(SgStatement* stmt); | |
associatedScopeNameSgName associatedScopeName(); | Return this scope's name for qualification. |
class_namevirtual std::string class_name() const override; [virtual] | returns a string representing the class name |
containsOnlyDeclarationsbool containsOnlyDeclarations() const; | This function is used to indicate if either the getDeclarationList() or getStatementList() can be called to return a reference to the list of IR nodes (manipulation of the list is then possible). |
copyvirtual SgNode* copy(SgCopyHelp& help) const override; [virtual] | |
count_alias_symbolsize_t count_alias_symbol(SgName const& n); | Count for alias symbols of a specific name, used in name qualification support. |
count_symbolsize_t count_symbol(SgName const& n); | return number of entries in symbol table for the specified name (note that it is sometime OK for there to be more than 1). |
find_symbol_by_type_of_functiontemplate<class T> SgFunctionSymbol* find_symbol_by_type_of_function( SgName const& name, SgType const* func_type, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList); | |
find_symbol_from_declarationSgSymbol* find_symbol_from_declaration(SgFunctionType const* node) const; | |
firstStatementSgStatement* firstStatement() const; | |
first_any_symbolSgSymbol* first_any_symbol() const; | get the first symbol independent of name (lack of name is stored as internal state) |
first_class_symbolSgClassSymbol* first_class_symbol() const; | |
first_enum_field_symbolSgEnumFieldSymbol* first_enum_field_symbol() const; | |
first_enum_symbolSgEnumSymbol* first_enum_symbol() const; | |
first_function_symbolSgFunctionSymbol* first_function_symbol() const; | |
first_label_symbolSgLabelSymbol* first_label_symbol() const; | |
first_namespace_symbolSgNamespaceSymbol* first_namespace_symbol() const; | |
first_typedef_symbolSgTypedefSymbol* first_typedef_symbol() const; | |
first_variable_symbolSgVariableSymbol* first_variable_symbol() const; | |
fixupCopy_referencesvirtual void fixupCopy_references( SgNode* copy, SgCopyHelp& help) const override; [virtual] | |
fixupCopy_scopesvirtual void fixupCopy_scopes( SgNode* copy, SgCopyHelp& help) const override; [virtual] | |
fixupCopy_symbolsvirtual void fixupCopy_symbols( SgNode* copy, SgCopyHelp& help) const override; [virtual] | |
generateStatementListSgStatementPtrList const generateStatementList() const; | Return a statement-list copy of this scope's statements or declarations. |
getDeclarationListSgDeclarationStatementPtrList& getDeclarationList(); | |
getStatementListSgStatementPtrList& getStatementList(); | |
get_auxiliary_declaration_scopesSgDeclarationScopeList* get_auxiliary_declaration_scopes() const; | |
get_auxiliary_declarationsSgAuxiliaryDeclarationList* get_auxiliary_declarations() const; | |
get_childIndexvirtual size_t get_childIndex(SgNode* child) const override; [virtual] | index-based access to traversal successors by child node |
get_mangled_namevirtual SgName get_mangled_name() const; [virtual] | |
get_numberOfTraversalSuccessorsvirtual size_t get_numberOfTraversalSuccessors() const override; [virtual] | return number of children in the traversal successor list |
get_pragmaSgPragma* get_pragma() const; | |
get_qualified_namevirtual SgName get_qualified_name() const; [virtual] | |
get_symbol_tableSgSymbolTable* get_symbol_table() const; | |
get_traversalSuccessorByIndexvirtual SgNode* get_traversalSuccessorByIndex(size_t idx) const override; [virtual] | index-based access to traversal successors by index number |
get_traversalSuccessorContainervirtual std::vector<SgNode*> get_traversalSuccessorContainer() const override; [virtual] | container of pointers to AST successor nodes used in the traversal overridden in every class by generated implementation |
get_traversalSuccessorIsListElementvirtual std::vector<bool> get_traversalSuccessorIsListElement() const override; [virtual] | |
get_traversalSuccessorNamesContainervirtual std::vector<std::string> get_traversalSuccessorNamesContainer() const override; [virtual] | container of names of variables or container indices used used in the traversal to access AST successor nodes overridden in every class by generated implementation |
get_type_tableSgTypeTable* get_type_table() const; | |
hasAmbiguitybool hasAmbiguity( SgName& name, SgSymbol* symbol); | |
insertStatementInScopevoid insertStatementInScope( SgStatement* newTransformationStatement, bool atTop); | |
insert_symbolvoid insert_symbol( SgName const& n, SgSymbol* s); | |
isCaseInsensitivebool isCaseInsensitive() const; | Whether this scope's symbol table is case insensitive (Fortran). |
isNamedScopebool isNamedScope(); | Whether this scope has a name for qualification. |
lastStatementSgStatement* lastStatement() const; | |
lookup_alias_symbolSgAliasSymbol* lookup_alias_symbol( SgName const& n, SgSymbol* sp) const; | |
lookup_class_symbolSgClassSymbol* lookup_class_symbol( SgName const& n, SgTemplateArgumentPtrList* templateArgumentsList = NULL) const; | |
lookup_enum_field_symbolSgEnumFieldSymbol* lookup_enum_field_symbol(SgName const& n) const; | |
lookup_enum_symbolSgEnumSymbol* lookup_enum_symbol(SgName const& n) const; | |
lookup_function_symbolSgFunctionSymbol* lookup_function_symbol(SgName const& n) const; | |
lookup_label_symbolSgLabelSymbol* lookup_label_symbol(SgName const& n) const; | |
lookup_namespace_symbolSgNamespaceSymbol* lookup_namespace_symbol(SgName const& n) const; | |
lookup_nonreal_symbolSgNonrealSymbol* lookup_nonreal_symbol( SgName const& n, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentsList = NULL) const; | |
lookup_nontemplate_class_symbolSgClassSymbol* lookup_nontemplate_class_symbol(SgName const& n) const; | |
lookup_nontemplate_function_symbolSgFunctionSymbol* lookup_nontemplate_function_symbol( SgName const& n, SgType const* t, SgTemplateArgumentPtrList* templateArgumentsList = NULL) const; | |
lookup_nontemplate_member_function_symbolSgMemberFunctionSymbol* lookup_nontemplate_member_function_symbol( SgName const& n, SgType const* t, SgTemplateArgumentPtrList* templateArgumentsList = NULL) const; | |
lookup_symbolSgSymbol* lookup_symbol( SgName const& n, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL) const; | get the first symbol with name (note that "" is a valid name and is used for unnamed declarations) the input name is stored as internal state to support the use of next_XXX_symbol() member function. |
lookup_symbol_for_ast_copy_fixupSgSymbol* lookup_symbol_for_ast_copy_fixup( SgName const& n, VariantT requestedSymbolKind, SgType const* type, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentList = NULL) const; | Lookup used only while reconciling an AST copied from a separate file. Recursive base-class search is explicit to this call. |
lookup_symbol_for_name_qualificationSgSymbol* lookup_symbol_for_name_qualification( SgName const& n, VariantT requestedSymbolKind, SgType const* type, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList, SgUnorderedNodeSet const& visibleAliasCausalNodes) const; | Lookup used by one name-qualification traversal. Alias visibility is derived exclusively from the supplied invocation-owned causal-node set. |
lookup_template_class_symbolSgTemplateClassSymbol* lookup_template_class_symbol( SgName const& n, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateSpecializationArgumentList) const; | |
lookup_template_function_symbolSgTemplateFunctionSymbol* lookup_template_function_symbol( SgName const& n, SgType const* t, SgTemplateParameterPtrList* templateParameterList) const; | |
lookup_template_member_function_symbolSgTemplateMemberFunctionSymbol* lookup_template_member_function_symbol( SgName const& n, SgType const* t, SgTemplateParameterPtrList* templateParameterList) const; | |
lookup_template_typedef_symbolSgTemplateTypedefSymbol* lookup_template_typedef_symbol(SgName const& n) const; | |
lookup_template_variable_symbolSgTemplateVariableSymbol* lookup_template_variable_symbol( SgName const& n, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentsList) const; | |
lookup_typedef_symbolSgTypedefSymbol* lookup_typedef_symbol(SgName const& n) const; | |
lookup_variable_symbolSgVariableSymbol* lookup_variable_symbol(SgName const& n) const; | |
next_any_symbolSgSymbol* next_any_symbol() const; | Only use after lookup_XXX_symbol(const SgName&) or after first_XXX_symbol() These functions use the stored state of the name or lack of name (from the lookup_XXX_symbol(const SgName&) or after first_XXX_symbol() member function) and return the next symbol. |
next_class_symbolSgClassSymbol* next_class_symbol() const; | |
next_enum_field_symbolSgEnumFieldSymbol* next_enum_field_symbol() const; | |
next_enum_symbolSgEnumSymbol* next_enum_symbol() const; | |
next_function_symbolSgFunctionSymbol* next_function_symbol() const; | |
next_label_symbolSgLabelSymbol* next_label_symbol() const; | |
next_namespace_symbolSgNamespaceSymbol* next_namespace_symbol() const; | |
next_typedef_symbolSgTypedefSymbol* next_typedef_symbol() const; | |
next_variable_symbolSgVariableSymbol* next_variable_symbol() const; | |
operator deletevoid operator delete( void* pointer, size_t size); | deallocated memory for IR node (returns memory to memory pool for reuse) |
operator newvoid* operator new(size_t size); | returns pointer to newly allocated IR node |
post_construction_initializationvirtual void post_construction_initialization() override; [virtual] | |
prepend_statementvoid prepend_statement(SgStatement* stmt); | |
print_symboltablevoid print_symboltable(std::string const& str); | |
processDataMemberReferenceToPointersvirtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler*) override; [virtual] | Pass references to stored node pointers to a handler. |
remove_symbolvoid remove_symbol(SgSymbol* s); | |
returnDataMemberPointersvirtual std::vector<std::pair<SgNode*, std::string>> returnDataMemberPointers() const override; [virtual] | Return the node pointers stored in this node's data members. |
roseRTIvirtual RTIReturnType roseRTI() override; [virtual] | return C++ Runtime-Time-Information |
sage_class_namevirtual char const* sage_class_name() const override; [virtual] | returns a C style string (char*) representing the class name |
setCaseInsensitivevoid setCaseInsensitive(bool b); | |
set_auxiliary_declaration_scopesvoid set_auxiliary_declaration_scopes(SgDeclarationScopeList* auxiliary_declaration_scopes); | |
set_auxiliary_declarationsvoid set_auxiliary_declarations(SgAuxiliaryDeclarationList* auxiliary_declarations); | |
set_pragmavoid set_pragma(SgPragma* pragma); | |
set_symbol_tablevoid set_symbol_table(SgSymbolTable* symbol_table); | |
set_type_tablevoid set_type_table(SgTypeTable* type_table); | |
statementExistsInScopebool statementExistsInScope(SgStatement* statement); | Test whether this scope contains the statement. |
supportsDefiningFunctionDeclarationbool supportsDefiningFunctionDeclaration(); | Reports if scope can support defining function declarations.// Not all scopes permit function declarations. Any function prototype in a// scope appropriate for a function definition triggers requirements for namequalification.// This function returns true if the scope is appropriate for the definition ofa function// or member function (i.e. is a SgGlobal, SgClassDefinition, orSgNamespaceDefinitionStatement). |
symbol_existsbool symbol_exists(SgName const& name) const; | |
symbol_table_sizesize_t symbol_table_size(); | Return the size of the symbol table. |
variantTvirtual VariantT variantT() const override; [virtual] | returns new style SageIII enum values |
Static Member Functions¶
| Name | Description |
|---|---|
isEquivalentScopestatic bool isEquivalentScope( SgScopeStatement* scope1, SgScopeStatement* scope2); | |
memoryUsagestatic size_t memoryUsage(); | Returns the size in bytes of the total memory allocated for all IR nodes of this type |
numberOfNodesstatic size_t numberOfNodes(); | Returns the total number of IR nodes of this type |
traverseMemoryPoolNodesstatic void traverseMemoryPoolNodes(ROSE_VisitTraversal& visit); | FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node. |
traverseMemoryPoolVisitorPatternstatic void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern& visitor); | FOR INTERNAL USE Support for visitor pattern. |
visitRepresentativeNodestatic void visitRepresentativeNode(ROSE_VisitTraversal& visit); | FOR INTERNAL USE Support for type-based traversal. |
Static Data Members¶
| Name | Description |
|---|---|
free_slots | Free slots, each numbered pool_index * pool_size + slot_index. The last entry is allocated next. |
pool_live_flags | |
pool_size | |
pools |
Protected Data Members¶
| Name |
|---|
p_auxiliary_declaration_scopes |
p_auxiliary_declarations |
p_pragma |
p_symbol_table |
p_type_table |
Friends¶
| Name | Description |
|---|---|
isSgScopeStatement | Casts pointer from base class to derived class (for const pointers) |
isSgScopeStatement | Casts pointer from base class to derived class |
Derived Classes¶
| Name | Description |
|---|---|
SgAssociateStatement | |
SgBasicBlock | This class represents the concept of a block (not a basic block from control flow analysis). |
SgCatchOptionStmt | This class represents the concept of a catch within a try-catch construct used in |
SgClassDefinition | This class represents the concept of a class definition in C++. |
SgDeclarationScope | |
SgDoWhileStmt | This class represents the concept of a do-while statement. |
SgForAllStatement | |
SgForStatement | This class represents the concept of a for loop. |
SgFortranDo | |
SgFunctionDefinition | |
SgFunctionParameterScope | |
SgGlobal | The global scope of a source file. |
SgIfStmt | This class represents the concept of an "if" construct. |
SgNamespaceDefinitionStatement | This class represents the concept of a namespace definition. |
SgRangeBasedForStatement | |
SgSwitchStatement | This class represents the concept of a switch. |
SgWhileStmt | This class represents a while statement. |
Created with MrDocs