P5.7 Step D: re-express metatype declare() as sx over declare_type

declare(name) is now an ordinary sx fn in modules/std/meta.sx that calls the
abi(.compiler) declare_type primitive — both mint/find the same forward nominal
slot. Removed the bespoke .declare arm from callBuiltinVm and the BuiltinId.declare
member; dropped the declare interception in tryLowerReflectionCall (the call now
routes to the sx fn). preregisterForwardTypes still scans for the literal
declare("Name") spelling so *Name self-references forward-register before the
body lowers (0618). define/type_info/field_type remain builtins.
This commit is contained in:
agra
2026-06-19 20:58:34 +03:00
parent 61f5700a36
commit 8850fcce70
4 changed files with 55 additions and 38 deletions

View File

@@ -1900,14 +1900,9 @@ pub const Vm = struct {
/// parity holds). Keeps BOTH paths alive during the VM-default transition.
fn callBuiltinVm(self: *Vm, bi: inst_mod.BuiltinCall, ins_ty: TypeId, frame: *Frame, ref_types: []const TypeId) Error!?Reg {
switch (bi.builtin) {
// declare(name) → mint an EMPTY nominal slot, returned as a Type value.
.declare => {
const table = try self.requireTable();
if (bi.args.len != 1) return self.failMsg("comptime declare: expected (name)");
const s = frame.get(bi.args[0].index()); // string fat-pointer Addr
const text = try self.machine.bytes(try self.sliceData(table, s), @intCast(try self.sliceLen(s)));
return @as(Reg, (self.declareNominal(table, text)).index());
},
// `declare(name)` is no longer a builtin — it's plain sx in
// `modules/std/meta.sx` over the `declare_type` compiler-API primitive
// (`callCompilerFn`). The `.declare` BuiltinId was removed with it.
// define(handle, info) → complete the declared slot from a TypeInfo VALUE.
.define => {
const table = try self.requireTable();