l0_backend_initializers::StaticInitializers class

Defined in module l0_backend_initializers (l0_backend_initializers.py).

Static initializer classification and constructor recursion.

Public static attributes

static BackendState state

Protected functions

auto _emit_let_initializer(self, Expr expr, Type expected_type) -> str
Generate C initializer expression for a top-level let.
auto _emit_bare_variant_static_initializer(self, VarRef expr, Type expected_type) -> str
Emit a bare zero-argument enum variant for static initialization.
auto _emit_const_constructor(self, CallExpr expr, Type expected_type) -> str
Emit a constant struct or enum constructor for static initialization.
auto _emit_const_struct_constructor(self, CallExpr expr, StructType struct_type) -> str
Emit constant struct constructor for static initialization.
auto _emit_const_variant_constructor(self, CallExpr expr, EnumType enum_type) -> str
Emit constant enum variant constructor for static initialization.

Function documentation

str l0_backend_initializers::StaticInitializers::_emit_let_initializer(self, Expr expr, Type expected_type) protected

Generate C initializer expression for a top-level let.

Parameters
expr The initializer expression.
expected_type The expected type of the constant.
Returns A C initializer expression string.
Exceptions
InternalCompilerError If the initializer is not constant or supported.

Supports compile-time constant literals and struct/enum construction.

str l0_backend_initializers::StaticInitializers::_emit_const_constructor(self, CallExpr expr, Type expected_type) protected

Emit a constant struct or enum constructor for static initialization.

Parameters
expr The constructor call expression.
expected_type The expected struct or enum type.
Returns A C initializer string.
Exceptions
InternalCompilerError If symbol or constructor type is invalid.

Similar to _try_emit_constructor but only handles constant expressions.

str l0_backend_initializers::StaticInitializers::_emit_const_struct_constructor(self, CallExpr expr, StructType struct_type) protected

Emit constant struct constructor for static initialization.

Parameters
expr The constructor call expression.
struct_type The struct type.
Returns A C struct initializer string.
Exceptions
InternalCompilerError If struct info is missing or argument count mismatches.

str l0_backend_initializers::StaticInitializers::_emit_const_variant_constructor(self, CallExpr expr, EnumType enum_type) protected

Emit constant enum variant constructor for static initialization.

Parameters
expr The variant call expression.
enum_type The enum type.
Returns A C enum variant initializer string.
Exceptions
InternalCompilerError If variant info or declaration is missing.