| 380 | //========================================================================== |
| 381 | |
| 382 | void FxExpression::EmitCompare(VMFunctionBuilder *build, bool invert, TArray<size_t> &patchspots_yes, TArray<size_t> &patchspots_no) |
| 383 | { |
| 384 | ExpEmit op = Emit(build); |
| 385 | ExpEmit i; |
| 386 | assert(op.RegType != REGT_NIL && op.RegCount == 1); |
| 387 | if (op.Konst) |
| 388 | { |
| 389 | ScriptPosition.Message(MSG_WARNING, "Conditional expression is constant"); |
| 390 | } |
| 391 | switch (op.RegType) |
| 392 | { |
| 393 | case REGT_INT: |
| 394 | build->Emit(OP_EQ_K, !invert, op.RegNum, build->GetConstantInt(0)); |
| 395 | break; |
| 396 | |
| 397 | case REGT_FLOAT: |
| 398 | build->Emit(OP_EQF_K, !invert, op.RegNum, build->GetConstantFloat(0)); |
| 399 | break; |
| 400 | |
| 401 | case REGT_POINTER: |
| 402 | build->Emit(OP_EQA_K, !invert, op.RegNum, build->GetConstantAddress(0)); |
| 403 | break; |
| 404 | |
| 405 | case REGT_STRING: |
| 406 | i = ExpEmit(build, REGT_INT); |
| 407 | build->Emit(OP_LENS, i.RegNum, op.RegNum); |
| 408 | build->Emit(OP_EQ_K, !invert, i.RegNum, build->GetConstantInt(0)); |
| 409 | i.Free(build); |
| 410 | break; |
| 411 | |
| 412 | default: |
| 413 | break; |
| 414 | } |
| 415 | patchspots_no.Push(build->Emit(OP_JMP, 0)); |
| 416 | op.Free(build); |
| 417 | } |
| 418 | |
| 419 | //========================================================================== |
| 420 | // |
no test coverage detected