Changeset 184 for trunk/thune/eval.c
- Timestamp:
- 06/12/06 01:58:22 (3 years ago)
- Files:
-
- 1 modified
-
trunk/thune/eval.c (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/eval.c
r183 r184 52 52 53 53 #define PUSHC_NONE \ 54 ur_ setType(UR_TOC, UT_NONE); \54 ur_initType(UR_TOC, UT_NONE); \ 55 55 UR_C_GROW 56 56 … … 126 126 127 127 cell = &blk; 128 ur_ setType( cell, UT_BLOCK );128 ur_initType( cell, UT_BLOCK ); 129 129 ur_setSeries( cell, blkN, 0 ); 130 130 … … 171 171 172 172 blkN = tos->series.n; 173 ur_ setType( tos, UT_FUNCTION );174 // localArgs cleared by ur_ setType().173 ur_initType( tos, UT_FUNCTION ); 174 // localArgs cleared by ur_initType(). 175 175 tos->func.bodyN = blkN; 176 176 tos->func.closureN = 0; … … 264 264 if( n < 3 ) 265 265 { 266 ur_ setType( res, UT_DECIMAL );266 ur_initType( res, UT_DECIMAL ); 267 267 ur_decimal(res) = (double) val->vec3.xyz[ n ]; 268 268 } … … 348 348 _infuseOpcodes( blkN ); 349 349 350 ur_ setType(tos, UT_BLOCK);350 ur_initType(tos, UT_BLOCK); 351 351 ur_setSeries(tos, blkN, 0); 352 352 … … 417 417 else if( ur_is(tos, UT_LITWORD) ) 418 418 { 419 ur_ setType(tos, UT_WORD );419 ur_type(tos) = UT_WORD; 420 420 } 421 421 // else leave tos unchanged... … … 761 761 762 762 case OP_INCREMENT: 763 if( ur_is(UR_TOS, UT_INT) ) 764 ur_int(UR_TOS) += 1; 763 if( ! ur_is(UR_TOS, UT_INT) ) 764 goto bad_opcode_type; 765 ur_int(UR_TOS) += 1; 765 766 ++pc; 766 767 break; 767 768 768 769 case OP_DECREMENT: 769 if( ur_is(UR_TOS, UT_INT) ) 770 ur_int(UR_TOS) -= 1; 770 if( ! ur_is(UR_TOS, UT_INT) ) 771 goto bad_opcode_type; 772 ur_int(UR_TOS) -= 1; 771 773 ++pc; 772 774 break; … … 932 934 else if( ur_is(val, UT_UNSET) ) 933 935 { 934 _throwUnset( ur_thread, pc - 1 ); 936 --pc; 937 _throwUnset( ur_thread, pc ); 938 _appendTraceBlk( &UR_TOS->err, blkN, pc - start ); 935 939 goto op_throw_cc; 936 940 } … … 1038 1042 UR_TOS = ntos; 1039 1043 } 1040 ur_ setType(ntos, UT_BLOCK);1044 ur_initType(ntos, UT_BLOCK); 1041 1045 ur_setSeries(ntos, rblkN, 0); 1042 1046 } … … 1166 1170 ur_throwErr( ur_thread, UR_EX_SCRIPT, 1167 1171 "recurse used outside of function" ); 1168 goto error;1172 goto trace_error; 1169 1173 1170 1174 default: … … 1184 1188 ur_throwErr( ur_thread, UR_EX_SCRIPT, 1185 1189 "return used outside of function" ); 1186 _appendTraceBlk( &UR_TOS->err, blkN, pc - start ); 1187 goto error; 1190 goto trace_error; 1188 1191 1189 1192 default: … … 1195 1198 return UR_EVAL_OK; 1196 1199 1200 bad_opcode_type: 1201 1202 ur_throwErr( ur_thread, UR_EX_DATATYPE, "invalid type %s! for '%s opcode", 1203 ur_typeName( ur_type(UR_TOS) ), 1204 ur_atomCStr( ur_atom(pc) ) ); 1205 _appendTraceBlk( &UR_TOS->err, blkN, pc - start ); 1206 goto op_throw_cc; 1207 1197 1208 stack_eaten: 1198 1209 1199 1210 ur_throwErr( ur_thread, UR_EX_SCRIPT, "data stack eaten" ); 1200 _appendTraceBlk( &UR_TOS->err, blkN, pc - start ); 1201 goto error; 1211 goto trace_error; 1202 1212 1203 1213 bad_control: 1204 1214 1205 1215 ur_throwErr( ur_thread, UR_EX_INTERNAL, "bad control code" ); 1216 1217 trace_error: 1218 1206 1219 _appendTraceBlk( &UR_TOS->err, blkN, pc - start ); 1207 1220 … … 1305 1318 UR_S_GROW; 1306 1319 tos = UR_TOS; 1307 ur_ setType(tos, UT_ERROR);1320 ur_initType(tos, UT_ERROR); 1308 1321 tos->err.exType = exceptionType; 1309 1322 tos->err.messageStr = strN; 1323 1324 // Init traceBlk to zero before ur_makeBlock() in case GC occurs. 1310 1325 tos->err.traceBlk = 0; 1311 1312 // Init traceBlk to zero before ur_makeBlock() in case GC occurs.1313 1326 tos->err.traceBlk = ur_makeBlock( 8 ); 1314 1327 … … 1349 1362 break; \ 1350 1363 case MJ_INT_DEC: \ 1351 ur_ setType(res, UT_DECIMAL); \1364 ur_initType(res, UT_DECIMAL); \ 1352 1365 ur_decimal(res) = ((double) ur_int(res)) OP ur_decimal(tos); \ 1353 1366 break; \ … … 1600 1613 UR_S_DROP; 1601 1614 ur_logic(UR_TOS) = ur_equal( UR_TOS, tos ); 1602 ur_ setType( UR_TOS, UT_LOGIC );1615 ur_initType( UR_TOS, UT_LOGIC ); 1603 1616 } 1604 1617 … … 1613 1626 1614 1627 same = ur_same( res, tos ); 1615 ur_ setType( res, UT_LOGIC );1628 ur_initType( res, UT_LOGIC ); 1616 1629 ur_logic(res) = same; 1617 1630 } … … 1623 1636 UR_S_DROP; 1624 1637 ur_logic(UR_TOS) = (ur_int(UR_TOS) > ur_int(tos)) ? 1 : 0; 1625 ur_ setType( UR_TOS, UT_LOGIC );1638 ur_initType( UR_TOS, UT_LOGIC ); 1626 1639 } 1627 1640 … … 1632 1645 UR_S_DROP; 1633 1646 ur_logic(UR_TOS) = (ur_int(UR_TOS) < ur_int(tos)) ? 1 : 0; 1634 ur_ setType( UR_TOS, UT_LOGIC );1647 ur_initType( UR_TOS, UT_LOGIC ); 1635 1648 } 1636 1649 … … 1646 1659 else 1647 1660 n = 0; 1648 ur_ setType(tos, UT_LOGIC);1661 ur_initType(tos, UT_LOGIC); 1649 1662 ur_logic(tos) = n; 1650 1663 } … … 1656 1669 int t = ur_type(tos); 1657 1670 UR_CALL_UNUSED_TH 1658 ur_ setType(tos, UT_DATATYPE);1671 ur_initType(tos, UT_DATATYPE); 1659 1672 ur_datatype(tos) = t; 1660 1673 } … … 1666 1679 int t = ur_type(tos); 1667 1680 UR_CALL_UNUSED_TH 1668 ur_ setType(tos, UT_WORD);1681 ur_initType(tos, UT_WORD); 1669 1682 tos->word.wordBlk = 0; 1670 1683 tos->word.valBlk = GLOBAL_VAL_BLKN; … … 1841 1854 if( ur_is(val, UT_INT) || ur_is(val, UT_CHAR) ) 1842 1855 { 1843 ur_ setType(val, UT_DECIMAL);1856 ur_initType(val, UT_DECIMAL); 1844 1857 ur_decimal(val) = ur_int(val); 1845 1858 } … … 1874 1887 break; 1875 1888 } 1889 } 1890 1891 1892 /* 1893 (block context -- block) 1894 */ 1895 UR_CALL( uc_bind ) 1896 { 1897 UCell* bc; 1898 1899 UR_S_DROP; 1900 bc = UR_TOS; 1901 1902 if( ur_is(tos, UT_LITWORD) || ur_is(tos, UT_CONTEXT) ) 1903 { 1904 if( ur_is(bc, UT_BLOCK) ) 1905 { 1906 ur_bind( bc->series.n, tos ); 1907 return; 1908 } 1909 } 1910 1911 ur_throwErr( ur_thread, UR_EX_DATATYPE, "Invalid bind values" ); 1876 1912 } 1877 1913 … … 1971 2007 UCell lctx; 1972 2008 1973 ur_ setType( &lctx, UT_CONTEXT );2009 ur_initType( &lctx, UT_CONTEXT ); 1974 2010 lctx.ctx.wordBlk = toc->func.sigN; 1975 2011 lctx.ctx.valBlk = ur_thread->localArgBlkN; … … 2028 2064 UR_S_DROPN(argc); 2029 2065 2030 ur_ setType( UR_TOS, UT_FUNCTION );2031 // localArgs cleared by ur_ setType().2066 ur_initType( UR_TOS, UT_FUNCTION ); 2067 // localArgs cleared by ur_initType(). 2032 2068 UR_TOS->func.bodyN = bodN; 2033 2069 UR_TOS->func.closureN = encN; … … 2100 2136 2101 2137 tos = UR_TOS; 2102 ur_ setType( tos, UT_FUNCTION );2138 ur_initType( tos, UT_FUNCTION ); 2103 2139 tos->func.localArgs = argc; 2104 2140 tos->func.localVars = argc + varc; … … 2155 2191 ur_toStrNatural( tos, ur_binPtr(strN), 0 ); 2156 2192 2157 ur_ setType(tos, UT_STRING);2193 ur_initType(tos, UT_STRING); 2158 2194 ur_setSeries(tos, strN, 0); 2159 2195 } … … 2165 2201 2166 2202 extern void uc_make( UThread*, UCell* ); 2167 extern void uc_bind( UThread*, UCell* );2168 2203 extern void uc_console_out( UThread*, UCell* ); 2169 2204 extern void uc_parse( UThread*, UCell* );
