fix bugs around compilation

This commit is contained in:
Yuichi Nishiwaki 2013-10-10 17:54:35 +09:00
parent bd4f3680ea
commit 2a6978a3b9
6 changed files with 16 additions and 14 deletions

View File

@ -1,7 +1,7 @@
all: build run all: build run
build: 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: clean:
rm bin/picrin rm bin/picrin

View File

@ -1,6 +1,8 @@
#ifndef PICRIN_H__ #ifndef PICRIN_H__
#define PICRIN_H__ #define PICRIN_H__
#include <stddef.h>
#include "picrin/value.h" #include "picrin/value.h"
typedef struct { typedef struct {

View File

@ -39,12 +39,12 @@ struct pic_symbol {
char *name; char *name;
}; };
#define pic_pair_ptr(o) ((struct pic_pair *)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) #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_nil_value();
pic_value pic_obj_value(struct pic_object *obj); pic_value pic_obj_value(void *);
#endif #endif

View File

@ -17,7 +17,7 @@ pic_car(pic_state *pic, pic_value obj)
{ {
struct pic_pair *pair; struct pic_pair *pair;
pair = (struct pic_pair *)obj->u->data; pair = (struct pic_pair *)obj.u.data;
return pair->car; return pair->car;
} }
@ -27,7 +27,7 @@ pic_cdr(pic_state *pic, pic_value obj)
{ {
struct pic_pair *pair; struct pic_pair *pair;
pair = (struct pic_pair *)obj->u->data; pair = (struct pic_pair *)obj.u.data;
return pair->cdr; return pair->cdr;
} }

View File

@ -3,7 +3,7 @@
#include "picrin.h" #include "picrin.h"
pic_value pic_value
pic_intern_cstr(pic_state *pic, char *name) pic_intern_cstr(pic_state *pic, const char *name)
{ {
struct pic_symbol *sym; struct pic_symbol *sym;
size_t len; size_t len;

View File

@ -3,11 +3,11 @@
enum pic_tt enum pic_tt
pic_type(pic_value v) pic_type(pic_value v)
{ {
switch (v->type) { switch (v.type) {
case PIC_VTYPE_NIL: case PIC_VTYPE_NIL:
return PIC_TT_NIL; return PIC_TT_NIL;
case PIC_VTYPE_HEAP: 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; pic_value v;
v.vtype = PIC_VTYPE_NIL; v.type = PIC_VTYPE_NIL;
v.u.data = NULL; v.u.data = NULL;
return v; return v;
} }
pic_value pic_value
pic_obj_value(struct pic_object *obj) pic_obj_value(void *ptr)
{ {
pic_value v; pic_value v;
v.vtype = PIC_VTYPE_HEAP; v.type = PIC_VTYPE_HEAP;
v.u.data = obj; v.u.data = ptr;
return v; return v;
} }