feat(lang): open registry - other modules' defs, in an order imports cannot change

A def from another module into a registry that is not open is refused,
and defs go through visibility (the registry exported, its module in the
definer's uses). Index order: the declaring module's entries, then the
other modules' by module name, each in reading order. A registry entry
is emitted as its own file's code, so what it names is seen from its
own module. Reseed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 04:28:34 +03:00
parent 05b09b4c98
commit 6cfaaf0bf9
19 changed files with 49801 additions and 47689 deletions

View file

@ -139,14 +139,14 @@ function emit_push(e: Node) -> Val {
# is the first element's; an empty literal has none, so it is spelled `new []T`.
function emit_list(e: Node) -> Val {
if len(e.kids) == 0 { perr("an empty list literal has no element type: write `new []T` instead") }
let first = emit_expr(e.kids[0])
let first = emit_list_elem(e.kids[0])
let ty = "[]" + first.ty
let elt = llty(first.ty)
let s = emit_new_slice(ty)
emit_push_into(s.code, elt, first)
var i = 1
while i < len(e.kids) {
let v = emit_expr(e.kids[i])
let v = emit_list_elem(e.kids[i])
if not (v.ty == first.ty) { perr(`list literal mixes element types {first.ty} and {v.ty}`) }
emit_push_into(s.code, elt, v)
i += 1
@ -154,6 +154,15 @@ function emit_list(e: Node) -> Val {
return s
}
# an element is its own file's code: a registry's entries come from the files their defs are in
# (L8), and what an entry may see (L3) is its own module's view, not the registry's
function emit_list_elem(k: Node) -> Val {
let saved = g_err_file
if k.file != null { g_err_file = k.file }
let v = emit_expr(k)
g_err_file = saved
return v
}
# append the already-emitted value `v` (of LLVM element type `elt`) to the slice
# whose header is `h`, growing the storage when it is full
function emit_push_into(h: pointer, elt: pointer, v: Val) -> void {