feat(lang): L8 registries by declaration - registry and def
registry NAME of RECORD [as PREFIX] is a global table; def NAME key { ... } in
any file is one entry, collected in source order and filled before any code
runs. Each entry gets an index constant (PREFIX_KEY), the table PREFIX_COUNT,
and a record with a key field gets it filled and a NAME_find(key). A record
literal naming a field its record lacks is now an error everywhere; a global's
initializer is lowered as its own file's code (its errors, and what its module
may see, were whichever statement came last).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b0b0b62bce
commit
7e7f3ab297
15 changed files with 48231 additions and 44362 deletions
|
|
@ -68,6 +68,10 @@ function emit_global_init_fn() -> void {
|
|||
while i < len(prog) {
|
||||
let d = prog[i]
|
||||
if d.kind == N_VAR and global_needs_init_code(d) {
|
||||
# an initializer is the global's own file's code: its errors, and what its module
|
||||
# may see (L3), are that file's - not whichever statement was lowered last
|
||||
g_err_file = d.file
|
||||
g_err_line = d.line
|
||||
let v = emit_expr(d.a)
|
||||
let cv = coerce_code(v, d.ty) # any conversion is its own line, before the store
|
||||
emit(" store "); emit(llty(d.ty)); emit(" "); emit(cv); emit(", ptr @g_"); emit(d.s); emit("\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue