let pic_proc be a first class object
This commit is contained in:
parent
d92bd71293
commit
1fb9ac5d03
|
@ -11,12 +11,6 @@ struct pic_env {
|
|||
struct pic_env *parent;
|
||||
};
|
||||
|
||||
struct pic_proc {
|
||||
union {
|
||||
struct pic_irep *irep;
|
||||
} u;
|
||||
};
|
||||
|
||||
#define PIC_HEAP_SIZE 1024
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -23,7 +23,8 @@ enum pic_tt {
|
|||
PIC_TT_UNDEF,
|
||||
/* heap */
|
||||
PIC_TT_PAIR,
|
||||
PIC_TT_SYMBOL
|
||||
PIC_TT_SYMBOL,
|
||||
PIC_TT_PROC
|
||||
};
|
||||
|
||||
#define PIC_OBJECT_HEADER \
|
||||
|
@ -44,8 +45,16 @@ struct pic_symbol {
|
|||
char *name;
|
||||
};
|
||||
|
||||
struct pic_proc {
|
||||
PIC_OBJECT_HEADER
|
||||
union {
|
||||
struct pic_irep *irep;
|
||||
} u;
|
||||
};
|
||||
|
||||
#define pic_pair_ptr(o) ((struct pic_pair *)o.u.data)
|
||||
#define pic_symbol_ptr(o) ((struct pic_symbol *)o.u.data)
|
||||
#define pic_proc_ptr(o) ((struct pic_proc *)o.u.data)
|
||||
|
||||
enum pic_tt pic_type(pic_value);
|
||||
|
||||
|
|
2
src/vm.c
2
src/vm.c
|
@ -161,7 +161,7 @@ pic_codegen(pic_state *pic, pic_value obj, struct pic_env *env)
|
|||
struct pic_irep *irep;
|
||||
struct pic_code *code;
|
||||
|
||||
proc = (struct pic_proc *)malloc(sizeof(struct pic_proc));
|
||||
proc = (struct pic_proc *)pic_gc_alloc(pic, sizeof(struct pic_proc), PIC_TT_PROC);
|
||||
|
||||
proc->u.irep = irep = (struct pic_irep *)malloc(sizeof(struct pic_irep));
|
||||
irep->code = code = (struct pic_code *)malloc(sizeof(struct pic_code) * 1024);
|
||||
|
|
Loading…
Reference in New Issue