-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy path_anewarray.php
More file actions
53 lines (45 loc) · 1.32 KB
/
_anewarray.php
File metadata and controls
53 lines (45 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace PHPJava\Kernel\Mnemonics;
use PHPJava\Kernel\Filters\Normalizer;
final class _anewarray extends AbstractOperationCode implements OperationCodeInterface
{
protected $isStackingOperation = true;
public function getOperands(): ?Operands
{
parent::getOperands();
if ($this->operands !== null) {
return $this->operands;
}
$indexbyte = $this->readUnsignedShort();
return $this->operands = new Operands(
['indexbyte', $indexbyte, ['indexbyte1', 'indexbyte2']]
);
}
/**
* create a new array of references of length count and component
* type identified by the class reference index (indexbyte1 << 8 + indexbyte2)
* in the constant pool.
*/
public function execute(): void
{
parent::execute();
// Current class index for Constant Pool
$this->getOperands()['indexbyte'];
// Get an array size
$count = Normalizer::getPrimitiveValue(
$this->popFromOperandStack()
);
// Make an array with object.
$array = new \ArrayIterator(
array_fill(
0,
$count,
null
)
);
$this->pushToOperandStackByReference(
$array
);
}
}