--- stack/stack.h 2002/03/10 09:13:36 1.8 +++ stack/stack.h 2002/03/14 10:39:11 1.14 @@ -24,6 +24,9 @@ /* First, define some types. */ +struct cons_struct; +struct symbol_struct; + /* A value of some type */ typedef struct { enum { @@ -31,21 +34,41 @@ tfloat, string, func, /* Function pointer */ - symb, - list + symb, /* Symbol */ + tcons /* A pair of two values */ } type:4; /* Type of stack element */ - int gc_garb:1; - int gc_protect:1; + union { + struct { + unsigned int mark:1; /* Used internally in the GC */ + unsigned int protect:1; /* Protect from GC */ + } flag; + unsigned int no_gc:2; /* Both flags as one integer */ + } gc; /* Garbage collector stuff */ union { void *ptr; /* Pointer to the content */ + struct cons_struct *c; /* ...or a pointer to a cons cell */ + struct symbol_struct *sym; /* ...or a pointer to a symbol */ int i; /* ...or an integer */ - float f; + float f; /* ...or a floating point number */ } content; /* Stores a pointer or an integer */ } 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 { /* A pair of two values */ + 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.) */ @@ -58,21 +81,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 */ + value *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 */ @@ -103,12 +118,12 @@ void push_sym(environment*, const char*); extern void nl(); extern void type(environment*); -void print_h(stackitem*, int); +void print_h(value*, 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(value*, long); extern void printstack(environment*); extern void swap(environment*); extern void rot(environment*); @@ -151,3 +166,4 @@ extern void sx_3c3d(environment*); extern void sx_3e3d(environment*); extern void sx_646976(environment*); +extern void then(environment*);