Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::UsingDeclaration Class Reference

Represents a using-declaration that aliases a single symbol into local scope. More...

#include <bond/compiler/parsenodes.h>

Inheritance diagram for Bond::UsingDeclaration:
Bond::Symbol Bond::ListParseNode Bond::ParseNode

Public Member Functions

 UsingDeclaration (QualifiedIdentifier *identifier)
 Constructs a using-declaration.
virtual ~UsingDeclaration ()
 Destroys a UsingDeclaration object.
virtual void Accept (ParseNodeVisitor &visitor) override
 Dispatches this node to the given visitor.
virtual void Accept (ParseNodeVisitor &visitor) const override
 Dispatches this node to the given visitor.
virtual SymbolType GetSymbolType () const override
 Returns the concrete symbol type.
virtual const Token * GetName () const override
 Returns the symbol name token.
virtual TypeAndValue * GetTypeAndValue () override
 Returns the symbol's type-and-value metadata.
virtual const TypeAndValue * GetTypeAndValue () const override
 Returns the symbol's type-and-value metadata.
virtual bool IsResolved () const override
 Returns true when symbol resolution has completed for this symbol.
QualifiedIdentifier * GetIdentifier ()
 Returns the qualified identifier naming the symbol to bring into scope.
const QualifiedIdentifier * GetIdentifier () const
 Returns the qualified identifier naming the symbol to bring into scope.
void SetTarget (Symbol *target)
 Sets the resolved symbol that this declaration aliases.
Symbol * GetTarget ()
 Returns the resolved symbol that this declaration aliases, if any.
virtual Symbol * Resolve () override
 Returns the symbol that lookups through this symbol should ultimately resolve to.
virtual const Symbol * Resolve () const override
 Returns the symbol that lookups through this symbol should ultimately resolve to.
Public Member Functions inherited from Bond::Symbol
virtual ~Symbol ()
 Destroys a Symbol object.
virtual const Token * GetContextToken () const override
 Returns the token used as source context for diagnostics.
bool IsTypeDefinition () const
 Returns true if this symbol defines a type, i.e. it is a struct or an enum.
Symbol * GetParentSymbol ()
 Returns the enclosing symbol.
const Symbol * GetParentSymbol () const
 Returns the enclosing symbol.
void SetParentSymbol (Symbol *parent)
 Sets the enclosing symbol.
Symbol * FindSymbol (const StringView &name)
 Finds a directly contained symbol by name.
const Symbol * FindSymbol (const StringView &name) const
 Finds a directly contained symbol by name.
Symbol * FindSymbol (const Token *name)
 Finds a directly contained symbol by token text.
const Symbol * FindSymbol (const Token *name) const
 Finds a directly contained symbol by token text.
Symbol * FindSymbol (const QualifiedIdentifier *identifier)
 Finds a symbol referenced by a qualified identifier.
const Symbol * FindSymbol (const QualifiedIdentifier *identifier) const
 Finds a symbol referenced by a qualified identifier.
Symbol * FindSymbol (const QualifiedIdentifier *identifier, bool &isAmbiguous)
 Finds a symbol referenced by a qualified identifier, flagging ambiguous matches.
const Symbol * FindSymbol (const QualifiedIdentifier *identifier, bool &isAmbiguous) const
 Finds a symbol referenced by a qualified identifier, flagging ambiguous matches.
void InsertSymbol (Symbol *symbol)
 Inserts a symbol at the front of this symbol's child list and sets this symbol as its parent.
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.
virtual UsingDirective * GetUsingNamespaceList ()
 Returns the list of namespaces opened in this scope via using-directives.
virtual const UsingDirective * GetUsingNamespaceList () const
 Returns the list of namespaces opened in this scope via using-directives.
virtual void AddUsingNamespace (UsingDirective *usingDirective)
 Opens a namespace into this scope, making its members visible to unqualified lookup.
Public Member Functions inherited from Bond::ListParseNode
virtual ~ListParseNode ()
 Destroys a ListParseNode object.
ListParseNode * GetNextNode ()
 Returns the next node in the list.
const ListParseNode * GetNextNode () 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 ()
 Destroys a ParseNode object.

Additional Inherited Members

Public Types inherited from Bond::Symbol
enum  SymbolType {
  TYPE_NAMESPACE , TYPE_STRUCT , TYPE_ENUM , TYPE_LOCALSCOPE ,
  TYPE_VALUE , TYPE_FUNCTION
}
 Identifies the concrete symbol category. More...
Protected Member Functions inherited from Bond::Symbol
 Symbol ()
Protected Member Functions inherited from Bond::ListParseNode
 ListParseNode ()
Protected Member Functions inherited from Bond::ParseNode
 ParseNode ()

Detailed Description

Represents a using-declaration that aliases a single symbol into local scope.

Participates in symbol lookup as an ordinary Symbol so that it can be linked into the intrusive scope list like any other local declaration, but Symbol::Resolve() causes lookups to transparently unwrap it to the aliased target, so no other part of the compiler ever observes a UsingDeclaration.

Constructor & Destructor Documentation

◆ UsingDeclaration()

Bond::UsingDeclaration::UsingDeclaration ( QualifiedIdentifier * identifier)
explicit

Constructs a using-declaration.

Parameters
identifierQualified identifier naming the symbol to bring into scope.

◆ ~UsingDeclaration()

virtual Bond::UsingDeclaration::~UsingDeclaration ( )
inlinevirtual

Destroys a UsingDeclaration object.

Member Function Documentation

◆ Accept() [1/2]

virtual void Bond::UsingDeclaration::Accept ( ParseNodeVisitor & visitor) const
inlineoverridevirtual

Dispatches this node to the given visitor.

Parameters
visitorVisitor that handles this node type.

Implements Bond::ParseNode.

◆ Accept() [2/2]

virtual void Bond::UsingDeclaration::Accept ( ParseNodeVisitor & visitor)
inlineoverridevirtual

Dispatches this node to the given visitor.

Parameters
visitorVisitor that handles this node type.

Implements Bond::ParseNode.

◆ GetIdentifier() [1/2]

QualifiedIdentifier * Bond::UsingDeclaration::GetIdentifier ( )
inline

Returns the qualified identifier naming the symbol to bring into scope.

◆ GetIdentifier() [2/2]

const QualifiedIdentifier * Bond::UsingDeclaration::GetIdentifier ( ) const
inline

Returns the qualified identifier naming the symbol to bring into scope.

◆ GetName()

virtual const Token * Bond::UsingDeclaration::GetName ( ) const
inlineoverridevirtual

Returns the symbol name token.

Returns
The name token, or null for anonymous symbols.

Reimplemented from Bond::Symbol.

◆ GetSymbolType()

virtual SymbolType Bond::UsingDeclaration::GetSymbolType ( ) const
inlineoverridevirtual

Returns the concrete symbol type.

Implements Bond::Symbol.

◆ GetTarget()

Symbol * Bond::UsingDeclaration::GetTarget ( )
inline

Returns the resolved symbol that this declaration aliases, if any.

◆ GetTypeAndValue() [1/2]

virtual const TypeAndValue * Bond::UsingDeclaration::GetTypeAndValue ( ) const
inlineoverridevirtual

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

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

Reimplemented from Bond::Symbol.

◆ GetTypeAndValue() [2/2]

virtual TypeAndValue * Bond::UsingDeclaration::GetTypeAndValue ( )
inlineoverridevirtual

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

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

Reimplemented from Bond::Symbol.

◆ IsResolved()

virtual bool Bond::UsingDeclaration::IsResolved ( ) const
inlineoverridevirtual

Returns true when symbol resolution has completed for this symbol.

Reimplemented from Bond::Symbol.

◆ Resolve() [1/2]

virtual const Symbol * Bond::UsingDeclaration::Resolve ( ) const
inlineoverridevirtual

Returns the symbol that lookups through this symbol should ultimately resolve to.

Reimplemented from Bond::Symbol.

◆ Resolve() [2/2]

virtual Symbol * Bond::UsingDeclaration::Resolve ( )
inlineoverridevirtual

Returns the symbol that lookups through this symbol should ultimately resolve to.

Overridden by UsingDeclaration so that a using-declaration alias is never observed outside of symbol lookup; every other symbol resolves to itself.

Reimplemented from Bond::Symbol.

◆ SetTarget()

void Bond::UsingDeclaration::SetTarget ( Symbol * target)
inline

Sets the resolved symbol that this declaration aliases.

Parameters
targetSymbol to alias.

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