Changeset 168 for trunk/thune/eval.c
- Timestamp:
- 06/05/06 03:23:01 (3 years ago)
- Files:
-
- 1 modified
-
trunk/thune/eval.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/eval.c
r164 r168 89 89 90 90 #define RESET_ITER(a,b) \ 91 b = UR_TOC->cp.cell; \92 a = UR_TOC[-1].cp.cell; \93 UR_C_GROW94 95 96 #define PUSHC_FOREACH(si,a,b) \97 UR_TOC->cp.cell = a; \98 UR_C_GROW; \99 UR_TOC->cp.code = CC_FOREACH; \100 UR_TOC->cp.n = si; \101 UR_TOC->cp.cell = b; \102 UR_C_GROW103 104 #define RESET_FOREACH(a,b) \105 91 b = UR_TOC->cp.cell; \ 106 92 a = UR_TOC[-1].cp.cell; \ … … 506 492 507 493 case CC_ITER: 508 case CC_FOREACH:509 494 toc -= CC_LEN_ITER; 510 495 break; … … 665 650 } 666 651 break; 667 668 case OP_FOREACH: // (blk series ['words] -- )669 ++pc;670 val = UR_TOS;671 while( ur_is(val, UT_LITWORD) )672 ++val;673 PUSHC_EVAL( blkN, start, pc );674 SET_BLK_PC( val[1].series.n,675 val[1].series.it );676 PUSHC_FOREACH( UR_BOS - val, pc, end );677 goto control;678 652 679 653 case OP_RECURSE: … … 975 949 goto control; 976 950 977 case CC_FOREACH:978 val = UR_BOS - UR_TOC->cp.n;979 if( ur_itLen(val) > 0 )980 {981 UR_TOS->series.it++;982 RESET_FOREACH( pc, end );983 UR_S_DUP;984 goto execute;985 }986 UR_C_DEC;987 UR_S_DROPN( UR_TOC->cp.n ); // Pop iterator values.988 goto control;989 990 951 case CC_CATCH: 991 952 UR_C_DECN( 2 ); … … 1044 1005 1045 1006 case CC_ITER: 1046 case CC_FOREACH:1047 1007 UR_C_DECN( CC_LEN_ITER ); 1048 1008 break; … … 1312 1272 break; 1313 1273 1274 case UT_CHAR: 1314 1275 case UT_INT: 1315 if( ur_is(b, UT_INT) )1276 if( ur_is(b, UT_INT) || ur_is(b, UT_CHAR) ) 1316 1277 { 1317 1278 if( ur_int(a) == ur_int(b) ) … … 1541 1502 1542 1503 1543 // (val word -- ) 1504 /* 1505 (val word -- ) 1506 1507 If val is a series and word is a block then the words are set to the 1508 first N elements of the series (where N is the number of words in word). 1509 */ 1544 1510 UR_CALL( uc_set ) 1545 1511 { 1512 UBlock* blk; 1513 UCell* cell; 1514 UCell* val; 1515 1516 val = ur_s_prev( tos ); 1517 1546 1518 if( ur_isAWord(tos) ) 1547 1519 { 1548 UBlock* blk;1549 UCell* cell;1550 UCell* val;1551 1552 1520 if( ur_wordIsUnbound(tos) ) 1553 1521 { … … 1563 1531 } 1564 1532 1565 val = ur_s_prev( tos );1566 1533 ur_wordCell( tos, blk, cell ); 1567 1534 ur_copyCell( cell, *val ); 1535 } 1536 else if( ur_is(tos, UT_BLOCK) ) 1537 { 1538 UCell* it; 1539 UCell* end; 1540 1541 blk = ur_block(tos); 1542 UR_ITER_BLOCK( it, end, blk, tos ); 1543 1544 if( ur_isASeries(val) ) 1545 { 1546 int n = 0; 1547 while( it != end ) 1548 { 1549 if( ur_isAWord(it) ) 1550 { 1551 ur_wordCell( it, blk, cell ); 1552 ur_pick( val, n++, cell ); 1553 } 1554 ++it; 1555 } 1556 } 1557 else 1558 { 1559 while( it != end ) 1560 { 1561 if( ur_isAWord(it) ) 1562 { 1563 ur_wordCell( it, blk, cell ); 1564 ur_copyCell( cell, *val ); 1565 } 1566 ++it; 1567 } 1568 } 1568 1569 } 1569 1570 UR_S_DROPN(2);
