sun::ast::StructLiteralAST
class · Source (opens in a new tab)
class sun::ast::StructLiteralAST : public sun::ast::ExprASTStruct literal: { color: "red", speed: 120 }.
Constructs a class by naming each field, for classes that declare no init. Positional construction is deliberately not offered for these: field order is a layout detail, and a positional call would silently change meaning if two same-typed fields were ever reordered.
A literal carries no type of its own — it takes the type of the context it appears in (var car: Car = { ... }), which semantic analysis supplies.
Inherits
- sun::ast::ExprAST (public)
Types
Public Functions
- StructLiteralAST
- dotLabel
- forEachChildSlot
- getFields
- getMutableFields
- getType
- resolvedFields
- size
- toString
StructLiteralAST
public · function · Source (opens in a new tab)
sun::ast::StructLiteralAST::StructLiteralAST(std::vector< FieldInit > fields)Creates this syntax node and takes ownership of any supplied child expressions.
Related: FieldInit
dotLabel
public · function · Source (opens in a new tab)
std::string sun::ast::StructLiteralAST::dotLabel() const overrideReturns the node label used in syntax-tree graph visualizations.
forEachChildSlot
public · function · Source (opens in a new tab)
void sun::ast::StructLiteralAST::forEachChildSlot(const ChildSlotFn &fn) overrideVisits replaceable child expressions so tree passes can rewrite them in place.
Related: ChildSlotFn
getFields
public · function · Source (opens in a new tab)
const std::vector< FieldInit > & sun::ast::StructLiteralAST::getFields() constProvides the field declarations belonging to this type.
Related: FieldInit
getMutableFields
public · function · Source (opens in a new tab)
std::vector< FieldInit > & sun::ast::StructLiteralAST::getMutableFields()Provides mutable access to field declarations for later compiler passes.
Related: FieldInit
getType
public · function · Source (opens in a new tab)
ASTNodeType sun::ast::StructLiteralAST::getType() const overrideReturns the syntax-node kind used to dispatch tree visitors.
Related: ASTNodeType
resolvedFields
public · function · Source (opens in a new tab)
std::vector< sun::semantic_analysis::DeclarationId > & sun::ast::StructLiteralAST::resolvedFields() constRetain selected fields separately from their source names.
Related: sun::semantic_analysis::DeclarationId
size
public · function · Source (opens in a new tab)
size_t sun::ast::StructLiteralAST::size() constReturns the number of stored entries.
toString
public · function · Source (opens in a new tab)
std::string sun::ast::StructLiteralAST::toString() const overrideReturns a readable representation for diagnostics and debugging.
Protected Functions
ensureAnalysis
protected · function · Source (opens in a new tab)
void sun::ast::StructLiteralAST::ensureAnalysis() const overrideCreates the analysis annotations required by this node when first needed.
Private Fields
fields_
private · variable · Source (opens in a new tab)
std::vector<FieldInit> sun::ast::StructLiteralAST::fields_No documentation comment.
Related: FieldInit