Skip to content

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
SgScopeStatement
SgScopeStatement(Sg_File_Info* file_info = NULL); [constructor]
Default constructor
~SgScopeStatement
virtual ~SgScopeStatement(); [destructor] [virtual]
Destructor
accept
virtual void accept(ROSE_VisitorPattern& visitor) override; [virtual]
support for the classic visitor pattern done in GoF
appendDestructorOwnedNodes
virtual void appendDestructorOwnedNodes(std::vector<SgNode*>& nodes) const override; [virtual]
append_statement
void append_statement(SgStatement* stmt);
associatedScopeName
SgName associatedScopeName();
Return this scope's name for qualification.
class_name
virtual std::string class_name() const override; [virtual]
returns a string representing the class name
containsOnlyDeclarations
bool 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).
copy
virtual SgNode* copy(SgCopyHelp& help) const override; [virtual]
count_alias_symbol
size_t count_alias_symbol(SgName const& n);
Count for alias symbols of a specific name, used in name qualification support.
count_symbol
size_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_function
template<class T> SgFunctionSymbol* find_symbol_by_type_of_function( SgName const& name, SgType const* func_type, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentList);
find_symbol_from_declaration
SgSymbol* find_symbol_from_declaration(SgFunctionType const* node) const;
firstStatement
SgStatement* firstStatement() const;
first_any_symbol
SgSymbol* first_any_symbol() const;
get the first symbol independent of name (lack of name is stored as internal state)
first_class_symbol
SgClassSymbol* first_class_symbol() const;
first_enum_field_symbol
SgEnumFieldSymbol* first_enum_field_symbol() const;
first_enum_symbol
SgEnumSymbol* first_enum_symbol() const;
first_function_symbol
SgFunctionSymbol* first_function_symbol() const;
first_label_symbol
SgLabelSymbol* first_label_symbol() const;
first_namespace_symbol
SgNamespaceSymbol* first_namespace_symbol() const;
first_typedef_symbol
SgTypedefSymbol* first_typedef_symbol() const;
first_variable_symbol
SgVariableSymbol* first_variable_symbol() const;
fixupCopy_references
virtual void fixupCopy_references( SgNode* copy, SgCopyHelp& help) const override; [virtual]
fixupCopy_scopes
virtual void fixupCopy_scopes( SgNode* copy, SgCopyHelp& help) const override; [virtual]
fixupCopy_symbols
virtual void fixupCopy_symbols( SgNode* copy, SgCopyHelp& help) const override; [virtual]
generateStatementList
SgStatementPtrList const generateStatementList() const;
Return a statement-list copy of this scope's statements or declarations.
getDeclarationList
SgDeclarationStatementPtrList& getDeclarationList();
getStatementList
SgStatementPtrList& getStatementList();
get_auxiliary_declaration_scopes
SgDeclarationScopeList* get_auxiliary_declaration_scopes() const;
get_auxiliary_declarations
SgAuxiliaryDeclarationList* get_auxiliary_declarations() const;
get_childIndex
virtual size_t get_childIndex(SgNode* child) const override; [virtual]
index-based access to traversal successors by child node
get_mangled_name
virtual SgName get_mangled_name() const; [virtual]
get_numberOfTraversalSuccessors
virtual size_t get_numberOfTraversalSuccessors() const override; [virtual]
return number of children in the traversal successor list
get_pragma
SgPragma* get_pragma() const;
get_qualified_name
virtual SgName get_qualified_name() const; [virtual]
get_symbol_table
SgSymbolTable* get_symbol_table() const;
get_traversalSuccessorByIndex
virtual SgNode* get_traversalSuccessorByIndex(size_t idx) const override; [virtual]
index-based access to traversal successors by index number
get_traversalSuccessorContainer
virtual 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_traversalSuccessorIsListElement
virtual std::vector<bool> get_traversalSuccessorIsListElement() const override; [virtual]
get_traversalSuccessorNamesContainer
virtual 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_table
SgTypeTable* get_type_table() const;
hasAmbiguity
bool hasAmbiguity( SgName& name, SgSymbol* symbol);
insertStatementInScope
void insertStatementInScope( SgStatement* newTransformationStatement, bool atTop);
insert_symbol
void insert_symbol( SgName const& n, SgSymbol* s);
isCaseInsensitive
bool isCaseInsensitive() const;
Whether this scope's symbol table is case insensitive (Fortran).
isNamedScope
bool isNamedScope();
Whether this scope has a name for qualification.
lastStatement
SgStatement* lastStatement() const;
lookup_alias_symbol
SgAliasSymbol* lookup_alias_symbol( SgName const& n, SgSymbol* sp) const;
lookup_class_symbol
SgClassSymbol* lookup_class_symbol( SgName const& n, SgTemplateArgumentPtrList* templateArgumentsList = NULL) const;
lookup_enum_field_symbol
SgEnumFieldSymbol* lookup_enum_field_symbol(SgName const& n) const;
lookup_enum_symbol
SgEnumSymbol* lookup_enum_symbol(SgName const& n) const;
lookup_function_symbol
SgFunctionSymbol* lookup_function_symbol(SgName const& n) const;
lookup_label_symbol
SgLabelSymbol* lookup_label_symbol(SgName const& n) const;
lookup_namespace_symbol
SgNamespaceSymbol* lookup_namespace_symbol(SgName const& n) const;
lookup_nonreal_symbol
SgNonrealSymbol* lookup_nonreal_symbol( SgName const& n, SgTemplateParameterPtrList* templateParameterList = NULL, SgTemplateArgumentPtrList* templateArgumentsList = NULL) const;
lookup_nontemplate_class_symbol
SgClassSymbol* lookup_nontemplate_class_symbol(SgName const& n) const;
lookup_nontemplate_function_symbol
SgFunctionSymbol* lookup_nontemplate_function_symbol( SgName const& n, SgType const* t, SgTemplateArgumentPtrList* templateArgumentsList = NULL) const;
lookup_nontemplate_member_function_symbol
SgMemberFunctionSymbol* lookup_nontemplate_member_function_symbol( SgName const& n, SgType const* t, SgTemplateArgumentPtrList* templateArgumentsList = NULL) const;
lookup_symbol
SgSymbol* 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_fixup
SgSymbol* 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_qualification
SgSymbol* 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_symbol
SgTemplateClassSymbol* lookup_template_class_symbol( SgName const& n, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateSpecializationArgumentList) const;
lookup_template_function_symbol
SgTemplateFunctionSymbol* lookup_template_function_symbol( SgName const& n, SgType const* t, SgTemplateParameterPtrList* templateParameterList) const;
lookup_template_member_function_symbol
SgTemplateMemberFunctionSymbol* lookup_template_member_function_symbol( SgName const& n, SgType const* t, SgTemplateParameterPtrList* templateParameterList) const;
lookup_template_typedef_symbol
SgTemplateTypedefSymbol* lookup_template_typedef_symbol(SgName const& n) const;
lookup_template_variable_symbol
SgTemplateVariableSymbol* lookup_template_variable_symbol( SgName const& n, SgTemplateParameterPtrList* templateParameterList, SgTemplateArgumentPtrList* templateArgumentsList) const;
lookup_typedef_symbol
SgTypedefSymbol* lookup_typedef_symbol(SgName const& n) const;
lookup_variable_symbol
SgVariableSymbol* lookup_variable_symbol(SgName const& n) const;
next_any_symbol
SgSymbol* 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_symbol
SgClassSymbol* next_class_symbol() const;
next_enum_field_symbol
SgEnumFieldSymbol* next_enum_field_symbol() const;
next_enum_symbol
SgEnumSymbol* next_enum_symbol() const;
next_function_symbol
SgFunctionSymbol* next_function_symbol() const;
next_label_symbol
SgLabelSymbol* next_label_symbol() const;
next_namespace_symbol
SgNamespaceSymbol* next_namespace_symbol() const;
next_typedef_symbol
SgTypedefSymbol* next_typedef_symbol() const;
next_variable_symbol
SgVariableSymbol* next_variable_symbol() const;
operator delete
void operator delete( void* pointer, size_t size);
deallocated memory for IR node (returns memory to memory pool for reuse)
operator new
void* operator new(size_t size);
returns pointer to newly allocated IR node
post_construction_initialization
virtual void post_construction_initialization() override; [virtual]
prepend_statement
void prepend_statement(SgStatement* stmt);
print_symboltable
void print_symboltable(std::string const& str);
processDataMemberReferenceToPointers
virtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler*) override; [virtual]
Pass references to stored node pointers to a handler.
remove_symbol
void remove_symbol(SgSymbol* s);
returnDataMemberPointers
virtual std::vector<std::pair<SgNode*, std::string>> returnDataMemberPointers() const override; [virtual]
Return the node pointers stored in this node's data members.
roseRTI
virtual RTIReturnType roseRTI() override; [virtual]
return C++ Runtime-Time-Information
sage_class_name
virtual char const* sage_class_name() const override; [virtual]
returns a C style string (char*) representing the class name
setCaseInsensitive
void setCaseInsensitive(bool b);
set_auxiliary_declaration_scopes
void set_auxiliary_declaration_scopes(SgDeclarationScopeList* auxiliary_declaration_scopes);
set_auxiliary_declarations
void set_auxiliary_declarations(SgAuxiliaryDeclarationList* auxiliary_declarations);
set_pragma
void set_pragma(SgPragma* pragma);
set_symbol_table
void set_symbol_table(SgSymbolTable* symbol_table);
set_type_table
void set_type_table(SgTypeTable* type_table);
statementExistsInScope
bool statementExistsInScope(SgStatement* statement);
Test whether this scope contains the statement.
supportsDefiningFunctionDeclaration
bool 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_exists
bool symbol_exists(SgName const& name) const;
symbol_table_size
size_t symbol_table_size();
Return the size of the symbol table.
variantT
virtual VariantT variantT() const override; [virtual]
returns new style SageIII enum values

Static Member Functions

Name Description
isEquivalentScope
static bool isEquivalentScope( SgScopeStatement* scope1, SgScopeStatement* scope2);
memoryUsage
static size_t memoryUsage();
Returns the size in bytes of the total memory allocated for all IR nodes of this type
numberOfNodes
static size_t numberOfNodes();
Returns the total number of IR nodes of this type
traverseMemoryPoolNodes
static void traverseMemoryPoolNodes(ROSE_VisitTraversal& visit);
FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
traverseMemoryPoolVisitorPattern
static void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern& visitor);
FOR INTERNAL USE Support for visitor pattern.
visitRepresentativeNode
static 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