sun::ast::StructLiteralAST

sun::ast::StructLiteralAST

class · Source (opens in a new tab)

class sun::ast::StructLiteralAST : public sun::ast::ExprAST

Struct 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

Types

Public Functions

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 override

Returns 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) override

Visits 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() const

Provides 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 override

Returns 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() const

Retain 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() const

Returns the number of stored entries.

toString

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

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

Creates 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