Changeset 538 for trunk/thune/eval.c

Show
Ignore:
Timestamp:
06/14/08 16:30:57 (6 months ago)
Author:
krobillard
Message:

Added get/words, isGlobalIndex(), and 10 reserved atoms.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/eval.c

    r533 r538  
    10891089   (word -- val) 
    10901090   (word ctx -- val) 
     1091   /words (ctx -- blk) 
    10911092*/ 
    10921093UR_CALL( uc_get ) 
     
    11071108    else if( ur_is(tos, UT_CONTEXT) ) 
    11081109    { 
    1109         val = ur_s_prev( tos ); 
    1110         if( ur_isAWord(val) ) 
    1111         { 
    1112             UBlock* blk; 
    1113             int wrdN; 
    1114  
    1115             wrdN = ur_lookup( tos, ur_atom(val) ); 
    1116             if( wrdN > -1 ) 
    1117             { 
    1118                 blk = ur_blockPtr( tos->ctx.valBlk ); 
    1119                 ur_copyCell(val, blk->ptr.cells[ wrdN ]); 
    1120                 /* 
    1121                 if( ur_is(ctx, UT_UNSET) ) 
    1122                     _throwUnset( ut, ctx ); 
    1123                 */ 
    1124             } 
    1125             else 
    1126             { 
    1127                 ur_setNone( val ); 
    1128             } 
    1129  
    1130             UR_S_DROP; 
     1110        UBlock* blk; 
     1111        UCell* inv = UR_CALL_CELL; 
     1112 
     1113        if( inv && ur_sel(inv) == UR_ATOM_WORDS ) 
     1114        { 
     1115            int len; 
     1116            UIndex blkN; 
     1117 
     1118            blk = ur_blockPtr( tos->ctx.valBlk ); 
     1119            len = blk->used; 
     1120            blk = ur_blockPtr( tos->ctx.wordBlk ); 
     1121            val = blk->ptr.cells; 
     1122 
     1123            blkN = ur_makeBlockT( ut, len, &blk );     // gc! 
     1124            ur_copyCells( val, val + len, blk->ptr.cells ); 
     1125            blk->used = len; 
     1126            ur_bindT( ut, blkN, tos, isGlobalIndex(tos->ctx.valBlk) ? 
     1127                                         UR_BIND_GLOBAL : UR_BIND_THREAD ); 
     1128 
     1129            ur_initBlock( tos, blkN, 0 );  
    11311130            return; 
     1131        } 
     1132        else 
     1133        { 
     1134            val = ur_s_prev( tos ); 
     1135            if( ur_isAWord(val) ) 
     1136            { 
     1137                int wrdN; 
     1138 
     1139                wrdN = ur_lookup( tos, ur_atom(val) ); 
     1140                if( wrdN > -1 ) 
     1141                { 
     1142                    blk = ur_blockPtr( tos->ctx.valBlk ); 
     1143                    ur_copyCell(val, blk->ptr.cells[ wrdN ]); 
     1144                    /* 
     1145                    if( ur_is(ctx, UT_UNSET) ) 
     1146                        _throwUnset( ut, ctx ); 
     1147                    */ 
     1148                } 
     1149                else 
     1150                { 
     1151                    ur_setNone( val ); 
     1152                } 
     1153 
     1154                UR_S_DROP; 
     1155                return; 
     1156            } 
    11321157        } 
    11331158    } 
     
    11541179#endif 
    11551180 
    1156     ur_throwErr( UR_ERR_DATATYPE, "get expected word!" ); 
     1181    ur_throwErr( UR_ERR_DATATYPE, "get expected word!/context!" ); 
    11571182} 
    11581183