primary eval support
This commit is contained in:
parent
09efa4715c
commit
e258529e8a
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* See Copyright Notice in picrin.h
|
||||
*/
|
||||
|
||||
#include "picrin.h"
|
||||
#include "picrin/macro.h"
|
||||
|
||||
pic_value
|
||||
pic_eval(pic_state *pic, pic_value program, struct pic_lib *lib)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
|
||||
proc = pic_compile(pic, program, lib);
|
||||
|
||||
return pic_apply(pic, proc, pic_nil_value());
|
||||
}
|
||||
|
||||
static pic_value
|
||||
pic_eval_eval(pic_state *pic)
|
||||
{
|
||||
pic_value program, spec;
|
||||
|
||||
pic_get_args(pic, "oo", &program, &spec);
|
||||
|
||||
return pic_eval(pic, program, pic_find_library(pic, spec));
|
||||
}
|
||||
|
||||
void
|
||||
pic_init_eval(pic_state *pic)
|
||||
{
|
||||
pic_deflibrary ("(scheme eval)") {
|
||||
pic_defun(pic, "eval", pic_eval_eval);
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ void pic_init_load(pic_state *);
|
|||
void pic_init_write(pic_state *);
|
||||
void pic_init_read(pic_state *);
|
||||
void pic_init_dict(pic_state *);
|
||||
void pic_init_eval(pic_state *);
|
||||
void pic_init_contrib(pic_state *);
|
||||
|
||||
void pic_load_piclib(pic_state *);
|
||||
|
@ -92,6 +93,7 @@ pic_init_core(pic_state *pic)
|
|||
pic_init_write(pic); DONE;
|
||||
pic_init_read(pic); DONE;
|
||||
pic_init_dict(pic); DONE;
|
||||
pic_init_eval(pic); DONE;
|
||||
|
||||
pic_load_piclib(pic); DONE;
|
||||
|
||||
|
|
10
src/vm.c
10
src/vm.c
|
@ -1061,13 +1061,3 @@ pic_apply_trampoline(pic_state *pic, struct pic_proc *proc, pic_value args)
|
|||
ci->retc = pic_length(pic, args);
|
||||
return pic_obj_value(proc);
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_eval(pic_state *pic, pic_value program, struct pic_lib *lib)
|
||||
{
|
||||
struct pic_proc *proc;
|
||||
|
||||
proc = pic_compile(pic, program, lib);
|
||||
|
||||
return pic_apply(pic, proc, pic_nil_value());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue