mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix bugs related to MULTINEWARRAY in various backends
This commit is contained in:
parent
2c74f282c4
commit
29fd95be95
|
@ -198,11 +198,7 @@ public class ClassGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(ConstructMultiArrayInstruction insn) {
|
public void visit(ConstructMultiArrayInstruction insn) {
|
||||||
ValueType type = insn.getItemType();
|
addType(insn.getItemType());
|
||||||
for (int i = 0; i < insn.getDimensions().size(); ++i) {
|
|
||||||
type = ValueType.arrayOf(type);
|
|
||||||
}
|
|
||||||
addType(type);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1326,7 +1326,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
||||||
WasmInt32Subtype.INT32));
|
WasmInt32Subtype.INT32));
|
||||||
}
|
}
|
||||||
|
|
||||||
int classPointer = classGenerator.getClassPointer(ValueType.arrayOf(type));
|
int classPointer = classGenerator.getClassPointer(type);
|
||||||
String allocName = context.names.forMethod(new MethodReference(Allocator.class, "allocateMultiArray",
|
String allocName = context.names.forMethod(new MethodReference(Allocator.class, "allocateMultiArray",
|
||||||
RuntimeClass.class, Address.class, int.class, RuntimeArray.class));
|
RuntimeClass.class, Address.class, int.class, RuntimeArray.class));
|
||||||
WasmCall call = new WasmCall(allocName);
|
WasmCall call = new WasmCall(allocName);
|
||||||
|
|
|
@ -828,11 +828,7 @@ public class ClassInference {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(ConstructMultiArrayInstruction insn) {
|
public void visit(ConstructMultiArrayInstruction insn) {
|
||||||
ValueType type = insn.getItemType();
|
addType(insn.getReceiver().getIndex(), 0, insn.getItemType().toString());
|
||||||
for (int i = 0; i < insn.getDimensions().size(); ++i) {
|
|
||||||
type = ValueType.arrayOf(type);
|
|
||||||
}
|
|
||||||
addType(insn.getReceiver().getIndex(), 0, type.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class TypeInferer {
|
||||||
@Override
|
@Override
|
||||||
public void createArray(VariableReader receiver, ValueType itemType,
|
public void createArray(VariableReader receiver, ValueType itemType,
|
||||||
List<? extends VariableReader> dimensions) {
|
List<? extends VariableReader> dimensions) {
|
||||||
types[receiver.getIndex()] = convert(ValueType.arrayOf(itemType));
|
types[receiver.getIndex()] = convert(itemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,6 +42,32 @@ public class VMTest {
|
||||||
assertEquals(int[].class, array[0].getClass());
|
assertEquals(int[].class, array[0].getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void longMultiArrayCreated() {
|
||||||
|
long[][] array = new long[3][2];
|
||||||
|
assertEquals(3, array.length);
|
||||||
|
assertEquals(2, array[1].length);
|
||||||
|
assertEquals(2, array[2].length);
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length; ++i) {
|
||||||
|
assertEquals(2, array[i].length);
|
||||||
|
for (int j = 0; j < array[i].length; ++j) {
|
||||||
|
assertEquals(0, array[i][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length; ++i) {
|
||||||
|
Arrays.fill(array[i], 0x0123456789ABCDEFL);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length; ++i) {
|
||||||
|
assertEquals(2, array[i].length);
|
||||||
|
for (int j = 0; j < array[i].length; ++j) {
|
||||||
|
assertEquals(0x0123456789ABCDEFL, array[i][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void catchExceptionFromLambda() {
|
public void catchExceptionFromLambda() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user