Skip to content

Commit 44d3782

Browse files
committed
Add mnemonics that are casts from interger types.
1 parent 08ab49b commit 44d3782

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

src/Kernel/Mnemonics/_i2b.php

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

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\_Byte;
56
use PHPJava\Utilities\BinaryTool;
7+
use PHPJava\Utilities\Extractor;
68

79
final class _i2b implements OperationInterface
810
{
@@ -11,6 +13,10 @@ final class _i2b implements OperationInterface
1113

1214
public function execute(): void
1315
{
14-
throw new NotImplementedException(__CLASS__);
16+
$value = Extractor::realValue(
17+
$this->popFromOperandStack()
18+
);
19+
20+
$this->pushToOperandStack(new _Byte($value));
1521
}
1622
}

src/Kernel/Mnemonics/_i2c.php

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

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\_Char;
56
use PHPJava\Utilities\BinaryTool;
7+
use PHPJava\Utilities\Extractor;
68

79
final class _i2c implements OperationInterface
810
{
@@ -11,6 +13,10 @@ final class _i2c implements OperationInterface
1113

1214
public function execute(): void
1315
{
14-
throw new NotImplementedException(__CLASS__);
16+
$value = Extractor::realValue(
17+
$this->popFromOperandStack()
18+
);
19+
20+
$this->pushToOperandStack(new _Char($value));
1521
}
1622
}

src/Kernel/Mnemonics/_i2d.php

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

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\_Double;
56
use PHPJava\Utilities\BinaryTool;
7+
use PHPJava\Utilities\Extractor;
68

79
final class _i2d implements OperationInterface
810
{
@@ -11,6 +13,10 @@ final class _i2d implements OperationInterface
1113

1214
public function execute(): void
1315
{
14-
throw new NotImplementedException(__CLASS__);
16+
$value = Extractor::realValue(
17+
$this->popFromOperandStack()
18+
);
19+
20+
$this->pushToOperandStack(new _Double($value));
1521
}
1622
}

src/Kernel/Mnemonics/_i2f.php

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

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\_Float;
56
use PHPJava\Utilities\BinaryTool;
7+
use PHPJava\Utilities\Extractor;
68

79
final class _i2f implements OperationInterface
810
{
@@ -11,6 +13,10 @@ final class _i2f implements OperationInterface
1113

1214
public function execute(): void
1315
{
14-
throw new NotImplementedException(__CLASS__);
16+
$value = Extractor::realValue(
17+
$this->popFromOperandStack()
18+
);
19+
20+
$this->pushToOperandStack(new _Float($value));
1521
}
1622
}

src/Kernel/Mnemonics/_i2l.php

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

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\_Long;
56
use PHPJava\Utilities\BinaryTool;
7+
use PHPJava\Utilities\Extractor;
68

79
final class _i2l implements OperationInterface
810
{
@@ -11,6 +13,10 @@ final class _i2l implements OperationInterface
1113

1214
public function execute(): void
1315
{
14-
throw new NotImplementedException(__CLASS__);
16+
$value = Extractor::realValue(
17+
$this->popFromOperandStack()
18+
);
19+
20+
$this->pushToOperandStack(new _Long($value));
1521
}
1622
}

src/Kernel/Mnemonics/_i2s.php

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

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Types\_Short;
56
use PHPJava\Utilities\BinaryTool;
7+
use PHPJava\Utilities\Extractor;
68

79
final class _i2s implements OperationInterface
810
{
@@ -11,8 +13,10 @@ final class _i2s implements OperationInterface
1113

1214
public function execute(): void
1315
{
14-
$value = $this->popFromOperandStack();
16+
$value = Extractor::realValue(
17+
$this->popFromOperandStack()
18+
);
1519

16-
$this->pushToOperandStack(base_convert(substr(sprintf('%032s', base_convert($value, 10, 2)), 16), 2, 10));
20+
$this->pushToOperandStack(new _Short($value));
1721
}
1822
}

0 commit comments

Comments
 (0)