Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.wasm.ir
class WasmModule(
val functionTypes: List = emptyList(),
val gcTypes: List = emptyList(),
val gcTypesInRecursiveGroup: Boolean,
val importsInOrder: List = emptyList(),
val importedFunctions: List = emptyList(),
val importedMemories: List = emptyList(),
val importedTables: List = emptyList(),
val importedGlobals: List = emptyList(),
val importedTags: List = emptyList(),
val definedFunctions: List = emptyList(),
val tables: List = emptyList(),
val memories: List = emptyList(),
val globals: List = emptyList(),
val exports: List> = emptyList(),
val elements: List = emptyList(),
val tags: List = emptyList(),
val startFunction: WasmFunction? = null,
val data: List = emptyList(),
val dataCount: Boolean = false,
)
sealed class WasmNamedModuleField {
var id: Int? = null
open val name: String = ""
}
sealed class WasmFunction(
override val name: String,
val type: WasmSymbolReadOnly
) : WasmNamedModuleField() {
class Defined(
name: String,
type: WasmSymbolReadOnly,
val locals: MutableList = mutableListOf(),
val instructions: MutableList = mutableListOf()
) : WasmFunction(name, type)
class Imported(
name: String,
type: WasmSymbolReadOnly,
val importPair: WasmImportPair
) : WasmFunction(name, type)
}
class WasmMemory(
val limits: WasmLimits,
val importPair: WasmImportPair? = null,
) : WasmNamedModuleField()
sealed class WasmDataMode {
class Active(
val memoryIdx: Int,
val offset: MutableList
) : WasmDataMode() {
constructor(memoryIdx: Int, offset: Int) : this(memoryIdx, mutableListOf().also> {
WasmIrExpressionBuilder(it).buildConstI32(offset)
})
}
object Passive : WasmDataMode()
}
class WasmData(
val mode: WasmDataMode,
val bytes: ByteArray,
) : WasmNamedModuleField()
class WasmTable(
var limits: WasmLimits = WasmLimits(1u, null),
val elementType: WasmType,
val importPair: WasmImportPair? = null
) : WasmNamedModuleField() {
sealed class Value {
class Function(val function: WasmSymbol) : Value() {
constructor(function: WasmFunction) : this(WasmSymbol(function))
}
class Expression(val expr: List) : Value()
}
}
class WasmElement(
val type: WasmType,
val values: List,
val mode: Mode,
) : WasmNamedModuleField() {
sealed class Mode {
object Passive : Mode()
class Active(val table: WasmTable, val offset: List) : Mode()
object Declarative : Mode()
}
}
class WasmTag(
val type: WasmFunctionType,
val importPair: WasmImportPair? = null
) : WasmNamedModuleField() {
init {
assert(type.resultTypes.isEmpty()) { "Must have empty return as per current spec" }
}
}
class WasmLocal(
val id: Int,
val name: String,
val type: WasmType,
val isParameter: Boolean
)
class WasmGlobal(
override val name: String,
val type: WasmType,
val isMutable: Boolean,
val init: List,
val importPair: WasmImportPair? = null
) : WasmNamedModuleField()
sealed class WasmExport(
val name: String,
val field: T,
val kind: Byte,
val keyword: String
) {
class Function(name: String, field: WasmFunction) : WasmExport(name, field, 0x0, "func")
class Table(name: String, field: WasmTable) : WasmExport(name, field, 0x1, "table")
class Memory(name: String, field: WasmMemory) : WasmExport(name, field, 0x2, "memory")
class Global(name: String, field: WasmGlobal) : WasmExport(name, field, 0x3, "global")
class Tag(name: String, field: WasmTag) : WasmExport(name, field, 0x4, "tag")
}
sealed class WasmTypeDeclaration(
override val name: String
) : WasmNamedModuleField()
data class WasmFunctionType(
val parameterTypes: List,
val resultTypes: List
) : WasmTypeDeclaration("")
class WasmStructDeclaration(
name: String,
val fields: List,
val superType: WasmSymbolReadOnly?
) : WasmTypeDeclaration(name)
class WasmArrayDeclaration(
name: String,
val field: WasmStructFieldDeclaration
) : WasmTypeDeclaration(name)
class WasmStructFieldDeclaration(
val name: String,
val type: WasmType,
val isMutable: Boolean
)
class WasmInstr(
val operator: WasmOp,
val immediates: List = emptyList()
)
data class WasmLimits(
val minSize: UInt,
val maxSize: UInt?
)
data class WasmImportPair(
val moduleName: String,
val declarationName: String
)