more preparations for separate compilation
This commit is contained in:
parent
fa08c543bb
commit
c430a91bb8
Binary file not shown.
|
@ -18,7 +18,7 @@
|
||||||
(export load load-r6rs-top-level)
|
(export load load-r6rs-top-level)
|
||||||
(import
|
(import
|
||||||
(except (ikarus) load)
|
(except (ikarus) load)
|
||||||
(only (psyntax expander) eval-top-level eval-r6rs-top-level)
|
(only (psyntax expander) eval-top-level compile-r6rs-top-level)
|
||||||
(only (ikarus reader) read-initial))
|
(only (ikarus reader) read-initial))
|
||||||
|
|
||||||
(define load-handler
|
(define load-handler
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
(read-and-eval p eval-proc)))
|
(read-and-eval p eval-proc)))
|
||||||
(close-input-port p))]))
|
(close-input-port p))]))
|
||||||
(define load-r6rs-top-level
|
(define load-r6rs-top-level
|
||||||
(lambda (x)
|
(lambda (x how)
|
||||||
(define (read-file)
|
(define (read-file)
|
||||||
(let ([p (open-input-file x)])
|
(let ([p (open-input-file x)])
|
||||||
(let ([x (read-script-annotated p)])
|
(let ([x (read-script-annotated p)])
|
||||||
|
@ -60,5 +60,9 @@
|
||||||
'()]
|
'()]
|
||||||
[else (cons x (f))]))))))))
|
[else (cons x (f))]))))))))
|
||||||
(let ([prog (read-file)])
|
(let ([prog (read-file)])
|
||||||
(eval-r6rs-top-level prog))))
|
(let ([thunk (compile-r6rs-top-level prog)])
|
||||||
|
(case how
|
||||||
|
[(run) (thunk)]
|
||||||
|
[(compile) (error 'load-r6rs "not yet")]
|
||||||
|
[else (error 'load-r6rs-top-level "invali argument" how)])))))
|
||||||
)
|
)
|
||||||
|
|
|
@ -90,13 +90,25 @@
|
||||||
(die 'ikarus "--r6rs-script requires a script name")]
|
(die 'ikarus "--r6rs-script requires a script name")]
|
||||||
[else
|
[else
|
||||||
(values '() (car d) 'r6rs-script (cdr d))]))]
|
(values '() (car d) 'r6rs-script (cdr d))]))]
|
||||||
|
[(string=? (car args) "--compile-r6rs-script")
|
||||||
|
(let ([d (cdr args)])
|
||||||
|
(cond
|
||||||
|
[(null? d)
|
||||||
|
(die 'ikarus
|
||||||
|
"--compile-r6rs-script requires a script name")]
|
||||||
|
[else
|
||||||
|
(values '() (car d) 'compile-r6rs-script (cdr d))]))]
|
||||||
[else
|
[else
|
||||||
(let-values ([(f* script script-type a*) (f (cdr args))])
|
(let-values ([(f* script script-type a*) (f (cdr args))])
|
||||||
(values (cons (car args) f*) script script-type a*))]))])
|
(values (cons (car args) f*) script script-type a*))]))])
|
||||||
(cond
|
(cond
|
||||||
[(eq? script-type 'r6rs-script)
|
[(eq? script-type 'r6rs-script)
|
||||||
(command-line-arguments (cons script args))
|
(command-line-arguments (cons script args))
|
||||||
(load-r6rs-top-level script)
|
(load-r6rs-top-level script 'run)
|
||||||
|
(exit 0)]
|
||||||
|
[(eq? script-type 'compile-r6rs-script)
|
||||||
|
(command-line-arguments (cons script args))
|
||||||
|
(load-r6rs-top-level script 'compile)
|
||||||
(exit 0)]
|
(exit 0)]
|
||||||
[(eq? script-type 'script) ; no greeting, no cafe
|
[(eq? script-type 'script) ; no greeting, no cafe
|
||||||
(command-line-arguments (cons script args))
|
(command-line-arguments (cons script args))
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1392
|
1393
|
||||||
|
|
|
@ -19,11 +19,13 @@
|
||||||
eval-core symbol-value set-symbol-value!
|
eval-core symbol-value set-symbol-value!
|
||||||
file-options-spec make-struct-type read-annotated
|
file-options-spec make-struct-type read-annotated
|
||||||
annotation? annotation-expression annotation-source
|
annotation? annotation-expression annotation-source
|
||||||
annotation-stripped)
|
annotation-stripped load-precompiled-library)
|
||||||
(import
|
(import
|
||||||
(only (ikarus.compiler) eval-core)
|
(only (ikarus.compiler) eval-core)
|
||||||
(ikarus))
|
(ikarus))
|
||||||
|
|
||||||
|
(define (load-precompiled-library filename sk) #f)
|
||||||
|
|
||||||
(define-syntax define-record
|
(define-syntax define-record
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
[(_ name (field* ...) printer)
|
[(_ name (field* ...) printer)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
bound-identifier=? datum->syntax syntax-error
|
bound-identifier=? datum->syntax syntax-error
|
||||||
syntax-violation
|
syntax-violation
|
||||||
syntax->datum make-variable-transformer
|
syntax->datum make-variable-transformer
|
||||||
eval-r6rs-top-level boot-library-expand eval-top-level
|
compile-r6rs-top-level boot-library-expand eval-top-level
|
||||||
null-environment scheme-report-environment ellipsis-map)
|
null-environment scheme-report-environment ellipsis-map)
|
||||||
(import
|
(import
|
||||||
(except (rnrs)
|
(except (rnrs)
|
||||||
|
@ -3759,11 +3759,12 @@
|
||||||
(define syntax->datum
|
(define syntax->datum
|
||||||
(lambda (x) (stx->datum x)))
|
(lambda (x) (stx->datum x)))
|
||||||
|
|
||||||
(define eval-r6rs-top-level
|
(define compile-r6rs-top-level
|
||||||
(lambda (x*)
|
(lambda (x*)
|
||||||
(let-values (((lib* invoke-code) (top-level-expander x*)))
|
(let-values (((lib* invoke-code) (top-level-expander x*)))
|
||||||
(for-each invoke-library lib*)
|
(lambda ()
|
||||||
(eval-core (expanded->core invoke-code)))))
|
(for-each invoke-library lib*)
|
||||||
|
(eval-core (expanded->core invoke-code))))))
|
||||||
|
|
||||||
;;; The interaction-library is a parameter that is either #f
|
;;; The interaction-library is a parameter that is either #f
|
||||||
;;; (the default, for r6rs scripts) or set to an extensible library
|
;;; (the default, for r6rs scripts) or set to an extensible library
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
find-library-by-name install-library library-spec invoke-library
|
find-library-by-name install-library library-spec invoke-library
|
||||||
extend-library-subst! extend-library-env! current-library-expander
|
extend-library-subst! extend-library-env! current-library-expander
|
||||||
current-library-collection library-path library-extensions)
|
current-library-collection library-path library-extensions)
|
||||||
(import (rnrs) (psyntax compat) (rnrs r5rs))
|
(import (rnrs) (psyntax compat) (rnrs r5rs)
|
||||||
|
(only (ikarus) printf))
|
||||||
|
|
||||||
(define (make-collection)
|
(define (make-collection)
|
||||||
(let ((set '()))
|
(let ((set '()))
|
||||||
|
@ -155,10 +156,38 @@
|
||||||
f
|
f
|
||||||
(assertion-violation 'file-locator "not a procedure" f)))))
|
(assertion-violation 'file-locator "not a procedure" f)))))
|
||||||
|
|
||||||
(define (library-precompiled? x) #f)
|
|
||||||
|
|
||||||
(define (load-precompiled-library x)
|
(define (try-load-from-file filename)
|
||||||
(error 'load-precompiled-library "not implemented"))
|
(load-precompiled-library filename
|
||||||
|
(case-lambda
|
||||||
|
[(id name ver imp* vis* inv* exp-subst exp-env
|
||||||
|
visit-proc invoke-proc visible?)
|
||||||
|
;;; make sure all dependencies are met
|
||||||
|
;;; if all is ok, install the library
|
||||||
|
;;; otherwise, return #f so that the
|
||||||
|
;;; library gets recompiled.
|
||||||
|
(let f ([deps (append imp* vis* inv*)])
|
||||||
|
(cond
|
||||||
|
[(null? deps)
|
||||||
|
(install-library id name ver imp* vis* inv*
|
||||||
|
exp-subst exp-env visit-proc invoke-proc
|
||||||
|
#f #f visible?)
|
||||||
|
#t]
|
||||||
|
[else
|
||||||
|
(let ([d (car deps)])
|
||||||
|
(let ([label (car d)] [dname (cadr d)])
|
||||||
|
(let ([l (find-library-by-name dname)])
|
||||||
|
(cond
|
||||||
|
[(and (library? l) (eq? label (library-id l)))
|
||||||
|
(f (cdr deps))]
|
||||||
|
[else
|
||||||
|
(printf
|
||||||
|
"WARNING: missing or inconsistent dependency \
|
||||||
|
on library ~s. \
|
||||||
|
Library ~s in file ~s will be recompiled.\n"
|
||||||
|
dname name filename)
|
||||||
|
#f]))))]))]
|
||||||
|
[others #f])))
|
||||||
|
|
||||||
(define library-loader
|
(define library-loader
|
||||||
(make-parameter
|
(make-parameter
|
||||||
|
@ -167,10 +196,9 @@
|
||||||
(cond
|
(cond
|
||||||
[(not file-name)
|
[(not file-name)
|
||||||
(assertion-violation #f "cannot file library" x)]
|
(assertion-violation #f "cannot file library" x)]
|
||||||
[(library-precompiled? file-name)
|
[(try-load-from-file file-name)]
|
||||||
(load-precompiled-library file-name)]
|
|
||||||
[else
|
[else
|
||||||
((current-library-expander)
|
((current-library-expander)
|
||||||
(with-input-from-file file-name read-annotated))])))
|
(with-input-from-file file-name read-annotated))])))
|
||||||
(lambda (f)
|
(lambda (f)
|
||||||
(if (procedure? f)
|
(if (procedure? f)
|
||||||
|
@ -218,7 +246,8 @@
|
||||||
(let ((id (car spec)))
|
(let ((id (car spec)))
|
||||||
(or (find-library-by
|
(or (find-library-by
|
||||||
(lambda (x) (eq? id (library-id x))))
|
(lambda (x) (eq? id (library-id x))))
|
||||||
(assertion-violation #f "cannot find library with required spec" spec))))
|
(assertion-violation #f
|
||||||
|
"cannot find library with required spec" spec))))
|
||||||
|
|
||||||
(define label->binding-table (make-eq-hashtable))
|
(define label->binding-table (make-eq-hashtable))
|
||||||
|
|
||||||
|
@ -278,7 +307,8 @@
|
||||||
(lambda () (assertion-violation 'invoke "circularity detected" lib)))
|
(lambda () (assertion-violation 'invoke "circularity detected" lib)))
|
||||||
(for-each invoke-library (library-inv* lib))
|
(for-each invoke-library (library-inv* lib))
|
||||||
(set-library-invoke-state! lib
|
(set-library-invoke-state! lib
|
||||||
(lambda () (assertion-violation 'invoke "first invoke did not return" lib)))
|
(lambda ()
|
||||||
|
(assertion-violation 'invoke "first invoke did not return" lib)))
|
||||||
(invoke)
|
(invoke)
|
||||||
(set-library-invoke-state! lib #t))))
|
(set-library-invoke-state! lib #t))))
|
||||||
|
|
||||||
|
@ -290,7 +320,8 @@
|
||||||
(lambda () (assertion-violation 'visit "circularity detected" lib)))
|
(lambda () (assertion-violation 'visit "circularity detected" lib)))
|
||||||
(for-each invoke-library (library-vis* lib))
|
(for-each invoke-library (library-vis* lib))
|
||||||
(set-library-visit-state! lib
|
(set-library-visit-state! lib
|
||||||
(lambda () (assertion-violation 'invoke "first visit did not return" lib)))
|
(lambda ()
|
||||||
|
(assertion-violation 'invoke "first visit did not return" lib)))
|
||||||
(visit)
|
(visit)
|
||||||
(set-library-visit-state! lib #t))))
|
(set-library-visit-state! lib #t))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue