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)
|
|
|
|
{
|
2015-06-16 09:51:49 -04:00
|
|
|
pic_value program, env;
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2015-06-16 09:51:49 -04:00
|
|
|
pic_get_args(pic, "oo", &program, &env);
|
2014-09-08 05:47:20 -04:00
|
|
|
|
2015-06-16 09:51:49 -04:00
|
|
|
pic_assert_type(pic, env, env);
|
|
|
|
|
|
|
|
return pic_eval(pic, program, pic_env_ptr(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
|
|
|
}
|