mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +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 AnyType type;
|
||||||
|
|
||||||
|
private final TypeManager types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of an array operation.
|
* Create an instance of an array operation.
|
||||||
*
|
*
|
||||||
@ -50,10 +52,11 @@ class WasmArrayInstruction extends WasmInstruction {
|
|||||||
* @param lineNumber
|
* @param lineNumber
|
||||||
* the line number in the Java source code
|
* 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 );
|
super( javaCodePos, lineNumber );
|
||||||
this.op = op;
|
this.op = op;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.types = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +80,7 @@ class WasmArrayInstruction extends WasmInstruction {
|
|||||||
AnyType getPushValueType() {
|
AnyType getPushValueType() {
|
||||||
switch( op ) {
|
switch( op ) {
|
||||||
case NEW:
|
case NEW:
|
||||||
return ValueType.anyref;
|
return types.arrayType( type );
|
||||||
case GET:
|
case GET:
|
||||||
return type instanceof ValueType ? (ValueType)type : ValueType.anyref;
|
return type instanceof ValueType ? (ValueType)type : ValueType.anyref;
|
||||||
case SET:
|
case SET:
|
||||||
|
@ -343,7 +343,7 @@ public abstract class WasmCodeBuilder {
|
|||||||
*/
|
*/
|
||||||
protected void addArrayInstruction( ArrayOperator op, AnyType type, int javaCodePos, int lineNumber ) {
|
protected void addArrayInstruction( ArrayOperator op, AnyType type, int javaCodePos, int lineNumber ) {
|
||||||
if( useGC ) {
|
if( useGC ) {
|
||||||
instructions.add( new WasmArrayInstruction( op, type, javaCodePos, lineNumber ) );
|
instructions.add( new WasmArrayInstruction( op, type, types, javaCodePos, lineNumber ) );
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if( type.getCode() >= 0 ) {
|
if( type.getCode() >= 0 ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user