From 0fad63f22ab625a37af93293956c2c1c26fb99a4 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 10 Oct 2013 17:08:54 +0900 Subject: [PATCH] add nil stuff --- Makefile | 2 +- include/picrin/value.h | 2 ++ src/value.c | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 45695887..dabf4361 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: build run build: - gcc -o bin/picrin -I./include src/main.c src/state.c + gcc -o bin/picrin -I./include src/main.c src/state.c src/gc.c clean: rm bin/picrin diff --git a/include/picrin/value.h b/include/picrin/value.h index 0ee56e30..86146585 100644 --- a/include/picrin/value.h +++ b/include/picrin/value.h @@ -2,6 +2,7 @@ #define VALUE_H__ enum pic_vtype { + PIC_VTYPE_NIL, PIC_VTYPE_HEAP }; @@ -35,6 +36,7 @@ struct pic_symbol { char *name; }; +pic_value pic_nil_value(); pic_value pic_obj_value(struct pic_object *obj); #endif diff --git a/src/value.c b/src/value.c index 778d2bc9..1c60e3ce 100644 --- a/src/value.c +++ b/src/value.c @@ -1,5 +1,15 @@ #include "picrin.h" +pic_value +pic_nil_value() +{ + pic_value v; + + v.vtype = PIC_VTYPE_NIL; + v.u.data = NULL; + return v; +} + pic_value pic_obj_value(struct pic_object *obj) {