Changeset 183 for trunk/thune/eval.c

Show
Ignore:
Timestamp:
06/11/06 05:58:53 (3 years ago)
Author:
krobillard
Message:

Thune - An error is now thrown when an unset word is accessed.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/eval.c

    r182 r183  
    488488 
    489489 
    490 static void _throwUnbound( UThread* ur_thread, UCell* wcell ) 
     490#define _throwUnset(th,cell)    _throwUnsetF(th,cell,"unset") 
     491#define _throwUnbound(th,cell)  _throwUnsetF(th,cell,"unbound") 
     492 
     493static void _throwUnsetF( UThread* ur_thread, UCell* wcell, 
     494                          const char* umsg ) 
    491495{ 
    492496    UString* str; 
     
    496500    ur_termCStr( str ); 
    497501    ur_throwErr( ur_thread, UR_EX_SCRIPT, 
    498                  "word '%s is unbound", str->ptr.c ); 
     502                 "word '%s is %s", str->ptr.c, umsg ); 
    499503} 
    500504 
     
    795799                    //case OP_END: 
    796800                    //    goto finish; 
     801 
     802                    default: 
     803                        _throwUnsetF( ur_thread, pc, "an invalid opcode" ); 
     804                        goto op_throw_cc; 
    797805                } 
    798806                break; 
     
    803811                { 
    804812                    _throwUnbound( ur_thread, pc ); 
    805                     UR_CALL_OP = 0; 
    806                     goto op_throw; 
     813                    goto op_throw_cc; 
    807814                } 
    808815 
    809816                ur_wordCell( pc, blk, val ); 
    810817                ++pc; 
     818 
    811819do_func: 
    812820                if( ur_is(val, UT_FUNCTION) ) 
     
    922930                    goto call_return; 
    923931                } 
     932                else if( ur_is(val, UT_UNSET) ) 
     933                { 
     934                    _throwUnset( ur_thread, pc - 1 ); 
     935                    goto op_throw_cc; 
     936                } 
    924937                else 
    925938                { 
     
    939952                assert( pc->word.index > -1 ); 
    940953                ur_wordCell( pc, blk, val ); 
     954                if( ur_is(val, UT_UNSET) ) 
     955                { 
     956                    _throwUnset( ur_thread, pc ); 
     957                    goto op_throw_cc; 
     958                } 
    941959                ++pc; 
    942960                UR_S_PUSH( *val ); 
     
    946964                if( ! ur_resolveSelector( ur_thread, pc++, UR_S_GROW ) ) 
    947965                { 
    948                     UR_CALL_OP = 0; 
    949                     goto op_throw; 
     966                    goto op_throw_cc; 
    950967                } 
    951968                break; 
     
    10501067    } 
    10511068 
     1069op_throw_cc: 
     1070 
     1071    UR_CALL_OP = 0; 
     1072     
    10521073op_throw: 
    10531074 
     
    17711792            blk = ur_blockPtr( ctx->ctx.valBlk ); 
    17721793            ur_copyCell(ctx, blk->ptr.cells[ wrdN ]); 
     1794            /* 
     1795            if( ur_is(ctx, UT_UNSET) ) 
     1796                _throwUnset( ur_thread, ctx ); 
     1797            */ 
    17731798            return; 
    17741799        }