Show
Ignore:
Timestamp:
06/11/07 04:07:02 (18 months ago)
Author:
krobillard
Message:

Thune - Simplified macros with macro! datatype.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/thune/thread_safe/make.c

    r400 r408  
    4545static void ur_internGlobal( UThread* ut, UCell* wc, UAtom atom ) 
    4646{ 
     47    UBlock* mblk; 
     48    UCell* mtop; 
     49    UCell* mbot; 
    4750    int wrdN; 
    4851 
    49     // A module system could be implemented by looking up atom in a stack 
    50     // of module contexts here... 
    51  
    52     wrdN = ur_lookup( &ur_global, atom ); 
    53     if( wrdN > -1 ) 
    54     { 
    55         // UR_BIND_THREAD should already be set. 
    56         wc->word.wordBlk = BLK_GLOBAL_WORD; 
    57         wc->word.valBlk  = BLK_GLOBAL_VAL; 
    58         wc->word.index   = wrdN; 
    59         return; 
    60     } 
    61  
     52    // Look for atom in module context stack. 
     53    mblk = ur_blockPtr( BLK_CTX_STACK ); 
     54    mbot = mblk->ptr.cells; 
     55    mtop = mbot + mblk->used; 
     56    do 
     57    { 
     58        --mtop; 
     59        wrdN = ur_lookup( mtop, atom ); 
     60        if( wrdN > -1 ) 
     61            goto assign; 
     62    } 
     63    while( mtop != mbot ); 
     64 
     65 
     66    // Now try the shared global context. 
    6267    if( ut->env->blocks.arr.used ) 
    6368    { 
     
    7378    } 
    7479 
    75     // For modules, intern word into current module (top of context stack). 
     80    // Word not found, so intern into current module (top of context stack). 
     81    mtop = mbot + (mblk->used - 1); 
     82    wrdN = ur_internWord( mtop, atom ); 
     83 
     84assign: 
    7685 
    7786    // UR_BIND_THREAD should already be set. 
    78     wc->word.wordBlk = BLK_GLOBAL_WORD; 
    79     wc->word.valBlk  = BLK_GLOBAL_VAL; 
    80     wc->word.index   = ur_internWord( &ur_global, atom ); 
     87    wc->word.wordBlk = mtop->ctx.wordBlk; 
     88    wc->word.valBlk  = mtop->ctx.valBlk; 
     89    wc->word.index   = wrdN; 
    8190} 
    8291