From ee3442210cf893610f3d48dcce8d61a5d4efa2ce Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 12 Oct 2013 12:55:05 +0900 Subject: [PATCH] replace evaluator in repl to the VM --- Makefile | 2 +- src/main.c | 6 +++++- src/vm.c | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 50040c41..fa9f2971 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ build: cd src; \ yacc -d parse.y; \ lex scan.l - gcc -o bin/picrin -I./include src/main.c src/state.c src/gc.c src/pair.c src/write.c src/symbol.c src/value.c src/y.tab.c src/lex.yy.c src/eval.c src/bool.c + gcc -o bin/picrin -I./include src/main.c src/state.c src/gc.c src/pair.c src/write.c src/symbol.c src/value.c src/y.tab.c src/lex.yy.c src/eval.c src/bool.c src/vm.c test-vm: cd src; \ diff --git a/src/main.c b/src/main.c index 15b28450..a14e4452 100644 --- a/src/main.c +++ b/src/main.c @@ -33,6 +33,7 @@ main() char line[LINE_MAX_LENGTH], last_char; int char_index; pic_value v; + struct pic_proc *proc; pic = pic_open(); @@ -54,7 +55,10 @@ main() /* echo */ v = pic_parse(pic, line); - pic_debug(pic, pic_eval(pic, v, pic->global_env)); + //pic_debug(pic, pic_eval(pic, v, pic->global_env)); + proc = pic_codegen(pic, v, pic->global_env); + v = pic_run(pic, proc, pic_nil_value()); + pic_debug(pic, v); printf("\n"); } diff --git a/src/vm.c b/src/vm.c index 51dabcc9..eb7deff4 100644 --- a/src/vm.c +++ b/src/vm.c @@ -138,6 +138,7 @@ pic_codegen(pic_state *pic, pic_value obj, struct pic_env *env) return proc; } +#if 0 int main() { @@ -164,3 +165,4 @@ main() return 0; } +#endif