2014-07-27 00:41:55 -04:00
|
|
|
/**
|
|
|
|
* 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;
|
2014-07-27 00:57:15 -04:00
|
|
|
struct pic_lib *lib;
|
2014-07-27 00:41:55 -04:00
|
|
|
|
|
|
|
pic_get_args(pic, "oo", &program, &spec);
|
|
|
|
|
2014-07-27 00:57:15 -04:00
|
|
|
lib = pic_find_library(pic, spec);
|
|
|
|
if (lib == NULL) {
|
|
|
|
pic_errorf(pic, "no library found: ~s", spec);
|
|
|
|
}
|
|
|
|
return pic_eval(pic, program, lib);
|
2014-07-27 00:41:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pic_init_eval(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_deflibrary ("(scheme eval)") {
|
|
|
|
pic_defun(pic, "eval", pic_eval_eval);
|
|
|
|
}
|
|
|
|
}
|