| 1412 | | } |
| 1413 | | |
| 1414 | | |
| 1415 | | /** |
| 1416 | | Pops TOS and returns cell pointer. |
| 1417 | | */ |
| 1418 | | UCell* ur_result( UThread* ur_thread, int pop ) |
| 1419 | | { |
| 1420 | | UCell* tos = UR_TOS; |
| 1421 | | if( pop ) |
| 1422 | | { |
| 1423 | | UR_S_SAFE_DROP; |
| 1424 | | } |
| 1425 | | return tos; |
| 1426 | | } |
| 1427 | | |
| 1428 | | |
| 1429 | | /** |
| 1430 | | Throw error from call. The error is pushed onto the stack. |
| 1431 | | */ |
| 1432 | | void ur_throwErr( UThread* ur_thread, int exceptionType, const char* fmt, ... ) |
| 1433 | | { |
| 1434 | | #define MAX_ERR_LEN 256 |
| 1435 | | UCell* tos; |
| 1436 | | UString* str; |
| 1437 | | UIndex strN; |
| 1438 | | char* cp; |
| 1439 | | va_list arg; |
| 1440 | | |
| 1441 | | //(void) exceptionType; |
| 1442 | | |
| 1443 | | strN = ur_makeBinary( MAX_ERR_LEN ); |
| 1444 | | str = ur_binPtr( strN ); |
| 1445 | | |
| 1446 | | va_start( arg, fmt ); |
| 1447 | | vaStrPrint( str->ptr.c, MAX_ERR_LEN, fmt, arg ); |
| 1448 | | va_end( arg ); |
| 1449 | | |
| 1450 | | cp = str->ptr.c; |
| 1451 | | while( *cp != '\0' ) |
| 1452 | | ++cp; |
| 1453 | | str->used = cp - str->ptr.c; |
| 1454 | | |
| 1455 | | //ur_termCStr( str ); |
| 1456 | | //makeError( exceptionType, str ); |
| 1457 | | //dprint( str->ptr.c ); |
| 1458 | | |
| 1459 | | UR_S_GROW; |
| 1460 | | tos = UR_TOS; |
| 1461 | | ur_initType(tos, UT_ERROR); |
| 1462 | | tos->err.exType = exceptionType; |
| 1463 | | tos->err.messageStr = strN; |
| 1464 | | |
| 1465 | | // Init traceBlk to zero before ur_makeBlock() in case GC occurs. |
| 1466 | | tos->err.traceBlk = 0; |
| 1467 | | tos->err.traceBlk = ur_makeBlock( 8 ); |
| 1468 | | |
| 1469 | | UR_CALL_OP = OP_THROW; |