Changeset 418 for branches/thune/thread_safe/rune/rune.c
- Timestamp:
- 06/22/07 20:53:36 (17 months ago)
- Files:
-
- 1 modified
-
branches/thune/thread_safe/rune/rune.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/thune/thread_safe/rune/rune.c
r351 r418 41 41 42 42 43 #define OR_TOC u r_thread->toc44 #define OR_BOC u r_thread->cstack43 #define OR_TOC ut->toc 44 #define OR_BOC ut->cstack 45 45 46 46 #define ur_funcFetch(cell) cell->func.closureN … … 140 140 141 141 #ifdef DEBUG 142 void dumpControl( )142 void dumpControl( UThread* ut ) 143 143 { 144 144 UString str; 145 145 UString* sp = &str; 146 UCell* it = u r_env->threads->cstack;147 UCell* end = u r_env->threads->toc + 1;146 UCell* it = ut->cstack; 147 UCell* end = ut->toc + 1; 148 148 149 149 ur_arrayInit( sp, 1, 0 ); … … 164 164 165 165 166 static int _verifyArgs( UThread* u r_thread, UCell* dt, int count )166 static int _verifyArgs( UThread* ut, UCell* dt, int count ) 167 167 { 168 168 UCell* it; … … 210 210 extern int ur_getSelector( UThread*, const UCell* sel, UCell* res ); 211 211 212 int ur_eval( UThread* u r_thread, UIndex blkN, UIndex si )212 int ur_eval( UThread* ut, UIndex blkN, UIndex si ) 213 213 { 214 214 UBlock* blk; … … 245 245 { 246 246 // Return from function. 247 cval = UR_LF_BEG-> localFrame.cell;247 cval = UR_LF_BEG->cell; 248 248 UR_LF_POP; 249 249 ur_copyCell(cval, *val); … … 285 285 if( ur_is(pc, UT_WORD) ) 286 286 { 287 val = ur_wordCell( u r_thread, pc );287 val = ur_wordCell( ut, pc ); 288 288 } 289 289 else … … 301 301 302 302 case UT_GETWORD: 303 val = ur_wordCell( u r_thread, val );303 val = ur_wordCell( ut, val ); 304 304 break; 305 305 … … 373 373 374 374 case UT_SELECT: 375 if( ! ur_getSelector( u r_thread, val, UR_TOS ) )375 if( ! ur_getSelector( ut, val, UR_TOS ) ) 376 376 { 377 377 --pc; … … 523 523 case ROP_EACH_LOOP: 524 524 val = ur_s_prev(UR_TOS); 525 if( ur_itLen( val ) > 0 )525 if( ur_itLen( ut, val ) > 0 ) 526 526 { 527 cval = ur_wordCell( u r_thread, ur_s_prev(val) );527 cval = ur_wordCell( ut, ur_s_prev(val) ); 528 528 if( ! cval ) 529 529 goto op_throw; 530 ur_pick( val, 0, cval );530 ur_pick( ut, val, 0, cval ); 531 531 val->series.it++; 532 532 val = UR_TOS; … … 553 553 case UT_SETWORD: 554 554 LOOK_AHEAD_FOR_INFIX 555 cval = ur_wordCell( u r_thread, OR_TOC );555 cval = ur_wordCell( ut, OR_TOC ); 556 556 if( ! cval ) 557 557 { … … 636 636 do_call: 637 637 638 //printf( "KR call %ld\n", UR_TOS - u r_thread->dstack );639 640 val->call.addr( u r_thread, UR_TOS );638 //printf( "KR call %ld\n", UR_TOS - ut->dstack ); 639 640 val->call.addr( ut, UR_TOS ); 641 641 val = UR_TOS; 642 642 UR_S_DROP; … … 680 680 int locc = totc - argc; 681 681 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 683 687 684 688 if( argc ) 685 689 { 686 690 blk = ur_blockPtr( val->func.sigN ); 687 if( ! _verifyArgs( u r_thread, blk->ptr.cells + totc, argc ) )691 if( ! _verifyArgs( ut, blk->ptr.cells + totc, argc ) ) 688 692 goto op_throw; 689 693 } … … 854 858 trace_error: 855 859 856 _appendTraceBlk( &UR_TOS->err, blkN, pc - start );860 _appendTraceBlk( ut, &UR_TOS->err, blkN, pc - start ); 857 861 858 862 error: … … 886 890 putchar( ur_char(tos) ); 887 891 } 888 else if( ur_stringSlice( tos, &it, &end) && it )892 else if( ur_stringSlice(ut, tos, &it, &end) && it ) 889 893 { 890 894 if( ur_encoding(tos) == UR_ENC_UTF16 ) … … 908 912 { 909 913 UString* str; 910 str = ur_binPtr( ur_thread->callTempBinN);914 str = ur_binPtr( BIN_THREAD_TMP ); 911 915 str->used = 0; 912 916 ur_toStr( tos, str, 0 ); … … 917 921 tos = UR_TOS; 918 922 ur_initType( tos, UT_STRING ); 919 ur_setSeries( tos, ur_thread->callTempBinN, 0 );920 rc_cout( u r_thread, tos );923 ur_setSeries( tos, BIN_THREAD_TMP, 0 ); 924 rc_cout( ut, tos ); 921 925 UR_S_DROP; 922 926 } … … 927 931 UR_CALL( rc_func_loop ) 928 932 { 929 uc_func( u r_thread, tos );933 uc_func( ut, tos ); 930 934 UR_TOS->func.flags |= UR_FLAG_FUNC_LOOP; 931 935 } … … 940 944 941 945 942 extern UIndex _funcSignature( const UCell* scell, int* pArgc, int* pVarc );946 extern UIndex _funcSignature( UThread*, const UCell*, int* pArgc, int* pVarc ); 943 947 944 948 // (block -- block) … … 961 965 { 962 966 assert( ur_is(it, UT_WORD) ); 963 val = ur_wordCell( u r_thread, it );967 val = ur_wordCell( ut, it ); 964 968 ++it; 965 969 assert( ur_is(it, UT_BLOCK) ); … … 968 972 { 969 973 /* 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 ); 971 975 ur_argc(val) = argc; 972 976 ur_varc(val) = 0; //varc … … 999 1003 1000 1004 1001 void rune_install( U rlanEnv* env)1002 { 1003 ur_makeCalls( env, rune_calls, sizeof(rune_calls) / sizeof(UCallDef) );1005 void rune_install( UThread* ut ) 1006 { 1007 ur_makeCalls( ut, rune_calls, sizeof(rune_calls) / sizeof(UCallDef) ); 1004 1008 1005 1009 // Bootstrap declare-natives 1006 1010 { 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 ); 1010 1013 if( val ) 1011 1014 {
