--- stack/stack.h 2002/03/10 10:06:36 1.9 +++ stack/stack.h 2002/03/10 20:08:47 1.10 @@ -24,6 +24,8 @@ /* First, define some types. */ +struct cons_struct; + /* A value of some type */ typedef struct { enum { @@ -32,7 +34,7 @@ string, func, /* Function pointer */ symb, - list + tcons } type:4; /* Type of stack element */ union { @@ -44,6 +46,7 @@ } gc; union { + struct cons_struct *c; void *ptr; /* Pointer to the content */ int i; /* ...or an integer */ float f; @@ -51,6 +54,19 @@ } value; +/* An item (value) on a stack */ +typedef struct stackitem_struct +{ + value *item; /* The value on the stack */ + /* (This is never NULL) */ + struct stackitem_struct *next; /* Next item */ +} stackitem; + +typedef struct cons_struct { + value *car; + value *cdr; +} cons; + /* A symbol with a name and possible value */ /* (These do not need reference counters, they are kept unique by hashing.) */ @@ -63,21 +79,13 @@ /* A type for a hash table for symbols */ typedef symbol *hashtbl[HASHTBLSIZE]; /* Hash table declaration */ -/* An item (value) on a stack */ -typedef struct stackitem_struct -{ - value *item; /* The value on the stack */ - /* (This is never NULL) */ - struct stackitem_struct *next; /* Next item */ -} stackitem; - /* An environment; gives access to the stack and a hash table of defined symbols */ typedef struct { stackitem *gc_ref; int gc_limit, gc_count; - stackitem *head; /* Head of the stack */ + cons *head; /* Head of the stack */ hashtbl symbols; /* Hash table of all variable bindings */ int err; /* Error flag */ char *in_string; /* Input pending to be read */ @@ -108,12 +116,12 @@ void push_sym(environment*, const char*); extern void nl(); extern void type(environment*); -void print_h(stackitem*, int); +void print_h(cons*, int); extern void print_(environment*); extern void print(environment*); extern void princ_(environment*); extern void princ(environment*); -void print_st(stackitem*, long); +void print_st(cons*, long); extern void printstack(environment*); extern void swap(environment*); extern void rot(environment*);