Changeset 450 for branches/thune

Show
Ignore:
Timestamp:
08/11/07 04:53:46 (16 months ago)
Author:
krobillard
Message:

Removed slice! datatype - series now have an end.
Added slice test.
ur_makeBinary() now takes pointer argument.
Fixed bug in _makeComponent().
Fixed compiler warnings. Minor optimization to if/.

Location:
branches/thune/thread_safe
Files:
2 added
23 modified

Legend:

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

    r444 r450  
    157157  "      ; fullpath file\n" 
    158158  "      next\n" 
    159   "      dup2 slice! rot.r make\n" 
     159  "      dup2 slice\n" 
    160160  "      rot.r nip\n" 
    161161  "    ]\n" 
  • branches/thune/thread_safe/component.c

    r442 r450  
    4343 
    4444    blk = ur_blockSlice( ut, sigCell, &start, &end ); 
    45     if( ! blk || ! it ) 
     45    if( ! blk || ! start ) 
    4646        return 0; 
    4747 
  • branches/thune/thread_safe/doc/UserManual

    r432 r450  
    8989set-select!  :obj/x :my-block/2 
    9090lit-select!  'obj/x 'my-block/2 
    91 slice! 
    9291time!        10:02 -0:0:32.08 
    9392context! 
     
    125124 
    126125 
     126Binary 
     127------ 
     128 
     129A binary value references a series of bytes. 
     130 
     131:: 
     132 
     133     #{0000ff01} 
     134     #{0000 ff01} 
     135     #{68656C6C6F}     ; "hello" as binary 
     136 
     137 
    127138Strings 
    128139------- 
     
    138149   {This string 
    139150   spans multiple lines.} 
    140  
    141  
    142 Slice 
    143 ----- 
    144  
    145 A range within a binary!, string!, or block! can be represented with a slice. 
    146  
    147 :: 
    148  
    149     "Hello world" :s 
    150     slice! s make .                  ; "Hello world" 
    151     slice! s next dup 4 skip make .  ; "ello" 
    152  
    153 To move the start of the slice use *prev* & *next*, as with a series. 
    154 To move the end of the slice use *slice.prev* & *slice.next*. 
    155151 
    156152 
     
    455451next        (ser -- ser)            Increment start of series. 
    456452skip        (ser n -- ser)          Increment start of series by **n**. 
     453slice_      (ser end -- slice)      Slice series. 
     454slice?      (ser end -- slice)      True if series is a slice. 
    457455slice.prev  (slice -- slice)        Decrement end of slice. 
    458456slice.next  (slice -- slice)        Increment end of slice. 
     
    631629 
    632630 
     631slice 
     632----- 
     633 
     634The slice word is used to control the slice range of a series value. 
     635 
     636:: 
     637 
     638    "Hello world" :s 
     639    s 2,6 slice .          ; "ello" 
     640    s -2 slice .           ; ""Hello wor" 
     641 
     642 
     643To move the start of a series by one, use *prev* & *next*. 
     644To move the end of a series by one, use *slice.prev* & *slice.next*. 
     645 
     646 
    633647change 
    634648------ 
  • branches/thune/thread_safe/eval.c

    r447 r450  
    9090static int ur_itLen( UThread* ut, UCell* cell ) 
    9191{ 
    92     int len = ur_seriesLen( cell ); 
     92    int len = ur_seriesEnd( cell ); 
    9393    if( len > -1 ) 
    9494        len -= cell->series.it; 
     
    704704        case UT_BINARY: 
    705705        case UT_STRING: 
    706         case UT_SLICE: 
    707706        { 
    708707            char *cpA1, *cpA2; 
     
    12131212                } 
    12141213                ur_type(val) = UT_BINARY; 
    1215             } 
    1216             else if( ur_is(val, UT_SLICE) && (ur_sliceDT(val) == UT_STRING) ) 
    1217             { 
    1218                 if( ur_encCharSize(val) == 1 ) 
    1219                     ur_sliceDT(val) = UT_BINARY; 
    12201214            } 
    12211215            else if( ur_is(val, UT_BITSET) ) 
  • branches/thune/thread_safe/files.c

    r447 r450  
    661661    unsigned int blen; 
    662662 
    663     if( ur_seriesMem( ut, tos, &cpA, &cpB ) ) 
     663    if( ur_binaryMem( ut, tos, &cpA, &cpB ) ) 
    664664    { 
    665665        if( cpA ) 
     
    807807    res = UR_TOS; 
    808808 
    809     if( ur_seriesMem( ut, res, &cpA, &cpB ) ) 
     809    if( ur_binaryMem( ut, res, &cpA, &cpB ) ) 
    810810    { 
    811811        switch( ur_atom(tos) ) 
  • branches/thune/thread_safe/gc.c

    r433 r450  
    273273            case UT_VECTOR: 
    274274            case UT_BITSET: 
    275                 SET_BIT_BIN_L( it->series.n ) 
    276                 break; 
    277  
    278             case UT_SLICE: 
    279                 if( ur_sliceDT(it) == UT_BLOCK || 
    280                     ur_sliceDT(it) == UT_PAREN ) 
    281                     goto mark_block; 
    282275                SET_BIT_BIN_L( it->series.n ) 
    283276                break; 
     
    309302            case UT_BLOCK: 
    310303            case UT_PAREN: 
    311 mark_block: 
    312304                idx = it->series.n; 
    313305                if( ur_isLocal(idx) ) 
  • branches/thune/thread_safe/gl/gx_atoms.h

    r442 r450  
    11// This file is automatically generated - do not edit. 
    22 
    3 #define UR_ATOM_DRAW_LIST_OPCODES               319 
    4 #define UR_ATOM_WIDTH           320 
    5 #define UR_ATOM_HEIGHT          321 
    6 #define UR_ATOM_AREA            322 
    7 #define UR_ATOM_RECT            323 
    8 #define UR_ATOM_RASTER          324 
    9 #define UR_ATOM_TEXTURE         325 
    10 #define UR_ATOM_ELEM            326 
    11 #define UR_ATOM_CLOSE           178 
    12 #define UR_ATOM_FOCUS           327 
    13 #define UR_ATOM_RESIZE          328 
    14 #define UR_ATOM_KEY_DOWN                329 
    15 #define UR_ATOM_KEY_UP          330 
    16 #define UR_ATOM_MOUSE_MOVE              331 
    17 #define UR_ATOM_MOUSE_UP                332 
    18 #define UR_ATOM_MOUSE_DOWN              333 
    19 #define UR_ATOM_MOUSE_WHEEL             334 
    20 #define UR_ATOM_AMBIENT         335 
    21 #define UR_ATOM_DIFFUSE         336 
    22 #define UR_ATOM_SPECULAR                337 
    23 #define UR_ATOM_POS             338 
    24 #define UR_ATOM_SHADER          339 
    25 #define UR_ATOM_VERTEX          340 
    26 #define UR_ATOM_FRAGMENT                341 
    27 #define UR_ATOM_DEFAULT         342 
    28 #define UR_ATOM_WAIT            343 
    29 #define UR_ATOM_RGB             344 
    30 #define UR_ATOM_RGBA            345 
    31 #define UR_ATOM_DEPTH           346 
    32 #define UR_ATOM_CLAMP           347 
    33 #define UR_ATOM_REPEAT          348 
    34 #define UR_ATOM_NEAREST         349 
    35 #define UR_ATOM_LINEAR          350 
    36 #define UR_ATOM_MIN             351 
    37 #define UR_ATOM_MAG             352 
    38 #define UR_ATOM_MIPMAP          353 
    39 #define UR_ATOM_GRAY            354 
    40 #define UR_ATOM_RGB             344 
    41 #define UR_ATOM_RGBA            345 
    42 #define UR_ATOM_ON              258 
    43 #define UR_ATOM_OFF             260 
    44 #define UR_ATOM_ADD             197 
    45 #define UR_ATOM_BURN            355 
    46 #define UR_ATOM_COLOR           356 
    47 #define UR_ATOM_TRANS           357 
    48 #define UR_ATOM_SPRITE          358 
     3#define UR_ATOM_DRAW_LIST_OPCODES               321 
     4#define UR_ATOM_WIDTH           322 
     5#define UR_ATOM_HEIGHT          323 
     6#define UR_ATOM_AREA            324 
     7#define UR_ATOM_RECT            325 
     8#define UR_ATOM_RASTER          326 
     9#define UR_ATOM_TEXTURE         327 
     10#define UR_ATOM_ELEM            328 
     11#define UR_ATOM_CLOSE           180 
     12#define UR_ATOM_FOCUS           329 
     13#define UR_ATOM_RESIZE          330 
     14#define UR_ATOM_KEY_DOWN                331 
     15#define UR_ATOM_KEY_UP          332 
     16#define UR_ATOM_MOUSE_MOVE              333 
     17#define UR_ATOM_MOUSE_UP                334 
     18#define UR_ATOM_MOUSE_DOWN              335 
     19#define UR_ATOM_MOUSE_WHEEL             336 
     20#define UR_ATOM_AMBIENT         337 
     21#define UR_ATOM_DIFFUSE         338 
     22#define UR_ATOM_SPECULAR                339 
     23#define UR_ATOM_POS             340 
     24#define UR_ATOM_SHADER          341 
     25#define UR_ATOM_VERTEX          342 
     26#define UR_ATOM_FRAGMENT                343 
     27#define UR_ATOM_DEFAULT         344 
     28#define UR_ATOM_WAIT            345 
     29#define UR_ATOM_RGB             346 
     30#define UR_ATOM_RGBA            347 
     31#define UR_ATOM_DEPTH           348 
     32#define UR_ATOM_CLAMP           349 
     33#define UR_ATOM_REPEAT          350 
     34#define UR_ATOM_NEAREST         351 
     35#define UR_ATOM_LINEAR          352 
     36#define UR_ATOM_MIN             353 
     37#define UR_ATOM_MAG             354 
     38#define UR_ATOM_MIPMAP          355 
     39#define UR_ATOM_GRAY            356 
     40#define UR_ATOM_RGB             346 
     41#define UR_ATOM_RGBA            347 
     42#define UR_ATOM_ON              260 
     43#define UR_ATOM_OFF             262 
     44#define UR_ATOM_ADD             199 
     45#define UR_ATOM_BURN            357 
     46#define UR_ATOM_COLOR           358 
     47#define UR_ATOM_TRANS           359 
     48#define UR_ATOM_SPRITE          360 
  • branches/thune/thread_safe/gl/gx_dt.c

    r449 r450  
    653653                { 
    654654                    case UT_STRING: 
    655                     case UT_SLICE: 
    656655                        if( cfg.fontFile ) 
    657656                            cfg.glyphs = ur_cstring( ut, it ); 
     
    773772 
    774773                    case UT_STRING: 
    775                     case UT_SLICE: 
    776774                        if( cmd == UR_ATOM_VERTEX ) 
    777775                            vprog = ur_cstring( ut, it ); 
  • branches/thune/thread_safe/make.c

    r447 r450  
    163163    UIndex binN = 0; 
    164164 
    165     if( ur_seriesMem( ut, cell, &cpA, &cpB ) ) 
     165    if( ur_binaryMem( ut, cell, &cpA, &cpB ) ) 
    166166    { 
    167167        int size; 
     
    13041304 
    13051305 
     1306/* 
    13061307static void _setSliceRange( UCell* cell, UIndex a, UIndex b ) 
    13071308{ 
    13081309    if( a < b ) 
    13091310    { 
    1310         cell->slice.it  = a; 
    1311         cell->slice.end = b; 
     1311        cell->series.it  = a; 
     1312        cell->series.end = b; 
    13121313    } 
    13131314    else 
    13141315    { 
    1315         cell->slice.it  = a; 
    1316         cell->slice.end = b; 
    1317     } 
    1318 } 
     1316        cell->series.it  = a; 
     1317        cell->series.end = b; 
     1318    } 
     1319} 
     1320*/ 
    13191321 
    13201322 
     
    16631665            UIndex binN; 
    16641666 
     1667#if 0 
     1668#ifdef LANG_THUNE 
     1669            if( argc == 2 ) 
     1670            { 
     1671                UCell* pc = ur_s_prev(tos); 
     1672 
     1673                ur_initType(res, UT_STRING); 
     1674                ur_sliceDT(res) = ur_type(tos); 
     1675                res->series.n = tos->series.n; 
     1676 
     1677                if( ur_is(tos, UT_STRING) ) 
     1678                    ur_encoding(res) = ur_encoding(tos); 
     1679                if( ur_isASeries(pc) ) 
     1680                { 
     1681                    _setSliceRange( res, pc->series.it, tos->series.it ); 
     1682                } 
     1683                else if( ur_is(pc, UT_COORD) ) 
     1684                { 
     1685                    int a, b; 
     1686 
     1687                    a = pc->coord.elem[0]; 
     1688                    b = pc->coord.elem[1]; 
     1689                    if( a < 1 ) 
     1690                        a = 0; 
     1691                    else 
     1692                        --a; 
     1693                    if( b < 1 ) 
     1694                    { 
     1695                        UString* str = ur_bin(tos); 
     1696                        b += ur_sliceEnd(tos, str); 
     1697                    } 
     1698                    else 
     1699                        --b; 
     1700 
     1701                    _setSliceRange( res, a, b ); 
     1702                } 
     1703            } 
     1704            else 
     1705#endif 
     1706#endif 
    16651707            if( ur_is(tos, UT_INT) ) 
    16661708            { 
     
    17731815            res->err.messageStr = tos->series.n; 
    17741816            res->err.traceBlk   = ur_makeBlock( 8 ); 
    1775             break; 
    1776  
    1777         case UT_SLICE: 
    1778             if( ur_isASeries(tos) ) 
    1779             { 
    1780                 ur_initType(res, UT_SLICE); 
    1781                 ur_sliceDT(res) = ur_type(tos); 
    1782                 res->series.n = tos->series.n; 
    1783  
    1784                 if( ur_is(tos, UT_STRING) ) 
    1785                     ur_encoding(res) = ur_encoding(tos); 
    1786  
    1787                 if( argc == 2 ) 
    1788                 { 
    1789                     UCell* pc = ur_s_prev(tos); 
    1790                     if( ur_isASeries(pc) ) 
    1791                     { 
    1792                         _setSliceRange( res, pc->series.it, tos->series.it ); 
    1793                     } 
    1794                     else if( ur_is(pc, UT_COORD) ) 
    1795                     { 
    1796                         _setSliceRange( res, pc->coord.elem[0] - 1, 
    1797                                              pc->coord.elem[1] - 1 ); 
    1798                     } 
    1799                 } 
    1800                 else 
    1801                 { 
    1802                     res->slice.it  = tos->series.it; 
    1803                     res->slice.end = -1; 
    1804                 } 
    1805             } 
    18061817            break; 
    18071818 
  • branches/thune/thread_safe/math.c

    r441 r450  
    655655    if( ur_isASeries( tos ) ) 
    656656    { 
    657         int len = ur_seriesLen( tos ); 
     657        int len = ur_seriesEnd( tos ); 
    658658        if( len > 0 ) 
    659659            tos->series.it += genrand_int32() % (len - tos->series.it); 
  • branches/thune/thread_safe/mkboot.t

    r444 r450  
    182182      ; fullpath file 
    183183      next 
    184       dup2 slice! rot.r make 
     184      dup2 slice 
    185185      rot.r nip 
    186186    ] 
  • branches/thune/thread_safe/net.c

    r447 r450  
    182182static int _netOpen( UPortDevice* dev, UThread* ut, UCell* tos ) 
    183183{ 
    184     int port; 
    185184    struct sockaddr_in addr; 
     185    int port = 0; 
    186186    UCell* spec = 0; 
    187187    UCell* res = ur_s_prev(tos); 
  • branches/thune/thread_safe/parse.c

    r398 r450  
    308308                ++rit; 
    309309 
    310                 ur_initType( cell, UT_SLICE ); 
    311                 ur_sliceDT(cell) = UT_STRING; 
    312                 ur_setSeries( cell, pe->input.n, pos ); 
    313                 cell->slice.end = pe->input.end; 
     310                ur_initType( cell, UT_STRING ); 
     311                ur_setSlice( cell, pe->input.n, pos, pe->input.end ); 
    314312            } 
    315313                break; 
     
    321319                ++rit; 
    322320 
    323                 if( ur_is(cell, UT_SLICE) && (cell->series.n == pe->input.n) ) 
    324                     cell->slice.end = pos; 
     321                if( ur_is(cell, UT_STRING) && (cell->series.n == pe->input.n) ) 
     322                    cell->series.end = pos; 
    325323            } 
    326324                break; 
     
    812810                ++rit; 
    813811 
    814                 ur_initType( cell, UT_SLICE ); 
    815                 ur_sliceDT(cell) = UT_BLOCK; 
    816                 ur_setSeries( cell, pe->input.n, pos ); 
    817                 cell->slice.end = pe->input.end; 
     812                ur_initType( cell, UT_BLOCK ); 
     813                ur_setSlice( cell, pe->input.n, pos, pe->input.end ); 
    818814            } 
    819815                break; 
     
    826822                ++rit; 
    827823 
    828                 if( ur_is(cell, UT_SLICE) && (cell->series.n == pe->input.n) ) 
    829                     cell->slice.end = pos; 
     824                if( ur_is(cell, UT_BLOCK) && (cell->series.n == pe->input.n) ) 
     825                    cell->series.end = pos; 
    830826            } 
    831827                break; 
     
    10651061    if( ur_is(rules, UT_BLOCK) ) 
    10661062    { 
    1067         if( ur_is(ser, UT_STRING) || 
    1068             (ur_is(ser, UT_SLICE) && (ur_sliceDT(ser) == UT_STRING)) ) 
     1063        if( ur_is(ser, UT_STRING) ) 
    10691064        { 
    10701065            StringParser pe; 
     
    11121107            return; 
    11131108        } 
    1114         else if( ur_is(ser, UT_BLOCK) || 
    1115                 (ur_is(ser, UT_SLICE) && (ur_sliceDT(ser) == UT_BLOCK)) ) 
     1109        else if( ur_is(ser, UT_BLOCK) ) 
    11161110        { 
    11171111            BlockParser pe; 
  • branches/thune/thread_safe/print.c

    r442 r450  
    5555 
    5656/* 
    57    c2 must be a string! or string slice!. 
     57   c2 must be a string!. 
    5858*/ 
    5959void ur_strCatCell( UThread* ut, UString* out, int encoding, const UCell* c2 ) 
     
    6666    si = c2->series.it; 
    6767 
    68     used = str2->used; 
    69     if( ur_is(c2, UT_SLICE) ) 
    70     { 
    71         if( used > c2->slice.end ) 
    72             used = c2->slice.end; 
    73     } 
     68    used = ur_sliceEnd( c2, str2 ); 
    7469    used -= si; 
    7570 
     
    263258static void _binCellToStr( UThread* ut, UString* out, const UCell* val ) 
    264259{ 
    265     UString* bin = ur_binPtr( val->series.n ); 
    266     _binToStr( out,  
    267                bin->ptr.b + val->series.it, 
    268                bin->ptr.b + bin->used ); 
     260    UBinary* bin = ur_bin( val ); 
     261    UIndex n = ur_sliceEnd( val, bin ); 
     262    if( n < val->series.it ) 
     263        n = val->series.it; 
     264    _binToStr( out, bin->ptr.b + val->series.it, 
     265                    bin->ptr.b + n ); 
    269266} 
    270267 
     
    783780        case UT_BLOCK: 
    784781        { 
     782            UCell* vp; 
     783            UCell* end; 
    785784            UBlock* blk = ur_block( val ); 
    786             UCell* vp  = blk->ptr.cells + val->series.it; 
    787             UCell* end = blk->ptr.cells + blk->used; 
    788  
    789             if( vp != end ) 
    790             { 
     785            UIndex n = ur_sliceEnd( val, blk ); 
     786 
     787            if( n > val->series.it ) 
     788            { 
     789                vp  = blk->ptr.cells + val->series.it; 
     790                end = blk->ptr.cells + n; 
    791791                while( 1 ) 
    792792                { 
     
    799799            } 
    800800        } 
    801             break; 
    802  
    803         case UT_SLICE: 
    804             switch( ur_sliceDT(val) ) 
    805             { 
    806                 case UT_STRING: 
    807                     ur_strCatCell( ut, out, UR_ENC_ASCII, val ); 
    808                     break; 
    809             } 
    810801            break; 
    811802 
     
    10121003        { 
    10131004            UString* str = ur_bin( val ); 
     1005            UIndex n = ur_sliceEnd( val, str ); 
     1006            if( n < val->series.it ) 
     1007                n = val->series.it; 
    10141008            if( ur_encoding(val) == UR_ENC_UTF16 ) 
    10151009            { 
    10161010                _appendStringUtf16( out, str->ptr.u16 + val->series.it, 
    1017                                          str->ptr.u16 + str->used ); 
     1011                                         str->ptr.u16 + n ); 
    10181012            } 
    10191013            else 
    10201014            { 
    10211015                _appendStringAscii( out, str->ptr.c + val->series.it, 
    1022                                          str->ptr.c + str->used ); 
     1016                                         str->ptr.c + n ); 
    10231017            } 
    10241018        } 
     
    11821176        case UT_BLOCK: