mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-06 12:46:35 +02:00
Handle import-sets that contain numbers
This commit is contained in:
parent
e8186fb6fe
commit
3f0306c404
1 changed files with 25 additions and 15 deletions
|
@ -83,7 +83,7 @@
|
|||
(define (lib:imports ast)
|
||||
(lib:result
|
||||
(let ((code (assoc 'import (cddr ast))))
|
||||
(if code (cdr code) #f))))
|
||||
(if code (lib:list->import-set (cdr code)) #f))))
|
||||
(define (lib:body ast)
|
||||
(lib:result
|
||||
(let ((code (assoc 'begin (cddr ast))))
|
||||
|
@ -99,6 +99,15 @@
|
|||
|
||||
;; TODO: include-ci, cond-expand
|
||||
|
||||
(define (lib:atom->string atom)
|
||||
(cond
|
||||
((symbol? atom)
|
||||
(symbol->string atom))
|
||||
((number? atom)
|
||||
(number->string atom))
|
||||
(else
|
||||
(error "Unexpected type in import set"))))
|
||||
|
||||
;; Resolve library filename given an import.
|
||||
;; Assumes ".sld" file extension if one is not specified.
|
||||
(define (lib:import->filename import . ext)
|
||||
|
@ -112,7 +121,7 @@
|
|||
string-append
|
||||
(map
|
||||
(lambda (i)
|
||||
(string-append "/" (symbol->string i)))
|
||||
(string-append "/" (lib:atom->string i)))
|
||||
import))
|
||||
file-ext))
|
||||
(filename
|
||||
|
@ -129,7 +138,7 @@
|
|||
string-append
|
||||
(map
|
||||
(lambda (i)
|
||||
(string-append (symbol->string i) "/"))
|
||||
(string-append (lib:atom->string i) "/"))
|
||||
import-path))))
|
||||
(if (tagged-list? 'scheme import)
|
||||
(string-append (Cyc-installation-dir 'sld) "/" path) ;; Built-in library
|
||||
|
@ -177,7 +186,7 @@
|
|||
(map
|
||||
(lambda (import)
|
||||
(lib:import->export-list import))
|
||||
imports)))
|
||||
(lib:list->import-set imports))))
|
||||
|
||||
(define (lib:import->metalist import)
|
||||
(let ((file (lib:import->filename import ".meta"))
|
||||
|
@ -204,19 +213,20 @@
|
|||
(define (lib:get-all-import-deps imports)
|
||||
(letrec ((libraries/deps '())
|
||||
(find-deps!
|
||||
(lambda (import-set)
|
||||
(lambda (import-sets)
|
||||
(for-each
|
||||
(lambda (i)
|
||||
(let ((import-set (lib:list->import-set i)))
|
||||
(cond
|
||||
;; Prevent cycles by only processing new libraries
|
||||
((not (assoc i libraries/deps))
|
||||
((not (assoc import-set libraries/deps))
|
||||
;; Find all dependencies of i (IE, libraries it imports)
|
||||
(let ((deps (lib:read-imports i)))
|
||||
(set! libraries/deps (cons (cons i deps) libraries/deps))
|
||||
(let ((deps (lib:read-imports import-set)))
|
||||
(set! libraries/deps (cons (cons import-set deps) libraries/deps))
|
||||
(find-deps! deps)
|
||||
))))
|
||||
import-set))))
|
||||
(find-deps! (lib:list->import-set imports))
|
||||
)))))
|
||||
import-sets))))
|
||||
(find-deps! imports)
|
||||
;`((deps ,libraries/deps) ; DEBUG
|
||||
; (result ,(lib:get-dep-list libraries/deps)))
|
||||
(lib:get-dep-list libraries/deps)
|
||||
|
|
Loading…
Add table
Reference in a new issue