sun::ast::FunctionAST

sun::ast::FunctionAST

class · Source (opens in a new tab)

class sun::ast::FunctionAST : public sun::ast::ExprAST

A function definition pairing its signature with an optional body.

Inherits

Public Functions

FunctionAST

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

sun::ast::FunctionAST::FunctionAST(std::unique_ptr< PrototypeAST > Proto, std::unique_ptr< BlockExprAST > Body)

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

Related: PrototypeAST, BlockExprAST

addSpecialization

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

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

Specialization storage for generic functions Called by semantic analyzer when a generic function is instantiated.

Related: DeclarationId, FunctionAST

clearComputedAnalysis

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

void sun::ast::FunctionAST::clearComputedAnalysis() const override

Clear body and signature results while retaining identities.

declarationIdentity

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

sun::semantic_analysis::DeclarationIdentity & sun::ast::FunctionAST::declarationIdentity() const override

Access the identities owned by the prototype.

Related: sun::semantic_analysis::DeclarationIdentity

dotLabel

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

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

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

Related: ChildSlotFn

getBody

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

const BlockExprAST & sun::ast::FunctionAST::getBody() const

Provides access to the expressions that make up the body.

Related: BlockExprAST

getDeclarationId

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

DeclarationId sun::ast::FunctionAST::getDeclarationId() const override

A function and its prototype denote the same declaration.

Related: DeclarationId

getFieldInitializerCount

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

size_t sun::ast::FunctionAST::getFieldInitializerCount() const

Returns the number of generated field assignments before the source body.

getProto

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

const PrototypeAST & sun::ast::FunctionAST::getProto() const

Provides the function signature independently of its body.

Related: PrototypeAST

getProtoMut

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

PrototypeAST & sun::ast::FunctionAST::getProtoMut()

Returns the modifiable function signature.

Related: PrototypeAST

getSpecialization

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

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

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

Related: FunctionAST, DeclarationId

getSpecializations

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

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

Provides the concrete instances created from this generic declaration.

Related: DeclarationId, FunctionAST

getType

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

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

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

Related: ASTNodeType

hasBody

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

bool sun::ast::FunctionAST::hasBody() const

Reports whether a function body is present rather than just a declaration.

hasNonEmptyBody

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

bool sun::ast::FunctionAST::hasNonEmptyBody() const

Reports whether this object has non empty body.

hasSpecialization

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

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

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

Related: DeclarationId

isCExtern

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

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

True only for extern function — a C symbol linked by its exact name, with no module scope.

declare function is a forward declaration of a Sun function and keeps the symbol derived from its declaration, so the two must not be conflated even though both are bodyless.

isExtern

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

bool sun::ast::FunctionAST::isExtern() const

Check if function is a bodyless declaration.

True for both extern function (C ABI) and declare function (Sun forward declaration).

isSynthesizedConstructor

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

bool sun::ast::FunctionAST::isSynthesizedConstructor() const

Reports whether field defaults supplied this constructor.

isTest

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

bool sun::ast::FunctionAST::isTest() const

True for test_function declarations.

Test functions are compiled only into the test binary; production builds and .moon bundles strip them.

releaseProto

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

std::unique_ptr< PrototypeAST > sun::ast::FunctionAST::releaseProto()

Add this method to allow moving the prototype out.

Related: PrototypeAST

resetAnalysisSession

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

void sun::ast::FunctionAST::resetAnalysisSession() const override

Discard the function's annotations and its prototype's annotations.

setBody

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

void sun::ast::FunctionAST::setBody(std::unique_ptr< BlockExprAST > newBody)

Set body (for replacing empty stub with parsed body).

Related: BlockExprAST

setCExtern

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

void sun::ast::FunctionAST::setCExtern(bool v)

Marks whether the function uses the C calling convention.

setDeclarationId

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

void sun::ast::FunctionAST::setDeclarationId(DeclarationId id) const override

Assign the prototype's declaration identity.

Related: DeclarationId

setFieldInitializerCount

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

void sun::ast::FunctionAST::setFieldInitializerCount(size_t count)

Records the generated prefix so lowering and analysis do not repeat it.

setIsTest

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

void sun::ast::FunctionAST::setIsTest(bool v)

Marks whether the function is a discoverable test.

setSynthesizedConstructor

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

void sun::ast::FunctionAST::setSynthesizedConstructor(bool value)

Marks a constructor supplied by field defaults.

toString

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

std::string sun::ast::FunctionAST::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::FunctionAST::ensureAnalysis() const override

Override to allocate FunctionAnalysis instead of base ExprAnalysis.

Related: FunctionAnalysis, ExprAnalysis

Private Functions

funcAnalysis

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

FunctionAnalysis & sun::ast::FunctionAST::funcAnalysis() const

Access as FunctionAnalysis.

Related: FunctionAnalysis

Private Fields

Body

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

std::unique_ptr<BlockExprAST> sun::ast::FunctionAST::Body

No documentation comment.

Related: BlockExprAST

CAbi

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

bool sun::ast::FunctionAST::CAbi = false

No documentation comment.

IsTest

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

bool sun::ast::FunctionAST::IsTest = false

No documentation comment.

Proto

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

std::unique_ptr<PrototypeAST> sun::ast::FunctionAST::Proto

No documentation comment.

Related: PrototypeAST

fieldInitializerCount_

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

size_t sun::ast::FunctionAST::fieldInitializerCount_ = 0

No documentation comment.

synthesizedConstructor_

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

bool sun::ast::FunctionAST::synthesizedConstructor_ = false

No documentation comment.