Add public API for WASM codegen
This commit is contained in:
parent
765905c64f
commit
51945bf58c
@ -1,4 +1,4 @@
|
|||||||
package kscience.kmath.ast
|
package kscience.kmath.wasm.internal
|
||||||
|
|
||||||
internal val f64StandardFunctions by lazy { Base64.toUint8Array(B) }
|
internal val f64StandardFunctions by lazy { Base64.toUint8Array(B) }
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package kscience.kmath.ast
|
package kscience.kmath.wasm.internal
|
||||||
|
|
||||||
import WebAssembly.Instance
|
import WebAssembly.Instance
|
||||||
import binaryen.*
|
import binaryen.*
|
41
kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/wasm.kt
Normal file
41
kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/wasm.kt
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package kscience.kmath.wasm
|
||||||
|
|
||||||
|
import kscience.kmath.ast.MST
|
||||||
|
import kscience.kmath.ast.MstExpression
|
||||||
|
import kscience.kmath.expressions.Expression
|
||||||
|
import kscience.kmath.operations.IntRing
|
||||||
|
import kscience.kmath.operations.RealField
|
||||||
|
import kscience.kmath.wasm.internal.IntWasmBuilder
|
||||||
|
import kscience.kmath.wasm.internal.RealWasmBuilder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles an [MST] to WASM in the context of reals.
|
||||||
|
*
|
||||||
|
* @author Iaroslav Postovalov.
|
||||||
|
*/
|
||||||
|
public fun RealField.expression(mst: MST): Expression<Double> =
|
||||||
|
RealWasmBuilder(mst).instance
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles an [MST] to WASM in the context of integers.
|
||||||
|
*
|
||||||
|
* @author Iaroslav Postovalov.
|
||||||
|
*/
|
||||||
|
public fun IntRing.expression(mst: MST): Expression<Int> =
|
||||||
|
IntWasmBuilder(mst).instance
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimizes performance of an [MstExpression] using WASM codegen in the context of reals.
|
||||||
|
*
|
||||||
|
* @author Iaroslav Postovalov.
|
||||||
|
*/
|
||||||
|
public fun MstExpression<Double, RealField>.compile(): Expression<Double> =
|
||||||
|
RealWasmBuilder(mst).instance
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimizes performance of an [MstExpression] using WASM codegen in the context of integers.
|
||||||
|
*
|
||||||
|
* @author Iaroslav Postovalov.
|
||||||
|
*/
|
||||||
|
public fun MstExpression<Int, IntRing>.compile(): Expression<Int> =
|
||||||
|
IntWasmBuilder(mst).instance
|
Loading…
Reference in New Issue
Block a user