--- stack/stack.h 2002/03/11 08:53:00 1.11 +++ stack/stack.h 2002/03/17 11:26:35 1.16 @@ -25,10 +25,12 @@ /* First, define some types. */ struct cons_struct; +struct symbol_struct; /* A value of some type */ typedef struct { enum { + empty, /* The empty list */ integer, tfloat, string, @@ -48,6 +50,7 @@ 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; /* ...or a floating point number */ } content; /* Stores a pointer or an integer */ @@ -65,7 +68,7 @@ typedef struct cons_struct { /* A pair of two values */ value *car; value *cdr; -} cons; +} pair; /* A symbol with a name and possible value */ /* (These do not need reference counters, they are kept unique by @@ -82,10 +85,7 @@ /* An environment; gives access to the stack and a hash table of defined symbols */ typedef struct { - stackitem *gc_ref; - int gc_limit, gc_count; - - cons *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 */ @@ -93,6 +93,11 @@ read from in_string */ FILE *inputstream; /* stdin or a file, most likely */ int interactive; /* print prompts, stack, etc */ + + /* Garbage Collector stuff*/ + stackitem *gc_ref; /* Stack of all allocated values */ + int gc_limit; /* Run GC when this much is allocated */ + int gc_count; /* Amount currently allocated */ } environment; /* A type for pointers to external functions */ @@ -116,12 +121,12 @@ void push_sym(environment*, const char*); extern void nl(); extern void type(environment*); -void print_h(cons*, 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(cons*, long); +void print_st(value*, long); extern void printstack(environment*); extern void swap(environment*); extern void rot(environment*); @@ -164,3 +169,4 @@ extern void sx_3c3d(environment*); extern void sx_3e3d(environment*); extern void sx_646976(environment*); +extern void then(environment*);