mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-21 22:59:16 +02:00
Register built-in inlines
This commit is contained in:
parent
e469f4d5a6
commit
51a1a63700
1 changed files with 31 additions and 13 deletions
44
cyclone.scm
44
cyclone.scm
|
@ -226,19 +226,37 @@
|
||||||
;; assumes (scheme base) is available to compiler AND at runtime in the compiled module/program
|
;; assumes (scheme base) is available to compiler AND at runtime in the compiled module/program
|
||||||
;; TODO: probably not good enough since inlines are not in export list
|
;; TODO: probably not good enough since inlines are not in export list
|
||||||
|
|
||||||
;(for-each
|
(for-each
|
||||||
; (lambda (import)
|
(lambda (import)
|
||||||
; (let* ((lib-name-str (lib:name->string (lib:list->import-set import)))
|
(let* ((lib-name-str (lib:name->string (lib:list->import-set import)))
|
||||||
; (inlinable-lambdas-fnc
|
(inlinable-lambdas-fnc
|
||||||
; (string->symbol
|
(string->symbol
|
||||||
; (string-append "c_" lib-name-str "_inlinable_lambdas"))))
|
(string-append "c_" lib-name-str "_inlinable_lambdas"))))
|
||||||
;TODO: no, only import if not previously loaded. may need a new export for this
|
(cond
|
||||||
; #t ;(eval `(import ,import))
|
((imported? import)
|
||||||
; (%import import)
|
(let ((lib-name (lib:list->import-set import))
|
||||||
; ;(define vars/inlines (eval `( ,inlinable-lambdas-fnc )))
|
(vars/inlines (eval `( ,inlinable-lambdas-fnc ))))
|
||||||
; ;(trace:info `(DEBUG ,import ,vars/inlines))
|
(trace:info `(DEBUG ,import ,vars/inlines))
|
||||||
; ))
|
;; Register inlines as user-defined primitives
|
||||||
; imports)
|
(for-each
|
||||||
|
(lambda (v/i)
|
||||||
|
(let ((var (car v/i)) (inline (cdr v/i)))
|
||||||
|
(prim:add-udf! var inline)))
|
||||||
|
vars/inlines)
|
||||||
|
;; Keep track of inline version of functions along with other imports
|
||||||
|
(set! imported-vars
|
||||||
|
(append
|
||||||
|
imported-vars
|
||||||
|
(map
|
||||||
|
(lambda (v/i)
|
||||||
|
(cons (cdr v/i) lib-name))
|
||||||
|
vars/inlines)))))
|
||||||
|
(else
|
||||||
|
;; TODO: try loading if not loaded (but need ex handler in case anything bad happens) #t ;(eval `(import ,import))
|
||||||
|
;;(%import import)
|
||||||
|
#f))
|
||||||
|
))
|
||||||
|
imports)
|
||||||
|
|
||||||
;(for-each
|
;(for-each
|
||||||
; (lambda (psyms)
|
; (lambda (psyms)
|
||||||
|
|
Loading…
Add table
Reference in a new issue