Changeset 505
- Timestamp:
- 02/05/08 16:46:07 (8 months ago)
- Files:
-
- 1 modified
-
trunk/thune/math.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/math.c
r485 r505 244 244 #define MATH_OPERATION_END \ 245 245 default: \ 246 UR_S_GROW; \ 246 247 ur_throwErr( UR_ERR_DATATYPE, \ 247 248 "Math operator requires int!/decimal!/vec3!" ); \ … … 388 389 389 390 391 static void logicError( UThread* ut, const char* name ) 392 { 393 ur_throwErr( UR_ERR_DATATYPE, "%s expected int!/logic!/char!", name ); 394 } 395 396 390 397 // (number number -- and) 391 398 UR_CALL( uc_and ) 392 399 { 393 UCell* res; 394 UR_S_DROP; 395 res = UR_TOS; 400 UCell* res = ur_s_prev(UR_TOS); 396 401 397 402 if( UR_IS_ANY3(tos, UT_INT, UT_LOGIC, UT_CHAR) && 398 403 UR_IS_ANY3(res, UT_INT, UT_LOGIC, UT_CHAR) ) 399 404 { 405 UR_S_DROP; 400 406 ur_initType(res, UT_INT); 401 407 ur_int(res) &= ur_int(tos); 402 408 } 409 else 410 logicError(ut,"and"); 403 411 } 404 412 … … 407 415 UR_CALL( uc_or ) 408 416 { 409 UCell* res; 410 UR_S_DROP; 411 res = UR_TOS; 417 UCell* res = ur_s_prev(UR_TOS); 412 418 413 419 if( UR_IS_ANY3(tos, UT_INT, UT_LOGIC, UT_CHAR) && 414 420 UR_IS_ANY3(res, UT_INT, UT_LOGIC, UT_CHAR) ) 415 421 { 422 UR_S_DROP; 416 423 ur_initType(res, UT_INT); 417 424 ur_int(res) |= ur_int(tos); 418 425 } 426 else 427 logicError(ut,"or"); 419 428 } 420 429 … … 423 432 UR_CALL( uc_xor ) 424 433 { 425 UCell* res; 426 UR_S_DROP; 427 res = UR_TOS; 434 UCell* res = ur_s_prev(UR_TOS); 428 435 429 436 if( UR_IS_ANY3(tos, UT_INT, UT_LOGIC, UT_CHAR) && 430 437 UR_IS_ANY3(res, UT_INT, UT_LOGIC, UT_CHAR) ) 431 438 { 439 UR_S_DROP; 432 440 ur_initType(res, UT_INT); 433 441 ur_int(res) ^= ur_int(tos); 434 442 } 443 else 444 logicError(ut,"xor"); 435 445 } 436 446 … … 479 489 break; 480 490 default: 481 ur_throwErr( UR_ERR_DATATYPE,482 "Invalid type for 'minimum" );491 UR_S_GROW; 492 ur_throwErr( UR_ERR_DATATYPE, "Invalid type for 'minimum" ); 483 493 break; 484 494 } … … 529 539 break; 530 540 default: 541 UR_S_GROW; 531 542 ur_throwErr( UR_ERR_DATATYPE, "Invalid type for 'maximum" ); 532 543 break;
