22 |
|
|
23 |
#define HASHTBLSIZE 2048 |
#define HASHTBLSIZE 2048 |
24 |
|
|
25 |
|
#define CAR(X) ((X)->content.c->car) |
26 |
|
#define CDR(X) ((X)->content.c->cdr) |
27 |
|
|
28 |
|
/* printf, sscanf, fgets, fprintf, fopen, perror */ |
29 |
|
#include <stdio.h> |
30 |
|
/* exit, EXIT_SUCCESS, malloc, free */ |
31 |
|
#include <stdlib.h> |
32 |
|
/* NULL */ |
33 |
|
#include <stddef.h> |
34 |
|
/* dlopen, dlsym, dlerror */ |
35 |
|
#include <dlfcn.h> |
36 |
|
/* strcmp, strcpy, strlen, strcat, strdup */ |
37 |
|
#include <string.h> |
38 |
|
/* getopt, STDIN_FILENO, STDOUT_FILENO, usleep */ |
39 |
|
#include <unistd.h> |
40 |
|
/* EX_NOINPUT, EX_USAGE */ |
41 |
|
#include <sysexits.h> |
42 |
|
/* assert */ |
43 |
|
#include <assert.h> |
44 |
|
/* waitpid */ |
45 |
|
#include <sys/wait.h> |
46 |
|
|
47 |
|
#ifdef __linux__ |
48 |
|
/* mtrace, muntrace */ |
49 |
|
#include <mcheck.h> |
50 |
|
/* ioctl */ |
51 |
|
#include <sys/ioctl.h> |
52 |
|
/* KDMKTONE */ |
53 |
|
#include <linux/kd.h> |
54 |
|
#endif /* __linux__ */ |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
/* First, define some types. */ |
/* First, define some types. */ |
59 |
|
|
60 |
struct cons_struct; |
struct cons_struct; |
61 |
struct symbol_struct; |
struct symbol_struct; |
62 |
|
struct environment_struct; |
63 |
|
|
64 |
|
/* A type for pointers to external functions */ |
65 |
|
typedef void (*funcp)(struct environment_struct*); |
66 |
|
/* funcp is a pointer to a void function (environment *) */ |
67 |
|
|
68 |
/* A value of some type */ |
/* A value of some type */ |
69 |
typedef struct { |
typedef struct { |
74 |
string, |
string, |
75 |
func, /* Function pointer */ |
func, /* Function pointer */ |
76 |
symb, /* Symbol */ |
symb, /* Symbol */ |
77 |
tcons /* A pair of two values */ |
tcons, /* A pair of two values */ |
78 |
|
port /* An I/O port */ |
79 |
} type:4; /* Type of stack element */ |
} type:4; /* Type of stack element */ |
80 |
|
|
81 |
union { |
union { |
90 |
void *ptr; /* Pointer to the content */ |
void *ptr; /* Pointer to the content */ |
91 |
struct cons_struct *c; /* ...or a pointer to a cons cell */ |
struct cons_struct *c; /* ...or a pointer to a cons cell */ |
92 |
struct symbol_struct *sym; /* ...or a pointer to a symbol */ |
struct symbol_struct *sym; /* ...or a pointer to a symbol */ |
93 |
|
FILE *p; /* ...or an I/O stream */ |
94 |
int i; /* ...or an integer */ |
int i; /* ...or an integer */ |
95 |
float f; /* ...or a floating point number */ |
float f; /* ...or a floating point number */ |
96 |
|
funcp func; /* ...or a function pointer */ |
97 |
|
char *string; /* ...or a string */ |
98 |
} content; /* Stores a pointer or an integer */ |
} content; /* Stores a pointer or an integer */ |
99 |
|
|
100 |
} value; |
} value; |
142 |
int gc_count; /* Amount currently allocated */ |
int gc_count; /* Amount currently allocated */ |
143 |
} environment; |
} environment; |
144 |
|
|
|
/* A type for pointers to external functions */ |
|
|
typedef void (*funcp)(environment*); /* funcp is a pointer to a void |
|
|
function (environment *) */ |
|
145 |
|
|
146 |
void init_env(environment*); |
void init_env(environment*); |
147 |
void printerr(const char*); |
void printerr(const char*); |
160 |
char *mangle_str(const char*); |
char *mangle_str(const char*); |
161 |
extern void mangle(environment*); |
extern void mangle(environment*); |
162 |
void push_sym(environment*, const char*); |
void push_sym(environment*, const char*); |
163 |
extern void nl(); |
extern void nl(environment*); |
164 |
|
extern void nlport(environment*); |
165 |
extern void type(environment*); |
extern void type(environment*); |
166 |
void print_val(value*, int, stackitem*); |
void print_val(environment *, value*, int, stackitem*, FILE*); |
167 |
extern void print_(environment*); |
extern void print_(environment*); |
168 |
extern void print(environment*); |
extern void print(environment*); |
169 |
extern void princ_(environment*); |
extern void princ_(environment*); |
170 |
extern void princ(environment*); |
extern void princ(environment*); |
171 |
void print_st(value*, long); |
extern void printport_(environment*); |
172 |
|
extern void printport(environment*); |
173 |
|
extern void princport_(environment*); |
174 |
|
extern void princport(environment*); |
175 |
|
void print_st(environment*, value*, long); |
176 |
extern void printstack(environment*); |
extern void printstack(environment*); |
177 |
extern void swap(environment*); |
extern void swap(environment*); |
178 |
extern void rot(environment*); |
extern void rot(environment*); |
208 |
extern void foreach(environment*); |
extern void foreach(environment*); |
209 |
extern void to(environment*); |
extern void to(environment*); |
210 |
extern void readline(environment*); |
extern void readline(environment*); |
211 |
|
extern void readlineport(environment*); |
212 |
|
void readlinestream(environment*, FILE*); |
213 |
extern void sx_72656164(environment*); |
extern void sx_72656164(environment*); |
214 |
|
extern void readport(environment*); |
215 |
|
void readstream(environment*, FILE*); |
216 |
extern void beep(environment*); |
extern void beep(environment*); |
217 |
extern void sx_77616974(environment*); |
extern void sx_77616974(environment*); |
218 |
extern void copying(environment*); |
extern void copying(environment*); |
229 |
extern void assq(environment*); |
extern void assq(environment*); |
230 |
void assocgen(environment*, funcp); |
void assocgen(environment*, funcp); |
231 |
extern void sx_646f(environment *); |
extern void sx_646f(environment *); |
232 |
|
extern void sx_6f70656e(environment*); |
233 |
|
extern void sx_636c6f7365(environment*); |