Changeset 184 for trunk/thune/make.c

Show
Ignore:
Timestamp:
06/12/06 01:58:22 (3 years ago)
Author:
krobillard
Message:

Thune -

Word lookup now uses an ordered binary search.
Renamed ur_setType as ur_initType.
Some error reporting improvements in eval.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/make.c

    r178 r184  
    203203    ur_arrayInit( ptrB, sizeof(UCell), wordCount ); 
    204204 
    205     ur_setType( ctx, UT_CONTEXT ); 
     205    ur_initType( ctx, UT_CONTEXT ); 
    206206    ctx->ctx.wordBlk     = ur_blockN( ptrA ); 
    207207    ctx->ctx.valBlk      = ur_blockN( ptrB ); 
     
    279279                while( it != rend ) 
    280280                { 
    281                     ur_setType( it, UT_NONE ); 
     281                    ur_initType( it, UT_NONE ); 
    282282                    ++it; 
    283283                } 
     
    683683    if( i == count ) 
    684684    { 
    685         ur_setType( res, UT_DATATYPE ); 
     685        ur_initType( res, UT_DATATYPE ); 
    686686        ur_datatype(res) = UT_TYPEMASK; 
    687687        res->dt.bitCount = count; 
     
    695695    if( count == 2 ) 
    696696    { 
    697         ur_setType( res, UT_SELECTOR ); 
     697        ur_initType( res, UT_SELECTOR ); 
    698698        if( nodeType & 2 ) 
    699699            res->id.flags |= UR_FLAG_SEL_ATOM; 
    700         res->word.valBlk = GLOBAL_VAL_BLKN; 
    701         res->word.atom   = node[0]; 
    702         ur_selector(res) = node[1]; 
    703         res->word.index  = ur_internWord( &ur_global, res->word.atom ); 
     700        res->word.wordBlk = 0; 
     701        res->word.valBlk  = GLOBAL_VAL_BLKN; 
     702        res->word.atom    = node[0]; 
     703        ur_selector(res)  = node[1]; 
     704        res->word.index   = ur_internWord( &ur_global, res->word.atom ); 
    704705 
    705706        return 1; 
     
    737738 
    738739        cell = vblk->ptr.cells + wrdN; 
    739         ur_setType( cell, UT_CALL ); 
     740        ur_initType( cell, UT_CALL ); 
    740741        cell->call.addr = (call_t) def->addr; 
    741742 
     
    758759    UCell* cell; 
    759760    UR_EXPAND_1( UCell, blk, cell ); 
    760     ur_setType( cell, type ); 
     761    ur_initType( cell, type ); 
    761762    return cell; 
    762763} 
     
    772773    cell = ur_appendCell( blk, type ); 
    773774 
     775    cell->word.atom    = ur_intern( name, len ); 
    774776    cell->word.wordBlk = 0;     //GLOBAL_WORD_BLKN; 
    775777    cell->word.valBlk  = GLOBAL_VAL_BLKN; 
    776     cell->word.atom    = ur_intern( name, len ); 
     778    cell->word.sel     = UR_CTX_UNORDERED; 
    777779 
    778780    if( type != UT_LITWORD ) 
     
    846848            if( ur_is(tos, UT_LITWORD) && ur_is(ur_s_prev(tos), UT_INT) ) 
    847849            { 
    848                 ur_setType( res, UT_OPCODE ); 
    849                 ur_opcode(res) = ur_int(ur_s_next(res)); 
    850                 ur_atom(res)   = ur_atom(tos); 
     850                ur_initType( res, UT_OPCODE ); 
     851                ur_atom(res)     = ur_atom(tos); 
     852                ur_opcode(res)   = ur_int(ur_s_next(res)); 
     853                ur_selector(res) = 0; 
    851854            } 
    852855            break; 
    853856 
    854857        case UT_LOGIC: 
    855             ur_setType( res, UT_LOGIC ); 
     858            ur_initType( res, UT_LOGIC ); 
    856859            ur_logic(res) = ur_int(tos) ? 1 : 0; 
    857860            break; 
     
    866869 
    867870                // Word is added to global context. 
    868                 ur_setType( res, t ); 
     871                ur_initType( res, t ); 
    869872                res->word.wordBlk = 0; 
    870873                res->word.valBlk  = GLOBAL_VAL_BLKN; 
     
    885888            if( ur_is(tos, UT_INT) ) 
    886889            { 
    887                 ur_setType( res, UT_CHAR ); 
     890                ur_initType( res, UT_CHAR ); 
    888891                ur_char(res) = ur_int(tos); 
    889892            } 
     
    892895                if( spA ) 
    893896                { 
    894                     ur_setType( res, UT_CHAR ); 
     897                    ur_initType( res, UT_CHAR ); 
    895898 
    896899                    if( *spA == ESCAPE_CHAR ) 
     
    924927            else 
    925928                goto error; 
    926             ur_setType( res, UT_INT ); 
     929            ur_initType( res, UT_INT ); 
    927930            ur_int(res) = n; 
    928931        } 
     
    943946            else 
    944947                goto error; 
    945             ur_setType( res, UT_DECIMAL ); 
     948            ur_initType( res, UT_DECIMAL ); 
    946949            ur_decimal(res) = n; 
    947950        } 
     
    954957                UIndex blkN; 
    955958                blkN = ur_makeBlock( ur_int(tos) ); 
    956                 ur_setType(res, ur_datatype(res) ); 
     959                ur_initType(res, ur_datatype(res) ); 
    957960                ur_setSeries(res, blkN, 0); 
    958961            } 
     
    968971                if( blkN ) 
    969972                { 
    970                     ur_setType(res, ur_datatype(res) ); 
     973                    ur_initType(res, ur_datatype(res) ); 
    971974                    ur_setSeries(res, blkN, 0); 
    972975                } 
     
    10131016                } 
    10141017 
    1015                 ur_setType(res, UT_BINARY); 
     1018                ur_initType(res, UT_BINARY); 
    10161019                ur_setSeries(res, binN, 0); 
    10171020            } 
     
    10281031                UIndex binN; 
    10291032                binN = ur_makeBinary( ur_int(tos) ); 
    1030                 ur_setType(res, UT_STRING); 
     1033                ur_initType(res, UT_STRING); 
    10311034                //ur_setEncoding(res, UR_ENC_ASCII); 
    10321035                ur_setSeries(res, binN, 0); 
     
    10421045                ur_toStr( tos, str, 0 ); 
    10431046 
    1044                 ur_setType(res, UT_STRING); 
     1047                ur_initType(res, UT_STRING); 
    10451048                //ur_setEncoding(res, UR_ENC_ASCII); 
    10461049                ur_setSeries(res, binN, 0); 
     
    10551058                    binN = ur_makeBinary( 0 ); 
    10561059 
    1057                 ur_setType(res, UT_STRING); 
     1060                ur_initType(res, UT_STRING); 
    10581061                //ur_setEncoding(res, UR_ENC_ASCII); 
    10591062                ur_setSeries(res, binN, 0); 
     
    10831086            // Make bitset before setting res in case GC is called. 
    10841087            UIndex binN = ur_makeBitset(tos); 
    1085             ur_setType(res, UT_BITSET); 
     1088            ur_initType(res, UT_BITSET); 
    10861089            ur_setSeries(res, binN, 0); 
    10871090        } 
     
    10921095                goto error; 
    10931096 
    1094             ur_setType(res, UT_ERROR); 
     1097            ur_initType(res, UT_ERROR); 
    10951098            res->err.exType     = UR_EX_SCRIPT; 
    10961099            res->err.messageStr = tos->series.n; 
     
    11011104            if( ur_isASeries(tos) ) 
    11021105            { 
    1103                 ur_setType(res, UT_SLICE); 
     1106                ur_initType(res, UT_SLICE); 
    11041107                ur_sliceDT(res) = ur_type(tos); 
    11051108                res->series.n = tos->series.n;