--- stack/stack.c 2002/02/15 18:27:18 1.87 +++ stack/stack.c 2002/02/16 00:51:32 1.88 @@ -15,68 +15,7 @@ /* mtrace, muntrace */ #include -#define HASHTBLSIZE 2048 - -/* First, define some types. */ - -/* A value of some type */ -typedef struct { - enum { - integer, - string, - func, /* Function pointer */ - symb, - list - } type; /* Type of stack element */ - - union { - void *ptr; /* Pointer to the content */ - int val; /* ...or an integer */ - } content; /* Stores a pointer or an integer */ - - int gc_garb; - -} value; - -/* A symbol with a name and possible value */ -/* (These do not need reference counters, they are kept unique by - hashing.) */ -typedef struct symbol_struct { - char *id; /* Symbol name */ - value *val; /* The value (if any) bound to it */ - struct symbol_struct *next; /* In case of hashing conflicts, a */ -} symbol; /* symbol is a kind of stack item. */ - -/* 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 */ - hashtbl symbols; /* Hash table of all variable bindings */ - int err; /* Error flag */ - char *in_string; /* Input pending to be read */ - char *free_string; /* Free this string when all input is - read from in_string */ - FILE *inputstream; /* stdin or a file, most likely */ - int interactive; /* print prompts, stack, etc */ -} environment; - -/* A type for pointers to external functions */ -typedef void (*funcp)(environment *); /* funcp is a pointer to a void - function (environment *) */ +#include "stack.h" /* Initialize a newly created environment */ void init_env(environment *env) @@ -144,8 +83,6 @@ } } -extern void gc_init(environment*); - value* new_val(environment *env) { value *nval= malloc(sizeof(value)); stackitem *nitem= malloc(sizeof(stackitem)); @@ -808,9 +745,6 @@ toss(env); toss(env); } -extern void clear(environment *); -void forget_sym(symbol **); - /* Quit stack. */ extern void quit(environment *env) { @@ -898,8 +832,6 @@ push_int(env, env->err); } -extern void sx_72656164(environment*); - int main(int argc, char **argv) { environment myenv;