Issue #165 - Handle includes as well

This commit is contained in:
Justin Ethier 2017-02-02 02:03:28 -05:00
parent 4bcbb2ad16
commit cc0aefd3f2
2 changed files with 29 additions and 8 deletions

View file

@ -73,9 +73,10 @@
(for-each (for-each
(lambda (include) (lambda (include)
(set! input-program (set! input-program
(append (read-file (string-append (append (read-file ;(string-append
(lib:import->path lib-name) (lib:import->path lib-name append-dirs prepend-dirs include)
include)) ;include)
)
input-program))) input-program)))
(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

View file

@ -234,7 +234,7 @@
)) ))
;; Get path to directory that contains the library ;; Get path to directory that contains the library
(define (lib:import->path import) (define (lib:import->path import append-dirs prepend-dirs include)
(let* ((import-path (reverse (cdr (reverse import)))) (let* ((import-path (reverse (cdr (reverse import))))
(path (path
(apply (apply
@ -242,10 +242,30 @@
(map (map
(lambda (i) (lambda (i)
(string-append (lib:atom->string i) "/")) (string-append (lib:atom->string i) "/"))
import-path)))) import-path)))
(if (tagged-list? 'scheme import) (filename
(string-append (Cyc-installation-dir 'sld) "/" path) ;; Built-in library (string-append path "" include))
path))) (dir (if (or (tagged-list? 'scheme import)
;(tagged-list? 'srfi import)
)
(Cyc-installation-dir 'sld)
"")))
(call/cc
(lambda (return)
(for-each
(lambda (path)
(let ((f (string-append path "/" filename)))
(if (file-exists? f)
(return f))))
(append prepend-dirs (list dir) append-dirs))
;; Not found, just return base name
(if (> (string-length dir) 0)
(string-append dir "/" filename)
filename)))
;(if (tagged-list? 'scheme import)
; (string-append (Cyc-installation-dir 'sld) "/" path) ;; Built-in library
; path)
))
;; Given a program's import set, resolve each import to its .o file, then ;; Given a program's import set, resolve each import to its .o file, then
;; process each import recursively to get the .o files that each one of those ;; process each import recursively to get the .o files that each one of those