green(reify): declare/define floor — reify is sx; E :: reify(...) comptime-evaluated
First slice of the re-architecture. The compiler gains two comptime
type-construction builtins — declare() (mint an empty/undefined nominal
slot) and define(handle, info) (decode a TypeInfo VALUE + complete the
slot) — executed by the interpreter against a new `mint` TypeTable handle
(setMintTable). reify becomes PLAIN sx in meta.sx:
reify :: (info) -> Type { h := declare(); define(h, info); return h; }
`E :: f(...)` where f is a non-generic Type-returning fn (reify, and later
make_enum) is now comptime-evaluated via evalComptimeTypeNamed: wrap the
call in a throwaway comptime fn, run it through the interp with the mint
table enabled so declare/define mint the type, read back the type_tag, and
rename the anonymous slot to the binding name. The compiler has ZERO reify
knowledge at the decl site — the old `E :: reify` hook is deleted.
examples/0614 (inline reify) now runs on this floor. Full suite green (673).
INTERMEDIATE: reifyType + findReturnReifyCall still serve the type-fn path
(0615/0617) and will be deleted in the next slice (type-fn body
comptime-eval), after which the compiler has no reify code at all.
This commit is contained in:
@@ -30,13 +30,27 @@ TypeInfo :: enum {
|
||||
`enum: EnumInfo;
|
||||
}
|
||||
|
||||
// reify(info) — mint a NEW nominal type from a `TypeInfo` (comptime-only).
|
||||
// type_info($T) — reflect an existing type into a `TypeInfo`.
|
||||
// field_type($T, i) — the i-th field/variant payload type of `$T`.
|
||||
reify :: (info: TypeInfo) -> Type #builtin;
|
||||
// The compiler's ONLY type-construction primitives (comptime-only #builtins):
|
||||
// declare() — mint a NEW empty (undefined) nominal type, returned
|
||||
// as a `Type` handle. Using it before `define` is a
|
||||
// loud error. References to it (`*Self`) are fine.
|
||||
// define(handle, info) — fill a declared handle's body from a `TypeInfo`.
|
||||
// `reify` and every other constructor below are PLAIN sx built over these — the
|
||||
// compiler has no `reify` knowledge.
|
||||
declare :: () -> Type #builtin;
|
||||
define :: (handle: Type, info: TypeInfo) #builtin;
|
||||
type_info :: ($T: Type) -> TypeInfo #builtin;
|
||||
field_type :: ($T: Type, idx: i64) -> Type #builtin;
|
||||
|
||||
// reify(info) — the one-shot, non-recursive sugar: declare + define + return.
|
||||
// (Recursive / mutually-recursive types use the explicit declare/define split
|
||||
// so the handle can be referenced inside its own definition.)
|
||||
reify :: (info: TypeInfo) -> Type {
|
||||
h := declare();
|
||||
define(h, info);
|
||||
return h;
|
||||
}
|
||||
|
||||
// --- Reify'd shapes built in sx library code (no new compiler machinery) ---
|
||||
//
|
||||
// The channel result types, expressed as type-fns over `reify`. They are the
|
||||
|
||||
Reference in New Issue
Block a user