Show
Ignore:
Timestamp:
06/22/07 20:53:36 (17 months ago)
Author:
krobillard
Message:

Rune works again.

Files:
1 modified

Legend:

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

    r351 r418  
    4141 
    4242 
    43 #define OR_TOC          ur_thread->toc 
    44 #define OR_BOC          ur_thread->cstack 
     43#define OR_TOC          ut->toc 
     44#define OR_BOC          ut->cstack 
    4545 
    4646#define ur_funcFetch(cell)  cell->func.closureN 
     
    140140 
    141141#ifdef DEBUG 
    142 void dumpControl() 
     142void dumpControl( UThread* ut ) 
    143143{ 
    144144    UString str; 
    145145    UString* sp = &str; 
    146     UCell* it  = ur_env->threads->cstack; 
    147     UCell* end = ur_env->threads->toc + 1; 
     146    UCell* it  = ut->cstack; 
     147    UCell* end = ut->toc + 1; 
    148148 
    149149    ur_arrayInit( sp, 1, 0 ); 
     
    164164 
    165165 
    166 static int _verifyArgs( UThread* ur_thread, UCell* dt, int count ) 
     166static int _verifyArgs( UThread* ut, UCell* dt, int count ) 
    167167{ 
    168168    UCell* it; 
     
    210210extern int ur_getSelector( UThread*, const UCell* sel, UCell* res ); 
    211211 
    212 int ur_eval( UThread* ur_thread, UIndex blkN, UIndex si ) 
     212int ur_eval( UThread* ut, UIndex blkN, UIndex si ) 
    213213{ 
    214214    UBlock* blk; 
     
    245245                { 
    246246                    // Return from function. 
    247                     cval = UR_LF_BEG->localFrame.cell; 
     247                    cval = UR_LF_BEG->cell; 
    248248                    UR_LF_POP; 
    249249                    ur_copyCell(cval, *val); 
     
    285285    if( ur_is(pc, UT_WORD) ) 
    286286    { 
    287         val = ur_wordCell( ur_thread, pc ); 
     287        val = ur_wordCell( ut, pc ); 
    288288    } 
    289289    else 
     
    301301 
    302302        case UT_GETWORD: 
    303             val = ur_wordCell( ur_thread, val ); 
     303            val = ur_wordCell( ut, val ); 
    304304            break; 
    305305 
     
    373373 
    374374        case UT_SELECT: 
    375             if( ! ur_getSelector( ur_thread, val, UR_TOS ) ) 
     375            if( ! ur_getSelector( ut, val, UR_TOS ) ) 
    376376            { 
    377377                --pc; 
     
    523523                case ROP_EACH_LOOP: 
    524524                    val = ur_s_prev(UR_TOS); 
    525                     if( ur_itLen( val ) > 0 ) 
     525                    if( ur_itLen( ut, val ) > 0 ) 
    526526                    { 
    527                         cval = ur_wordCell( ur_thread, ur_s_prev(val) ); 
     527                        cval = ur_wordCell( ut, ur_s_prev(val) ); 
    528528                        if( ! cval ) 
    529529                            goto op_throw; 
    530                         ur_pick( val, 0, cval ); 
     530                        ur_pick( ut, val, 0, cval ); 
    531531                        val->series.it++; 
    532532                        val = UR_TOS; 
     
    553553        case UT_SETWORD: 
    554554            LOOK_AHEAD_FOR_INFIX 
    555             cval = ur_wordCell( ur_thread, OR_TOC ); 
     555            cval = ur_wordCell( ut, OR_TOC ); 
    556556            if( ! cval ) 
    557557            { 
     
    636636do_call: 
    637637 
    638     //printf( "KR call %ld\n", UR_TOS - ur_thread->dstack ); 
    639  
    640     val->call.addr( ur_thread, UR_TOS ); 
     638    //printf( "KR call %ld\n", UR_TOS - ut->dstack ); 
     639 
     640    val->call.addr( ut, UR_TOS ); 
    641641    val = UR_TOS; 
    642642    UR_S_DROP; 
     
    680680        int locc = totc - argc; 
    681681 
    682         UR_LF_PUSH( -val->func.sigN, UR_TOS - (argc - 1) ); 
     682        //UR_LF_PUSH( -val->func.sigN, UR_TOS - (argc - 1) ); 
     683        --ut->localFT; 
     684        UR_LF_BEG->cell = UR_TOS - (argc - 1); 
     685        UR_LF_BEG->n    = val->func.sigN; 
     686 
    683687 
    684688        if( argc ) 
    685689        { 
    686690            blk = ur_blockPtr( val->func.sigN ); 
    687             if( ! _verifyArgs( ur_thread, blk->ptr.cells + totc, argc ) ) 
     691            if( ! _verifyArgs( ut, blk->ptr.cells + totc, argc ) ) 
    688692                goto op_throw; 
    689693        } 
     
    854858trace_error: 
    855859 
    856     _appendTraceBlk( &UR_TOS->err, blkN, pc - start ); 
     860    _appendTraceBlk( ut, &UR_TOS->err, blkN, pc - start ); 
    857861 
    858862error: 
     
    886890        putchar( ur_char(tos) ); 
    887891    } 
    888     else if( ur_stringSlice(tos, &it, &end) && it ) 
     892    else if( ur_stringSlice(ut, tos, &it, &end) && it ) 
    889893    { 
    890894        if( ur_encoding(tos) == UR_ENC_UTF16 ) 
     
    908912{ 
    909913    UString* str; 
    910     str = ur_binPtr( ur_thread->callTempBinN ); 
     914    str = ur_binPtr( BIN_THREAD_TMP ); 
    911915    str->used = 0; 
    912916    ur_toStr( tos, str, 0 ); 
     
    917921    tos = UR_TOS; 
    918922    ur_initType( tos, UT_STRING ); 
    919     ur_setSeries( tos, ur_thread->callTempBinN, 0 ); 
    920     rc_cout( ur_thread, tos ); 
     923    ur_setSeries( tos, BIN_THREAD_TMP, 0 ); 
     924    rc_cout( ut, tos ); 
    921925    UR_S_DROP; 
    922926} 
     
    927931UR_CALL( rc_func_loop ) 
    928932{ 
    929     uc_func( ur_thread, tos ); 
     933    uc_func( ut, tos ); 
    930934    UR_TOS->func.flags |= UR_FLAG_FUNC_LOOP; 
    931935} 
     
    940944 
    941945 
    942 extern UIndex _funcSignature( const UCell* scell, int* pArgc, int* pVarc ); 
     946extern UIndex _funcSignature( UThread*, const UCell*, int* pArgc, int* pVarc ); 
    943947 
    944948// (block -- block) 
     
    961965        { 
    962966            assert( ur_is(it, UT_WORD) ); 
    963             val = ur_wordCell( ur_thread, it ); 
     967            val = ur_wordCell( ut, it ); 
    964968            ++it; 
    965969            assert( ur_is(it, UT_BLOCK) ); 
     
    968972            { 
    969973                /* LIMIT: All Rune call sigN blocks must be in first 65k. */ 
    970                 val->call.sigN  = _funcSignature( it, &argc, &varc ); 
     974                val->call.sigN  = _funcSignature( ut, it, &argc, &varc ); 
    971975                ur_argc(val)    = argc; 
    972976                ur_varc(val)    = 0; //varc 
     
    9991003 
    10001004 
    1001 void rune_install( UrlanEnv* env ) 
    1002 { 
    1003     ur_makeCalls( env, rune_calls, sizeof(rune_calls) / sizeof(UCallDef) ); 
     1005void rune_install( UThread* ut ) 
     1006{ 
     1007    ur_makeCalls( ut, rune_calls, sizeof(rune_calls) / sizeof(UCallDef) ); 
    10041008 
    10051009    // Bootstrap declare-natives 
    10061010    { 
    1007     UCell* val = ur_resolveArgPath( UT_WORD, 
    1008                                     ur_intern(env, "declare-natives", 15), 
    1009                                     UT_NONE ); 
     1011    UCell* val = ur_resolvePath( ut, ur_intern("declare-natives", 15), 
     1012                                 UT_NONE ); 
    10101013    if( val ) 
    10111014    {