pub struct ClassPlan { /* private fields */ }Expand description
The class-emission plan, computed once and threaded through the codegen phases.
Implementations§
Source§impl ClassPlan
impl ClassPlan
pub fn is_empty(&self) -> bool
Sourcepub fn collect(
ta: &TypedAst,
imported: &BTreeMap<MangledName, ImportedClassLayout>,
) -> Result<Self, CompilerFailure>
pub fn collect( ta: &TypedAst, imported: &BTreeMap<MangledName, ImportedClassLayout>, ) -> Result<Self, CompilerFailure>
Phase 0: gather class declarations from the typed AST, topologically
ordered by extends (parents before children), and resolve each class’s
full field + method slot layout across the inheritance chain.
Sourcepub fn field_name_lists(&self) -> Vec<Vec<FieldName>>
pub fn field_name_lists(&self) -> Vec<Vec<FieldName>>
The ordered list of class field-name vectors, for the shared
field-names-array global emission (field_names::emit). Built from the
same helper the instance payload is, so the two cannot drift.
Sourcepub fn accessor_property_names(&self) -> Vec<String>
pub fn accessor_property_names(&self) -> Vec<String>
Accessor property names across all classes. They need per-name $string
globals for the runtime property scan, but are not data fields, so they’re
excluded from field_name_lists (no shape stores them).
Sourcepub fn reserve_and_emit_types(
&mut self,
types: &mut TypeSection,
next_type_idx: &mut u32,
symbols: &mut SymbolTable,
intrinsics: IntrinsicTypeIndices,
) -> Result<(), CompilerFailure>
pub fn reserve_and_emit_types( &mut self, types: &mut TypeSection, next_type_idx: &mut u32, symbols: &mut SymbolTable, intrinsics: IntrinsicTypeIndices, ) -> Result<(), CompilerFailure>
Phase: emit standalone method fn-type sigs, then reserve struct/vtable type
indices, then emit the class rec group. types/next_type_idx advance in
lockstep with the wasm-encoder type section.
Sourcepub fn allocate_funcs(
&mut self,
next_func_idx: &mut u32,
symbols: &mut SymbolTable,
) -> Result<(), CompilerFailure>
pub fn allocate_funcs( &mut self, next_func_idx: &mut u32, symbols: &mut SymbolTable, ) -> Result<(), CompilerFailure>
Phase: reserve function indices — 4 shared universal stubs, then per-class method stubs (one per own method) + getter + setter.
Sourcepub fn emit_function_entries(
&self,
functions: &mut FunctionSection,
symbols: &SymbolTable,
intrinsics: IntrinsicTypeIndices,
) -> Result<(), CompilerFailure>
pub fn emit_function_entries( &self, functions: &mut FunctionSection, symbols: &SymbolTable, intrinsics: IntrinsicTypeIndices, ) -> Result<(), CompilerFailure>
Phase: function-section entries for every emitted function, in the same
order as allocate_funcs / emit_bodies.
Sourcepub fn emit_globals(
&self,
globals: &mut GlobalSection,
symbols: &mut SymbolTable,
next_global_idx: &mut u32,
intrinsics: IntrinsicTypeIndices,
) -> Result<(), CompilerFailure>
pub fn emit_globals( &self, globals: &mut GlobalSection, symbols: &mut SymbolTable, next_global_idx: &mut u32, intrinsics: IntrinsicTypeIndices, ) -> Result<(), CompilerFailure>
Phase: vtable instance, getter, and setter globals (the field-names array
global is emitted separately via field_names::emit).
Sourcepub fn emit_bodies(
&self,
code: &mut CodeSection,
debug: &mut DebugFunctions,
ctx: &CodegenCtx<'_>,
) -> Result<(), CompilerFailure>
pub fn emit_bodies( &self, code: &mut CodeSection, debug: &mut DebugFunctions, ctx: &CodegenCtx<'_>, ) -> Result<(), CompilerFailure>
Phase: function bodies — constructor + init, method bodies and their closure adapters, then the retired getter/setter stubs (kept for stable numbering) and the four per-class universal vtable bodies (equals/toString/toJson/hash).
Sourcepub fn exported_funcs(
&self,
symbols: &SymbolTable,
is_exported: impl Fn(&MangledName) -> bool,
) -> Result<Vec<(MangledName, u32)>, CompilerFailure>
pub fn exported_funcs( &self, symbols: &SymbolTable, is_exported: impl Fn(&MangledName) -> bool, ) -> Result<Vec<(MangledName, u32)>, CompilerFailure>
(export name, func index) pairs for every class function a cross-package
consumer may import: the entry constructor, the self-first ctor-init, and
every method body. Restricted to classes the package actually exports
(is_exported). Method bodies include private methods — Wasm-level
visibility is wider than source so a cross-package subclass can fill its
inherited vtable slots (docs/classes.md §2, §6). Generic methods are
excluded (still emitted as stubs this slice).
Sourcepub fn exported_vtable_globals(
&self,
symbols: &SymbolTable,
is_exported: impl Fn(&MangledName) -> bool,
) -> Result<Vec<(MangledName, u32)>, CompilerFailure>
pub fn exported_vtable_globals( &self, symbols: &SymbolTable, is_exported: impl Fn(&MangledName) -> bool, ) -> Result<Vec<(MangledName, u32)>, CompilerFailure>
Each exported class’s vtable-singleton global, for the export section —
the class’s nominal identity, imported by consumers for instanceof’s
ref.eq comparison and as a local subclass’s parent link.
Sourcepub fn declared_funcs(&self, symbols: &SymbolTable) -> Vec<u32>
pub fn declared_funcs(&self, symbols: &SymbolTable) -> Vec<u32>
Function indices that appear in a ref.func const-expr and so must be
covered by the declarative element section.