mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 13:05:05 +02:00
Cleanup, adjust formatting, remove debug statement
This commit is contained in:
parent
ea2550a882
commit
8be4221c1c
1 changed files with 57 additions and 72 deletions
127
cyclone.scm
127
cyclone.scm
|
@ -232,78 +232,63 @@
|
||||||
(trace:info "---------------- after alpha conversion:")
|
(trace:info "---------------- after alpha conversion:")
|
||||||
(trace:info input-program) ;pretty-print
|
(trace:info input-program) ;pretty-print
|
||||||
|
|
||||||
;; EXPERIMENTAL CODE
|
;; EXPERIMENTAL CODE - Load functions in other modules that are
|
||||||
;; TODO: extend this initially by, for each import, invoking that module's inlinable_lambdas function
|
;; able to be inlined (in this context, from CPS).
|
||||||
;; behind an exception handler (in case the compiler does not have that module loaded).
|
;;
|
||||||
;;
|
;; TODO: extend this initially by, for each import, invoking that module's inlinable_lambdas function
|
||||||
;; Longer term, need to test if module is loaded (maybe do that in combo with exception handler above)
|
;; behind an exception handler (in case the compiler does not have that module loaded).
|
||||||
;; and if not loaded, eval/import it and try again.
|
;;
|
||||||
;;
|
;; Longer term, need to test if module is loaded (maybe do that in combo with exception handler above)
|
||||||
;; assumes (scheme base) is available to compiler AND at runtime in the compiled module/program
|
;; and if not loaded, eval/import it and try again.
|
||||||
;; TODO: probably not good enough since inlines are not in export list
|
;;
|
||||||
;;
|
;; assumes (scheme base) is available to compiler AND at runtime in the compiled module/program
|
||||||
;; TODO: later on, in cgen, only add inlinables that correspond to exported functions
|
;; TODO: probably not good enough since inlines are not in export list
|
||||||
|
;;
|
||||||
|
;; TODO: later on, in cgen, only add inlinables that correspond to exported functions
|
||||||
|
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (import)
|
(lambda (import)
|
||||||
(with-handler
|
(with-handler
|
||||||
(lambda (err)
|
(lambda (err)
|
||||||
#f)
|
#f)
|
||||||
(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"))))
|
||||||
(cond
|
(cond
|
||||||
((imported? import)
|
((imported? import)
|
||||||
(let ((lib-name (lib:import->library-name
|
(let ((lib-name (lib:import->library-name
|
||||||
(lib:list->import-set import)))
|
(lib:list->import-set import)))
|
||||||
(vars/inlines
|
(vars/inlines
|
||||||
(filter
|
(filter
|
||||||
(lambda (v/i)
|
(lambda (v/i)
|
||||||
;; Try to avoid name conflicts by not loading inlines
|
;; Try to avoid name conflicts by not loading inlines
|
||||||
;; that conflict with identifiers in this module.
|
;; that conflict with identifiers in this module.
|
||||||
;; More of a band-aid than a true solution, though.
|
;; More of a band-aid than a true solution, though.
|
||||||
(not (member (car v/i) module-globals)))
|
(not (member (car v/i) module-globals)))
|
||||||
(eval `( ,inlinable-lambdas-fnc )))))
|
(eval `( ,inlinable-lambdas-fnc )))))
|
||||||
(trace:info `(DEBUG ,import ,vars/inlines ,module-globals))
|
;(trace:info `(DEBUG ,import ,vars/inlines ,module-globals))
|
||||||
;; Register inlines as user-defined primitives
|
;; Register inlines as user-defined primitives
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (v/i)
|
(lambda (v/i)
|
||||||
(let ((var (car v/i)) (inline (cdr v/i)))
|
(let ((var (car v/i)) (inline (cdr v/i)))
|
||||||
(prim:add-udf! var inline)))
|
(prim:add-udf! var inline)))
|
||||||
vars/inlines)
|
vars/inlines)
|
||||||
;; Keep track of inline version of functions along with other imports
|
;; Keep track of inline version of functions along with other imports
|
||||||
(set! imported-vars
|
(set! imported-vars
|
||||||
(append
|
(append
|
||||||
imported-vars
|
imported-vars
|
||||||
(map
|
(map
|
||||||
(lambda (v/i)
|
(lambda (v/i)
|
||||||
(cons (cdr v/i) lib-name))
|
(cons (cdr v/i) lib-name))
|
||||||
vars/inlines)))))
|
vars/inlines)))))
|
||||||
(else
|
(else
|
||||||
;; TODO: try loading if not loaded (but need ex handler in case anything bad happens) #t ;(eval `(import ,import))
|
;; TODO: try loading if not loaded (but need ex handler in case anything bad happens) #t ;(eval `(import ,import))
|
||||||
;;(%import import)
|
;;(%import import)
|
||||||
;; if this work is done, would need to consolidate inline reg code above
|
;; if this work is done, would need to consolidate inline reg code above
|
||||||
#f)))))
|
#f)))))
|
||||||
imports)
|
imports)
|
||||||
|
;; END
|
||||||
;(for-each
|
|
||||||
; (lambda (psyms)
|
|
||||||
; (let ((var (car psyms)) (inline (cdr psyms)))
|
|
||||||
; (prim:add-udf! var inline)))
|
|
||||||
; (eval '(c_schemebase_inlinable_lambdas)))
|
|
||||||
; ;(assoc 'quotient (c_schemebase_inlinable_lambdas))
|
|
||||||
; ; (set! globals (append (lib:idb:ids imported-vars) module-globals))
|
|
||||||
;
|
|
||||||
; ;; total hack to update export list
|
|
||||||
; (set! imported-vars
|
|
||||||
; (append
|
|
||||||
; imported-vars
|
|
||||||
; (map
|
|
||||||
; (lambda (psyms)
|
|
||||||
; (list (cdr psyms) 'scheme 'base))
|
|
||||||
; (eval '(c_schemebase_inlinable_lambdas)))))
|
|
||||||
;; END
|
|
||||||
|
|
||||||
;; Convert some function calls to primitives, if possible
|
;; Convert some function calls to primitives, if possible
|
||||||
(set! input-program
|
(set! input-program
|
||||||
|
|
Loading…
Add table
Reference in a new issue