ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/microscheme/scheme.c
(Generate patch)

Comparing cvsroot/microscheme/scheme.c (file contents):
Revision 1.15 by root, Thu Nov 26 09:05:20 2015 UTC vs.
Revision 1.24 by root, Fri Nov 27 02:12:08 2015 UTC

28#endif 28#endif
29#if USE_MATH 29#if USE_MATH
30# include <math.h> 30# include <math.h>
31#endif 31#endif
32 32
33#include "ecb.h"
34
33#include <sys/types.h> 35#include <sys/types.h>
34#include <sys/stat.h> 36#include <sys/stat.h>
35#include <fcntl.h> 37#include <fcntl.h>
36 38
37#include <string.h> 39#include <string.h>
65#define S_T (&SCHEME_V->xT) //TODO: magic ptr value? 67#define S_T (&SCHEME_V->xT) //TODO: magic ptr value?
66#define S_F (&SCHEME_V->xF) //TODO: magic ptr value? 68#define S_F (&SCHEME_V->xF) //TODO: magic ptr value?
67#define S_SINK (&SCHEME_V->xsink) 69#define S_SINK (&SCHEME_V->xsink)
68#define S_EOF (&SCHEME_V->xEOF_OBJ) 70#define S_EOF (&SCHEME_V->xEOF_OBJ)
69 71
70/* should use libecb */
71#if __GNUC__ >= 4
72# define ecb_expect(expr,value) __builtin_expect ((expr),(value))
73# define ecb_expect_false(expr) ecb_expect (!!(expr), 0)
74# define ecb_expect_true(expr) ecb_expect (!!(expr), 1)
75#endif
76
77#if !USE_MULTIPLICITY 72#if !USE_MULTIPLICITY
78static scheme sc; 73static scheme sc;
79#endif 74#endif
80 75
81static void 76static void
150 145
151#define toupper(c) xtoupper (c) 146#define toupper(c) xtoupper (c)
152#define tolower(c) xtolower (c) 147#define tolower(c) xtolower (c)
153#define isdigit(c) xisdigit (c) 148#define isdigit(c) xisdigit (c)
154 149
155#if USE_STRLWR 150#if USE_IGNORECASE
156static const char * 151static const char *
157strlwr (char *s) 152xstrlwr (char *s)
158{ 153{
159 const char *p = s; 154 const char *p = s;
160 155
161 while (*s) 156 while (*s)
162 { 157 {
164 s++; 159 s++;
165 } 160 }
166 161
167 return p; 162 return p;
168} 163}
169#endif
170 164
165#define stricmp(a,b) strcasecmp (a, b)
166#define strlwr(s) xstrlwr (s)
167
168#else
171#define stricmp(a,b) strcmp (a, b) 169# define stricmp(a,b) strcmp (a, b)
172#define strlwr(s) (s) 170# define strlwr(s) (s)
171#endif
173 172
174#ifndef prompt 173#ifndef prompt
175# define prompt "ts> " 174# define prompt "ts> "
176#endif 175#endif
177 176
220#if USE_MATH 219#if USE_MATH
221static double round_per_R5RS (double x); 220static double round_per_R5RS (double x);
222#endif 221#endif
223static int is_zero_rvalue (RVALUE x); 222static int is_zero_rvalue (RVALUE x);
224 223
225static INLINE int 224ecb_inline int
226num_is_integer (pointer p) 225num_is_integer (pointer p)
227{ 226{
228 return num_is_fixnum (p->object.number); 227 return num_is_fixnum (p->object.number);
229} 228}
230 229
234/* macros for cell operations */ 233/* macros for cell operations */
235#define typeflag(p) ((p)->flag + 0) 234#define typeflag(p) ((p)->flag + 0)
236#define set_typeflag(p,v) ((p)->flag = (v)) 235#define set_typeflag(p,v) ((p)->flag = (v))
237#define type(p) (typeflag (p) & T_MASKTYPE) 236#define type(p) (typeflag (p) & T_MASKTYPE)
238 237
239INTERFACE INLINE int 238INTERFACE int
240is_string (pointer p) 239is_string (pointer p)
241{ 240{
242 return type (p) == T_STRING; 241 return type (p) == T_STRING;
243} 242}
244 243
245#define strvalue(p) ((p)->object.string.svalue) 244#define strvalue(p) ((p)->object.string.svalue)
246#define strlength(p) ((p)->object.string.length) 245#define strlength(p) ((p)->object.string.length)
247 246
248INTERFACE int is_list (SCHEME_P_ pointer p); 247INTERFACE int is_list (SCHEME_P_ pointer p);
248
249INTERFACE INLINE int 249INTERFACE int
250is_vector (pointer p) 250is_vector (pointer p)
251{ 251{
252 return type (p) == T_VECTOR; 252 return type (p) == T_VECTOR;
253} 253}
254 254
263vector_length (pointer vec) 263vector_length (pointer vec)
264{ 264{
265 return vec->object.vector.length; 265 return vec->object.vector.length;
266} 266}
267 267
268INTERFACE INLINE int 268INTERFACE int
269is_number (pointer p) 269is_number (pointer p)
270{ 270{
271 return type (p) == T_NUMBER; 271 return type (p) == T_NUMBER;
272} 272}
273 273
274INTERFACE INLINE int 274INTERFACE int
275is_integer (pointer p) 275is_integer (pointer p)
276{ 276{
277 if (!is_number (p)) 277 if (!is_number (p))
278 return 0; 278 return 0;
279 279
281 return 1; 281 return 1;
282 282
283 return 0; 283 return 0;
284} 284}
285 285
286INTERFACE INLINE int 286INTERFACE int
287is_real (pointer p) 287is_real (pointer p)
288{ 288{
289 return is_number (p) && !num_is_fixnum (p->object.number); 289 return is_number (p) && !num_is_fixnum (p->object.number);
290} 290}
291 291
292INTERFACE INLINE int 292INTERFACE int
293is_character (pointer p) 293is_character (pointer p)
294{ 294{
295 return type (p) == T_CHARACTER; 295 return type (p) == T_CHARACTER;
296} 296}
297 297
298INTERFACE INLINE char * 298INTERFACE char *
299string_value (pointer p) 299string_value (pointer p)
300{ 300{
301 return strvalue (p); 301 return strvalue (p);
302} 302}
303 303
304INLINE num 304ecb_inline num
305nvalue (pointer p) 305nvalue (pointer p)
306{ 306{
307 return (p)->object.number; 307 return (p)->object.number;
308} 308}
309 309
339#else 339#else
340# define rvalue_unchecked(p) ((p)->object.number.value.ivalue) 340# define rvalue_unchecked(p) ((p)->object.number.value.ivalue)
341# define set_num_integer(p) 0 341# define set_num_integer(p) 0
342# define set_num_real(p) 0 342# define set_num_real(p) 0
343#endif 343#endif
344
344INTERFACE long 345INTERFACE long
345charvalue (pointer p) 346charvalue (pointer p)
346{ 347{
347 return ivalue_unchecked (p); 348 return ivalue_unchecked (p);
348} 349}
349 350
350INTERFACE INLINE int 351INTERFACE int
351is_port (pointer p) 352is_port (pointer p)
352{ 353{
353 return type (p) == T_PORT; 354 return type (p) == T_PORT;
354} 355}
355 356
356INTERFACE INLINE int 357INTERFACE int
357is_inport (pointer p) 358is_inport (pointer p)
358{ 359{
359 return is_port (p) && p->object.port->kind & port_input; 360 return is_port (p) && p->object.port->kind & port_input;
360} 361}
361 362
362INTERFACE INLINE int 363INTERFACE int
363is_outport (pointer p) 364is_outport (pointer p)
364{ 365{
365 return is_port (p) && p->object.port->kind & port_output; 366 return is_port (p) && p->object.port->kind & port_output;
366} 367}
367 368
368INTERFACE INLINE int 369INTERFACE int
369is_pair (pointer p) 370is_pair (pointer p)
370{ 371{
371 return type (p) == T_PAIR; 372 return type (p) == T_PAIR;
372} 373}
373 374
405pair_cdr (pointer p) 406pair_cdr (pointer p)
406{ 407{
407 return cdr (p); 408 return cdr (p);
408} 409}
409 410
410INTERFACE INLINE int 411INTERFACE int
411is_symbol (pointer p) 412is_symbol (pointer p)
412{ 413{
413 return type (p) == T_SYMBOL; 414 return type (p) == T_SYMBOL;
414} 415}
415 416
416INTERFACE INLINE char * 417INTERFACE char *
417symname (pointer p) 418symname (pointer p)
418{ 419{
419 return strvalue (car (p)); 420 return strvalue (car (p));
420} 421}
421 422
422#if USE_PLIST 423#if USE_PLIST
423SCHEME_EXPORT INLINE int 424SCHEME_EXPORT int
424hasprop (pointer p) 425hasprop (pointer p)
425{ 426{
426 return typeflag (p) & T_SYMBOL; 427 return typeflag (p) & T_SYMBOL;
427} 428}
428 429
429# define symprop(p) cdr(p) 430# define symprop(p) cdr(p)
430#endif 431#endif
431 432
432INTERFACE INLINE int 433INTERFACE int
433is_syntax (pointer p) 434is_syntax (pointer p)
434{ 435{
435 return typeflag (p) & T_SYNTAX; 436 return typeflag (p) & T_SYNTAX;
436} 437}
437 438
438INTERFACE INLINE int 439INTERFACE int
439is_proc (pointer p) 440is_proc (pointer p)
440{ 441{
441 return type (p) == T_PROC; 442 return type (p) == T_PROC;
442} 443}
443 444
444INTERFACE INLINE int 445INTERFACE int
445is_foreign (pointer p) 446is_foreign (pointer p)
446{ 447{
447 return type (p) == T_FOREIGN; 448 return type (p) == T_FOREIGN;
448} 449}
449 450
450INTERFACE INLINE char * 451INTERFACE char *
451syntaxname (pointer p) 452syntaxname (pointer p)
452{ 453{
453 return strvalue (car (p)); 454 return strvalue (car (p));
454} 455}
455 456
456#define procnum(p) ivalue (p) 457#define procnum(p) ivalue (p)
457static const char *procname (pointer x); 458static const char *procname (pointer x);
458 459
459INTERFACE INLINE int 460INTERFACE int
460is_closure (pointer p) 461is_closure (pointer p)
461{ 462{
462 return type (p) == T_CLOSURE; 463 return type (p) == T_CLOSURE;
463} 464}
464 465
465INTERFACE INLINE int 466INTERFACE int
466is_macro (pointer p) 467is_macro (pointer p)
467{ 468{
468 return type (p) == T_MACRO; 469 return type (p) == T_MACRO;
469} 470}
470 471
471INTERFACE INLINE pointer 472INTERFACE pointer
472closure_code (pointer p) 473closure_code (pointer p)
473{ 474{
474 return car (p); 475 return car (p);
475} 476}
476 477
477INTERFACE INLINE pointer 478INTERFACE pointer
478closure_env (pointer p) 479closure_env (pointer p)
479{ 480{
480 return cdr (p); 481 return cdr (p);
481} 482}
482 483
483INTERFACE INLINE int 484INTERFACE int
484is_continuation (pointer p) 485is_continuation (pointer p)
485{ 486{
486 return type (p) == T_CONTINUATION; 487 return type (p) == T_CONTINUATION;
487} 488}
488 489
489#define cont_dump(p) cdr (p) 490#define cont_dump(p) cdr (p)
490#define set_cont_dump(p,v) set_cdr ((p), (v)) 491#define set_cont_dump(p,v) set_cdr ((p), (v))
491 492
492/* To do: promise should be forced ONCE only */ 493/* To do: promise should be forced ONCE only */
493INTERFACE INLINE int 494INTERFACE int
494is_promise (pointer p) 495is_promise (pointer p)
495{ 496{
496 return type (p) == T_PROMISE; 497 return type (p) == T_PROMISE;
497} 498}
498 499
499INTERFACE INLINE int 500INTERFACE int
500is_environment (pointer p) 501is_environment (pointer p)
501{ 502{
502 return type (p) == T_ENVIRONMENT; 503 return type (p) == T_ENVIRONMENT;
503} 504}
504 505
510 511
511#define is_mark(p) (typeflag (p) & T_MARK) 512#define is_mark(p) (typeflag (p) & T_MARK)
512#define setmark(p) set_typeflag ((p), typeflag (p) | T_MARK) 513#define setmark(p) set_typeflag ((p), typeflag (p) | T_MARK)
513#define clrmark(p) set_typeflag ((p), typeflag (p) & ~T_MARK) 514#define clrmark(p) set_typeflag ((p), typeflag (p) & ~T_MARK)
514 515
515INTERFACE INLINE int 516INTERFACE int
516is_immutable (pointer p) 517is_immutable (pointer p)
517{ 518{
518 return typeflag (p) & T_IMMUTABLE && USE_ERROR_CHECKING; 519 return typeflag (p) & T_IMMUTABLE && USE_ERROR_CHECKING;
519} 520}
520 521
521INTERFACE INLINE void 522INTERFACE void
522setimmutable (pointer p) 523setimmutable (pointer p)
523{ 524{
524#if USE_ERROR_CHECKING 525#if USE_ERROR_CHECKING
525 set_typeflag (p, typeflag (p) | T_IMMUTABLE); 526 set_typeflag (p, typeflag (p) | T_IMMUTABLE);
526#endif 527#endif
527} 528}
528 529
529#if USE_CHAR_CLASSIFIERS 530#if USE_CHAR_CLASSIFIERS
530static INLINE int 531ecb_inline int
531Cisalpha (int c) 532Cisalpha (int c)
532{ 533{
533 return isascii (c) && isalpha (c); 534 return isascii (c) && isalpha (c);
534} 535}
535 536
536static INLINE int 537ecb_inline int
537Cisdigit (int c) 538Cisdigit (int c)
538{ 539{
539 return isascii (c) && isdigit (c); 540 return isascii (c) && isdigit (c);
540} 541}
541 542
542static INLINE int 543ecb_inline int
543Cisspace (int c) 544Cisspace (int c)
544{ 545{
545 return isascii (c) && isspace (c); 546 return isascii (c) && isspace (c);
546} 547}
547 548
548static INLINE int 549ecb_inline int
549Cisupper (int c) 550Cisupper (int c)
550{ 551{
551 return isascii (c) && isupper (c); 552 return isascii (c) && isupper (c);
552} 553}
553 554
554static INLINE int 555ecb_inline int
555Cislower (int c) 556Cislower (int c)
556{ 557{
557 return isascii (c) && islower (c); 558 return isascii (c) && islower (c);
558} 559}
559#endif 560#endif
620#endif 621#endif
621 622
622static int file_push (SCHEME_P_ const char *fname); 623static int file_push (SCHEME_P_ const char *fname);
623static void file_pop (SCHEME_P); 624static void file_pop (SCHEME_P);
624static int file_interactive (SCHEME_P); 625static int file_interactive (SCHEME_P);
625static INLINE int is_one_of (char *s, int c); 626ecb_inline int is_one_of (char *s, int c);
626static int alloc_cellseg (SCHEME_P_ int n); 627static int alloc_cellseg (SCHEME_P_ int n);
627static INLINE pointer get_cell (SCHEME_P_ pointer a, pointer b); 628ecb_inline pointer get_cell (SCHEME_P_ pointer a, pointer b);
628static void finalize_cell (SCHEME_P_ pointer a); 629static void finalize_cell (SCHEME_P_ pointer a);
629static int count_consecutive_cells (pointer x, int needed); 630static int count_consecutive_cells (pointer x, int needed);
630static pointer find_slot_in_env (SCHEME_P_ pointer env, pointer sym, int all); 631static pointer find_slot_in_env (SCHEME_P_ pointer env, pointer sym, int all);
631static pointer mk_number (SCHEME_P_ const num n); 632static pointer mk_number (SCHEME_P_ const num n);
632static char *store_string (SCHEME_P_ uint32_t len, const char *str, char fill); 633static char *store_string (SCHEME_P_ uint32_t len, const char *str, char fill);
649static int basic_inchar (port *pt); 650static int basic_inchar (port *pt);
650static int inchar (SCHEME_P); 651static int inchar (SCHEME_P);
651static void backchar (SCHEME_P_ int c); 652static void backchar (SCHEME_P_ int c);
652static char *readstr_upto (SCHEME_P_ char *delim); 653static char *readstr_upto (SCHEME_P_ char *delim);
653static pointer readstrexp (SCHEME_P); 654static pointer readstrexp (SCHEME_P);
654static INLINE int skipspace (SCHEME_P); 655ecb_inline int skipspace (SCHEME_P);
655static int token (SCHEME_P); 656static int token (SCHEME_P);
656static void printslashstring (SCHEME_P_ char *s, int len); 657static void printslashstring (SCHEME_P_ char *s, int len);
657static void atom2str (SCHEME_P_ pointer l, int f, char **pp, int *plen); 658static void atom2str (SCHEME_P_ pointer l, int f, char **pp, int *plen);
658static void printatom (SCHEME_P_ pointer l, int f); 659static void printatom (SCHEME_P_ pointer l, int f);
659static pointer mk_proc (SCHEME_P_ enum scheme_opcodes op); 660static pointer mk_proc (SCHEME_P_ enum scheme_opcodes op);
663static pointer reverse_in_place (SCHEME_P_ pointer term, pointer list); 664static pointer reverse_in_place (SCHEME_P_ pointer term, pointer list);
664static pointer revappend (SCHEME_P_ pointer a, pointer b); 665static pointer revappend (SCHEME_P_ pointer a, pointer b);
665static pointer ss_get_cont (SCHEME_P); 666static pointer ss_get_cont (SCHEME_P);
666static void ss_set_cont (SCHEME_P_ pointer cont); 667static void ss_set_cont (SCHEME_P_ pointer cont);
667static void dump_stack_mark (SCHEME_P); 668static void dump_stack_mark (SCHEME_P);
668static pointer opexe_0 (SCHEME_P_ enum scheme_opcodes op); 669static int opexe_0 (SCHEME_P_ enum scheme_opcodes op);
670static int opexe_1 (SCHEME_P_ enum scheme_opcodes op);
669static pointer opexe_2 (SCHEME_P_ enum scheme_opcodes op); 671static int opexe_2 (SCHEME_P_ enum scheme_opcodes op);
670static pointer opexe_r (SCHEME_P_ enum scheme_opcodes op);
671static pointer opexe_3 (SCHEME_P_ enum scheme_opcodes op); 672static int opexe_3 (SCHEME_P_ enum scheme_opcodes op);
672static pointer opexe_4 (SCHEME_P_ enum scheme_opcodes op); 673static int opexe_4 (SCHEME_P_ enum scheme_opcodes op);
673static pointer opexe_5 (SCHEME_P_ enum scheme_opcodes op); 674static int opexe_5 (SCHEME_P_ enum scheme_opcodes op);
674static pointer opexe_6 (SCHEME_P_ enum scheme_opcodes op); 675static int opexe_6 (SCHEME_P_ enum scheme_opcodes op);
675static void Eval_Cycle (SCHEME_P_ enum scheme_opcodes op); 676static void Eval_Cycle (SCHEME_P_ enum scheme_opcodes op);
676static void assign_syntax (SCHEME_P_ const char *name); 677static void assign_syntax (SCHEME_P_ const char *name);
677static int syntaxnum (pointer p); 678static int syntaxnum (pointer p);
678static void assign_proc (SCHEME_P_ enum scheme_opcodes, const char *name); 679static void assign_proc (SCHEME_P_ enum scheme_opcodes, const char *name);
679 680
777 778
778 num_set_ivalue (ret, res); 779 num_set_ivalue (ret, res);
779 return ret; 780 return ret;
780} 781}
781 782
782/* this completely disrespects NaNs */ 783/* this completely disrespects NaNs, but r5rs doesn't even allow NaNs */
783static int 784static int
784num_cmp (num a, num b) 785num_cmp (num a, num b)
785{ 786{
786 int is_fixnum = num_is_fixnum (a) && num_is_fixnum (b); 787 int is_fixnum = num_is_fixnum (a) && num_is_fixnum (b);
787 int ret; 788 int ret;
819 return ce; 820 return ce;
820 else if (dfl < dce) 821 else if (dfl < dce)
821 return fl; 822 return fl;
822 else 823 else
823 { 824 {
824 if (fmod (fl, 2.0) == 0.0) /* I imagine this holds */ 825 if (fmod (fl, 2) == 0) /* I imagine this holds */
825 return fl; 826 return fl;
826 else 827 else
827 return ce; 828 return ce;
828 } 829 }
829} 830}
830#endif 831#endif
831 832
832static int 833static int
833is_zero_rvalue (RVALUE x) 834is_zero_rvalue (RVALUE x)
834{ 835{
836 return x == 0;
837#if 0
835#if USE_REAL 838#if USE_REAL
836 return x < DBL_MIN && x > -DBL_MIN; /* why the hate of denormals? this should be == 0. */ 839 return x < DBL_MIN && x > -DBL_MIN; /* why the hate of denormals? this should be == 0. */
837#else 840#else
838 return x == 0; 841 return x == 0;
842#endif
839#endif 843#endif
840} 844}
841 845
842/* allocate new cell segment */ 846/* allocate new cell segment */
843static int 847static int
915 919
916 return n; 920 return n;
917} 921}
918 922
919/* get new cell. parameter a, b is marked by gc. */ 923/* get new cell. parameter a, b is marked by gc. */
920static INLINE pointer 924ecb_inline pointer
921get_cell_x (SCHEME_P_ pointer a, pointer b) 925get_cell_x (SCHEME_P_ pointer a, pointer b)
922{ 926{
923 if (ecb_expect_false (SCHEME_V->free_cell == NIL)) 927 if (ecb_expect_false (SCHEME_V->free_cell == NIL))
924 { 928 {
925 if (SCHEME_V->no_memory && USE_ERROR_CHECKING) 929 if (SCHEME_V->no_memory && USE_ERROR_CHECKING)
1003 push_recent_alloc (SCHEME_A_ v, NIL); 1007 push_recent_alloc (SCHEME_A_ v, NIL);
1004 1008
1005 return v; 1009 return v;
1006} 1010}
1007 1011
1008static INLINE void 1012ecb_inline void
1009ok_to_freely_gc (SCHEME_P) 1013ok_to_freely_gc (SCHEME_P)
1010{ 1014{
1011 set_car (S_SINK, NIL); 1015 set_car (S_SINK, NIL);
1012} 1016}
1013 1017
1077 location = hash_fn (name, veclength (SCHEME_V->oblist)); 1081 location = hash_fn (name, veclength (SCHEME_V->oblist));
1078 set_vector_elem (SCHEME_V->oblist, location, immutable_cons (x, vector_elem (SCHEME_V->oblist, location))); 1082 set_vector_elem (SCHEME_V->oblist, location, immutable_cons (x, vector_elem (SCHEME_V->oblist, location)));
1079 return x; 1083 return x;
1080} 1084}
1081 1085
1082static INLINE pointer 1086ecb_inline pointer
1083oblist_find_by_name (SCHEME_P_ const char *name) 1087oblist_find_by_name (SCHEME_P_ const char *name)
1084{ 1088{
1085 int location; 1089 int location;
1086 pointer x; 1090 pointer x;
1087 char *s; 1091 char *s;
1120oblist_initial_value (SCHEME_P) 1124oblist_initial_value (SCHEME_P)
1121{ 1125{
1122 return NIL; 1126 return NIL;
1123} 1127}
1124 1128
1125static INLINE pointer 1129ecb_inline pointer
1126oblist_find_by_name (SCHEME_P_ const char *name) 1130oblist_find_by_name (SCHEME_P_ const char *name)
1127{ 1131{
1128 pointer x; 1132 pointer x;
1129 char *s; 1133 char *s;
1130 1134
2228 } 2232 }
2229 } 2233 }
2230} 2234}
2231 2235
2232/* check c is in chars */ 2236/* check c is in chars */
2233static INLINE int 2237ecb_inline int
2234is_one_of (char *s, int c) 2238is_one_of (char *s, int c)
2235{ 2239{
2236 if (c == EOF) 2240 if (c == EOF)
2237 return 1; 2241 return 1;
2238 2242
2239 return !!strchr (s, c); 2243 return !!strchr (s, c);
2240} 2244}
2241 2245
2242/* skip white characters */ 2246/* skip white characters */
2243static INLINE int 2247ecb_inline int
2244skipspace (SCHEME_P) 2248skipspace (SCHEME_P)
2245{ 2249{
2246 int c, curr_line = 0; 2250 int c, curr_line = 0;
2247 2251
2248 do 2252 do
2819 2823
2820 SCHEME_V->envir = immutable_cons (new_frame, old_env); 2824 SCHEME_V->envir = immutable_cons (new_frame, old_env);
2821 setenvironment (SCHEME_V->envir); 2825 setenvironment (SCHEME_V->envir);
2822} 2826}
2823 2827
2824static INLINE void 2828ecb_inline void
2825new_slot_spec_in_env (SCHEME_P_ pointer env, pointer variable, pointer value) 2829new_slot_spec_in_env (SCHEME_P_ pointer env, pointer variable, pointer value)
2826{ 2830{
2827 pointer slot = immutable_cons (variable, value); 2831 pointer slot = immutable_cons (variable, value);
2828 2832
2829 if (is_vector (car (env))) 2833 if (is_vector (car (env)))
2869 return NIL; 2873 return NIL;
2870} 2874}
2871 2875
2872#else /* USE_ALIST_ENV */ 2876#else /* USE_ALIST_ENV */
2873 2877
2874static INLINE void 2878ecb_inline void
2875new_frame_in_env (SCHEME_P_ pointer old_env) 2879new_frame_in_env (SCHEME_P_ pointer old_env)
2876{ 2880{
2877 SCHEME_V->envir = immutable_cons (NIL, old_env); 2881 SCHEME_V->envir = immutable_cons (NIL, old_env);
2878 setenvironment (SCHEME_V->envir); 2882 setenvironment (SCHEME_V->envir);
2879} 2883}
2880 2884
2881static INLINE void 2885ecb_inline void
2882new_slot_spec_in_env (SCHEME_P_ pointer env, pointer variable, pointer value) 2886new_slot_spec_in_env (SCHEME_P_ pointer env, pointer variable, pointer value)
2883{ 2887{
2884 set_car (env, immutable_cons (immutable_cons (variable, value), car (env))); 2888 set_car (env, immutable_cons (immutable_cons (variable, value), car (env)));
2885} 2889}
2886 2890
2908 return NIL; 2912 return NIL;
2909} 2913}
2910 2914
2911#endif /* USE_ALIST_ENV else */ 2915#endif /* USE_ALIST_ENV else */
2912 2916
2913static INLINE void 2917ecb_inline void
2914new_slot_in_env (SCHEME_P_ pointer variable, pointer value) 2918new_slot_in_env (SCHEME_P_ pointer variable, pointer value)
2915{ 2919{
2916 new_slot_spec_in_env (SCHEME_A_ SCHEME_V->envir, variable, value); 2920 new_slot_spec_in_env (SCHEME_A_ SCHEME_V->envir, variable, value);
2917} 2921}
2918 2922
2919static INLINE void 2923ecb_inline void
2920set_slot_in_env (SCHEME_P_ pointer slot, pointer value) 2924set_slot_in_env (SCHEME_P_ pointer slot, pointer value)
2921{ 2925{
2922 set_cdr (slot, value); 2926 set_cdr (slot, value);
2923} 2927}
2924 2928
2925static INLINE pointer 2929ecb_inline pointer
2926slot_value_in_env (pointer slot) 2930slot_value_in_env (pointer slot)
2927{ 2931{
2928 return cdr (slot); 2932 return cdr (slot);
2929} 2933}
2930 2934
2931/* ========== Evaluation Cycle ========== */ 2935/* ========== Evaluation Cycle ========== */
2932 2936
2933static pointer 2937static int
2934xError_1 (SCHEME_P_ const char *s, pointer a) 2938xError_1 (SCHEME_P_ const char *s, pointer a)
2935{ 2939{
2936#if USE_ERROR_HOOK 2940#if USE_ERROR_HOOK
2937 pointer x; 2941 pointer x;
2938 pointer hdl = SCHEME_V->ERROR_HOOK; 2942 pointer hdl = SCHEME_V->ERROR_HOOK;
2973 code = cons (mk_string (SCHEME_A_ s), code); 2977 code = cons (mk_string (SCHEME_A_ s), code);
2974 setimmutable (car (code)); 2978 setimmutable (car (code));
2975 SCHEME_V->code = cons (slot_value_in_env (x), code); 2979 SCHEME_V->code = cons (slot_value_in_env (x), code);
2976 SCHEME_V->op = OP_EVAL; 2980 SCHEME_V->op = OP_EVAL;
2977 2981
2978 return S_T; 2982 return 0;
2979 } 2983 }
2980#endif 2984#endif
2981 2985
2982 if (a) 2986 if (a)
2983 SCHEME_V->args = cons (a, NIL); 2987 SCHEME_V->args = cons (a, NIL);
2985 SCHEME_V->args = NIL; 2989 SCHEME_V->args = NIL;
2986 2990
2987 SCHEME_V->args = cons (mk_string (SCHEME_A_ s), SCHEME_V->args); 2991 SCHEME_V->args = cons (mk_string (SCHEME_A_ s), SCHEME_V->args);
2988 setimmutable (car (SCHEME_V->args)); 2992 setimmutable (car (SCHEME_V->args));
2989 SCHEME_V->op = OP_ERR0; 2993 SCHEME_V->op = OP_ERR0;
2994
2990 return S_T; 2995 return 0;
2991} 2996}
2992 2997
2993#define Error_1(s, a) return xError_1(SCHEME_A_ USE_ERROR_CHECKING ? s : "", a) 2998#define Error_1(s, a) return xError_1(SCHEME_A_ USE_ERROR_CHECKING ? s : "", a)
2994#define Error_0(s) Error_1 (s, 0) 2999#define Error_0(s) Error_1 (s, 0)
2995 3000
2996/* Too small to turn into function */ 3001/* Too small to turn into function */
2997#define BEGIN do { 3002#define BEGIN do {
2998#define END } while (0) 3003#define END } while (0)
2999#define s_goto(a) BEGIN \ 3004#define s_goto(a) BEGIN \
3000 SCHEME_V->op = a; \ 3005 SCHEME_V->op = a; \
3001 return S_T; END 3006 return 0; END
3002 3007
3003#define s_return(a) return xs_return (SCHEME_A_ a) 3008#define s_return(a) return xs_return (SCHEME_A_ a)
3004 3009
3005#ifndef USE_SCHEME_STACK 3010#ifndef USE_SCHEME_STACK
3006 3011
3031 next_frame = SCHEME_V->dump_base + nframes; 3036 next_frame = SCHEME_V->dump_base + nframes;
3032 3037
3033 next_frame->op = op; 3038 next_frame->op = op;
3034 next_frame->args = args; 3039 next_frame->args = args;
3035 next_frame->envir = SCHEME_V->envir; 3040 next_frame->envir = SCHEME_V->envir;
3036 next_frame->code = code; 3041 next_frame->code = code;
3037 3042
3038 SCHEME_V->dump = (pointer)(uintptr_t)(nframes + 1); 3043 SCHEME_V->dump = (pointer)(uintptr_t)(nframes + 1);
3039} 3044}
3040 3045
3041static pointer 3046static int
3042xs_return (SCHEME_P_ pointer a) 3047xs_return (SCHEME_P_ pointer a)
3043{ 3048{
3044 int nframes = (uintptr_t)SCHEME_V->dump; 3049 int nframes = (uintptr_t)SCHEME_V->dump;
3045 struct dump_stack_frame *frame; 3050 struct dump_stack_frame *frame;
3046 3051
3047 SCHEME_V->value = a; 3052 SCHEME_V->value = a;
3048 3053
3049 if (nframes <= 0) 3054 if (nframes <= 0)
3050 return NIL; 3055 return -1;
3051 3056
3052 frame = &SCHEME_V->dump_base[--nframes]; 3057 frame = &SCHEME_V->dump_base[--nframes];
3053 SCHEME_V->op = frame->op; 3058 SCHEME_V->op = frame->op;
3054 SCHEME_V->args = frame->args; 3059 SCHEME_V->args = frame->args;
3055 SCHEME_V->envir = frame->envir; 3060 SCHEME_V->envir = frame->envir;
3056 SCHEME_V->code = frame->code; 3061 SCHEME_V->code = frame->code;
3057 SCHEME_V->dump = (pointer)(uintptr_t)nframes; 3062 SCHEME_V->dump = (pointer)(uintptr_t)nframes;
3058 3063
3059 return S_T; 3064 return 0;
3060} 3065}
3061 3066
3062static INLINE void 3067ecb_inline void
3063dump_stack_reset (SCHEME_P) 3068dump_stack_reset (SCHEME_P)
3064{ 3069{
3065 /* in this implementation, SCHEME_V->dump is the number of frames on the stack */ 3070 /* in this implementation, SCHEME_V->dump is the number of frames on the stack */
3066 SCHEME_V->dump = (pointer)+0; 3071 SCHEME_V->dump = (pointer)+0;
3067} 3072}
3068 3073
3069static INLINE void 3074ecb_inline void
3070dump_stack_initialize (SCHEME_P) 3075dump_stack_initialize (SCHEME_P)
3071{ 3076{
3072 SCHEME_V->dump_size = 0; 3077 SCHEME_V->dump_size = 0;
3073 SCHEME_V->dump_base = 0; 3078 SCHEME_V->dump_base = 0;
3074 dump_stack_reset (SCHEME_A); 3079 dump_stack_reset (SCHEME_A);
3141 SCHEME_V->dump = (pointer)(uintptr_t)i; 3146 SCHEME_V->dump = (pointer)(uintptr_t)i;
3142} 3147}
3143 3148
3144#else 3149#else
3145 3150
3146static INLINE void 3151ecb_inline void
3147dump_stack_reset (SCHEME_P) 3152dump_stack_reset (SCHEME_P)
3148{ 3153{
3149 SCHEME_V->dump = NIL; 3154 SCHEME_V->dump = NIL;
3150} 3155}
3151 3156
3152static INLINE void 3157ecb_inline void
3153dump_stack_initialize (SCHEME_P) 3158dump_stack_initialize (SCHEME_P)
3154{ 3159{
3155 dump_stack_reset (SCHEME_A); 3160 dump_stack_reset (SCHEME_A);
3156} 3161}
3157 3162
3159dump_stack_free (SCHEME_P) 3164dump_stack_free (SCHEME_P)
3160{ 3165{
3161 SCHEME_V->dump = NIL; 3166 SCHEME_V->dump = NIL;
3162} 3167}
3163 3168
3164static pointer 3169static int
3165xs_return (SCHEME_P_ pointer a) 3170xs_return (SCHEME_P_ pointer a)
3166{ 3171{
3167 pointer dump = SCHEME_V->dump; 3172 pointer dump = SCHEME_V->dump;
3168 3173
3169 SCHEME_V->value = a; 3174 SCHEME_V->value = a;
3170 3175
3171 if (dump == NIL) 3176 if (dump == NIL)
3172 return NIL; 3177 return -1;
3173 3178
3174 SCHEME_V->op = ivalue (car (dump)); dump = cdr (dump); 3179 SCHEME_V->op = ivalue (car (dump)); dump = cdr (dump);
3175 SCHEME_V->args = car (dump) ; dump = cdr (dump); 3180 SCHEME_V->args = car (dump) ; dump = cdr (dump);
3176 SCHEME_V->envir = car (dump) ; dump = cdr (dump); 3181 SCHEME_V->envir = car (dump) ; dump = cdr (dump);
3177 SCHEME_V->code = car (dump) ; dump = cdr (dump); 3182 SCHEME_V->code = car (dump) ; dump = cdr (dump);
3178 3183
3179 SCHEME_V->dump = dump; 3184 SCHEME_V->dump = dump;
3180 3185
3181 return S_T; 3186 return 0;
3182} 3187}
3183 3188
3184static void 3189static void
3185s_save (SCHEME_P_ enum scheme_opcodes op, pointer args, pointer code) 3190s_save (SCHEME_P_ enum scheme_opcodes op, pointer args, pointer code)
3186{ 3191{
3211 3216
3212#endif 3217#endif
3213 3218
3214#define s_retbool(tf) s_return ((tf) ? S_T : S_F) 3219#define s_retbool(tf) s_return ((tf) ? S_T : S_F)
3215 3220
3216static pointer 3221static int
3217opexe_0 (SCHEME_P_ enum scheme_opcodes op) 3222opexe_0 (SCHEME_P_ enum scheme_opcodes op)
3218{ 3223{
3224 pointer args = SCHEME_V->args;
3219 pointer x, y; 3225 pointer x, y;
3220 3226
3221 switch (op) 3227 switch (op)
3222 { 3228 {
3223 case OP_LOAD: /* load */ 3229 case OP_LOAD: /* load */
3224 if (file_interactive (SCHEME_A)) 3230 if (file_interactive (SCHEME_A))
3225 { 3231 {
3226 xwrstr ("Loading "); xwrstr (strvalue (car (SCHEME_V->args))); xwrstr ("\n"); 3232 xwrstr ("Loading "); xwrstr (strvalue (car (args))); xwrstr ("\n");
3227 //D fprintf (SCHEME_V->outport->object.port->rep.stdio.file, "Loading %s\n", strvalue (car (SCHEME_V->args))); 3233 //D fprintf (SCHEME_V->outport->object.port->rep.stdio.file, "Loading %s\n", strvalue (car (args)));
3228 } 3234 }
3229 3235
3230 if (!file_push (SCHEME_A_ strvalue (car (SCHEME_V->args)))) 3236 if (!file_push (SCHEME_A_ strvalue (car (args))))
3231 Error_1 ("unable to open", car (SCHEME_V->args)); 3237 Error_1 ("unable to open", car (args));
3232 else 3238 else
3233 { 3239 {
3234 SCHEME_V->args = mk_integer (SCHEME_A_ SCHEME_V->file_i); 3240 SCHEME_V->args = mk_integer (SCHEME_A_ SCHEME_V->file_i);
3235 s_goto (OP_T0LVL); 3241 s_goto (OP_T0LVL);
3236 } 3242 }
3310 case OP_EVAL: /* main part of evaluation */ 3316 case OP_EVAL: /* main part of evaluation */
3311#if USE_TRACING 3317#if USE_TRACING
3312 if (SCHEME_V->tracing) 3318 if (SCHEME_V->tracing)
3313 { 3319 {
3314 /*s_save(SCHEME_A_ OP_VALUEPRINT,NIL,NIL); */ 3320 /*s_save(SCHEME_A_ OP_VALUEPRINT,NIL,NIL); */
3315 s_save (SCHEME_A_ OP_REAL_EVAL, SCHEME_V->args, SCHEME_V->code); 3321 s_save (SCHEME_A_ OP_REAL_EVAL, args, SCHEME_V->code);
3316 SCHEME_V->args = SCHEME_V->code; 3322 SCHEME_V->args = SCHEME_V->code;
3317 putstr (SCHEME_A_ "\nEval: "); 3323 putstr (SCHEME_A_ "\nEval: ");
3318 s_goto (OP_P0LIST); 3324 s_goto (OP_P0LIST);
3319 } 3325 }
3320 3326
3364 SCHEME_V->code = cdr (SCHEME_V->code); 3370 SCHEME_V->code = cdr (SCHEME_V->code);
3365 s_goto (OP_E1ARGS); 3371 s_goto (OP_E1ARGS);
3366 } 3372 }
3367 3373
3368 case OP_E1ARGS: /* eval arguments */ 3374 case OP_E1ARGS: /* eval arguments */
3369 SCHEME_V->args = cons (SCHEME_V->value, SCHEME_V->args); 3375 args = cons (SCHEME_V->value, args);
3370 3376
3371 if (is_pair (SCHEME_V->code)) /* continue */ 3377 if (is_pair (SCHEME_V->code)) /* continue */
3372 { 3378 {
3373 s_save (SCHEME_A_ OP_E1ARGS, SCHEME_V->args, cdr (SCHEME_V->code)); 3379 s_save (SCHEME_A_ OP_E1ARGS, args, cdr (SCHEME_V->code));
3374 SCHEME_V->code = car (SCHEME_V->code); 3380 SCHEME_V->code = car (SCHEME_V->code);
3375 SCHEME_V->args = NIL; 3381 SCHEME_V->args = NIL;
3376 s_goto (OP_EVAL); 3382 s_goto (OP_EVAL);
3377 } 3383 }
3378 else /* end */ 3384 else /* end */
3379 { 3385 {
3380 SCHEME_V->args = reverse_in_place (SCHEME_A_ NIL, SCHEME_V->args); 3386 args = reverse_in_place (SCHEME_A_ NIL, args);
3381 SCHEME_V->code = car (SCHEME_V->args); 3387 SCHEME_V->code = car (args);
3382 SCHEME_V->args = cdr (SCHEME_V->args); 3388 SCHEME_V->args = cdr (args);
3383 s_goto (OP_APPLY); 3389 s_goto (OP_APPLY);
3384 } 3390 }
3385 3391
3386#if USE_TRACING 3392#if USE_TRACING
3387 3393
3388 case OP_TRACING: 3394 case OP_TRACING:
3389 { 3395 {
3390 int tr = SCHEME_V->tracing; 3396 int tr = SCHEME_V->tracing;
3391 3397
3392 SCHEME_V->tracing = ivalue (car (SCHEME_V->args)); 3398 SCHEME_V->tracing = ivalue (car (args));
3393 s_return (mk_integer (SCHEME_A_ tr)); 3399 s_return (mk_integer (SCHEME_A_ tr));
3394 } 3400 }
3395 3401
3396#endif 3402#endif
3397 3403
3398 case OP_APPLY: /* apply 'code' to 'args' */ 3404 case OP_APPLY: /* apply 'code' to 'args' */
3399#if USE_TRACING 3405#if USE_TRACING
3400 if (SCHEME_V->tracing) 3406 if (SCHEME_V->tracing)
3401 { 3407 {
3402 s_save (SCHEME_A_ OP_REAL_APPLY, SCHEME_V->args, SCHEME_V->code); 3408 s_save (SCHEME_A_ OP_REAL_APPLY, args, SCHEME_V->code);
3403 SCHEME_V->print_flag = 1; 3409 SCHEME_V->print_flag = 1;
3404 /* SCHEME_V->args=cons(SCHEME_V->code,SCHEME_V->args); */ 3410 /* args=cons(SCHEME_V->code,args); */
3405 putstr (SCHEME_A_ "\nApply to: "); 3411 putstr (SCHEME_A_ "\nApply to: ");
3406 s_goto (OP_P0LIST); 3412 s_goto (OP_P0LIST);
3407 } 3413 }
3408 3414
3409 /* fall through */ 3415 /* fall through */
3410 3416
3411 case OP_REAL_APPLY: 3417 case OP_REAL_APPLY:
3412#endif 3418#endif
3413 if (is_proc (SCHEME_V->code)) 3419 if (is_proc (SCHEME_V->code))
3414 {
3415 s_goto (procnum (SCHEME_V->code)); /* PROCEDURE */ 3420 s_goto (procnum (SCHEME_V->code)); /* PROCEDURE */
3416 }
3417 else if (is_foreign (SCHEME_V->code)) 3421 else if (is_foreign (SCHEME_V->code))
3418 { 3422 {
3419 /* Keep nested calls from GC'ing the arglist */ 3423 /* Keep nested calls from GC'ing the arglist */
3420 push_recent_alloc (SCHEME_A_ SCHEME_V->args, NIL); 3424 push_recent_alloc (SCHEME_A_ args, NIL);
3421 x = SCHEME_V->code->object.ff (SCHEME_A_ SCHEME_V->args); 3425 x = SCHEME_V->code->object.ff (SCHEME_A_ args);
3422 3426
3423 s_return (x); 3427 s_return (x);
3424 } 3428 }
3425 else if (is_closure (SCHEME_V->code) || is_macro (SCHEME_V->code) || is_promise (SCHEME_V->code)) /* CLOSURE */ 3429 else if (is_closure (SCHEME_V->code) || is_macro (SCHEME_V->code) || is_promise (SCHEME_V->code)) /* CLOSURE */
3426 { 3430 {
3427 /* Should not accept promise */ 3431 /* Should not accept promise */
3428 /* make environment */ 3432 /* make environment */
3429 new_frame_in_env (SCHEME_A_ closure_env (SCHEME_V->code)); 3433 new_frame_in_env (SCHEME_A_ closure_env (SCHEME_V->code));
3430 3434
3431 for (x = car (closure_code (SCHEME_V->code)), y = SCHEME_V->args; is_pair (x); x = cdr (x), y = cdr (y)) 3435 for (x = car (closure_code (SCHEME_V->code)), y = args; is_pair (x); x = cdr (x), y = cdr (y))
3432 { 3436 {
3433 if (y == NIL) 3437 if (y == NIL)
3434 Error_0 ("not enough arguments"); 3438 Error_0 ("not enough arguments");
3435 else 3439 else
3436 new_slot_in_env (SCHEME_A_ car (x), car (y)); 3440 new_slot_in_env (SCHEME_A_ car (x), car (y));
3454 s_goto (OP_BEGIN); 3458 s_goto (OP_BEGIN);
3455 } 3459 }
3456 else if (is_continuation (SCHEME_V->code)) /* CONTINUATION */ 3460 else if (is_continuation (SCHEME_V->code)) /* CONTINUATION */
3457 { 3461 {
3458 ss_set_cont (SCHEME_A_ cont_dump (SCHEME_V->code)); 3462 ss_set_cont (SCHEME_A_ cont_dump (SCHEME_V->code));
3459 s_return (SCHEME_V->args != NIL ? car (SCHEME_V->args) : NIL); 3463 s_return (args != NIL ? car (args) : NIL);
3460 } 3464 }
3461 else 3465 else
3462 Error_0 ("illegal function"); 3466 Error_0 ("illegal function");
3463 3467
3464 case OP_DOMACRO: /* do macro */ 3468 case OP_DOMACRO: /* do macro */
3473 { 3477 {
3474 pointer f = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->COMPILE_HOOK, 1); 3478 pointer f = find_slot_in_env (SCHEME_A_ SCHEME_V->envir, SCHEME_V->COMPILE_HOOK, 1);
3475 3479
3476 if (f != NIL) 3480 if (f != NIL)
3477 { 3481 {
3478 s_save (SCHEME_A_ OP_LAMBDA1, SCHEME_V->args, SCHEME_V->code); 3482 s_save (SCHEME_A_ OP_LAMBDA1, args, SCHEME_V->code);
3479 SCHEME_V->args = cons (SCHEME_V->code, NIL); 3483 SCHEME_V->args = cons (SCHEME_V->code, NIL);
3480 SCHEME_V->code = slot_value_in_env (f); 3484 SCHEME_V->code = slot_value_in_env (f);
3481 s_goto (OP_APPLY); 3485 s_goto (OP_APPLY);
3482 } 3486 }
3483 3487
3494 s_return (mk_closure (SCHEME_A_ SCHEME_V->code, SCHEME_V->envir)); 3498 s_return (mk_closure (SCHEME_A_ SCHEME_V->code, SCHEME_V->envir));
3495 3499
3496#endif 3500#endif
3497 3501
3498 case OP_MKCLOSURE: /* make-closure */ 3502 case OP_MKCLOSURE: /* make-closure */
3499 x = car (SCHEME_V->args); 3503 x = car (args);
3500 3504
3501 if (car (x) == SCHEME_V->LAMBDA) 3505 if (car (x) == SCHEME_V->LAMBDA)
3502 x = cdr (x); 3506 x = cdr (x);
3503 3507
3504 if (cdr (SCHEME_V->args) == NIL) 3508 if (cdr (args) == NIL)
3505 y = SCHEME_V->envir; 3509 y = SCHEME_V->envir;
3506 else 3510 else
3507 y = cadr (SCHEME_V->args); 3511 y = cadr (args);
3508 3512
3509 s_return (mk_closure (SCHEME_A_ x, y)); 3513 s_return (mk_closure (SCHEME_A_ x, y));
3510 3514
3511 case OP_QUOTE: /* quote */ 3515 case OP_QUOTE: /* quote */
3512 s_return (car (SCHEME_V->code)); 3516 s_return (car (SCHEME_V->code));
3544 3548
3545 3549
3546 case OP_DEFP: /* defined? */ 3550 case OP_DEFP: /* defined? */
3547 x = SCHEME_V->envir; 3551 x = SCHEME_V->envir;
3548 3552
3549 if (cdr (SCHEME_V->args) != NIL) 3553 if (cdr (args) != NIL)
3550 x = cadr (SCHEME_V->args); 3554 x = cadr (args);
3551 3555
3552 s_retbool (find_slot_in_env (SCHEME_A_ x, car (SCHEME_V->args), 1) != NIL); 3556 s_retbool (find_slot_in_env (SCHEME_A_ x, car (args), 1) != NIL);
3553 3557
3554 case OP_SET0: /* set! */ 3558 case OP_SET0: /* set! */
3555 if (is_immutable (car (SCHEME_V->code))) 3559 if (is_immutable (car (SCHEME_V->code)))
3556 Error_1 ("set!: unable to alter immutable variable", car (SCHEME_V->code)); 3560 Error_1 ("set!: unable to alter immutable variable", car (SCHEME_V->code));
3557 3561
3588 3592
3589 case OP_IF1: /* if */ 3593 case OP_IF1: /* if */
3590 if (is_true (SCHEME_V->value)) 3594 if (is_true (SCHEME_V->value))
3591 SCHEME_V->code = car (SCHEME_V->code); 3595 SCHEME_V->code = car (SCHEME_V->code);
3592 else 3596 else
3593 SCHEME_V->code = cadr (SCHEME_V->code); /* (if #f 1) ==> () because 3597 SCHEME_V->code = cadr (SCHEME_V->code); /* (if #f 1) ==> () because * car(NIL) = NIL */
3594
3595 * car(NIL) = NIL */
3596 s_goto (OP_EVAL); 3598 s_goto (OP_EVAL);
3597 3599
3598 case OP_LET0: /* let */ 3600 case OP_LET0: /* let */
3599 SCHEME_V->args = NIL; 3601 SCHEME_V->args = NIL;
3600 SCHEME_V->value = SCHEME_V->code; 3602 SCHEME_V->value = SCHEME_V->code;
3601 SCHEME_V->code = is_symbol (car (SCHEME_V->code)) ? cadr (SCHEME_V->code) : car (SCHEME_V->code); 3603 SCHEME_V->code = is_symbol (car (SCHEME_V->code)) ? cadr (SCHEME_V->code) : car (SCHEME_V->code);
3602 s_goto (OP_LET1); 3604 s_goto (OP_LET1);
3603 3605
3604 case OP_LET1: /* let (calculate parameters) */ 3606 case OP_LET1: /* let (calculate parameters) */
3605 SCHEME_V->args = cons (SCHEME_V->value, SCHEME_V->args); 3607 args = cons (SCHEME_V->value, args);
3606 3608
3607 if (is_pair (SCHEME_V->code)) /* continue */ 3609 if (is_pair (SCHEME_V->code)) /* continue */
3608 { 3610 {
3609 if (!is_pair (car (SCHEME_V->code)) || !is_pair (cdar (SCHEME_V->code))) 3611 if (!is_pair (car (SCHEME_V->code)) || !is_pair (cdar (SCHEME_V->code)))
3610 Error_1 ("Bad syntax of binding spec in let :", car (SCHEME_V->code)); 3612 Error_1 ("Bad syntax of binding spec in let :", car (SCHEME_V->code));
3611 3613
3612 s_save (SCHEME_A_ OP_LET1, SCHEME_V->args, cdr (SCHEME_V->code)); 3614 s_save (SCHEME_A_ OP_LET1, args, cdr (SCHEME_V->code));
3613 SCHEME_V->code = cadar (SCHEME_V->code); 3615 SCHEME_V->code = cadar (SCHEME_V->code);
3614 SCHEME_V->args = NIL; 3616 SCHEME_V->args = NIL;
3615 s_goto (OP_EVAL); 3617 s_goto (OP_EVAL);
3616 } 3618 }
3617 else /* end */ 3619 else /* end */
3618 { 3620 {
3619 SCHEME_V->args = reverse_in_place (SCHEME_A_ NIL, SCHEME_V->args); 3621 args = reverse_in_place (SCHEME_A_ NIL, args);
3620 SCHEME_V->code = car (SCHEME_V->args); 3622 SCHEME_V->code = car (args);
3621 SCHEME_V->args = cdr (SCHEME_V->args); 3623 SCHEME_V->args = cdr (args);
3622 s_goto (OP_LET2); 3624 s_goto (OP_LET2);
3623 } 3625 }
3624 3626
3625 case OP_LET2: /* let */ 3627 case OP_LET2: /* let */
3626 new_frame_in_env (SCHEME_A_ SCHEME_V->envir); 3628 new_frame_in_env (SCHEME_A_ SCHEME_V->envir);
3627 3629
3628 for (x = is_symbol (car (SCHEME_V->code)) ? cadr (SCHEME_V->code) : car (SCHEME_V->code), y = SCHEME_V->args; 3630 for (x = is_symbol (car (SCHEME_V->code)) ? cadr (SCHEME_V->code) : car (SCHEME_V->code), y = args;
3629 y != NIL; x = cdr (x), y = cdr (y)) 3631 y != NIL; x = cdr (x), y = cdr (y))
3630 new_slot_in_env (SCHEME_A_ caar (x), car (y)); 3632 new_slot_in_env (SCHEME_A_ caar (x), car (y));
3631 3633
3632 if (is_symbol (car (SCHEME_V->code))) /* named let */ 3634 if (is_symbol (car (SCHEME_V->code))) /* named let */
3633 { 3635 {
3634 for (x = cadr (SCHEME_V->code), SCHEME_V->args = NIL; x != NIL; x = cdr (x)) 3636 for (x = cadr (SCHEME_V->code), args = NIL; x != NIL; x = cdr (x))
3635 { 3637 {
3636 if (!is_pair (x)) 3638 if (!is_pair (x))
3637 Error_1 ("Bad syntax of binding in let :", x); 3639 Error_1 ("Bad syntax of binding in let :", x);
3638 3640
3639 if (!is_list (SCHEME_A_ car (x))) 3641 if (!is_list (SCHEME_A_ car (x)))
3640 Error_1 ("Bad syntax of binding in let :", car (x)); 3642 Error_1 ("Bad syntax of binding in let :", car (x));
3641 3643
3642 SCHEME_V->args = cons (caar (x), SCHEME_V->args); 3644 args = cons (caar (x), args);
3643 } 3645 }
3644 3646
3645 x =
3646 mk_closure (SCHEME_A_ cons (reverse_in_place (SCHEME_A_ NIL, SCHEME_V->args), cddr (SCHEME_V->code)), 3647 x = mk_closure (SCHEME_A_ cons (reverse_in_place (SCHEME_A_ NIL, args), cddr (SCHEME_V->code)),
3647 SCHEME_V->envir); 3648 SCHEME_V->envir);
3648 new_slot_in_env (SCHEME_A_ car (SCHEME_V->code), x); 3649 new_slot_in_env (SCHEME_A_ car (SCHEME_V->code), x);
3649 SCHEME_V->code = cddr (SCHEME_V->code); 3650 SCHEME_V->code = cddr (SCHEME_V->code);
3650 SCHEME_V->args = NIL;
3651 } 3651 }
3652 else 3652 else
3653 { 3653 {
3654 SCHEME_V->code = cdr (SCHEME_V->code); 3654 SCHEME_V->code = cdr (SCHEME_V->code);
3655 }
3656
3655 SCHEME_V->args = NIL; 3657 SCHEME_V->args = NIL;
3656 }
3657
3658 s_goto (OP_BEGIN); 3658 s_goto (OP_BEGIN);
3659 3659
3660 case OP_LET0AST: /* let* */ 3660 case OP_LET0AST: /* let* */
3661 if (car (SCHEME_V->code) == NIL) 3661 if (car (SCHEME_V->code) == NIL)
3662 { 3662 {
3680 new_slot_in_env (SCHEME_A_ caar (SCHEME_V->code), SCHEME_V->value); 3680 new_slot_in_env (SCHEME_A_ caar (SCHEME_V->code), SCHEME_V->value);
3681 SCHEME_V->code = cdr (SCHEME_V->code); 3681 SCHEME_V->code = cdr (SCHEME_V->code);
3682 3682
3683 if (is_pair (SCHEME_V->code)) /* continue */ 3683 if (is_pair (SCHEME_V->code)) /* continue */
3684 { 3684 {
3685 s_save (SCHEME_A_ OP_LET2AST, SCHEME_V->args, SCHEME_V->code); 3685 s_save (SCHEME_A_ OP_LET2AST, args, SCHEME_V->code);
3686 SCHEME_V->code = cadar (SCHEME_V->code); 3686 SCHEME_V->code = cadar (SCHEME_V->code);
3687 SCHEME_V->args = NIL; 3687 SCHEME_V->args = NIL;
3688 s_goto (OP_EVAL); 3688 s_goto (OP_EVAL);
3689 } 3689 }
3690 else /* end */ 3690 else /* end */
3691 { 3691 {
3692 SCHEME_V->code = SCHEME_V->args; 3692 SCHEME_V->code = args;
3693 SCHEME_V->args = NIL; 3693 SCHEME_V->args = NIL;
3694 s_goto (OP_BEGIN); 3694 s_goto (OP_BEGIN);
3695 } 3695 }
3696 3696
3697 case OP_LET0REC: /* letrec */ 3697 case OP_LET0REC: /* letrec */
3700 SCHEME_V->value = SCHEME_V->code; 3700 SCHEME_V->value = SCHEME_V->code;
3701 SCHEME_V->code = car (SCHEME_V->code); 3701 SCHEME_V->code = car (SCHEME_V->code);
3702 s_goto (OP_LET1REC); 3702 s_goto (OP_LET1REC);
3703 3703
3704 case OP_LET1REC: /* letrec (calculate parameters) */ 3704 case OP_LET1REC: /* letrec (calculate parameters) */
3705 SCHEME_V->args = cons (SCHEME_V->value, SCHEME_V->args); 3705 args = cons (SCHEME_V->value, args);
3706 3706
3707 if (is_pair (SCHEME_V->code)) /* continue */ 3707 if (is_pair (SCHEME_V->code)) /* continue */
3708 { 3708 {
3709 if (!is_pair (car (SCHEME_V->code)) || !is_pair (cdar (SCHEME_V->code))) 3709 if (!is_pair (car (SCHEME_V->code)) || !is_pair (cdar (SCHEME_V->code)))
3710 Error_1 ("Bad syntax of binding spec in letrec :", car (SCHEME_V->code)); 3710 Error_1 ("Bad syntax of binding spec in letrec :", car (SCHEME_V->code));
3711 3711
3712 s_save (SCHEME_A_ OP_LET1REC, SCHEME_V->args, cdr (SCHEME_V->code)); 3712 s_save (SCHEME_A_ OP_LET1REC, args, cdr (SCHEME_V->code));
3713 SCHEME_V->code = cadar (SCHEME_V->code); 3713 SCHEME_V->code = cadar (SCHEME_V->code);
3714 SCHEME_V->args = NIL; 3714 SCHEME_V->args = NIL;
3715 s_goto (OP_EVAL); 3715 s_goto (OP_EVAL);
3716 } 3716 }
3717 else /* end */ 3717 else /* end */
3718 { 3718 {
3719 SCHEME_V->args = reverse_in_place (SCHEME_A_ NIL, SCHEME_V->args); 3719 args = reverse_in_place (SCHEME_A_ NIL, args);
3720 SCHEME_V->code = car (SCHEME_V->args); 3720 SCHEME_V->code = car (args);
3721 SCHEME_V->args = cdr (SCHEME_V->args); 3721 SCHEME_V->args = cdr (args);
3722 s_goto (OP_LET2REC); 3722 s_goto (OP_LET2REC);
3723 } 3723 }
3724 3724
3725 case OP_LET2REC: /* letrec */ 3725 case OP_LET2REC: /* letrec */
3726 for (x = car (SCHEME_V->code), y = SCHEME_V->args; y != NIL; x = cdr (x), y = cdr (y)) 3726 for (x = car (SCHEME_V->code), y = args; y != NIL; x = cdr (x), y = cdr (y))
3727 new_slot_in_env (SCHEME_A_ caar (x), car (y)); 3727 new_slot_in_env (SCHEME_A_ caar (x), car (y));
3728 3728
3729 SCHEME_V->code = cdr (SCHEME_V->code); 3729 SCHEME_V->code = cdr (SCHEME_V->code);
3730 SCHEME_V->args = NIL; 3730 SCHEME_V->args = NIL;
3731 s_goto (OP_BEGIN); 3731 s_goto (OP_BEGIN);
3817 s_save (SCHEME_A_ OP_C1STREAM, NIL, cdr (SCHEME_V->code)); 3817 s_save (SCHEME_A_ OP_C1STREAM, NIL, cdr (SCHEME_V->code));
3818 SCHEME_V->code = car (SCHEME_V->code); 3818 SCHEME_V->code = car (SCHEME_V->code);
3819 s_goto (OP_EVAL); 3819 s_goto (OP_EVAL);
3820 3820
3821 case OP_C1STREAM: /* cons-stream */ 3821 case OP_C1STREAM: /* cons-stream */
3822 SCHEME_V->args = SCHEME_V->value; /* save SCHEME_V->value to register SCHEME_V->args for gc */ 3822 SCHEME_V->args = SCHEME_V->value; /* save SCHEME_V->value to register args for gc */
3823 x = mk_closure (SCHEME_A_ cons (NIL, SCHEME_V->code), SCHEME_V->envir); 3823 x = mk_closure (SCHEME_A_ cons (NIL, SCHEME_V->code), SCHEME_V->envir);
3824 set_typeflag (x, T_PROMISE); 3824 set_typeflag (x, T_PROMISE);
3825 s_return (cons (SCHEME_V->args, x)); 3825 s_return (cons (args, x));
3826 3826
3827 case OP_MACRO0: /* macro */ 3827 case OP_MACRO0: /* macro */
3828 if (is_pair (car (SCHEME_V->code))) 3828 if (is_pair (car (SCHEME_V->code)))
3829 { 3829 {
3830 x = caar (SCHEME_V->code); 3830 x = caar (SCHEME_V->code);
3863 { 3863 {
3864 if (!is_pair (y = caar (x))) 3864 if (!is_pair (y = caar (x)))
3865 break; 3865 break;
3866 3866
3867 for (; y != NIL; y = cdr (y)) 3867 for (; y != NIL; y = cdr (y))
3868 {
3869 if (eqv (car (y), SCHEME_V->value)) 3868 if (eqv (car (y), SCHEME_V->value))
3870 break; 3869 break;
3871 }
3872 3870
3873 if (y != NIL) 3871 if (y != NIL)
3874 break; 3872 break;
3875 } 3873 }
3876 3874
3896 s_goto (OP_BEGIN); 3894 s_goto (OP_BEGIN);
3897 else 3895 else
3898 s_return (NIL); 3896 s_return (NIL);
3899 3897
3900 case OP_PAPPLY: /* apply */ 3898 case OP_PAPPLY: /* apply */
3901 SCHEME_V->code = car (SCHEME_V->args); 3899 SCHEME_V->code = car (args);
3902 SCHEME_V->args = list_star (SCHEME_A_ cdr (SCHEME_V->args)); 3900 SCHEME_V->args = list_star (SCHEME_A_ cdr (args));
3903 /*SCHEME_V->args = cadr(SCHEME_V->args); */ 3901 /*SCHEME_V->args = cadr(args); */
3904 s_goto (OP_APPLY); 3902 s_goto (OP_APPLY);
3905 3903
3906 case OP_PEVAL: /* eval */ 3904 case OP_PEVAL: /* eval */
3907 if (cdr (SCHEME_V->args) != NIL) 3905 if (cdr (args) != NIL)
3908 SCHEME_V->envir = cadr (SCHEME_V->args); 3906 SCHEME_V->envir = cadr (args);
3909 3907
3910 SCHEME_V->code = car (SCHEME_V->args); 3908 SCHEME_V->code = car (args);
3911 s_goto (OP_EVAL); 3909 s_goto (OP_EVAL);
3912 3910
3913 case OP_CONTINUATION: /* call-with-current-continuation */ 3911 case OP_CONTINUATION: /* call-with-current-continuation */
3914 SCHEME_V->code = car (SCHEME_V->args); 3912 SCHEME_V->code = car (args);
3915 SCHEME_V->args = cons (mk_continuation (SCHEME_A_ ss_get_cont (SCHEME_A)), NIL); 3913 SCHEME_V->args = cons (mk_continuation (SCHEME_A_ ss_get_cont (SCHEME_A)), NIL);
3916 s_goto (OP_APPLY); 3914 s_goto (OP_APPLY);
3917 } 3915 }
3918 3916
3919 abort (); 3917 if (USE_ERROR_CHECKING) abort ();
3920} 3918}
3921 3919
3922static pointer 3920static int
3923opexe_2 (SCHEME_P_ enum scheme_opcodes op) 3921opexe_1 (SCHEME_P_ enum scheme_opcodes op)
3924{ 3922{
3925 pointer x; 3923 pointer args = SCHEME_V->args;
3924 pointer x = car (args);
3926 num v; 3925 num v;
3927 3926
3928#if USE_MATH 3927#if USE_MATH
3929 RVALUE dd; 3928 RVALUE dd;
3930#endif 3929#endif
3931 3930
3932 switch (op) 3931 switch (op)
3933 { 3932 {
3934#if USE_MATH 3933#if USE_MATH
3935
3936 case OP_INEX2EX: /* inexact->exact */ 3934 case OP_INEX2EX: /* inexact->exact */
3937 x = car (SCHEME_V->args);
3938
3939 if (num_is_integer (x)) 3935 if (num_is_integer (x))
3940 s_return (x); 3936 s_return (x);
3941 else if (modf (rvalue_unchecked (x), &dd) == 0.0) 3937 else if (modf (rvalue_unchecked (x), &dd) == 0)
3942 s_return (mk_integer (SCHEME_A_ ivalue (x))); 3938 s_return (mk_integer (SCHEME_A_ ivalue (x)));
3943 else 3939 else
3944 Error_1 ("inexact->exact: not integral:", x); 3940 Error_1 ("inexact->exact: not integral:", x);
3945 3941
3946 case OP_EXP:
3947 x = car (SCHEME_V->args);
3948 s_return (mk_real (SCHEME_A_ exp (rvalue (x)))); 3942 case OP_EXP: s_return (mk_real (SCHEME_A_ exp (rvalue (x))));
3949
3950 case OP_LOG:
3951 x = car (SCHEME_V->args);
3952 s_return (mk_real (SCHEME_A_ log (rvalue (x)))); 3943 case OP_LOG: s_return (mk_real (SCHEME_A_ log (rvalue (x))));
3953
3954 case OP_SIN:
3955 x = car (SCHEME_V->args);
3956 s_return (mk_real (SCHEME_A_ sin (rvalue (x)))); 3944 case OP_SIN: s_return (mk_real (SCHEME_A_ sin (rvalue (x))));
3957
3958 case OP_COS:
3959 x = car (SCHEME_V->args);
3960 s_return (mk_real (SCHEME_A_ cos (rvalue (x)))); 3945 case OP_COS: s_return (mk_real (SCHEME_A_ cos (rvalue (x))));
3961
3962 case OP_TAN:
3963 x = car (SCHEME_V->args);
3964 s_return (mk_real (SCHEME_A_ tan (rvalue (x)))); 3946 case OP_TAN: s_return (mk_real (SCHEME_A_ tan (rvalue (x))));
3965
3966 case OP_ASIN:
3967 x = car (SCHEME_V->args);
3968 s_return (mk_real (SCHEME_A_ asin (rvalue (x)))); 3947 case OP_ASIN: s_return (mk_real (SCHEME_A_ asin (rvalue (x))));
3969
3970 case OP_ACOS:
3971 x = car (SCHEME_V->args);
3972 s_return (mk_real (SCHEME_A_ acos (rvalue (x)))); 3948 case OP_ACOS: s_return (mk_real (SCHEME_A_ acos (rvalue (x))));
3973 3949
3974 case OP_ATAN: 3950 case OP_ATAN:
3975 x = car (SCHEME_V->args);
3976
3977 if (cdr (SCHEME_V->args) == NIL) 3951 if (cdr (args) == NIL)
3978 s_return (mk_real (SCHEME_A_ atan (rvalue (x)))); 3952 s_return (mk_real (SCHEME_A_ atan (rvalue (x))));
3979 else 3953 else
3980 { 3954 {
3981 pointer y = cadr (SCHEME_V->args); 3955 pointer y = cadr (args);
3982
3983 s_return (mk_real (SCHEME_A_ atan2 (rvalue (x), rvalue (y)))); 3956 s_return (mk_real (SCHEME_A_ atan2 (rvalue (x), rvalue (y))));
3984 } 3957 }
3985 3958
3986 case OP_SQRT: 3959 case OP_SQRT:
3987 x = car (SCHEME_V->args);
3988 s_return (mk_real (SCHEME_A_ sqrt (rvalue (x)))); 3960 s_return (mk_real (SCHEME_A_ sqrt (rvalue (x))));
3989 3961
3990 case OP_EXPT: 3962 case OP_EXPT:
3991 { 3963 {
3992 RVALUE result; 3964 RVALUE result;
3993 int real_result = 1; 3965 int real_result = 1;
3994 pointer y = cadr (SCHEME_V->args); 3966 pointer y = cadr (args);
3995
3996 x = car (SCHEME_V->args);
3997 3967
3998 if (num_is_integer (x) && num_is_integer (y)) 3968 if (num_is_integer (x) && num_is_integer (y))
3999 real_result = 0; 3969 real_result = 0;
4000 3970
4001 /* This 'if' is an R5RS compatibility fix. */ 3971 /* This 'if' is an R5RS compatibility fix. */
4002 /* NOTE: Remove this 'if' fix for R6RS. */ 3972 /* NOTE: Remove this 'if' fix for R6RS. */
4003 if (rvalue (x) == 0 && rvalue (y) < 0) 3973 if (rvalue (x) == 0 && rvalue (y) < 0)
4004 result = 0.0; 3974 result = 0;
4005 else 3975 else
4006 result = pow (rvalue (x), rvalue (y)); 3976 result = pow (rvalue (x), rvalue (y));
4007 3977
4008 /* Before returning integer result make sure we can. */ 3978 /* Before returning integer result make sure we can. */
4009 /* If the test fails, result is too big for integer. */ 3979 /* If the test fails, result is too big for integer. */
4010 if (!real_result) 3980 if (!real_result)
4011 { 3981 {
4012 long result_as_long = (long) result; 3982 long result_as_long = result;
4013 3983
4014 if (result != (RVALUE) result_as_long) 3984 if (result != (RVALUE) result_as_long)
4015 real_result = 1; 3985 real_result = 1;
4016 } 3986 }
4017 3987
4019 s_return (mk_real (SCHEME_A_ result)); 3989 s_return (mk_real (SCHEME_A_ result));
4020 else 3990 else
4021 s_return (mk_integer (SCHEME_A_ result)); 3991 s_return (mk_integer (SCHEME_A_ result));
4022 } 3992 }
4023 3993
4024 case OP_FLOOR:
4025 x = car (SCHEME_V->args);
4026 s_return (mk_real (SCHEME_A_ floor (rvalue (x)))); 3994 case OP_FLOOR: s_return (mk_real (SCHEME_A_ floor (rvalue (x))));
4027
4028 case OP_CEILING:
4029 x = car (SCHEME_V->args);
4030 s_return (mk_real (SCHEME_A_ ceil (rvalue (x)))); 3995 case OP_CEILING: s_return (mk_real (SCHEME_A_ ceil (rvalue (x))));
4031 3996
4032 case OP_TRUNCATE: 3997 case OP_TRUNCATE:
4033 { 3998 {
4034 RVALUE rvalue_of_x; 3999 RVALUE rvalue_of_x;
4035 4000
4036 x = car (SCHEME_V->args);
4037 rvalue_of_x = rvalue (x); 4001 rvalue_of_x = rvalue (x);
4038 4002
4039 if (rvalue_of_x > 0) 4003 if (rvalue_of_x > 0)
4040 s_return (mk_real (SCHEME_A_ floor (rvalue_of_x))); 4004 s_return (mk_real (SCHEME_A_ floor (rvalue_of_x)));
4041 else 4005 else
4042 s_return (mk_real (SCHEME_A_ ceil (rvalue_of_x))); 4006 s_return (mk_real (SCHEME_A_ ceil (rvalue_of_x)));
4043 } 4007 }
4044 4008
4045 case OP_ROUND: 4009 case OP_ROUND:
4046 x = car (SCHEME_V->args);
4047
4048 if (num_is_integer (x)) 4010 if (num_is_integer (x))
4049 s_return (x); 4011 s_return (x);
4050 4012
4051 s_return (mk_real (SCHEME_A_ round_per_R5RS (rvalue (x)))); 4013 s_return (mk_real (SCHEME_A_ round_per_R5RS (rvalue (x))));
4052#endif 4014#endif
4053 4015
4054 case OP_ADD: /* + */ 4016 case OP_ADD: /* + */
4055 v = num_zero; 4017 v = num_zero;
4056 4018
4057 for (x = SCHEME_V->args; x != NIL; x = cdr (x)) 4019 for (x = args; x != NIL; x = cdr (x))
4058 v = num_op ('+', v, nvalue (car (x))); 4020 v = num_op (NUM_ADD, v, nvalue (car (x)));
4059 4021
4060 s_return (mk_number (SCHEME_A_ v)); 4022 s_return (mk_number (SCHEME_A_ v));
4061 4023
4062 case OP_MUL: /* * */ 4024 case OP_MUL: /* * */
4063 v = num_one; 4025 v = num_one;
4064 4026
4065 for (x = SCHEME_V->args; x != NIL; x = cdr (x)) 4027 for (x = args; x != NIL; x = cdr (x))
4066 v = num_op ('+', v, nvalue (car (x))); 4028 v = num_op (NUM_MUL, v, nvalue (car (x)));
4067 4029
4068 s_return (mk_number (SCHEME_A_ v)); 4030 s_return (mk_number (SCHEME_A_ v));
4069 4031
4070 case OP_SUB: /* - */ 4032 case OP_SUB: /* - */
4071 if (cdr (SCHEME_V->args) == NIL) 4033 if (cdr (args) == NIL)
4072 { 4034 {
4073 x = SCHEME_V->args; 4035 x = args;
4074 v = num_zero; 4036 v = num_zero;
4075 } 4037 }
4076 else 4038 else
4077 { 4039 {
4078 x = cdr (SCHEME_V->args); 4040 x = cdr (args);
4079 v = nvalue (car (SCHEME_V->args)); 4041 v = nvalue (car (args));
4080 } 4042 }
4081 4043
4082 for (; x != NIL; x = cdr (x)) 4044 for (; x != NIL; x = cdr (x))
4083 v = num_op ('+', v, nvalue (car (x))); 4045 v = num_op (NUM_SUB, v, nvalue (car (x)));
4084 4046
4085 s_return (mk_number (SCHEME_A_ v)); 4047 s_return (mk_number (SCHEME_A_ v));
4086 4048
4087 case OP_DIV: /* / */ 4049 case OP_DIV: /* / */
4088 if (cdr (SCHEME_V->args) == NIL) 4050 if (cdr (args) == NIL)
4089 { 4051 {
4090 x = SCHEME_V->args; 4052 x = args;
4091 v = num_one; 4053 v = num_one;
4092 } 4054 }
4093 else 4055 else
4094 { 4056 {
4095 x = cdr (SCHEME_V->args); 4057 x = cdr (args);
4096 v = nvalue (car (SCHEME_V->args)); 4058 v = nvalue (car (args));
4097 } 4059 }
4098 4060
4099 for (; x != NIL; x = cdr (x)) 4061 for (; x != NIL; x = cdr (x))
4100 {
4101 if (!is_zero_rvalue (rvalue (car (x)))) 4062 if (!is_zero_rvalue (rvalue (car (x))))
4102 v = num_div (v, nvalue (car (x))); 4063 v = num_div (v, nvalue (car (x)));
4103 else 4064 else
4104 Error_0 ("/: division by zero"); 4065 Error_0 ("/: division by zero");
4105 }
4106 4066
4107 s_return (mk_number (SCHEME_A_ v)); 4067 s_return (mk_number (SCHEME_A_ v));
4108 4068
4109 case OP_INTDIV: /* quotient */ 4069 case OP_INTDIV: /* quotient */
4110 if (cdr (SCHEME_V->args) == NIL) 4070 if (cdr (args) == NIL)
4111 { 4071 {
4112 x = SCHEME_V->args; 4072 x = args;
4113 v = num_one; 4073 v = num_one;
4114 } 4074 }
4115 else 4075 else
4116 { 4076 {
4117 x = cdr (SCHEME_V->args); 4077 x = cdr (args);
4118 v = nvalue (car (SCHEME_V->args)); 4078 v = nvalue (car (args));
4119 } 4079 }
4120 4080
4121 for (; x != NIL; x = cdr (x)) 4081 for (; x != NIL; x = cdr (x))
4122 { 4082 {
4123 if (ivalue (car (x)) != 0) 4083 if (ivalue (car (x)) != 0)
4124 v = num_op ('/', v, nvalue (car (x))); 4084 v = num_op (NUM_INTDIV, v, nvalue (car (x)));
4125 else 4085 else
4126 Error_0 ("quotient: division by zero"); 4086 Error_0 ("quotient: division by zero");
4127 } 4087 }
4128 4088
4129 s_return (mk_number (SCHEME_A_ v)); 4089 s_return (mk_number (SCHEME_A_ v));
4130 4090
4131 case OP_REM: /* remainder */ 4091 case OP_REM: /* remainder */
4132 v = nvalue (car (SCHEME_V->args)); 4092 v = nvalue (x);
4133 4093
4134 if (ivalue (cadr (SCHEME_V->args)) != 0) 4094 if (ivalue (cadr (args)) != 0)
4135 v = num_rem (v, nvalue (cadr (SCHEME_V->args))); 4095 v = num_rem (v, nvalue (cadr (args)));
4136 else 4096 else
4137 Error_0 ("remainder: division by zero"); 4097 Error_0 ("remainder: division by zero");
4138 4098
4139 s_return (mk_number (SCHEME_A_ v)); 4099 s_return (mk_number (SCHEME_A_ v));
4140 4100
4141 case OP_MOD: /* modulo */ 4101 case OP_MOD: /* modulo */
4142 v = nvalue (car (SCHEME_V->args)); 4102 v = nvalue (x);
4143 4103
4144 if (ivalue (cadr (SCHEME_V->args)) != 0) 4104 if (ivalue (cadr (args)) != 0)
4145 v = num_mod (v, nvalue (cadr (SCHEME_V->args))); 4105 v = num_mod (v, nvalue (cadr (args)));
4146 else 4106 else
4147 Error_0 ("modulo: division by zero"); 4107 Error_0 ("modulo: division by zero");
4148 4108
4149 s_return (mk_number (SCHEME_A_ v)); 4109 s_return (mk_number (SCHEME_A_ v));
4150 4110
4151 case OP_CAR: /* car */ 4111 case OP_CAR: /* car */
4152 s_return (caar (SCHEME_V->args)); 4112 s_return (caar (args));
4153 4113
4154 case OP_CDR: /* cdr */ 4114 case OP_CDR: /* cdr */
4155 s_return (cdar (SCHEME_V->args)); 4115 s_return (cdar (args));
4156 4116
4157 case OP_CONS: /* cons */ 4117 case OP_CONS: /* cons */
4158 set_cdr (SCHEME_V->args, cadr (SCHEME_V->args)); 4118 set_cdr (args, cadr (args));
4159 s_return (SCHEME_V->args); 4119 s_return (args);
4160 4120
4161 case OP_SETCAR: /* set-car! */ 4121 case OP_SETCAR: /* set-car! */
4162 if (!is_immutable (car (SCHEME_V->args))) 4122 if (!is_immutable (x))
4163 { 4123 {
4164 set_car (car (SCHEME_V->args), cadr (SCHEME_V->args)); 4124 set_car (x, cadr (args));
4165 s_return (car (SCHEME_V->args)); 4125 s_return (car (args));
4166 } 4126 }
4167 else 4127 else
4168 Error_0 ("set-car!: unable to alter immutable pair"); 4128 Error_0 ("set-car!: unable to alter immutable pair");
4169 4129
4170 case OP_SETCDR: /* set-cdr! */ 4130 case OP_SETCDR: /* set-cdr! */
4171 if (!is_immutable (car (SCHEME_V->args))) 4131 if (!is_immutable (x))
4172 { 4132 {
4173 set_cdr (car (SCHEME_V->args), cadr (SCHEME_V->args)); 4133 set_cdr (x, cadr (args));
4174 s_return (car (SCHEME_V->args)); 4134 s_return (car (args));
4175 } 4135 }
4176 else 4136 else
4177 Error_0 ("set-cdr!: unable to alter immutable pair"); 4137 Error_0 ("set-cdr!: unable to alter immutable pair");
4178 4138
4179 case OP_CHAR2INT: /* char->integer */ 4139 case OP_CHAR2INT: /* char->integer */
4180 s_return (mk_integer (SCHEME_A_ ivalue (car (SCHEME_V->args)))); 4140 s_return (mk_integer (SCHEME_A_ ivalue (x)));
4181 4141
4182 case OP_INT2CHAR: /* integer->char */ 4142 case OP_INT2CHAR: /* integer->char */
4183 s_return (mk_character (SCHEME_A_ ivalue (car (SCHEME_V->args)))); 4143 s_return (mk_character (SCHEME_A_ ivalue (x)));
4184 4144
4185 case OP_CHARUPCASE: 4145 case OP_CHARUPCASE:
4186 { 4146 {
4187 unsigned char c = ivalue (car (SCHEME_V->args)); 4147 unsigned char c = ivalue (x);
4188 c = toupper (c); 4148 c = toupper (c);
4189 s_return (mk_character (SCHEME_A_ c)); 4149 s_return (mk_character (SCHEME_A_ c));
4190 } 4150 }
4191 4151
4192 case OP_CHARDNCASE: 4152 case OP_CHARDNCASE:
4193 { 4153 {
4194 unsigned char c = ivalue (car (SCHEME_V->args)); 4154 unsigned char c = ivalue (x);
4195 c = tolower (c); 4155 c = tolower (c);
4196 s_return (mk_character (SCHEME_A_ c)); 4156 s_return (mk_character (SCHEME_A_ c));
4197 } 4157 }
4198 4158
4199 case OP_STR2SYM: /* string->symbol */ 4159 case OP_STR2SYM: /* string->symbol */
4200 s_return (mk_symbol (SCHEME_A_ strvalue (car (SCHEME_V->args)))); 4160 s_return (mk_symbol (SCHEME_A_ strvalue (x)));
4201 4161
4202 case OP_STR2ATOM: /* string->atom */ 4162 case OP_STR2ATOM: /* string->atom */
4203 { 4163 {
4204 char *s = strvalue (car (SCHEME_V->args)); 4164 char *s = strvalue (x);
4205 long pf = 0; 4165 long pf = 0;
4206 4166
4207 if (cdr (SCHEME_V->args) != NIL) 4167 if (cdr (args) != NIL)
4208 { 4168 {
4209 /* we know cadr(SCHEME_V->args) is a natural number */ 4169 /* we know cadr(args) is a natural number */
4210 /* see if it is 2, 8, 10, or 16, or error */ 4170 /* see if it is 2, 8, 10, or 16, or error */
4211 pf = ivalue_unchecked (cadr (SCHEME_V->args)); 4171 pf = ivalue_unchecked (cadr (args));
4212 4172
4213 if (pf == 16 || pf == 10 || pf == 8 || pf == 2) 4173 if (pf == 16 || pf == 10 || pf == 8 || pf == 2)
4214 { 4174 {
4215 /* base is OK */ 4175 /* base is OK */
4216 } 4176 }
4217 else 4177 else
4218 pf = -1; 4178 pf = -1;
4219 } 4179 }
4220 4180
4221 if (pf < 0) 4181 if (pf < 0)
4222 Error_1 ("string->atom: bad base:", cadr (SCHEME_V->args)); 4182 Error_1 ("string->atom: bad base:", cadr (args));
4223 else if (*s == '#') /* no use of base! */ 4183 else if (*s == '#') /* no use of base! */
4224 s_return (mk_sharp_const (SCHEME_A_ s + 1)); 4184 s_return (mk_sharp_const (SCHEME_A_ s + 1));
4225 else 4185 else
4226 { 4186 {
4227 if (pf == 0 || pf == 10) 4187 if (pf == 0 || pf == 10)
4238 } 4198 }
4239 } 4199 }
4240 } 4200 }
4241 4201
4242 case OP_SYM2STR: /* symbol->string */ 4202 case OP_SYM2STR: /* symbol->string */
4243 x = mk_string (SCHEME_A_ symname (car (SCHEME_V->args))); 4203 x = mk_string (SCHEME_A_ symname (x));
4244 setimmutable (x); 4204 setimmutable (x);
4245 s_return (x); 4205 s_return (x);
4246 4206
4247 case OP_ATOM2STR: /* atom->string */ 4207 case OP_ATOM2STR: /* atom->string */
4248 { 4208 {
4249 long pf = 0; 4209 long pf = 0;
4250 4210
4251 x = car (SCHEME_V->args);
4252
4253 if (cdr (SCHEME_V->args) != NIL) 4211 if (cdr (args) != NIL)
4254 { 4212 {
4255 /* we know cadr(SCHEME_V->args) is a natural number */ 4213 /* we know cadr(args) is a natural number */
4256 /* see if it is 2, 8, 10, or 16, or error */ 4214 /* see if it is 2, 8, 10, or 16, or error */
4257 pf = ivalue_unchecked (cadr (SCHEME_V->args)); 4215 pf = ivalue_unchecked (cadr (args));
4258 4216
4259 if (is_number (x) && (pf == 16 || pf == 10 || pf == 8 || pf == 2)) 4217 if (is_number (x) && (pf == 16 || pf == 10 || pf == 8 || pf == 2))
4260 { 4218 {
4261 /* base is OK */ 4219 /* base is OK */
4262 } 4220 }
4263 else 4221 else
4264 pf = -1; 4222 pf = -1;
4265 } 4223 }
4266 4224
4267 if (pf < 0) 4225 if (pf < 0)
4268 Error_1 ("atom->string: bad base:", cadr (SCHEME_V->args)); 4226 Error_1 ("atom->string: bad base:", cadr (args));
4269 else if (is_number (x) || is_character (x) || is_string (x) || is_symbol (x)) 4227 else if (is_number (x) || is_character (x) || is_string (x) || is_symbol (x))
4270 { 4228 {
4271 char *p; 4229 char *p;
4272 int len; 4230 int len;
4273 4231
4281 case OP_MKSTRING: /* make-string */ 4239 case OP_MKSTRING: /* make-string */
4282 { 4240 {
4283 int fill = ' '; 4241 int fill = ' ';
4284 int len; 4242 int len;
4285 4243
4286 len = ivalue (car (SCHEME_V->args)); 4244 len = ivalue (x);
4287 4245
4288 if (cdr (SCHEME_V->args) != NIL) 4246 if (cdr (args) != NIL)
4289 fill = charvalue (cadr (SCHEME_V->args)); 4247 fill = charvalue (cadr (args));
4290 4248
4291 s_return (mk_empty_string (SCHEME_A_ len, (char) fill)); 4249 s_return (mk_empty_string (SCHEME_A_ len, fill));
4292 } 4250 }
4293 4251
4294 case OP_STRLEN: /* string-length */ 4252 case OP_STRLEN: /* string-length */
4295 s_return (mk_integer (SCHEME_A_ strlength (car (SCHEME_V->args)))); 4253 s_return (mk_integer (SCHEME_A_ strlength (x)));
4296 4254
4297 case OP_STRREF: /* string-ref */ 4255 case OP_STRREF: /* string-ref */
4298 { 4256 {
4299 char *str; 4257 char *str;
4300 int index; 4258 int index;
4301 4259
4302 str = strvalue (car (SCHEME_V->args)); 4260 str = strvalue (x);
4303 4261
4304 index = ivalue (cadr (SCHEME_V->args)); 4262 index = ivalue (cadr (args));
4305 4263
4306 if (index >= strlength (car (SCHEME_V->args))) 4264 if (index >= strlength (x))
4307 Error_1 ("string-ref: out of bounds:", cadr (SCHEME_V->args)); 4265 Error_1 ("string-ref: out of bounds:", cadr (args));
4308 4266
4309 s_return (mk_character (SCHEME_A_ ((unsigned char *) str)[index])); 4267 s_return (mk_character (SCHEME_A_ ((unsigned char *)str)[index]));
4310 } 4268 }
4311 4269
4312 case OP_STRSET: /* string-set! */ 4270 case OP_STRSET: /* string-set! */
4313 { 4271 {
4314 char *str; 4272 char *str;
4315 int index; 4273 int index;
4316 int c; 4274 int c;
4317 4275
4318 if (is_immutable (car (SCHEME_V->args))) 4276 if (is_immutable (x))
4319 Error_1 ("string-set!: unable to alter immutable string:", car (SCHEME_V->args)); 4277 Error_1 ("string-set!: unable to alter immutable string:", x);
4320 4278
4321 str = strvalue (car (SCHEME_V->args)); 4279 str = strvalue (x);
4322 4280
4323 index = ivalue (cadr (SCHEME_V->args)); 4281 index = ivalue (cadr (args));
4324 4282
4325 if (index >= strlength (car (SCHEME_V->args))) 4283 if (index >= strlength (x))
4326 Error_1 ("string-set!: out of bounds:", cadr (SCHEME_V->args)); 4284 Error_1 ("string-set!: out of bounds:", cadr (args));
4327 4285
4328 c = charvalue (caddr (SCHEME_V->args)); 4286 c = charvalue (caddr (args));
4329 4287
4330 str[index] = (char) c; 4288 str[index] = c;
4331 s_return (car (SCHEME_V->args)); 4289 s_return (car (args));
4332 } 4290 }
4333 4291
4334 case OP_STRAPPEND: /* string-append */ 4292 case OP_STRAPPEND: /* string-append */
4335 { 4293 {
4336 /* in 1.29 string-append was in Scheme in init.scm but was too slow */ 4294 /* in 1.29 string-append was in Scheme in init.scm but was too slow */
4337 int len = 0; 4295 int len = 0;
4338 pointer newstr; 4296 pointer newstr;
4339 char *pos; 4297 char *pos;
4340 4298
4341 /* compute needed length for new string */ 4299 /* compute needed length for new string */
4342 for (x = SCHEME_V->args; x != NIL; x = cdr (x)) 4300 for (x = args; x != NIL; x = cdr (x))
4343 len += strlength (car (x)); 4301 len += strlength (car (x));
4344 4302
4345 newstr = mk_empty_string (SCHEME_A_ len, ' '); 4303 newstr = mk_empty_string (SCHEME_A_ len, ' ');
4346 4304
4347 /* store the contents of the argument strings into the new string */ 4305 /* store the contents of the argument strings into the new string */
4348 for (pos = strvalue (newstr), x = SCHEME_V->args; x != NIL; pos += strlength (car (x)), x = cdr (x)) 4306 for (pos = strvalue (newstr), x = args; x != NIL; pos += strlength (car (x)), x = cdr (x))
4349 memcpy (pos, strvalue (car (x)), strlength (car (x))); 4307 memcpy (pos, strvalue (car (x)), strlength (car (x)));
4350 4308
4351 s_return (newstr); 4309 s_return (newstr);
4352 } 4310 }
4353 4311
4356 char *str; 4314 char *str;
4357 int index0; 4315 int index0;
4358 int index1; 4316 int index1;
4359 int len; 4317 int len;
4360 4318
4361 str = strvalue (car (SCHEME_V->args)); 4319 str = strvalue (x);
4362 4320
4363 index0 = ivalue (cadr (SCHEME_V->args)); 4321 index0 = ivalue (cadr (args));
4364 4322
4365 if (index0 > strlength (car (SCHEME_V->args))) 4323 if (index0 > strlength (x))
4366 Error_1 ("substring: start out of bounds:", cadr (SCHEME_V->args)); 4324 Error_1 ("substring: start out of bounds:", cadr (args));
4367 4325
4368 if (cddr (SCHEME_V->args) != NIL) 4326 if (cddr (args) != NIL)
4369 { 4327 {
4370 index1 = ivalue (caddr (SCHEME_V->args)); 4328 index1 = ivalue (caddr (args));
4371 4329
4372 if (index1 > strlength (car (SCHEME_V->args)) || index1 < index0) 4330 if (index1 > strlength (x) || index1 < index0)
4373 Error_1 ("substring: end out of bounds:", caddr (SCHEME_V->args)); 4331 Error_1 ("substring: end out of bounds:", caddr (args));
4374 } 4332 }
4375 else 4333 else
4376 index1 = strlength (car (SCHEME_V->args)); 4334 index1 = strlength (x);
4377 4335
4378 len = index1 - index0; 4336 len = index1 - index0;
4379 x = mk_empty_string (SCHEME_A_ len, ' '); 4337 x = mk_empty_string (SCHEME_A_ len, ' ');
4380 memcpy (strvalue (x), str + index0, len); 4338 memcpy (strvalue (x), str + index0, len);
4381 strvalue (x)[len] = 0; 4339 strvalue (x)[len] = 0;
4385 4343
4386 case OP_VECTOR: /* vector */ 4344 case OP_VECTOR: /* vector */
4387 { 4345 {
4388 int i; 4346 int i;
4389 pointer vec; 4347 pointer vec;
4390 int len = list_length (SCHEME_A_ SCHEME_V->args); 4348 int len = list_length (SCHEME_A_ args);
4391 4349
4392 if (len < 0) 4350 if (len < 0)
4393 Error_1 ("vector: not a proper list:", SCHEME_V->args); 4351 Error_1 ("vector: not a proper list:", args);
4394 4352
4395 vec = mk_vector (SCHEME_A_ len); 4353 vec = mk_vector (SCHEME_A_ len);
4396 4354
4397#if USE_ERROR_CHECKING 4355#if USE_ERROR_CHECKING
4398 if (SCHEME_V->no_memory) 4356 if (SCHEME_V->no_memory)
4399 s_return (S_SINK); 4357 s_return (S_SINK);
4400#endif 4358#endif
4401 4359
4402 for (x = SCHEME_V->args, i = 0; is_pair (x); x = cdr (x), i++) 4360 for (x = args, i = 0; is_pair (x); x = cdr (x), i++)
4403 set_vector_elem (vec, i, car (x)); 4361 set_vector_elem (vec, i, car (x));
4404 4362
4405 s_return (vec); 4363 s_return (vec);
4406 } 4364 }
4407 4365
4409 { 4367 {
4410 pointer fill = NIL; 4368 pointer fill = NIL;
4411 int len; 4369 int len;
4412 pointer vec; 4370 pointer vec;
4413 4371
4414 len = ivalue (car (SCHEME_V->args)); 4372 len = ivalue (x);
4415 4373
4416 if (cdr (SCHEME_V->args) != NIL) 4374 if (cdr (args) != NIL)
4417 fill = cadr (SCHEME_V->args); 4375 fill = cadr (args);
4418 4376
4419 vec = mk_vector (SCHEME_A_ len); 4377 vec = mk_vector (SCHEME_A_ len);
4420 4378
4421#if USE_ERROR_CHECKING 4379#if USE_ERROR_CHECKING
4422 if (SCHEME_V->no_memory) 4380 if (SCHEME_V->no_memory)
4428 4386
4429 s_return (vec); 4387 s_return (vec);
4430 } 4388 }
4431 4389
4432 case OP_VECLEN: /* vector-length */ 4390 case OP_VECLEN: /* vector-length */
4433 s_return (mk_integer (SCHEME_A_ veclength (car (SCHEME_V->args)))); 4391 s_return (mk_integer (SCHEME_A_ veclength (x)));
4434 4392
4435 case OP_VECREF: /* vector-ref */ 4393 case OP_VECREF: /* vector-ref */
4436 { 4394 {
4437 int index; 4395 int index;
4438 4396
4439 index = ivalue (cadr (SCHEME_V->args)); 4397 index = ivalue (cadr (args));
4440 4398
4441 if (index >= veclength (car (SCHEME_V->args)) && USE_ERROR_CHECKING) 4399 if (index >= veclength (car (args)) && USE_ERROR_CHECKING)
4442 Error_1 ("vector-ref: out of bounds:", cadr (SCHEME_V->args)); 4400 Error_1 ("vector-ref: out of bounds:", cadr (args));
4443 4401
4444 s_return (vector_elem (car (SCHEME_V->args), index)); 4402 s_return (vector_elem (x, index));
4445 } 4403 }
4446 4404
4447 case OP_VECSET: /* vector-set! */ 4405 case OP_VECSET: /* vector-set! */
4448 { 4406 {
4449 int index; 4407 int index;
4450 4408
4451 if (is_immutable (car (SCHEME_V->args))) 4409 if (is_immutable (x))
4452 Error_1 ("vector-set!: unable to alter immutable vector:", car (SCHEME_V->args)); 4410 Error_1 ("vector-set!: unable to alter immutable vector:", x);
4453 4411
4454 index = ivalue (cadr (SCHEME_V->args)); 4412 index = ivalue (cadr (args));
4455 4413
4456 if (index >= veclength (car (SCHEME_V->args)) && USE_ERROR_CHECKING) 4414 if (index >= veclength (car (args)) && USE_ERROR_CHECKING)
4457 Error_1 ("vector-set!: out of bounds:", cadr (SCHEME_V->args)); 4415 Error_1 ("vector-set!: out of bounds:", cadr (args));
4458 4416
4459 set_vector_elem (car (SCHEME_V->args), index, caddr (SCHEME_V->args)); 4417 set_vector_elem (x, index, caddr (args));
4460 s_return (car (SCHEME_V->args)); 4418 s_return (x);
4461 } 4419 }
4462 } 4420 }
4463 4421
4464 return S_T; 4422 if (USE_ERROR_CHECKING) abort ();
4465} 4423}
4466 4424
4467INTERFACE int 4425INTERFACE int
4468is_list (SCHEME_P_ pointer a) 4426is_list (SCHEME_P_ pointer a)
4469{ 4427{
4516 return -1; 4474 return -1;
4517 } 4475 }
4518 } 4476 }
4519} 4477}
4520 4478
4521static pointer 4479static int
4522opexe_r (SCHEME_P_ enum scheme_opcodes op) 4480opexe_2 (SCHEME_P_ enum scheme_opcodes op)
4523{ 4481{
4524 pointer x = SCHEME_V->args; 4482 pointer x = SCHEME_V->args;
4525 4483
4526 for (;;) 4484 for (;;)
4527 { 4485 {
4547 } 4505 }
4548 4506
4549 s_return (S_T); 4507 s_return (S_T);
4550} 4508}
4551 4509
4552static pointer 4510static int
4553opexe_3 (SCHEME_P_ enum scheme_opcodes op) 4511opexe_3 (SCHEME_P_ enum scheme_opcodes op)
4554{ 4512{
4555 pointer x = SCHEME_V->args; 4513 pointer args = SCHEME_V->args;
4556 pointer a = car (x); 4514 pointer a = car (args);
4557 pointer d = cdr (x); 4515 pointer d = cdr (args);
4558 int r; 4516 int r;
4559 4517
4560 switch (op) 4518 switch (op)
4561 { 4519 {
4562 case OP_NOT: /* not */ r = is_false (a) ; break; 4520 case OP_NOT: /* not */ r = is_false (a) ; break;
4596 4554
4597 case OP_PAIRP: /* pair? */ r = is_pair (a) ; break; 4555 case OP_PAIRP: /* pair? */ r = is_pair (a) ; break;
4598 case OP_LISTP: /* list? */ r = list_length (SCHEME_A_ a) >= 0; break; 4556 case OP_LISTP: /* list? */ r = list_length (SCHEME_A_ a) >= 0; break;
4599 case OP_ENVP: /* environment? */ r = is_environment (a) ; break; 4557 case OP_ENVP: /* environment? */ r = is_environment (a) ; break;
4600 case OP_VECTORP: /* vector? */ r = is_vector (a) ; break; 4558 case OP_VECTORP: /* vector? */ r = is_vector (a) ; break;
4601 case OP_EQ: /* eq? */ r = a == cadr (x) ; break; 4559 case OP_EQ: /* eq? */ r = a == cadr (args) ; break;
4602 case OP_EQV: /* eqv? */ r = eqv (a, cadr (x)) ; break; 4560 case OP_EQV: /* eqv? */ r = eqv (a, cadr (args)) ; break;
4603 } 4561 }
4604 4562
4605 s_retbool (r); 4563 s_retbool (r);
4606} 4564}
4607 4565
4608static pointer 4566static int
4609opexe_4 (SCHEME_P_ enum scheme_opcodes op) 4567opexe_4 (SCHEME_P_ enum scheme_opcodes op)
4610{ 4568{
4569 pointer args = SCHEME_V->args;
4570 pointer a = car (args);
4611 pointer x, y; 4571 pointer x, y;
4612 4572
4613 switch (op) 4573 switch (op)
4614 { 4574 {
4615 case OP_FORCE: /* force */ 4575 case OP_FORCE: /* force */
4616 SCHEME_V->code = car (SCHEME_V->args); 4576 SCHEME_V->code = a;
4617 4577
4618 if (is_promise (SCHEME_V->code)) 4578 if (is_promise (SCHEME_V->code))
4619 { 4579 {
4620 /* Should change type to closure here */ 4580 /* Should change type to closure here */
4621 s_save (SCHEME_A_ OP_SAVE_FORCED, NIL, SCHEME_V->code); 4581 s_save (SCHEME_A_ OP_SAVE_FORCED, NIL, SCHEME_V->code);
4642 s_save (SCHEME_A_ OP_SET_OUTPORT, x, NIL); 4602 s_save (SCHEME_A_ OP_SET_OUTPORT, x, NIL);
4643 SCHEME_V->outport = cadr (SCHEME_V->args); 4603 SCHEME_V->outport = cadr (SCHEME_V->args);
4644 } 4604 }
4645 } 4605 }
4646 4606
4647 SCHEME_V->args = car (SCHEME_V->args); 4607 SCHEME_V->args = a;
4648 4608
4649 if (op == OP_WRITE) 4609 if (op == OP_WRITE)
4650 SCHEME_V->print_flag = 1; 4610 SCHEME_V->print_flag = 1;
4651 else 4611 else
4652 SCHEME_V->print_flag = 0; 4612 SCHEME_V->print_flag = 0;
4653 4613
4654 s_goto (OP_P0LIST); 4614 s_goto (OP_P0LIST);
4655 4615
4656 case OP_NEWLINE: /* newline */ 4616 case OP_NEWLINE: /* newline */
4657 if (is_pair (SCHEME_V->args)) 4617 if (is_pair (args))
4658 { 4618 {
4659 if (car (SCHEME_V->args) != SCHEME_V->outport) 4619 if (a != SCHEME_V->outport)
4660 { 4620 {
4661 x = cons (SCHEME_V->outport, NIL); 4621 x = cons (SCHEME_V->outport, NIL);
4662 s_save (SCHEME_A_ OP_SET_OUTPORT, x, NIL); 4622 s_save (SCHEME_A_ OP_SET_OUTPORT, x, NIL);
4663 SCHEME_V->outport = car (SCHEME_V->args); 4623 SCHEME_V->outport = a;
4664 } 4624 }
4665 } 4625 }
4666 4626
4667 putstr (SCHEME_A_ "\n"); 4627 putstr (SCHEME_A_ "\n");
4668 s_return (S_T); 4628 s_return (S_T);
4669#endif 4629#endif
4670 4630
4671 case OP_ERR0: /* error */ 4631 case OP_ERR0: /* error */
4672 SCHEME_V->retcode = -1; 4632 SCHEME_V->retcode = -1;
4673 4633
4674 if (!is_string (car (SCHEME_V->args))) 4634 if (!is_string (a))
4675 { 4635 {
4676 SCHEME_V->args = cons (mk_string (SCHEME_A_ " -- "), SCHEME_V->args); 4636 args = cons (mk_string (SCHEME_A_ " -- "), args);
4677 setimmutable (car (SCHEME_V->args)); 4637 setimmutable (car (args));
4678 } 4638 }
4679 4639
4680 putstr (SCHEME_A_ "Error: "); 4640 putstr (SCHEME_A_ "Error: ");
4681 putstr (SCHEME_A_ strvalue (car (SCHEME_V->args))); 4641 putstr (SCHEME_A_ strvalue (car (args)));
4682 SCHEME_V->args = cdr (SCHEME_V->args); 4642 SCHEME_V->args = cdr (args);
4683 s_goto (OP_ERR1); 4643 s_goto (OP_ERR1);
4684 4644
4685 case OP_ERR1: /* error */ 4645 case OP_ERR1: /* error */
4686 putstr (SCHEME_A_ " "); 4646 putstr (SCHEME_A_ " ");
4687 4647
4688 if (SCHEME_V->args != NIL) 4648 if (args != NIL)
4689 { 4649 {
4690 s_save (SCHEME_A_ OP_ERR1, cdr (SCHEME_V->args), NIL); 4650 s_save (SCHEME_A_ OP_ERR1, cdr (args), NIL);
4691 SCHEME_V->args = car (SCHEME_V->args); 4651 SCHEME_V->args = a;
4692 SCHEME_V->print_flag = 1; 4652 SCHEME_V->print_flag = 1;
4693 s_goto (OP_P0LIST); 4653 s_goto (OP_P0LIST);
4694 } 4654 }
4695 else 4655 else
4696 { 4656 {
4697 putstr (SCHEME_A_ "\n"); 4657 putstr (SCHEME_A_ "\n");
4698 4658
4699 if (SCHEME_V->interactive_repl) 4659 if (SCHEME_V->interactive_repl)
4700 s_goto (OP_T0LVL); 4660 s_goto (OP_T0LVL);
4701 else 4661 else
4702 return NIL; 4662 return -1;
4703 } 4663 }
4704 4664
4705 case OP_REVERSE: /* reverse */ 4665 case OP_REVERSE: /* reverse */
4706 s_return (reverse (SCHEME_A_ car (SCHEME_V->args))); 4666 s_return (reverse (SCHEME_A_ a));
4707 4667
4708 case OP_LIST_STAR: /* list* */ 4668 case OP_LIST_STAR: /* list* */
4709 s_return (list_star (SCHEME_A_ SCHEME_V->args)); 4669 s_return (list_star (SCHEME_A_ SCHEME_V->args));
4710 4670
4711 case OP_APPEND: /* append */ 4671 case OP_APPEND: /* append */
4712 x = NIL; 4672 x = NIL;
4713 y = SCHEME_V->args; 4673 y = args;
4714 4674
4715 if (y == x) 4675 if (y == x)
4716 s_return (x); 4676 s_return (x);
4717 4677
4718 /* cdr() in the while condition is not a typo. If car() */ 4678 /* cdr() in the while condition is not a typo. If car() */
4729 s_return (reverse_in_place (SCHEME_A_ car (y), x)); 4689 s_return (reverse_in_place (SCHEME_A_ car (y), x));
4730 4690
4731#if USE_PLIST 4691#if USE_PLIST
4732 4692
4733 case OP_PUT: /* put */ 4693 case OP_PUT: /* put */
4734 if (!hasprop (car (SCHEME_V->args)) || !hasprop (cadr (SCHEME_V->args))) 4694 if (!hasprop (a) || !hasprop (cadr (args)))
4735 Error_0 ("illegal use of put"); 4695 Error_0 ("illegal use of put");
4736 4696
4737 for (x = symprop (car (SCHEME_V->args)), y = cadr (SCHEME_V->args); x != NIL; x = cdr (x)) 4697 for (x = symprop (a), y = cadr (args); x != NIL; x = cdr (x))
4738 { 4698 {
4739 if (caar (x) == y) 4699 if (caar (x) == y)
4740 break; 4700 break;
4741 } 4701 }
4742 4702
4743 if (x != NIL) 4703 if (x != NIL)
4744 cdar (x) = caddr (SCHEME_V->args); 4704 cdar (x) = caddr (args);
4745 else 4705 else
4746 symprop (car (SCHEME_V->args)) = cons (cons (y, caddr (SCHEME_V->args)), symprop (car (SCHEME_V->args))); 4706 symprop (a) = cons (cons (y, caddr (args)), symprop (a));
4747 4707
4748 s_return (S_T); 4708 s_return (S_T);
4749 4709
4750 case OP_GET: /* get */ 4710 case OP_GET: /* get */
4751 if (!hasprop (car (SCHEME_V->args)) || !hasprop (cadr (SCHEME_V->args))) 4711 if (!hasprop (a) || !hasprop (cadr (args)))
4752 Error_0 ("illegal use of get"); 4712 Error_0 ("illegal use of get");
4753 4713
4754 for (x = symprop (car (SCHEME_V->args)), y = cadr (SCHEME_V->args); x != NIL; x = cdr (x)) 4714 for (x = symprop (a), y = cadr (args); x != NIL; x = cdr (x))
4755 if (caar (x) == y) 4715 if (caar (x) == y)
4756 break; 4716 break;
4757 4717
4758 if (x != NIL) 4718 if (x != NIL)
4759 s_return (cdar (x)); 4719 s_return (cdar (x));
4761 s_return (NIL); 4721 s_return (NIL);
4762 4722
4763#endif /* USE_PLIST */ 4723#endif /* USE_PLIST */
4764 4724
4765 case OP_QUIT: /* quit */ 4725 case OP_QUIT: /* quit */
4766 if (is_pair (SCHEME_V->args)) 4726 if (is_pair (args))
4767 SCHEME_V->retcode = ivalue (car (SCHEME_V->args)); 4727 SCHEME_V->retcode = ivalue (a);
4768 4728
4769 return NIL; 4729 return -1;
4770 4730
4771 case OP_GC: /* gc */ 4731 case OP_GC: /* gc */
4772 gc (SCHEME_A_ NIL, NIL); 4732 gc (SCHEME_A_ NIL, NIL);
4773 s_return (S_T); 4733 s_return (S_T);
4774 4734
4775 case OP_GCVERB: /* gc-verbose */ 4735 case OP_GCVERB: /* gc-verbose */
4776 { 4736 {
4777 int was = SCHEME_V->gc_verbose; 4737 int was = SCHEME_V->gc_verbose;
4778 4738
4779 SCHEME_V->gc_verbose = (car (SCHEME_V->args) != S_F); 4739 SCHEME_V->gc_verbose = (a != S_F);
4780 s_retbool (was); 4740 s_retbool (was);
4781 } 4741 }
4782 4742
4783 case OP_NEWSEGMENT: /* new-segment */ 4743 case OP_NEWSEGMENT: /* new-segment */
4784 if (!is_pair (SCHEME_V->args) || !is_number (car (SCHEME_V->args))) 4744 if (!is_pair (args) || !is_number (a))
4785 Error_0 ("new-segment: argument must be a number"); 4745 Error_0 ("new-segment: argument must be a number");
4786 4746
4787 alloc_cellseg (SCHEME_A_ (int)ivalue (car (SCHEME_V->args))); 4747 alloc_cellseg (SCHEME_A_ (int)ivalue (a));
4788 4748
4789 s_return (S_T); 4749 s_return (S_T);
4790 4750
4791 case OP_OBLIST: /* oblist */ 4751 case OP_OBLIST: /* oblist */
4792 s_return (oblist_all_symbols (SCHEME_A)); 4752 s_return (oblist_all_symbols (SCHEME_A));
4819 case OP_OPEN_INOUTFILE: 4779 case OP_OPEN_INOUTFILE:
4820 prop = port_input | port_output; 4780 prop = port_input | port_output;
4821 break; 4781 break;
4822 } 4782 }
4823 4783
4824 p = port_from_filename (SCHEME_A_ strvalue (car (SCHEME_V->args)), prop); 4784 p = port_from_filename (SCHEME_A_ strvalue (a), prop);
4825 4785
4826 if (p == NIL) 4786 s_return (p == NIL ? S_F : p);
4827 s_return (S_F);
4828
4829 s_return (p);
4830 } 4787 }
4831 4788
4832# if USE_STRING_PORTS 4789# if USE_STRING_PORTS
4833 4790
4834 case OP_OPEN_INSTRING: /* open-input-string */ 4791 case OP_OPEN_INSTRING: /* open-input-string */
4846 case OP_OPEN_INOUTSTRING: 4803 case OP_OPEN_INOUTSTRING:
4847 prop = port_input | port_output; 4804 prop = port_input | port_output;
4848 break; 4805 break;
4849 } 4806 }
4850 4807
4851 p = port_from_string (SCHEME_A_ strvalue (car (SCHEME_V->args)), 4808 p = port_from_string (SCHEME_A_ strvalue (a),
4852 strvalue (car (SCHEME_V->args)) + strlength (car (SCHEME_V->args)), prop); 4809 strvalue (a) + strlength (a), prop);
4853 4810
4854 if (p == NIL) 4811 s_return (p == NIL ? S_F : p);
4855 s_return (S_F);
4856
4857 s_return (p);
4858 } 4812 }
4859 4813
4860 case OP_OPEN_OUTSTRING: /* open-output-string */ 4814 case OP_OPEN_OUTSTRING: /* open-output-string */
4861 { 4815 {
4862 pointer p; 4816 pointer p;
4863 4817
4864 if (car (SCHEME_V->args) == NIL) 4818 if (a == NIL)
4865 {
4866 p = port_from_scratch (SCHEME_A); 4819 p = port_from_scratch (SCHEME_A);
4867
4868 if (p == NIL)
4869 s_return (S_F);
4870 }
4871 else 4820 else
4872 {
4873 p = port_from_string (SCHEME_A_ strvalue (car (SCHEME_V->args)), 4821 p = port_from_string (SCHEME_A_ strvalue (a),
4874 strvalue (car (SCHEME_V->args)) + strlength (car (SCHEME_V->args)), port_output); 4822 strvalue (a) + strlength (a), port_output);
4875 4823
4876 if (p == NIL) 4824 s_return (p == NIL ? S_F : p);
4877 s_return (S_F);
4878 }
4879
4880 s_return (p);
4881 } 4825 }
4882 4826
4883 case OP_GET_OUTSTRING: /* get-output-string */ 4827 case OP_GET_OUTSTRING: /* get-output-string */
4884 { 4828 {
4885 port *p; 4829 port *p;
4886 4830
4887 if ((p = car (SCHEME_V->args)->object.port)->kind & port_string) 4831 if ((p = a->object.port)->kind & port_string)
4888 { 4832 {
4889 off_t size; 4833 off_t size;
4890 char *str; 4834 char *str;
4891 4835
4892 size = p->rep.string.curr - p->rep.string.start + 1; 4836 size = p->rep.string.curr - p->rep.string.start + 1;
4908 } 4852 }
4909 4853
4910# endif 4854# endif
4911 4855
4912 case OP_CLOSE_INPORT: /* close-input-port */ 4856 case OP_CLOSE_INPORT: /* close-input-port */
4913 port_close (SCHEME_A_ car (SCHEME_V->args), port_input); 4857 port_close (SCHEME_A_ a, port_input);
4914 s_return (S_T); 4858 s_return (S_T);
4915 4859
4916 case OP_CLOSE_OUTPORT: /* close-output-port */ 4860 case OP_CLOSE_OUTPORT: /* close-output-port */
4917 port_close (SCHEME_A_ car (SCHEME_V->args), port_output); 4861 port_close (SCHEME_A_ a, port_output);
4918 s_return (S_T); 4862 s_return (S_T);
4919#endif 4863#endif
4920 4864
4921 case OP_INT_ENV: /* interaction-environment */ 4865 case OP_INT_ENV: /* interaction-environment */
4922 s_return (SCHEME_V->global_env); 4866 s_return (SCHEME_V->global_env);
4924 case OP_CURR_ENV: /* current-environment */ 4868 case OP_CURR_ENV: /* current-environment */
4925 s_return (SCHEME_V->envir); 4869 s_return (SCHEME_V->envir);
4926 4870
4927 } 4871 }
4928 4872
4929 abort (); 4873 if (USE_ERROR_CHECKING) abort ();
4930} 4874}
4931 4875
4932static pointer 4876static int
4933opexe_5 (SCHEME_P_ enum scheme_opcodes op) 4877opexe_5 (SCHEME_P_ enum scheme_opcodes op)
4934{ 4878{
4879 pointer args = SCHEME_V->args;
4935 pointer x; 4880 pointer x;
4936 4881
4937 if (SCHEME_V->nesting != 0) 4882 if (SCHEME_V->nesting != 0)
4938 { 4883 {
4939 int n = SCHEME_V->nesting; 4884 int n = SCHEME_V->nesting;
4946 switch (op) 4891 switch (op)
4947 { 4892 {
4948 /* ========== reading part ========== */ 4893 /* ========== reading part ========== */
4949#if USE_PORTS 4894#if USE_PORTS
4950 case OP_READ: 4895 case OP_READ:
4951 if (!is_pair (SCHEME_V->args)) 4896 if (!is_pair (args))
4952 s_goto (OP_READ_INTERNAL); 4897 s_goto (OP_READ_INTERNAL);
4953 4898
4954 if (!is_inport (car (SCHEME_V->args))) 4899 if (!is_inport (car (args)))
4955 Error_1 ("read: not an input port:", car (SCHEME_V->args)); 4900 Error_1 ("read: not an input port:", car (args));
4956 4901
4957 if (car (SCHEME_V->args) == SCHEME_V->inport) 4902 if (car (args) == SCHEME_V->inport)
4958 s_goto (OP_READ_INTERNAL); 4903 s_goto (OP_READ_INTERNAL);
4959 4904
4960 x = SCHEME_V->inport; 4905 x = SCHEME_V->inport;
4961 SCHEME_V->inport = car (SCHEME_V->args); 4906 SCHEME_V->inport = car (args);
4962 x = cons (x, NIL); 4907 x = cons (x, NIL);
4963 s_save (SCHEME_A_ OP_SET_INPORT, x, NIL); 4908 s_save (SCHEME_A_ OP_SET_INPORT, x, NIL);
4964 s_goto (OP_READ_INTERNAL); 4909 s_goto (OP_READ_INTERNAL);
4965 4910
4966 case OP_READ_CHAR: /* read-char */ 4911 case OP_READ_CHAR: /* read-char */
4967 case OP_PEEK_CHAR: /* peek-char */ 4912 case OP_PEEK_CHAR: /* peek-char */
4968 { 4913 {
4969 int c; 4914 int c;
4970 4915
4971 if (is_pair (SCHEME_V->args)) 4916 if (is_pair (args))
4972 { 4917 {
4973 if (car (SCHEME_V->args) != SCHEME_V->inport) 4918 if (car (args) != SCHEME_V->inport)
4974 { 4919 {
4975 x = SCHEME_V->inport; 4920 x = SCHEME_V->inport;
4976 x = cons (x, NIL); 4921 x = cons (x, NIL);
4977 s_save (SCHEME_A_ OP_SET_INPORT, x, NIL); 4922 s_save (SCHEME_A_ OP_SET_INPORT, x, NIL);
4978 SCHEME_V->inport = car (SCHEME_V->args); 4923 SCHEME_V->inport = car (args);
4979 } 4924 }
4980 } 4925 }
4981 4926
4982 c = inchar (SCHEME_A); 4927 c = inchar (SCHEME_A);
4983 4928
4993 case OP_CHAR_READY: /* char-ready? */ 4938 case OP_CHAR_READY: /* char-ready? */
4994 { 4939 {
4995 pointer p = SCHEME_V->inport; 4940 pointer p = SCHEME_V->inport;
4996 int res; 4941 int res;
4997 4942
4998 if (is_pair (SCHEME_V->args)) 4943 if (is_pair (args))
4999 p = car (SCHEME_V->args); 4944 p = car (args);
5000 4945
5001 res = p->object.port->kind & port_string; 4946 res = p->object.port->kind & port_string;
5002 4947
5003 s_retbool (res); 4948 s_retbool (res);
5004 } 4949 }
5005 4950
5006 case OP_SET_INPORT: /* set-input-port */ 4951 case OP_SET_INPORT: /* set-input-port */
5007 SCHEME_V->inport = car (SCHEME_V->args); 4952 SCHEME_V->inport = car (args);
5008 s_return (SCHEME_V->value); 4953 s_return (SCHEME_V->value);
5009 4954
5010 case OP_SET_OUTPORT: /* set-output-port */ 4955 case OP_SET_OUTPORT: /* set-output-port */
5011 SCHEME_V->outport = car (SCHEME_V->args); 4956 SCHEME_V->outport = car (args);
5012 s_return (SCHEME_V->value); 4957 s_return (SCHEME_V->value);
5013#endif 4958#endif
5014 4959
5015 case OP_RDSEXPR: 4960 case OP_RDSEXPR:
5016 switch (SCHEME_V->tok) 4961 switch (SCHEME_V->tok)
5102 } 5047 }
5103 5048
5104 break; 5049 break;
5105 5050
5106 case OP_RDLIST: 5051 case OP_RDLIST:
5107 SCHEME_V->args = cons (SCHEME_V->value, SCHEME_V->args); 5052 SCHEME_V->args = cons (SCHEME_V->value, args);
5108 SCHEME_V->tok = token (SCHEME_A); 5053 SCHEME_V->tok = token (SCHEME_A);
5109 5054
5110 switch (SCHEME_V->tok) 5055 switch (SCHEME_V->tok)
5111 { 5056 {
5112 case TOK_EOF: 5057 case TOK_EOF:
5140 case OP_RDDOT: 5085 case OP_RDDOT:
5141 if (token (SCHEME_A) != TOK_RPAREN) 5086 if (token (SCHEME_A) != TOK_RPAREN)
5142 Error_0 ("syntax error: illegal dot expression"); 5087 Error_0 ("syntax error: illegal dot expression");
5143 5088
5144 SCHEME_V->nesting_stack[SCHEME_V->file_i]--; 5089 SCHEME_V->nesting_stack[SCHEME_V->file_i]--;
5145 s_return (reverse_in_place (SCHEME_A_ SCHEME_V->value, SCHEME_V->args)); 5090 s_return (reverse_in_place (SCHEME_A_ SCHEME_V->value, args));
5146 5091
5147 case OP_RDQUOTE: 5092 case OP_RDQUOTE:
5148 s_return (cons (SCHEME_V->QUOTE, cons (SCHEME_V->value, NIL))); 5093 s_return (cons (SCHEME_V->QUOTE, cons (SCHEME_V->value, NIL)));
5149 5094
5150 case OP_RDQQUOTE: 5095 case OP_RDQQUOTE:
5172 SCHEME_V->args = SCHEME_V->value; 5117 SCHEME_V->args = SCHEME_V->value;
5173 s_goto (OP_VECTOR); 5118 s_goto (OP_VECTOR);
5174 5119
5175 /* ========== printing part ========== */ 5120 /* ========== printing part ========== */
5176 case OP_P0LIST: 5121 case OP_P0LIST:
5177 if (is_vector (SCHEME_V->args)) 5122 if (is_vector (args))
5178 { 5123 {
5179 putstr (SCHEME_A_ "#("); 5124 putstr (SCHEME_A_ "#(");
5180 SCHEME_V->args = cons (SCHEME_V->args, mk_integer (SCHEME_A_ 0)); 5125 SCHEME_V->args = cons (args, mk_integer (SCHEME_A_ 0));
5181 s_goto (OP_PVECFROM); 5126 s_goto (OP_PVECFROM);
5182 } 5127 }
5183 else if (is_environment (SCHEME_V->args)) 5128 else if (is_environment (args))
5184 { 5129 {
5185 putstr (SCHEME_A_ "#<ENVIRONMENT>"); 5130 putstr (SCHEME_A_ "#<ENVIRONMENT>");
5186 s_return (S_T); 5131 s_return (S_T);
5187 } 5132 }
5188 else if (!is_pair (SCHEME_V->args)) 5133 else if (!is_pair (args))
5189 { 5134 {
5190 printatom (SCHEME_A_ SCHEME_V->args, SCHEME_V->print_flag); 5135 printatom (SCHEME_A_ args, SCHEME_V->print_flag);
5191 s_return (S_T); 5136 s_return (S_T);
5192 } 5137 }
5193 else if (car (SCHEME_V->args) == SCHEME_V->QUOTE && ok_abbrev (cdr (SCHEME_V->args))) 5138 else
5194 { 5139 {
5140 pointer a = car (args);
5141 pointer b = cdr (args);
5142 int ok_abbr = ok_abbrev (b);
5143 SCHEME_V->args = car (b);
5144
5145 if (a == SCHEME_V->QUOTE && ok_abbr)
5195 putstr (SCHEME_A_ "'"); 5146 putstr (SCHEME_A_ "'");
5196 SCHEME_V->args = cadr (SCHEME_V->args); 5147 else if (a == SCHEME_V->QQUOTE && ok_abbr)
5148 putstr (SCHEME_A_ "`");
5149 else if (a == SCHEME_V->UNQUOTE && ok_abbr)
5150 putstr (SCHEME_A_ ",");
5151 else if (a == SCHEME_V->UNQUOTESP && ok_abbr)
5152 putstr (SCHEME_A_ ",@");
5153 else
5154 {
5155 putstr (SCHEME_A_ "(");
5156 s_save (SCHEME_A_ OP_P1LIST, b, NIL);
5157 SCHEME_V->args = a;
5158 }
5159
5197 s_goto (OP_P0LIST); 5160 s_goto (OP_P0LIST);
5198 } 5161 }
5199 else if (car (SCHEME_V->args) == SCHEME_V->QQUOTE && ok_abbrev (cdr (SCHEME_V->args))) 5162
5163 case OP_P1LIST:
5164 if (is_pair (args))
5200 { 5165 {
5166 s_save (SCHEME_A_ OP_P1LIST, cdr (args), NIL);
5201 putstr (SCHEME_A_ "`"); 5167 putstr (SCHEME_A_ " ");
5202 SCHEME_V->args = cadr (SCHEME_V->args); 5168 SCHEME_V->args = car (args);
5203 s_goto (OP_P0LIST); 5169 s_goto (OP_P0LIST);
5204 } 5170 }
5205 else if (car (SCHEME_V->args) == SCHEME_V->UNQUOTE && ok_abbrev (cdr (SCHEME_V->args)))
5206 {
5207 putstr (SCHEME_A_ ",");
5208 SCHEME_V->args = cadr (SCHEME_V->args);
5209 s_goto (OP_P0LIST);
5210 }
5211 else if (car (SCHEME_V->args) == SCHEME_V->UNQUOTESP && ok_abbrev (cdr (SCHEME_V->args)))
5212 {
5213 putstr (SCHEME_A_ ",@");
5214 SCHEME_V->args = cadr (SCHEME_V->args);
5215 s_goto (OP_P0LIST);
5216 }
5217 else
5218 {
5219 putstr (SCHEME_A_ "(");
5220 s_save (SCHEME_A_ OP_P1LIST, cdr (SCHEME_V->args), NIL);
5221 SCHEME_V->args = car (SCHEME_V->args);
5222 s_goto (OP_P0LIST);
5223 }
5224
5225 case OP_P1LIST:
5226 if (is_pair (SCHEME_V->args))
5227 {
5228 s_save (SCHEME_A_ OP_P1LIST, cdr (SCHEME_V->args), NIL);
5229 putstr (SCHEME_A_ " ");
5230 SCHEME_V->args = car (SCHEME_V->args);
5231 s_goto (OP_P0LIST);
5232 }
5233 else if (is_vector (SCHEME_V->args)) 5171 else if (is_vector (args))
5234 { 5172 {
5235 s_save (SCHEME_A_ OP_P1LIST, NIL, NIL); 5173 s_save (SCHEME_A_ OP_P1LIST, NIL, NIL);
5236 putstr (SCHEME_A_ " . "); 5174 putstr (SCHEME_A_ " . ");
5237 s_goto (OP_P0LIST); 5175 s_goto (OP_P0LIST);
5238 } 5176 }
5239 else 5177 else
5240 { 5178 {
5241 if (SCHEME_V->args != NIL) 5179 if (args != NIL)
5242 { 5180 {
5243 putstr (SCHEME_A_ " . "); 5181 putstr (SCHEME_A_ " . ");
5244 printatom (SCHEME_A_ SCHEME_V->args, SCHEME_V->print_flag); 5182 printatom (SCHEME_A_ args, SCHEME_V->print_flag);
5245 } 5183 }
5246 5184
5247 putstr (SCHEME_A_ ")"); 5185 putstr (SCHEME_A_ ")");
5248 s_return (S_T); 5186 s_return (S_T);
5249 } 5187 }
5250 5188
5251 case OP_PVECFROM: 5189 case OP_PVECFROM:
5252 { 5190 {
5253 int i = ivalue_unchecked (cdr (SCHEME_V->args)); 5191 int i = ivalue_unchecked (cdr (args));
5254 pointer vec = car (SCHEME_V->args); 5192 pointer vec = car (args);
5255 int len = veclength (vec); 5193 int len = veclength (vec);
5256 5194
5257 if (i == len) 5195 if (i == len)
5258 { 5196 {
5259 putstr (SCHEME_A_ ")"); 5197 putstr (SCHEME_A_ ")");
5261 } 5199 }
5262 else 5200 else
5263 { 5201 {
5264 pointer elem = vector_elem (vec, i); 5202 pointer elem = vector_elem (vec, i);
5265 5203
5266 ivalue_unchecked (cdr (SCHEME_V->args)) = i + 1; 5204 ivalue_unchecked (cdr (args)) = i + 1;
5267 s_save (SCHEME_A_ OP_PVECFROM, SCHEME_V->args, NIL); 5205 s_save (SCHEME_A_ OP_PVECFROM, args, NIL);
5268 SCHEME_V->args = elem; 5206 SCHEME_V->args = elem;
5269 5207
5270 if (i > 0) 5208 if (i > 0)
5271 putstr (SCHEME_A_ " "); 5209 putstr (SCHEME_A_ " ");
5272 5210
5273 s_goto (OP_P0LIST); 5211 s_goto (OP_P0LIST);
5274 } 5212 }
5275 } 5213 }
5276 } 5214 }
5277 5215
5278 abort (); 5216 if (USE_ERROR_CHECKING) abort ();
5279} 5217}
5280 5218
5281static pointer 5219static int
5282opexe_6 (SCHEME_P_ enum scheme_opcodes op) 5220opexe_6 (SCHEME_P_ enum scheme_opcodes op)
5283{ 5221{
5222 pointer args = SCHEME_V->args;
5223 pointer a = car (args);
5284 pointer x, y; 5224 pointer x, y;
5285 5225
5286 switch (op) 5226 switch (op)
5287 { 5227 {
5288 case OP_LIST_LENGTH: /* length *//* a.k */ 5228 case OP_LIST_LENGTH: /* length *//* a.k */
5289 { 5229 {
5290 long v = list_length (SCHEME_A_ car (SCHEME_V->args)); 5230 long v = list_length (SCHEME_A_ a);
5291 5231
5292 if (v < 0) 5232 if (v < 0)
5293 Error_1 ("length: not a list:", car (SCHEME_V->args)); 5233 Error_1 ("length: not a list:", a);
5294 5234
5295 s_return (mk_integer (SCHEME_A_ v)); 5235 s_return (mk_integer (SCHEME_A_ v));
5296 } 5236 }
5297 5237
5298 case OP_ASSQ: /* assq *//* a.k */ 5238 case OP_ASSQ: /* assq *//* a.k */
5299 x = car (SCHEME_V->args); 5239 x = a;
5300 5240
5301 for (y = cadr (SCHEME_V->args); is_pair (y); y = cdr (y)) 5241 for (y = cadr (args); is_pair (y); y = cdr (y))
5302 { 5242 {
5303 if (!is_pair (car (y))) 5243 if (!is_pair (car (y)))
5304 Error_0 ("unable to handle non pair element"); 5244 Error_0 ("unable to handle non pair element");
5305 5245
5306 if (x == caar (y)) 5246 if (x == caar (y))
5312 else 5252 else
5313 s_return (S_F); 5253 s_return (S_F);
5314 5254
5315 5255
5316 case OP_GET_CLOSURE: /* get-closure-code *//* a.k */ 5256 case OP_GET_CLOSURE: /* get-closure-code *//* a.k */
5317 SCHEME_V->args = car (SCHEME_V->args); 5257 SCHEME_V->args = a;
5318 5258
5319 if (SCHEME_V->args == NIL) 5259 if (SCHEME_V->args == NIL)
5320 s_return (S_F); 5260 s_return (S_F);
5321 else if (is_closure (SCHEME_V->args)) 5261 else if (is_closure (SCHEME_V->args))
5322 s_return (cons (SCHEME_V->LAMBDA, closure_code (SCHEME_V->value))); 5262 s_return (cons (SCHEME_V->LAMBDA, closure_code (SCHEME_V->value)));
5328 case OP_CLOSUREP: /* closure? */ 5268 case OP_CLOSUREP: /* closure? */
5329 /* 5269 /*
5330 * Note, macro object is also a closure. 5270 * Note, macro object is also a closure.
5331 * Therefore, (closure? <#MACRO>) ==> #t 5271 * Therefore, (closure? <#MACRO>) ==> #t
5332 */ 5272 */
5333 s_retbool (is_closure (car (SCHEME_V->args))); 5273 s_retbool (is_closure (a));
5334 5274
5335 case OP_MACROP: /* macro? */ 5275 case OP_MACROP: /* macro? */
5336 s_retbool (is_macro (car (SCHEME_V->args))); 5276 s_retbool (is_macro (a));
5337 } 5277 }
5338 5278
5339 abort (); 5279 if (USE_ERROR_CHECKING) abort ();
5340} 5280}
5341 5281
5282/* dispatch functions (opexe_x) return new opcode, or 0 for same opcode, or -1 to stop */
5342typedef pointer (*dispatch_func) (SCHEME_P_ enum scheme_opcodes); 5283typedef int (*dispatch_func)(SCHEME_P_ enum scheme_opcodes);
5343 5284
5344typedef int (*test_predicate) (pointer); 5285typedef int (*test_predicate)(pointer);
5345static int 5286static int
5346is_any (pointer p) 5287is_any (pointer p)
5347{ 5288{
5348 return 1; 5289 return 1;
5349} 5290}
5350 5291
5351static int 5292static int
5352is_nonneg (pointer p) 5293is_nonneg (pointer p)
5353{ 5294{
5354 return ivalue (p) >= 0 && is_integer (p); 5295 return ivalue (p) >= 0 && is_integer (p);
5296}
5297
5298static int
5299tst_is_list (pointer p)
5300{
5301 return p == NIL || is_pair (p);
5355} 5302}
5356 5303
5357/* Correspond carefully with following defines! */ 5304/* Correspond carefully with following defines! */
5358static struct 5305static struct
5359{ 5306{
5360 test_predicate fct; 5307 test_predicate fct;
5361 const char *kind; 5308 const char *kind;
5362} tests[] = 5309} tests[] =
5363{ 5310{
5364 { 0, 0}, /* unused */ 5311 { is_any, 0 },
5365 { is_any, 0}, 5312 { is_string, "string" },
5366 { is_string, "string" }, 5313 { is_symbol, "symbol" },
5367 { is_symbol, "symbol" }, 5314 { is_port, "port" },
5368 { is_port, "port" },
5369 { is_inport, "input port" }, 5315 { is_inport, "input port" },
5370 { is_outport, "output port" }, 5316 { is_outport, "output port" },
5371 { is_environment, "environment" }, 5317 { is_environment, "environment" },
5372 { is_pair, "pair" }, 5318 { is_pair, "pair" },
5373 { 0, "pair or '()" }, 5319 { tst_is_list, "pair or '()" },
5374 { is_character, "character" }, 5320 { is_character, "character" },
5375 { is_vector, "vector" }, 5321 { is_vector, "vector" },
5376 { is_number, "number" }, 5322 { is_number, "number" },
5377 { is_integer, "integer" }, 5323 { is_integer, "integer" },
5378 { is_nonneg, "non-negative integer" } 5324 { is_nonneg, "non-negative integer" }
5379}; 5325};
5380 5326
5381#define TST_NONE 0 5327#define TST_NONE 0 /* TST_NONE used for built-ins, 0 for internal ops */
5382#define TST_ANY "\001" 5328#define TST_ANY "\001"
5383#define TST_STRING "\002" 5329#define TST_STRING "\002"
5384#define TST_SYMBOL "\003" 5330#define TST_SYMBOL "\003"
5385#define TST_PORT "\004" 5331#define TST_PORT "\004"
5386#define TST_INPORT "\005" 5332#define TST_INPORT "\005"
5387#define TST_OUTPORT "\006" 5333#define TST_OUTPORT "\006"
5388#define TST_ENVIRONMENT "\007" 5334#define TST_ENVIRONMENT "\007"
5389#define TST_PAIR "\010" 5335#define TST_PAIR "\010"
5390#define TST_LIST "\011" 5336#define TST_LIST "\011"
5391#define TST_CHAR "\012" 5337#define TST_CHAR "\012"
5392#define TST_VECTOR "\013" 5338#define TST_VECTOR "\013"
5393#define TST_NUMBER "\014" 5339#define TST_NUMBER "\014"
5394#define TST_INTEGER "\015" 5340#define TST_INTEGER "\015"
5395#define TST_NATURAL "\016" 5341#define TST_NATURAL "\016"
5342
5343#define INF_ARG 0xff
5344#define UNNAMED_OP ""
5345
5346static const char opnames[] =
5347#define OP_DEF(func,name,minarity,maxarity,argtest,op) name "\x00"
5348#include "opdefines.h"
5349#undef OP_DEF
5350;
5351
5352static const char *
5353opname (int idx)
5354{
5355 const char *name = opnames;
5356
5357 /* should do this at compile time, but would require external program, right? */
5358 while (idx--)
5359 name += strlen (name) + 1;
5360
5361 return *name ? name : "ILLEGAL";
5362}
5363
5364static const char *
5365procname (pointer x)
5366{
5367 return opname (procnum (x));
5368}
5396 5369
5397typedef struct 5370typedef struct
5398{ 5371{
5399 dispatch_func func; 5372 uint8_t func;
5400 char *name; 5373 /*dispatch_func func;*//*TODO: maybe optionally keep the pointer, for speed? */
5374 uint8_t builtin;
5401 int min_arity; 5375 uint8_t min_arity;
5402 int max_arity; 5376 uint8_t max_arity;
5403 char *arg_tests_encoding; 5377 char arg_tests_encoding[3];
5404} op_code_info; 5378} op_code_info;
5405 5379
5406#define INF_ARG 0xffff
5407
5408static op_code_info dispatch_table[] = { 5380static const op_code_info dispatch_table[] = {
5409#define OP_DEF(A,B,C,D,E,OP) {A,B,C,D,E}, 5381#define OP_DEF(func,name,minarity,maxarity,argtest,op) { func, sizeof (name) > 1, minarity, maxarity, argtest },
5410#include "opdefines.h" 5382#include "opdefines.h"
5383#undef OP_DEF
5411 {0} 5384 {0}
5412}; 5385};
5413 5386
5414static const char *
5415procname (pointer x)
5416{
5417 int n = procnum (x);
5418 const char *name = dispatch_table[n].name;
5419
5420 if (name == 0)
5421 name = "ILLEGAL!";
5422
5423 return name;
5424}
5425
5426/* kernel of this interpreter */ 5387/* kernel of this interpreter */
5427static void 5388static void ecb_hot
5428Eval_Cycle (SCHEME_P_ enum scheme_opcodes op) 5389Eval_Cycle (SCHEME_P_ enum scheme_opcodes op)
5429{ 5390{
5430 SCHEME_V->op = op; 5391 SCHEME_V->op = op;
5431 5392
5432 for (;;) 5393 for (;;)
5433 { 5394 {
5434 op_code_info *pcd = dispatch_table + SCHEME_V->op; 5395 const op_code_info *pcd = dispatch_table + SCHEME_V->op;
5435 5396
5436#if USE_ERROR_CHECKING 5397#if USE_ERROR_CHECKING
5437 if (pcd->name) /* if built-in function, check arguments */ 5398 if (pcd->builtin) /* if built-in function, check arguments */
5438 { 5399 {
5439 int ok = 1;
5440 char msg[STRBUFFSIZE]; 5400 char msg[STRBUFFSIZE];
5441 int n = list_length (SCHEME_A_ SCHEME_V->args); 5401 int n = list_length (SCHEME_A_ SCHEME_V->args);
5442 5402
5443 /* Check number of arguments */ 5403 /* Check number of arguments */
5444 if (ecb_expect_false (n < pcd->min_arity)) 5404 if (ecb_expect_false (n < pcd->min_arity))
5445 { 5405 {
5446 ok = 0;
5447 snprintf (msg, STRBUFFSIZE, "%s: needs%s %d argument(s)", 5406 snprintf (msg, STRBUFFSIZE, "%s: needs%s %d argument(s)",
5448 pcd->name, pcd->min_arity == pcd->max_arity ? "" : " at least", pcd->min_arity); 5407 opname (SCHEME_V->op), pcd->min_arity == pcd->max_arity ? "" : " at least", pcd->min_arity);
5408 xError_1 (SCHEME_A_ msg, 0);
5409 continue;
5449 } 5410 }
5450 else if (ecb_excpect_false (n > pcd->max_arity)) 5411 else if (ecb_expect_false (n > pcd->max_arity && pcd->max_arity != INF_ARG))
5451 { 5412 {
5452 ok = 0;
5453 snprintf (msg, STRBUFFSIZE, "%s: needs%s %d argument(s)", 5413 snprintf (msg, STRBUFFSIZE, "%s: needs%s %d argument(s)",
5454 pcd->name, pcd->min_arity == pcd->max_arity ? "" : " at most", pcd->max_arity); 5414 opname (SCHEME_V->op), pcd->min_arity == pcd->max_arity ? "" : " at most", pcd->max_arity);
5415 xError_1 (SCHEME_A_ msg, 0);
5416 continue;
5455 } 5417 }
5456 5418 else
5457 if (ecb_expect_false (ok))
5458 { 5419 {
5459 if (pcd->arg_tests_encoding) 5420 if (*pcd->arg_tests_encoding) /* literal 0 and TST_NONE treated the same */
5460 { 5421 {
5461 int i = 0; 5422 int i = 0;
5462 int j; 5423 int j;
5463 const char *t = pcd->arg_tests_encoding; 5424 const char *t = pcd->arg_tests_encoding;
5464 pointer arglist = SCHEME_V->args; 5425 pointer arglist = SCHEME_V->args;
5465 5426
5466 do 5427 do
5467 { 5428 {
5468 pointer arg = car (arglist); 5429 pointer arg = car (arglist);
5469 5430
5470 j = (int) t[0]; 5431 j = t[0];
5471 5432
5472 if (j == TST_LIST[0]) 5433 if (!tests[j - 1].fct (arg))
5473 {
5474 if (arg != NIL && !is_pair (arg))
5475 break; 5434 break;
5476 }
5477 else
5478 {
5479 if (!tests[j].fct (arg))
5480 break;
5481 }
5482 5435
5483 if (t[1] != 0) /* last test is replicated as necessary */ 5436 if (t[1]) /* last test is replicated as necessary */
5484 t++; 5437 t++;
5485 5438
5486 arglist = cdr (arglist); 5439 arglist = cdr (arglist);
5487 i++; 5440 i++;
5488 } 5441 }
5489 while (i < n); 5442 while (i < n);
5490 5443
5491 if (i < n) 5444 if (i < n)
5492 { 5445 {
5493 ok = 0;
5494 snprintf (msg, STRBUFFSIZE, "%s: argument %d must be: %s", pcd->name, i + 1, tests[j].kind); 5446 snprintf (msg, STRBUFFSIZE, "%s: argument %d must be: %s", opname (SCHEME_V->op), i + 1, tests[j].kind);
5447 xError_1 (SCHEME_A_ msg, 0);
5448 continue;
5495 } 5449 }
5496 } 5450 }
5497 } 5451 }
5498
5499 if (!ok)
5500 {
5501 if (xError_1 (SCHEME_A_ msg, 0) == NIL)
5502 return;
5503
5504 pcd = dispatch_table + SCHEME_V->op;
5505 }
5506 } 5452 }
5507#endif 5453#endif
5508 5454
5509 ok_to_freely_gc (SCHEME_A); 5455 ok_to_freely_gc (SCHEME_A);
5510 5456
5457 static const dispatch_func dispatch_funcs[] = {
5458 opexe_0,
5459 opexe_1,
5460 opexe_2,
5461 opexe_3,
5462 opexe_4,
5463 opexe_5,
5464 opexe_6,
5465 };
5466
5511 if (ecb_expect_false (pcd->func (SCHEME_A_ SCHEME_V->op) == NIL)) 5467 if (ecb_expect_false (dispatch_funcs [pcd->func] (SCHEME_A_ SCHEME_V->op) != 0))
5512 return; 5468 return;
5513 5469
5514 if (SCHEME_V->no_memory && USE_ERROR_CHECKING) 5470 if (SCHEME_V->no_memory && USE_ERROR_CHECKING)
5515 { 5471 {
5516 xwrstr ("No memory!\n"); 5472 xwrstr ("No memory!\n");
5615 return OP_C0STREAM; /* cons-stream */ 5571 return OP_C0STREAM; /* cons-stream */
5616 } 5572 }
5617} 5573}
5618 5574
5619#if USE_MULTIPLICITY 5575#if USE_MULTIPLICITY
5620scheme * 5576ecb_cold scheme *
5621scheme_init_new () 5577scheme_init_new ()
5622{ 5578{
5623 scheme *sc = malloc (sizeof (scheme)); 5579 scheme *sc = malloc (sizeof (scheme));
5624 5580
5625 if (!scheme_init (SCHEME_A)) 5581 if (!scheme_init (SCHEME_A))
5630 else 5586 else
5631 return sc; 5587 return sc;
5632} 5588}
5633#endif 5589#endif
5634 5590
5635int 5591ecb_cold int
5636scheme_init (SCHEME_P) 5592scheme_init (SCHEME_P)
5637{ 5593{
5638 int i, n = sizeof (dispatch_table) / sizeof (dispatch_table[0]); 5594 int i, n = sizeof (dispatch_table) / sizeof (dispatch_table[0]);
5639 pointer x; 5595 pointer x;
5640 5596
5713 5669
5714 for (i = 0; i < sizeof (syntax_names) / sizeof (*syntax_names); ++i) 5670 for (i = 0; i < sizeof (syntax_names) / sizeof (*syntax_names); ++i)
5715 assign_syntax (SCHEME_A_ syntax_names[i]); 5671 assign_syntax (SCHEME_A_ syntax_names[i]);
5716 } 5672 }
5717 5673
5674 // TODO: should iterate via strlen, to avoid n² complexity
5718 for (i = 0; i < n; i++) 5675 for (i = 0; i < n; i++)
5719 if (dispatch_table[i].name != 0) 5676 if (dispatch_table[i].builtin)
5720 assign_proc (SCHEME_A_ i, dispatch_table[i].name); 5677 assign_proc (SCHEME_A_ i, opname (i));
5721 5678
5722 /* initialization of global pointers to special symbols */ 5679 /* initialization of global pointers to special symbols */
5723 SCHEME_V->LAMBDA = mk_symbol (SCHEME_A_ "lambda"); 5680 SCHEME_V->LAMBDA = mk_symbol (SCHEME_A_ "lambda");
5724 SCHEME_V->QUOTE = mk_symbol (SCHEME_A_ "quote"); 5681 SCHEME_V->QUOTE = mk_symbol (SCHEME_A_ "quote");
5725 SCHEME_V->QQUOTE = mk_symbol (SCHEME_A_ "quasiquote"); 5682 SCHEME_V->QQUOTE = mk_symbol (SCHEME_A_ "quasiquote");
5764scheme_set_external_data (SCHEME_P_ void *p) 5721scheme_set_external_data (SCHEME_P_ void *p)
5765{ 5722{
5766 SCHEME_V->ext_data = p; 5723 SCHEME_V->ext_data = p;
5767} 5724}
5768 5725
5769void 5726ecb_cold void
5770scheme_deinit (SCHEME_P) 5727scheme_deinit (SCHEME_P)
5771{ 5728{
5772 int i; 5729 int i;
5773 5730
5774#if SHOW_ERROR_LINE 5731#if SHOW_ERROR_LINE
5866{ 5823{
5867 dump_stack_reset (SCHEME_A); 5824 dump_stack_reset (SCHEME_A);
5868 SCHEME_V->envir = SCHEME_V->global_env; 5825 SCHEME_V->envir = SCHEME_V->global_env;
5869 SCHEME_V->file_i = 0; 5826 SCHEME_V->file_i = 0;
5870 SCHEME_V->load_stack[0].kind = port_input | port_string; 5827 SCHEME_V->load_stack[0].kind = port_input | port_string;
5871 SCHEME_V->load_stack[0].rep.string.start = (char *) cmd; /* This func respects const */ 5828 SCHEME_V->load_stack[0].rep.string.start = (char *)cmd; /* This func respects const */
5872 SCHEME_V->load_stack[0].rep.string.past_the_end = (char *) cmd + strlen (cmd); 5829 SCHEME_V->load_stack[0].rep.string.past_the_end = (char *)cmd + strlen (cmd);
5873 SCHEME_V->load_stack[0].rep.string.curr = (char *) cmd; 5830 SCHEME_V->load_stack[0].rep.string.curr = (char *)cmd;
5874#if USE_PORTS 5831#if USE_PORTS
5875 SCHEME_V->loadport = mk_port (SCHEME_A_ SCHEME_V->load_stack); 5832 SCHEME_V->loadport = mk_port (SCHEME_A_ SCHEME_V->load_stack);
5876#endif 5833#endif
5877 SCHEME_V->retcode = 0; 5834 SCHEME_V->retcode = 0;
5878 SCHEME_V->interactive_repl = 0; 5835 SCHEME_V->interactive_repl = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines