File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<?php
22namespace PHPJava \Kernel \Mnemonics ;
33
4+ use PHPJava \Utilities \Extractor ;
5+
46final class _aastore implements OperationInterface
57{
68 use \PHPJava \Kernel \Core \Accumulator;
@@ -12,7 +14,7 @@ final class _aastore implements OperationInterface
1214 public function execute (): void
1315 {
1416 $ value = $ this ->popFromOperandStack ();
15- $ index = $ this ->popFromOperandStack ();
17+ $ index = Extractor:: getRealValue ( $ this ->popFromOperandStack () );
1618 $ arrayref = $ this ->popFromOperandStack ();
1719
1820 $ arrayref [$ index ] = $ value ;
Original file line number Diff line number Diff line change 11<?php
22namespace PHPJava \Kernel \Mnemonics ;
33
4+ use PHPJava \Utilities \Extractor ;
5+
46final class _anewarray implements OperationInterface
57{
68 use \PHPJava \Kernel \Core \Accumulator;
@@ -17,7 +19,7 @@ public function execute(): void
1719 $ this ->readUnsignedShort ();
1820
1921 // 空の配列を渡す (nullで埋める)
20- $ count = $ this ->popFromOperandStack ();
22+ $ count = Extractor:: getRealValue ( $ this ->popFromOperandStack () );
2123 // need reference
2224 $ ref = new \ArrayIterator (array_fill (0 , $ count , null ));
2325 $ this ->pushToOperandStackByReference ($ ref );
Original file line number Diff line number Diff line change 11<?php
22namespace PHPJava \Kernel \Mnemonics ;
33
4+ use PHPJava \Utilities \Extractor ;
5+
46final class _daload implements OperationInterface
57{
68 use \PHPJava \Kernel \Core \Accumulator;
@@ -11,7 +13,7 @@ final class _daload implements OperationInterface
1113 */
1214 public function execute (): void
1315 {
14- $ index = $ this ->popFromOperandStack ();
16+ $ index = Extractor:: getRealValue ( $ this ->popFromOperandStack () );
1517 $ arrayref = $ this ->popFromOperandStack ();
1618
1719 $ this ->pushToOperandStack ($ arrayref [$ index ]);
Original file line number Diff line number Diff line change 11<?php
22namespace PHPJava \Kernel \Mnemonics ;
33
4+ use PHPJava \Utilities \Extractor ;
5+
46final class _dastore implements OperationInterface
57{
68 use \PHPJava \Kernel \Core \Accumulator;
@@ -12,7 +14,7 @@ final class _dastore implements OperationInterface
1214 public function execute (): void
1315 {
1416 $ value = $ this ->popFromOperandStack ();
15- $ index = $ this ->popFromOperandStack ();
17+ $ index = Extractor:: getRealValue ( $ this ->popFromOperandStack () );
1618 $ arrayref = $ this ->popFromOperandStack ();
1719
1820 $ arrayref [$ index ] = $ value ;
Original file line number Diff line number Diff line change 11<?php
22namespace PHPJava \Kernel \Mnemonics ;
33
4+ use PHPJava \Utilities \Extractor ;
5+
46final class _laload implements OperationInterface
57{
68 use \PHPJava \Kernel \Core \Accumulator;
@@ -11,7 +13,7 @@ final class _laload implements OperationInterface
1113 */
1214 public function execute (): void
1315 {
14- $ index = $ this ->popFromOperandStack ();
16+ $ index = Extractor:: getRealValue ( $ this ->popFromOperandStack () );
1517 $ arrayref = $ this ->popFromOperandStack ();
1618
1719 $ this ->pushToOperandStack ($ arrayref [$ index ]);
Original file line number Diff line number Diff line change 11<?php
22namespace PHPJava \Kernel \Mnemonics ;
33
4+ use PHPJava \Utilities \Extractor ;
5+
46final class _lastore implements OperationInterface
57{
68 use \PHPJava \Kernel \Core \Accumulator;
@@ -12,7 +14,7 @@ final class _lastore implements OperationInterface
1214 public function execute (): void
1315 {
1416 $ value = $ this ->popFromOperandStack ();
15- $ index = $ this ->popFromOperandStack ();
17+ $ index = Extractor:: getRealValue ( $ this ->popFromOperandStack () );
1618 $ arrayref = $ this ->popFromOperandStack ();
1719
1820 $ arrayref [$ index ] = $ value ;
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace PHPJava \Tests ;
3+
4+ class ArrayTest extends Base
5+ {
6+ protected $ fixtures = [
7+ 'ArrayTest ' ,
8+ ];
9+
10+ private function call ($ method )
11+ {
12+ $ calculatedValue = $ this ->initiatedJavaClasses ['ArrayTest ' ]
13+ ->getInvoker ()
14+ ->getStatic ()
15+ ->getMethods ()
16+ ->call ($ method );
17+
18+ return $ calculatedValue ;
19+ }
20+
21+ public function testCreateIntArray ()
22+ {
23+ $ actual = $ this ->call ('createIntArray ' );
24+
25+ $ this ->assertEquals (3 , $ actual ->count ());
26+ $ this ->assertEquals (1 , $ actual ->offsetGet (0 )->getValue ());
27+ $ this ->assertEquals (2 , $ actual ->offsetGet (1 )->getValue ());
28+ $ this ->assertEquals (3 , $ actual ->offsetGet (2 )->getValue ());
29+ }
30+
31+ public function testCreateStringArray ()
32+ {
33+ $ actual = $ this ->call ('createStringArray ' );
34+
35+ $ this ->assertEquals (3 , $ actual ->count ());
36+ $ this ->assertEquals ("foo " , $ actual ->offsetGet (0 ));
37+ $ this ->assertEquals ("bar " , $ actual ->offsetGet (1 ));
38+ $ this ->assertEquals ("baz " , $ actual ->offsetGet (2 ));
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ class ArrayTest
2+ {
3+ public static int [] createIntArray ()
4+ {
5+ return new int [] { 1 , 2 , 3 };
6+ }
7+
8+ public static String [] createStringArray ()
9+ {
10+ return new String [] { "foo" , "bar" , "baz" };
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments