gc and cons pairs
This commit is contained in:
parent
d64b0f0a6f
commit
fe9a8a7039
8 changed files with 217 additions and 10 deletions
26
wscm.h
26
wscm.h
|
|
@ -36,10 +36,12 @@ struct St {
|
|||
};
|
||||
|
||||
// gc header
|
||||
enum { OBJ_CONS, OBJ_SYM, OBJ_FWD };
|
||||
|
||||
typedef struct H H;
|
||||
struct H {
|
||||
I type;
|
||||
Z len;
|
||||
Z size;
|
||||
};
|
||||
|
||||
// heap
|
||||
|
|
@ -58,4 +60,26 @@ struct E {
|
|||
extern E heap;
|
||||
extern St syms;
|
||||
|
||||
#define IMM(x) ((x) & 1)
|
||||
#define NUM(x) (((O)((I)(x) << 1)) | (V)1)
|
||||
#define ORD(x) ((I)(x) >> 1)
|
||||
#define BOX(x) ((O)(x))
|
||||
#define UNBOX(x) ((H *)(x))
|
||||
|
||||
#define NIL ((O)0)
|
||||
#define GC_HEAP_BYTES (1024 * 1024)
|
||||
|
||||
// GC
|
||||
void addroot(O *ptr);
|
||||
I rootmark(void);
|
||||
void rootreset(I mark);
|
||||
void collect(void);
|
||||
H *alloc(Z sz);
|
||||
void gcinit(void);
|
||||
void gcfinalize(void);
|
||||
|
||||
S *intern(const char *str, I len);
|
||||
O mksym(const char *str);
|
||||
|
||||
O cons(O head, O tail);
|
||||
C *uncons(O obj);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue