--- stack/stack.h 2003/08/04 11:22:02 1.22 +++ stack/stack.h 2003/08/11 14:31:48 1.26 @@ -41,6 +41,10 @@ #include /* assert */ #include +/* waitpid */ +#include +/* va_list, va_start, va_arg, va_end */ +#include #ifdef __linux__ /* mtrace, muntrace */ @@ -57,19 +61,28 @@ struct cons_struct; struct symbol_struct; +struct environment_struct; + +/* A type for pointers to external functions */ +typedef void (*funcp)(struct environment_struct*); +/* funcp is a pointer to a void function (environment *) */ + +enum type_enum { + unknown, + empty, /* The empty list */ + integer, + tfloat, + string, + func, /* Function pointer */ + symb, /* Symbol */ + tcons, /* A pair of two values */ + port /* An I/O port */ +}; /* Type of stack element */ + /* A value of some type */ typedef struct { - enum { - empty, /* The empty list */ - integer, - tfloat, - string, - func, /* Function pointer */ - symb, /* Symbol */ - tcons, /* A pair of two values */ - port /* An I/O port */ - } type:4; /* Type of stack element */ + enum type_enum type:4; union { struct { @@ -86,6 +99,8 @@ FILE *p; /* ...or an I/O stream */ int i; /* ...or an integer */ float f; /* ...or a floating point number */ + funcp func; /* ...or a function pointer */ + char *string; /* ...or a string */ } content; /* Stores a pointer or an integer */ } value; @@ -121,6 +136,7 @@ value *head; /* Head of the stack */ hashtbl symbols; /* Hash table of all variable bindings */ int err; /* Error flag */ + char *errsymb; char *in_string; /* Input pending to be read */ char *free_string; /* Free this string when all input is read from in_string */ @@ -133,12 +149,9 @@ int gc_count; /* Amount currently allocated */ } environment; -/* A type for pointers to external functions */ -typedef void (*funcp)(environment*); /* funcp is a pointer to a void - function (environment *) */ void init_env(environment*); -void printerr(const char*); +void printerr(environment*, const char*); extern void toss(environment*); symbol **hash(hashtbl, const char*); value* new_val(environment*); @@ -225,3 +238,4 @@ extern void sx_646f(environment *); extern void sx_6f70656e(environment*); extern void sx_636c6f7365(environment*); +int check_args(environment*, ...);