Show
Ignore:
Timestamp:
07/07/07 04:41:31 (17 months ago)
Author:
krobillard
Message:

Setting words in the shared global store now throws an error.
Default binding changed so top-level set-words are added to thread context.

Files:
1 modified

Legend:

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

    r426 r427  
    3333extern double ur_stringToDec( const char*, const char*, const char** ); 
    3434 
    35 extern UContext ur_global; 
    36 extern UContext ur_envGlobal; 
     35extern UContext ur_thrGlobal; 
    3736 
    3837 
    3938//#define GC_STRESS_TEST  1 
    4039 
     40 
     41extern void ur_internDefault( UThread* ut, UCell* wc, UAtom atom, 
     42                              UCell* cbot, UCell* ctop ); 
    4143 
    4244/* 
     
    4547static void ur_internGlobal( UThread* ut, UCell* wc, UAtom atom ) 
    4648{ 
    47     UBlock* mblk; 
    48     UCell* mtop; 
    49     UCell* mbot; 
    50     int wrdN; 
    51  
    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. 
    67     if( ut->env->blocks.arr.used ) 
    68     { 
    69         wrdN = ur_lookup( &ur_envGlobal, atom ); 
    70         if( wrdN > -1 ) 
    71         { 
    72             ur_setBindType( wc, UR_BIND_GLOBAL ); 
    73             wc->word.wordBlk = ur_envGlobal.ctx.wordBlk; 
    74             wc->word.valBlk  = ur_envGlobal.ctx.valBlk; 
    75             wc->word.index   = wrdN; 
    76             return; 
    77         } 
    78     } 
    79  
    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  
    84 assign: 
    85  
    86     // UR_BIND_THREAD should already be set. 
    87     wc->word.wordBlk = mtop->ctx.wordBlk; 
    88     wc->word.valBlk  = mtop->ctx.valBlk; 
    89     wc->word.index   = wrdN; 
     49    UBlock* cblk = tBlockPtr( BLK_CTX_STACK ); 
     50    ur_internDefault( ut, wc, atom, cblk->ptr.cells, 
     51                                    cblk->ptr.cells + cblk->used ); 
    9052} 
    9153 
     
    12821244            ++cp; 
    12831245 
    1284         wrdN = ur_internWord( &ur_global, 
     1246        wrdN = ur_internWord( &ur_thrGlobal, 
    12851247                              ur_intern(def->name, cp - def->name) ); 
    12861248 
     
    12881250        ur_initType( cell, UT_CALL ); 
    12891251        cell->call.addr = (call_t) def->addr; 
    1290  
    1291         /* 
    1292         ur_appendWord( wblk, UT_WORD, "make", 4 ); 
    1293         cell = ur_appendCell( vblk, UT_CALL ); 
    1294         cell->call.addr = (call_t) uc_make; 
    1295         */ 
    12961252 
    12971253        ++def; 
     
    13201276    UCell* cell = ur_appendCell( blk, type ); 
    13211277 
     1278#if 0 
    13221279    // Add word to global context. 
    13231280 
    13241281    ur_atom(cell) = ur_intern( name, len ); 
    13251282    ur_sel(cell)  = UR_CTX_UNORDERED; 
     1283 
    13261284    ur_internGlobal( ut, cell, ur_atom(cell) ); 
     1285#else 
     1286    ur_setUnbound( cell, ur_intern( name, len ) ); 
     1287#endif 
    13271288 
    13281289    return cell; 
     
    16161577                if( spA ) 
    16171578                { 
    1618                     blkN = ur_tokenize( ut, spA, spB, 0 ); 
     1579                    blkN = ur_tokenize( ut, spA, spB ); 
    16191580                    if( ! blkN ) 
    16201581                        return;     // ur_tokenize() has thrown.