mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
Emit code for define-c inlines
This commit is contained in:
parent
470ea62e9d
commit
c7476fb1ed
1 changed files with 37 additions and 4 deletions
|
@ -823,10 +823,13 @@
|
||||||
(st:add-function! trace var)))
|
(st:add-function! trace var)))
|
||||||
(c-code/vars "" (list ""))))
|
(c-code/vars "" (list ""))))
|
||||||
|
|
||||||
;; TODO: not tested, does not work yet:
|
(define (c-compile-raw-global-lambda exp append-preamble cont trace . inline?)
|
||||||
(define (c-compile-raw-global-lambda exp append-preamble cont trace)
|
(let* ((precompiled-sym
|
||||||
(let* ((lambda-data
|
(if (equal? inline? '(#t))
|
||||||
`(precompiled-lambda
|
'precompiled-inline-lambda
|
||||||
|
'precompiled-lambda))
|
||||||
|
(lambda-data
|
||||||
|
`(,precompiled-sym
|
||||||
,(caddr exp) ;; Args
|
,(caddr exp) ;; Args
|
||||||
,(cadddr exp) ;; Body
|
,(cadddr exp) ;; Body
|
||||||
))
|
))
|
||||||
|
@ -842,6 +845,21 @@
|
||||||
(num-args
|
(num-args
|
||||||
(- total-num-args 4))
|
(- total-num-args 4))
|
||||||
)
|
)
|
||||||
|
;; Is the function also defined inline?
|
||||||
|
;(trace:error `(JAE define-c ,exp))
|
||||||
|
(cond
|
||||||
|
((> (length exp) 4)
|
||||||
|
;(trace:error `(JAE define-c inline detected))
|
||||||
|
(let ((fnc-sym
|
||||||
|
(define-c->inline-var exp)))
|
||||||
|
;(trace:error `(JAE define-c inline detected ,fnc-sym))
|
||||||
|
(c-compile-raw-global-lambda
|
||||||
|
`(define-c ,fnc-sym ,@(cddddr exp))
|
||||||
|
append-preamble
|
||||||
|
cont
|
||||||
|
trace
|
||||||
|
#t)))) ;; Inline this one
|
||||||
|
;; Add this define-c
|
||||||
(add-global
|
(add-global
|
||||||
(define->var exp)
|
(define->var exp)
|
||||||
#t ;(lambda? body)
|
#t ;(lambda? body)
|
||||||
|
@ -1256,6 +1274,12 @@
|
||||||
(number->string (car l))
|
(number->string (car l))
|
||||||
(cadadr l)
|
(cadadr l)
|
||||||
" ;"))
|
" ;"))
|
||||||
|
((equal? 'precompiled-inline-lambda (caadr l))
|
||||||
|
(emit*
|
||||||
|
"static object __lambda_"
|
||||||
|
(number->string (car l))
|
||||||
|
(cadadr l)
|
||||||
|
" ;"))
|
||||||
(else
|
(else
|
||||||
(emit*
|
(emit*
|
||||||
"static void __lambda_"
|
"static void __lambda_"
|
||||||
|
@ -1279,6 +1303,15 @@
|
||||||
(car (cddadr l))
|
(car (cddadr l))
|
||||||
" }"
|
" }"
|
||||||
))
|
))
|
||||||
|
((equal? 'precompiled-inline-lambda (caadr l))
|
||||||
|
(emit*
|
||||||
|
"static object __lambda_"
|
||||||
|
(number->string (car l))
|
||||||
|
(cadadr l)
|
||||||
|
" {"
|
||||||
|
(car (cddadr l))
|
||||||
|
" }"
|
||||||
|
))
|
||||||
(else
|
(else
|
||||||
(emit ((caadr l) (string-append "__lambda_" (number->string (car l))))))))
|
(emit ((caadr l) (string-append "__lambda_" (number->string (car l))))))))
|
||||||
lambdas)
|
lambdas)
|
||||||
|
|
Loading…
Add table
Reference in a new issue