SgSymbol¶
This class represents the concept of a name within the compiler.
Synopsis¶
Declared in <src/frontend/SageIII/Cxx_Grammar.h> (not stored in Git)
class [[visibility("default")]] SgSymbol
: public SgNode Description¶
Symbols are a simpler way for the compiler to quickly associate types, declarations and names. It is also more compact than carrying around names as strings. The SgSymbol can contain many references and is a shared IR node. A "symbol" within the compiler is a concept of a name. The simplest example is a variable name, the variable most often has a name but internally within the compiler the variable is referenced as a symbol, the symbol data struction contains a name, type, and declaration (where the name was first associated with the type). Each variable has an associated symbol and each variable reference internally stores a pointer to the single symbol representing that variable. this avoids the compiler internally relying upon string processing to compile variable (different symbols can be trivially compared to either have the same address on not). Each named entity within the language's translation within the AST has a unique symbol. Mappings from names to symbols are held in the "Symbol Table" which provides for a quick (hashed) lookup on the symbol for any name. Mappings from the symbol to the name are held through pointers to the declaration (stored within the symbol). To organize the symbols, they are differentiated by type, each symbol is derived from the SgSymbol class and defines a specialized interface for that specific kind of IR node. For example, there are symbol objects specific to classes, templates, variable, enums, functions, member functions, lables, function types, namespaces, typedefs, etc. In each case these symbols contain a name (or method for generating a name when it is located elsewhere), and a declaration, and often a reference to a type (or function to returning the type if not held in the symbol directly). Each SgSymbol has a get_name() member function which gets the associated name of the symbol, usually from the stored declaration. A few symbols have an explicitly stored name (SgName), this is done where the name is derived from a named type (SgNamedType). IMPORTANT: Declarations in Symbols Indepedent of the different kinds of declarations (declarations are statements), declarations can be considered to be definind and non-defining. See SgDeclarationStatement for details. where there exist defining and non-defining declarations symbols within Sage III always reference non-defining declarations (only non-defining declarations are shared within the AST).
- Internal: This is a base class for all symbols.
- Todo: Consider derivation of SgEnumSymbol, SgClassSymbol, SgFunctionTypeSymbol, and SgTypedefSymbol from a common SgTypeSymbol. Then supporting functions for SgTypeSymbol would lookup any of these type based symbols.
- See also: SgDeclarationStatement
- See also: Example of using a SgSymbol object
Member functions
SgSymbol::get_name() const¶
Access function for getting name from declarations or types internally.
- Internal: This is a virtual function.
- Return: Returns SgName.
SgSymbol::get_type() const¶
This function returns the type associated with the named entity.
- Internal: This is a virtual function.
- Return: Returns SgType*.
Base Classes¶
| Name | Description |
|---|---|
SgNode | This class represents the base class for all IR nodes within Sage III. |
Type Aliases¶
| Name |
|---|
base_node_type |
Enums¶
| Name | Description |
|---|---|
Unnamed enum | static variant value |
Member Functions¶
| Name | Description |
|---|---|
SgSymbolSgSymbol(); [constructor] | Default constructor |
~SgSymbolvirtual ~SgSymbol(); [destructor] [virtual] | Destructor |
acceptvirtual void accept(ROSE_VisitorPattern& visitor) override; [virtual] | support for the classic visitor pattern done in GoF |
addNewAttributevirtual void addNewAttribute( std::string s, AstAttribute* a) override; [virtual] | Add a new attribute represented by the named string. |
appendDestructorOwnedNodesvirtual void appendDestructorOwnedNodes(std::vector<SgNode*>& nodes) const override; [virtual] | |
attributeExistsvirtual bool attributeExists(std::string s) const override; [virtual] | Tests if attribute of name 's' is present. |
class_namevirtual std::string class_name() const override; [virtual] | returns a string representing the class name |
getAttributevirtual AstAttribute* getAttribute(std::string s) const override; [virtual] | Returns attribute of name 's'. |
get_attributeMechanismvirtual AstAttributeMechanism* get_attributeMechanism() const override; [virtual] | |
get_childIndexvirtual size_t get_childIndex(SgNode* child) const override; [virtual] | index-based access to traversal successors by child node |
get_mangled_nameSgName get_mangled_name() const; | |
get_namevirtual SgName get_name() const = 0; [virtual] | |
get_numberOfTraversalSuccessorsvirtual size_t get_numberOfTraversalSuccessors() const override; [virtual] | return number of children in the traversal successor list |
get_scopevirtual SgScopeStatement* get_scope() const; [virtual] | |
get_symbol_basisvirtual SgNode* get_symbol_basis() const; [virtual] | |
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_typevirtual SgType* get_type() const = 0; [virtual] | |
numberOfAttributesvirtual int numberOfAttributes() const override; [virtual] | Returns the number of attributes on this IR node. |
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 |
processDataMemberReferenceToPointersvirtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler*) override; [virtual] | Pass references to stored node pointers to a handler. |
removeAttributevirtual void removeAttribute(std::string s) override; [virtual] | Remove attribute of name 's' if present. |
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 |
setAttributevirtual void setAttribute( std::string s, AstAttribute* a) override; [virtual] | This is a wrapper function with the following semantics: if no attribute of name 's' exists then addNewAttribute(s,a); is called, otherwise updateAttribute(s,a); is called. |
set_attributeMechanismvirtual void set_attributeMechanism(AstAttributeMechanism* attributeMechanism) override; [virtual] | |
updateAttributevirtual void updateAttribute( std::string s, AstAttribute* a) override; [virtual] | Replace existing attribute of name 's' with new AstAttribute. |
variantTvirtual VariantT variantT() const override; [virtual] | returns new style SageIII enum values |
Static Member Functions¶
| Name | Description |
|---|---|
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_attributeMechanism |
Friends¶
| Name | Description |
|---|---|
isSgSymbol | Casts pointer from base class to derived class (for const pointers) |
isSgSymbol | Casts pointer from base class to derived class |
Derived Classes¶
| Name | Description |
|---|---|
SgAliasSymbol | |
SgClassSymbol | This class represents the concept of a class name within the compiler. |
SgCommonSymbol | |
SgDefaultSymbol | |
SgEnumFieldSymbol | |
SgEnumSymbol | |
SgFunctionSymbol | |
SgFunctionTypeSymbol | This class represents the concept of a name and a type. It may be |
SgInterfaceSymbol | |
SgIntrinsicSymbol | |
SgLabelSymbol | |
SgModuleSymbol | |
SgNamelistSymbol | |
SgNamespaceSymbol | This class represents the concept of a namespace name within the compiler. |
SgNonrealSymbol | |
SgTemplateSymbol | |
SgTypedefSymbol | |
SgVariableSymbol | This class represents the concept of a variable name within the compiler (a |
Created with MrDocs