lua: string metatable, high-byte chars, multi-return truthy, perf

This commit is contained in:
2026-04-25 11:15:12 +00:00
parent dd47fa8a0b
commit 8ca5c8052d
7 changed files with 196 additions and 121 deletions

View File

@@ -204,6 +204,16 @@
(make-symbol "arg")
(list (make-symbol "lua-varargs-arg-table") (make-symbol "__args") n))))
(define
lua-body-uses-vararg?
(fn
(node)
(cond
((not (= (type-of node) "list")) false)
((= (first node) (quote lua-vararg)) true)
((= (first node) (quote lua-function)) false)
(else (some lua-body-uses-vararg? node)))))
(define
lua-tx-function-guard
(fn (body-sx)
@@ -236,9 +246,10 @@
((all-bindings
(if is-vararg
(append bindings
(list
(lua-tx-function-varargs-binding (len params))
(lua-tx-function-arg-binding (len params))))
(list (lua-tx-function-varargs-binding (len params)))
(if (lua-body-uses-vararg? body)
(list)
(list (lua-tx-function-arg-binding (len params)))))
bindings)))
(list
(make-symbol "fn")
@@ -518,10 +529,8 @@
((target (nth node 1)) (func (nth node 2)))
(cond
((= (first target) (quote lua-name))
(list
(make-symbol "define")
(make-symbol (nth target 1))
(lua-tx func)))
(let ((nm (nth target 1)))
(list (make-symbol "set!") (make-symbol nm) (lua-tx func))))
((= (first target) (quote lua-field))
(list
(make-symbol "lua-set!")