Changeset 509

Show
Ignore:
Timestamp:
02/09/08 02:35:22 (7 months ago)
Author:
krobillard
Message:

Added hold/release macros. ur_readDir() now holds its result block.

Location:
trunk/thune
Files:
15 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/doc/UserManual

    r506 r509  
    423423copy        (a -- r)                  Copy value. 
    424424copy.part   (ser limit -- r)          Copy part of a series. 
    425 mark.eol    (block -- block)          Set EOL flag for current cell. 
     425mark.sol    (val -- block)            Set Start Of Line flag for current cell. 
    426426parse       (data rules -- pos)       Parse string or block. 
    427427==========  ========================  ================= 
  • trunk/thune/doc/thune.vim

    r468 r509  
    125125" Control statements 
    126126syn keyword     thuneStatement          try throw halt quit return recurse break 
    127 syn keyword     thuneConditional        ift iff either select case 
     127syn keyword     thuneConditional        ift iff if-some or-else either select case 
    128128syn keyword     thuneRepeat                     iter forever each each.set 
    129129"for forall foreach forskip loop repeat while until do 
  • trunk/thune/eval.c

    r499 r509  
    17491749    { uc_recycle,      "recycle" }, 
    17501750    { uc_to_hex,       "to-hex" }, 
    1751     { uc_mark_sol,     "mark.eol" }, 
     1751    { uc_mark_sol,     "mark.sol" }, 
    17521752    { uc_hash,         "hash" }, 
    17531753    { uc_encode,       "encode" }, 
  • trunk/thune/gc.c

    r508 r509  
    231231 
    232232 
     233static void _checkCells( UThread* ut, UCollector* gc, UCell* it, UCell* end ); 
     234 
    233235static void _checkBlock( UThread* ut, UCollector* gc, UBlock* blk ) 
    234236{ 
    235     int idx; 
    236237    UCell* it  = blk->ptr.cells; 
    237     UCell* end = it + blk->used; 
    238238 
    239239#ifdef GC_VERBOSE 
     
    241241#endif 
    242242 
    243     if( ! it ) 
    244         return; 
    245  
     243    if( it ) 
     244        _checkCells( ut, gc, it, it + blk->used ); 
     245} 
     246 
     247 
     248static void _checkCells( UThread* ut, UCollector* gc, UCell* it, UCell* end ) 
     249{ 
     250    int idx; 
    246251    while( it != end ) 
    247252    { 
     
    396401            case CC_ITER: 
    397402            case CC_EACH: 
     403            { 
     404                UCell* cell = ((UCell*) it) - 1; 
    398405                SET_BIT_BLOCK_L( it->cp.n ) 
     406                _checkCells( ut, gc, cell, cell + 1 ); 
    399407                it -= CC_LEN_ITER; 
     408            } 
    400409                break; 
    401410 
     
    422431static void _checkControlStack( UThread* ut, UCollector* gc ) 
    423432{ 
    424     UBlock blk; 
    425  
    426     blk.ptr.cells = UR_BOC; 
    427     blk.used      = UR_TOC - UR_BOC; 
    428  
    429     assert( blk.used > -1 ); 
    430  
    431     _checkBlock( ut, gc, &blk ); 
     433    assert( UR_TOC >= UR_BOC ); 
     434 
     435    _checkCells( ut, gc, UR_BOC, UR_TOC ); 
    432436} 
    433437#endif 
     
    436440static void _checkDataStack( UThread* ut, UCollector* gc ) 
    437441{ 
    438     UBlock blk; 
    439  
    440     blk.ptr.cells = UR_BOS + 1; 
    441     blk.used      = UR_TOS - UR_BOS; 
    442  
    443442#ifndef LANG_RUNE 
    444443    assert( ur_is(UR_BOS, UT_UNSET) ); 
    445444#endif 
    446     assert( blk.used > -1 ); 
    447  
    448     _checkBlock( ut, gc, &blk ); 
     445    assert( UR_TOS >= UR_BOS ); 
     446 
     447    _checkCells( ut, gc, UR_BOS + 1, UR_TOS + 1 ); 
    449448} 
    450449 
  • trunk/thune/gl/rfont.c

    r458 r509  
    112112    if( bin->ptr.b ) 
    113113    { 
    114         hold = ur_hold( ut, UT_BINARY, rastN ); 
     114        hold = ur_holdBin( rastN ); 
    115115 
    116116        fbm.width  = cfg->texW; 
     
    195195 
    196196        txf_free( &tf ); 
    197         ur_release( ut, hold ); 
     197        ur_release( hold ); 
    198198        return ok; 
    199199    } 
  • trunk/thune/scripts/replace.t

    r232 r509  
    3535    [[b a] [a b]] rev pick 
    3636    [ 
    37         rules [a (b prin) |] copy 'a infuse append.cat tail prev mark.eol drop 
     37        rules [a (b prin) |] copy 'a infuse append.cat tail prev mark.sol drop 
    3838    ] 
    3939    each.set 
  • trunk/thune/series.c

    r508 r509  
    23802380                if( it != end ) 
    23812381                { 
    2382                     hold = (deep == 1) ? ur_hold( ut, UT_BLOCK, blkN ) : 
    2383                                          UR_INVALID_HOLD; 
     2382                    hold = (deep == 1) ? ur_holdBlock(blkN) : UR_INVALID_HOLD; 
    23842383                    do 
    23852384                    { 
     
    23902389 
    23912390                    if( hold != UR_INVALID_HOLD ) 
    2392                         ur_release( ut, hold ); 
     2391                        ur_release( hold ); 
    23932392                } 
    23942393            } 
  • trunk/thune/tests/working/parse.t

    r212 r509  
    1010 
    1111    [ 
    12         linefeed ift (tail prev mark.eol none :linefeed) 
     12        linefeed ift (tail prev mark.sol none :linefeed) 
    1313        drop 
    14     ] proc :blk-eol 
     14    ] proc :blk-sol 
    1515 
    1616    [ 
    1717        make 
    1818        blk swap append 
    19         blk-eol 
     19        blk-sol 
    2020    ] proc :app 
    2121 
     
    2323        0 make 
    2424        blk over append 
    25         blk-eol 
     25        blk-sol 
    2626        blk-stack blk append drop 
    2727        :blk 
     
    3131        drop    ; TODO: verify type 
    3232        blk-stack dup last :blk tail prev remove drop 
    33         linefeed ift (/*blk tail prev 2 mark.eol drop*/ none :linefeed) 
     33        linefeed ift (/*blk tail prev 2 mark.sol drop*/ none :linefeed) 
    3434    ] proc :pop-block 
    3535 
  • trunk/thune/tests/working/parse2.good

    r503 r509  
    2323    [[b a] [a b]] rev pick 
    2424    [ 
    25         rules [a (b prin) |] copy 'a infuse append.cat tail prev mark.eol drop 
     25        rules [a (b prin) |] copy 'a infuse append.cat tail prev mark.sol drop 
    2626    ] 
    2727    each.set 
  • trunk/thune/tests/working/parse2.t

    r503 r509  
    2323    [[b a] [a b]] rev pick 
    2424    [ 
    25         rules [a (b prin) |] copy 'a infuse append.cat tail prev mark.eol drop 
     25        rules [a (b prin) |] copy 'a infuse append.cat tail prev mark.sol drop 
    2626    ] 
    2727    each.set 
  • trunk/thune/thread.c

    r508 r509  
    303303 
    304304 
    305 void ur_release( UThread* ut, UIndex which ) 
     305void ur_releaseT( UThread* ut, UIndex which ) 
    306306{ 
    307307    UBlock* blk = ur_blockPtr( BLK_THREAD_HOLD ); 
  • trunk/thune/tokenize.c

    r508 r509  
    323323    stack.used++; 
    324324 
    325     hold = ur_hold( ut, UT_BLOCK, STACK[0] ); 
     325    hold = ur_holdBlock( STACK[0] ); 
    326326 
    327327start: 
     
    10791079    } 
    10801080 
    1081     ur_release( ut, hold ); 
     1081    ur_release( hold ); 
    10821082    hold = STACK[0]; 
    10831083    ur_arrayFree( &stack ); 
     
    10891089error: 
    10901090 
    1091     ur_release( ut, hold ); 
     1091    ur_release( hold ); 
    10921092    ur_arrayFree( &stack ); 
    10931093    return 0; 
  • trunk/thune/unix/os.c

    r458 r509  
    247247        UCell* cell; 
    248248        UIndex blkN; 
    249         UBlock* blk; 
     249        UIndex hold; 
    250250 
    251251        blkN = ur_makeBlock( 0 ); 
    252         blk = ur_blockPtr( blkN ); 
     252        hold = ur_holdBlock( blkN ); 
    253253 
    254254        while( (entry = readdir( dir )) ) 
     
    259259 
    260260            // Mark cell as unset in case GC is called by ur_makeString. 
    261             cell = ur_appendCell( blk, UT_UNSET ); 
     261            cell = ur_appendCell( ur_blockPtr( blkN ), UT_UNSET ); 
    262262            ur_makeString( cell, cp, -1 ); 
    263263        } 
    264264 
    265265        closedir( dir ); 
     266 
     267        ur_release( hold ); 
    266268 
    267269        ur_initType(res, UT_BLOCK); 
  • trunk/thune/urlan.h

    r508 r509  
    598598 
    599599UIndex ur_hold( UThread*, int type, UIndex which ); 
    600 void   ur_release( UThread*, UIndex ); 
     600void   ur_releaseT( UThread*, UIndex ); 
    601601 
    602602UBlock*    ur_blockPtrT( UThread*, UIndex ); 
     
    648648#define ur_block(c)         ur_blockPtr( (c)->series.n ) 
    649649#define ur_bin(c)           ur_binPtr( (c)->series.n ) 
     650 
     651#define ur_holdBlock(n)     ur_hold( ut, UT_BLOCK, n ) 
     652#define ur_holdBin(n)       ur_hold( ut, UT_BINARY, n ) 
     653#define ur_release(n)       ur_releaseT( ut, n ) 
    650654 
    651655#define ur_type(c)          (c)->id.type 
  • trunk/thune/win32/os.c

    r477 r509  
    314314        UCell* cell; 
    315315        UIndex blkN; 
    316         UBlock* blk; 
     316        UIndex hold; 
    317317            
    318318        blkN = ur_makeBlock( 0 ); 
    319         blk  = ur_blockPtr( blkN ); 
     319        hold = ur_holdBlock( blkN ); 
    320320 
    321321        do 
     
    326326 
    327327            // Mark cell as unset in case GC is called by ur_makeString. 
    328             cell = ur_appendCell( blk, UT_UNSET ); 
     328            cell = ur_appendCell( ur_blockPtr( blkN ), UT_UNSET ); 
    329329            ur_makeString( cell, fileinfo.name, -1 ); 
    330330        } 
     
    332332 
    333333        _findclose( handle ); 
     334 
     335        ur_release( hold ); 
    334336 
    335337        ur_initType(res, UT_BLOCK);