MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / runIfElseOp

Method runIfElseOp

lib/executor/engine/controlInstr.cpp:11–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace Executor {
10
11Expect<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
36Expect<void> Executor::runThrowOp(Runtime::StackManager &StackMgr,
37 const AST::Instruction &Instr,

Callers

nothing calls this directly

Calls 7

unlikelyFunction · 0.85
UnexpectFunction · 0.85
popMethod · 0.80
getJumpElseMethod · 0.80
getJumpEndMethod · 0.80
incInstrCountMethod · 0.80
addInstrCostMethod · 0.80

Tested by

no test coverage detected