| 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; |
| 67 |
string, |
string, |
| 68 |
func, /* Function pointer */ |
func, /* Function pointer */ |
| 69 |
symb, /* Symbol */ |
symb, /* Symbol */ |
| 70 |
tcons /* A pair of two values */ |
tcons, /* A pair of two values */ |
| 71 |
|
port /* An I/O port */ |
| 72 |
} type:4; /* Type of stack element */ |
} type:4; /* Type of stack element */ |
| 73 |
|
|
| 74 |
union { |
union { |
| 83 |
void *ptr; /* Pointer to the content */ |
void *ptr; /* Pointer to the content */ |
| 84 |
struct cons_struct *c; /* ...or a pointer to a cons cell */ |
struct cons_struct *c; /* ...or a pointer to a cons cell */ |
| 85 |
struct symbol_struct *sym; /* ...or a pointer to a symbol */ |
struct symbol_struct *sym; /* ...or a pointer to a symbol */ |
| 86 |
|
FILE *p; /* ...or an I/O stream */ |
| 87 |
int i; /* ...or an integer */ |
int i; /* ...or an integer */ |
| 88 |
float f; /* ...or a floating point number */ |
float f; /* ...or a floating point number */ |
| 89 |
} content; /* Stores a pointer or an integer */ |
} content; /* Stores a pointer or an integer */ |
| 101 |
typedef struct cons_struct { /* A pair of two values */ |
typedef struct cons_struct { /* A pair of two values */ |
| 102 |
value *car; |
value *car; |
| 103 |
value *cdr; |
value *cdr; |
| 104 |
} cons; |
} pair; |
| 105 |
|
|
| 106 |
/* A symbol with a name and possible value */ |
/* A symbol with a name and possible value */ |
| 107 |
/* (These do not need reference counters, they are kept unique by |
/* (These do not need reference counters, they are kept unique by |
| 143 |
symbol **hash(hashtbl, const char*); |
symbol **hash(hashtbl, const char*); |
| 144 |
value* new_val(environment*); |
value* new_val(environment*); |
| 145 |
void gc_mark(value*); |
void gc_mark(value*); |
| 146 |
void gc_maybe(environment *env); |
void gc_maybe(environment*); |
| 147 |
extern void gc_init(environment*); |
extern void gc_init(environment*); |
| 148 |
|
void protect(value*); |
| 149 |
|
void unprotect(value*); |
| 150 |
void push_val(environment*, value*); |
void push_val(environment*, value*); |
| 151 |
void push_int(environment*, int); |
void push_int(environment*, int); |
| 152 |
void push_float(environment*, float); |
void push_float(environment*, float); |
| 154 |
char *mangle_str(const char*); |
char *mangle_str(const char*); |
| 155 |
extern void mangle(environment*); |
extern void mangle(environment*); |
| 156 |
void push_sym(environment*, const char*); |
void push_sym(environment*, const char*); |
| 157 |
extern void nl(); |
extern void nl(environment*); |
| 158 |
|
extern void nlport(environment*); |
| 159 |
extern void type(environment*); |
extern void type(environment*); |
| 160 |
void print_h(value*, int); |
void print_val(environment *, value*, int, stackitem*, FILE*); |
| 161 |
extern void print_(environment*); |
extern void print_(environment*); |
| 162 |
extern void print(environment*); |
extern void print(environment*); |
| 163 |
extern void princ_(environment*); |
extern void princ_(environment*); |
| 164 |
extern void princ(environment*); |
extern void princ(environment*); |
| 165 |
void print_st(value*, long); |
extern void printport_(environment*); |
| 166 |
|
extern void printport(environment*); |
| 167 |
|
extern void princport_(environment*); |
| 168 |
|
extern void princport(environment*); |
| 169 |
|
void print_st(environment*, value*, long); |
| 170 |
extern void printstack(environment*); |
extern void printstack(environment*); |
| 171 |
extern void swap(environment*); |
extern void swap(environment*); |
| 172 |
extern void rot(environment*); |
extern void rot(environment*); |
| 188 |
extern void sx_2b(environment*); |
extern void sx_2b(environment*); |
| 189 |
extern void sx_2d(environment*); |
extern void sx_2d(environment*); |
| 190 |
extern void sx_3e(environment*); |
extern void sx_3e(environment*); |
| 191 |
|
extern void sx_3c(environment*); |
| 192 |
|
extern void sx_3c3d(environment*); |
| 193 |
|
extern void sx_3e3d(environment*); |
| 194 |
value *copy_val(environment*, value*); |
value *copy_val(environment*, value*); |
| 195 |
extern void sx_647570(environment*); |
extern void sx_647570(environment*); |
| 196 |
extern void sx_6966(environment*); |
extern void sx_6966(environment*); |
| 197 |
extern void ifelse(environment*); |
extern void ifelse(environment*); |
| 198 |
|
extern void sx_656c7365(environment*); |
| 199 |
|
extern void then(environment*); |
| 200 |
extern void sx_7768696c65(environment*); |
extern void sx_7768696c65(environment*); |
| 201 |
extern void sx_666f72(environment*); |
extern void sx_666f72(environment*); |
| 202 |
|
extern void foreach(environment*); |
| 203 |
extern void to(environment*); |
extern void to(environment*); |
| 204 |
extern void readline(environment*); |
extern void readline(environment*); |
| 205 |
|
extern void readlineport(environment*); |
| 206 |
|
void readlinestream(environment*, FILE*); |
| 207 |
extern void sx_72656164(environment*); |
extern void sx_72656164(environment*); |
| 208 |
extern void foreach(environment*); |
extern void readport(environment*); |
| 209 |
void protect(value*); |
void readstream(environment*, FILE*); |
| 210 |
void unprotect(value*); |
extern void beep(environment*); |
| 211 |
|
extern void sx_77616974(environment*); |
| 212 |
extern void copying(environment*); |
extern void copying(environment*); |
| 213 |
extern void warranty(environment*); |
extern void warranty(environment*); |
| 214 |
extern void sx_2a(environment*); |
extern void sx_2a(environment*); |
| 215 |
extern void sx_2f(environment*); |
extern void sx_2f(environment*); |
| 216 |
extern void mod(environment*); |
extern void mod(environment*); |
|
extern void sx_3c(environment*); |
|
|
extern void sx_3c3d(environment*); |
|
|
extern void sx_3e3d(environment*); |
|
| 217 |
extern void sx_646976(environment*); |
extern void sx_646976(environment*); |
| 218 |
extern void then(environment*); |
extern void setcar(environment*); |
| 219 |
|
extern void setcdr(environment*); |
| 220 |
|
extern void car(environment*); |
| 221 |
|
extern void cdr(environment*); |
| 222 |
|
extern void cons(environment*); |
| 223 |
|
extern void assq(environment*); |
| 224 |
|
void assocgen(environment*, funcp); |
| 225 |
|
extern void sx_646f(environment *); |
| 226 |
|
extern void sx_6f70656e(environment*); |
| 227 |
|
extern void sx_636c6f7365(environment*); |