Skip to main content

Module classes

Module classes 

Source
Expand description

WasmGC type emission and body lowering for user class declarations.

Each class becomes one rec group holding a struct type $Foo (sub $ObjectShape …) and a vtable type $Foo_vtable (sub $VTable …), with subclasses subtyping their parent’s pair. Alongside those: the per-class singleton globals (vtable instance, field-names array), the allocating constructor and its self-first init counterpart, real method bodies, one closure-ABI adapter per non-generic vtable slot for interface-typed dispatch (inherited slots included — a subclass reuses its ancestor’s adapter where one exists locally), and the four universal vtable bodies (toString/toJson/equals/hash).

Data fields live in the shared object-fields payload rather than as named struct fields, so a class’s struct only ever references its own vtable and the intrinsics — which is what lets a cross-package consumer rebuild just the classes it uses (see super::imported_classes).

Structs§

ClassPlan
The class-emission plan, computed once and threaded through the codegen phases.