Skip to content

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
SgSymbol
SgSymbol(); [constructor]
Default constructor
~SgSymbol
virtual ~SgSymbol(); [destructor] [virtual]
Destructor
accept
virtual void accept(ROSE_VisitorPattern& visitor) override; [virtual]
support for the classic visitor pattern done in GoF
addNewAttribute
virtual void addNewAttribute( std::string s, AstAttribute* a) override; [virtual]
Add a new attribute represented by the named string.
appendDestructorOwnedNodes
virtual void appendDestructorOwnedNodes(std::vector<SgNode*>& nodes) const override; [virtual]
attributeExists
virtual bool attributeExists(std::string s) const override; [virtual]
Tests if attribute of name 's' is present.
class_name
virtual std::string class_name() const override; [virtual]
returns a string representing the class name
getAttribute
virtual AstAttribute* getAttribute(std::string s) const override; [virtual]
Returns attribute of name 's'.
get_attributeMechanism
virtual AstAttributeMechanism* get_attributeMechanism() const override; [virtual]
get_childIndex
virtual size_t get_childIndex(SgNode* child) const override; [virtual]
index-based access to traversal successors by child node
get_mangled_name
SgName get_mangled_name() const;
get_name
virtual SgName get_name() const = 0; [virtual]
get_numberOfTraversalSuccessors
virtual size_t get_numberOfTraversalSuccessors() const override; [virtual]
return number of children in the traversal successor list
get_scope
virtual SgScopeStatement* get_scope() const; [virtual]
get_symbol_basis
virtual SgNode* get_symbol_basis() const; [virtual]
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
virtual SgType* get_type() const = 0; [virtual]
numberOfAttributes
virtual int numberOfAttributes() const override; [virtual]
Returns the number of attributes on this IR node.
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
processDataMemberReferenceToPointers
virtual void processDataMemberReferenceToPointers(ReferenceToPointerHandler*) override; [virtual]
Pass references to stored node pointers to a handler.
removeAttribute
virtual void removeAttribute(std::string s) override; [virtual]
Remove attribute of name 's' if present.
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
setAttribute
virtual 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_attributeMechanism
virtual void set_attributeMechanism(AstAttributeMechanism* attributeMechanism) override; [virtual]
updateAttribute
virtual void updateAttribute( std::string s, AstAttribute* a) override; [virtual]
Replace existing attribute of name 's' with new AstAttribute.
variantT
virtual VariantT variantT() const override; [virtual]
returns new style SageIII enum values

Static Member Functions

Name Description
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_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