File tree Expand file tree Collapse file tree 13 files changed +126
-30
lines changed
Expand file tree Collapse file tree 13 files changed +126
-30
lines changed Original file line number Diff line number Diff line change 44use PHPJava \Exceptions \NotImplementedException ;
55use PHPJava \Kernel \Types \_Int ;
66use PHPJava \Utilities \BinaryTool ;
7+ use PHPJava \Utilities \Extractor ;
78
89final class _iadd implements OperationInterface
910{
@@ -15,14 +16,13 @@ public function execute(): void
1516 $ rightValue = $ this ->getStack ();
1617 $ leftValue = $ this ->getStack ();
1718
18- if ($ leftValue instanceof _Int) {
19- $ leftValue = $ leftValue ->getValue ();
20- }
21-
22- if ($ rightValue instanceof _Int) {
23- $ rightValue = $ rightValue ->getValue ();
24- }
25-
26- $ this ->pushStack (BinaryTool::add ($ leftValue , $ rightValue ));
19+ $ this ->pushStack (
20+ new _Int (
21+ BinaryTool::add (
22+ Extractor::realValue ($ leftValue ),
23+ Extractor::realValue ($ rightValue )
24+ )
25+ )
26+ );
2727 }
2828}
Original file line number Diff line number Diff line change 22namespace PHPJava \Kernel \Mnemonics ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Kernel \Types \_Double ;
56use PHPJava \Utilities \BinaryTool ;
7+ use PHPJava \Utilities \Extractor ;
68
79final class _idiv implements OperationInterface
810{
@@ -11,6 +13,16 @@ final class _idiv implements OperationInterface
1113
1214 public function execute (): void
1315 {
14- throw new NotImplementedException (__CLASS__ );
16+ $ value2 = $ this ->getStack ();
17+ $ value1 = $ this ->getStack ();
18+
19+ $ this ->pushStack (
20+ new _Double (
21+ BinaryTool::div (
22+ Extractor::realValue ($ value1 ),
23+ Extractor::realValue ($ value2 )
24+ )
25+ )
26+ );
1527 }
1628}
Original file line number Diff line number Diff line change 22namespace PHPJava \Kernel \Mnemonics ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Kernel \Types \_Int ;
56use PHPJava \Utilities \BinaryTool ;
7+ use PHPJava \Utilities \Extractor ;
68
79final class _imul implements OperationInterface
810{
@@ -14,6 +16,13 @@ public function execute(): void
1416 $ value2 = $ this ->getStack ();
1517 $ value1 = $ this ->getStack ();
1618
17- $ this ->pushStack (BinaryTool::multiply ($ value1 , $ value2 , 4 ));
19+ $ this ->pushStack (
20+ new _Int (
21+ BinaryTool::multiply (
22+ Extractor::realValue ($ value1 ),
23+ Extractor::realValue ($ value2 )
24+ )
25+ )
26+ );
1827 }
1928}
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ final class _ireturn implements OperationInterface
1515 */
1616 public function execute ()
1717 {
18- return new _Int ($ this ->getStack ());
18+ $ value = $ this ->getStack ();
19+ return ($ value instanceof _Int)
20+ ? $ value
21+ : new _Int ($ value );
1922 }
2023}
Original file line number Diff line number Diff line change 22namespace PHPJava \Kernel \Mnemonics ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Kernel \Types \_Int ;
56use PHPJava \Utilities \BinaryTool ;
7+ use PHPJava \Utilities \Extractor ;
68
79final class _isub implements OperationInterface
810{
@@ -14,6 +16,13 @@ public function execute(): void
1416 $ rightValue = $ this ->getStack ();
1517 $ leftValue = $ this ->getStack ();
1618
17- $ this ->pushStack (BinaryTool::sub ($ leftValue , $ rightValue , 4 ));
19+ $ this ->pushStack (
20+ new _Int (
21+ BinaryTool::sub (
22+ Extractor::realValue ($ leftValue ),
23+ Extractor::realValue ($ rightValue )
24+ )
25+ )
26+ );
1827 }
1928}
Original file line number Diff line number Diff line change 22namespace PHPJava \Kernel \Mnemonics ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Kernel \Types \_Long ;
56use PHPJava \Utilities \BinaryTool ;
7+ use PHPJava \Utilities \Extractor ;
68
79final class _ladd implements OperationInterface
810{
@@ -14,6 +16,13 @@ public function execute(): void
1416 $ value2 = $ this ->getStack ();
1517 $ value1 = $ this ->getStack ();
1618
17- $ this ->pushStack (BinaryTool::add ($ value1 , $ value2 ));
19+ $ this ->pushStack (
20+ new _Long (
21+ BinaryTool::add (
22+ Extractor::realValue ($ value1 ),
23+ Extractor::realValue ($ value2 )
24+ )
25+ )
26+ );
1827 }
1928}
Original file line number Diff line number Diff line change 22namespace PHPJava \Kernel \Mnemonics ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Kernel \Types \_Double ;
56use PHPJava \Utilities \BinaryTool ;
7+ use PHPJava \Utilities \Extractor ;
68
79final class _ldiv implements OperationInterface
810{
@@ -11,6 +13,16 @@ final class _ldiv implements OperationInterface
1113
1214 public function execute (): void
1315 {
14- throw new NotImplementedException (__CLASS__ );
16+ $ value2 = $ this ->getStack ();
17+ $ value1 = $ this ->getStack ();
18+
19+ $ this ->pushStack (
20+ new _Double (
21+ BinaryTool::div (
22+ Extractor::realValue ($ value1 ),
23+ Extractor::realValue ($ value2 )
24+ )
25+ )
26+ );
1527 }
1628}
Original file line number Diff line number Diff line change 22namespace PHPJava \Kernel \Mnemonics ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Kernel \Types \_Long ;
56use PHPJava \Utilities \BinaryTool ;
7+ use PHPJava \Utilities \Extractor ;
68
79final class _lmul implements OperationInterface
810{
@@ -14,6 +16,13 @@ public function execute(): void
1416 $ value2 = $ this ->getStack ();
1517 $ value1 = $ this ->getStack ();
1618
17- $ this ->pushStack (BinaryTool::multiply ($ value1 , $ value2 , 8 ));
19+ $ this ->pushStack (
20+ new _Long (
21+ BinaryTool::multiply (
22+ Extractor::realValue ($ value1 ),
23+ Extractor::realValue ($ value2 )
24+ )
25+ )
26+ );
1827 }
1928}
Original file line number Diff line number Diff line change 22namespace PHPJava \Kernel \Mnemonics ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Kernel \Types \_Long ;
56use PHPJava \Utilities \BinaryTool ;
67
78final class _lreturn implements OperationInterface
89{
910 use \PHPJava \Kernel \Core \Accumulator;
1011 use \PHPJava \Kernel \Core \ConstantPool;
1112
12- public function execute (): void
13+ public function execute ()
1314 {
14- return new JavaTypeLong ($ this ->getStack ());
15+ $ value = $ this ->getStack ();
16+ return ($ value instanceof _Long)
17+ ? $ value
18+ : new _Long ($ value );
1519 }
1620}
Original file line number Diff line number Diff line change 22namespace PHPJava \Kernel \Mnemonics ;
33
44use PHPJava \Exceptions \NotImplementedException ;
5+ use PHPJava \Kernel \Types \_Long ;
56use PHPJava \Utilities \BinaryTool ;
7+ use PHPJava \Utilities \Extractor ;
68
79final class _lsub implements OperationInterface
810{
@@ -14,6 +16,13 @@ public function execute(): void
1416 $ value2 = $ this ->getStack ();
1517 $ value1 = $ this ->getStack ();
1618
17- $ this ->pushStack (BinaryTool::sub ($ value1 , $ value2 , 8 ));
19+ $ this ->pushStack (
20+ new _Long (
21+ BinaryTool::sub (
22+ Extractor::realValue ($ value1 ),
23+ Extractor::realValue ($ value2 )
24+ )
25+ )
26+ );
1827 }
1928}
You can’t perform that action at this time.
0 commit comments