| 48 |
{ |
{ |
| 49 |
int i; |
int i; |
| 50 |
|
|
| 51 |
env->gc_limit= 20; |
env->gc_limit= 200; |
| 52 |
env->gc_count= 0; |
env->gc_count= 0; |
| 53 |
env->gc_ref= NULL; |
env->gc_ref= NULL; |
| 54 |
env->gc_protect= NULL; |
env->gc_protect= NULL; |
| 63 |
env->interactive= 1; |
env->interactive= 1; |
| 64 |
} |
} |
| 65 |
|
|
| 66 |
void printerr(const char* in_string) { |
void printerr(const char* in_string) |
| 67 |
|
{ |
| 68 |
fprintf(stderr, "Err: %s\n", in_string); |
fprintf(stderr, "Err: %s\n", in_string); |
| 69 |
} |
} |
| 70 |
|
|
| 82 |
env->head= env->head->next; /* Remove the top stack item */ |
env->head= env->head->next; /* Remove the top stack item */ |
| 83 |
free(temp); /* Free the old top stack item */ |
free(temp); /* Free the old top stack item */ |
| 84 |
|
|
| 85 |
gc_init(env); |
env->gc_limit--; |
| 86 |
} |
} |
| 87 |
|
|
| 88 |
/* Returns a pointer to a pointer to an element in the hash table. */ |
/* Returns a pointer to a pointer to an element in the hash table. */ |
| 114 |
} |
} |
| 115 |
} |
} |
| 116 |
|
|
| 117 |
value* new_val(environment *env) { |
/* Create new value */ |
| 118 |
|
value* new_val(environment *env) |
| 119 |
|
{ |
| 120 |
value *nval= malloc(sizeof(value)); |
value *nval= malloc(sizeof(value)); |
| 121 |
stackitem *nitem= malloc(sizeof(stackitem)); |
stackitem *nitem= malloc(sizeof(stackitem)); |
| 122 |
|
|
| 127 |
env->gc_ref= nitem; |
env->gc_ref= nitem; |
| 128 |
|
|
| 129 |
env->gc_count++; |
env->gc_count++; |
| 130 |
|
nval->gc_garb= 1; |
|
protect(env, nval); |
|
|
gc_init(env); |
|
|
unprotect(env); |
|
| 131 |
|
|
| 132 |
return nval; |
return nval; |
| 133 |
} |
} |
| 134 |
|
|
| 135 |
void gc_mark(value *val) { |
/* Mark values recursively. |
| 136 |
|
Marked values are not collected by the GC. */ |
| 137 |
|
inline void gc_mark(value *val) |
| 138 |
|
{ |
| 139 |
stackitem *iterator; |
stackitem *iterator; |
| 140 |
|
|
| 141 |
if(val==NULL || val->gc_garb==0) |
if(val->gc_garb==0) |
| 142 |
return; |
return; |
| 143 |
|
|
| 144 |
val->gc_garb= 0; |
val->gc_garb= 0; |
| 153 |
} |
} |
| 154 |
} |
} |
| 155 |
|
|
| 156 |
extern void gc_init(environment *env) { |
inline void gc_maybe(environment *env) |
| 157 |
stackitem *new_head= NULL, *titem, *iterator; |
{ |
|
symbol *tsymb; |
|
|
int i; |
|
|
|
|
| 158 |
if(env->gc_count < env->gc_limit) |
if(env->gc_count < env->gc_limit) |
| 159 |
return; |
return; |
| 160 |
|
else |
| 161 |
|
return gc_init(env); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
/* Garb by default */ |
/* Start GC */ |
| 165 |
iterator= env->gc_ref; |
extern void gc_init(environment *env) |
| 166 |
while(iterator!=NULL) { |
{ |
| 167 |
iterator->item->gc_garb= 1; |
stackitem *new_head= NULL, *titem, *iterator; |
| 168 |
iterator= iterator->next; |
symbol *tsymb; |
| 169 |
} |
int i; |
| 170 |
|
|
| 171 |
/* Mark protected values */ |
/* Mark protected values */ |
| 172 |
iterator= env->gc_protect; |
iterator= env->gc_protect; |
| 175 |
iterator= iterator->next; |
iterator= iterator->next; |
| 176 |
} |
} |
| 177 |
|
|
| 178 |
/* Mark values in stack */ |
/* Mark values on stack */ |
| 179 |
iterator= env->head; |
iterator= env->head; |
| 180 |
while(iterator!=NULL) { |
while(iterator!=NULL) { |
| 181 |
gc_mark(iterator->item); |
gc_mark(iterator->item); |
| 186 |
for(i= 0; i<HASHTBLSIZE; i++) { |
for(i= 0; i<HASHTBLSIZE; i++) { |
| 187 |
tsymb= env->symbols[i]; |
tsymb= env->symbols[i]; |
| 188 |
while(tsymb!=NULL) { |
while(tsymb!=NULL) { |
| 189 |
gc_mark(tsymb->val); |
if (tsymb->val != NULL) |
| 190 |
|
gc_mark(tsymb->val); |
| 191 |
tsymb= tsymb->next; |
tsymb= tsymb->next; |
| 192 |
} |
} |
| 193 |
} |
} |
| 194 |
|
|
| 195 |
env->gc_count= 0; |
env->gc_count= 0; |
| 196 |
|
|
| 197 |
/* Sweep */ |
while(env->gc_ref!=NULL) { /* Sweep unused values */ |
|
while(env->gc_ref!=NULL) { |
|
| 198 |
|
|
| 199 |
if(env->gc_ref->item->gc_garb) { |
if(env->gc_ref->item->gc_garb) { |
| 200 |
|
|
| 201 |
/* Remove content */ |
switch(env->gc_ref->item->type) { /* Remove content */ |
|
switch(env->gc_ref->item->type) { |
|
| 202 |
case string: |
case string: |
| 203 |
free(env->gc_ref->item->content.ptr); |
free(env->gc_ref->item->content.ptr); |
| 204 |
break; |
break; |
| 208 |
env->gc_ref->item->content.ptr= titem->next; |
env->gc_ref->item->content.ptr= titem->next; |
| 209 |
free(titem); |
free(titem); |
| 210 |
} |
} |
|
break; |
|
| 211 |
default: |
default: |
|
break; |
|
| 212 |
} |
} |
| 213 |
free(env->gc_ref->item); /* Remove from gc_ref */ |
free(env->gc_ref->item); /* Remove from gc_ref */ |
| 214 |
titem= env->gc_ref->next; |
titem= env->gc_ref->next; |
| 215 |
free(env->gc_ref); /* Remove value */ |
free(env->gc_ref); /* Remove value */ |
| 216 |
env->gc_ref= titem; |
env->gc_ref= titem; |
| 217 |
} else { /* Save */ |
continue; |
|
titem= env->gc_ref->next; |
|
|
env->gc_ref->next= new_head; |
|
|
new_head= env->gc_ref; |
|
|
env->gc_ref= titem; |
|
|
env->gc_count++; |
|
| 218 |
} |
} |
| 219 |
|
|
| 220 |
|
/* Keep values */ |
| 221 |
|
titem= env->gc_ref->next; |
| 222 |
|
env->gc_ref->next= new_head; |
| 223 |
|
new_head= env->gc_ref; |
| 224 |
|
new_head->item->gc_garb= 1; |
| 225 |
|
env->gc_ref= titem; |
| 226 |
|
env->gc_count++; |
| 227 |
} |
} |
| 228 |
|
|
| 229 |
env->gc_limit= env->gc_count*2; |
env->gc_limit= env->gc_count*2; |
| 230 |
env->gc_ref= new_head; |
env->gc_ref= new_head; |
| 231 |
} |
} |
| 232 |
|
|
| 233 |
|
/* Protect values from GC */ |
| 234 |
void protect(environment *env, value *val) |
void protect(environment *env, value *val) |
| 235 |
{ |
{ |
| 236 |
stackitem *new_item= malloc(sizeof(stackitem)); |
stackitem *new_item= malloc(sizeof(stackitem)); |
| 239 |
env->gc_protect= new_item; |
env->gc_protect= new_item; |
| 240 |
} |
} |
| 241 |
|
|
| 242 |
|
/* Unprotect values from GC */ |
| 243 |
void unprotect(environment *env) |
void unprotect(environment *env) |
| 244 |
{ |
{ |
| 245 |
stackitem *temp= env->gc_protect; |
stackitem *temp= env->gc_protect; |
| 256 |
env->head= new_item; |
env->head= new_item; |
| 257 |
} |
} |
| 258 |
|
|
| 259 |
/* Push an integer onto the stack. */ |
/* Push an integer onto the stack */ |
| 260 |
void push_int(environment *env, int in_val) |
void push_int(environment *env, int in_val) |
| 261 |
{ |
{ |
| 262 |
value *new_value= new_val(env); |
value *new_value= new_val(env); |
| 267 |
push_val(env, new_value); |
push_val(env, new_value); |
| 268 |
} |
} |
| 269 |
|
|
| 270 |
|
/* Push a floating point number onto the stack */ |
| 271 |
void push_float(environment *env, float in_val) |
void push_float(environment *env, float in_val) |
| 272 |
{ |
{ |
| 273 |
value *new_value= new_val(env); |
value *new_value= new_val(env); |
| 291 |
} |
} |
| 292 |
|
|
| 293 |
/* Mangle a symbol name to a valid C identifier name */ |
/* Mangle a symbol name to a valid C identifier name */ |
| 294 |
char *mangle_str(const char *old_string){ |
char *mangle_str(const char *old_string) |
| 295 |
|
{ |
| 296 |
char validchars[]= "0123456789abcdef"; |
char validchars[]= "0123456789abcdef"; |
| 297 |
char *new_string, *current; |
char *new_string, *current; |
| 298 |
|
|
| 310 |
return new_string; /* The caller must free() it */ |
return new_string; /* The caller must free() it */ |
| 311 |
} |
} |
| 312 |
|
|
| 313 |
extern void mangle(environment *env){ |
extern void mangle(environment *env) |
| 314 |
|
{ |
| 315 |
char *new_string; |
char *new_string; |
| 316 |
|
|
| 317 |
if((env->head)==NULL) { |
if((env->head)==NULL) { |
| 380 |
|
|
| 381 |
mangled= mangle_str(in_string); /* mangle the name */ |
mangled= mangle_str(in_string); /* mangle the name */ |
| 382 |
funcptr= dlsym(handle, mangled); /* and try to find it */ |
funcptr= dlsym(handle, mangled); /* and try to find it */ |
| 383 |
free(mangled); |
|
| 384 |
dlerr= dlerror(); |
dlerr= dlerror(); |
| 385 |
if(dlerr != NULL) { /* If no function was found */ |
if(dlerr != NULL) { /* If no function was found */ |
| 386 |
funcptr= dlsym(handle, in_string); /* Get function pointer */ |
funcptr= dlsym(handle, in_string); /* Get function pointer */ |
| 387 |
dlerr= dlerror(); |
dlerr= dlerror(); |
| 388 |
} |
} |
| 389 |
|
|
| 390 |
if(dlerr==NULL) { /* If a function was found */ |
if(dlerr==NULL) { /* If a function was found */ |
| 391 |
new_fvalue->type= func; /* The new value is a function pointer */ |
new_fvalue->type= func; /* The new value is a function pointer */ |
| 392 |
new_fvalue->content.ptr= funcptr; /* Store function pointer */ |
new_fvalue->content.ptr= funcptr; /* Store function pointer */ |
| 393 |
(*new_symbol)->val= new_fvalue; /* Bind the symbol to the new |
(*new_symbol)->val= new_fvalue; /* Bind the symbol to the new |
| 394 |
function value */ |
function value */ |
| 395 |
} |
} |
| 396 |
|
|
| 397 |
|
free(mangled); |
| 398 |
} |
} |
| 399 |
|
|
| 400 |
push_val(env, new_value); |
push_val(env, new_value); |
| 401 |
unprotect(env); unprotect(env); |
unprotect(env); unprotect(env); |
| 402 |
} |
} |
| 408 |
} |
} |
| 409 |
|
|
| 410 |
/* Gets the type of a value */ |
/* Gets the type of a value */ |
| 411 |
extern void type(environment *env){ |
extern void type(environment *env) |
| 412 |
|
{ |
| 413 |
int typenum; |
int typenum; |
| 414 |
|
|
| 415 |
if((env->head)==NULL) { |
if((env->head)==NULL) { |
| 477 |
} |
} |
| 478 |
} |
} |
| 479 |
|
|
| 480 |
extern void print_(environment *env) { |
extern void print_(environment *env) |
| 481 |
|
{ |
| 482 |
if(env->head==NULL) { |
if(env->head==NULL) { |
| 483 |
printerr("Too Few Arguments"); |
printerr("Too Few Arguments"); |
| 484 |
env->err=1; |
env->err=1; |
| 496 |
toss(env); |
toss(env); |
| 497 |
} |
} |
| 498 |
|
|
| 499 |
extern void princ_(environment *env) { |
extern void princ_(environment *env) |
| 500 |
|
{ |
| 501 |
if(env->head==NULL) { |
if(env->head==NULL) { |
| 502 |
printerr("Too Few Arguments"); |
printerr("Too Few Arguments"); |
| 503 |
env->err=1; |
env->err=1; |
| 531 |
printf("Stack Empty\n"); |
printf("Stack Empty\n"); |
| 532 |
return; |
return; |
| 533 |
} |
} |
| 534 |
|
|
| 535 |
print_st(env->head, 1); |
print_st(env->head, 1); |
| 536 |
} |
} |
| 537 |
|
|
| 609 |
|
|
| 610 |
eval_start: |
eval_start: |
| 611 |
|
|
| 612 |
|
gc_maybe(env); |
| 613 |
|
|
| 614 |
if(env->head==NULL) { |
if(env->head==NULL) { |
| 615 |
printerr("Too Few Arguments"); |
printerr("Too Few Arguments"); |
| 616 |
env->err=1; |
env->err=1; |
| 667 |
} |
} |
| 668 |
|
|
| 669 |
/* Reverse (flip) a list */ |
/* Reverse (flip) a list */ |
| 670 |
extern void rev(environment *env){ |
extern void rev(environment *env) |
| 671 |
|
{ |
| 672 |
stackitem *old_head, *new_head, *item; |
stackitem *old_head, *new_head, *item; |
| 673 |
|
|
| 674 |
if((env->head)==NULL) { |
if((env->head)==NULL) { |
| 854 |
/* Quit stack. */ |
/* Quit stack. */ |
| 855 |
extern void quit(environment *env) |
extern void quit(environment *env) |
| 856 |
{ |
{ |
| 857 |
long i; |
int i; |
| 858 |
|
|
| 859 |
clear(env); |
clear(env); |
| 860 |
|
|
| 867 |
} |
} |
| 868 |
|
|
| 869 |
env->gc_limit= 0; |
env->gc_limit= 0; |
| 870 |
gc_init(env); |
gc_maybe(env); |
| 871 |
|
|
| 872 |
if(env->free_string!=NULL) |
if(env->free_string!=NULL) |
| 873 |
free(env->free_string); |
free(env->free_string); |
| 900 |
} |
} |
| 901 |
|
|
| 902 |
/* Internal forget function */ |
/* Internal forget function */ |
| 903 |
void forget_sym(symbol **hash_entry) { |
void forget_sym(symbol **hash_entry) |
| 904 |
|
{ |
| 905 |
symbol *temp; |
symbol *temp; |
| 906 |
|
|
| 907 |
temp= *hash_entry; |
temp= *hash_entry; |
| 936 |
} |
} |
| 937 |
|
|
| 938 |
/* Returns the current error number to the stack */ |
/* Returns the current error number to the stack */ |
| 939 |
extern void errn(environment *env){ |
extern void errn(environment *env) |
| 940 |
|
{ |
| 941 |
push_int(env, env->err); |
push_int(env, env->err); |
| 942 |
} |
} |
| 943 |
|
|
| 1006 |
toss(&myenv); /* No error check in main */ |
toss(&myenv); /* No error check in main */ |
| 1007 |
eval(&myenv); |
eval(&myenv); |
| 1008 |
} |
} |
| 1009 |
gc_init(&myenv); |
gc_maybe(&myenv); |
| 1010 |
} |
} |
| 1011 |
quit(&myenv); |
quit(&myenv); |
| 1012 |
return EXIT_FAILURE; |
return EXIT_FAILURE; |
| 1013 |
} |
} |
| 1014 |
|
|
| 1015 |
/* "+" */ |
/* "+" */ |
| 1016 |
extern void sx_2b(environment *env) { |
extern void sx_2b(environment *env) |
| 1017 |
|
{ |
| 1018 |
int a, b; |
int a, b; |
| 1019 |
float fa, fb; |
float fa, fb; |
| 1020 |
size_t len; |
size_t len; |
| 1094 |
} |
} |
| 1095 |
|
|
| 1096 |
/* "-" */ |
/* "-" */ |
| 1097 |
extern void sx_2d(environment *env) { |
extern void sx_2d(environment *env) |
| 1098 |
|
{ |
| 1099 |
int a, b; |
int a, b; |
| 1100 |
float fa, fb; |
float fa, fb; |
| 1101 |
|
|
| 1154 |
} |
} |
| 1155 |
|
|
| 1156 |
/* ">" */ |
/* ">" */ |
| 1157 |
extern void sx_3e(environment *env) { |
extern void sx_3e(environment *env) |
| 1158 |
|
{ |
| 1159 |
int a, b; |
int a, b; |
| 1160 |
float fa, fb; |
float fa, fb; |
| 1161 |
|
|
| 1214 |
} |
} |
| 1215 |
|
|
| 1216 |
/* "<" */ |
/* "<" */ |
| 1217 |
extern void sx_3c(environment *env) { |
extern void sx_3c(environment *env) |
| 1218 |
|
{ |
| 1219 |
swap(env); if(env->err) return; |
swap(env); if(env->err) return; |
| 1220 |
sx_3e(env); |
sx_3e(env); |
| 1221 |
} |
} |
| 1222 |
|
|
| 1223 |
/* "<=" */ |
/* "<=" */ |
| 1224 |
extern void sx_3c3d(environment *env) { |
extern void sx_3c3d(environment *env) |
| 1225 |
|
{ |
| 1226 |
sx_3e(env); if(env->err) return; |
sx_3e(env); if(env->err) return; |
| 1227 |
not(env); |
not(env); |
| 1228 |
} |
} |
| 1229 |
|
|
| 1230 |
/* ">=" */ |
/* ">=" */ |
| 1231 |
extern void sx_3e3d(environment *env) { |
extern void sx_3e3d(environment *env) |
| 1232 |
|
{ |
| 1233 |
sx_3c(env); if(env->err) return; |
sx_3c(env); if(env->err) return; |
| 1234 |
not(env); |
not(env); |
| 1235 |
} |
} |
| 1236 |
|
|
| 1237 |
/* Return copy of a value */ |
/* Return copy of a value */ |
| 1238 |
value *copy_val(environment *env, value *old_value){ |
value *copy_val(environment *env, value *old_value) |
| 1239 |
|
{ |
| 1240 |
stackitem *old_item, *new_item, *prev_item; |
stackitem *old_item, *new_item, *prev_item; |
| 1241 |
value *new_value; |
value *new_value; |
| 1242 |
|
|
| 1283 |
} |
} |
| 1284 |
|
|
| 1285 |
/* "dup"; duplicates an item on the stack */ |
/* "dup"; duplicates an item on the stack */ |
| 1286 |
extern void sx_647570(environment *env) { |
extern void sx_647570(environment *env) |
| 1287 |
|
{ |
| 1288 |
if((env->head)==NULL) { |
if((env->head)==NULL) { |
| 1289 |
printerr("Too Few Arguments"); |
printerr("Too Few Arguments"); |
| 1290 |
env->err= 1; |
env->err= 1; |
| 1294 |
} |
} |
| 1295 |
|
|
| 1296 |
/* "if", If-Then */ |
/* "if", If-Then */ |
| 1297 |
extern void sx_6966(environment *env) { |
extern void sx_6966(environment *env) |
| 1298 |
|
{ |
| 1299 |
int truth; |
int truth; |
| 1300 |
|
|
| 1301 |
if((env->head)==NULL || env->head->next==NULL) { |
if((env->head)==NULL || env->head->next==NULL) { |
| 1325 |
} |
} |
| 1326 |
|
|
| 1327 |
/* If-Then-Else */ |
/* If-Then-Else */ |
| 1328 |
extern void ifelse(environment *env) { |
extern void ifelse(environment *env) |
| 1329 |
|
{ |
| 1330 |
int truth; |
int truth; |
| 1331 |
|
|
| 1332 |
if((env->head)==NULL || env->head->next==NULL |
if((env->head)==NULL || env->head->next==NULL |
| 1361 |
} |
} |
| 1362 |
|
|
| 1363 |
/* "while" */ |
/* "while" */ |
| 1364 |
extern void sx_7768696c65(environment *env) { |
extern void sx_7768696c65(environment *env) |
| 1365 |
|
{ |
| 1366 |
int truth; |
int truth; |
| 1367 |
value *loop, *test; |
value *loop, *test; |
| 1368 |
|
|
| 1407 |
|
|
| 1408 |
|
|
| 1409 |
/* "for"; for-loop */ |
/* "for"; for-loop */ |
| 1410 |
extern void sx_666f72(environment *env) { |
extern void sx_666f72(environment *env) |
| 1411 |
|
{ |
| 1412 |
value *loop; |
value *loop; |
| 1413 |
int foo1, foo2; |
int foo1, foo2; |
| 1414 |
|
|
| 1455 |
} |
} |
| 1456 |
|
|
| 1457 |
/* Variant of for-loop */ |
/* Variant of for-loop */ |
| 1458 |
extern void foreach(environment *env) { |
extern void foreach(environment *env) |
| 1459 |
|
{ |
| 1460 |
value *loop, *foo; |
value *loop, *foo; |
| 1461 |
stackitem *iterator; |
stackitem *iterator; |
| 1462 |
|
|
| 1492 |
} |
} |
| 1493 |
|
|
| 1494 |
/* "to" */ |
/* "to" */ |
| 1495 |
extern void to(environment *env) { |
extern void to(environment *env) |
| 1496 |
int i, start, ending; |
{ |
| 1497 |
stackitem *temp_head; |
int ending, start, i; |
| 1498 |
value *temp_val; |
stackitem *iterator, *temp; |
| 1499 |
|
value *pack; |
| 1500 |
|
|
| 1501 |
if((env->head)==NULL || env->head->next==NULL) { |
if((env->head)==NULL || env->head->next==NULL) { |
| 1502 |
printerr("Too Few Arguments"); |
printerr("Too Few Arguments"); |
| 1503 |
env->err=1; |
env->err=1; |
| 1516 |
start= env->head->item->content.i; |
start= env->head->item->content.i; |
| 1517 |
toss(env); if(env->err) return; |
toss(env); if(env->err) return; |
| 1518 |
|
|
| 1519 |
temp_head= env->head; |
push_sym(env, "["); |
|
env->head= NULL; |
|
| 1520 |
|
|
| 1521 |
if(ending>=start) { |
if(ending>=start) { |
| 1522 |
for(i= ending; i>=start; i--) |
for(i= ending; i>=start; i--) |
| 1526 |
push_int(env, i); |
push_int(env, i); |
| 1527 |
} |
} |
| 1528 |
|
|
| 1529 |
temp_val= new_val(env); |
iterator= env->head; |
| 1530 |
protect(env, temp_val); |
pack= new_val(env); |
| 1531 |
|
protect(env, pack); |
| 1532 |
|
|
| 1533 |
temp_val->content.ptr= env->head; |
if(iterator==NULL |
| 1534 |
temp_val->type= list; |
|| (iterator->item->type==symb |
| 1535 |
env->head= temp_head; |
&& ((symbol*)(iterator->item->content.ptr))->id[0]=='[')) { |
| 1536 |
push_val(env, temp_val); |
temp= NULL; |
| 1537 |
|
toss(env); |
| 1538 |
|
} else { |
| 1539 |
|
/* Search for first delimiter */ |
| 1540 |
|
while(iterator->next!=NULL |
| 1541 |
|
&& (iterator->next->item->type!=symb |
| 1542 |
|
|| ((symbol*)(iterator->next->item->content.ptr))->id[0]!='[')) |
| 1543 |
|
iterator= iterator->next; |
| 1544 |
|
|
| 1545 |
|
/* Extract list */ |
| 1546 |
|
temp= env->head; |
| 1547 |
|
env->head= iterator->next; |
| 1548 |
|
iterator->next= NULL; |
| 1549 |
|
|
| 1550 |
|
pack->type= list; |
| 1551 |
|
pack->content.ptr= temp; |
| 1552 |
|
|
| 1553 |
|
if(env->head!=NULL) |
| 1554 |
|
toss(env); |
| 1555 |
|
} |
| 1556 |
|
|
| 1557 |
|
/* Push list */ |
| 1558 |
|
|
| 1559 |
|
push_val(env, pack); |
| 1560 |
|
|
| 1561 |
unprotect(env); |
unprotect(env); |
| 1562 |
} |
} |
| 1563 |
|
|
| 1564 |
/* Read a string */ |
/* Read a string */ |
| 1565 |
extern void readline(environment *env) { |
extern void readline(environment *env) |
| 1566 |
|
{ |
| 1567 |
char in_string[101]; |
char in_string[101]; |
| 1568 |
|
|
| 1569 |
if(fgets(in_string, 100, env->inputstream)==NULL) |
if(fgets(in_string, 100, env->inputstream)==NULL) |
| 1573 |
} |
} |
| 1574 |
|
|
| 1575 |
/* "read"; Read a value and place on stack */ |
/* "read"; Read a value and place on stack */ |
| 1576 |
extern void sx_72656164(environment *env) { |
extern void sx_72656164(environment *env) |
| 1577 |
|
{ |
| 1578 |
const char symbform[]= "%[a-zA-Z0-9!$%*+./:<=>?@^_~-]%n"; |
const char symbform[]= "%[a-zA-Z0-9!$%*+./:<=>?@^_~-]%n"; |
| 1579 |
const char strform[]= "\"%[^\"]\"%n"; |
const char strform[]= "\"%[^\"]\"%n"; |
| 1580 |
const char intform[]= "%i%n"; |
const char intform[]= "%i%n"; |
| 1653 |
return sx_72656164(env); |
return sx_72656164(env); |
| 1654 |
} |
} |
| 1655 |
|
|
| 1656 |
extern void beep(environment *env) { |
extern void beep(environment *env) |
| 1657 |
|
{ |
| 1658 |
int freq, dur, period, ticks; |
int freq, dur, period, ticks; |
| 1659 |
|
|
| 1660 |
if((env->head)==NULL || env->head->next==NULL) { |
if((env->head)==NULL || env->head->next==NULL) { |
| 1694 |
default: |
default: |
| 1695 |
abort(); |
abort(); |
| 1696 |
} |
} |
| 1697 |
}; |
} |
| 1698 |
|
|
| 1699 |
/* "wait" */ |
/* "wait" */ |
| 1700 |
extern void sx_77616974(environment *env) { |
extern void sx_77616974(environment *env) |
| 1701 |
|
{ |
| 1702 |
int dur; |
int dur; |
| 1703 |
|
|
| 1704 |
if((env->head)==NULL) { |
if((env->head)==NULL) { |
| 1717 |
toss(env); |
toss(env); |
| 1718 |
|
|
| 1719 |
usleep(dur); |
usleep(dur); |
| 1720 |
}; |
} |
| 1721 |
|
|
| 1722 |
extern void copying(environment *env){ |
extern void copying(environment *env) |
| 1723 |
|
{ |
| 1724 |
printf("GNU GENERAL PUBLIC LICENSE\n\ |
printf("GNU GENERAL PUBLIC LICENSE\n\ |
| 1725 |
Version 2, June 1991\n\ |
Version 2, June 1991\n\ |
| 1726 |
\n\ |
\n\ |
| 1979 |
of promoting the sharing and reuse of software generally.\n"); |
of promoting the sharing and reuse of software generally.\n"); |
| 1980 |
} |
} |
| 1981 |
|
|
| 1982 |
extern void warranty(environment *env){ |
extern void warranty(environment *env) |
| 1983 |
|
{ |
| 1984 |
printf(" NO WARRANTY\n\ |
printf(" NO WARRANTY\n\ |
| 1985 |
\n\ |
\n\ |
| 1986 |
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n\ |
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n\ |