41 |
#include <sysexits.h> |
#include <sysexits.h> |
42 |
/* assert */ |
/* assert */ |
43 |
#include <assert.h> |
#include <assert.h> |
44 |
|
/* waitpid */ |
45 |
|
#include <sys/wait.h> |
46 |
|
/* va_list, va_start, va_arg, va_end */ |
47 |
|
#include <stdarg.h> |
48 |
|
/* time */ |
49 |
|
#include <time.h> |
50 |
|
|
51 |
#ifdef __linux__ |
#ifdef __linux__ |
52 |
/* mtrace, muntrace */ |
/* mtrace, muntrace */ |
69 |
typedef void (*funcp)(struct environment_struct*); |
typedef void (*funcp)(struct environment_struct*); |
70 |
/* funcp is a pointer to a void function (environment *) */ |
/* funcp is a pointer to a void function (environment *) */ |
71 |
|
|
72 |
|
enum type_enum { |
73 |
|
unknown, |
74 |
|
empty, /* The empty list */ |
75 |
|
integer, |
76 |
|
tfloat, |
77 |
|
string, |
78 |
|
func, /* Function pointer */ |
79 |
|
symb, /* Symbol */ |
80 |
|
tcons, /* A pair of two values */ |
81 |
|
port /* An I/O port */ |
82 |
|
}; /* Type of stack element */ |
83 |
|
|
84 |
|
|
85 |
/* A value of some type */ |
/* A value of some type */ |
86 |
typedef struct { |
typedef struct { |
87 |
enum { |
enum type_enum type:4; |
|
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 */ |
|
88 |
|
|
89 |
union { |
union { |
90 |
struct { |
struct { |
101 |
FILE *p; /* ...or an I/O stream */ |
FILE *p; /* ...or an I/O stream */ |
102 |
int i; /* ...or an integer */ |
int i; /* ...or an integer */ |
103 |
float f; /* ...or a floating point number */ |
float f; /* ...or a floating point number */ |
104 |
funcp func; /* ...or a function */ |
funcp func; /* ...or a function pointer */ |
105 |
char *string; /* ...or a string */ |
char *string; /* ...or a string */ |
106 |
} content; /* Stores a pointer or an integer */ |
} content; /* Stores a pointer or an integer */ |
107 |
|
|
138 |
value *head; /* Head of the stack */ |
value *head; /* Head of the stack */ |
139 |
hashtbl symbols; /* Hash table of all variable bindings */ |
hashtbl symbols; /* Hash table of all variable bindings */ |
140 |
int err; /* Error flag */ |
int err; /* Error flag */ |
141 |
|
char *errsymb; |
142 |
char *in_string; /* Input pending to be read */ |
char *in_string; /* Input pending to be read */ |
143 |
char *free_string; /* Free this string when all input is |
char *free_string; /* Free this string when all input is |
144 |
read from in_string */ |
read from in_string */ |
153 |
|
|
154 |
|
|
155 |
void init_env(environment*); |
void init_env(environment*); |
156 |
void printerr(const char*); |
void printerr(environment*); |
157 |
extern void toss(environment*); |
extern void toss(environment*); |
158 |
symbol **hash(hashtbl, const char*); |
symbol **hash(hashtbl, const char*); |
159 |
value* new_val(environment*); |
value* new_val(environment*); |
240 |
extern void sx_646f(environment *); |
extern void sx_646f(environment *); |
241 |
extern void sx_6f70656e(environment*); |
extern void sx_6f70656e(environment*); |
242 |
extern void sx_636c6f7365(environment*); |
extern void sx_636c6f7365(environment*); |
243 |
|
int check_args(environment*, int, ...); |