Changeset 157
- Timestamp:
- 05/25/06 15:20:35 (2 years ago)
- Files:
-
- trunk/thune/context.c (modified) (1 diff)
- trunk/thune/eval.c (modified) (7 diffs)
- trunk/thune/internal.h (modified) (1 diff)
- trunk/thune/make.c (modified) (5 diffs)
- trunk/thune/parse.c (modified) (2 diffs)
- trunk/thune/print.c (modified) (4 diffs)
- trunk/thune/urlan.c (modified) (2 diffs)
- trunk/thune/urlan.h (modified) (7 diffs)
- trunk/thune/urlan_atoms.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/thune/context.c
r152 r157 26 26 typedef struct 27 27 { 28 uint16_t nameIndex; // Index into BIN_ATOM_NAMESptr.c28 uint16_t nameIndex; // Index into ur_binPtr(BIN_ATOM_NAMES)->ptr.c 29 29 uint16_t nameLen; 30 30 } trunk/thune/eval.c
r152 r157 463 463 464 464 465 static void _throwUnbound( UThread* ur_thread, UCell* wcell ) 466 { 467 UString* str; 468 str = ur_binPtr( ur_thread->callTempBinN ); 469 str->used = 0; 470 ur_atomStr( ur_atom(wcell), str ); 471 ur_termCStr( str ); 472 ur_throwErr( ur_thread, UR_EX_SCRIPT, 473 "word '%s is unbound", str->ptr.c ); 474 } 475 476 465 477 #define DO_BLOCK(vp) \ 466 478 PUSHC_EVAL( blkN, start, pc ); \ … … 713 725 714 726 case UT_WORD: 715 assert( pc->word.index > -1 ); 716 //if( pc->word.index < 0 ) 717 // ur_throwErr( "word %s is unset", ); 727 //assert( pc->word.index > -1 ); 728 if( ur_wordIsUnbound(pc) ) 729 { 730 _throwUnbound( ur_thread, pc ); 731 UR_CALL_OP = 0; 732 goto op_throw; 733 } 718 734 719 735 ur_wordCell( pc, blk, val ); … … 982 998 case CC_ITER: 983 999 case CC_FOREACH: 984 UR_C_DECN( CC_LEN_ITER );1000 UR_C_DECN( CC_LEN_ITER ); 985 1001 break; 986 1002 … … 1173 1189 tos->err.exType = exceptionType; 1174 1190 tos->err.messageStr = strN; 1191 tos->err.traceBlk = 0; 1192 1193 // Init traceBlk to zero before ur_makeBlock() in case GC occurs. 1175 1194 tos->err.traceBlk = ur_makeBlock( 8 ); 1176 1195 … … 1476 1495 UCell* cell; 1477 1496 UCell* val; 1497 1498 if( ur_wordIsUnbound(tos) ) 1499 { 1500 if( tos->word.valBlk == GLOBAL_VAL_BLKN ) 1501 { 1502 tos->word.index = ur_internWord( &ur_global, ur_atom(tos) ); 1503 } 1504 else 1505 { 1506 _throwUnbound( ur_thread, tos ); 1507 return; 1508 } 1509 } 1478 1510 1479 1511 val = ur_s_prev( tos ); … … 1752 1784 } 1753 1785 } 1786 1787 1788 #include "encoding.c" 1754 1789 1755 1790 … … 1790 1825 { uc_enclose, "enclose"}, 1791 1826 { ur_recycle, "recycle"}, 1792 { uc_mark_eol, "mark.eol"} 1827 { uc_mark_eol, "mark.eol"}, 1828 { uc_encode, "encode"}, 1829 { uc_encodingQ, "encoding?"} 1793 1830 }; 1794 1831 trunk/thune/internal.h
r152 r157 17 17 elem = ((type*) (arr->ptr.v)) + arr->used; \ 18 18 ++arr->used 19 20 #define ur_setUnbound(cell,atm) \ 21 cell->word.wordBlk = 0; \ 22 cell->word.valBlk = GLOBAL_VAL_BLKN; \ 23 cell->word.index = UR_UNBOUND; \ 24 cell->word.atom = atm 19 25 20 26 trunk/thune/make.c
r152 r157 597 597 598 598 /** 599 Append word!, lit-word!, or set-word! value to block.599 Append word!, lit-word!, set-word!, or get-word! value to block. 600 600 */ 601 601 UCell* ur_appendWord( UBlock* blk, int type, const char* name, int len ) … … 607 607 cell->word.wordBlk = 0; //GLOBAL_WORD_BLKN; 608 608 cell->word.valBlk = GLOBAL_VAL_BLKN; 609 //cell->word.index = -1;609 cell->word.index = UR_UNBOUND; 610 610 cell->word.atom = ur_intern( name, len ); 611 611 612 //if( type == UT_SETWORD )612 if( type != UT_LITWORD ) 613 613 { 614 614 // Add word to global context. … … 839 839 binN = ur_makeBinary( ur_int(tos) ); 840 840 ur_setType(res, UT_STRING); 841 //ur_setEncoding(res, UR_ENC_ASCII); 841 842 ur_setSeries(res, binN, 0); 842 843 } … … 852 853 853 854 ur_setType(res, UT_STRING); 855 //ur_setEncoding(res, UR_ENC_ASCII); 854 856 ur_setSeries(res, binN, 0); 855 857 } … … 864 866 865 867 ur_setType(res, UT_STRING); 868 //ur_setEncoding(res, UR_ENC_ASCII); 866 869 ur_setSeries(res, binN, 0); 867 870 } trunk/thune/parse.c
r125 r157 37 37 typedef struct 38 38 { 39 UThread* thread;40 UCell* rules;41 UCellS liceinput;42 UString* str;43 int error;44 int matchCase;39 UThread* thread; 40 UCell* rules; 41 UCellSeries input; 42 UString* str; 43 int error; 44 int matchCase; 45 45 } 46 46 StringParser; … … 49 49 typedef struct 50 50 { 51 UThread* thread;52 UCell* rules;53 UCellS liceinput;54 UString* blk;55 int error;51 UThread* thread; 52 UCell* rules; 53 UCellSeries input; 54 UString* blk; 55 int error; 56 56 } 57 57 BlockParser; trunk/thune/print.c
r152 r157 84 84 ++cp; 85 85 out->used = cp - out->ptr.c; 86 } 87 88 89 /* 90 Returns number of characters copied. 91 */ 92 static int copyUtf16ToAscii( uint8_t* dest, uint16_t* src, int len ) 93 { 94 uint16_t* end; 95 uint16_t c; 96 97 end = src + len; 98 99 while( src != end ) 100 { 101 c = *src++; 102 if( c > 127 ) 103 c = 0; 104 *dest++ = c; 105 } 106 return len; 86 107 } 87 108 … … 680 701 int used = str->used - si; 681 702 if( used > 0 ) 682 append( out, str->ptr.c + si, used ); 703 { 704 switch( ur_encoding(val) ) 705 { 706 case UR_ENC_ASCII: 707 case UR_ENC_UTF8: 708 append( out, str->ptr.c + si, used ); 709 break; 710 711 case UR_ENC_UTF16: 712 EXPAND( out, used ); 713 out->used += copyUtf16ToAscii( (uint8_t*) out->ptr.c, 714 str->ptr.u16, used ); 715 break; 716 } 717 } 683 718 } 684 719 break; … … 776 811 } 777 812 } 778 779 780 #if 0781 void orForm( UString* out, const UCell* val )782 {783 ur_toStrNatural( out, val, 0 );784 if( out->used )785 {786 orCTermStr( out );787 }788 }789 #endif790 813 791 814 … … 1175 1198 1176 1199 1177 #if 01178 void orMold( UString* out, const UCell* val )1179 {1180 ur_toStr( out, val, 0 );1181 if( out->used )1182 {1183 orCTermStr( out );1184 }1185 }1186 1187 1188 /**1189 Converts a value to a string.1190 */1191 void orFormNative( UCell* a1 )1192 {1193 UString* str = orMakeString( 0 );1194 orForm( str, a1 );1195 orResultSTRING( str - orSTRINGS );1196 }1197 1198 1199 /**1200 Converts a value to a parseable string.1201 */1202 void orMoldNative( UCell* a1 )1203 {1204 UString* str = orMakeString( 0 );1205 orMold( str, a1 );1206 orResultSTRING( str - orSTRINGS );1207 }1208 #endif1209 1210 1211 1200 /*EOF*/ trunk/thune/urlan.c
r139 r157 177 177 178 178 // Atoms used by parse. 179 #if 0180 FIXED_ATOM( "token", 5, UR_ATOM_TOKEN )181 FIXED_ATOM( ".", 1, UR_ATOM_DOT )182 FIXED_ATOM( "-", 1, UR_ATOM_DASH )183 FIXED_ATOM( "|", 1, UR_ATOM_BAR )184 #else185 179 FIXED_ATOM( "-", 1, UR_ATOM_DASH ) 186 180 FIXED_ATOM( "|", 1, UR_ATOM_BAR ) … … 194 188 FIXED_ATOM( "to", 2, UR_ATOM_TO ) 195 189 FIXED_ATOM( "thru", 4, UR_ATOM_THRU ) 196 #endif 190 191 // String Encodings 192 FIXED_ATOM( "ascii", 5, UR_ATOM_ASCII ) 193 FIXED_ATOM( "utf8", 4, UR_ATOM_UTF8 ) 194 FIXED_ATOM( "utf16", 5, UR_ATOM_UTF16 ) 197 195 198 196 #if MAKE_ATOM_HEADER trunk/thune/urlan.h
r141 r157 89 89 90 90 91 /* String Encodings */ 92 93 #define UR_ENC_ASCII 0 94 #define UR_ENC_UTF8 1 95 #define UR_ENC_UTF16 2 96 97 91 98 /* Eval/call return */ 92 99 … … 112 119 113 120 121 #define UR_UNBOUND -1 114 122 #define UR_INVALID_HOLD -1 115 123 #define UR_COPY_ALL 0x7fffffff … … 222 230 typedef struct 223 231 { 224 UCellId id; 225 UIndex n; /* Series number */ 226 UIndex it; /* Element Iterator */ 227 } 228 UCellSeries; // Series, set, sequence, array, chain, group, list 229 230 231 typedef struct 232 { 233 uint8_t type; 234 uint8_t flags; 232 uint8_t type; 233 uint8_t flags; 234 uint8_t encoding; 235 235 uint8_t datatype; 236 uint8_t _pad;237 236 UIndex n; /* Series number */ 238 237 UIndex it; /* Element Iterator */ 239 238 UIndex end; /* Slice end */ 240 239 } 241 UCellS lice;240 UCellSeries; // Series, set, sequence, array, chain, group, list 242 241 243 242 … … 307 306 UCellTime time; 308 307 UCellSeries series; 309 UCellS liceslice;308 UCellSeries slice; 310 309 UCellPath path; 311 310 UCellList list; … … 330 329 UChar* c; 331 330 uint8_t* b; 331 uint16_t* u16; 332 332 int32_t* i; 333 333 double* d; … … 542 542 (c)->series.it = sit 543 543 544 #define ur_setEncoding(c,en) (c)->series.encoding = en 545 #define ur_encoding(c) (c)->series.encoding 546 544 547 #define ur_atom(c) (c)->word.atom 545 548 #define ur_datatype(c) (c)->dt.n … … 562 565 #define ur_selIsAtom(c) ((c)->word.flags & UR_FLAG_SEL_ATOM) 563 566 567 #define ur_wordIsUnbound(pc) (pc->word.index < 0) 568 564 569 #define ur_wordCell(pc,blk,val) \ 565 570 blk = ur_blockPtr( pc->word.valBlk ); \ trunk/thune/urlan_atoms.h
r129 r157 18 18 #define UR_ATOM_TO 52 19 19 #define UR_ATOM_THRU 53 20 #define UR_ATOM_ASCII 54 21 #define UR_ATOM_UTF8 55 22 #define UR_ATOM_UTF16 56
