mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-07 05:06:36 +02:00
WIP for FFI
This commit is contained in:
parent
5e1bc2f282
commit
52cd5c48e1
2 changed files with 22 additions and 6 deletions
|
@ -298,6 +298,8 @@
|
|||
; Global definition
|
||||
((define? exp)
|
||||
(c-compile-global exp append-preamble cont trace))
|
||||
; ((define-c? exp)
|
||||
; (c-compile-raw-global-lambda exp append-preamble cont trace))
|
||||
; Special case - global function w/out a closure. Create an empty closure
|
||||
((tagged-list? 'lambda exp)
|
||||
(c-compile-exp
|
||||
|
@ -991,6 +993,20 @@
|
|||
(st:add-function! trace var)))
|
||||
(c-code/vars "" (list ""))))
|
||||
|
||||
;; TODO: not tested, does not work yet:
|
||||
(define (c-compile-raw-global-lambda exp append-preamble cont trace)
|
||||
(let* ((lid (allocate-lambda (c-compile-lambda lam trace)))
|
||||
(fnc-name (string-append "static void __lambda_" (number->string lid))))
|
||||
(add-global
|
||||
(define->var exp)
|
||||
#t ;(lambda? body)
|
||||
(c-code (caddr exp))
|
||||
;(c-compile-exp
|
||||
; body append-preamble cont
|
||||
; (st:add-function! trace var))
|
||||
)
|
||||
(c-code/vars "" (list ""))))
|
||||
|
||||
;; Symbol compilation
|
||||
|
||||
(define *symbols* '())
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(define-library (scheme load)
|
||||
(export
|
||||
prim-test ;; TODO: This is just temporary, of course
|
||||
; prim-test ;; TODO: This is just temporary, of course
|
||||
load)
|
||||
(import (scheme base)
|
||||
(scheme eval)
|
||||
|
@ -15,11 +15,11 @@
|
|||
;; lambda portion is computed, so we can't include that.
|
||||
;; compiler would need to insert the "static void (lambda)" part
|
||||
;; TODO: maybe break up into two args, one being the args list and the other being the function body??
|
||||
(define-c prim-test "
|
||||
(void *data, int argc, closure _, object k, object arg1, object arg2) {
|
||||
return_closcall1(data, k, arg1);
|
||||
}
|
||||
")
|
||||
; (define-c prim-test "
|
||||
; (void *data, int argc, closure _, object k, object arg1, object arg2) {
|
||||
; return_closcall1(data, k, arg1);
|
||||
; }
|
||||
; ")
|
||||
;; End FFI
|
||||
(define (load filename . env)
|
||||
(let ((exprs (call-with-input-file filename
|
||||
|
|
Loading…
Add table
Reference in a new issue