From 408255381ca3b4ecf4d874f77c1d89954f310759 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 3 Mar 2014 22:23:10 +0900 Subject: [PATCH] add pic_eval --- include/picrin.h | 1 + src/vm.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/picrin.h b/include/picrin.h index fa73d7dd..0e7a8af5 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -181,6 +181,7 @@ pic_value pic_load(pic_state *, const char *); pic_value pic_apply(pic_state *, struct pic_proc *, pic_value); pic_value pic_apply_argv(pic_state *, struct pic_proc *, size_t, ...); pic_value pic_apply_trampoline(pic_state *, struct pic_proc *, pic_value); +pic_value pic_eval(pic_state *, pic_value); struct pic_proc *pic_compile(pic_state *, pic_value); pic_value pic_macroexpand(pic_state *, pic_value); diff --git a/src/vm.c b/src/vm.c index 31025f7d..eef5fa04 100644 --- a/src/vm.c +++ b/src/vm.c @@ -873,3 +873,13 @@ pic_apply_trampoline(pic_state *pic, struct pic_proc *proc, pic_value args) ci->fp = fp - 1; /* the last argument is pushed by the VM */ return v; } + +pic_value +pic_eval(pic_state *pic, pic_value program) +{ + struct pic_proc *proc; + + proc = pic_compile(pic, program); + + return pic_apply(pic, proc, pic_nil_value()); +}