30 |
/* A value of some type */ |
/* A value of some type */ |
31 |
typedef struct { |
typedef struct { |
32 |
enum { |
enum { |
33 |
|
empty, /* The empty list */ |
34 |
integer, |
integer, |
35 |
tfloat, |
tfloat, |
36 |
string, |
string, |
68 |
typedef struct cons_struct { /* A pair of two values */ |
typedef struct cons_struct { /* A pair of two values */ |
69 |
value *car; |
value *car; |
70 |
value *cdr; |
value *cdr; |
71 |
} cons; |
} pair; |
72 |
|
|
73 |
/* A symbol with a name and possible value */ |
/* A symbol with a name and possible value */ |
74 |
/* (These do not need reference counters, they are kept unique by |
/* (These do not need reference counters, they are kept unique by |
85 |
/* An environment; gives access to the stack and a hash table of |
/* An environment; gives access to the stack and a hash table of |
86 |
defined symbols */ |
defined symbols */ |
87 |
typedef struct { |
typedef struct { |
|
stackitem *gc_ref; |
|
|
int gc_limit, gc_count; |
|
|
|
|
88 |
value *head; /* Head of the stack */ |
value *head; /* Head of the stack */ |
89 |
hashtbl symbols; /* Hash table of all variable bindings */ |
hashtbl symbols; /* Hash table of all variable bindings */ |
90 |
int err; /* Error flag */ |
int err; /* Error flag */ |
93 |
read from in_string */ |
read from in_string */ |
94 |
FILE *inputstream; /* stdin or a file, most likely */ |
FILE *inputstream; /* stdin or a file, most likely */ |
95 |
int interactive; /* print prompts, stack, etc */ |
int interactive; /* print prompts, stack, etc */ |
96 |
|
|
97 |
|
/* Garbage Collector stuff*/ |
98 |
|
stackitem *gc_ref; /* Stack of all allocated values */ |
99 |
|
int gc_limit; /* Run GC when this much is allocated */ |
100 |
|
int gc_count; /* Amount currently allocated */ |
101 |
} environment; |
} environment; |
102 |
|
|
103 |
/* A type for pointers to external functions */ |
/* A type for pointers to external functions */ |
110 |
symbol **hash(hashtbl, const char*); |
symbol **hash(hashtbl, const char*); |
111 |
value* new_val(environment*); |
value* new_val(environment*); |
112 |
void gc_mark(value*); |
void gc_mark(value*); |
113 |
void gc_maybe(environment *env); |
void gc_maybe(environment*); |
114 |
extern void gc_init(environment*); |
extern void gc_init(environment*); |
115 |
|
void protect(value*); |
116 |
|
void unprotect(value*); |
117 |
void push_val(environment*, value*); |
void push_val(environment*, value*); |
118 |
void push_int(environment*, int); |
void push_int(environment*, int); |
119 |
void push_float(environment*, float); |
void push_float(environment*, float); |
123 |
void push_sym(environment*, const char*); |
void push_sym(environment*, const char*); |
124 |
extern void nl(); |
extern void nl(); |
125 |
extern void type(environment*); |
extern void type(environment*); |
126 |
void print_h(value*, int); |
void print_val(value*, int, stackitem*); |
127 |
extern void print_(environment*); |
extern void print_(environment*); |
128 |
extern void print(environment*); |
extern void print(environment*); |
129 |
extern void princ_(environment*); |
extern void princ_(environment*); |
150 |
extern void sx_2b(environment*); |
extern void sx_2b(environment*); |
151 |
extern void sx_2d(environment*); |
extern void sx_2d(environment*); |
152 |
extern void sx_3e(environment*); |
extern void sx_3e(environment*); |
153 |
|
extern void sx_3c(environment*); |
154 |
|
extern void sx_3c3d(environment*); |
155 |
|
extern void sx_3e3d(environment*); |
156 |
value *copy_val(environment*, value*); |
value *copy_val(environment*, value*); |
157 |
extern void sx_647570(environment*); |
extern void sx_647570(environment*); |
158 |
extern void sx_6966(environment*); |
extern void sx_6966(environment*); |
159 |
extern void ifelse(environment*); |
extern void ifelse(environment*); |
160 |
|
extern void sx_656c7365(environment*); |
161 |
|
extern void then(environment*); |
162 |
extern void sx_7768696c65(environment*); |
extern void sx_7768696c65(environment*); |
163 |
extern void sx_666f72(environment*); |
extern void sx_666f72(environment*); |
164 |
|
extern void foreach(environment*); |
165 |
extern void to(environment*); |
extern void to(environment*); |
166 |
extern void readline(environment*); |
extern void readline(environment*); |
167 |
extern void sx_72656164(environment*); |
extern void sx_72656164(environment*); |
168 |
extern void foreach(environment*); |
extern void beep(environment*); |
169 |
void protect(value*); |
extern void sx_77616974(environment*); |
|
void unprotect(value*); |
|
170 |
extern void copying(environment*); |
extern void copying(environment*); |
171 |
extern void warranty(environment*); |
extern void warranty(environment*); |
172 |
extern void sx_2a(environment*); |
extern void sx_2a(environment*); |
173 |
extern void sx_2f(environment*); |
extern void sx_2f(environment*); |
174 |
extern void mod(environment*); |
extern void mod(environment*); |
|
extern void sx_3c(environment*); |
|
|
extern void sx_3c3d(environment*); |
|
|
extern void sx_3e3d(environment*); |
|
175 |
extern void sx_646976(environment*); |
extern void sx_646976(environment*); |
176 |
extern void then(environment*); |
extern void setcar(environment*); |
177 |
|
extern void setcdr(environment*); |
178 |
|
extern void car(environment*); |
179 |
|
extern void cdr(environment*); |
180 |
|
extern void cons(environment*); |