Very experimental WASM code generation by MST in contexts of Int and Real #158
@ -1,10 +1,17 @@
|
||||
@file:Suppress(
|
||||
"INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE",
|
||||
"CONFLICTING_OVERLOADS", "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "KDocMissingDocumentation", "ClassName",
|
||||
"SpellCheckingInspection", "PackageName"
|
||||
"INTERFACE_WITH_SUPERCLASS",
|
||||
"OVERRIDING_FINAL_MEMBER",
|
||||
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
|
||||
"CONFLICTING_OVERLOADS",
|
||||
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING",
|
||||
"KDocMissingDocumentation",
|
||||
"ObjectPropertyName",
|
||||
"ClassName",
|
||||
"PackageDirectoryMismatch",
|
||||
"PackageName",
|
||||
)
|
||||
@file:JsModule("js-base64")
|
||||
@file:JsNonModule
|
||||
|
||||
package Base64
|
||||
|
||||
import org.khronos.webgl.Uint8Array
|
@ -8,12 +8,11 @@
|
||||
"KDocMissingDocumentation",
|
||||
"PropertyName",
|
||||
"ClassName",
|
||||
"SortModifiers",
|
||||
"SpellCheckingInspection",
|
||||
)
|
||||
|
||||
@file:JsModule("binaryen")
|
||||
@file:JsNonModule
|
||||
|
||||
package binaryen
|
||||
|
||||
import org.khronos.webgl.Uint8Array
|
||||
@ -1649,7 +1648,7 @@ external interface `T$27` {
|
||||
var sourceMap: String?
|
||||
}
|
||||
|
||||
external open class Module {
|
||||
open external class Module {
|
||||
open var ptr: Number
|
||||
open fun block(label: String, children: Array<ExpressionRef>, resultType: Type = definedExternally): ExpressionRef
|
||||
open fun `if`(
|
||||
@ -2222,7 +2221,7 @@ external fun setOneCallerInlineMaxSize(size: Number)
|
||||
|
||||
external fun exit(status: Number)
|
||||
|
||||
external open class Relooper(module: Module) {
|
||||
open external class Relooper(module: Module) {
|
||||
open fun addBlock(expression: ExpressionRef): RelooperBlockRef
|
||||
open fun addBranch(from: RelooperBlockRef, to: RelooperBlockRef, condition: ExpressionRef, code: ExpressionRef)
|
||||
open fun addBlockWithSwitch(code: ExpressionRef, condition: ExpressionRef): RelooperBlockRef
|
||||
|
@ -4,6 +4,8 @@ import kscience.kmath.expressions.Expression
|
||||
import kscience.kmath.expressions.StringSymbol
|
||||
import kscience.kmath.operations.*
|
||||
|
||||
private val spreader = eval("(obj, args) => obj(...args)")
|
||||
|
||||
public fun compileMstToWasmF64(mst: MST): Expression<Double> {
|
||||
val keys = mutableListOf<String>()
|
||||
|
||||
@ -75,7 +77,6 @@ public fun compileMstToWasmF64(mst: MST): Expression<Double> {
|
||||
|
||||
return Expression { args ->
|
||||
val params = keys.map { StringSymbol(it) }.map { args.getValue(it) }.toTypedArray()
|
||||
val spreader = eval("(obj, args) => obj(...args)")
|
||||
spreader(i.exports.asDynamic().executable, params) as Double
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,16 @@
|
||||
@file:JsQualifier("WebAssembly")
|
||||
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS",
|
||||
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "KDocMissingDocumentation", "PackageDirectoryMismatch", "PackageName",
|
||||
"Reformat", "ClassName", "SortModifiers"
|
||||
|
||||
@file:Suppress(
|
||||
"INTERFACE_WITH_SUPERCLASS",
|
||||
"OVERRIDING_FINAL_MEMBER",
|
||||
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
|
||||
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING",
|
||||
"KDocMissingDocumentation",
|
||||
"PackageDirectoryMismatch",
|
||||
"PackageName",
|
||||
"ClassName",
|
||||
)
|
||||
|
||||
package WebAssembly
|
||||
|
||||
import org.khronos.webgl.ArrayBuffer
|
||||
@ -132,7 +140,10 @@ external fun compileStreaming(source: Response): Promise<Module>
|
||||
|
||||
external fun compileStreaming(source: Promise<Response>): Promise<Module>
|
||||
|
||||
external fun instantiate(bytes: ArrayBufferView, importObject: Imports = definedExternally): Promise<WebAssemblyInstantiatedSource>
|
||||
external fun instantiate(
|
||||
bytes: ArrayBufferView,
|
||||
importObject: Imports = definedExternally
|
||||
): Promise<WebAssemblyInstantiatedSource>
|
||||
|
||||
external fun instantiate(bytes: ArrayBufferView): Promise<WebAssemblyInstantiatedSource>
|
||||
|
||||
@ -144,11 +155,17 @@ external fun instantiate(moduleObject: Module, importObject: Imports = definedEx
|
||||
|
||||
external fun instantiate(moduleObject: Module): Promise<Instance>
|
||||
|
||||
external fun instantiateStreaming(response: Response, importObject: Imports = definedExternally): Promise<WebAssemblyInstantiatedSource>
|
||||
external fun instantiateStreaming(
|
||||
response: Response,
|
||||
importObject: Imports = definedExternally
|
||||
): Promise<WebAssemblyInstantiatedSource>
|
||||
|
||||
external fun instantiateStreaming(response: Response): Promise<WebAssemblyInstantiatedSource>
|
||||
|
||||
external fun instantiateStreaming(response: PromiseLike<Response>, importObject: Imports = definedExternally): Promise<WebAssemblyInstantiatedSource>
|
||||
external fun instantiateStreaming(
|
||||
response: PromiseLike<Response>,
|
||||
importObject: Imports = definedExternally
|
||||
): Promise<WebAssemblyInstantiatedSource>
|
||||
|
||||
external fun instantiateStreaming(response: PromiseLike<Response>): Promise<WebAssemblyInstantiatedSource>
|
||||
|
||||
@ -167,7 +184,7 @@ external interface `T$1` {
|
||||
var kind: String
|
||||
}
|
||||
|
||||
external open class Module {
|
||||
open external class Module {
|
||||
constructor(bufferSource: ArrayBuffer)
|
||||
constructor(bufferSource: Uint8Array)
|
||||
|
||||
@ -179,18 +196,18 @@ external open class Module {
|
||||
}
|
||||
|
||||
@JsName("Instance")
|
||||
external open class Instance(module: Module, importObject: Any = definedExternally) {
|
||||
open external class Instance(module: Module, importObject: Any = definedExternally) {
|
||||
open var exports: Any
|
||||
}
|
||||
|
||||
@JsName("Memory")
|
||||
external open class Memory1(memoryDescriptor: MemoryDescriptor) {
|
||||
open external class Memory1(memoryDescriptor: MemoryDescriptor) {
|
||||
open var buffer: ArrayBuffer
|
||||
open fun grow(numPages: Number): Number
|
||||
}
|
||||
|
||||
@JsName("Table")
|
||||
external open class Table1(tableDescriptor: TableDescriptor) {
|
||||
open external class Table1(tableDescriptor: TableDescriptor) {
|
||||
open var length: Number
|
||||
open fun get(index: Number): Function<*>
|
||||
open fun grow(numElements: Number): Number
|
||||
|
@ -1,19 +1,9 @@
|
||||
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS")
|
||||
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS",
|
||||
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "PackageDirectoryMismatch", "KDocMissingDocumentation"
|
||||
)
|
||||
package tsstdlib
|
||||
|
||||
import kotlin.js.*
|
||||
import org.khronos.webgl.*
|
||||
import org.w3c.dom.*
|
||||
import org.w3c.dom.events.*
|
||||
import org.w3c.dom.parsing.*
|
||||
import org.w3c.dom.svg.*
|
||||
import org.w3c.dom.url.*
|
||||
import org.w3c.fetch.*
|
||||
import org.w3c.files.*
|
||||
import org.w3c.notifications.*
|
||||
import org.w3c.performance.*
|
||||
import org.w3c.workers.*
|
||||
import org.w3c.xhr.*
|
||||
import kotlin.js.Promise
|
||||
|
||||
external interface IteratorYieldResult<TYield> {
|
||||
var done: Boolean?
|
||||
|
@ -1,19 +1,13 @@
|
||||
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS")
|
||||
@file:Suppress(
|
||||
"INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS",
|
||||
"PackageDirectoryMismatch", "DEPRECATION", "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "KDocMissingDocumentation",
|
||||
"UNUSED_TYPEALIAS_PARAMETER", "PropertyName"
|
||||
)
|
||||
|
||||
package tsstdlib
|
||||
|
||||
import kotlin.js.*
|
||||
import org.khronos.webgl.*
|
||||
import org.w3c.dom.*
|
||||
import org.w3c.dom.events.*
|
||||
import org.w3c.dom.parsing.*
|
||||
import org.w3c.dom.svg.*
|
||||
import org.w3c.dom.url.*
|
||||
import org.w3c.fetch.*
|
||||
import org.w3c.files.*
|
||||
import org.w3c.notifications.*
|
||||
import org.w3c.performance.*
|
||||
import org.w3c.workers.*
|
||||
import org.w3c.xhr.*
|
||||
import org.khronos.webgl.ArrayBuffer
|
||||
import org.khronos.webgl.Uint8Array
|
||||
|
||||
external interface FunctionConstructor {
|
||||
@nativeInvoke
|
||||
@ -28,13 +22,18 @@ external interface ErrorConstructor {
|
||||
}
|
||||
|
||||
external interface PromiseLike<T> {
|
||||
fun then(onfulfilled: ((value: T) -> Any?)? = definedExternally, onrejected: ((reason: Any) -> Any?)? = definedExternally): PromiseLike<dynamic /* TResult1 | TResult2 */>
|
||||
fun then(
|
||||
onfulfilled: ((value: T) -> Any?)? = definedExternally,
|
||||
onrejected: ((reason: Any) -> Any?)? = definedExternally
|
||||
): PromiseLike<dynamic /* TResult1 | TResult2 */>
|
||||
}
|
||||
|
||||
external interface ArrayLike<T> {
|
||||
var length: Number
|
||||
|
||||
@nativeGetter
|
||||
operator fun get(n: Number): T?
|
||||
|
||||
@nativeSetter
|
||||
operator fun set(n: Number, value: T)
|
||||
}
|
||||
@ -51,13 +50,24 @@ external interface ArrayBufferConstructor {
|
||||
}
|
||||
|
||||
external interface Uint8ArrayConstructor {
|
||||
fun from(arrayLike: Iterable<Number>, mapfn: (v: Number, k: Number) -> Number = definedExternally, thisArg: Any = definedExternally): Uint8Array
|
||||
fun from(
|
||||
arrayLike: Iterable<Number>,
|
||||
mapfn: (v: Number, k: Number) -> Number = definedExternally,
|
||||
thisArg: Any = definedExternally
|
||||
): Uint8Array
|
||||
|
||||
fun from(arrayLike: Iterable<Number>): Uint8Array
|
||||
fun from(arrayLike: Iterable<Number>, mapfn: (v: Number, k: Number) -> Number = definedExternally): Uint8Array
|
||||
var prototype: Uint8Array
|
||||
var BYTES_PER_ELEMENT: Number
|
||||
fun of(vararg items: Number): Uint8Array
|
||||
fun from(arrayLike: ArrayLike<Number>): Uint8Array
|
||||
fun <T> from(arrayLike: ArrayLike<T>, mapfn: (v: T, k: Number) -> Number, thisArg: Any = definedExternally): Uint8Array
|
||||
|
||||
fun <T> from(
|
||||
arrayLike: ArrayLike<T>,
|
||||
mapfn: (v: T, k: Number) -> Number,
|
||||
thisArg: Any = definedExternally
|
||||
): Uint8Array
|
||||
|
||||
fun <T> from(arrayLike: ArrayLike<T>, mapfn: (v: T, k: Number) -> Number): Uint8Array
|
||||
}
|
Loading…
Reference in New Issue
Block a user