Skip to content

Commit b83a7ec

Browse files
committed
Add tests
1 parent d2260c9 commit b83a7ec

20 files changed

+715
-24
lines changed

src/Core/JVM/Invoker/Invokable.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use PHPJava\Kernel\Provider\DependencyInjectionProvider;
2121
use PHPJava\Kernel\Structures\_MethodInfo;
2222
use PHPJava\Kernel\Types\_Char;
23+
use PHPJava\Kernel\Types\_Double;
24+
use PHPJava\Kernel\Types\_Long;
2325
use PHPJava\Packages\java\lang\NoSuchMethodException;
2426
use PHPJava\Utilities\AttributionResolver;
2527
use PHPJava\Utilities\DebugTool;
@@ -123,11 +125,10 @@ function () use ($name, $arguments) {
123125
}
124126

125127
$reader = new BinaryReader($handle);
126-
$localStorage = $arguments;
127128

128129
if ($this->isDynamic()) {
129130
array_unshift(
130-
$localStorage,
131+
$arguments,
131132
$this->javaClassInvoker->getJavaClass()
132133
);
133134
}
@@ -145,13 +146,22 @@ function () use ($name, $arguments) {
145146

146147
$this->debugTool->getLogger()->info('Start operations: ' . $methodBeautified);
147148

148-
$localStorage = array_map(
149-
function ($item) {
150-
return TypeResolver::convertPHPTypeToJavaType($item);
149+
$arguments = array_map(
150+
function ($argument) {
151+
return TypeResolver::convertPHPTypeToJavaType($argument);
151152
},
152-
$localStorage
153+
$arguments
153154
);
154155

156+
$localStorage = [];
157+
foreach ($arguments as $argument) {
158+
$localStorage[] = $argument;
159+
if ($argument instanceof _Double || $argument instanceof _Long) {
160+
// Double and Long has problem which skipping next storage.
161+
$localStorage[] = null;
162+
}
163+
}
164+
155165
$dependencyInjectionProvider = (new DependencyInjectionProvider())
156166
->add(
157167
'ConstantPool',

src/Kernel/Mnemonics/_dadd.php

Lines changed: 12 additions & 3 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 _dadd implements OperationInterface
79
{
@@ -10,9 +12,16 @@ final class _dadd implements OperationInterface
1012

1113
public function execute(): void
1214
{
13-
$value2 = $this->popFromOperandStack();
14-
$value1 = $this->popFromOperandStack();
15+
$rightValue = $this->popFromOperandStack();
16+
$leftValue = $this->popFromOperandStack();
1517

16-
$this->pushToOperandStack(BinaryTool::add($value1, $value2));
18+
$this->pushToOperandStack(
19+
_Double::get(
20+
BinaryTool::add(
21+
Extractor::getRealValue($leftValue),
22+
Extractor::getRealValue($rightValue)
23+
)
24+
)
25+
);
1726
}
1827
}

src/Kernel/Mnemonics/_dmul.php

Lines changed: 12 additions & 3 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 _dmul implements OperationInterface
79
{
@@ -10,9 +12,16 @@ final class _dmul implements OperationInterface
1012

1113
public function execute(): void
1214
{
13-
$value2 = $this->popFromOperandStack();
14-
$value1 = $this->popFromOperandStack();
15+
$rightValue = $this->popFromOperandStack();
16+
$leftValue = $this->popFromOperandStack();
1517

16-
$this->pushToOperandStack(BinaryTool::multiply($value1, $value2, 8));
18+
$this->pushToOperandStack(
19+
_Double::get(
20+
BinaryTool::multiply(
21+
Extractor::getRealValue($leftValue),
22+
Extractor::getRealValue($rightValue)
23+
)
24+
)
25+
);
1726
}
1827
}

src/Kernel/Mnemonics/_drem.php

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

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Kernel\Types\_Double;
65
use PHPJava\Utilities\Extractor;
76

src/Kernel/Mnemonics/_dsub.php

Lines changed: 10 additions & 1 deletion
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 _dsub implements OperationInterface
79
{
@@ -13,6 +15,13 @@ public function execute(): void
1315
$rightValue = $this->popFromOperandStack();
1416
$leftValue = $this->popFromOperandStack();
1517

16-
$this->pushToOperandStack(BinaryTool::sub($leftValue, $rightValue, 8));
18+
$this->pushToOperandStack(
19+
_Double::get(
20+
BinaryTool::sub(
21+
Extractor::getRealValue($leftValue),
22+
Extractor::getRealValue($rightValue)
23+
)
24+
)
25+
);
1726
}
1827
}

src/Kernel/Mnemonics/_fadd.php

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

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Kernel\Types\_Float;
65
use PHPJava\Utilities\BinaryTool;
76
use PHPJava\Utilities\Extractor;

src/Kernel/Mnemonics/_fmul.php

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

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Kernel\Types\_Float;
6-
use PHPJava\Kernel\Types\_Int;
75
use PHPJava\Utilities\BinaryTool;
86
use PHPJava\Utilities\Extractor;
97

src/Kernel/Mnemonics/_frem.php

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

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Kernel\Types\_Float;
65
use PHPJava\Utilities\Extractor;
76

src/Kernel/Mnemonics/_fsub.php

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

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Kernel\Types\_Float;
65
use PHPJava\Utilities\BinaryTool;
76
use PHPJava\Utilities\Extractor;

src/Kernel/Mnemonics/_if_icmpeq.php

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

4-
use PHPJava\Exceptions\NotImplementedException;
54
use PHPJava\Utilities\Extractor;
65

76
final class _if_icmpeq implements OperationInterface

0 commit comments

Comments
 (0)