HS cluster 22: host-call-fn FFI + hs-win-call + def hoisting
- Add host-call-fn FFI primitive to test runner (calls SX lambdas or JS fns) - Add hs-win-call runtime helper: looks up fn by name in window globals - Compiler call case: emit guard-wrapped hs-win-call for bare (ref ...) calls - Compiler method-call else: same guard pattern for non-dot method calls - Compiler do case: hoist define forms before init/other forms (def hoisting) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1058,9 +1058,15 @@
|
||||
(cons
|
||||
(quote hs-method-call)
|
||||
(cons obj (cons method args))))
|
||||
(cons
|
||||
(quote hs-method-call)
|
||||
(cons (hs-to-sx dot-node) args)))))
|
||||
(if
|
||||
(and (list? dot-node) (= (first dot-node) (quote ref)))
|
||||
(list
|
||||
(quote guard)
|
||||
(list (quote _hs-win-e)
|
||||
(list (quote true)
|
||||
(list (quote hs-win-call) (nth dot-node 1) (cons (quote list) args))))
|
||||
(cons (hs-to-sx dot-node) args))
|
||||
(cons (quote hs-method-call) (cons (hs-to-sx dot-node) args))))))
|
||||
((= head (quote string-postfix))
|
||||
(list (quote str) (hs-to-sx (nth ast 1)) (nth ast 2)))
|
||||
((= head (quote block-literal))
|
||||
@@ -1714,7 +1720,10 @@
|
||||
body)))
|
||||
(nth compiled (- (len compiled) 1))
|
||||
(rest (reverse compiled)))
|
||||
(cons (quote do) compiled)))))
|
||||
(let
|
||||
((defs (filter (fn (c) (and (list? c) (> (len c) 0) (= (first c) (quote define)))) compiled))
|
||||
(non-defs (filter (fn (c) (not (and (list? c) (> (len c) 0) (= (first c) (quote define))))) compiled)))
|
||||
(cons (quote do) (append defs non-defs)))))))
|
||||
((= head (quote wait)) (list (quote hs-wait) (nth ast 1)))
|
||||
((= head (quote wait-for)) (emit-wait-for ast))
|
||||
((= head (quote log))
|
||||
@@ -1822,7 +1831,14 @@
|
||||
(make-symbol raw-fn)
|
||||
(hs-to-sx raw-fn)))
|
||||
(args (map hs-to-sx (rest (rest ast)))))
|
||||
(cons fn-expr args)))
|
||||
(if (and (list? raw-fn) (= (first raw-fn) (quote ref)))
|
||||
(list
|
||||
(quote guard)
|
||||
(list (quote _hs-win-e)
|
||||
(list (quote true)
|
||||
(list (quote hs-win-call) (nth raw-fn 1) (cons (quote list) args))))
|
||||
(cons fn-expr args))
|
||||
(cons fn-expr args))))
|
||||
((= head (quote return))
|
||||
(let
|
||||
((val (nth ast 1)))
|
||||
|
||||
Reference in New Issue
Block a user