Changeset 450 for branches/thune
- Timestamp:
- 08/11/07 04:53:46 (16 months ago)
- Location:
- branches/thune/thread_safe
- Files:
-
- 2 added
- 23 modified
-
boot.c (modified) (1 diff)
-
component.c (modified) (1 diff)
-
doc/UserManual (modified) (5 diffs)
-
eval.c (modified) (3 diffs)
-
files.c (modified) (2 diffs)
-
gc.c (modified) (2 diffs)
-
gl/gx_atoms.h (modified) (1 diff)
-
gl/gx_dt.c (modified) (2 diffs)
-
make.c (modified) (4 diffs)
-
math.c (modified) (1 diff)
-
mkboot.t (modified) (1 diff)
-
net.c (modified) (1 diff)
-
parse.c (modified) (6 diffs)
-
print.c (modified) (8 diffs)
-
series.c (modified) (54 diffs)
-
tests/working/bytecode.t (modified) (1 diff)
-
tests/working/encode.t (modified) (1 diff)
-
tests/working/slice.good (added)
-
tests/working/slice.t (added)
-
thread.c (modified) (1 diff)
-
thune.c (modified) (4 diffs)
-
tokenize.c (modified) (1 diff)
-
trim_string.c (modified) (3 diffs)
-
urlan.c (modified) (2 diffs)
-
urlan.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/thune/thread_safe/boot.c
r444 r450 157 157 " ; fullpath file\n" 158 158 " next\n" 159 " dup2 slice ! rot.r make\n"159 " dup2 slice\n" 160 160 " rot.r nip\n" 161 161 " ]\n" -
branches/thune/thread_safe/component.c
r442 r450 43 43 44 44 blk = ur_blockSlice( ut, sigCell, &start, &end ); 45 if( ! blk || ! it )45 if( ! blk || ! start ) 46 46 return 0; 47 47 -
branches/thune/thread_safe/doc/UserManual
r432 r450 89 89 set-select! :obj/x :my-block/2 90 90 lit-select! 'obj/x 'my-block/2 91 slice!92 91 time! 10:02 -0:0:32.08 93 92 context! … … 125 124 126 125 126 Binary 127 ------ 128 129 A binary value references a series of bytes. 130 131 :: 132 133 #{0000ff01} 134 #{0000 ff01} 135 #{68656C6C6F} ; "hello" as binary 136 137 127 138 Strings 128 139 ------- … … 138 149 {This string 139 150 spans multiple lines.} 140 141 142 Slice143 -----144 145 A range within a binary!, string!, or block! can be represented with a slice.146 147 ::148 149 "Hello world" :s150 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*.155 151 156 152 … … 455 451 next (ser -- ser) Increment start of series. 456 452 skip (ser n -- ser) Increment start of series by **n**. 453 slice_ (ser end -- slice) Slice series. 454 slice? (ser end -- slice) True if series is a slice. 457 455 slice.prev (slice -- slice) Decrement end of slice. 458 456 slice.next (slice -- slice) Increment end of slice. … … 631 629 632 630 631 slice 632 ----- 633 634 The 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 643 To move the start of a series by one, use *prev* & *next*. 644 To move the end of a series by one, use *slice.prev* & *slice.next*. 645 646 633 647 change 634 648 ------ -
branches/thune/thread_safe/eval.c
r447 r450 90 90 static int ur_itLen( UThread* ut, UCell* cell ) 91 91 { 92 int len = ur_series Len( cell );92 int len = ur_seriesEnd( cell ); 93 93 if( len > -1 ) 94 94 len -= cell->series.it; … … 704 704 case UT_BINARY: 705 705 case UT_STRING: 706 case UT_SLICE:707 706 { 708 707 char *cpA1, *cpA2; … … 1213 1212 } 1214 1213 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;1220 1214 } 1221 1215 else if( ur_is(val, UT_BITSET) ) -
branches/thune/thread_safe/files.c
r447 r450 661 661 unsigned int blen; 662 662 663 if( ur_ seriesMem( ut, tos, &cpA, &cpB ) )663 if( ur_binaryMem( ut, tos, &cpA, &cpB ) ) 664 664 { 665 665 if( cpA ) … … 807 807 res = UR_TOS; 808 808 809 if( ur_ seriesMem( ut, res, &cpA, &cpB ) )809 if( ur_binaryMem( ut, res, &cpA, &cpB ) ) 810 810 { 811 811 switch( ur_atom(tos) ) -
branches/thune/thread_safe/gc.c
r433 r450 273 273 case UT_VECTOR: 274 274 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;282 275 SET_BIT_BIN_L( it->series.n ) 283 276 break; … … 309 302 case UT_BLOCK: 310 303 case UT_PAREN: 311 mark_block:312 304 idx = it->series.n; 313 305 if( ur_isLocal(idx) ) -
branches/thune/thread_safe/gl/gx_atoms.h
r442 r450 1 1 // This file is automatically generated - do not edit. 2 2 3 #define UR_ATOM_DRAW_LIST_OPCODES 3 194 #define UR_ATOM_WIDTH 32 05 #define UR_ATOM_HEIGHT 32 16 #define UR_ATOM_AREA 32 27 #define UR_ATOM_RECT 32 38 #define UR_ATOM_RASTER 32 49 #define UR_ATOM_TEXTURE 32 510 #define UR_ATOM_ELEM 32 611 #define UR_ATOM_CLOSE 1 7812 #define UR_ATOM_FOCUS 32 713 #define UR_ATOM_RESIZE 3 2814 #define UR_ATOM_KEY_DOWN 3 2915 #define UR_ATOM_KEY_UP 33 016 #define UR_ATOM_MOUSE_MOVE 33 117 #define UR_ATOM_MOUSE_UP 33 218 #define UR_ATOM_MOUSE_DOWN 33 319 #define UR_ATOM_MOUSE_WHEEL 33 420 #define UR_ATOM_AMBIENT 33 521 #define UR_ATOM_DIFFUSE 33 622 #define UR_ATOM_SPECULAR 33 723 #define UR_ATOM_POS 3 3824 #define UR_ATOM_SHADER 3 3925 #define UR_ATOM_VERTEX 34 026 #define UR_ATOM_FRAGMENT 34 127 #define UR_ATOM_DEFAULT 34 228 #define UR_ATOM_WAIT 34 329 #define UR_ATOM_RGB 34 430 #define UR_ATOM_RGBA 34 531 #define UR_ATOM_DEPTH 34 632 #define UR_ATOM_CLAMP 34 733 #define UR_ATOM_REPEAT 3 4834 #define UR_ATOM_NEAREST 3 4935 #define UR_ATOM_LINEAR 35 036 #define UR_ATOM_MIN 35 137 #define UR_ATOM_MAG 35 238 #define UR_ATOM_MIPMAP 35 339 #define UR_ATOM_GRAY 35 440 #define UR_ATOM_RGB 34 441 #define UR_ATOM_RGBA 34 542 #define UR_ATOM_ON 2 5843 #define UR_ATOM_OFF 26 044 #define UR_ATOM_ADD 19 745 #define UR_ATOM_BURN 35 546 #define UR_ATOM_COLOR 35 647 #define UR_ATOM_TRANS 35 748 #define UR_ATOM_SPRITE 3 583 #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 653 653 { 654 654 case UT_STRING: 655 case UT_SLICE:656 655 if( cfg.fontFile ) 657 656 cfg.glyphs = ur_cstring( ut, it ); … … 773 772 774 773 case UT_STRING: 775 case UT_SLICE:776 774 if( cmd == UR_ATOM_VERTEX ) 777 775 vprog = ur_cstring( ut, it ); -
branches/thune/thread_safe/make.c
r447 r450 163 163 UIndex binN = 0; 164 164 165 if( ur_ seriesMem( ut, cell, &cpA, &cpB ) )165 if( ur_binaryMem( ut, cell, &cpA, &cpB ) ) 166 166 { 167 167 int size; … … 1304 1304 1305 1305 1306 /* 1306 1307 static void _setSliceRange( UCell* cell, UIndex a, UIndex b ) 1307 1308 { 1308 1309 if( a < b ) 1309 1310 { 1310 cell->s lice.it = a;1311 cell->s lice.end = b;1311 cell->series.it = a; 1312 cell->series.end = b; 1312 1313 } 1313 1314 else 1314 1315 { 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 */ 1319 1321 1320 1322 … … 1663 1665 UIndex binN; 1664 1666 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 1665 1707 if( ur_is(tos, UT_INT) ) 1666 1708 { … … 1773 1815 res->err.messageStr = tos->series.n; 1774 1816 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 else1801 {1802 res->slice.it = tos->series.it;1803 res->slice.end = -1;1804 }1805 }1806 1817 break; 1807 1818 -
branches/thune/thread_safe/math.c
r441 r450 655 655 if( ur_isASeries( tos ) ) 656 656 { 657 int len = ur_series Len( tos );657 int len = ur_seriesEnd( tos ); 658 658 if( len > 0 ) 659 659 tos->series.it += genrand_int32() % (len - tos->series.it); -
branches/thune/thread_safe/mkboot.t
r444 r450 182 182 ; fullpath file 183 183 next 184 dup2 slice ! rot.r make184 dup2 slice 185 185 rot.r nip 186 186 ] -
branches/thune/thread_safe/net.c
r447 r450 182 182 static int _netOpen( UPortDevice* dev, UThread* ut, UCell* tos ) 183 183 { 184 int port;185 184 struct sockaddr_in addr; 185 int port = 0; 186 186 UCell* spec = 0; 187 187 UCell* res = ur_s_prev(tos); -
branches/thune/thread_safe/parse.c
r398 r450 308 308 ++rit; 309 309 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 ); 314 312 } 315 313 break; … … 321 319 ++rit; 322 320 323 if( ur_is(cell, UT_S LICE) && (cell->series.n == pe->input.n) )324 cell->s lice.end = pos;321 if( ur_is(cell, UT_STRING) && (cell->series.n == pe->input.n) ) 322 cell->series.end = pos; 325 323 } 326 324 break; … … 812 810 ++rit; 813 811 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 ); 818 814 } 819 815 break; … … 826 822 ++rit; 827 823 828 if( ur_is(cell, UT_ SLICE) && (cell->series.n == pe->input.n) )829 cell->s lice.end = pos;824 if( ur_is(cell, UT_BLOCK) && (cell->series.n == pe->input.n) ) 825 cell->series.end = pos; 830 826 } 831 827 break; … … 1065 1061 if( ur_is(rules, UT_BLOCK) ) 1066 1062 { 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) ) 1069 1064 { 1070 1065 StringParser pe; … … 1112 1107 return; 1113 1108 } 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) ) 1116 1110 { 1117 1111 BlockParser pe; -
branches/thune/thread_safe/print.c
r442 r450 55 55 56 56 /* 57 c2 must be a string! or string slice!.57 c2 must be a string!. 58 58 */ 59 59 void ur_strCatCell( UThread* ut, UString* out, int encoding, const UCell* c2 ) … … 66 66 si = c2->series.it; 67 67 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 ); 74 69 used -= si; 75 70 … … 263 258 static void _binCellToStr( UThread* ut, UString* out, const UCell* val ) 264 259 { 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 ); 269 266 } 270 267 … … 783 780 case UT_BLOCK: 784 781 { 782 UCell* vp; 783 UCell* end; 785 784 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; 791 791 while( 1 ) 792 792 { … … 799 799 } 800 800 } 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 }810 801 break; 811 802 … … 1012 1003 { 1013 1004 UString* str = ur_bin( val ); 1005 UIndex n = ur_sliceEnd( val, str ); 1006 if( n < val->series.it ) 1007 n = val->series.it; 1014 1008 if( ur_encoding(val) == UR_ENC_UTF16 ) 1015 1009 { 1016 1010 _appendStringUtf16( out, str->ptr.u16 + val->series.it, 1017 str->ptr.u16 + str->used);1011 str->ptr.u16 + n ); 1018 1012 } 1019 1013 else 1020 1014 { 1021 1015 _appendStringAscii( out, str->ptr.c + val->series.it, 1022 str->ptr.c + str->used);1016 str->ptr.c + n ); 1023 1017 } 1024 1018 } … … 1182 1176 case UT_BLOCK:
