Step 10d: fix scope form compilation for non-keyword args
compile-expr args instead of keyword-name — handles (context "name"), (context var), and (context :name) uniformly. Fixes freeze.sx .sxbc compilation (was failing with "keyword-name: expected keyword"). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -315,19 +315,27 @@
|
||||
(compile-provide em args scope tail?)
|
||||
(= name "context")
|
||||
(do
|
||||
(emit-const em (keyword-name (first args)))
|
||||
(emit-op em 52)
|
||||
(emit-u16 em (pool-add (get em "pool") "context"))
|
||||
(emit-byte em 1))
|
||||
(compile-expr em (first args) scope false)
|
||||
(if
|
||||
(> (len args) 1)
|
||||
(do
|
||||
(compile-expr em (nth args 1) scope false)
|
||||
(emit-op em 52)
|
||||
(emit-u16 em (pool-add (get em "pool") "context"))
|
||||
(emit-byte em 2))
|
||||
(do
|
||||
(emit-op em 52)
|
||||
(emit-u16 em (pool-add (get em "pool") "context"))
|
||||
(emit-byte em 1))))
|
||||
(= name "peek")
|
||||
(do
|
||||
(emit-const em (keyword-name (first args)))
|
||||
(compile-expr em (first args) scope false)
|
||||
(emit-op em 52)
|
||||
(emit-u16 em (pool-add (get em "pool") "scope-peek"))
|
||||
(emit-byte em 1))
|
||||
(= name "provide!")
|
||||
(do
|
||||
(emit-const em (keyword-name (first args)))
|
||||
(compile-expr em (first args) scope false)
|
||||
(compile-expr em (nth args 1) scope false)
|
||||
(emit-op em 52)
|
||||
(emit-u16 em (pool-add (get em "pool") "provide-set!"))
|
||||
@@ -340,14 +348,14 @@
|
||||
(emit-byte em 1))
|
||||
(= name "emit!")
|
||||
(do
|
||||
(emit-const em (keyword-name (first args)))
|
||||
(compile-expr em (first args) scope false)
|
||||
(compile-expr em (nth args 1) scope false)
|
||||
(emit-op em 52)
|
||||
(emit-u16 em (pool-add (get em "pool") "scope-emit!"))
|
||||
(emit-byte em 2))
|
||||
(= name "emitted")
|
||||
(do
|
||||
(emit-const em (keyword-name (first args)))
|
||||
(compile-expr em (first args) scope false)
|
||||
(emit-op em 52)
|
||||
(emit-u16 em (pool-add (get em "pool") "scope-emitted"))
|
||||
(emit-byte em 1))
|
||||
@@ -986,7 +994,14 @@
|
||||
(fn
|
||||
(em args scope tail?)
|
||||
(let
|
||||
((name (keyword-name (first args)))
|
||||
((first-arg (first args))
|
||||
(name
|
||||
(cond
|
||||
(= (type-of first-arg) "keyword")
|
||||
(keyword-name first-arg)
|
||||
(= (type-of first-arg) "string")
|
||||
first-arg
|
||||
:else (symbol-name first-arg)))
|
||||
(val-expr (nth args 1))
|
||||
(body (slice args 2))
|
||||
(name-idx (pool-add (get em "pool") name)))
|
||||
|
||||
Reference in New Issue
Block a user