| 9 | namespace Executor { |
| 10 | |
| 11 | Expect<void> Executor::runIfElseOp(Runtime::StackManager &StackMgr, |
| 12 | const AST::Instruction &Instr, |
| 13 | AST::InstrView::iterator &PC) noexcept { |
| 14 | // Get condition. |
| 15 | uint32_t Cond = StackMgr.pop().get<uint32_t>(); |
| 16 | |
| 17 | // If non-zero, run if-statement; else, run else-statement. |
| 18 | if (Cond == 0) { |
| 19 | if (Instr.getJumpElse() == Instr.getJumpEnd()) { |
| 20 | // No else-statement case. Jump to right before the End instruction. |
| 21 | PC += (Instr.getJumpEnd() - 1); |
| 22 | } else { |
| 23 | if (Stat) { |
| 24 | Stat->incInstrCount(); |
| 25 | if (unlikely(!Stat->addInstrCost(OpCode::Else))) { |
| 26 | return Unexpect(ErrCode::Value::CostLimitExceeded); |
| 27 | } |
| 28 | } |
| 29 | // Else-statement case. Jump to the Else instruction to continue. |
| 30 | PC += Instr.getJumpElse(); |
| 31 | } |
| 32 | } |
| 33 | return {}; |
| 34 | } |
| 35 | |
| 36 | Expect<void> Executor::runThrowOp(Runtime::StackManager &StackMgr, |
| 37 | const AST::Instruction &Instr, |
nothing calls this directly
no test coverage detected