Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::Symbol Class Referenceabstract

Base class for named entities that participate in symbol lookup. More...

#include <bond/compiler/parsenodes.h>

Inheritance diagram for Bond::Symbol:
Bond::ListParseNode Bond::ParseNode Bond::CompoundStatement Bond::EnumDeclaration Bond::Enumerator Bond::ForStatement Bond::FunctionDefinition Bond::NamedInitializer Bond::NamespaceDefinition Bond::Parameter Bond::StructDeclaration Bond::SwitchSection

Public Types

enum  SymbolType {
  TYPE_NAMESPACE , TYPE_STRUCT , TYPE_ENUM , TYPE_LOCALSCOPE ,
  TYPE_VALUE , TYPE_FUNCTION
}
 Identifies the concrete symbol category. More...

Public Member Functions

virtual ~Symbol ()
virtual const TokenGetContextToken () const override
 Returns the token used as source context for diagnostics.
virtual SymbolType GetSymbolType () const =0
 Returns the concrete symbol type.
virtual const TokenGetName () const
 Returns the symbol name token.
virtual TypeAndValueGetTypeAndValue ()
 Returns the symbol's type-and-value metadata.
virtual const TypeAndValueGetTypeAndValue () const
 Returns the symbol's type-and-value metadata.
virtual bool IsResolved () const
 Returns true when symbol resolution has completed for this symbol.
bool IsTypeDefinition () const
 Returns true if this symbol defines a type.
SymbolGetParentSymbol ()
 Returns the enclosing symbol.
const SymbolGetParentSymbol () const
 Returns the enclosing symbol.
void SetParentSymbol (Symbol *parent)
 Sets the enclosing symbol.
SymbolFindSymbol (const StringView &name)
 Finds a directly contained symbol by name.
const SymbolFindSymbol (const StringView &name) const
 Finds a directly contained symbol by name.
SymbolFindSymbol (const Token *name)
 Finds a directly contained symbol by token text.
const SymbolFindSymbol (const Token *name) const
 Finds a directly contained symbol by token text.
SymbolFindSymbol (const QualifiedIdentifier *identifier)
 Finds a symbol referenced by a qualified identifier.
const SymbolFindSymbol (const QualifiedIdentifier *identifier) const
 Finds a symbol referenced by a qualified identifier.
void InsertSymbol (Symbol *symbol)
 Inserts a symbol into this symbol's child list.
bool IsAnonymous () const
 Returns true if this symbol has no explicit name.
bool Matches (const StringView &name) const
 Returns true if this symbol's name matches the given text.
Public Member Functions inherited from Bond::ListParseNode
virtual ~ListParseNode ()
ListParseNodeGetNextNode ()
 Returns the next node in the list.
const ListParseNodeGetNextNode () const
 Returns the next node in the list.
void SetNextNode (ListParseNode *next)
 Sets the next node in the list.
Public Member Functions inherited from Bond::ParseNode
virtual ~ParseNode ()
virtual void Accept (ParseNodeVisitor &visitor)=0
 Dispatches this node to the given visitor.
virtual void Accept (ParseNodeVisitor &visitor) const =0
 Dispatches this node to the given visitor.

Protected Member Functions

 Symbol ()
Protected Member Functions inherited from Bond::ListParseNode
 ListParseNode ()
Protected Member Functions inherited from Bond::ParseNode
 ParseNode ()

Detailed Description

Base class for named entities that participate in symbol lookup.

Member Enumeration Documentation

◆ SymbolType

Identifies the concrete symbol category.

Enumerator
TYPE_NAMESPACE 

Namespace declaration symbol.

TYPE_STRUCT 

Struct declaration symbol.

TYPE_ENUM 

Enum declaration symbol.

TYPE_LOCALSCOPE 

Local scope symbol.

TYPE_VALUE 

Value symbol, such as a variable or enumerator.

TYPE_FUNCTION 

Function symbol.

Constructor & Destructor Documentation

◆ ~Symbol()

virtual Bond::Symbol::~Symbol ( )
inlinevirtual

◆ Symbol()

Bond::Symbol::Symbol ( )
inlineprotected

Member Function Documentation

◆ FindSymbol() [1/6]

Symbol * Bond::Symbol::FindSymbol ( const QualifiedIdentifier * identifier)

Finds a symbol referenced by a qualified identifier.

Parameters
identifierQualified identifier to resolve.
Returns
Matching symbol, or null if not found.

◆ FindSymbol() [2/6]

const Symbol * Bond::Symbol::FindSymbol ( const QualifiedIdentifier * identifier) const

Finds a symbol referenced by a qualified identifier.

Parameters
identifierQualified identifier to resolve.
Returns
Matching symbol, or null if not found.

◆ FindSymbol() [3/6]

Symbol * Bond::Symbol::FindSymbol ( const StringView & name)

Finds a directly contained symbol by name.

Parameters
nameName to search for.
Returns
Matching symbol, or null if not found.

◆ FindSymbol() [4/6]

const Symbol * Bond::Symbol::FindSymbol ( const StringView & name) const

Finds a directly contained symbol by name.

Parameters
nameName to search for.
Returns
Matching symbol, or null if not found.

◆ FindSymbol() [5/6]

Symbol * Bond::Symbol::FindSymbol ( const Token * name)
inline

Finds a directly contained symbol by token text.

Parameters
nameName token to search for.
Returns
Matching symbol, or null if not found.

◆ FindSymbol() [6/6]

const Symbol * Bond::Symbol::FindSymbol ( const Token * name) const
inline

Finds a directly contained symbol by token text.

Parameters
nameName token to search for.
Returns
Matching symbol, or null if not found.

◆ GetContextToken()

virtual const Token * Bond::Symbol::GetContextToken ( ) const
inlineoverridevirtual

Returns the token used as source context for diagnostics.

Returns
A token associated with this node, or null if no token applies.

Implements Bond::ParseNode.

Reimplemented in Bond::ForStatement.

◆ GetName()

virtual const Token * Bond::Symbol::GetName ( ) const
inlinevirtual

Returns the symbol name token.

Returns
The name token, or null for anonymous symbols.

Reimplemented in Bond::EnumDeclaration, Bond::Enumerator, Bond::FunctionDefinition, Bond::NamedInitializer, Bond::NamespaceDefinition, Bond::Parameter, and Bond::StructDeclaration.

◆ GetParentSymbol() [1/2]

Symbol * Bond::Symbol::GetParentSymbol ( )
inline

Returns the enclosing symbol.

Returns
The parent symbol, or null at global scope.

◆ GetParentSymbol() [2/2]

const Symbol * Bond::Symbol::GetParentSymbol ( ) const
inline

Returns the enclosing symbol.

Returns
The parent symbol, or null at global scope.

◆ GetSymbolType()

◆ GetTypeAndValue() [1/2]

virtual TypeAndValue * Bond::Symbol::GetTypeAndValue ( )
inlinevirtual

Returns the symbol's type-and-value metadata.

Returns
Type and value information, or null if not applicable.

Reimplemented in Bond::Enumerator, Bond::FunctionDefinition, Bond::NamedInitializer, and Bond::Parameter.

◆ GetTypeAndValue() [2/2]

virtual const TypeAndValue * Bond::Symbol::GetTypeAndValue ( ) const
inlinevirtual

Returns the symbol's type-and-value metadata.

Returns
Type and value information, or null if not applicable.

Reimplemented in Bond::Enumerator, Bond::FunctionDefinition, Bond::NamedInitializer, and Bond::Parameter.

◆ InsertSymbol()

void Bond::Symbol::InsertSymbol ( Symbol * symbol)

Inserts a symbol into this symbol's child list.

Parameters
symbolSymbol to insert.

◆ IsAnonymous()

bool Bond::Symbol::IsAnonymous ( ) const
inline

Returns true if this symbol has no explicit name.

◆ IsResolved()

virtual bool Bond::Symbol::IsResolved ( ) const
inlinevirtual

Returns true when symbol resolution has completed for this symbol.

Reimplemented in Bond::StructDeclaration.

◆ IsTypeDefinition()

bool Bond::Symbol::IsTypeDefinition ( ) const

Returns true if this symbol defines a type.

◆ Matches()

bool Bond::Symbol::Matches ( const StringView & name) const

Returns true if this symbol's name matches the given text.

Parameters
nameName to compare against.

◆ SetParentSymbol()

void Bond::Symbol::SetParentSymbol ( Symbol * parent)

Sets the enclosing symbol.

Parameters
parentParent symbol to assign.

The documentation for this class was generated from the following file:
  • include/bond/compiler/parsenodes.h