[Wasm] Rename WasmImportPair -> WasmImportDescriptor

This commit is contained in:
Svyatoslav Kuzmich
2022-12-28 10:11:11 +01:00
parent dd53998c2d
commit 62217b39ec
5 changed files with 13 additions and 13 deletions
@@ -84,7 +84,7 @@ class DeclarationGenerator(
// check(declaration.isExternal) { "Non-external fun with @JsFun ${declaration.fqNameWhenAvailable}"}
val jsCodeName = jsCodeName(declaration)
context.addJsFun(jsCodeName, jsCode)
WasmImportPair("js_code", jsCodeName(declaration))
WasmImportDescriptor("js_code", jsCodeName(declaration))
}
else -> {
null
@@ -16,17 +16,17 @@ import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.getAnnotation
import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.wasm.ir.WasmImportPair
import org.jetbrains.kotlin.wasm.ir.WasmImportDescriptor
fun IrAnnotationContainer.hasExcludedFromCodegenAnnotation(): Boolean =
hasAnnotation(FqName("kotlin.wasm.internal.ExcludedFromCodegen"))
fun IrFunction.getWasmImportDescriptor(): WasmImportPair? {
fun IrFunction.getWasmImportDescriptor(): WasmImportDescriptor? {
val annotation = getAnnotation(FqName("kotlin.wasm.WasmImport"))
?: return null
@Suppress("UNCHECKED_CAST")
return WasmImportPair(
return WasmImportDescriptor(
(annotation.getValueArgument(0) as IrConst<String>).value,
(annotation.getValueArgument(1) as? IrConst<String>)?.value ?: this.name.asString()
)
@@ -51,13 +51,13 @@ sealed class WasmFunction(
class Imported(
name: String,
type: WasmSymbolReadOnly<WasmFunctionType>,
val importPair: WasmImportPair
val importPair: WasmImportDescriptor
) : WasmFunction(name, type)
}
class WasmMemory(
val limits: WasmLimits,
val importPair: WasmImportPair? = null,
val importPair: WasmImportDescriptor? = null,
) : WasmNamedModuleField()
sealed class WasmDataMode {
@@ -81,7 +81,7 @@ class WasmData(
class WasmTable(
var limits: WasmLimits = WasmLimits(1u, null),
val elementType: WasmType,
val importPair: WasmImportPair? = null
val importPair: WasmImportDescriptor? = null
) : WasmNamedModuleField() {
sealed class Value {
@@ -108,7 +108,7 @@ class WasmElement(
class WasmTag(
val type: WasmFunctionType,
val importPair: WasmImportPair? = null
val importPair: WasmImportDescriptor? = null
) : WasmNamedModuleField() {
init {
assert(type.resultTypes.isEmpty()) { "Must have empty return as per current spec" }
@@ -127,7 +127,7 @@ class WasmGlobal(
val type: WasmType,
val isMutable: Boolean,
val init: List<WasmInstr>,
val importPair: WasmImportPair? = null
val importPair: WasmImportDescriptor? = null
) : WasmNamedModuleField()
sealed class WasmExport<T : WasmNamedModuleField>(
@@ -199,7 +199,7 @@ data class WasmLimits(
val maxSize: UInt?
)
data class WasmImportPair(
data class WasmImportDescriptor(
val moduleName: String,
val declarationName: String
)
@@ -91,7 +91,7 @@ class WasmBinaryToIR(val b: MyByteReader) {
// Import section
2 -> {
forEachVectorElement {
val importPair = WasmImportPair(readString(), readString())
val importPair = WasmImportDescriptor(readString(), readString())
when (val kind = b.readByte().toInt()) {
0 -> {
val type = functionTypes[b.readVarUInt32AsInt()]
@@ -359,7 +359,7 @@ class WasmBinaryToIR(val b: MyByteReader) {
)
}
private fun readTag(importPair: WasmImportPair? = null): WasmTag {
private fun readTag(importPair: WasmImportDescriptor? = null): WasmTag {
val attribute = b.readByte()
check(attribute.toInt() == 0) { "as per spec" }
val type = functionTypes[b.readVarUInt32AsInt()]
@@ -320,7 +320,7 @@ class WasmIrToText : SExpressionBuilder() {
}
}
private fun WasmImportPair.appendImportPair() {
private fun WasmImportDescriptor.appendImportPair() {
sameLineList("import") {
toWatString(moduleName)
toWatString(declarationName)