feat(lang): ports - port Clock { ... } in a module, bind Clock { ... } in the app
A port is a record of function values a module calls through (Clock.now()) without naming the module that answers. A port used and never bound, a bind missing a required member or naming one the port lacks, and a second bind are refused; the binder must see the port, and what it binds is checked from its own file. Reseed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d0ad364ad4
commit
b1ccaf08bd
19 changed files with 50439 additions and 47750 deletions
|
|
@ -72,7 +72,14 @@ function emit_global_init_fn() -> void {
|
|||
# may see (L3), are that file's - not whichever statement was lowered last
|
||||
g_err_file = d.file
|
||||
g_err_line = d.line
|
||||
# a port's bind is written in the app and checked there (frontend/ports.ludic)
|
||||
if is_port_var(d) {
|
||||
g_err_file = d.a.file
|
||||
g_err_line = d.a.line
|
||||
g_vis_off = true
|
||||
}
|
||||
let v = emit_expr(d.a)
|
||||
g_vis_off = false
|
||||
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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ function vis_say(m: pointer) -> void {
|
|||
}
|
||||
function vis_check(d: Node, what0: pointer) -> void {
|
||||
if d == null { return }
|
||||
port_check_bound(d)
|
||||
if g_vis_off { return }
|
||||
if d.file == null { return }
|
||||
let what = vis_plain(what0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue