Changeset 497 for trunk/thune/thune.c

Show
Ignore:
Timestamp:
11/14/07 04:27:55 (12 months ago)
Author:
krobillard
Message:

Iter accepts negative skip.
Updated GL atoms, manual, and encode test.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/thune.c

    r490 r497  
    609609 
    610610                case OP_ITER:           // (series blk -- ) 
    611                     if( ur_is(UR_TOS, UT_BLOCK) && 
    612                         (ur_itLen( ut, ur_s_prev(UR_TOS) ) > 0) ) 
     611                    if( ur_is(UR_TOS, UT_BLOCK) ) 
    613612                    { 
     613                        int skip = ur_sel(val); 
     614                        if( skip == 0 ) 
     615                            skip = 1; 
     616                        if( skip > 0 ) 
     617                        { 
     618                            if( ur_itLen( ut, ur_s_prev(UR_TOS) ) < 1 ) 
     619                                goto no_iter; 
     620                        } 
     621                        else 
     622                        { 
     623                            if( ur_s_prev(UR_TOS)->series.it < 1 ) 
     624                                goto no_iter; 
     625                        } 
    614626                        PUSHC_EVAL( blkN, start, pc ); 
    615627                        SET_BLK_PC( UR_TOS->series.n, 
    616628                                    UR_TOS->series.it ); 
    617                         PUSHC_ITER( blkN, pc, end, 
    618                                     (ur_sel(val) > 1) ? ur_sel(val) : 1 ); 
     629                        PUSHC_ITER( blkN, pc, end, skip ); 
    619630 
    620631                        // Loop code must drop TOS. 
     
    623634                    else 
    624635                    { 
     636no_iter: 
    625637                        UR_S_DROPN(2); 
    626638                    } 
     
    10631075 
    10641076        case CC_ITER: 
    1065             UR_TOS->series.it += UR_TOC->iter.skip; 
    1066             if( ur_itLen(ut, UR_TOS) > 0 ) 
     1077        { 
     1078            int skip = UR_TOC->iter.skip; 
     1079            UR_TOS->series.it += skip; 
     1080            if( ((skip > 0) ? ur_itLen(ut, UR_TOS) : UR_TOS->series.it + 1) 
     1081                    > 0 ) 
    10671082            { 
    10681083                RESET_ITER( pc, end ); 
     
    10721087            UR_C_DEC; 
    10731088            UR_S_DROP;           // Pop iterator value. 
     1089        } 
    10741090            goto control; 
    10751091