Fix the stack value of array new.

This commit is contained in:
Volker Berlin 2019-08-27 20:41:00 +02:00
parent fd0a22121c
commit 6ea1955886
2 changed files with 6 additions and 3 deletions

View File

@ -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:

View File

@ -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 ) {