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.24 by root, Fri Nov 27 02:12:08 2015 UTC vs.
Revision 1.26 by root, Sat Nov 28 05:12:53 2015 UTC

182# define FIRST_CELLSEGS 3 182# define FIRST_CELLSEGS 3
183#endif 183#endif
184 184
185enum scheme_types 185enum scheme_types
186{ 186{
187 T_INTEGER,
187 T_FREE, 188 T_REAL,
188 T_STRING, 189 T_STRING,
189 T_NUMBER,
190 T_SYMBOL, 190 T_SYMBOL,
191 T_PROC, 191 T_PROC,
192 T_PAIR, 192 T_PAIR, /* also used for free cells */
193 T_CLOSURE, 193 T_CLOSURE,
194 T_CONTINUATION, 194 T_CONTINUATION,
195 T_FOREIGN, 195 T_FOREIGN,
196 T_CHARACTER, 196 T_CHARACTER,
197 T_PORT, 197 T_PORT,
207#define T_SYNTAX 0x0010 207#define T_SYNTAX 0x0010
208#define T_IMMUTABLE 0x0020 208#define T_IMMUTABLE 0x0020
209#define T_ATOM 0x0040 /* only for gc */ 209#define T_ATOM 0x0040 /* only for gc */
210#define T_MARK 0x0080 /* only for gc */ 210#define T_MARK 0x0080 /* only for gc */
211 211
212/* num, for generic arithmetic */
213struct num
214{
215 IVALUE ivalue;
216#if USE_REAL
217 RVALUE rvalue;
218 char is_fixnum;
219#endif
220};
221
222#if USE_REAL
223# define num_is_fixnum(n) (n).is_fixnum
224# define num_set_fixnum(n,f) (n).is_fixnum = (f)
225# define num_ivalue(n) (n).ivalue
226# define num_rvalue(n) (n).rvalue
227# define num_set_ivalue(n,i) (n).rvalue = (n).ivalue = (i)
228# define num_set_rvalue(n,r) (n).rvalue = (r)
229#else
230# define num_is_fixnum(n) 1
231# define num_set_fixnum(n,f) 0
232# define num_ivalue(n) (n).ivalue
233# define num_rvalue(n) (n).ivalue
234# define num_set_ivalue(n,i) (n).ivalue = (i)
235# define num_set_rvalue(n,r) (n).ivalue = (r)
236#endif
237
212enum num_op { NUM_ADD, NUM_SUB, NUM_MUL, NUM_INTDIV }; 238enum num_op { NUM_ADD, NUM_SUB, NUM_MUL, NUM_INTDIV };
213 239
214static num num_op (enum num_op op, num a, num b); 240static num num_op (enum num_op op, num a, num b);
215static num num_intdiv (num a, num b); 241static num num_intdiv (num a, num b);
216static num num_rem (num a, num b); 242static num num_rem (num a, num b);
219#if USE_MATH 245#if USE_MATH
220static double round_per_R5RS (double x); 246static double round_per_R5RS (double x);
221#endif 247#endif
222static int is_zero_rvalue (RVALUE x); 248static int is_zero_rvalue (RVALUE x);
223 249
224ecb_inline int
225num_is_integer (pointer p)
226{
227 return num_is_fixnum (p->object.number);
228}
229
230static num num_zero; 250static num num_zero;
231static num num_one; 251static num num_one;
232 252
233/* macros for cell operations */ 253/* macros for cell operations */
234#define typeflag(p) ((p)->flag + 0) 254#define typeflag(p) ((p)->flag + 0)
241 return type (p) == T_STRING; 261 return type (p) == T_STRING;
242} 262}
243 263
244#define strvalue(p) ((p)->object.string.svalue) 264#define strvalue(p) ((p)->object.string.svalue)
245#define strlength(p) ((p)->object.string.length) 265#define strlength(p) ((p)->object.string.length)
246
247INTERFACE int is_list (SCHEME_P_ pointer p);
248 266
249INTERFACE int 267INTERFACE int
250is_vector (pointer p) 268is_vector (pointer p)
251{ 269{
252 return type (p) == T_VECTOR; 270 return type (p) == T_VECTOR;
264{ 282{
265 return vec->object.vector.length; 283 return vec->object.vector.length;
266} 284}
267 285
268INTERFACE int 286INTERFACE int
269is_number (pointer p)
270{
271 return type (p) == T_NUMBER;
272}
273
274INTERFACE int
275is_integer (pointer p) 287is_integer (pointer p)
276{ 288{
277 if (!is_number (p)) 289 return type (p) == T_INTEGER;
278 return 0;
279
280 if (num_is_integer (p) || ivalue (p) == rvalue (p))
281 return 1;
282
283 return 0;
284} 290}
285 291
292/* not the same as in scheme, where integers are (correctly :) reals */
286INTERFACE int 293INTERFACE int
287is_real (pointer p) 294is_real (pointer p)
288{ 295{
289 return is_number (p) && !num_is_fixnum (p->object.number); 296 return type (p) == T_REAL;
297}
298
299INTERFACE int
300is_number (pointer p)
301{
302 return is_integer (p) || is_real (p);
290} 303}
291 304
292INTERFACE int 305INTERFACE int
293is_character (pointer p) 306is_character (pointer p)
294{ 307{
299string_value (pointer p) 312string_value (pointer p)
300{ 313{
301 return strvalue (p); 314 return strvalue (p);
302} 315}
303 316
304ecb_inline num
305nvalue (pointer p)
306{
307 return (p)->object.number;
308}
309
310static IVALUE
311num_get_ivalue (const num n)
312{
313 return num_is_fixnum (n) ? num_ivalue (n) : (IVALUE)num_rvalue (n);
314}
315
316static RVALUE
317num_get_rvalue (const num n)
318{
319 return num_is_fixnum (n) ? (RVALUE)num_ivalue (n) : num_rvalue (n);
320}
321
322INTERFACE IVALUE
323ivalue (pointer p)
324{
325 return num_get_ivalue (p->object.number);
326}
327
328INTERFACE RVALUE
329rvalue (pointer p)
330{
331 return num_get_rvalue (p->object.number);
332}
333
334#define ivalue_unchecked(p) ((p)->object.number.value.ivalue) 317#define ivalue_unchecked(p) (p)->object.ivalue
318#define set_ivalue(p,v) (p)->object.ivalue = (v)
319
335#if USE_REAL 320#if USE_REAL
336# define rvalue_unchecked(p) ((p)->object.number.value.rvalue) 321#define rvalue_unchecked(p) (p)->object.rvalue
337# define set_num_integer(p) (p)->object.number.is_fixnum=1; 322#define set_rvalue(p,v) (p)->object.rvalue = (v)
338# define set_num_real(p) (p)->object.number.is_fixnum=0;
339#else 323#else
340# define rvalue_unchecked(p) ((p)->object.number.value.ivalue) 324#define rvalue_unchecked(p) (p)->object.ivalue
341# define set_num_integer(p) 0 325#define set_rvalue(p,v) (p)->object.ivalue = (v)
342# define set_num_real(p) 0
343#endif 326#endif
344 327
345INTERFACE long 328INTERFACE long
346charvalue (pointer p) 329charvalue (pointer p)
347{ 330{
452syntaxname (pointer p) 435syntaxname (pointer p)
453{ 436{
454 return strvalue (car (p)); 437 return strvalue (car (p));
455} 438}
456 439
457#define procnum(p) ivalue (p) 440#define procnum(p) ivalue_unchecked (p)
458static const char *procname (pointer x); 441static const char *procname (pointer x);
459 442
460INTERFACE int 443INTERFACE int
461is_closure (pointer p) 444is_closure (pointer p)
462{ 445{
523setimmutable (pointer p) 506setimmutable (pointer p)
524{ 507{
525#if USE_ERROR_CHECKING 508#if USE_ERROR_CHECKING
526 set_typeflag (p, typeflag (p) | T_IMMUTABLE); 509 set_typeflag (p, typeflag (p) | T_IMMUTABLE);
527#endif 510#endif
511}
512
513/* Result is:
514 proper list: length
515 circular list: -1
516 not even a pair: -2
517 dotted list: -2 minus length before dot
518*/
519INTERFACE int
520list_length (SCHEME_P_ pointer a)
521{
522 int i = 0;
523 pointer slow, fast;
524
525 slow = fast = a;
526
527 while (1)
528 {
529 if (fast == NIL)
530 return i;
531
532 if (!is_pair (fast))
533 return -2 - i;
534
535 fast = cdr (fast);
536 ++i;
537
538 if (fast == NIL)
539 return i;
540
541 if (!is_pair (fast))
542 return -2 - i;
543
544 ++i;
545 fast = cdr (fast);
546
547 /* Safe because we would have already returned if `fast'
548 encountered a non-pair. */
549 slow = cdr (slow);
550
551 if (fast == slow)
552 {
553 /* the fast pointer has looped back around and caught up
554 with the slow pointer, hence the structure is circular,
555 not of finite length, and therefore not a list */
556 return -1;
557 }
558 }
559}
560
561INTERFACE int
562is_list (SCHEME_P_ pointer a)
563{
564 return list_length (SCHEME_A_ a) >= 0;
528} 565}
529 566
530#if USE_CHAR_CLASSIFIERS 567#if USE_CHAR_CLASSIFIERS
531ecb_inline int 568ecb_inline int
532Cisalpha (int c) 569Cisalpha (int c)
676static void Eval_Cycle (SCHEME_P_ enum scheme_opcodes op); 713static void Eval_Cycle (SCHEME_P_ enum scheme_opcodes op);
677static void assign_syntax (SCHEME_P_ const char *name); 714static void assign_syntax (SCHEME_P_ const char *name);
678static int syntaxnum (pointer p); 715static int syntaxnum (pointer p);
679static void assign_proc (SCHEME_P_ enum scheme_opcodes, const char *name); 716static void assign_proc (SCHEME_P_ enum scheme_opcodes, const char *name);
680 717
718static IVALUE
719ivalue (pointer x)
720{
721 return is_integer (x) ? ivalue_unchecked (x) : rvalue_unchecked (x);
722}
723
724static RVALUE
725rvalue (pointer x)
726{
727 return is_integer (x) ? ivalue_unchecked (x) : rvalue_unchecked (x);
728}
729
730INTERFACE num
731nvalue (pointer x)
732{
733 num n;
734
735 num_set_fixnum (n, is_integer (x));
736
737 if (num_is_fixnum (n))
738 num_set_ivalue (n, ivalue_unchecked (x));
739 else
740 num_set_rvalue (n, rvalue_unchecked (x));
741
742 return n;
743}
744
681static num 745static num
682num_op (enum num_op op, num a, num b) 746num_op (enum num_op op, num a, num b)
683{ 747{
684 num ret; 748 num ret;
685 749
686 num_set_fixnum (ret, num_is_fixnum (a) && num_is_fixnum (b)); 750 num_set_fixnum (ret, num_is_fixnum (a) && num_is_fixnum (b));
687 751
688 if (num_is_fixnum (ret)) 752 if (num_is_fixnum (ret))
689 { 753 {
690 IVALUE av = num_get_ivalue (a);
691 IVALUE bv = num_get_ivalue (b);
692
693 switch (op) 754 switch (op)
694 { 755 {
695 case NUM_ADD: av += bv; break; 756 case NUM_ADD: a.ivalue += b.ivalue; break;
696 case NUM_SUB: av -= bv; break; 757 case NUM_SUB: a.ivalue -= b.ivalue; break;
697 case NUM_MUL: av *= bv; break; 758 case NUM_MUL: a.ivalue *= b.ivalue; break;
698 case NUM_INTDIV: av /= bv; break; 759 case NUM_INTDIV: a.ivalue /= b.ivalue; break;
699 } 760 }
700 761
701 num_set_ivalue (ret, av); 762 num_set_ivalue (ret, a.ivalue);
702 } 763 }
764#if USE_REAL
703 else 765 else
704 { 766 {
705 RVALUE av = num_get_rvalue (a);
706 RVALUE bv = num_get_rvalue (b);
707
708 switch (op) 767 switch (op)
709 { 768 {
710 case NUM_ADD: av += bv; break; 769 case NUM_ADD: a.rvalue += b.rvalue; break;
711 case NUM_SUB: av -= bv; break; 770 case NUM_SUB: a.rvalue -= b.rvalue; break;
712 case NUM_MUL: av *= bv; break; 771 case NUM_MUL: a.rvalue *= b.rvalue; break;
713 case NUM_INTDIV: av /= bv; break; 772 case NUM_INTDIV: a.rvalue /= b.rvalue; break;
714 } 773 }
715 774
716 num_set_rvalue (ret, av); 775 num_set_rvalue (ret, a.rvalue);
717 } 776 }
777#endif
718 778
719 return ret; 779 return ret;
720} 780}
721 781
722static num 782static num
723num_div (num a, num b) 783num_div (num a, num b)
724{ 784{
725 num ret; 785 num ret;
726 786
727 num_set_fixnum (ret, num_is_fixnum (a) && num_is_fixnum (b) && num_get_ivalue (a) % num_get_ivalue (b) == 0); 787 num_set_fixnum (ret, num_is_fixnum (a) && num_is_fixnum (b) && num_ivalue (a) % num_ivalue (b) == 0);
728 788
729 if (num_is_fixnum (ret)) 789 if (num_is_fixnum (ret))
730 num_set_ivalue (ret, num_get_ivalue (a) / num_get_ivalue (b)); 790 num_set_ivalue (ret, num_ivalue (a) / num_ivalue (b));
731 else 791 else
732 num_set_rvalue (ret, num_get_rvalue (a) / num_get_rvalue (b)); 792 num_set_rvalue (ret, num_rvalue (a) / num_rvalue (b));
733 793
734 return ret; 794 return ret;
735} 795}
736 796
737static num 797static num
739{ 799{
740 num ret; 800 num ret;
741 long e1, e2, res; 801 long e1, e2, res;
742 802
743 num_set_fixnum (ret, num_is_fixnum (a) && num_is_fixnum (b)); 803 num_set_fixnum (ret, num_is_fixnum (a) && num_is_fixnum (b));
744 e1 = num_get_ivalue (a); 804 e1 = num_ivalue (a);
745 e2 = num_get_ivalue (b); 805 e2 = num_ivalue (b);
746 res = e1 % e2; 806 res = e1 % e2;
747 807
748 /* remainder should have same sign as second operand */ 808 /* remainder should have same sign as second operand */
749 if (res > 0) 809 if (res > 0)
750 { 810 {
766{ 826{
767 num ret; 827 num ret;
768 long e1, e2, res; 828 long e1, e2, res;
769 829
770 num_set_fixnum (ret, num_is_fixnum (a) && num_is_fixnum (b)); 830 num_set_fixnum (ret, num_is_fixnum (a) && num_is_fixnum (b));
771 e1 = num_get_ivalue (a); 831 e1 = num_ivalue (a);
772 e2 = num_get_ivalue (b); 832 e2 = num_ivalue (b);
773 res = e1 % e2; 833 res = e1 % e2;
774 834
775 /* modulo should have same sign as second operand */ 835 /* modulo should have same sign as second operand */
776 if (res * e2 < 0) 836 if (res * e2 < 0)
777 res += e2; 837 res += e2;
787 int is_fixnum = num_is_fixnum (a) && num_is_fixnum (b); 847 int is_fixnum = num_is_fixnum (a) && num_is_fixnum (b);
788 int ret; 848 int ret;
789 849
790 if (is_fixnum) 850 if (is_fixnum)
791 { 851 {
792 IVALUE av = num_get_ivalue (a); 852 IVALUE av = num_ivalue (a);
793 IVALUE bv = num_get_ivalue (b); 853 IVALUE bv = num_ivalue (b);
794 854
795 ret = av == bv ? 0 : av < bv ? -1 : +1; 855 ret = av == bv ? 0 : av < bv ? -1 : +1;
796 } 856 }
797 else 857 else
798 { 858 {
799 RVALUE av = num_get_rvalue (a); 859 RVALUE av = num_rvalue (a);
800 RVALUE bv = num_get_rvalue (b); 860 RVALUE bv = num_rvalue (b);
801 861
802 ret = av == bv ? 0 : av < bv ? -1 : +1; 862 ret = av == bv ? 0 : av < bv ? -1 : +1;
803 } 863 }
804 864
805 return ret; 865 return ret;
892 SCHEME_V->fcells += segsize; 952 SCHEME_V->fcells += segsize;
893 last = newp + segsize - 1; 953 last = newp + segsize - 1;
894 954
895 for (p = newp; p <= last; p++) 955 for (p = newp; p <= last; p++)
896 { 956 {
897 set_typeflag (p, T_FREE); 957 set_typeflag (p, T_PAIR);
898 set_car (p, NIL); 958 set_car (p, NIL);
899 set_cdr (p, p + 1); 959 set_cdr (p, p + 1);
900 } 960 }
901 961
902 /* insert new cells in address order on free list */ 962 /* insert new cells in address order on free list */
1193mk_character (SCHEME_P_ int c) 1253mk_character (SCHEME_P_ int c)
1194{ 1254{
1195 pointer x = get_cell (SCHEME_A_ NIL, NIL); 1255 pointer x = get_cell (SCHEME_A_ NIL, NIL);
1196 1256
1197 set_typeflag (x, (T_CHARACTER | T_ATOM)); 1257 set_typeflag (x, (T_CHARACTER | T_ATOM));
1198 ivalue_unchecked (x) = c & 0xff; 1258 set_ivalue (x, c & 0xff);
1199 set_num_integer (x); 1259
1200 return x; 1260 return x;
1201} 1261}
1202 1262
1203/* get number atom (integer) */ 1263/* get number atom (integer) */
1204INTERFACE pointer 1264INTERFACE pointer
1205mk_integer (SCHEME_P_ long num) 1265mk_integer (SCHEME_P_ long n)
1206{ 1266{
1207 pointer x = get_cell (SCHEME_A_ NIL, NIL); 1267 pointer x = get_cell (SCHEME_A_ NIL, NIL);
1208 1268
1209 set_typeflag (x, (T_NUMBER | T_ATOM)); 1269 set_typeflag (x, (T_INTEGER | T_ATOM));
1210 ivalue_unchecked (x) = num; 1270 set_ivalue (x, n);
1211 set_num_integer (x); 1271
1212 return x; 1272 return x;
1213} 1273}
1214 1274
1215INTERFACE pointer 1275INTERFACE pointer
1216mk_real (SCHEME_P_ RVALUE n) 1276mk_real (SCHEME_P_ RVALUE n)
1217{ 1277{
1278#if USE_REAL
1218 pointer x = get_cell (SCHEME_A_ NIL, NIL); 1279 pointer x = get_cell (SCHEME_A_ NIL, NIL);
1219 1280
1220 set_typeflag (x, (T_NUMBER | T_ATOM)); 1281 set_typeflag (x, (T_REAL | T_ATOM));
1221 rvalue_unchecked (x) = n; 1282 set_rvalue (x, n);
1222 set_num_real (x); 1283
1223 return x; 1284 return x;
1285#else
1286 return mk_integer (SCHEME_A_ n);
1287#endif
1224} 1288}
1225 1289
1226static pointer 1290static pointer
1227mk_number (SCHEME_P_ const num n) 1291mk_number (SCHEME_P_ const num n)
1228{ 1292{
1293#if USE_REAL
1229 if (num_is_fixnum (n)) 1294 return num_is_fixnum (n)
1295 ? mk_integer (SCHEME_A_ num_ivalue (n))
1296 : mk_real (SCHEME_A_ num_rvalue (n));
1297#else
1230 return mk_integer (SCHEME_A_ num_get_ivalue (n)); 1298 return mk_integer (SCHEME_A_ num_ivalue (n));
1231 else 1299#endif
1232 return mk_real (SCHEME_A_ num_get_rvalue (n));
1233} 1300}
1234 1301
1235/* allocate name to string area */ 1302/* allocate name to string area */
1236static char * 1303static char *
1237store_string (SCHEME_P_ uint32_t len_str, const char *str, char fill) 1304store_string (SCHEME_P_ uint32_t len_str, const char *str, char fill)
1413 } 1480 }
1414 else if ((c == 'e') || (c == 'E')) 1481 else if ((c == 'e') || (c == 'E'))
1415 { 1482 {
1416 if (!has_fp_exp) 1483 if (!has_fp_exp)
1417 { 1484 {
1418 has_dec_point = 1; /* decimal point illegal 1485 has_dec_point = 1; /* decimal point illegal from now on */
1419 from now on */
1420 p++; 1486 p++;
1421 1487
1422 if ((*p == '-') || (*p == '+') || isdigit (*p)) 1488 if ((*p == '-') || (*p == '+') || isdigit (*p))
1423 continue; 1489 continue;
1424 } 1490 }
1620 if (is_mark (p)) 1686 if (is_mark (p))
1621 clrmark (p); 1687 clrmark (p);
1622 else 1688 else
1623 { 1689 {
1624 /* reclaim cell */ 1690 /* reclaim cell */
1625 if (typeflag (p) != T_FREE) 1691 if (typeflag (p) != T_PAIR)
1626 { 1692 {
1627 finalize_cell (SCHEME_A_ p); 1693 finalize_cell (SCHEME_A_ p);
1628 set_typeflag (p, T_FREE); 1694 set_typeflag (p, T_PAIR);
1629 set_car (p, NIL); 1695 set_car (p, NIL);
1630 } 1696 }
1631 1697
1632 ++SCHEME_V->fcells; 1698 ++SCHEME_V->fcells;
1633 set_cdr (p, SCHEME_V->free_cell); 1699 set_cdr (p, SCHEME_V->free_cell);
1635 } 1701 }
1636 } 1702 }
1637 } 1703 }
1638 1704
1639 if (SCHEME_V->gc_verbose) 1705 if (SCHEME_V->gc_verbose)
1706 {
1640 xwrstr ("done: "); xwrnum (SCHEME_V->fcells); xwrstr (" cells were recovered.\n"); 1707 xwrstr ("done: "); xwrnum (SCHEME_V->fcells); xwrstr (" cells were recovered.\n");
1708 }
1641} 1709}
1642 1710
1643static void 1711static void
1644finalize_cell (SCHEME_P_ pointer a) 1712finalize_cell (SCHEME_P_ pointer a)
1645{ 1713{
2480 { 2548 {
2481 p = SCHEME_V->strbuff; 2549 p = SCHEME_V->strbuff;
2482 2550
2483 if (f <= 1 || f == 10) /* f is the base for numbers if > 1 */ 2551 if (f <= 1 || f == 10) /* f is the base for numbers if > 1 */
2484 { 2552 {
2485 if (num_is_integer (l)) 2553 if (is_integer (l))
2486 xnum (p, ivalue_unchecked (l)); 2554 xnum (p, ivalue_unchecked (l));
2487#if USE_REAL 2555#if USE_REAL
2488 else 2556 else
2489 { 2557 {
2490 snprintf (p, STRBUFFSIZE, "%.10g", rvalue_unchecked (l)); 2558 snprintf (p, STRBUFFSIZE, "%.10g", rvalue_unchecked (l));
2745 return 0; 2813 return 0;
2746 } 2814 }
2747 else if (is_number (a)) 2815 else if (is_number (a))
2748 { 2816 {
2749 if (is_number (b)) 2817 if (is_number (b))
2750 if (num_is_integer (a) == num_is_integer (b))
2751 return num_cmp (nvalue (a), nvalue (b)) == 0; 2818 return num_cmp (nvalue (a), nvalue (b)) == 0;
2752 2819
2753 return 0; 2820 return 0;
2754 } 2821 }
2755 else if (is_character (a)) 2822 else if (is_character (a))
2756 { 2823 {
3132 int i = 0; 3199 int i = 0;
3133 struct dump_stack_frame *frame = SCHEME_V->dump_base; 3200 struct dump_stack_frame *frame = SCHEME_V->dump_base;
3134 3201
3135 while (cont != NIL) 3202 while (cont != NIL)
3136 { 3203 {
3137 frame->op = ivalue (car (cont)); cont = cdr (cont); 3204 frame->op = ivalue_unchecked (car (cont)); cont = cdr (cont);
3138 frame->args = car (cont) ; cont = cdr (cont); 3205 frame->args = car (cont) ; cont = cdr (cont);
3139 frame->envir = car (cont) ; cont = cdr (cont); 3206 frame->envir = car (cont) ; cont = cdr (cont);
3140 frame->code = car (cont) ; cont = cdr (cont); 3207 frame->code = car (cont) ; cont = cdr (cont);
3141 3208
3142 ++frame; 3209 ++frame;
3143 ++i; 3210 ++i;
3144 } 3211 }
3145 3212
3174 SCHEME_V->value = a; 3241 SCHEME_V->value = a;
3175 3242
3176 if (dump == NIL) 3243 if (dump == NIL)
3177 return -1; 3244 return -1;
3178 3245
3179 SCHEME_V->op = ivalue (car (dump)); dump = cdr (dump); 3246 SCHEME_V->op = ivalue_unchecked (car (dump)); dump = cdr (dump);
3180 SCHEME_V->args = car (dump) ; dump = cdr (dump); 3247 SCHEME_V->args = car (dump) ; dump = cdr (dump);
3181 SCHEME_V->envir = car (dump) ; dump = cdr (dump); 3248 SCHEME_V->envir = car (dump) ; dump = cdr (dump);
3182 SCHEME_V->code = car (dump) ; dump = cdr (dump); 3249 SCHEME_V->code = car (dump) ; dump = cdr (dump);
3183 3250
3184 SCHEME_V->dump = dump; 3251 SCHEME_V->dump = dump;
3185 3252
3186 return 0; 3253 return 0;
3187} 3254}
3393 3460
3394 case OP_TRACING: 3461 case OP_TRACING:
3395 { 3462 {
3396 int tr = SCHEME_V->tracing; 3463 int tr = SCHEME_V->tracing;
3397 3464
3398 SCHEME_V->tracing = ivalue (car (args)); 3465 SCHEME_V->tracing = ivalue_unchecked (car (args));
3399 s_return (mk_integer (SCHEME_A_ tr)); 3466 s_return (mk_integer (SCHEME_A_ tr));
3400 } 3467 }
3401 3468
3402#endif 3469#endif
3403 3470
3922{ 3989{
3923 pointer args = SCHEME_V->args; 3990 pointer args = SCHEME_V->args;
3924 pointer x = car (args); 3991 pointer x = car (args);
3925 num v; 3992 num v;
3926 3993
3927#if USE_MATH
3928 RVALUE dd;
3929#endif
3930
3931 switch (op) 3994 switch (op)
3932 { 3995 {
3933#if USE_MATH 3996#if USE_MATH
3934 case OP_INEX2EX: /* inexact->exact */ 3997 case OP_INEX2EX: /* inexact->exact */
3998 {
3935 if (num_is_integer (x)) 3999 if (is_integer (x))
3936 s_return (x); 4000 s_return (x);
3937 else if (modf (rvalue_unchecked (x), &dd) == 0) 4001
4002 RVALUE r = rvalue_unchecked (x);
4003
4004 if (r == (RVALUE)(IVALUE)r)
3938 s_return (mk_integer (SCHEME_A_ ivalue (x))); 4005 s_return (mk_integer (SCHEME_A_ rvalue_unchecked (x)));
3939 else 4006 else
3940 Error_1 ("inexact->exact: not integral:", x); 4007 Error_1 ("inexact->exact: not integral:", x);
4008 }
3941 4009
3942 case OP_EXP: s_return (mk_real (SCHEME_A_ exp (rvalue (x)))); 4010 case OP_EXP: s_return (mk_real (SCHEME_A_ exp (rvalue (x))));
3943 case OP_LOG: s_return (mk_real (SCHEME_A_ log (rvalue (x)))); 4011 case OP_LOG: s_return (mk_real (SCHEME_A_ log (rvalue (x))));
3944 case OP_SIN: s_return (mk_real (SCHEME_A_ sin (rvalue (x)))); 4012 case OP_SIN: s_return (mk_real (SCHEME_A_ sin (rvalue (x))));
3945 case OP_COS: s_return (mk_real (SCHEME_A_ cos (rvalue (x)))); 4013 case OP_COS: s_return (mk_real (SCHEME_A_ cos (rvalue (x))));
3963 { 4031 {
3964 RVALUE result; 4032 RVALUE result;
3965 int real_result = 1; 4033 int real_result = 1;
3966 pointer y = cadr (args); 4034 pointer y = cadr (args);
3967 4035
3968 if (num_is_integer (x) && num_is_integer (y)) 4036 if (is_integer (x) && is_integer (y))
3969 real_result = 0; 4037 real_result = 0;
3970 4038
3971 /* This 'if' is an R5RS compatibility fix. */ 4039 /* This 'if' is an R5RS compatibility fix. */
3972 /* NOTE: Remove this 'if' fix for R6RS. */ 4040 /* NOTE: Remove this 'if' fix for R6RS. */
3973 if (rvalue (x) == 0 && rvalue (y) < 0) 4041 if (rvalue (x) == 0 && rvalue (y) < 0)
3979 /* If the test fails, result is too big for integer. */ 4047 /* If the test fails, result is too big for integer. */
3980 if (!real_result) 4048 if (!real_result)
3981 { 4049 {
3982 long result_as_long = result; 4050 long result_as_long = result;
3983 4051
3984 if (result != (RVALUE) result_as_long) 4052 if (result != result_as_long)
3985 real_result = 1; 4053 real_result = 1;
3986 } 4054 }
3987 4055
3988 if (real_result) 4056 if (real_result)
3989 s_return (mk_real (SCHEME_A_ result)); 4057 s_return (mk_real (SCHEME_A_ result));
3994 case OP_FLOOR: s_return (mk_real (SCHEME_A_ floor (rvalue (x)))); 4062 case OP_FLOOR: s_return (mk_real (SCHEME_A_ floor (rvalue (x))));
3995 case OP_CEILING: s_return (mk_real (SCHEME_A_ ceil (rvalue (x)))); 4063 case OP_CEILING: s_return (mk_real (SCHEME_A_ ceil (rvalue (x))));
3996 4064
3997 case OP_TRUNCATE: 4065 case OP_TRUNCATE:
3998 { 4066 {
3999 RVALUE rvalue_of_x; 4067 RVALUE n = rvalue (x);
4000
4001 rvalue_of_x = rvalue (x);
4002
4003 if (rvalue_of_x > 0)
4004 s_return (mk_real (SCHEME_A_ floor (rvalue_of_x))); 4068 s_return (mk_real (SCHEME_A_ n > 0 ? floor (n) : ceil (n)));
4005 else
4006 s_return (mk_real (SCHEME_A_ ceil (rvalue_of_x)));
4007 } 4069 }
4008 4070
4009 case OP_ROUND: 4071 case OP_ROUND:
4010 if (num_is_integer (x)) 4072 if (is_integer (x))
4011 s_return (x); 4073 s_return (x);
4012 4074
4013 s_return (mk_real (SCHEME_A_ round_per_R5RS (rvalue (x)))); 4075 s_return (mk_real (SCHEME_A_ round_per_R5RS (rvalue (x))));
4014#endif 4076#endif
4015 4077
4135 } 4197 }
4136 else 4198 else
4137 Error_0 ("set-cdr!: unable to alter immutable pair"); 4199 Error_0 ("set-cdr!: unable to alter immutable pair");
4138 4200
4139 case OP_CHAR2INT: /* char->integer */ 4201 case OP_CHAR2INT: /* char->integer */
4140 s_return (mk_integer (SCHEME_A_ ivalue (x))); 4202 s_return (mk_integer (SCHEME_A_ ivalue_unchecked (x)));
4141 4203
4142 case OP_INT2CHAR: /* integer->char */ 4204 case OP_INT2CHAR: /* integer->char */
4143 s_return (mk_character (SCHEME_A_ ivalue (x))); 4205 s_return (mk_character (SCHEME_A_ ivalue_unchecked (x)));
4144 4206
4145 case OP_CHARUPCASE: 4207 case OP_CHARUPCASE:
4146 { 4208 {
4147 unsigned char c = ivalue (x); 4209 unsigned char c = ivalue_unchecked (x);
4148 c = toupper (c); 4210 c = toupper (c);
4149 s_return (mk_character (SCHEME_A_ c)); 4211 s_return (mk_character (SCHEME_A_ c));
4150 } 4212 }
4151 4213
4152 case OP_CHARDNCASE: 4214 case OP_CHARDNCASE:
4153 { 4215 {
4154 unsigned char c = ivalue (x); 4216 unsigned char c = ivalue_unchecked (x);
4155 c = tolower (c); 4217 c = tolower (c);
4156 s_return (mk_character (SCHEME_A_ c)); 4218 s_return (mk_character (SCHEME_A_ c));
4157 } 4219 }
4158 4220
4159 case OP_STR2SYM: /* string->symbol */ 4221 case OP_STR2SYM: /* string->symbol */
4236 Error_1 ("atom->string: not an atom:", x); 4298 Error_1 ("atom->string: not an atom:", x);
4237 } 4299 }
4238 4300
4239 case OP_MKSTRING: /* make-string */ 4301 case OP_MKSTRING: /* make-string */
4240 { 4302 {
4241 int fill = ' '; 4303 int fill = cdr (args) != NIL ? charvalue (cadr (args)) : ' ';
4242 int len;
4243
4244 len = ivalue (x); 4304 int len = ivalue_unchecked (x);
4245
4246 if (cdr (args) != NIL)
4247 fill = charvalue (cadr (args));
4248 4305
4249 s_return (mk_empty_string (SCHEME_A_ len, fill)); 4306 s_return (mk_empty_string (SCHEME_A_ len, fill));
4250 } 4307 }
4251 4308
4252 case OP_STRLEN: /* string-length */ 4309 case OP_STRLEN: /* string-length */
4253 s_return (mk_integer (SCHEME_A_ strlength (x))); 4310 s_return (mk_integer (SCHEME_A_ strlength (x)));
4254 4311
4255 case OP_STRREF: /* string-ref */ 4312 case OP_STRREF: /* string-ref */
4256 { 4313 {
4257 char *str;
4258 int index;
4259
4260 str = strvalue (x); 4314 char *str = strvalue (x);
4261
4262 index = ivalue (cadr (args)); 4315 int index = ivalue_unchecked (cadr (args));
4263 4316
4264 if (index >= strlength (x)) 4317 if (index >= strlength (x))
4265 Error_1 ("string-ref: out of bounds:", cadr (args)); 4318 Error_1 ("string-ref: out of bounds:", cadr (args));
4266 4319
4267 s_return (mk_character (SCHEME_A_ ((unsigned char *)str)[index])); 4320 s_return (mk_character (SCHEME_A_ ((unsigned char *)str)[index]));
4268 } 4321 }
4269 4322
4270 case OP_STRSET: /* string-set! */ 4323 case OP_STRSET: /* string-set! */
4271 { 4324 {
4272 char *str; 4325 char *str = strvalue (x);
4273 int index; 4326 int index = ivalue_unchecked (cadr (args));
4274 int c; 4327 int c;
4275 4328
4276 if (is_immutable (x)) 4329 if (is_immutable (x))
4277 Error_1 ("string-set!: unable to alter immutable string:", x); 4330 Error_1 ("string-set!: unable to alter immutable string:", x);
4278
4279 str = strvalue (x);
4280
4281 index = ivalue (cadr (args));
4282 4331
4283 if (index >= strlength (x)) 4332 if (index >= strlength (x))
4284 Error_1 ("string-set!: out of bounds:", cadr (args)); 4333 Error_1 ("string-set!: out of bounds:", cadr (args));
4285 4334
4286 c = charvalue (caddr (args)); 4335 c = charvalue (caddr (args));
4309 s_return (newstr); 4358 s_return (newstr);
4310 } 4359 }
4311 4360
4312 case OP_SUBSTR: /* substring */ 4361 case OP_SUBSTR: /* substring */
4313 { 4362 {
4314 char *str; 4363 char *str = strvalue (x);
4315 int index0; 4364 int index0 = ivalue_unchecked (cadr (args));
4316 int index1; 4365 int index1;
4317 int len; 4366 int len;
4318 4367
4319 str = strvalue (x);
4320
4321 index0 = ivalue (cadr (args));
4322
4323 if (index0 > strlength (x)) 4368 if (index0 > strlength (x))
4324 Error_1 ("substring: start out of bounds:", cadr (args)); 4369 Error_1 ("substring: start out of bounds:", cadr (args));
4325 4370
4326 if (cddr (args) != NIL) 4371 if (cddr (args) != NIL)
4327 { 4372 {
4328 index1 = ivalue (caddr (args)); 4373 index1 = ivalue_unchecked (caddr (args));
4329 4374
4330 if (index1 > strlength (x) || index1 < index0) 4375 if (index1 > strlength (x) || index1 < index0)
4331 Error_1 ("substring: end out of bounds:", caddr (args)); 4376 Error_1 ("substring: end out of bounds:", caddr (args));
4332 } 4377 }
4333 else 4378 else
4364 } 4409 }
4365 4410
4366 case OP_MKVECTOR: /* make-vector */ 4411 case OP_MKVECTOR: /* make-vector */
4367 { 4412 {
4368 pointer fill = NIL; 4413 pointer fill = NIL;
4369 int len;
4370 pointer vec; 4414 pointer vec;
4371
4372 len = ivalue (x); 4415 int len = ivalue_unchecked (x);
4373 4416
4374 if (cdr (args) != NIL) 4417 if (cdr (args) != NIL)
4375 fill = cadr (args); 4418 fill = cadr (args);
4376 4419
4377 vec = mk_vector (SCHEME_A_ len); 4420 vec = mk_vector (SCHEME_A_ len);
4390 case OP_VECLEN: /* vector-length */ 4433 case OP_VECLEN: /* vector-length */
4391 s_return (mk_integer (SCHEME_A_ veclength (x))); 4434 s_return (mk_integer (SCHEME_A_ veclength (x)));
4392 4435
4393 case OP_VECREF: /* vector-ref */ 4436 case OP_VECREF: /* vector-ref */
4394 { 4437 {
4395 int index;
4396
4397 index = ivalue (cadr (args)); 4438 int index = ivalue_unchecked (cadr (args));
4398 4439
4399 if (index >= veclength (car (args)) && USE_ERROR_CHECKING) 4440 if (index >= veclength (car (args)) && USE_ERROR_CHECKING)
4400 Error_1 ("vector-ref: out of bounds:", cadr (args)); 4441 Error_1 ("vector-ref: out of bounds:", cadr (args));
4401 4442
4402 s_return (vector_elem (x, index)); 4443 s_return (vector_elem (x, index));
4403 } 4444 }
4404 4445
4405 case OP_VECSET: /* vector-set! */ 4446 case OP_VECSET: /* vector-set! */
4406 { 4447 {
4407 int index; 4448 int index = ivalue_unchecked (cadr (args));
4408 4449
4409 if (is_immutable (x)) 4450 if (is_immutable (x))
4410 Error_1 ("vector-set!: unable to alter immutable vector:", x); 4451 Error_1 ("vector-set!: unable to alter immutable vector:", x);
4411
4412 index = ivalue (cadr (args));
4413 4452
4414 if (index >= veclength (car (args)) && USE_ERROR_CHECKING) 4453 if (index >= veclength (car (args)) && USE_ERROR_CHECKING)
4415 Error_1 ("vector-set!: out of bounds:", cadr (args)); 4454 Error_1 ("vector-set!: out of bounds:", cadr (args));
4416 4455
4417 set_vector_elem (x, index, caddr (args)); 4456 set_vector_elem (x, index, caddr (args));
4418 s_return (x); 4457 s_return (x);
4419 } 4458 }
4420 } 4459 }
4421 4460
4422 if (USE_ERROR_CHECKING) abort (); 4461 if (USE_ERROR_CHECKING) abort ();
4423}
4424
4425INTERFACE int
4426is_list (SCHEME_P_ pointer a)
4427{
4428 return list_length (SCHEME_A_ a) >= 0;
4429}
4430
4431/* Result is:
4432 proper list: length
4433 circular list: -1
4434 not even a pair: -2
4435 dotted list: -2 minus length before dot
4436*/
4437INTERFACE int
4438list_length (SCHEME_P_ pointer a)
4439{
4440 int i = 0;
4441 pointer slow, fast;
4442
4443 slow = fast = a;
4444
4445 while (1)
4446 {
4447 if (fast == NIL)
4448 return i;
4449
4450 if (!is_pair (fast))
4451 return -2 - i;
4452
4453 fast = cdr (fast);
4454 ++i;
4455
4456 if (fast == NIL)
4457 return i;
4458
4459 if (!is_pair (fast))
4460 return -2 - i;
4461
4462 ++i;
4463 fast = cdr (fast);
4464
4465 /* Safe because we would have already returned if `fast'
4466 encountered a non-pair. */
4467 slow = cdr (slow);
4468
4469 if (fast == slow)
4470 {
4471 /* the fast pointer has looped back around and caught up
4472 with the slow pointer, hence the structure is circular,
4473 not of finite length, and therefore not a list */
4474 return -1;
4475 }
4476 }
4477} 4462}
4478 4463
4479static int 4464static int
4480opexe_2 (SCHEME_P_ enum scheme_opcodes op) 4465opexe_2 (SCHEME_P_ enum scheme_opcodes op)
4481{ 4466{
4527 case OP_INTEGERP: /* integer? */ r = is_integer (a) ; break; 4512 case OP_INTEGERP: /* integer? */ r = is_integer (a) ; break;
4528 case OP_REALP: /* real? */ r = is_number (a) ; break; /* all numbers are real */ 4513 case OP_REALP: /* real? */ r = is_number (a) ; break; /* all numbers are real */
4529 case OP_CHARP: /* char? */ r = is_character (a) ; break; 4514 case OP_CHARP: /* char? */ r = is_character (a) ; break;
4530 4515
4531#if USE_CHAR_CLASSIFIERS 4516#if USE_CHAR_CLASSIFIERS
4532 case OP_CHARAP: /* char-alphabetic? */ r = Cisalpha (ivalue (a)); break; 4517 case OP_CHARAP: /* char-alphabetic? */ r = Cisalpha (ivalue_unchecked (a)); break;
4533 case OP_CHARNP: /* char-numeric? */ r = Cisdigit (ivalue (a)); break; 4518 case OP_CHARNP: /* char-numeric? */ r = Cisdigit (ivalue_unchecked (a)); break;
4534 case OP_CHARWP: /* char-whitespace? */ r = Cisspace (ivalue (a)); break; 4519 case OP_CHARWP: /* char-whitespace? */ r = Cisspace (ivalue_unchecked (a)); break;
4535 case OP_CHARUP: /* char-upper-case? */ r = Cisupper (ivalue (a)); break; 4520 case OP_CHARUP: /* char-upper-case? */ r = Cisupper (ivalue_unchecked (a)); break;
4536 case OP_CHARLP: /* char-lower-case? */ r = Cislower (ivalue (a)); break; 4521 case OP_CHARLP: /* char-lower-case? */ r = Cislower (ivalue_unchecked (a)); break;
4537#endif 4522#endif
4538 4523
4539#if USE_PORTS 4524#if USE_PORTS
4540 case OP_PORTP: /* port? */ r = is_port (a) ; break; 4525 case OP_PORTP: /* port? */ r = is_port (a) ; break;
4541 case OP_INPORTP: /* input-port? */ r = is_inport (a) ; break; 4526 case OP_INPORTP: /* input-port? */ r = is_inport (a) ; break;
4724 4709
4725 case OP_QUIT: /* quit */ 4710 case OP_QUIT: /* quit */
4726 if (is_pair (args)) 4711 if (is_pair (args))
4727 SCHEME_V->retcode = ivalue (a); 4712 SCHEME_V->retcode = ivalue (a);
4728 4713
4714 exit(0);//D
4729 return -1; 4715 return -1;
4730 4716
4731 case OP_GC: /* gc */ 4717 case OP_GC: /* gc */
4732 gc (SCHEME_A_ NIL, NIL); 4718 gc (SCHEME_A_ NIL, NIL);
4733 s_return (S_T); 4719 s_return (S_T);
4742 4728
4743 case OP_NEWSEGMENT: /* new-segment */ 4729 case OP_NEWSEGMENT: /* new-segment */
4744 if (!is_pair (args) || !is_number (a)) 4730 if (!is_pair (args) || !is_number (a))
4745 Error_0 ("new-segment: argument must be a number"); 4731 Error_0 ("new-segment: argument must be a number");
4746 4732
4747 alloc_cellseg (SCHEME_A_ (int)ivalue (a)); 4733 alloc_cellseg (SCHEME_A_ ivalue (a));
4748 4734
4749 s_return (S_T); 4735 s_return (S_T);
4750 4736
4751 case OP_OBLIST: /* oblist */ 4737 case OP_OBLIST: /* oblist */
4752 s_return (oblist_all_symbols (SCHEME_A)); 4738 s_return (oblist_all_symbols (SCHEME_A));
5282/* dispatch functions (opexe_x) return new opcode, or 0 for same opcode, or -1 to stop */ 5268/* dispatch functions (opexe_x) return new opcode, or 0 for same opcode, or -1 to stop */
5283typedef int (*dispatch_func)(SCHEME_P_ enum scheme_opcodes); 5269typedef int (*dispatch_func)(SCHEME_P_ enum scheme_opcodes);
5284 5270
5285typedef int (*test_predicate)(pointer); 5271typedef int (*test_predicate)(pointer);
5286static int 5272static int
5287is_any (pointer p) 5273tst_any (pointer p)
5288{ 5274{
5289 return 1; 5275 return 1;
5290} 5276}
5291 5277
5292static int 5278static int
5293is_nonneg (pointer p) 5279tst_inonneg (pointer p)
5294{ 5280{
5295 return ivalue (p) >= 0 && is_integer (p); 5281 return is_integer (p) && ivalue_unchecked (p) >= 0;
5296} 5282}
5297 5283
5298static int 5284static int
5299tst_is_list (pointer p) 5285tst_is_list (SCHEME_P_ pointer p)
5300{ 5286{
5301 return p == NIL || is_pair (p); 5287 return p == NIL || is_pair (p);
5302} 5288}
5303 5289
5304/* Correspond carefully with following defines! */ 5290/* Correspond carefully with following defines! */
5305static struct 5291static struct
5306{ 5292{
5307 test_predicate fct; 5293 test_predicate fct;
5308 const char *kind; 5294 const char *kind;
5309} tests[] = 5295} tests[] = {
5310{
5311 { is_any, 0 }, 5296 { tst_any , 0 },
5312 { is_string, "string" }, 5297 { is_string , "string" },
5313 { is_symbol, "symbol" }, 5298 { is_symbol , "symbol" },
5314 { is_port, "port" }, 5299 { is_port , "port" },
5315 { is_inport, "input port" }, 5300 { is_inport , "input port" },
5316 { is_outport, "output port" }, 5301 { is_outport , "output port" },
5317 { is_environment, "environment" }, 5302 { is_environment, "environment" },
5318 { is_pair, "pair" }, 5303 { is_pair , "pair" },
5319 { tst_is_list, "pair or '()" }, 5304 { 0 , "pair or '()" },
5320 { is_character, "character" }, 5305 { is_character , "character" },
5321 { is_vector, "vector" }, 5306 { is_vector , "vector" },
5322 { is_number, "number" }, 5307 { is_number , "number" },
5323 { is_integer, "integer" }, 5308 { is_integer , "integer" },
5324 { is_nonneg, "non-negative integer" } 5309 { tst_inonneg , "non-negative integer" }
5325}; 5310};
5326 5311
5327#define TST_NONE 0 /* TST_NONE used for built-ins, 0 for internal ops */ 5312#define TST_NONE 0 /* TST_NONE used for built-ins, 0 for internal ops */
5328#define TST_ANY "\001" 5313#define TST_ANY "\001"
5329#define TST_STRING "\002" 5314#define TST_STRING "\002"
5370typedef struct 5355typedef struct
5371{ 5356{
5372 uint8_t func; 5357 uint8_t func;
5373 /*dispatch_func func;*//*TODO: maybe optionally keep the pointer, for speed? */ 5358 /*dispatch_func func;*//*TODO: maybe optionally keep the pointer, for speed? */
5374 uint8_t builtin; 5359 uint8_t builtin;
5360#if USE_ERROR_CHECKING
5375 uint8_t min_arity; 5361 uint8_t min_arity;
5376 uint8_t max_arity; 5362 uint8_t max_arity;
5377 char arg_tests_encoding[3]; 5363 char arg_tests_encoding[3];
5364#endif
5378} op_code_info; 5365} op_code_info;
5379 5366
5380static const op_code_info dispatch_table[] = { 5367static const op_code_info dispatch_table[] = {
5368#if USE_ERROR_CHECKING
5381#define OP_DEF(func,name,minarity,maxarity,argtest,op) { func, sizeof (name) > 1, minarity, maxarity, argtest }, 5369#define OP_DEF(func,name,minarity,maxarity,argtest,op) { func, sizeof (name) > 1, minarity, maxarity, argtest },
5370#else
5371#define OP_DEF(func,name,minarity,maxarity,argtest,op) { func, sizeof (name) > 1 },
5372#endif
5382#include "opdefines.h" 5373#include "opdefines.h"
5383#undef OP_DEF 5374#undef OP_DEF
5384 {0} 5375 {0}
5385}; 5376};
5386 5377
5428 { 5419 {
5429 pointer arg = car (arglist); 5420 pointer arg = car (arglist);
5430 5421
5431 j = t[0]; 5422 j = t[0];
5432 5423
5424 /*TODO: tst_is_list has different prototype - fix if other tests acquire same prototype */
5425 if (j == TST_LIST[0])
5426 {
5427 if (!tst_is_list (SCHEME_A_ arg))
5428 break;
5429 }
5430 else
5431 {
5433 if (!tests[j - 1].fct (arg)) 5432 if (!tests[j - 1].fct (arg))
5434 break; 5433 break;
5434 }
5435 5435
5436 if (t[1]) /* last test is replicated as necessary */ 5436 if (t[1]) /* last test is replicated as necessary */
5437 t++; 5437 t++;
5438 5438
5439 arglist = cdr (arglist); 5439 arglist = cdr (arglist);
5496mk_proc (SCHEME_P_ enum scheme_opcodes op) 5496mk_proc (SCHEME_P_ enum scheme_opcodes op)
5497{ 5497{
5498 pointer y = get_cell (SCHEME_A_ NIL, NIL); 5498 pointer y = get_cell (SCHEME_A_ NIL, NIL);
5499 set_typeflag (y, (T_PROC | T_ATOM)); 5499 set_typeflag (y, (T_PROC | T_ATOM));
5500 ivalue_unchecked (y) = op; 5500 ivalue_unchecked (y) = op;
5501 set_num_integer (y);
5502 return y; 5501 return y;
5503} 5502}
5504 5503
5505/* Hard-coded for the given keywords. Remember to rewrite if more are added! */ 5504/* Hard-coded for the given keywords. Remember to rewrite if more are added! */
5506static int 5505static int

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines