diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Execution/Runtime.php | 2 | ||||
| -rw-r--r-- | src/Execution/Stack.php | 22 |
2 files changed, 9 insertions, 15 deletions
diff --git a/src/Execution/Runtime.php b/src/Execution/Runtime.php index 98893d0..2f69431 100644 --- a/src/Execution/Runtime.php +++ b/src/Execution/Runtime.php @@ -66,7 +66,7 @@ final class Runtime $moduleInstInit = $allocator->allocPreInitModule($module, $externVals); - $stack = new Stack([]); + $stack = new Stack(); $frameInit = new Frame(0, [], $moduleInstInit, 'preinit'); $stack->pushFrame($frameInit); diff --git a/src/Execution/Stack.php b/src/Execution/Stack.php index dfecfec..1e32388 100644 --- a/src/Execution/Stack.php +++ b/src/Execution/Stack.php @@ -21,11 +21,12 @@ final class Stack private ?Frame $currentFrame = null; /** - * @param list<int|float|Ref|Frame|Label> $entries + * @var list<int|float|Ref|Frame|Label> */ - public function __construct( - private array $entries, - ) { + private array $entries; + + public function __construct() + { } public function pushFrame(Frame $frame): void @@ -154,17 +155,10 @@ final class Stack public function popEntriesToCurrentFrame(): void { - while (!$this->isEmpty()) { - if ($this->pop() instanceof Frame) { - break; - } - } - array_pop($this->frames); - if (count($this->frames) === 0) { - $this->currentFrame = null; - } else { - $this->currentFrame = end($this->frames); + while (!$this->isEmpty() && !$this->top() instanceof Frame) { + $this->pop(); } + $this->popFrame(); } public function top(): int|float|Ref|Frame|Label|null |
