sun::ast::FunctionAST
class · Source (opens in a new tab)
class sun::ast::FunctionAST : public sun::ast::ExprASTA function definition pairing its signature with an optional body.
Inherits
- sun::ast::ExprAST (public)
Public Functions
- FunctionAST
- addSpecialization
- clearComputedAnalysis
- declarationIdentity
- dotLabel
- forEachChildSlot
- getBody
- getDeclarationId
- getFieldInitializerCount
- getProto
- getProtoMut
- getSpecialization
- getSpecializations
- getType
- hasBody
- hasNonEmptyBody
- hasSpecialization
- isCExtern
- isExtern
- isSynthesizedConstructor
- isTest
- releaseProto
- resetAnalysisSession
- setBody
- setCExtern
- setDeclarationId
- setFieldInitializerCount
- setIsTest
- setSynthesizedConstructor
- toString
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) constSpecialization 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 overrideClear 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 overrideAccess 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 overrideReturns 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) overrideVisits 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() constProvides 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 overrideA 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() constReturns 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() constProvides 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) constLooks 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() constProvides 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 overrideReturns 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() constReports 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() constReports whether this object has non empty body.
hasSpecialization
public · function · Source (opens in a new tab)
bool sun::ast::FunctionAST::hasSpecialization(DeclarationId id) constReports 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() constTrue 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() constCheck 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() constReports whether field defaults supplied this constructor.
isTest
public · function · Source (opens in a new tab)
bool sun::ast::FunctionAST::isTest() constTrue 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 overrideDiscard 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 overrideAssign 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 overrideReturns a readable representation for diagnostics and debugging.
Protected Functions
ensureAnalysis
protected · function · Source (opens in a new tab)
void sun::ast::FunctionAST::ensureAnalysis() const overrideOverride 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() constAccess as FunctionAnalysis.
Related: FunctionAnalysis
Private Fields
Body
private · variable · Source (opens in a new tab)
std::unique_ptr<BlockExprAST> sun::ast::FunctionAST::BodyNo documentation comment.
Related: BlockExprAST
CAbi
private · variable · Source (opens in a new tab)
bool sun::ast::FunctionAST::CAbi = falseNo documentation comment.
IsTest
private · variable · Source (opens in a new tab)
bool sun::ast::FunctionAST::IsTest = falseNo documentation comment.
Proto
private · variable · Source (opens in a new tab)
std::unique_ptr<PrototypeAST> sun::ast::FunctionAST::ProtoNo documentation comment.
Related: PrototypeAST
fieldInitializerCount_
private · variable · Source (opens in a new tab)
size_t sun::ast::FunctionAST::fieldInitializerCount_ = 0No documentation comment.
synthesizedConstructor_
private · variable · Source (opens in a new tab)
bool sun::ast::FunctionAST::synthesizedConstructor_ = falseNo documentation comment.