@@ -432,13 +432,12 @@ public WasmTable tableAlloc(int initial, int maximum, TableKind elemKind, Object
432
432
433
433
private static Object tableGrow (Object [] args ) {
434
434
checkArgumentCount (args , 2 );
435
- if (!(args [0 ] instanceof WasmTable )) {
435
+ if (!(args [0 ] instanceof WasmTable table )) {
436
436
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "First argument must be wasm table" );
437
437
}
438
438
if (!(args [1 ] instanceof Integer )) {
439
439
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "Second argument must be integer" );
440
440
}
441
- WasmTable table = (WasmTable ) args [0 ];
442
441
int delta = (Integer ) args [1 ];
443
442
if (args .length > 2 ) {
444
443
return tableGrow (table , delta , args [2 ]);
@@ -456,13 +455,12 @@ public static int tableGrow(WasmTable table, int delta, Object ref) {
456
455
457
456
private static Object tableRead (Object [] args ) {
458
457
checkArgumentCount (args , 2 );
459
- if (!(args [0 ] instanceof WasmTable )) {
458
+ if (!(args [0 ] instanceof WasmTable table )) {
460
459
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "First argument must be wasm table" );
461
460
}
462
461
if (!(args [1 ] instanceof Integer )) {
463
462
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "Second argument must be integer" );
464
463
}
465
- WasmTable table = (WasmTable ) args [0 ];
466
464
int index = (Integer ) args [1 ];
467
465
return tableRead (table , index );
468
466
}
@@ -477,13 +475,12 @@ public static Object tableRead(WasmTable table, int index) {
477
475
478
476
private Object tableWrite (Object [] args ) {
479
477
checkArgumentCount (args , 3 );
480
- if (!(args [0 ] instanceof WasmTable )) {
478
+ if (!(args [0 ] instanceof WasmTable table )) {
481
479
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "First argument must be wasm table" );
482
480
}
483
481
if (!(args [1 ] instanceof Integer )) {
484
482
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "Second argument must be integer" );
485
483
}
486
- WasmTable table = (WasmTable ) args [0 ];
487
484
int index = (Integer ) args [1 ];
488
485
return tableWrite (table , index , args [2 ]);
489
486
}
@@ -515,10 +512,9 @@ public Object tableWrite(WasmTable table, int index, Object element) {
515
512
516
513
private static Object tableSize (Object [] args ) {
517
514
checkArgumentCount (args , 1 );
518
- if (!(args [0 ] instanceof WasmTable )) {
515
+ if (!(args [0 ] instanceof WasmTable table )) {
519
516
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "First argument must be wasm table" );
520
517
}
521
- WasmTable table = (WasmTable ) args [0 ];
522
518
return tableSize (table );
523
519
}
524
520
@@ -613,13 +609,12 @@ public static WasmMemory memAlloc(int initial, int maximum, boolean shared) {
613
609
614
610
private static Object memGrow (Object [] args ) {
615
611
checkArgumentCount (args , 2 );
616
- if (!(args [0 ] instanceof WasmMemory )) {
612
+ if (!(args [0 ] instanceof WasmMemory memory )) {
617
613
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "First argument must be wasm memory" );
618
614
}
619
615
if (!(args [1 ] instanceof Integer )) {
620
616
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "Second argument must be integer" );
621
617
}
622
- WasmMemory memory = (WasmMemory ) args [0 ];
623
618
int delta = (Integer ) args [1 ];
624
619
return memGrow (memory , delta );
625
620
}
@@ -818,10 +813,9 @@ public WasmGlobal globalAlloc(ValueType valueType, boolean mutable, Object value
818
813
819
814
private static Object globalRead (Object [] args ) {
820
815
checkArgumentCount (args , 1 );
821
- if (!(args [0 ] instanceof WasmGlobal )) {
816
+ if (!(args [0 ] instanceof WasmGlobal global )) {
822
817
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "First argument must be wasm global" );
823
818
}
824
- WasmGlobal global = (WasmGlobal ) args [0 ];
825
819
return globalRead (global );
826
820
}
827
821
@@ -845,10 +839,9 @@ public static Object globalRead(WasmGlobal global) {
845
839
846
840
private Object globalWrite (Object [] args ) {
847
841
checkArgumentCount (args , 2 );
848
- if (!(args [0 ] instanceof WasmGlobal )) {
842
+ if (!(args [0 ] instanceof WasmGlobal global )) {
849
843
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "First argument must be wasm global" );
850
844
}
851
- WasmGlobal global = (WasmGlobal ) args [0 ];
852
845
return globalWrite (global , args [1 ]);
853
846
}
854
847
@@ -904,14 +897,12 @@ public Object globalWrite(WasmGlobal global, Object value) {
904
897
905
898
private static Object instanceExport (Object [] args ) {
906
899
checkArgumentCount (args , 2 );
907
- if (!(args [0 ] instanceof WasmInstance )) {
900
+ if (!(args [0 ] instanceof WasmInstance instance )) {
908
901
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "First argument must be wasm instance" );
909
902
}
910
- if (!(args [1 ] instanceof String )) {
903
+ if (!(args [1 ] instanceof String name )) {
911
904
throw new WasmJsApiException (WasmJsApiException .Kind .TypeError , "Second argument must be string" );
912
905
}
913
- WasmInstance instance = (WasmInstance ) args [0 ];
914
- String name = (String ) args [1 ];
915
906
return instanceExport (instance , name );
916
907
}
917
908
0 commit comments