mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 04:55:04 +02:00
Relocate imports for lib:get-all-import-deps
Read program imports earlier to also handle lib-deps
This commit is contained in:
parent
5303c0cf6c
commit
3fe1dca790
1 changed files with 9 additions and 9 deletions
16
cyclone.scm
16
cyclone.scm
|
@ -27,7 +27,8 @@
|
||||||
;; Code emission.
|
;; Code emission.
|
||||||
|
|
||||||
; c-compile-and-emit : (string -> A) exp -> void
|
; c-compile-and-emit : (string -> A) exp -> void
|
||||||
(define (c-compile-and-emit input-program lib-deps src-file append-dirs prepend-dirs)
|
(define (c-compile-and-emit input-program program:imports/code
|
||||||
|
lib-deps src-file append-dirs prepend-dirs)
|
||||||
(call/cc
|
(call/cc
|
||||||
(lambda (return)
|
(lambda (return)
|
||||||
(define globals '())
|
(define globals '())
|
||||||
|
@ -81,7 +82,7 @@
|
||||||
(reverse includes))))) ;; Append code in same order as the library's includes
|
(reverse includes))))) ;; Append code in same order as the library's includes
|
||||||
(else
|
(else
|
||||||
;; Handle imports, if present
|
;; Handle imports, if present
|
||||||
(let ((reduction (import-reduction input-program)))
|
(let ((reduction program:imports/code))
|
||||||
(set! imports (car reduction))
|
(set! imports (car reduction))
|
||||||
(set! input-program (cdr reduction)))
|
(set! input-program (cdr reduction)))
|
||||||
|
|
||||||
|
@ -330,13 +331,11 @@
|
||||||
(let* ((in-file (car args))
|
(let* ((in-file (car args))
|
||||||
(in-prog (read-file in-file))
|
(in-prog (read-file in-file))
|
||||||
(program? (not (library? (car in-prog))))
|
(program? (not (library? (car in-prog))))
|
||||||
TODO: for a program need to get the import list here, not later on.
|
(program:imports/code (if program? (import-reduction in-prog) '()))
|
||||||
then pass that import list futher as well as using it here in the
|
|
||||||
call to lib:get-all-import-deps:
|
|
||||||
(lib-deps
|
(lib-deps
|
||||||
(if (and program?
|
(if (and program?
|
||||||
(tagged-list? 'import (car in-prog)))
|
(not (null? (car program:imports/code))))
|
||||||
(lib:get-all-import-deps (cdar in-prog) append-dirs prepend-dirs)
|
(lib:get-all-import-deps (car program:imports/code) append-dirs prepend-dirs)
|
||||||
'()))
|
'()))
|
||||||
(exec-file (basename in-file))
|
(exec-file (basename in-file))
|
||||||
(src-file (string-append exec-file ".c"))
|
(src-file (string-append exec-file ".c"))
|
||||||
|
@ -346,7 +345,8 @@ call to lib:get-all-import-deps:
|
||||||
(with-output-to-file
|
(with-output-to-file
|
||||||
src-file
|
src-file
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(c-compile-and-emit program lib-deps in-file append-dirs prepend-dirs)))))
|
(c-compile-and-emit program program:imports/code
|
||||||
|
lib-deps in-file append-dirs prepend-dirs)))))
|
||||||
(result (create-c-file in-prog)))
|
(result (create-c-file in-prog)))
|
||||||
|
|
||||||
;; Compile the generated C file
|
;; Compile the generated C file
|
||||||
|
|
Loading…
Add table
Reference in a new issue