Skip to content

Commit a676a0e

Browse files
committed
Add mnemonics
1 parent 36a1b4c commit a676a0e

10 files changed

Lines changed: 97 additions & 10 deletions

File tree

src/Kernel/Mnemonics/_baload.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace PHPJava\Kernel\Mnemonics;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Utilities\Extractor;
56

67
final class _baload implements OperationInterface
78
{
@@ -10,6 +11,11 @@ final class _baload implements OperationInterface
1011

1112
public function execute(): void
1213
{
13-
throw new NotImplementedException(__CLASS__);
14+
$index = Extractor::getRealValue($this->popFromOperandStack());
15+
$arrayref = $this->popFromOperandStack();
16+
17+
$this->pushToOperandStack(
18+
$arrayref[$index]
19+
);
1420
}
1521
}

src/Kernel/Mnemonics/_bastore.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
namespace PHPJava\Kernel\Mnemonics;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\Type;
6+
use PHPJava\Utilities\Extractor;
57

68
final class _bastore implements OperationInterface
79
{
@@ -10,6 +12,19 @@ final class _bastore implements OperationInterface
1012

1113
public function execute(): void
1214
{
13-
throw new NotImplementedException(__CLASS__);
15+
$value = $this->popFromOperandStack();
16+
$index = Extractor::getRealValue($this->popFromOperandStack());
17+
18+
/**
19+
* @var Type $arrayref
20+
*/
21+
$arrayref = $this->popFromOperandStack();
22+
23+
// The value is a ref.
24+
$arrayref[$index] = $value;
25+
26+
$this->pushToOperandStack(
27+
$arrayref
28+
);
1429
}
1530
}

src/Kernel/Mnemonics/_caload.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace PHPJava\Kernel\Mnemonics;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Utilities\Extractor;
56

67
final class _caload implements OperationInterface
78
{
@@ -10,6 +11,11 @@ final class _caload implements OperationInterface
1011

1112
public function execute(): void
1213
{
13-
throw new NotImplementedException(__CLASS__);
14+
$index = Extractor::getRealValue($this->popFromOperandStack());
15+
$arrayref = $this->popFromOperandStack();
16+
17+
$this->pushToOperandStack(
18+
$arrayref[$index]
19+
);
1420
}
1521
}

src/Kernel/Mnemonics/_daload.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public function execute(): void
1616
$index = Extractor::getRealValue($this->popFromOperandStack());
1717
$arrayref = $this->popFromOperandStack();
1818

19-
$this->pushToOperandStack($arrayref[$index]);
19+
$this->pushToOperandStack(
20+
$arrayref[$index]
21+
);
2022
}
2123
}

src/Kernel/Mnemonics/_dastore.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4+
use PHPJava\Kernel\Types\Type;
45
use PHPJava\Utilities\Extractor;
56

67
final class _dastore implements OperationInterface
@@ -15,8 +16,17 @@ public function execute(): void
1516
{
1617
$value = $this->popFromOperandStack();
1718
$index = Extractor::getRealValue($this->popFromOperandStack());
19+
20+
/**
21+
* @var Type $arrayref
22+
*/
1823
$arrayref = $this->popFromOperandStack();
1924

25+
// The value is a ref.
2026
$arrayref[$index] = $value;
27+
28+
$this->pushToOperandStack(
29+
$arrayref
30+
);
2131
}
2232
}

src/Kernel/Mnemonics/_dstore.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
namespace PHPJava\Kernel\Mnemonics;
33

4+
use PHPJava\Kernel\Types\_Double;
45
use PHPJava\Utilities\BinaryTool;
6+
use PHPJava\Utilities\Extractor;
57

68
final class _dstore implements OperationInterface
79
{
@@ -14,8 +16,11 @@ final class _dstore implements OperationInterface
1416
public function execute(): void
1517
{
1618
$index = $this->readUnsignedByte();
17-
$value = $this->popFromOperandStack();
19+
$value = Extractor::getRealValue($this->popFromOperandStack());
1820

19-
$this->setLocalStorage($index, BinaryTool::convertDoubleToIEEE754($value));
21+
$this->setLocalStorage(
22+
$index,
23+
$value
24+
);
2025
}
2126
}

src/Kernel/Mnemonics/_faload.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
namespace PHPJava\Kernel\Mnemonics;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\Type;
6+
use PHPJava\Utilities\Extractor;
57

68
final class _faload implements OperationInterface
79
{
@@ -10,6 +12,11 @@ final class _faload implements OperationInterface
1012

1113
public function execute(): void
1214
{
13-
throw new NotImplementedException(__CLASS__);
15+
$index = Extractor::getRealValue($this->popFromOperandStack());
16+
$arrayref = $this->popFromOperandStack();
17+
18+
$this->pushToOperandStack(
19+
$arrayref[$index]
20+
);
1421
}
1522
}

src/Kernel/Mnemonics/_fastore.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
namespace PHPJava\Kernel\Mnemonics;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\Type;
6+
use PHPJava\Utilities\Extractor;
57

68
final class _fastore implements OperationInterface
79
{
@@ -10,6 +12,19 @@ final class _fastore implements OperationInterface
1012

1113
public function execute(): void
1214
{
13-
throw new NotImplementedException(__CLASS__);
15+
$value = $this->popFromOperandStack();
16+
$index = Extractor::getRealValue($this->popFromOperandStack());
17+
18+
/**
19+
* @var Type $arrayref
20+
*/
21+
$arrayref = $this->popFromOperandStack();
22+
23+
// The value is a ref.
24+
$arrayref[$index] = $value;
25+
26+
$this->pushToOperandStack(
27+
$arrayref
28+
);
1429
}
1530
}

src/Kernel/Mnemonics/_saload.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace PHPJava\Kernel\Mnemonics;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Utilities\Extractor;
56

67
final class _saload implements OperationInterface
78
{
@@ -10,6 +11,11 @@ final class _saload implements OperationInterface
1011

1112
public function execute(): void
1213
{
13-
throw new NotImplementedException(__CLASS__);
14+
$index = Extractor::getRealValue($this->popFromOperandStack());
15+
$arrayref = $this->popFromOperandStack();
16+
17+
$this->pushToOperandStack(
18+
$arrayref[$index]
19+
);
1420
}
1521
}

src/Kernel/Mnemonics/_sastore.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
namespace PHPJava\Kernel\Mnemonics;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\Type;
6+
use PHPJava\Utilities\Extractor;
57

68
final class _sastore implements OperationInterface
79
{
@@ -10,6 +12,19 @@ final class _sastore implements OperationInterface
1012

1113
public function execute(): void
1214
{
13-
throw new NotImplementedException(__CLASS__);
15+
$value = $this->popFromOperandStack();
16+
$index = Extractor::getRealValue($this->popFromOperandStack());
17+
18+
/**
19+
* @var Type $arrayref
20+
*/
21+
$arrayref = $this->popFromOperandStack();
22+
23+
// The value is a ref.
24+
$arrayref[$index] = $value;
25+
26+
$this->pushToOperandStack(
27+
$arrayref
28+
);
1429
}
1530
}

0 commit comments

Comments
 (0)