| 368 | //------------------------------------------------------------ |
| 369 | |
| 370 | U32 ConditionalExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) |
| 371 | { |
| 372 | // code is testExpr |
| 373 | // JMPIFNOT falseStart |
| 374 | // trueExpr |
| 375 | // JMP end |
| 376 | // falseExpr |
| 377 | if (testExpr->getPreferredType() == TypeReqUInt) |
| 378 | { |
| 379 | integer = true; |
| 380 | } |
| 381 | else |
| 382 | { |
| 383 | integer = false; |
| 384 | } |
| 385 | |
| 386 | ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat); |
| 387 | codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT); |
| 388 | |
| 389 | U32 jumpElseIp = codeStream.emit(0); |
| 390 | ip = trueExpr->compile(codeStream, ip, type); |
| 391 | codeStream.emit(OP_JMP); |
| 392 | U32 jumpEndIp = codeStream.emit(0); |
| 393 | codeStream.patch(jumpElseIp, codeStream.tell()); |
| 394 | ip = falseExpr->compile(codeStream, ip, type); |
| 395 | codeStream.patch(jumpEndIp, codeStream.tell()); |
| 396 | |
| 397 | return codeStream.tell(); |
| 398 | } |
| 399 | |
| 400 | TypeReq ConditionalExprNode::getPreferredType() |
| 401 | { |
no test coverage detected