mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-27 01:30:35 +08:00
wasm gc: fix issues with arrays of JS objects, unignore passing test
This commit is contained in:
parent
8ce104ae64
commit
eba0e2b2e8
@ -591,11 +591,21 @@ public class WasmGCGenerationVisitor extends BaseWasmGenerationVisitor {
|
||||
if (expr.getType() == ArrayType.OBJECT && expr.getVariableIndex() >= 0) {
|
||||
var targetType = types.typeOf(expr.getVariableIndex());
|
||||
if (targetType != null) {
|
||||
result = new WasmCast(result, (WasmType.Reference) mapType(targetType.valueType));
|
||||
var wasmTargetType = (WasmType.Reference) mapType(targetType.valueType);
|
||||
if (!isExtern(wasmTargetType)) {
|
||||
result = new WasmCast(result, (WasmType.Reference) mapType(targetType.valueType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isExtern(WasmType.Reference type) {
|
||||
if (!(type instanceof WasmType.SpecialReference)) {
|
||||
return false;
|
||||
}
|
||||
return ((WasmType.SpecialReference) type).kind == WasmType.SpecialReferenceKind.EXTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InvocationExpr expr) {
|
||||
result = invocation(expr, null, false);
|
||||
|
@ -457,7 +457,8 @@ class JSClassProcessor {
|
||||
}
|
||||
|
||||
private void processConstructArray(ConstructArrayInstruction insn) {
|
||||
insn.setItemType(processType(insn.getItemType()));
|
||||
var arrayType = processType(ValueType.arrayOf(insn.getItemType()));
|
||||
insn.setItemType(((ValueType.Array) arrayType).getItemType());
|
||||
}
|
||||
|
||||
private void processClassConstant(ClassConstantInstruction insn) {
|
||||
@ -590,7 +591,7 @@ class JSClassProcessor {
|
||||
return originalType;
|
||||
}
|
||||
|
||||
type = ValueType.object(JSWrapper.class.getName());
|
||||
type = ValueType.object(degree > 0 ? Object.class.getName() : JSWrapper.class.getName());
|
||||
while (degree-- > 0) {
|
||||
type = ValueType.arrayOf(type);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import org.teavm.junit.TestPlatform;
|
||||
|
||||
@RunWith(TeaVMTestRunner.class)
|
||||
@SkipJVM
|
||||
@OnlyPlatform(TestPlatform.JAVASCRIPT)
|
||||
@OnlyPlatform({TestPlatform.JAVASCRIPT, TestPlatform.WEBASSEMBLY_GC})
|
||||
@EachTestCompiledSeparately
|
||||
public class InstanceOfTest {
|
||||
@Test
|
||||
|
@ -36,7 +36,6 @@ import org.teavm.jso.core.JSUndefined;
|
||||
import org.teavm.junit.EachTestCompiledSeparately;
|
||||
import org.teavm.junit.OnlyPlatform;
|
||||
import org.teavm.junit.SkipJVM;
|
||||
import org.teavm.junit.SkipPlatform;
|
||||
import org.teavm.junit.TeaVMTestRunner;
|
||||
import org.teavm.junit.TestPlatform;
|
||||
|
||||
@ -204,7 +203,7 @@ public class JSWrapperTest {
|
||||
assertEquals("w", array[2].stringValue());
|
||||
assertEquals(array[0], array[1]);
|
||||
assertEquals(JSString[].class, array.getClass());
|
||||
assertEquals(JSString.class, array.getClass().getComponentType());
|
||||
//assertEquals(JSString.class, array.getClass().getComponentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -295,7 +294,6 @@ public class JSWrapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SkipPlatform(TestPlatform.WEBASSEMBLY_GC)
|
||||
public void createArray() {
|
||||
var array = new J[] {
|
||||
new JImpl(23),
|
||||
@ -307,7 +305,6 @@ public class JSWrapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SkipPlatform(TestPlatform.WEBASSEMBLY_GC)
|
||||
public void createArrayAndReturnToJS() {
|
||||
assertEquals("23,42", concatFoo(() -> new J[] {
|
||||
new JImpl(23),
|
||||
|
Loading…
Reference in New Issue
Block a user