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 |
|
|
45 |
|
#ifdef __linux__ |
46 |
|
/* mtrace, muntrace */ |
47 |
|
#include <mcheck.h> |
48 |
|
/* ioctl */ |
49 |
|
#include <sys/ioctl.h> |
50 |
|
/* KDMKTONE */ |
51 |
|
#include <linux/kd.h> |
52 |
|
#endif /* __linux__ */ |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
/* First, define some types. */ |
/* First, define some types. */ |
57 |
|
|
58 |
struct cons_struct; |
struct cons_struct; |
59 |
struct symbol_struct; |
struct symbol_struct; |
60 |
|
struct environment_struct; |
61 |
|
|
62 |
|
/* A type for pointers to external functions */ |
63 |
|
typedef void (*funcp)(struct environment_struct*); |
64 |
|
/* funcp is a pointer to a void function (environment *) */ |
65 |
|
|
66 |
/* A value of some type */ |
/* A value of some type */ |
67 |
typedef struct { |
typedef struct { |
72 |
string, |
string, |
73 |
func, /* Function pointer */ |
func, /* Function pointer */ |
74 |
symb, /* Symbol */ |
symb, /* Symbol */ |
75 |
tcons /* A pair of two values */ |
tcons, /* A pair of two values */ |
76 |
|
port /* An I/O port */ |
77 |
} type:4; /* Type of stack element */ |
} type:4; /* Type of stack element */ |
78 |
|
|
79 |
union { |
union { |
88 |
void *ptr; /* Pointer to the content */ |
void *ptr; /* Pointer to the content */ |
89 |
struct cons_struct *c; /* ...or a pointer to a cons cell */ |
struct cons_struct *c; /* ...or a pointer to a cons cell */ |
90 |
struct symbol_struct *sym; /* ...or a pointer to a symbol */ |
struct symbol_struct *sym; /* ...or a pointer to a symbol */ |
91 |
|
FILE *p; /* ...or an I/O stream */ |
92 |
int i; /* ...or an integer */ |
int i; /* ...or an integer */ |
93 |
float f; /* ...or a floating point number */ |
float f; /* ...or a floating point number */ |
94 |
|
funcp func; /* ...or a function pointer */ |
95 |
|
char *string; /* ...or a string */ |
96 |
} content; /* Stores a pointer or an integer */ |
} content; /* Stores a pointer or an integer */ |
97 |
|
|
98 |
} value; |
} value; |
140 |
int gc_count; /* Amount currently allocated */ |
int gc_count; /* Amount currently allocated */ |
141 |
} environment; |
} environment; |
142 |
|
|
|
/* A type for pointers to external functions */ |
|
|
typedef void (*funcp)(environment*); /* funcp is a pointer to a void |
|
|
function (environment *) */ |
|
143 |
|
|
144 |
void init_env(environment*); |
void init_env(environment*); |
145 |
void printerr(const char*); |
void printerr(const char*); |
158 |
char *mangle_str(const char*); |
char *mangle_str(const char*); |
159 |
extern void mangle(environment*); |
extern void mangle(environment*); |
160 |
void push_sym(environment*, const char*); |
void push_sym(environment*, const char*); |
161 |
extern void nl(); |
extern void nl(environment*); |
162 |
|
extern void nlport(environment*); |
163 |
extern void type(environment*); |
extern void type(environment*); |
164 |
void print_val(value*, int, stackitem*); |
void print_val(environment *, value*, int, stackitem*, FILE*); |
165 |
extern void print_(environment*); |
extern void print_(environment*); |
166 |
extern void print(environment*); |
extern void print(environment*); |
167 |
extern void princ_(environment*); |
extern void princ_(environment*); |
168 |
extern void princ(environment*); |
extern void princ(environment*); |
169 |
void print_st(value*, long); |
extern void printport_(environment*); |
170 |
|
extern void printport(environment*); |
171 |
|
extern void princport_(environment*); |
172 |
|
extern void princport(environment*); |
173 |
|
void print_st(environment*, value*, long); |
174 |
extern void printstack(environment*); |
extern void printstack(environment*); |
175 |
extern void swap(environment*); |
extern void swap(environment*); |
176 |
extern void rot(environment*); |
extern void rot(environment*); |
206 |
extern void foreach(environment*); |
extern void foreach(environment*); |
207 |
extern void to(environment*); |
extern void to(environment*); |
208 |
extern void readline(environment*); |
extern void readline(environment*); |
209 |
|
extern void readlineport(environment*); |
210 |
|
void readlinestream(environment*, FILE*); |
211 |
extern void sx_72656164(environment*); |
extern void sx_72656164(environment*); |
212 |
|
extern void readport(environment*); |
213 |
|
void readstream(environment*, FILE*); |
214 |
extern void beep(environment*); |
extern void beep(environment*); |
215 |
extern void sx_77616974(environment*); |
extern void sx_77616974(environment*); |
216 |
extern void copying(environment*); |
extern void copying(environment*); |
227 |
extern void assq(environment*); |
extern void assq(environment*); |
228 |
void assocgen(environment*, funcp); |
void assocgen(environment*, funcp); |
229 |
extern void sx_646f(environment *); |
extern void sx_646f(environment *); |
230 |
|
extern void sx_6f70656e(environment*); |
231 |
|
extern void sx_636c6f7365(environment*); |