2014-09-08 05:47:20 -04:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "picrin.h"
|
|
|
|
|
|
|
|
pic_value
|
2015-06-15 12:52:18 -04:00
|
|
|
pic_eval(pic_state *pic, pic_value program, struct pic_env *env)
|
2014-09-08 05:47:20 -04:00
|
|
|
{
|
|
|
|
struct pic_proc *proc;
|
|
|
|
|
2015-06-15 12:52:18 -04:00
|
|
|
proc = pic_compile(pic, program, env);
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2015-06-15 12:52:18 -04:00
|
|
|
return pic_apply0(pic, proc);
|
2014-09-08 05:47:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static pic_value
|
|
|
|
pic_eval_eval(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_value program, spec;
|
|
|
|
struct pic_lib *lib;
|
|
|
|
|
|
|
|
pic_get_args(pic, "oo", &program, &spec);
|
|
|
|
|
|
|
|
lib = pic_find_library(pic, spec);
|
|
|
|
if (lib == NULL) {
|
|
|
|
pic_errorf(pic, "no library found: ~s", spec);
|
|
|
|
}
|
2015-06-15 12:52:18 -04:00
|
|
|
return pic_eval(pic, program, lib->env);
|
2014-09-08 05:47:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pic_init_eval(pic_state *pic)
|
|
|
|
{
|
2014-09-08 06:38:19 -04:00
|
|
|
pic_defun(pic, "eval", pic_eval_eval);
|
2014-09-08 05:47:20 -04:00
|
|
|
}
|