Revert "[WASM] Remove deprecated usage of externref"

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