Skip to content

Commit f2e9b23

Browse files
committed
Refactor anewarray
1 parent d8cd90c commit f2e9b23

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/Kernel/Mnemonics/_anewarray.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,25 @@ final class _anewarray implements OperationInterface
1515
*/
1616
public function execute(): void
1717
{
18-
// 配列のサイズを調べる (PHPでは不要なので実行するだけ)
18+
// Current class index for Constant Pool
1919
$this->readUnsignedShort();
2020

21-
// 空の配列を渡す (nullで埋める)
22-
$count = Extractor::getRealValue($this->popFromOperandStack());
23-
// need reference
24-
$ref = new \ArrayIterator(array_fill(0, $count, null));
25-
$this->pushToOperandStackByReference($ref);
21+
// Get an array size
22+
$count = Extractor::getRealValue(
23+
$this->popFromOperandStack()
24+
);
25+
26+
// Make an array with object.
27+
$array = new \ArrayIterator(
28+
array_fill(
29+
0,
30+
$count,
31+
null
32+
)
33+
);
34+
35+
$this->pushToOperandStackByReference(
36+
$array
37+
);
2638
}
2739
}

0 commit comments

Comments
 (0)