aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Execution/Stack.php
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-07 14:58:59 +0900
committernsfisis <nsfisis@gmail.com>2024-07-07 14:58:59 +0900
commit799f7790b9b8d1dc126eeab7e6e04327b6cfe717 (patch)
tree9049c734cbb72cecfc7551b42e9803256690a4d0 /src/Execution/Stack.php
parente79241c1988e7c0b3d422cdb99c9a105d0cfa903 (diff)
downloadphp-waddiwasi-799f7790b9b8d1dc126eeab7e6e04327b6cfe717.tar.gz
php-waddiwasi-799f7790b9b8d1dc126eeab7e6e04327b6cfe717.tar.zst
php-waddiwasi-799f7790b9b8d1dc126eeab7e6e04327b6cfe717.zip
refactor: Stack
Diffstat (limited to 'src/Execution/Stack.php')
-rw-r--r--src/Execution/Stack.php22
1 files changed, 8 insertions, 14 deletions
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