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

Represents a struct declaration. More...

#include <bond/compiler/parsenodes.h>

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

Public Types

enum  Variant { VARIANT_BOND , VARIANT_NATIVE , VARIANT_NATIVE_STUB }
 Identifies the implementation variant of a struct. More...
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...

Public Member Functions

 StructDeclaration (const Token *name, const Token *size, const Token *alignment, FunctionDefinition *memberFunctionList, DeclarativeStatement *memberVariableList, Variant variant)
 Constructs a struct declaration.
virtual ~StructDeclaration ()
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 bool IsResolved () const override
 Returns true when this struct and its members are resolved.
TypeDescriptor & GetThisTypeDescriptor ()
 Returns the descriptor of this-parameter type.
const TypeDescriptor & GetThisTypeDescriptor () const
 Returns the descriptor of this-parameter type.
TypeDescriptor & GetConstThisTypeDescriptor ()
 Returns the descriptor of const this-parameter type.
const TypeDescriptor & GetConstThisTypeDescriptor () const
 Returns the descriptor of const this-parameter type.
const Token * GetSizeToken () const
 Returns the token specifying struct size metadata.
const Token * GetAlignmentToken () const
 Returns the token specifying struct alignment metadata.
FunctionDefinition * GetMemberFunctionList ()
 Returns the list of member functions.
const FunctionDefinition * GetMemberFunctionList () const
 Returns the list of member functions.
void SetMemberFunctionList (FunctionDefinition *memberFunctionList)
 Sets the list of member functions.
DeclarativeStatement * GetMemberVariableList ()
 Returns the list of member variables.
const DeclarativeStatement * GetMemberVariableList () const
 Returns the list of member variables.
void SetMemberVariableList (DeclarativeStatement *memberVariableList)
 Sets the list of member variables.
const StructDeclaration * GetSizeSpecifier () const
 Returns the struct used to determine this struct's size.
void SetSizeSpecifier (const StructDeclaration *sizeSpecifier)
 Sets the struct used to determine this struct's size.
Variant GetVariant () const
 Returns this struct declaration's variant.
bool IsNative () const
 Returns true if this struct is native-backed.
uint32_t GetSize () const
 Returns the resolved size in bytes.
void SetSize (uint32_t size)
 Sets the resolved size in bytes.
uint32_t GetAlignment () const
 Returns the resolved alignment in bytes.
void SetAlignment (uint32_t alignment)
 Sets the resolved alignment in bytes.
bool IsInstantiable () const
 Returns true if instances of this struct can be created.
Public Member Functions inherited from Bond::Symbol
virtual ~Symbol ()
virtual const Token * GetContextToken () const override
 Returns the token used as source context for diagnostics.
virtual TypeAndValue * GetTypeAndValue ()
 Returns the symbol's type-and-value metadata.
virtual const TypeAndValue * GetTypeAndValue () const
 Returns the symbol's type-and-value metadata.
bool IsTypeDefinition () const
 Returns true if this symbol defines a type.
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.
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 ()
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 ()

Additional Inherited Members

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 struct declaration.

Member Enumeration Documentation

◆ Variant

Identifies the implementation variant of a struct.

Enumerator
VARIANT_BOND 

Bond-defined struct.

VARIANT_NATIVE 

Struct mapped to a native type.

VARIANT_NATIVE_STUB 

Stub for a native struct declaration.

Constructor & Destructor Documentation

◆ StructDeclaration()

Bond::StructDeclaration::StructDeclaration ( const Token * name,
const Token * size,
const Token * alignment,
FunctionDefinition * memberFunctionList,
DeclarativeStatement * memberVariableList,
Variant variant )
inline

Constructs a struct declaration.

Parameters
nameStruct name token.
sizeOptional token describing explicit size metadata.
alignmentOptional token describing explicit alignment metadata.
memberFunctionListList of member functions.
memberVariableListList of member variables.
variantStruct implementation variant.

◆ ~StructDeclaration()

virtual Bond::StructDeclaration::~StructDeclaration ( )
inlinevirtual

Member Function Documentation

◆ Accept() [1/2]

virtual void Bond::StructDeclaration::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::StructDeclaration::Accept ( ParseNodeVisitor & visitor)
inlineoverridevirtual

Dispatches this node to the given visitor.

Parameters
visitorVisitor that handles this node type.

Implements Bond::ParseNode.

◆ GetAlignment()

uint32_t Bond::StructDeclaration::GetAlignment ( ) const
inline

Returns the resolved alignment in bytes.

◆ GetAlignmentToken()

const Token * Bond::StructDeclaration::GetAlignmentToken ( ) const
inline

Returns the token specifying struct alignment metadata.

◆ GetConstThisTypeDescriptor() [1/2]

TypeDescriptor & Bond::StructDeclaration::GetConstThisTypeDescriptor ( )
inline

Returns the descriptor of const this-parameter type.

◆ GetConstThisTypeDescriptor() [2/2]

const TypeDescriptor & Bond::StructDeclaration::GetConstThisTypeDescriptor ( ) const
inline

Returns the descriptor of const this-parameter type.

◆ GetMemberFunctionList() [1/2]

FunctionDefinition * Bond::StructDeclaration::GetMemberFunctionList ( )
inline

Returns the list of member functions.

◆ GetMemberFunctionList() [2/2]

const FunctionDefinition * Bond::StructDeclaration::GetMemberFunctionList ( ) const
inline

Returns the list of member functions.

◆ GetMemberVariableList() [1/2]

DeclarativeStatement * Bond::StructDeclaration::GetMemberVariableList ( )
inline

Returns the list of member variables.

◆ GetMemberVariableList() [2/2]

const DeclarativeStatement * Bond::StructDeclaration::GetMemberVariableList ( ) const
inline

Returns the list of member variables.

◆ GetName()

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

Returns the symbol name token.

Returns
The name token, or null for anonymous symbols.

Reimplemented from Bond::Symbol.

◆ GetSize()

uint32_t Bond::StructDeclaration::GetSize ( ) const
inline

Returns the resolved size in bytes.

◆ GetSizeSpecifier()

const StructDeclaration * Bond::StructDeclaration::GetSizeSpecifier ( ) const
inline

Returns the struct used to determine this struct's size.

◆ GetSizeToken()

const Token * Bond::StructDeclaration::GetSizeToken ( ) const
inline

Returns the token specifying struct size metadata.

◆ GetSymbolType()

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

Returns the concrete symbol type.

Implements Bond::Symbol.

◆ GetThisTypeDescriptor() [1/2]

TypeDescriptor & Bond::StructDeclaration::GetThisTypeDescriptor ( )
inline

Returns the descriptor of this-parameter type.

◆ GetThisTypeDescriptor() [2/2]

const TypeDescriptor & Bond::StructDeclaration::GetThisTypeDescriptor ( ) const
inline

Returns the descriptor of this-parameter type.

◆ GetVariant()

Variant Bond::StructDeclaration::GetVariant ( ) const
inline

Returns this struct declaration's variant.

◆ IsInstantiable()

bool Bond::StructDeclaration::IsInstantiable ( ) const
inline

Returns true if instances of this struct can be created.

◆ IsNative()

bool Bond::StructDeclaration::IsNative ( ) const
inline

Returns true if this struct is native-backed.

◆ IsResolved()

virtual bool Bond::StructDeclaration::IsResolved ( ) const
overridevirtual

Returns true when this struct and its members are resolved.

Reimplemented from Bond::Symbol.

◆ SetAlignment()

void Bond::StructDeclaration::SetAlignment ( uint32_t alignment)
inline

Sets the resolved alignment in bytes.

Parameters
alignmentStruct alignment in bytes.

◆ SetMemberFunctionList()

void Bond::StructDeclaration::SetMemberFunctionList ( FunctionDefinition * memberFunctionList)
inline

Sets the list of member functions.

Parameters
memberFunctionListHead of member function list.

◆ SetMemberVariableList()

void Bond::StructDeclaration::SetMemberVariableList ( DeclarativeStatement * memberVariableList)
inline

Sets the list of member variables.

Parameters
memberVariableListHead of member variable list.

◆ SetSize()

void Bond::StructDeclaration::SetSize ( uint32_t size)
inline

Sets the resolved size in bytes.

Parameters
sizeStruct size in bytes.

◆ SetSizeSpecifier()

void Bond::StructDeclaration::SetSizeSpecifier ( const StructDeclaration * sizeSpecifier)
inline

Sets the struct used to determine this struct's size.

Parameters
sizeSpecifierStruct whose size metadata should be used.

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