From 2a6978a3b9885a94cab63e6d55e9fb4188dd4358 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 10 Oct 2013 17:54:35 +0900 Subject: [PATCH] fix bugs around compilation --- Makefile | 2 +- include/picrin.h | 2 ++ include/picrin/value.h | 8 ++++---- src/pair.c | 4 ++-- src/symbol.c | 2 +- src/value.c | 12 ++++++------ 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index dabf4361..3b4ff387 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 src/gc.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 clean: rm bin/picrin diff --git a/include/picrin.h b/include/picrin.h index fb5d964d..f8346e4e 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -1,6 +1,8 @@ #ifndef PICRIN_H__ #define PICRIN_H__ +#include + #include "picrin/value.h" typedef struct { diff --git a/include/picrin/value.h b/include/picrin/value.h index 85cb863a..75ec2fd9 100644 --- a/include/picrin/value.h +++ b/include/picrin/value.h @@ -39,12 +39,12 @@ struct pic_symbol { char *name; }; -#define pic_pair_ptr(o) ((struct pic_pair *)o->u->data) -#define pic_symbol_ptr(o) ((struct pic_symbol *)o->u->data) +#define pic_pair_ptr(o) ((struct pic_pair *)o.u.data) +#define pic_symbol_ptr(o) ((struct pic_symbol *)o.u.data) -enum pic_tt pic_type(pic_value v); +enum pic_tt pic_type(pic_value); pic_value pic_nil_value(); -pic_value pic_obj_value(struct pic_object *obj); +pic_value pic_obj_value(void *); #endif diff --git a/src/pair.c b/src/pair.c index 3b4c4ad2..dcb9d202 100644 --- a/src/pair.c +++ b/src/pair.c @@ -17,7 +17,7 @@ pic_car(pic_state *pic, pic_value obj) { struct pic_pair *pair; - pair = (struct pic_pair *)obj->u->data; + pair = (struct pic_pair *)obj.u.data; return pair->car; } @@ -27,7 +27,7 @@ pic_cdr(pic_state *pic, pic_value obj) { struct pic_pair *pair; - pair = (struct pic_pair *)obj->u->data; + pair = (struct pic_pair *)obj.u.data; return pair->cdr; } diff --git a/src/symbol.c b/src/symbol.c index a3bde2b8..c247de7d 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -3,7 +3,7 @@ #include "picrin.h" pic_value -pic_intern_cstr(pic_state *pic, char *name) +pic_intern_cstr(pic_state *pic, const char *name) { struct pic_symbol *sym; size_t len; diff --git a/src/value.c b/src/value.c index b06007a1..7c6c1604 100644 --- a/src/value.c +++ b/src/value.c @@ -3,11 +3,11 @@ enum pic_tt pic_type(pic_value v) { - switch (v->type) { + switch (v.type) { case PIC_VTYPE_NIL: return PIC_TT_NIL; case PIC_VTYPE_HEAP: - return v->u->data->tt; + return ((struct pic_object *)v.u.data)->tt; } } @@ -16,17 +16,17 @@ pic_nil_value() { pic_value v; - v.vtype = PIC_VTYPE_NIL; + v.type = PIC_VTYPE_NIL; v.u.data = NULL; return v; } pic_value -pic_obj_value(struct pic_object *obj) +pic_obj_value(void *ptr) { pic_value v; - v.vtype = PIC_VTYPE_HEAP; - v.u.data = obj; + v.type = PIC_VTYPE_HEAP; + v.u.data = ptr; return v; }