mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 10:44:47 +01:00
Fix the stack value of array new.
This commit is contained in:
parent
fd0a22121c
commit
6ea1955886
@ -38,6 +38,8 @@ class WasmArrayInstruction extends WasmInstruction {
|
||||
|
||||
private final AnyType type;
|
||||
|
||||
private final TypeManager types;
|
||||
|
||||
/**
|
||||
* Create an instance of an array operation.
|
||||
*
|
||||
@ -50,10 +52,11 @@ class WasmArrayInstruction extends WasmInstruction {
|
||||
* @param lineNumber
|
||||
* the line number in the Java source code
|
||||
*/
|
||||
WasmArrayInstruction( @Nullable ArrayOperator op, @Nullable AnyType type, int javaCodePos, int lineNumber ) {
|
||||
WasmArrayInstruction( @Nullable ArrayOperator op, @Nullable AnyType type, TypeManager types, int javaCodePos, int lineNumber ) {
|
||||
super( javaCodePos, lineNumber );
|
||||
this.op = op;
|
||||
this.type = type;
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,7 +80,7 @@ class WasmArrayInstruction extends WasmInstruction {
|
||||
AnyType getPushValueType() {
|
||||
switch( op ) {
|
||||
case NEW:
|
||||
return ValueType.anyref;
|
||||
return types.arrayType( type );
|
||||
case GET:
|
||||
return type instanceof ValueType ? (ValueType)type : ValueType.anyref;
|
||||
case SET:
|
||||
|
@ -343,7 +343,7 @@ public abstract class WasmCodeBuilder {
|
||||
*/
|
||||
protected void addArrayInstruction( ArrayOperator op, AnyType type, int javaCodePos, int lineNumber ) {
|
||||
if( useGC ) {
|
||||
instructions.add( new WasmArrayInstruction( op, type, javaCodePos, lineNumber ) );
|
||||
instructions.add( new WasmArrayInstruction( op, type, types, javaCodePos, lineNumber ) );
|
||||
} else {
|
||||
try {
|
||||
if( type.getCode() >= 0 ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user