eval procedure now takes environment object for the second argument
This commit is contained in:
parent
eef74604d0
commit
4f69cb8ec3
|
@ -4,14 +4,12 @@
|
||||||
(define environment
|
(define environment
|
||||||
(let ((counter 0))
|
(let ((counter 0))
|
||||||
(lambda specs
|
(lambda specs
|
||||||
(let ((library-name `(picrin @@my-environment ,counter)))
|
(let ((library-name `(picrin @@my-environment ,(string->symbol (number->string counter)))))
|
||||||
(set! counter (+ counter 1))
|
(set! counter (+ counter 1))
|
||||||
(eval
|
(eval
|
||||||
`(define-library ,library-name
|
`(define-library ,library-name
|
||||||
,@(map (lambda (spec)
|
,@(map (lambda (spec) `(import ,spec)) specs))
|
||||||
`(import ,spec))
|
(library-environment (find-library '(scheme base))))
|
||||||
specs))
|
(library-environment (find-library library-name))))))
|
||||||
'(scheme base))
|
|
||||||
library-name))))
|
|
||||||
|
|
||||||
(export environment eval))
|
(export environment eval))
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
(scheme cxr)
|
(scheme cxr)
|
||||||
(scheme lazy)
|
(scheme lazy)
|
||||||
(scheme eval)
|
(scheme eval)
|
||||||
(scheme load))
|
(scheme load)
|
||||||
|
(picrin base))
|
||||||
|
|
||||||
(define-library (scheme null)
|
(define-library (scheme null)
|
||||||
(import (scheme base))
|
(import (scheme base))
|
||||||
|
@ -25,12 +26,12 @@
|
||||||
(define (null-environment n)
|
(define (null-environment n)
|
||||||
(if (not (= n 5))
|
(if (not (= n 5))
|
||||||
(error "unsupported environment version" n)
|
(error "unsupported environment version" n)
|
||||||
'(scheme null)))
|
(library-environment (find-library '(scheme null)))))
|
||||||
|
|
||||||
(define (scheme-report-environment n)
|
(define (scheme-report-environment n)
|
||||||
(if (not (= n 5))
|
(if (not (= n 5))
|
||||||
(error "unsupported environment version" n)
|
(error "unsupported environment version" n)
|
||||||
'(scheme r5rs)))
|
(library-environment (find-library '(scheme r5rs)))))
|
||||||
|
|
||||||
(export * + - / < <= = > >=
|
(export * + - / < <= = > >=
|
||||||
abs acos and
|
abs acos and
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
(scheme read)
|
(scheme read)
|
||||||
(scheme write)
|
(scheme write)
|
||||||
(scheme eval))
|
(scheme eval)
|
||||||
|
(picrin base))
|
||||||
|
|
||||||
(cond-expand
|
(cond-expand
|
||||||
((library (picrin readline))
|
((library (picrin readline))
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
(picrin macro)
|
(picrin macro)
|
||||||
(picrin array)
|
(picrin array)
|
||||||
(picrin library))
|
(picrin library))
|
||||||
'(picrin user))
|
(library-environment (find-library '(picrin user))))
|
||||||
|
|
||||||
(define (repl)
|
(define (repl)
|
||||||
(let loop ((buf ""))
|
(let loop ((buf ""))
|
||||||
|
|
|
@ -17,16 +17,13 @@ pic_eval(pic_state *pic, pic_value program, struct pic_env *env)
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_eval_eval(pic_state *pic)
|
pic_eval_eval(pic_state *pic)
|
||||||
{
|
{
|
||||||
pic_value program, spec;
|
pic_value program, env;
|
||||||
struct pic_lib *lib;
|
|
||||||
|
|
||||||
pic_get_args(pic, "oo", &program, &spec);
|
pic_get_args(pic, "oo", &program, &env);
|
||||||
|
|
||||||
lib = pic_find_library(pic, spec);
|
pic_assert_type(pic, env, env);
|
||||||
if (lib == NULL) {
|
|
||||||
pic_errorf(pic, "no library found: ~s", spec);
|
return pic_eval(pic, program, pic_env_ptr(env));
|
||||||
}
|
|
||||||
return pic_eval(pic, program, lib->env);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue