sun::ast::VariableCreationAST

sun::ast::VariableCreationAST

class · Source (opens in a new tab)

class sun::ast::VariableCreationAST : public sun::ast::ExprAST

A variable declaration with its type, initializer, and binding properties.

Inherits

Public Functions

VariableCreationAST

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

sun::ast::VariableCreationAST::VariableCreationAST(std::string name, std::unique_ptr< ExprAST > value, std::optional< TypeAnnotation > type=std::nullopt, bool isConst=false)

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

Related: ExprAST, TypeAnnotation

dotLabel

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

std::string sun::ast::VariableCreationAST::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::VariableCreationAST::forEachChildSlot(const ChildSlotFn &fn) override

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

Related: ChildSlotFn

getDoc

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

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

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

Related: doc_comments.h

getGlobalInit

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

const sun::semantic_analysis::constants::GlobalInitRecord * sun::ast::VariableCreationAST::getGlobalInit() const

How this file-scope variable gets its first value: computed at compile time and written into the program, or computed by the startup function.

Null until analysis has decided, and for a variable that is not at file scope.

Related: sun::semantic_analysis::constants::GlobalInitRecord

getImportedConstant

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

const std::optional< sun::semantic_analysis::constants::ConstantValue > & sun::ast::VariableCreationAST::getImportedConstant() const

The compile-time value a library published for this global, if any.

Only a global read from a bundle has one.

Related: sun::semantic_analysis::constants::ConstantValue

getLinkName

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

const std::string & sun::ast::VariableCreationAST::getLinkName() const

Returns the link name stored by this object.

getName

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

const std::string & sun::ast::VariableCreationAST::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::VariableCreationAST::getQualifiedName() const

Qualified name (after semantic analysis qualifies it).

Related: sun::semantic_analysis::QualifiedName

getType

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

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

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

Related: ASTNodeType

getTypeAnnotation

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

const std::optional< TypeAnnotation > & sun::ast::VariableCreationAST::getTypeAnnotation() const

Returns the type annotation stored by this object.

Related: TypeAnnotation

getValue

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

const ExprAST * sun::ast::VariableCreationAST::getValue() const

Returns the value represented by this object.

Related: ExprAST

hasExplicitCAbi

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

bool sun::ast::VariableCreationAST::hasExplicitCAbi() const

Reports whether this object has explicit c ABI.

hasLinkName

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

bool sun::ast::VariableCreationAST::hasLinkName() const

Reports whether an explicit linker symbol name is present.

hasQualifiedName

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

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

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

hasTypeAnnotation

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

bool sun::ast::VariableCreationAST::hasTypeAnnotation() const

Reports whether this object has type annotation.

hasValue

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

bool sun::ast::VariableCreationAST::hasValue() const

Reports whether this object has value.

isCExtern

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

bool sun::ast::VariableCreationAST::isCExtern() const

Reports whether this syntax node represents a declaration using the C calling convention.

isConst

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

bool sun::ast::VariableCreationAST::isConst() const

Reports whether this syntax node represents an immutable declaration.

setCExtern

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

void sun::ast::VariableCreationAST::setCExtern(bool value)

Marks whether the function uses the C calling convention.

setDoc

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

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

Stores the source documentation comment for this declaration.

setExplicitCAbi

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

void sun::ast::VariableCreationAST::setExplicitCAbi(bool value)

Records whether the declaration explicitly uses the C calling convention.

setGlobalInit

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

void sun::ast::VariableCreationAST::setGlobalInit(sun::semantic_analysis::constants::GlobalInitRecord record) const

Records the decision made for this file-scope variable.

Related: sun::semantic_analysis::constants::GlobalInitRecord

setImportedConstant

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

void sun::ast::VariableCreationAST::setImportedConstant(sun::semantic_analysis::constants::ConstantValue value)

Records the value read from a bundle for this global.

Related: sun::semantic_analysis::constants::ConstantValue

setLinkName

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

void sun::ast::VariableCreationAST::setLinkName(std::string name)

Updates the link name stored by this object.

setQualifiedName

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

void sun::ast::VariableCreationAST::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::VariableCreationAST::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::VariableCreationAST::ensureAnalysis() const override

Override to allocate VariableAnalysis instead of base ExprAnalysis.

Related: VariableAnalysis, ExprAnalysis

Private Functions

varAnalysis

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

VariableAnalysis & sun::ast::VariableCreationAST::varAnalysis() const

Access as VariableAnalysis.

Related: VariableAnalysis

Private Fields

doc_

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

std::string sun::ast::VariableCreationAST::doc_

No documentation comment.

explicitCAbi_

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

bool sun::ast::VariableCreationAST::explicitCAbi_ = false

No documentation comment.

importedConstant_

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

std::optional<sun::semantic_analysis::constants::ConstantValue> sun::ast::VariableCreationAST::importedConstant_

No documentation comment.

Related: sun::semantic_analysis::constants::ConstantValue

isCExtern_

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

bool sun::ast::VariableCreationAST::isCExtern_ = false

No documentation comment.

isConst_

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

bool sun::ast::VariableCreationAST::isConst_

No documentation comment.

linkName_

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

std::optional<std::string> sun::ast::VariableCreationAST::linkName_

No documentation comment.

name

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

std::string sun::ast::VariableCreationAST::name

No documentation comment.

typeAnnotation

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

std::optional<TypeAnnotation> sun::ast::VariableCreationAST::typeAnnotation

No documentation comment.

Related: TypeAnnotation

value

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

std::unique_ptr<ExprAST> sun::ast::VariableCreationAST::value

No documentation comment.

Related: ExprAST