sun::ast::PrototypeAST
class · Source (opens in a new tab)
class sun::ast::PrototypeASTTop-level nodes (not derived from ExprAST).
Public Functions
- PrototypeAST
- canThrow
- clearComputedAnalysis
- clearTypeParameters
- clone
- declarationIdentity
- getAllParamNames
- getAllParamTypes
- getAnalysis
- getArgNames
- getArgs
- getCaptures
- getConstRefCaptureNames
- getDeclarationId
- getDoc
- getLifetimeParameters
- getLinkName
- getLocation
- getMutableArgs
- getName
- getOwnedCaptureNames
- getQualifiedName
- getRefCaptureNames
- getResolvedParamTypes
- getResolvedReturnType
- getResolvedVariadicTypes
- getReturnType
- getType
- getTypeBindings
- getTypeParameterNames
- getTypeParameters
- getVariadicParam
- getVariadicParamName
- getVariadicTypeAnnotation
- hasAnalysis
- hasClosure
- hasLinkName
- hasQualifiedName
- hasRefCaptures
- hasResolvedParamTypes
- hasResolvedReturnType
- hasResolvedVariadicTypes
- hasReturnType
- hasTypeBindings
- hasVariadicParam
- hasVariadicTypeAnnotation
- isCVariadic
- isConstMethod
- isConstRefCapture
- isGeneric
- isOwnedCapture
- isTemplate
- isUnsafeMethod
- paramTypeNamed
- resetAnalysisSession
- setCVariadic
- setCaptures
- setConstMethod
- setConstRefCaptureNames
- setDeclarationId
- setDoc
- setLifetimeParameters
- setLinkName
- setLocation
- setName
- setOwnedCaptureNames
- setQualifiedName
- setRefCaptureNames
- setResolvedParamTypes
- setResolvedReturnType
- setResolvedVariadicTypes
- setReturnType
- setTypeBindings
- setUnsafeMethod
PrototypeAST
public · function · Source (opens in a new tab)
sun::ast::PrototypeAST::PrototypeAST(std::string Name, std::vector< std::pair< std::string, TypeAnnotation > > args, std::optional< TypeAnnotation > retType=std::nullopt, std::vector< TypeParameter > typeParams={}, std::optional< VariadicParam > variadicParam=std::nullopt)Creates this syntax node and takes ownership of any supplied child expressions.
Related: TypeAnnotation, TypeParameter, VariadicParam
canThrow
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::canThrow() constCheck if this function can throw (declared with "throws IError").
clearComputedAnalysis
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::clearComputedAnalysis() constClear the resolved signature while retaining declaration identities.
clearTypeParameters
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::clearTypeParameters()Removes generic parameters after a declaration is specialized.
clone
public · function · Source (opens in a new tab)
std::unique_ptr< PrototypeAST > sun::ast::PrototypeAST::clone() constClone the prototype via protobuf serialization (deep copy).
Related: PrototypeAST
declarationIdentity
public · function · Source (opens in a new tab)
sun::semantic_analysis::DeclarationIdentity & sun::ast::PrototypeAST::declarationIdentity() constAccess identities for the function and its parameters.
Related: sun::semantic_analysis::DeclarationIdentity
getAllParamNames
public · function · Source (opens in a new tab)
std::vector< std::string > sun::ast::PrototypeAST::getAllParamNames() constTheir names, in the same order.
A pack's elements are args.0, args.1, … — the names the body's expanded references resolve against.
getAllParamTypes
public · function · Source (opens in a new tab)
std::vector< TypePtr > sun::ast::PrototypeAST::getAllParamTypes() constThe full parameter list this specialization is emitted with: the fixed parameters followed by the pack's elements.
Codegen appends them in this order, so every argument check lines up against the same list.
Related: TypePtr
getAnalysis
public · function · Source (opens in a new tab)
const PrototypeAnalysis * sun::ast::PrototypeAST::getAnalysis() constReturns the analysis stored by this object.
Related: PrototypeAnalysis
getArgNames
public · function · Source (opens in a new tab)
std::vector< std::string > sun::ast::PrototypeAST::getArgNames() constReturns the parameter names.
getArgs
public · function · Source (opens in a new tab)
const std::vector< std::pair< std::string, TypeAnnotation > > & sun::ast::PrototypeAST::getArgs() constProvides the ordered arguments associated with this expression.
Related: TypeAnnotation
getCaptures
public · function · Source (opens in a new tab)
const std::vector< Capture > & sun::ast::PrototypeAST::getCaptures() constReturn computed captures, or an empty list before analysis.
Related: Capture
getConstRefCaptureNames
public · function · Source (opens in a new tab)
const std::vector< std::string > & sun::ast::PrototypeAST::getConstRefCaptureNames() constReturns the names of captures borrowed without write access.
getDeclarationId
public · function · Source (opens in a new tab)
DeclarationId sun::ast::PrototypeAST::getDeclarationId() constReturn this function's identity in the current analysis session.
Related: DeclarationId
getDoc
public · function · Source (opens in a new tab)
const std::string & sun::ast::PrototypeAST::getDoc() constComment written above the function (see doc_comments.h).
Related: doc_comments.h
getLifetimeParameters
public · function · Source (opens in a new tab)
const std::vector< LifetimeParameter > & sun::ast::PrototypeAST::getLifetimeParameters() constProvides the declared lifetime parameters used to check borrowed values.
Related: LifetimeParameter
getLinkName
public · function · Source (opens in a new tab)
const std::string & sun::ast::PrototypeAST::getLinkName() constThe symbol to emit: the as name when given, otherwise the Sun name.
getLocation
public · function · Source (opens in a new tab)
const sun::support::Position & sun::ast::PrototypeAST::getLocation() constReturns the source position used for diagnostics.
Related: sun::support::Position
getMutableArgs
public · function · Source (opens in a new tab)
std::vector< std::pair< std::string, TypeAnnotation > > & sun::ast::PrototypeAST::getMutableArgs()Returns the modifiable argument expressions.
Related: TypeAnnotation
getName
public · function · Source (opens in a new tab)
const std::string & sun::ast::PrototypeAST::getName() constReturns the declared name used to identify this object.
getOwnedCaptureNames
public · function · Source (opens in a new tab)
const std::vector< std::string > & sun::ast::PrototypeAST::getOwnedCaptureNames() constReturns the names of captures whose ownership was transferred.
getQualifiedName
public · function · Source (opens in a new tab)
const sun::semantic_analysis::QualifiedName & sun::ast::PrototypeAST::getQualifiedName() constQualified name (after semantic analysis qualifies it).
Related: sun::semantic_analysis::QualifiedName
getRefCaptureNames
public · function · Source (opens in a new tab)
const std::vector< std::string > & sun::ast::PrototypeAST::getRefCaptureNames() constReturns the names of borrowed captures.
getResolvedParamTypes
public · function · Source (opens in a new tab)
const std::vector< TypePtr > & sun::ast::PrototypeAST::getResolvedParamTypes() constReturns the parameter types selected by analysis.
Related: TypePtr
getResolvedReturnType
public · function · Source (opens in a new tab)
TypePtr sun::ast::PrototypeAST::getResolvedReturnType() constReturns the resolved return type stored by this object.
Related: TypePtr
getResolvedVariadicTypes
public · function · Source (opens in a new tab)
const std::vector< TypePtr > & sun::ast::PrototypeAST::getResolvedVariadicTypes() constReturns the concrete variadic parameter types.
Related: TypePtr
getReturnType
public · function · Source (opens in a new tab)
const std::optional< TypeAnnotation > & sun::ast::PrototypeAST::getReturnType() constReturns the semantic type of the function result.
Related: TypeAnnotation
getType
public · function · Source (opens in a new tab)
ASTNodeType sun::ast::PrototypeAST::getType() constReturns the syntax-node kind used to dispatch tree visitors.
Related: ASTNodeType
getTypeBindings
public · function · Source (opens in a new tab)
const std::vector< std::pair< std::string, TypePtr > > & sun::ast::PrototypeAST::getTypeBindings() constReturns the type bindings stored by this object.
Related: TypePtr
getTypeParameterNames
public · function · Source (opens in a new tab)
std::vector< std::string > sun::ast::PrototypeAST::getTypeParameterNames() constReturns the names used to bind generic arguments during specialization.
getTypeParameters
public · function · Source (opens in a new tab)
const std::vector< TypeParameter > & sun::ast::PrototypeAST::getTypeParameters() constGeneric method support.
Related: TypeParameter
getVariadicParam
public · function · Source (opens in a new tab)
const VariadicParam & sun::ast::PrototypeAST::getVariadicParam() constReturns the variadic parameter declaration.
Related: VariadicParam
getVariadicParamName
public · function · Source (opens in a new tab)
const std::string & sun::ast::PrototypeAST::getVariadicParamName() constThe pack's name, or empty when the signature declares no pack.
getVariadicTypeAnnotation
public · function · Source (opens in a new tab)
const TypeAnnotation & sun::ast::PrototypeAST::getVariadicTypeAnnotation() constReturns the variadic parameter type annotation.
Related: TypeAnnotation
hasAnalysis
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasAnalysis() constReports whether this object has analysis.
hasClosure
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasClosure() constReport whether analysis found a closure environment.
hasLinkName
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasLinkName() constExplicit C symbol from extern function sunName(...) T as "c_name";.
Lets a Sun-side name differ from the symbol actually linked against.
hasQualifiedName
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasQualifiedName() constReports whether a name including the enclosing scopes has been assigned.
hasRefCaptures
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasRefCaptures() constTrue if the closure holds state bound to the frame that built it: a borrow of a local, or a value it owns and drops there.
Either way the closure must not outlive that frame.
hasResolvedParamTypes
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasResolvedParamTypes() constReports whether this object has resolved param types.
hasResolvedReturnType
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasResolvedReturnType() constReports whether this object has resolved return type.
hasResolvedVariadicTypes
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasResolvedVariadicTypes() constReports whether this object has resolved variadic types.
hasReturnType
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasReturnType() constReports whether this object has return type.
hasTypeBindings
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasTypeBindings() constReports whether this object has type bindings.
hasVariadicParam
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasVariadicParam() constThe trailing args... pack, when the signature declares one.
Callers that only want a piece of it have the three shorthands below.
Related: args
hasVariadicTypeAnnotation
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::hasVariadicTypeAnnotation() constReports whether this object has variadic type annotation.
isCVariadic
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::isCVariadic() constC-style trailing varargs: fn(fmt: raw_ptr<u8>, ...).
Unrelated to the named args... pack above — this one binds no name and only affects the LLVM function type's isVarArg flag. Extern declarations only.
Related: args
isConstMethod
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::isConstMethod() constA class/interface method declared const method: its body may not change this, and it may be called on a constant receiver.
isConstRefCapture
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::isConstRefCapture(const std::string &name) constTrue if name was written [const ref name] rather than [ref name].
isGeneric
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::isGeneric() constReports whether this declaration still has unbound type parameters.
isOwnedCapture
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::isOwnedCapture(const std::string &name) constTrue if name was written in the capture list without ref.
isTemplate
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::isTemplate() constEmitted as one function per specialization: either because it has type parameters, or because its args... pack is keyed on the call's argument types.
A pack-only template has no type arguments but many arities.
A specialization keeps its pack — codegen needs the name to number the elements — so what marks it as no longer a template is that the pack's types are resolved, the same way clearTypeParameters() does for <T>.
Related: args, clearTypeParameters()
isUnsafeMethod
public · function · Source (opens in a new tab)
bool sun::ast::PrototypeAST::isUnsafeMethod() constWhether callers must uphold this method's safety contract.
paramTypeNamed
public · function · Source (opens in a new tab)
TypePtr sun::ast::PrototypeAST::paramTypeNamed(const std::string &name) constThe declared type of the parameter named name, or null if there is no such parameter.
Codegen walks a function's LLVM arguments, which are named from getAllParamNames(), so asking by name rather than by index keeps the two lists from drifting — and a closure or fat-pointer argument, which is not a parameter at all, simply answers null.
Related: TypePtr, getAllParamNames()
resetAnalysisSession
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::resetAnalysisSession() constDrop all annotations when discarding the owning session.
setCVariadic
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setCVariadic(bool v)Updates the C variadic-call setting.
setCaptures
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setCaptures(const std::vector< Capture > &caps)Record the bindings selected for this closure in the current session.
Related: Capture
setConstMethod
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setConstMethod(bool v)Marks whether the method receives its object without write access.
setConstRefCaptureNames
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setConstRefCaptureNames(std::vector< std::string > names)Updates the names of captures borrowed without write access.
setDeclarationId
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setDeclarationId(DeclarationId id) constAssign the identity shared by the function and its prototype.
Related: DeclarationId
setDoc
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setDoc(std::string doc)Stores the source documentation comment for this declaration.
setLifetimeParameters
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setLifetimeParameters(std::vector< LifetimeParameter > params)Lifetime parameter support.
Related: LifetimeParameter
setLinkName
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setLinkName(std::string name)Updates the link name stored by this object.
setLocation
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setLocation(sun::support::Position loc)Sets the source position used for diagnostics.
Related: sun::support::Position
setName
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setName(std::string name)Updates the name stored by this object.
setOwnedCaptureNames
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setOwnedCaptureNames(std::vector< std::string > names)Updates the names of captures whose ownership was transferred.
setQualifiedName
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setQualifiedName(sun::semantic_analysis::QualifiedName qname)Records the declaration name together with its enclosing scopes.
Related: sun::semantic_analysis::QualifiedName
setRefCaptureNames
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setRefCaptureNames(std::vector< std::string > names)Names declared in the lambda's [ref x, ...] capture list (parser-derived source of truth; Capture::kind is derived from it during analysis).
Related: Capture::kind
setResolvedParamTypes
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setResolvedParamTypes(std::vector< TypePtr > types)Resolved types for specialized generic functions Set during instantiation, used by codegen to skip type annotation conversion.
Related: TypePtr
setResolvedReturnType
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setResolvedReturnType(TypePtr type)Updates the resolved return type stored by this object.
Related: TypePtr
setResolvedVariadicTypes
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setResolvedVariadicTypes(std::vector< TypePtr > types)The pack's element types for this specialization, in order.
An empty list is still a resolved pack — the call simply passed nothing.
Related: TypePtr
setReturnType
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setReturnType(TypeAnnotation type)Set the return type (used by semantic analyzer for type inference).
Related: TypeAnnotation
setTypeBindings
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setTypeBindings(std::vector< std::pair< std::string, TypePtr > > bindings)Type parameter bindings for specialized generic functions.
Related: TypePtr
setUnsafeMethod
public · function · Source (opens in a new tab)
void sun::ast::PrototypeAST::setUnsafeMethod(bool v)Mark a method as requiring an unsafe block at each call.
Private Functions
analysis
private · function · Source (opens in a new tab)
PrototypeAnalysis & sun::ast::PrototypeAST::analysis() constLazy accessor for analysis data.
Related: PrototypeAnalysis
Private Fields
- Name
- analysis_
- args
- cVariadic_
- constMethod_
- constRefCaptureNames
- doc_
- lifetimeParameters
- linkName_
- location_
- ownedCaptureNames
- refCaptureNames
- returnType
- typeParameters
- unsafeMethod_
- variadicParam_
Name
private · variable · Source (opens in a new tab)
std::string sun::ast::PrototypeAST::NameNo documentation comment.
analysis_
private · variable · Source (opens in a new tab)
std::unique_ptr<PrototypeAnalysis> sun::ast::PrototypeAST::analysis_No documentation comment.
Related: PrototypeAnalysis
args
private · variable · Source (opens in a new tab)
std::vector<std::pair<std::string, TypeAnnotation> > sun::ast::PrototypeAST::argsNo documentation comment.
Related: TypeAnnotation
cVariadic_
private · variable · Source (opens in a new tab)
bool sun::ast::PrototypeAST::cVariadic_ = falseNo documentation comment.
constMethod_
private · variable · Source (opens in a new tab)
bool sun::ast::PrototypeAST::constMethod_ = falseNo documentation comment.
constRefCaptureNames
private · variable · Source (opens in a new tab)
std::vector<std::string> sun::ast::PrototypeAST::constRefCaptureNamesNo documentation comment.
doc_
private · variable · Source (opens in a new tab)
std::string sun::ast::PrototypeAST::doc_No documentation comment.
lifetimeParameters
private · variable · Source (opens in a new tab)
std::vector<LifetimeParameter> sun::ast::PrototypeAST::lifetimeParametersNo documentation comment.
Related: LifetimeParameter
linkName_
private · variable · Source (opens in a new tab)
std::optional<std::string> sun::ast::PrototypeAST::linkName_No documentation comment.
location_
private · variable · Source (opens in a new tab)
sun::support::Position sun::ast::PrototypeAST::location_No documentation comment.
Related: sun::support::Position
ownedCaptureNames
private · variable · Source (opens in a new tab)
std::vector<std::string> sun::ast::PrototypeAST::ownedCaptureNamesNo documentation comment.
refCaptureNames
private · variable · Source (opens in a new tab)
std::vector<std::string> sun::ast::PrototypeAST::refCaptureNamesNo documentation comment.
returnType
private · variable · Source (opens in a new tab)
std::optional<TypeAnnotation> sun::ast::PrototypeAST::returnTypeNo documentation comment.
Related: TypeAnnotation
typeParameters
private · variable · Source (opens in a new tab)
std::vector<TypeParameter> sun::ast::PrototypeAST::typeParametersNo documentation comment.
Related: TypeParameter
unsafeMethod_
private · variable · Source (opens in a new tab)
bool sun::ast::PrototypeAST::unsafeMethod_ = falseNo documentation comment.
variadicParam_
private · variable · Source (opens in a new tab)
std::optional<VariadicParam> sun::ast::PrototypeAST::variadicParam_No documentation comment.
Related: VariadicParam