| 417 | //------------------------------------------------------------ |
| 418 | |
| 419 | U32 ConditionalExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) |
| 420 | { |
| 421 | // code is testExpr |
| 422 | // JMPIFNOT falseStart |
| 423 | // trueExpr |
| 424 | // JMP end |
| 425 | // falseExpr |
| 426 | if(testExpr->getPreferredType() == TypeReqUInt) |
| 427 | { |
| 428 | integer = true; |
| 429 | } |
| 430 | else |
| 431 | { |
| 432 | integer = false; |
| 433 | } |
| 434 | |
| 435 | ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat); |
| 436 | codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT); |
| 437 | |
| 438 | U32 jumpElseIp = codeStream.emit(0); |
| 439 | ip = trueExpr->compile(codeStream, ip, type); |
| 440 | codeStream.emit(OP_JMP); |
| 441 | U32 jumpEndIp = codeStream.emit(0); |
| 442 | codeStream.patch(jumpElseIp, codeStream.tell()); |
| 443 | ip = falseExpr->compile(codeStream, ip, type); |
| 444 | codeStream.patch(jumpEndIp, codeStream.tell()); |
| 445 | |
| 446 | return codeStream.tell(); |
| 447 | } |
| 448 | |
| 449 | TypeReq ConditionalExprNode::getPreferredType() |
| 450 | { |
no test coverage detected