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