Changeset 510
- Timestamp:
- 02/10/08 23:53:46 (8 months ago)
- Location:
- trunk/thune
- Files:
-
- 1 added
- 23 modified
-
boot.c (modified) (2 diffs)
-
config.t (modified) (1 diff)
-
doc/UserManual (modified) (3 diffs)
-
doc/thune.vim (modified) (1 diff)
-
fcalc.c (added)
-
files.c (modified) (3 diffs)
-
gc.c (modified) (1 diff)
-
gl/gx_atoms.h (modified) (1 diff)
-
internal.h (modified) (5 diffs)
-
make.c (modified) (1 diff)
-
math.c (modified) (2 diffs)
-
mkboot.t (modified) (2 diffs)
-
net.c (modified) (2 diffs)
-
project.r (modified) (1 diff)
-
read_config.r (modified) (1 diff)
-
scripts/mandel.t (modified) (1 diff)
-
scripts/nsieve.t (modified) (2 diffs)
-
stdio.c (modified) (1 diff)
-
tests/working/inc.good (modified) (1 diff)
-
tests/working/inc.t (modified) (2 diffs)
-
thune.c (modified) (7 diffs)
-
urlan.c (modified) (1 diff)
-
urlan.h (modified) (2 diffs)
-
urlan_atoms.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/boot.c
r507 r510 36 36 " opcode! 31 'verify make :verify\n" 37 37 " opcode! 32 'forever make :forever\n" 38 " opcode! 33 'loop make :loop\n" 38 39 " int!/decimal! :number!\n" 39 40 " word!/set-word!/get-word!/lit-word! :any-word!\n" … … 65 66 "]\n" 66 67 "'loop proc :while ;(block cond -- )\n" 67 "[\n"68 " int! verify\n"69 " [dup zero? ift break over do dec] forever\n"70 " drop drop\n"71 "]\n"72 "'loop proc :loop ;(block count -- )\n"73 68 "[body n number! limit number!] [\n" 74 69 " n\n" -
trunk/thune/config.t
r458 r510 4 4 [x] trig "Include trigonometric math calls" 5 5 [x] math3d "Include vector & matrix math calls" 6 enable trig6 enable [trig fcalc] 7 7 [x] macros "Reader macros" 8 8 [x] net "UDP socket port" 9 9 [x] dataflow "Component! datatype for dataflow programming" 10 [X] fcalc "Floating point calculator" 10 11 11 12 [ ] threads "CPU Threads" -
trunk/thune/doc/UserManual
r509 r510 364 364 either (logic t-val f-val -- ) Evaluate either t-val or f-val. 365 365 forever (block -- ) Evaluate block until exception thrown. 366 loop_ (block n -- ) Repeat block **n** times. 367 loop_ (block n limit -- ) Repeat block **n** to **limit** times. 366 368 iter (ser body -- ) Iterate over series. 367 369 iter/N (ser body -- ) Iterate over series with skip. … … 393 395 each.set (ser words body -- ) Iterate over series and assign elements. 394 396 while (body cond -- ) Evaluate body while cond is true. 395 loop (block n -- ) Repeat block **n** times.396 397 loop.to (block n limit -- ) Repeat block **n** to **limit** times. 397 398 proc.env (env body -- proc) Create procedure with private context. … … 632 633 633 634 635 loop 636 ---- 637 :: 638 639 (block int -- ) 640 (block int int -- ) 641 642 The first form simply evalutes the body block a given number of times. 643 644 The second form pushes the counter value onto the stack before each loop, 645 and stops when the limit is reached. 646 647 Example:: 648 649 )> [.] -2 2 loop 650 -2 651 -1 652 0 653 1 654 634 655 635 656 Data Manipulation Functions -
trunk/thune/doc/thune.vim
r509 r510 117 117 syn keyword thuneType unset! datatype! none! logic! word! set-word! 118 118 syn keyword thuneType get-word! lit-word! select! set-select! opcode! 119 syn keyword thuneType char! int! int64! decimal! coord! vec3!119 syn keyword thuneType char! int! bignum! decimal! coord! vec3! vector! 120 120 syn keyword thuneType binary! string! block! paren! path! setpath! 121 syn keyword thuneType slice! list! context!121 syn keyword thuneType list! context! port! 122 122 syn keyword thuneType function! call! date! time! bitset! error! code! 123 123 "syn keyword thuneTypeFunction type? -
trunk/thune/files.c
r483 r510 317 317 UPortDevice* dev = _devicePtr( ut, ur_s_prev(tos) ); 318 318 if( dev ) 319 dev->read( ut, tos /*, part*/);319 dev->read( ut, tos, part ); 320 320 return; 321 321 } … … 1099 1099 1100 1100 1101 // (port buf len-- port buf)1102 UR_CALL( _fileRead)1101 // (port buf -- port buf) 1102 void _fileRead( UThread* ut, UCell* tos, int part ) 1103 1103 { 1104 1104 UBlock* blk; … … 1122 1122 1123 1123 1124 len = READ_BUF_SIZE;1124 len = part ? part : READ_BUF_SIZE; 1125 1125 1126 1126 if( ur_is(tos, UT_BINARY) || ur_is(tos, UT_STRING) ) -
trunk/thune/gc.c
r509 r510 394 394 break; 395 395 396 case CC_LOOP: 397 --it; 398 SET_BIT_BLOCK_L( it->cell.series.n ) 399 --it; 400 break; 401 396 402 case CC_REDUCE: 397 403 SET_BIT_BLOCK_L( it->reduce.n ) -
trunk/thune/gl/gx_atoms.h
r508 r510 1 1 // This file is automatically generated - do not edit. 2 2 3 #define UR_ATOM_DRAW_LIST_OPCODES 32 34 #define UR_ATOM_WIDTH 32 45 #define UR_ATOM_HEIGHT 32 56 #define UR_ATOM_AREA 32 67 #define UR_ATOM_RECT 3 278 #define UR_ATOM_RASTER 3 289 #define UR_ATOM_TEXTURE 3 2910 #define UR_ATOM_ELEM 33 011 #define UR_ATOM_CLOSE 18 412 #define UR_ATOM_FOCUS 33 113 #define UR_ATOM_RESIZE 33 214 #define UR_ATOM_KEY_DOWN 33 315 #define UR_ATOM_KEY_UP 33 416 #define UR_ATOM_MOUSE_MOVE 33 517 #define UR_ATOM_MOUSE_UP 33 618 #define UR_ATOM_MOUSE_DOWN 3 3719 #define UR_ATOM_MOUSE_WHEEL 3 3820 #define UR_ATOM_AMBIENT 3 3921 #define UR_ATOM_DIFFUSE 34 022 #define UR_ATOM_SPECULAR 34 123 #define UR_ATOM_POS 34 224 #define UR_ATOM_SHADER 34 325 #define UR_ATOM_VERTEX 34 426 #define UR_ATOM_FRAGMENT 34 527 #define UR_ATOM_DEFAULT 34 628 #define UR_ATOM_WAIT 13 529 #define UR_ATOM_RGB 3 4730 #define UR_ATOM_RGBA 3 4831 #define UR_ATOM_DEPTH 3 4932 #define UR_ATOM_CLAMP 35 033 #define UR_ATOM_REPEAT 35 134 #define UR_ATOM_NEAREST 35 235 #define UR_ATOM_LINEAR 35 336 #define UR_ATOM_MIN 35 437 #define UR_ATOM_MAG 35 538 #define UR_ATOM_MIPMAP 35 639 #define UR_ATOM_GRAY 3 5740 #define UR_ATOM_RGB 3 4741 #define UR_ATOM_RGBA 3 4842 #define UR_ATOM_ON 2 6743 #define UR_ATOM_OFF 2 6944 #define UR_ATOM_ADD 20 345 #define UR_ATOM_BURN 3 5846 #define UR_ATOM_COLOR 3 5947 #define UR_ATOM_TRANS 36 048 #define UR_ATOM_SPRITE 36 149 #define UR_ATOM_ONCE 36 250 #define UR_ATOM_PING_PONG 36 351 #define UR_ATOM_PONG 36 43 #define UR_ATOM_DRAW_LIST_OPCODES 326 4 #define UR_ATOM_WIDTH 327 5 #define UR_ATOM_HEIGHT 328 6 #define UR_ATOM_AREA 329 7 #define UR_ATOM_RECT 330 8 #define UR_ATOM_RASTER 331 9 #define UR_ATOM_TEXTURE 332 10 #define UR_ATOM_ELEM 333 11 #define UR_ATOM_CLOSE 186 12 #define UR_ATOM_FOCUS 334 13 #define UR_ATOM_RESIZE 335 14 #define UR_ATOM_KEY_DOWN 336 15 #define UR_ATOM_KEY_UP 337 16 #define UR_ATOM_MOUSE_MOVE 338 17 #define UR_ATOM_MOUSE_UP 339 18 #define UR_ATOM_MOUSE_DOWN 340 19 #define UR_ATOM_MOUSE_WHEEL 341 20 #define UR_ATOM_AMBIENT 342 21 #define UR_ATOM_DIFFUSE 343 22 #define UR_ATOM_SPECULAR 344 23 #define UR_ATOM_POS 345 24 #define UR_ATOM_SHADER 346 25 #define UR_ATOM_VERTEX 347 26 #define UR_ATOM_FRAGMENT 348 27 #define UR_ATOM_DEFAULT 349 28 #define UR_ATOM_WAIT 137 29 #define UR_ATOM_RGB 350 30 #define UR_ATOM_RGBA 351 31 #define UR_ATOM_DEPTH 352 32 #define UR_ATOM_CLAMP 353 33 #define UR_ATOM_REPEAT 354 34 #define UR_ATOM_NEAREST 355 35 #define UR_ATOM_LINEAR 356 36 #define UR_ATOM_MIN 357 37 #define UR_ATOM_MAG 358 38 #define UR_ATOM_MIPMAP 359 39 #define UR_ATOM_GRAY 360 40 #define UR_ATOM_RGB 350 41 #define UR_ATOM_RGBA 351 42 #define UR_ATOM_ON 270 43 #define UR_ATOM_OFF 272 44 #define UR_ATOM_ADD 205 45 #define UR_ATOM_BURN 361 46 #define UR_ATOM_COLOR 362 47 #define UR_ATOM_TRANS 363 48 #define UR_ATOM_SPRITE 364 49 #define UR_ATOM_ONCE 365 50 #define UR_ATOM_PING_PONG 366 51 #define UR_ATOM_PONG 367 -
trunk/thune/internal.h
r506 r510 108 108 typedef struct 109 109 { 110 int16_t code; 111 uint16_t flags; 112 int32_t n; 113 int32_t it; 114 } 115 CELoop; 116 117 typedef struct 118 { 110 119 int16_t code; 111 120 int16_t locals; … … 118 127 typedef union 119 128 { 120 char bytes[16];129 UCell cell; 121 130 CEId id; 122 131 CECell cp; 123 132 CEEnd end; 124 133 CEEval eval; 134 CELoop loop; 125 135 CECell iter; 126 136 CECell reduce; … … 134 144 #define CC_EVAL 2 135 145 #define CC_EVAL_RUNNING 3 136 #define CC_FOREVER 4 137 #define CC_REDUCE 5 138 #define CC_ITER 6 139 #define CC_EACH 7 140 #define CC_CATCH 8 141 #define CC_TERM 9 142 #define CC_END 10 146 #define CC_REDUCE 4 147 #define CC_FOREVER 5 148 #define CC_LOOP 6 149 #define CC_ITER 7 150 #define CC_EACH 8 151 #define CC_CATCH 9 152 #define CC_TERM 10 153 #define CC_END 11 143 154 #define CC_COUNT (CC_END+1) 144 155 … … 147 158 #define CC_LEN_EVAL 1 148 159 #define CC_LEN_FOREVER 1 160 #define CC_LEN_LOOP 2 149 161 #define CC_LEN_REDUCE 1 150 162 #define CC_LEN_ITER 2 … … 210 222 #define OP_VERIFY 31 211 223 #define OP_FOREVER 32 212 #define OP_REDUCE 33 213 #define OP_DO_FUNC 34 224 #define OP_LOOP 33 225 #define OP_REDUCE 34 226 #define OP_DO_FUNC 35 214 227 //#define OP_END 255 215 228 -
trunk/thune/make.c
r508 r510 1582 1582 n = ur_stringToInt( spA, spB, 0 ); 1583 1583 } 1584 } 1585 } 1586 else if( ur_binarySlice(ut, tos, &spA, &spB) ) 1587 { 1588 if( (spB - spA) > 3 ) 1589 { 1590 // Load 32-bit big-endian number. 1591 uint8_t* bp = (uint8_t*) spA; 1592 n = (bp[0] << 24) | (bp[1] << 16) | 1593 (bp[2] << 8) | bp[3]; 1584 1594 } 1585 1595 } -
trunk/thune/math.c
r505 r510 977 977 #include "math3d.c" 978 978 #endif 979 #ifdef UR_CONFIG_FCALC 980 #include "fcalc.c" 981 #endif 979 982 980 983 … … 1018 1021 { uc_cross, "cross" }, 1019 1022 { uc_normalize, "normalize" }, 1020 { uc_set_stride, "set-stride" } 1023 { uc_set_stride, "set-stride" }, 1024 #endif 1025 1026 #ifdef UR_CONFIG_FCALC 1027 { uc_fcalc, "fcalc" }, 1021 1028 #endif 1022 1029 }; -
trunk/thune/mkboot.t
r507 r510 37 37 opcode! 31 'verify make :verify 38 38 opcode! 32 'forever make :forever 39 opcode! 33 'loop make :loop 39 40 40 41 int!/decimal! :number! … … 72 73 ] 73 74 'loop proc :while ;(block cond -- ) 74 75 [76 int! verify77 [dup zero? ift break over do dec] forever78 drop drop79 ]80 'loop proc :loop ;(block count -- )81 75 82 76 [body n number! limit number!] [ -
trunk/thune/net.c
r471 r510 326 326 327 327 // (port buf -- port buf) 328 UR_CALL( _netRead)328 void _netRead( UThread* ut, UCell* tos, int part ) 329 329 { 330 330 UBinary* bin; … … 333 333 UCell* val; 334 334 UCell* pc = ur_s_prev(tos); 335 336 (void) part; 335 337 336 338 blk = ur_blockPtr( pc->port.valBlk ); -
trunk/thune/project.r
r497 r510 14 14 default [ 15 15 warn 16 debug17 ;release16 ;debug 17 release 18 18 19 19 cflags {-DLANG_THUNE} -
trunk/thune/read_config.r
r458 r510 14 14 dataflow: 15 15 dt-code: 16 fcalc: 16 17 net: 17 18 uds: -
trunk/thune/scripts/mandel.t
r226 r510 31 31 40.0 div y 40.0 div mandelbrot '*' ' ' either prin 32 32 ] 33 -39 39 loop .to33 -39 39 loop 34 34 ] 35 -39 39 loop .to35 -39 39 loop 36 36 eol prin 37 37 ] -
trunk/thune/scripts/nsieve.t
r338 r510 27 27 ) 28 28 ] 29 2 size loop .to29 2 size loop 30 30 31 31 ;count … … 62 62 int! args/1 make :n 63 63 64 [10000 n rot sub lshift nsieve] 0 3 loop .to64 [10000 n rot sub lshift nsieve] 0 3 loop 65 65 -
trunk/thune/stdio.c
r469 r510 56 56 fwrite( it, 1, end - it, stdout ); 57 57 } 58 } 59 else if( ur_binarySlice(ut, tos, &it, &end) && it ) 60 { 61 fwrite( it, 1, end - it, stdout ); 58 62 } 59 63 -
trunk/thune/tests/working/inc.good
r353 r510 3 3 2.0 4 4 0.0 5 16 07 2.08 1.0 -
trunk/thune/tests/working/inc.t
r458 r510 5 5 1.0 dec . 6 6 7 /* 7 8 0 :a 8 9 ++ a a . … … 12 13 ++ a a . 13 14 -- a a . 15 */ 14 16 15 17 .s -
trunk/thune/thune.c
r506 r510 45 45 case CC_EVAL: 46 46 case CC_EVAL_RUNNING: 47 case CC_REDUCE: 47 48 case CC_FOREVER: 48 case CC_REDUCE:49 49 toc -= CC_LEN_EVAL; 50 50 break; 51 51 52 case CC_LOOP: 52 53 case CC_ITER: 53 54 case CC_EACH: … … 795 796 goto bad_opcode_type; 796 797 break; 797 798 #if 0 798 799 case OP_INC_WORD: // ( -- ) 799 800 if( (pc == end) || (! ur_is(pc, UT_WORD)) ) … … 841 842 } 842 843 break; 843 844 #endif 844 845 case OP_VERIFY: // (val type -- val) 845 846 // (v1 v2 t1 t2 -- v1 v2) … … 869 870 goto control; 870 871 872 case OP_LOOP: // (body n [n2] -- ) 873 { 874 int n0, n1; 875 int prevInt; 876 UCell* prev = ur_s_prev(UR_TOS); 877 878 if( ur_is(prev, UT_INT) ) 879 { 880 n0 = ur_int(prev); 881 --prev; 882 prevInt = 1; 883 } 884 else 885 { 886 n0 = 0; 887 prevInt = 0; 888 } 889 890 if( ! ur_is(UR_TOS, UT_INT) || ! ur_is(prev, UT_BLOCK) ) 891 { 892 ur_throwErr( UR_ERR_DATATYPE, 893 "loop expected block! int!" ); 894 goto throw_cc; 895 } 896 n1 = ur_int(UR_TOS); 897 UR_S_DROP; 898 if( prevInt ) 899 UR_S_DROP; 900 if( n1 > n0 ) 901 { 902 PUSHC_EVAL( blkN, start, pc ); 903 SET_BLK_PC( UR_TOS->series.n, 904 UR_TOS->series.it ); 905 ur_copyCell( ut->toc, *UR_TOS ); 906 UR_C_GROW; 907 908 UR_TOC->loop.code = CC_LOOP; 909 UR_TOC->loop.flags = prevInt; 910 UR_TOC->loop.n = n1; 911 UR_TOC->loop.it = n0; 912 UR_C_GROW; 913 914 if( prevInt ) // Loop body must drop counter. 915 { 916 ur_initInt( UR_TOS, n0 ); 917 UR_S_GROW; 918 } 919 } 920 UR_S_DROP; 921 } 922 break; 923 871 924 //case OP_END: 872 925 // goto finish; … … 1070 1123 goto control; 1071 1124 1072 case CC_FOREVER:1073 SET_BLK_PC( UR_TOC->eval.n, UR_TOC->eval.it );1074 UR_C_GROW;1075 goto execute;1076 1077 1125 case CC_REDUCE: 1078 1126 { … … 1097 1145 ur_setSeries(ntos, rblkN, 0); 1098 1146 } 1147 goto control; 1148 1149 case CC_FOREVER: 1150 SET_BLK_PC( UR_TOC->eval.n, UR_TOC->eval.it ); 1151 UR_C_GROW; 1152 goto execute; 1153 1154 case CC_LOOP: 1155 if( ++UR_TOC->loop.it < UR_TOC->loop.n ) 1156 { 1157 UCell* ser = ut->toc - 1; 1158 if( UR_TOC->loop.flags ) 1159 { 1160 UR_S_GROW; // Loop code must drop TOS. 1161 ur_initInt( UR_TOS, UR_TOC->loop.it ); 1162 } 1163 SET_BLK_PC( ser->series.n, ser->series.it ); 1164 UR_C_GROW; 1165 goto execute; 1166 } <
