sun::ast::ExprAST
class · Source (opens in a new tab)
class sun::ast::ExprASTBase syntax node carrying source positions and semantic analysis annotations.
Inherited by
- sun::ast::ArrayIndexAST (public)
- sun::ast::ArrayLiteralAST (public)
- sun::ast::BlockExprAST (public)
- sun::ast::BoolLiteralAST (public)
- sun::ast::BreakAST (public)
- sun::ast::CallExprAST (public)
- sun::ast::CharLiteralAST (public)
- sun::ast::ClassDefinitionAST (public)
- sun::ast::CompoundAssignmentAST (public)
- sun::ast::ContinueAST (public)
- sun::ast::DeclareTypeAST (public)
- sun::ast::EnumDefinitionAST (public)
- sun::ast::ForExprAST (public)
- sun::ast::ForInExprAST (public)
- sun::ast::FunctionAST (public)
- sun::ast::GenericCallAST (public)
- sun::ast::IfExprAST (public)
- sun::ast::IndexAST (public)
- sun::ast::IndexedAssignmentAST (public)
- sun::ast::InterfaceDefinitionAST (public)
- sun::ast::InterpolatedStringAST (public)
- sun::ast::LambdaAST (public)
- sun::ast::ManifestAST (public)
- sun::ast::MatchExprAST (public)
- sun::ast::MemberAccessAST (public)
- sun::ast::MemberAssignmentAST (public)
- sun::ast::ModuleAST (public)
- sun::ast::MoonScopeAST (public)
- sun::ast::NullLiteralAST (public)
- sun::ast::NumberExprAST (public)
- sun::ast::PackExpansionAST (public)
- sun::ast::ParenExprAST (public)
- sun::ast::QualifiedNameAST (public)
- sun::ast::ReferenceCreationAST (public)
- sun::ast::ReturnExprAST (public)
- sun::ast::SliceExprAST (public)
- sun::ast::StringLiteralAST (public)
- sun::ast::StructLiteralAST (public)
- sun::ast::TernaryExprAST (public)
- sun::ast::ThisExprAST (public)
- sun::ast::ThrowExprAST (public)
- sun::ast::TryCatchExprAST (public)
- sun::ast::UnaryExprAST (public)
- sun::ast::UnsafeBlockAST (public)
- sun::ast::UsingAST (public)
- sun::ast::VariableAssignmentAST (public)
- sun::ast::VariableCreationAST (public)
- sun::ast::VariableReferenceAST (public)
- sun::ast::WhileExprAST (public)
Public Functions
- clearComputedAnalysis
- clearResolvedType
- clone
- declarationIdentity
- dotLabel
- dump
- forEachChildSlot
- getColumn
- getDeclarationId
- getLine
- getLocation
- getModuleDeclaration
- getResolvedType
- getSourceFileId
- getSymbolPrefix
- getTargetDeclarationId
- getType
- getVisibility
- hasAnalysis
- hasResolvedType
- inheritSourceFile
- isBlock
- isFunction
- isLambda
- isLvalue
- isMoved
- isPrecompiled
- isPublic
- isReturn
- isTemporary
- resetAnalysisSession
- setDeclarationId
- setLocation
- setModuleDeclaration
- setMoved
- setPrecompiled
- setResolvedType
- setSkipCodegen
- setSourceFileId
- setSymbolPrefix
- setTargetDeclarationId
- setVisibility
- shouldSkipCodegen
- toString
- ~ExprAST
clearComputedAnalysis
public · function · Source (opens in a new tab)
virtual void sun::ast::ExprAST::clearComputedAnalysis() constDiscard computed results while preserving this session's identities.
clearResolvedType
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::clearResolvedType() constDiscards the cached type so analysis can resolve it again.
clone
public · function · Source (opens in a new tab)
std::unique_ptr< ExprAST > sun::ast::ExprAST::clone() constClone this AST node (deep copy) via protobuf serialization roundtrip.
This approach is less error-prone than manual cloning as it automatically handles all fields through the proto schema.
Related: ExprAST
declarationIdentity
public · function · Source (opens in a new tab)
virtual sun::semantic_analysis::DeclarationIdentity & sun::ast::ExprAST::declarationIdentity() constAccess declaration and parameter identities retained within a session.
Related: sun::semantic_analysis::DeclarationIdentity
dotLabel
public · function · Source (opens in a new tab)
virtual std::string sun::ast::ExprAST::dotLabel() const =0Label for DOT graph visualization (includes type name).
dump
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::dump() constPrint to stderr (easier to call from debugger than toString()).
Related: toString()
forEachChildSlot
public · function · Source (opens in a new tab)
virtual void sun::ast::ExprAST::forEachChildSlot(const ChildSlotFn &)Visits replaceable child expressions so tree passes can rewrite them in place.
Related: ChildSlotFn
getColumn
public · function · Source (opens in a new tab)
int sun::ast::ExprAST::getColumn() constReturns the source column used to report this node in diagnostics.
getDeclarationId
public · function · Source (opens in a new tab)
virtual DeclarationId sun::ast::ExprAST::getDeclarationId() constRead the declaration identity without allocating computed analysis.
Related: DeclarationId
getLine
public · function · Source (opens in a new tab)
int sun::ast::ExprAST::getLine() constReturns the source line used to report this node in diagnostics.
getLocation
public · function · Source (opens in a new tab)
const sun::support::Position & sun::ast::ExprAST::getLocation() constReturns the source position used for diagnostics.
Related: sun::support::Position
getModuleDeclaration
public · function · Source (opens in a new tab)
const std::optional< PortableDeclarationKey > & sun::ast::ExprAST::getModuleDeclaration() constThe original module denoted by this expression or retained using target.
Related: PortableDeclarationKey
getResolvedType
public · function · Source (opens in a new tab)
sun::types::TypePtr sun::ast::ExprAST::getResolvedType() constReturns the type assigned by semantic analysis, if available.
Related: sun::types::TypePtr
getSourceFileId
public · function · Source (opens in a new tab)
SourceFileId sun::ast::ExprAST::getSourceFileId() constThe source unit whose imports apply to this node.
Related: SourceFileId
getSymbolPrefix
public · function · Source (opens in a new tab)
const std::string & sun::ast::ExprAST::getSymbolPrefix() constSymbol prefix for moon library isolation (content hash).
getTargetDeclarationId
public · function · Source (opens in a new tab)
DeclarationId sun::ast::ExprAST::getTargetDeclarationId() constReturn the declaration selected by semantic resolution.
Related: DeclarationId
getType
public · function · Source (opens in a new tab)
virtual ASTNodeType sun::ast::ExprAST::getType() const =0Returns the syntax-node kind used to dispatch tree visitors.
Related: ASTNodeType
getVisibility
public · function · Source (opens in a new tab)
Visibility sun::ast::ExprAST::getVisibility() constDeclaration visibility (meaningful on declaration nodes only).
Related: Visibility
hasAnalysis
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::hasAnalysis() constReports whether this object has analysis.
hasResolvedType
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::hasResolvedType() constReports whether semantic analysis has assigned a type.
inheritSourceFile
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::inheritSourceFile(SourceFileId id)Fill missing source identities without changing imported subtrees.
Related: SourceFileId
isBlock
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isBlock() constReports whether this syntax node represents a lexical block.
isFunction
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isFunction() constReports whether this syntax node represents a function definition.
isLambda
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isLambda() constReports whether this syntax node represents a lambda expression.
isLvalue
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isLvalue() constReturns true if this expression is an lvalue (can be assigned to, has a stable address).
Includes variables, member access, and indexing.
isMoved
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isMoved() constMoved flag: set by borrow checker when ownership is transferred (returned, assigned to variable/field, passed by value).
Moved expressions should not have deinit called - the destination owns the data.
isPrecompiled
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isPrecompiled() constPrecompiled flag (for definitions loaded from .moon files).
isPublic
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isPublic() constReports whether this declaration is accessible outside its defining scope.
isReturn
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isReturn() constReports whether this syntax node represents a return statement.
isTemporary
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::isTemporary() constReturns true if this expression is a temporary (rvalue) that will be destroyed at the end of the statement.
Temporaries include:
- Constructor/function calls that return class values (CALL, GENERIC_CALL)
- Literals that produce class values Named variables (VARIABLE_REFERENCE) and member accesses are NOT temporaries.
resetAnalysisSession
public · function · Source (opens in a new tab)
virtual void sun::ast::ExprAST::resetAnalysisSession() constDiscard all annotations when the owning analysis session is discarded.
setDeclarationId
public · function · Source (opens in a new tab)
virtual void sun::ast::ExprAST::setDeclarationId(DeclarationId id) constAssign the identity allocated by the owning analysis session.
Related: DeclarationId
setLocation
setLocation(sun::support::Position loc)
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setLocation(sun::support::Position loc)Source location tracking.
Related: sun::support::Position
setLocation(int line, int column)
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setLocation(int line, int column)Sets the source position used for diagnostics.
setModuleDeclaration
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setModuleDeclaration(PortableDeclarationKey name)Bind a module reference without changing its source spelling.
Related: PortableDeclarationKey
setMoved
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setMoved(bool value) constRecords whether ownership of this expression has already been transferred.
setPrecompiled
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setPrecompiled(bool value)Marks whether this node came from an already compiled library.
setResolvedType
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setResolvedType(sun::types::TypePtr type) constType annotation set by semantic analyzer (delegates to analysis).
Related: sun::types::TypePtr
setSkipCodegen
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setSkipCodegen(bool value)Controls whether code generation omits this declaration.
setSourceFileId
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setSourceFileId(SourceFileId id)Preserve the source context when parsing or synthesizing a node.
Related: SourceFileId
setSymbolPrefix
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setSymbolPrefix(const std::string &prefix)Sets the prefix used to keep generated library symbols distinct.
setTargetDeclarationId
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setTargetDeclarationId(DeclarationId id) constRecord a resolved reference without changing the source spelling.
Related: DeclarationId
setVisibility
public · function · Source (opens in a new tab)
void sun::ast::ExprAST::setVisibility(Visibility v)Sets which scopes may access this declaration.
Related: Visibility
shouldSkipCodegen
public · function · Source (opens in a new tab)
bool sun::ast::ExprAST::shouldSkipCodegen() constSkip codegen flag (set by semantic analyzer for diamond import duplicates).
toString
public · function · Source (opens in a new tab)
virtual std::string sun::ast::ExprAST::toString() const =0Debug representation of this AST node.
~ExprAST
public · function · Source (opens in a new tab)
virtual sun::ast::ExprAST::~ExprAST()=defaultDestroys this object and releases its owned members.
Public Type Aliases
ChildSlotFn
public · typedef · Source (opens in a new tab)
using sun::ast::ExprAST::ChildSlotFn = std::function<void(std::unique_ptr<ExprAST>&)>Invoke fn on every direct child slot that holds a replaceable expression (used by AST-rewriting passes, e.g.
lowering). Strongly-typed children (e.g. a BlockExprAST member) cannot be replaced, so overrides forward into them instead of exposing their slot.
Related: ExprAST, BlockExprAST
Protected Functions
ExprAST
ExprAST()=default
protected · function · Source (opens in a new tab)
sun::ast::ExprAST::ExprAST()=defaultCreates a base syntax node without a source position or analysis annotations.
ExprAST(sun::support::Position loc)
protected · function · Source (opens in a new tab)
sun::ast::ExprAST::ExprAST(sun::support::Position loc)Creates a base syntax node at the supplied source position.
Related: sun::support::Position
analysis
protected · function · Source (opens in a new tab)
ExprAnalysis & sun::ast::ExprAST::analysis() constAccessor for analysis data - calls ensureAnalysis to allocate correct type.
Related: ExprAnalysis
cloneBase
protected · function · Source (opens in a new tab)
void sun::ast::ExprAST::cloneBase(ExprAST &dest) constCopy base class fields to a cloned node.
Called by derived clone() methods.
ensureAnalysis
protected · function · Source (opens in a new tab)
virtual void sun::ast::ExprAST::ensureAnalysis() constVirtual method to ensure analysis is allocated with the correct type Derived classes with specialized analysis types should override this.
Protected Fields
- analysis_
- location_
- moduleDeclaration_
- precompiled_
- skipCodegen_
- sourceFileId_
- symbolPrefix_
- visibility_
analysis_
protected · variable · Source (opens in a new tab)
std::unique_ptr<ExprAnalysis> sun::ast::ExprAST::analysis_No documentation comment.
Related: ExprAnalysis
location_
protected · variable · Source (opens in a new tab)
sun::support::Position sun::ast::ExprAST::location_No documentation comment.
Related: sun::support::Position
moduleDeclaration_
protected · variable · Source (opens in a new tab)
std::optional<PortableDeclarationKey> sun::ast::ExprAST::moduleDeclaration_When set, this expression IS a fully qualified module name, identified by its defining bundle and original module path.
For a using statement, this identifies its target module instead of the statement itself. Used only by variable references, qualified names, member accesses, and using statements. Lookup uses this identity directly, without resolving source aliases in the caller. Source spelling is kept for formatting and diagnostics.
Related: PortableDeclarationKey
precompiled_
protected · variable · Source (opens in a new tab)
bool sun::ast::ExprAST::precompiled_ = falseNo documentation comment.
skipCodegen_
protected · variable · Source (opens in a new tab)
bool sun::ast::ExprAST::skipCodegen_ = falseNo documentation comment.
sourceFileId_
protected · variable · Source (opens in a new tab)
SourceFileId sun::ast::ExprAST::sourceFileId_ = 0No documentation comment.
Related: SourceFileId
symbolPrefix_
protected · variable · Source (opens in a new tab)
std::string sun::ast::ExprAST::symbolPrefix_No documentation comment.
visibility_
protected · variable · Source (opens in a new tab)
Visibility sun::ast::ExprAST::visibility_ = Visibility::PrivateNo documentation comment.
Related: Visibility