sun::ast::ClassDefinitionAST

sun::ast::ClassDefinitionAST

class · Source (opens in a new tab)

class sun::ast::ClassDefinitionAST : public sun::ast::ExprAST

Class definition: class Name<T, U> implements Interface1<T>, Interface2 { fields and methods }.

Inherits

Public Functions

ClassDefinitionAST

public · function · Source (opens in a new tab)

sun::ast::ClassDefinitionAST::ClassDefinitionAST(std::string name, std::vector< TypeParameter > typeParams, std::vector< ImplementedInterfaceAST > interfaces, std::vector< ClassFieldDecl > fields, std::vector< ClassMethodDecl > methods, bool precompiled=false)

Creates this syntax node and takes ownership of any supplied child expressions.

Related: TypeParameter, ImplementedInterfaceAST, ClassFieldDecl, ClassMethodDecl

addCompiledSpecialization

public · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::addCompiledSpecialization(std::string key)

Record a specialization supplied by the imported bundle.

addSpecialization

public · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::addSpecialization(DeclarationId id, std::shared_ptr< ClassDefinitionAST > specializedAST) const

Specialization storage for generic classes Called by semantic analyzer when a generic class is instantiated.

Related: DeclarationId, ClassDefinitionAST

classKeyword

public · function · Source (opens in a new tab)

const char * sun::ast::ClassDefinitionAST::classKeyword() const

Keyword that introduces this qualifiedName in source.

dotLabel

public · function · Source (opens in a new tab)

std::string sun::ast::ClassDefinitionAST::dotLabel() const override

Returns the node label used in syntax-tree graph visualizations.

forEachChildSlot

public · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::forEachChildSlot(const ChildSlotFn &fn) override

Visits replaceable child expressions so tree passes can rewrite them in place.

Related: ChildSlotFn

getCompiledSpecializations

public · function · Source (opens in a new tab)

const std::set< std::string > & sun::ast::ClassDefinitionAST::getCompiledSpecializations() const

Return the specializations already compiled into the bundle.

getConstructor

public · function · Source (opens in a new tab)

const ClassMethodDecl * sun::ast::ClassDefinitionAST::getConstructor() const

Find the constructor (init method).

Related: ClassMethodDecl

getDoc

public · function · Source (opens in a new tab)

const std::string & sun::ast::ClassDefinitionAST::getDoc() const

Comment written above the class (see doc_comments.h).

Related: doc_comments.h

getFields

public · function · Source (opens in a new tab)

const std::vector< ClassFieldDecl > & sun::ast::ClassDefinitionAST::getFields() const

Provides the field declarations belonging to this type.

Related: ClassFieldDecl

getImplementedInterfaces

public · function · Source (opens in a new tab)

const std::vector< ImplementedInterfaceAST > & sun::ast::ClassDefinitionAST::getImplementedInterfaces() const

Provides the interfaces implemented by this class.

Related: ImplementedInterfaceAST

getLifetimeParameters

public · function · Source (opens in a new tab)

const std::vector< LifetimeParameter > & sun::ast::ClassDefinitionAST::getLifetimeParameters() const

Provides the declared lifetime parameters used to check borrowed values.

Related: LifetimeParameter

getMethods

public · function · Source (opens in a new tab)

const std::vector< ClassMethodDecl > & sun::ast::ClassDefinitionAST::getMethods() const

Provides the method declarations belonging to this type.

Related: ClassMethodDecl

getMutableFields

public · function · Source (opens in a new tab)

std::vector< ClassFieldDecl > & sun::ast::ClassDefinitionAST::getMutableFields()

Provides mutable access to field declarations for later compiler passes.

Related: ClassFieldDecl

getMutableMethods

public · function · Source (opens in a new tab)

std::vector< ClassMethodDecl > & sun::ast::ClassDefinitionAST::getMutableMethods()

Allow adding methods from extensions (mutable for merging).

Related: ClassMethodDecl

getName

public · function · Source (opens in a new tab)

const std::string & sun::ast::ClassDefinitionAST::getName() const

Returns the declared name used to identify this object.

getQualifiedName

public · function · Source (opens in a new tab)

const sun::semantic_analysis::QualifiedName & sun::ast::ClassDefinitionAST::getQualifiedName() const

Qualified name (after semantic analysis qualifies it).

Related: sun::semantic_analysis::QualifiedName

getSpecialization

public · function · Source (opens in a new tab)

std::shared_ptr< ClassDefinitionAST > sun::ast::ClassDefinitionAST::getSpecialization(DeclarationId id) const

Looks up the instance previously created for the supplied type arguments.

Related: ClassDefinitionAST, DeclarationId

getSpecializations

public · function · Source (opens in a new tab)

const std::map< DeclarationId, std::shared_ptr< ClassDefinitionAST > > & sun::ast::ClassDefinitionAST::getSpecializations() const

Provides the concrete instances created from this generic declaration.

Related: DeclarationId, ClassDefinitionAST

getType

public · function · Source (opens in a new tab)

ASTNodeType sun::ast::ClassDefinitionAST::getType() const override

Returns the syntax-node kind used to dispatch tree visitors.

Related: ASTNodeType

getTypeParameterNames

public · function · Source (opens in a new tab)

std::vector< std::string > sun::ast::ClassDefinitionAST::getTypeParameterNames() const

Returns the names used to bind generic arguments during specialization.

getTypeParameters

public · function · Source (opens in a new tab)

const std::vector< TypeParameter > & sun::ast::ClassDefinitionAST::getTypeParameters() const

Provides the generic parameters declared by this type or function.

Related: TypeParameter

hasCompiledSpecialization

public · function · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::hasCompiledSpecialization(const std::string &key) const

Report whether the bundle supplies this concrete class.

hasGenericMethods

public · function · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::hasGenericMethods() const

Reports whether this object has generic methods.

hasQualifiedName

public · function · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::hasQualifiedName() const

Reports whether a name including the enclosing scopes has been assigned.

hasSpecialization

public · function · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::hasSpecialization(DeclarationId id) const

Reports whether an instance already exists for the supplied type arguments.

Related: DeclarationId

isGeneric

public · function · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::isGeneric() const

Reports whether this declaration still has unbound type parameters.

isPacked

public · function · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::isPacked() const

Packed class support: "packed class X {}" lays fields out with no padding.

isPartial

public · function · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::isPartial() const

Partial class support: "partial class X {}" adds methods to existing class.

setDoc

public · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::setDoc(std::string doc)

Stores the source documentation comment for this declaration.

setIsPacked

public · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::setIsPacked(bool v)

Controls whether the class uses a packed memory layout.

setIsPartial

public · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::setIsPartial(bool v)

Marks whether this class declaration extends a partial class.

setLifetimeParameters

public · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::setLifetimeParameters(std::vector< LifetimeParameter > params)

Stores the declared lifetime parameters used to check borrowed values.

Related: LifetimeParameter

setQualifiedName

public · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::setQualifiedName(sun::semantic_analysis::QualifiedName qname)

Records the declaration name together with its enclosing scopes.

Related: sun::semantic_analysis::QualifiedName

toString

public · function · Source (opens in a new tab)

std::string sun::ast::ClassDefinitionAST::toString() const override

Returns a readable representation for diagnostics and debugging.

Protected Functions

ensureAnalysis

protected · function · Source (opens in a new tab)

void sun::ast::ClassDefinitionAST::ensureAnalysis() const override

Override to allocate ClassAnalysis instead of base ExprAnalysis.

Related: ClassAnalysis, ExprAnalysis

Private Functions

classAnalysis

private · function · Source (opens in a new tab)

ClassAnalysis & sun::ast::ClassDefinitionAST::classAnalysis() const

Access as ClassAnalysis.

Related: ClassAnalysis

Private Fields

compiledSpecializations_

private · variable · Source (opens in a new tab)

std::set<std::string> sun::ast::ClassDefinitionAST::compiledSpecializations_

No documentation comment.

doc_

private · variable · Source (opens in a new tab)

std::string sun::ast::ClassDefinitionAST::doc_

No documentation comment.

fields

private · variable · Source (opens in a new tab)

std::vector<ClassFieldDecl> sun::ast::ClassDefinitionAST::fields

No documentation comment.

Related: ClassFieldDecl

implementedInterfaces

private · variable · Source (opens in a new tab)

std::vector<ImplementedInterfaceAST> sun::ast::ClassDefinitionAST::implementedInterfaces

No documentation comment.

Related: ImplementedInterfaceAST

isPacked_

private · variable · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::isPacked_ = false

No documentation comment.

isPartial_

private · variable · Source (opens in a new tab)

bool sun::ast::ClassDefinitionAST::isPartial_ = false

No documentation comment.

lifetimeParameters

private · variable · Source (opens in a new tab)

std::vector<LifetimeParameter> sun::ast::ClassDefinitionAST::lifetimeParameters

No documentation comment.

Related: LifetimeParameter

methods

private · variable · Source (opens in a new tab)

std::vector<ClassMethodDecl> sun::ast::ClassDefinitionAST::methods

No documentation comment.

Related: ClassMethodDecl

name

private · variable · Source (opens in a new tab)

std::string sun::ast::ClassDefinitionAST::name

No documentation comment.

typeParameters

private · variable · Source (opens in a new tab)

std::vector<TypeParameter> sun::ast::ClassDefinitionAST::typeParameters

No documentation comment.

Related: TypeParameter