mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 13:05:05 +02:00
Added c-macro-return-direct-with-closure
This commit is contained in:
parent
8f7b785ec3
commit
8eb447d11b
1 changed files with 24 additions and 1 deletions
|
@ -125,7 +125,10 @@
|
||||||
(vector-ref *c-call-arity* arity))
|
(vector-ref *c-call-arity* arity))
|
||||||
(emit (c-macro-closcall arity))
|
(emit (c-macro-closcall arity))
|
||||||
(emit (c-macro-return-closcall arity))
|
(emit (c-macro-return-closcall arity))
|
||||||
(emit (c-macro-return-direct arity))))
|
(emit (c-macro-return-direct arity))
|
||||||
|
(emit (c-macro-return-direct-with-closure arity))
|
||||||
|
)
|
||||||
|
)
|
||||||
(emit-c-arity-macros (+ arity 1))))
|
(emit-c-arity-macros (+ arity 1))))
|
||||||
|
|
||||||
(define (c-macro-return-closcall num-args)
|
(define (c-macro-return-closcall num-args)
|
||||||
|
@ -163,6 +166,26 @@
|
||||||
" (_fn)(td, " n ", (closure)_fn" args "); \\\n"
|
" (_fn)(td, " n ", (closure)_fn" args "); \\\n"
|
||||||
" }}\n")))
|
" }}\n")))
|
||||||
|
|
||||||
|
(define (c-macro-return-direct-with-closure num-args)
|
||||||
|
(let ((args (c-macro-n-prefix num-args ",a"))
|
||||||
|
(n (number->string num-args))
|
||||||
|
(arry-assign (c-macro-array-assign num-args "buf" "a")))
|
||||||
|
(string-append
|
||||||
|
;"/* Check for GC, then call C function directly */\n"
|
||||||
|
"#define return_direct_with_clo" n "(td, clo, _clo_fn, _fn" args ") { \\\n"
|
||||||
|
" char top; \\\n"
|
||||||
|
" if (stack_overflow(&top, (((gc_thread_data *)data)->stack_limit))) { \\\n"
|
||||||
|
;; " object buf[" n "]; " arry-assign " \\\n"
|
||||||
|
;; " mclosure0(c1, (function_type) _clo_fn); \\\n"
|
||||||
|
;; " GC(td, &c1, buf, " n "); \\\n"
|
||||||
|
;; " return; \\\n"
|
||||||
|
" object buf[" n "]; " arry-assign "\\\n"
|
||||||
|
" GC(td, clo, buf, " n "); \\\n"
|
||||||
|
" return; \\\n"
|
||||||
|
" } else { \\\n"
|
||||||
|
" (_fn)(td, " n ", (closure)(clo)" args "); \\\n"
|
||||||
|
" }}\n")))
|
||||||
|
|
||||||
(define (c-macro-closcall num-args)
|
(define (c-macro-closcall num-args)
|
||||||
(let ((args (c-macro-n-prefix num-args ",a"))
|
(let ((args (c-macro-n-prefix num-args ",a"))
|
||||||
(n (number->string num-args))
|
(n (number->string num-args))
|
||||||
|
|
Loading…
Add table
Reference in a new issue