From a6e1225bdaee353f764ec471e2d613a2d5b893b0 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 29 Apr 2024 22:33:27 +0900 Subject: fix: loop op Also remove work-around for wrong implementation. --- src/Execution/Runtime.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index 945c187..55fbbfb 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -2388,9 +2388,8 @@ final class Runtime $instrs = $instr->body; $f = $this->stack->currentFrame(); $bt = self::expandBlockType($blockType, $f->module); - assert(count($bt->params->types) === 0); - $n = count($bt->results->types); - $l = new Label($n); + $m = count($bt->params->types); + $l = new Label($m); while (true) { $result = $this->execInstrs($instrs, $l); if ($result === null) { @@ -2398,16 +2397,10 @@ final class Runtime } elseif ($result === -1) { return -1; } elseif ($result === 0) { - if ($n === 1) { - if ($this->stack->top() instanceof Label) { - // WORKAROUND: - $this->stack->pushValue(0); - } - } - $this->deactivateLabel($n); + $this->deactivateLabel($m); continue; } else { - $this->deactivateLabel($n); + $this->deactivateLabel($m); return $result - 1; } } -- cgit v1.2.3-70-g09d2