fix bugs around compilation
This commit is contained in:
parent
bd4f3680ea
commit
2a6978a3b9
2
Makefile
2
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
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef PICRIN_H__
|
||||
#define PICRIN_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "picrin/value.h"
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
12
src/value.c
12
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue