[WASM] Remove deprecated usage of externref

This commit is contained in:
Igor Yakovlev
2022-06-08 12:07:00 +02:00
parent bf575f73a2
commit 270a41a2db
4 changed files with 4 additions and 9 deletions
@@ -445,7 +445,7 @@ fun generateDefaultInitializerForType(type: WasmType, g: WasmExpressionBuilder)
WasmF32 -> g.buildConstF32(0f)
WasmF64 -> g.buildConstF64(0.0)
is WasmRefNullType -> g.buildRefNull(type.heapType)
is WasmAnyRef -> g.buildRefNull(WasmHeapType.Simple.Extern)
is WasmAnyRef -> g.buildRefNull(WasmHeapType.Simple.Any)
WasmUnreachableType -> error("Unreachable type can't be initialized")
else -> error("Unknown value type ${type.name}")
}
@@ -22,8 +22,7 @@ object WasmV128 : WasmType("v128", -0x5)
object WasmI8 : WasmType("i8", -0x6)
object WasmI16 : WasmType("i16", -0x7)
object WasmFuncRef : WasmType("funcref", -0x10)
object WasmExternRef : WasmType("externref", -0x11)
object WasmAnyRef : WasmType("anyref", -0x12)
object WasmAnyRef : WasmType("anyref", -0x11)
object WasmEqRef : WasmType("eqref", -0x13)
data class WasmRefNullType(val heapType: WasmHeapType) : WasmType("ref null", -0x14)
@@ -45,8 +44,7 @@ sealed class WasmHeapType {
sealed class Simple(val name: String, val code: Byte) : WasmHeapType() {
object Func : Simple("func", -0x10)
object Extern : Simple("extern", -0x11)
object Any : Simple("any", -0x12)
object Any : Simple("any", -0x11)
object Eq : Simple("eq", -0x13)
@Suppress("unused")
@@ -73,6 +71,5 @@ fun WasmType.getHeapType(): WasmHeapType =
is WasmEqRef -> WasmHeapType.Simple.Eq
is WasmAnyRef -> WasmHeapType.Simple.Any
is WasmFuncRef -> WasmHeapType.Simple.Func
is WasmExternRef -> WasmHeapType.Simple.Extern
else -> error("Unknown heap type for type $this")
}
@@ -468,7 +468,6 @@ class WasmBinaryToIR(val b: MyByteReader) {
WasmI16,
WasmFuncRef,
WasmAnyRef,
WasmExternRef,
WasmEqRef
).associateBy { it.code }
@@ -491,7 +490,7 @@ class WasmBinaryToIR(val b: MyByteReader) {
return when (code.toInt()) {
0x70 -> WasmFuncRef
0x6F -> WasmExternRef
0x6F -> WasmAnyRef
else -> error("Unsupported heap type ${code.toString(16)}")
}
}
@@ -453,7 +453,6 @@ class WasmIrToText : SExpressionBuilder() {
when (type) {
is WasmFuncRef -> appendElement("func")
is WasmAnyRef -> appendElement("any")
is WasmExternRef -> appendElement("extern")
else -> TODO()
}
}