diff --git a/kmath-ast/build.gradle.kts b/kmath-ast/build.gradle.kts index 2f95d427d..e46f4839e 100644 --- a/kmath-ast/build.gradle.kts +++ b/kmath-ast/build.gradle.kts @@ -2,6 +2,20 @@ plugins { id("ru.mipt.npm.mpp") } +kotlin.js { + nodejs { // or `browser` + testTask { + useMocha().timeout = "0" + } + } + + browser { + testTask { + useMocha().timeout = "0" + } + } +} + kotlin.sourceSets { commonMain { dependencies { @@ -16,4 +30,12 @@ kotlin.sourceSets { implementation("org.ow2.asm:asm-commons:8.0.1") } } + + jsMain { + dependencies { + implementation(npm("binaryen", "98.0.0-nightly.20201113")) + implementation(npm("js-base64", "3.6.0")) + implementation(npm("webassembly", "0.11.0")) + } + } } diff --git a/kmath-ast/src/jsMain/kotlin/base64.d.ts b/kmath-ast/src/jsMain/kotlin/base64.d.ts new file mode 100644 index 000000000..cb26dace9 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/base64.d.ts @@ -0,0 +1,135 @@ +/** + * base64.ts + * + * Licensed under the BSD 3-Clause License. + * http://opensource.org/licenses/BSD-3-Clause + * + * References: + * http://en.wikipedia.org/wiki/Base64 + * + * @author Dan Kogai (https://github.com/dankogai) + */ +declare const version = "3.6.0"; +/** + * @deprecated use lowercase `version`. + */ +declare const VERSION = "3.6.0"; +/** + * polyfill version of `btoa` + */ +declare const btoaPolyfill: (bin: string) => string; +/** + * does what `window.btoa` of web browsers do. + * @param {String} bin binary string + * @returns {string} Base64-encoded string + */ +declare const _btoa: (bin: string) => string; +/** + * converts a Uint8Array to a Base64 string. + * @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5 + * @returns {string} Base64 string + */ +declare const fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string; +/** + * @deprecated should have been internal use only. + * @param {string} src UTF-8 string + * @returns {string} UTF-16 string + */ +declare const utob: (u: string) => string; +/** + * converts a UTF-8-encoded string to a Base64 string. + * @param {boolean} [urlsafe] if `true` make the result URL-safe + * @returns {string} Base64 string + */ +declare const encode: (src: string, urlsafe?: boolean) => string; +/** + * converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5. + * @returns {string} Base64 string + */ +declare const encodeURI: (src: string) => string; +/** + * @deprecated should have been internal use only. + * @param {string} src UTF-16 string + * @returns {string} UTF-8 string + */ +declare const btou: (b: string) => string; +/** + * polyfill version of `atob` + */ +declare const atobPolyfill: (asc: string) => string; +/** + * does what `window.atob` of web browsers do. + * @param {String} asc Base64-encoded string + * @returns {string} binary string + */ +declare const _atob: (asc: string) => string; +/** + * converts a Base64 string to a Uint8Array. + */ +declare const toUint8Array: (a: string) => Uint8Array; +/** + * converts a Base64 string to a UTF-8 string. + * @param {String} src Base64 string. Both normal and URL-safe are supported + * @returns {string} UTF-8 string + */ +declare const decode: (src: string) => string; +/** + * check if a value is a valid Base64 string + * @param {String} src a value to check + */ +declare const isValid: (src: any) => boolean; +/** + * extend String.prototype with relevant methods + */ +declare const extendString: () => void; +/** + * extend Uint8Array.prototype with relevant methods + */ +declare const extendUint8Array: () => void; +/** + * extend Builtin prototypes with relevant methods + */ +declare const extendBuiltins: () => void; +declare const gBase64: { + version: string; + VERSION: string; + atob: (asc: string) => string; + atobPolyfill: (asc: string) => string; + btoa: (bin: string) => string; + btoaPolyfill: (bin: string) => string; + fromBase64: (src: string) => string; + toBase64: (src: string, urlsafe?: boolean) => string; + encode: (src: string, urlsafe?: boolean) => string; + encodeURI: (src: string) => string; + encodeURL: (src: string) => string; + utob: (u: string) => string; + btou: (b: string) => string; + decode: (src: string) => string; + isValid: (src: any) => boolean; + fromUint8Array: (u8a: Uint8Array, urlsafe?: boolean) => string; + toUint8Array: (a: string) => Uint8Array; + extendString: () => void; + extendUint8Array: () => void; + extendBuiltins: () => void; +}; +export { version }; +export { VERSION }; +export { _atob as atob }; +export { atobPolyfill }; +export { _btoa as btoa }; +export { btoaPolyfill }; +export { decode as fromBase64 }; +export { encode as toBase64 }; +export { utob }; +export { encode }; +export { encodeURI }; +export { encodeURI as encodeURL }; +export { btou }; +export { decode }; +export { isValid }; +export { fromUint8Array }; +export { toUint8Array }; +export { extendString }; +export { extendUint8Array }; +export { extendBuiltins }; +export { gBase64 as Base64 }; \ No newline at end of file diff --git a/kmath-ast/src/jsMain/kotlin/base64.kt b/kmath-ast/src/jsMain/kotlin/base64.kt new file mode 100644 index 000000000..70c57ee97 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/base64.kt @@ -0,0 +1,75 @@ +@file:Suppress( + "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:JsNonModule +@file:JsModule("js-base64") + +package Base64 + +import org.khronos.webgl.Uint8Array + +external var version: Any + +external var VERSION: Any + +external var btoaPolyfill: (bin: String) -> String + +external var _btoa: (bin: String) -> String + +external var fromUint8Array: (u8a: Uint8Array, urlsafe: Boolean) -> String + +external var utob: (u: String) -> String + +external var encode: (src: String, urlsafe: Boolean) -> String + +external var encodeURI: (src: String) -> String + +external var btou: (b: String) -> String + +external var atobPolyfill: (asc: String) -> String + +external var _atob: (asc: String) -> String + +external var toUint8Array: (a: String) -> Uint8Array + +external var decode: (src: String) -> String + +external var isValid: (src: Any) -> Boolean + +external var extendString: () -> Unit + +external var extendUint8Array: () -> Unit + +external var extendBuiltins: () -> Unit + +external object gBase64 { + var version: String + var VERSION: String + var atob: (asc: String) -> String + var atobPolyfill: (asc: String) -> String + var btoa: (bin: String) -> String + var btoaPolyfill: (bin: String) -> String + var fromBase64: (src: String) -> String + var toBase64: (src: String, urlsafe: Boolean) -> String + var encode: (src: String, urlsafe: Boolean) -> String + var encodeURI: (src: String) -> String + var encodeURL: (src: String) -> String + var utob: (u: String) -> String + var btou: (b: String) -> String + var decode: (src: String) -> String + var isValid: (src: Any) -> Boolean + var fromUint8Array: (u8a: Uint8Array, urlsafe: Boolean) -> String + var toUint8Array: (a: String) -> Uint8Array + var extendString: () -> Unit + var extendUint8Array: () -> Unit + var extendBuiltins: () -> Unit +} diff --git a/kmath-ast/src/jsMain/kotlin/index.binaryen.kt b/kmath-ast/src/jsMain/kotlin/index.binaryen.kt new file mode 100644 index 000000000..e28289b0f --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/index.binaryen.kt @@ -0,0 +1,2236 @@ +@file:Suppress( + "INTERFACE_WITH_SUPERCLASS", + "OVERRIDING_FINAL_MEMBER", + "RETURN_TYPE_MISMATCH_ON_OVERRIDE", + "CONFLICTING_OVERLOADS", + "PackageDirectoryMismatch", + "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", + "KDocMissingDocumentation", + "PropertyName", + "ClassName", +) + +@file:JsModule("binaryen") +@file:JsNonModule + +package binaryen + +import org.khronos.webgl.Uint8Array +import kotlin.js.Promise + +external var isReady: Boolean + +external var ready: Promise + +external var none: Type + +external var i32: Type + +external var i64: Type + +external var f32: Type + +external var f64: Type + +external var v128: Type + +external var funcref: Type + +external var anyref: Type + +external var nullref: Type + +external var exnref: Type + +external var unreachable: Type + +external var auto: Type + +external fun createType(types: Array): Type + +external fun expandType(type: Type): Array + +external enum class ExpressionIds { + Invalid, + Block, + If, + Loop, + Break, + Switch, + Call, + CallIndirect, + LocalGet, + LocalSet, + GlobalGet, + GlobalSet, + Load, + Store, + Const, + Unary, + Binary, + Select, + Drop, + Return, + Host, + Nop, + Unreachable, + AtomicCmpxchg, + AtomicRMW, + AtomicWait, + AtomicNotify, + AtomicFence, + SIMDExtract, + SIMDReplace, + SIMDShuffle, + SIMDTernary, + SIMDShift, + SIMDLoad, + MemoryInit, + DataDrop, + MemoryCopy, + MemoryFill, + RefNull, + RefIsNull, + RefFunc, + Try, + Throw, + Rethrow, + BrOnExn, + TupleMake, + TupleExtract, + Push, + Pop +} + +external var InvalidId: ExpressionIds + +external var BlockId: ExpressionIds + +external var IfId: ExpressionIds + +external var LoopId: ExpressionIds + +external var BreakId: ExpressionIds + +external var SwitchId: ExpressionIds + +external var CallId: ExpressionIds + +external var CallIndirectId: ExpressionIds + +external var LocalGetId: ExpressionIds + +external var LocalSetId: ExpressionIds + +external var GlobalGetId: ExpressionIds + +external var GlobalSetId: ExpressionIds + +external var LoadId: ExpressionIds + +external var StoreId: ExpressionIds + +external var ConstId: ExpressionIds + +external var UnaryId: ExpressionIds + +external var BinaryId: ExpressionIds + +external var SelectId: ExpressionIds + +external var DropId: ExpressionIds + +external var ReturnId: ExpressionIds + +external var HostId: ExpressionIds + +external var NopId: ExpressionIds + +external var UnreachableId: ExpressionIds + +external var AtomicCmpxchgId: ExpressionIds + +external var AtomicRMWId: ExpressionIds + +external var AtomicWaitId: ExpressionIds + +external var AtomicNotifyId: ExpressionIds + +external var AtomicFenceId: ExpressionIds + +external var SIMDExtractId: ExpressionIds + +external var SIMDReplaceId: ExpressionIds + +external var SIMDShuffleId: ExpressionIds + +external var SIMDTernaryId: ExpressionIds + +external var SIMDShiftId: ExpressionIds + +external var SIMDLoadId: ExpressionIds + +external var MemoryInitId: ExpressionIds + +external var DataDropId: ExpressionIds + +external var MemoryCopyId: ExpressionIds + +external var MemoryFillId: ExpressionIds + +external var RefNullId: ExpressionIds + +external var RefIsNullId: ExpressionIds + +external var RefFuncId: ExpressionIds + +external var TryId: ExpressionIds + +external var ThrowId: ExpressionIds + +external var RethrowId: ExpressionIds + +external var BrOnExnId: ExpressionIds + +external var TupleMakeId: ExpressionIds + +external var TupleExtractId: ExpressionIds + +external var PushId: ExpressionIds + +external var PopId: ExpressionIds + +external enum class ExternalKinds { + Function, + Table, + Memory, + Global, + Event +} + +external var ExternalFunction: ExternalKinds + +external var ExternalTable: ExternalKinds + +external var ExternalMemory: ExternalKinds + +external var ExternalGlobal: ExternalKinds + +external var ExternalEvent: ExternalKinds + +external enum class Features { + MVP, + Atomics, + MutableGlobals, + TruncSat, + SIMD, + BulkMemory, + SignExt, + ExceptionHandling, + TailCall, + ReferenceTypes, + Multivalue, + GC, + Memory64, + All +} + +external enum class Operations { + ClzInt32, + CtzInt32, + PopcntInt32, + NegFloat32, + AbsFloat32, + CeilFloat32, + FloorFloat32, + TruncFloat32, + NearestFloat32, + SqrtFloat32, + EqZInt32, + ClzInt64, + CtzInt64, + PopcntInt64, + NegFloat64, + AbsFloat64, + CeilFloat64, + FloorFloat64, + TruncFloat64, + NearestFloat64, + SqrtFloat64, + EqZInt64, + ExtendSInt32, + ExtendUInt32, + WrapInt64, + TruncSFloat32ToInt32, + TruncSFloat32ToInt64, + TruncUFloat32ToInt32, + TruncUFloat32ToInt64, + TruncSFloat64ToInt32, + TruncSFloat64ToInt64, + TruncUFloat64ToInt32, + TruncUFloat64ToInt64, + TruncSatSFloat32ToInt32, + TruncSatSFloat32ToInt64, + TruncSatUFloat32ToInt32, + TruncSatUFloat32ToInt64, + TruncSatSFloat64ToInt32, + TruncSatSFloat64ToInt64, + TruncSatUFloat64ToInt32, + TruncSatUFloat64ToInt64, + ReinterpretFloat32, + ReinterpretFloat64, + ConvertSInt32ToFloat32, + ConvertSInt32ToFloat64, + ConvertUInt32ToFloat32, + ConvertUInt32ToFloat64, + ConvertSInt64ToFloat32, + ConvertSInt64ToFloat64, + ConvertUInt64ToFloat32, + ConvertUInt64ToFloat64, + PromoteFloat32, + DemoteFloat64, + ReinterpretInt32, + ReinterpretInt64, + ExtendS8Int32, + ExtendS16Int32, + ExtendS8Int64, + ExtendS16Int64, + ExtendS32Int64, + AddInt32, + SubInt32, + MulInt32, + DivSInt32, + DivUInt32, + RemSInt32, + RemUInt32, + AndInt32, + OrInt32, + XorInt32, + ShlInt32, + ShrUInt32, + ShrSInt32, + RotLInt32, + RotRInt32, + EqInt32, + NeInt32, + LtSInt32, + LtUInt32, + LeSInt32, + LeUInt32, + GtSInt32, + GtUInt32, + GeSInt32, + GeUInt32, + AddInt64, + SubInt64, + MulInt64, + DivSInt64, + DivUInt64, + RemSInt64, + RemUInt64, + AndInt64, + OrInt64, + XorInt64, + ShlInt64, + ShrUInt64, + ShrSInt64, + RotLInt64, + RotRInt64, + EqInt64, + NeInt64, + LtSInt64, + LtUInt64, + LeSInt64, + LeUInt64, + GtSInt64, + GtUInt64, + GeSInt64, + GeUInt64, + AddFloat32, + SubFloat32, + MulFloat32, + DivFloat32, + CopySignFloat32, + MinFloat32, + MaxFloat32, + EqFloat32, + NeFloat32, + LtFloat32, + LeFloat32, + GtFloat32, + GeFloat32, + AddFloat64, + SubFloat64, + MulFloat64, + DivFloat64, + CopySignFloat64, + MinFloat64, + MaxFloat64, + EqFloat64, + NeFloat64, + LtFloat64, + LeFloat64, + GtFloat64, + GeFloat64, + MemorySize, + MemoryGrow, + AtomicRMWAdd, + AtomicRMWSub, + AtomicRMWAnd, + AtomicRMWOr, + AtomicRMWXor, + AtomicRMWXchg, + SplatVecI8x16, + ExtractLaneSVecI8x16, + ExtractLaneUVecI8x16, + ReplaceLaneVecI8x16, + SplatVecI16x8, + ExtractLaneSVecI16x8, + ExtractLaneUVecI16x8, + ReplaceLaneVecI16x8, + SplatVecI32x4, + ExtractLaneVecI32x4, + ReplaceLaneVecI32x4, + SplatVecI64x2, + ExtractLaneVecI64x2, + ReplaceLaneVecI64x2, + SplatVecF32x4, + ExtractLaneVecF32x4, + ReplaceLaneVecF32x4, + SplatVecF64x2, + ExtractLaneVecF64x2, + ReplaceLaneVecF64x2, + EqVecI8x16, + NeVecI8x16, + LtSVecI8x16, + LtUVecI8x16, + GtSVecI8x16, + GtUVecI8x16, + LeSVecI8x16, + LeUVecI8x16, + GeSVecI8x16, + GeUVecI8x16, + EqVecI16x8, + NeVecI16x8, + LtSVecI16x8, + LtUVecI16x8, + GtSVecI16x8, + GtUVecI16x8, + LeSVecI16x8, + LeUVecI16x8, + GeSVecI16x8, + GeUVecI16x8, + EqVecI32x4, + NeVecI32x4, + LtSVecI32x4, + LtUVecI32x4, + GtSVecI32x4, + GtUVecI32x4, + LeSVecI32x4, + LeUVecI32x4, + GeSVecI32x4, + GeUVecI32x4, + EqVecF32x4, + NeVecF32x4, + LtVecF32x4, + GtVecF32x4, + LeVecF32x4, + GeVecF32x4, + EqVecF64x2, + NeVecF64x2, + LtVecF64x2, + GtVecF64x2, + LeVecF64x2, + GeVecF64x2, + NotVec128, + AndVec128, + OrVec128, + XorVec128, + AndNotVec128, + BitselectVec128, + NegVecI8x16, + AnyTrueVecI8x16, + AllTrueVecI8x16, + ShlVecI8x16, + ShrSVecI8x16, + ShrUVecI8x16, + AddVecI8x16, + AddSatSVecI8x16, + AddSatUVecI8x16, + SubVecI8x16, + SubSatSVecI8x16, + SubSatUVecI8x16, + MulVecI8x16, + MinSVecI8x16, + MinUVecI8x16, + MaxSVecI8x16, + MaxUVecI8x16, + NegVecI16x8, + AnyTrueVecI16x8, + AllTrueVecI16x8, + ShlVecI16x8, + ShrSVecI16x8, + ShrUVecI16x8, + AddVecI16x8, + AddSatSVecI16x8, + AddSatUVecI16x8, + SubVecI16x8, + SubSatSVecI16x8, + SubSatUVecI16x8, + MulVecI16x8, + MinSVecI16x8, + MinUVecI16x8, + MaxSVecI16x8, + MaxUVecI16x8, + DotSVecI16x8ToVecI32x4, + NegVecI32x4, + AnyTrueVecI32x4, + AllTrueVecI32x4, + ShlVecI32x4, + ShrSVecI32x4, + ShrUVecI32x4, + AddVecI32x4, + SubVecI32x4, + MulVecI32x4, + MinSVecI32x4, + MinUVecI32x4, + MaxSVecI32x4, + MaxUVecI32x4, + NegVecI64x2, + AnyTrueVecI64x2, + AllTrueVecI64x2, + ShlVecI64x2, + ShrSVecI64x2, + ShrUVecI64x2, + AddVecI64x2, + SubVecI64x2, + AbsVecF32x4, + NegVecF32x4, + SqrtVecF32x4, + QFMAVecF32x4, + QFMSVecF32x4, + AddVecF32x4, + SubVecF32x4, + MulVecF32x4, + DivVecF32x4, + MinVecF32x4, + MaxVecF32x4, + AbsVecF64x2, + NegVecF64x2, + SqrtVecF64x2, + QFMAVecF64x2, + QFMSVecF64x2, + AddVecF64x2, + SubVecF64x2, + MulVecF64x2, + DivVecF64x2, + MinVecF64x2, + MaxVecF64x2, + TruncSatSVecF32x4ToVecI32x4, + TruncSatUVecF32x4ToVecI32x4, + TruncSatSVecF64x2ToVecI64x2, + TruncSatUVecF64x2ToVecI64x2, + ConvertSVecI32x4ToVecF32x4, + ConvertUVecI32x4ToVecF32x4, + ConvertSVecI64x2ToVecF64x2, + ConvertUVecI64x2ToVecF64x2, + LoadSplatVec8x16, + LoadSplatVec16x8, + LoadSplatVec32x4, + LoadSplatVec64x2, + LoadExtSVec8x8ToVecI16x8, + LoadExtUVec8x8ToVecI16x8, + LoadExtSVec16x4ToVecI32x4, + LoadExtUVec16x4ToVecI32x4, + LoadExtSVec32x2ToVecI64x2, + LoadExtUVec32x2ToVecI64x2, + NarrowSVecI16x8ToVecI8x16, + NarrowUVecI16x8ToVecI8x16, + NarrowSVecI32x4ToVecI16x8, + NarrowUVecI32x4ToVecI16x8, + WidenLowSVecI8x16ToVecI16x8, + WidenHighSVecI8x16ToVecI16x8, + WidenLowUVecI8x16ToVecI16x8, + WidenHighUVecI8x16ToVecI16x8, + WidenLowSVecI16x8ToVecI32x4, + WidenHighSVecI16x8ToVecI32x4, + WidenLowUVecI16x8ToVecI32x4, + WidenHighUVecI16x8ToVecI32x4, + SwizzleVec8x16 +} + +external var ClzInt32: Operations + +external var CtzInt32: Operations + +external var PopcntInt32: Operations + +external var NegFloat32: Operations + +external var AbsFloat32: Operations + +external var CeilFloat32: Operations + +external var FloorFloat32: Operations + +external var TruncFloat32: Operations + +external var NearestFloat32: Operations + +external var SqrtFloat32: Operations + +external var EqZInt32: Operations + +external var ClzInt64: Operations + +external var CtzInt64: Operations + +external var PopcntInt64: Operations + +external var NegFloat64: Operations + +external var AbsFloat64: Operations + +external var CeilFloat64: Operations + +external var FloorFloat64: Operations + +external var TruncFloat64: Operations + +external var NearestFloat64: Operations + +external var SqrtFloat64: Operations + +external var EqZInt64: Operations + +external var ExtendSInt32: Operations + +external var ExtendUInt32: Operations + +external var WrapInt64: Operations + +external var TruncSFloat32ToInt32: Operations + +external var TruncSFloat32ToInt64: Operations + +external var TruncUFloat32ToInt32: Operations + +external var TruncUFloat32ToInt64: Operations + +external var TruncSFloat64ToInt32: Operations + +external var TruncSFloat64ToInt64: Operations + +external var TruncUFloat64ToInt32: Operations + +external var TruncUFloat64ToInt64: Operations + +external var TruncSatSFloat32ToInt32: Operations + +external var TruncSatSFloat32ToInt64: Operations + +external var TruncSatUFloat32ToInt32: Operations + +external var TruncSatUFloat32ToInt64: Operations + +external var TruncSatSFloat64ToInt32: Operations + +external var TruncSatSFloat64ToInt64: Operations + +external var TruncSatUFloat64ToInt32: Operations + +external var TruncSatUFloat64ToInt64: Operations + +external var ReinterpretFloat32: Operations + +external var ReinterpretFloat64: Operations + +external var ConvertSInt32ToFloat32: Operations + +external var ConvertSInt32ToFloat64: Operations + +external var ConvertUInt32ToFloat32: Operations + +external var ConvertUInt32ToFloat64: Operations + +external var ConvertSInt64ToFloat32: Operations + +external var ConvertSInt64ToFloat64: Operations + +external var ConvertUInt64ToFloat32: Operations + +external var ConvertUInt64ToFloat64: Operations + +external var PromoteFloat32: Operations + +external var DemoteFloat64: Operations + +external var ReinterpretInt32: Operations + +external var ReinterpretInt64: Operations + +external var ExtendS8Int32: Operations + +external var ExtendS16Int32: Operations + +external var ExtendS8Int64: Operations + +external var ExtendS16Int64: Operations + +external var ExtendS32Int64: Operations + +external var AddInt32: Operations + +external var SubInt32: Operations + +external var MulInt32: Operations + +external var DivSInt32: Operations + +external var DivUInt32: Operations + +external var RemSInt32: Operations + +external var RemUInt32: Operations + +external var AndInt32: Operations + +external var OrInt32: Operations + +external var XorInt32: Operations + +external var ShlInt32: Operations + +external var ShrUInt32: Operations + +external var ShrSInt32: Operations + +external var RotLInt32: Operations + +external var RotRInt32: Operations + +external var EqInt32: Operations + +external var NeInt32: Operations + +external var LtSInt32: Operations + +external var LtUInt32: Operations + +external var LeSInt32: Operations + +external var LeUInt32: Operations + +external var GtSInt32: Operations + +external var GtUInt32: Operations + +external var GeSInt32: Operations + +external var GeUInt32: Operations + +external var AddInt64: Operations + +external var SubInt64: Operations + +external var MulInt64: Operations + +external var DivSInt64: Operations + +external var DivUInt64: Operations + +external var RemSInt64: Operations + +external var RemUInt64: Operations + +external var AndInt64: Operations + +external var OrInt64: Operations + +external var XorInt64: Operations + +external var ShlInt64: Operations + +external var ShrUInt64: Operations + +external var ShrSInt64: Operations + +external var RotLInt64: Operations + +external var RotRInt64: Operations + +external var EqInt64: Operations + +external var NeInt64: Operations + +external var LtSInt64: Operations + +external var LtUInt64: Operations + +external var LeSInt64: Operations + +external var LeUInt64: Operations + +external var GtSInt64: Operations + +external var GtUInt64: Operations + +external var GeSInt64: Operations + +external var GeUInt64: Operations + +external var AddFloat32: Operations + +external var SubFloat32: Operations + +external var MulFloat32: Operations + +external var DivFloat32: Operations + +external var CopySignFloat32: Operations + +external var MinFloat32: Operations + +external var MaxFloat32: Operations + +external var EqFloat32: Operations + +external var NeFloat32: Operations + +external var LtFloat32: Operations + +external var LeFloat32: Operations + +external var GtFloat32: Operations + +external var GeFloat32: Operations + +external var AddFloat64: Operations + +external var SubFloat64: Operations + +external var MulFloat64: Operations + +external var DivFloat64: Operations + +external var CopySignFloat64: Operations + +external var MinFloat64: Operations + +external var MaxFloat64: Operations + +external var EqFloat64: Operations + +external var NeFloat64: Operations + +external var LtFloat64: Operations + +external var LeFloat64: Operations + +external var GtFloat64: Operations + +external var GeFloat64: Operations + +external var MemorySize: Operations + +external var MemoryGrow: Operations + +external var AtomicRMWAdd: Operations + +external var AtomicRMWSub: Operations + +external var AtomicRMWAnd: Operations + +external var AtomicRMWOr: Operations + +external var AtomicRMWXor: Operations + +external var AtomicRMWXchg: Operations + +external var SplatVecI8x16: Operations + +external var ExtractLaneSVecI8x16: Operations + +external var ExtractLaneUVecI8x16: Operations + +external var ReplaceLaneVecI8x16: Operations + +external var SplatVecI16x8: Operations + +external var ExtractLaneSVecI16x8: Operations + +external var ExtractLaneUVecI16x8: Operations + +external var ReplaceLaneVecI16x8: Operations + +external var SplatVecI32x4: Operations + +external var ExtractLaneVecI32x4: Operations + +external var ReplaceLaneVecI32x4: Operations + +external var SplatVecI64x2: Operations + +external var ExtractLaneVecI64x2: Operations + +external var ReplaceLaneVecI64x2: Operations + +external var SplatVecF32x4: Operations + +external var ExtractLaneVecF32x4: Operations + +external var ReplaceLaneVecF32x4: Operations + +external var SplatVecF64x2: Operations + +external var ExtractLaneVecF64x2: Operations + +external var ReplaceLaneVecF64x2: Operations + +external var EqVecI8x16: Operations + +external var NeVecI8x16: Operations + +external var LtSVecI8x16: Operations + +external var LtUVecI8x16: Operations + +external var GtSVecI8x16: Operations + +external var GtUVecI8x16: Operations + +external var LeSVecI8x16: Operations + +external var LeUVecI8x16: Operations + +external var GeSVecI8x16: Operations + +external var GeUVecI8x16: Operations + +external var EqVecI16x8: Operations + +external var NeVecI16x8: Operations + +external var LtSVecI16x8: Operations + +external var LtUVecI16x8: Operations + +external var GtSVecI16x8: Operations + +external var GtUVecI16x8: Operations + +external var LeSVecI16x8: Operations + +external var LeUVecI16x8: Operations + +external var GeSVecI16x8: Operations + +external var GeUVecI16x8: Operations + +external var EqVecI32x4: Operations + +external var NeVecI32x4: Operations + +external var LtSVecI32x4: Operations + +external var LtUVecI32x4: Operations + +external var GtSVecI32x4: Operations + +external var GtUVecI32x4: Operations + +external var LeSVecI32x4: Operations + +external var LeUVecI32x4: Operations + +external var GeSVecI32x4: Operations + +external var GeUVecI32x4: Operations + +external var EqVecF32x4: Operations + +external var NeVecF32x4: Operations + +external var LtVecF32x4: Operations + +external var GtVecF32x4: Operations + +external var LeVecF32x4: Operations + +external var GeVecF32x4: Operations + +external var EqVecF64x2: Operations + +external var NeVecF64x2: Operations + +external var LtVecF64x2: Operations + +external var GtVecF64x2: Operations + +external var LeVecF64x2: Operations + +external var GeVecF64x2: Operations + +external var NotVec128: Operations + +external var AndVec128: Operations + +external var OrVec128: Operations + +external var XorVec128: Operations + +external var AndNotVec128: Operations + +external var BitselectVec128: Operations + +external var NegVecI8x16: Operations + +external var AnyTrueVecI8x16: Operations + +external var AllTrueVecI8x16: Operations + +external var ShlVecI8x16: Operations + +external var ShrSVecI8x16: Operations + +external var ShrUVecI8x16: Operations + +external var AddVecI8x16: Operations + +external var AddSatSVecI8x16: Operations + +external var AddSatUVecI8x16: Operations + +external var SubVecI8x16: Operations + +external var SubSatSVecI8x16: Operations + +external var SubSatUVecI8x16: Operations + +external var MulVecI8x16: Operations + +external var MinSVecI8x16: Operations + +external var MinUVecI8x16: Operations + +external var MaxSVecI8x16: Operations + +external var MaxUVecI8x16: Operations + +external var NegVecI16x8: Operations + +external var AnyTrueVecI16x8: Operations + +external var AllTrueVecI16x8: Operations + +external var ShlVecI16x8: Operations + +external var ShrSVecI16x8: Operations + +external var ShrUVecI16x8: Operations + +external var AddVecI16x8: Operations + +external var AddSatSVecI16x8: Operations + +external var AddSatUVecI16x8: Operations + +external var SubVecI16x8: Operations + +external var SubSatSVecI16x8: Operations + +external var SubSatUVecI16x8: Operations + +external var MulVecI16x8: Operations + +external var MinSVecI16x8: Operations + +external var MinUVecI16x8: Operations + +external var MaxSVecI16x8: Operations + +external var MaxUVecI16x8: Operations + +external var DotSVecI16x8ToVecI32x4: Operations + +external var NegVecI32x4: Operations + +external var AnyTrueVecI32x4: Operations + +external var AllTrueVecI32x4: Operations + +external var ShlVecI32x4: Operations + +external var ShrSVecI32x4: Operations + +external var ShrUVecI32x4: Operations + +external var AddVecI32x4: Operations + +external var SubVecI32x4: Operations + +external var MulVecI32x4: Operations + +external var MinSVecI32x4: Operations + +external var MinUVecI32x4: Operations + +external var MaxSVecI32x4: Operations + +external var MaxUVecI32x4: Operations + +external var NegVecI64x2: Operations + +external var AnyTrueVecI64x2: Operations + +external var AllTrueVecI64x2: Operations + +external var ShlVecI64x2: Operations + +external var ShrSVecI64x2: Operations + +external var ShrUVecI64x2: Operations + +external var AddVecI64x2: Operations + +external var SubVecI64x2: Operations + +external var AbsVecF32x4: Operations + +external var NegVecF32x4: Operations + +external var SqrtVecF32x4: Operations + +external var QFMAVecF32x4: Operations + +external var QFMSVecF32x4: Operations + +external var AddVecF32x4: Operations + +external var SubVecF32x4: Operations + +external var MulVecF32x4: Operations + +external var DivVecF32x4: Operations + +external var MinVecF32x4: Operations + +external var MaxVecF32x4: Operations + +external var AbsVecF64x2: Operations + +external var NegVecF64x2: Operations + +external var SqrtVecF64x2: Operations + +external var QFMAVecF64x2: Operations + +external var QFMSVecF64x2: Operations + +external var AddVecF64x2: Operations + +external var SubVecF64x2: Operations + +external var MulVecF64x2: Operations + +external var DivVecF64x2: Operations + +external var MinVecF64x2: Operations + +external var MaxVecF64x2: Operations + +external var TruncSatSVecF32x4ToVecI32x4: Operations + +external var TruncSatUVecF32x4ToVecI32x4: Operations + +external var TruncSatSVecF64x2ToVecI64x2: Operations + +external var TruncSatUVecF64x2ToVecI64x2: Operations + +external var ConvertSVecI32x4ToVecF32x4: Operations + +external var ConvertUVecI32x4ToVecF32x4: Operations + +external var ConvertSVecI64x2ToVecF64x2: Operations + +external var ConvertUVecI64x2ToVecF64x2: Operations + +external var LoadSplatVec8x16: Operations + +external var LoadSplatVec16x8: Operations + +external var LoadSplatVec32x4: Operations + +external var LoadSplatVec64x2: Operations + +external var LoadExtSVec8x8ToVecI16x8: Operations + +external var LoadExtUVec8x8ToVecI16x8: Operations + +external var LoadExtSVec16x4ToVecI32x4: Operations + +external var LoadExtUVec16x4ToVecI32x4: Operations + +external var LoadExtSVec32x2ToVecI64x2: Operations + +external var LoadExtUVec32x2ToVecI64x2: Operations + +external var NarrowSVecI16x8ToVecI8x16: Operations + +external var NarrowUVecI16x8ToVecI8x16: Operations + +external var NarrowSVecI32x4ToVecI16x8: Operations + +external var NarrowUVecI32x4ToVecI16x8: Operations + +external var WidenLowSVecI8x16ToVecI16x8: Operations + +external var WidenHighSVecI8x16ToVecI16x8: Operations + +external var WidenLowUVecI8x16ToVecI16x8: Operations + +external var WidenHighUVecI8x16ToVecI16x8: Operations + +external var WidenLowSVecI16x8ToVecI32x4: Operations + +external var WidenHighSVecI16x8ToVecI32x4: Operations + +external var WidenLowUVecI16x8ToVecI32x4: Operations + +external var WidenHighUVecI16x8ToVecI32x4: Operations + +external var SwizzleVec8x16: Operations + +external interface `T$2` { + fun get(index: Number, type: Type): ExpressionRef + fun set(index: Number, value: ExpressionRef): ExpressionRef + fun tee(index: Number, value: ExpressionRef, type: Type): ExpressionRef +} + +external interface `T$3` { + fun get(name: String, type: Type): ExpressionRef + fun set(name: String, value: ExpressionRef): ExpressionRef +} + +external interface `T$4` { + fun size(): ExpressionRef + fun grow(value: ExpressionRef): ExpressionRef + fun init(segment: Number, dest: ExpressionRef, offset: ExpressionRef, size: ExpressionRef): ExpressionRef + fun copy(dest: ExpressionRef, source: ExpressionRef, size: ExpressionRef): ExpressionRef + fun fill(dest: ExpressionRef, value: ExpressionRef, size: ExpressionRef): ExpressionRef +} + +external interface `T$5` { + fun drop(segment: Number): ExpressionRef +} + +external interface `T$6` { + fun f32(value: ExpressionRef): ExpressionRef + fun f64(value: ExpressionRef): ExpressionRef +} + +external interface `T$7` { + fun add(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun sub(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun and(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun or(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun xor(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun xchg(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun cmpxchg(offset: Number, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef): ExpressionRef +} + +external interface `T$8` { + fun load(offset: Number, ptr: ExpressionRef): ExpressionRef + fun load8_u(offset: Number, ptr: ExpressionRef): ExpressionRef + fun load16_u(offset: Number, ptr: ExpressionRef): ExpressionRef + fun store(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store8(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store16(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + var rmw: `T$7` + var rmw8_u: `T$7` + var rmw16_u: `T$7` + fun wait(ptr: ExpressionRef, expected: ExpressionRef, timeout: ExpressionRef): ExpressionRef +} + +external interface `T$9` { + fun load(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load8_s(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load8_u(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load16_s(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load16_u(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun store(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store8(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store16(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun const(value: Number): ExpressionRef + fun clz(value: ExpressionRef): ExpressionRef + fun ctz(value: ExpressionRef): ExpressionRef + fun popcnt(value: ExpressionRef): ExpressionRef + fun eqz(value: ExpressionRef): ExpressionRef + var trunc_s: `T$6` + var trunc_u: `T$6` + var trunc_s_sat: `T$6` + var trunc_u_sat: `T$6` + fun reinterpret(value: ExpressionRef): ExpressionRef + fun extend8_s(value: ExpressionRef): ExpressionRef + fun extend16_s(value: ExpressionRef): ExpressionRef + fun wrap(value: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun div_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun div_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun rem_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun rem_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun and(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun or(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun xor(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun shl(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun shr_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun shr_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun rotl(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun rotr(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + var atomic: `T$8` + fun pop(): ExpressionRef +} + +external interface `T$10` { + fun load(offset: Number, ptr: ExpressionRef): ExpressionRef + fun load8_u(offset: Number, ptr: ExpressionRef): ExpressionRef + fun load16_u(offset: Number, ptr: ExpressionRef): ExpressionRef + fun load32_u(offset: Number, ptr: ExpressionRef): ExpressionRef + fun store(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store8(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store16(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store32(offset: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + var rmw: `T$7` + var rmw8_u: `T$7` + var rmw16_u: `T$7` + var rmw32_u: `T$7` + fun wait(ptr: ExpressionRef, expected: ExpressionRef, timeout: ExpressionRef): ExpressionRef +} + +external interface `T$11` { + fun load(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load8_s(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load8_u(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load16_s(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load16_u(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load32_s(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load32_u(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun store(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store8(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store16(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun store32(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun const(low: Number, high: Number): ExpressionRef + fun clz(value: ExpressionRef): ExpressionRef + fun ctz(value: ExpressionRef): ExpressionRef + fun popcnt(value: ExpressionRef): ExpressionRef + fun eqz(value: ExpressionRef): ExpressionRef + var trunc_s: `T$6` + var trunc_u: `T$6` + var trunc_s_sat: `T$6` + var trunc_u_sat: `T$6` + fun reinterpret(value: ExpressionRef): ExpressionRef + fun extend8_s(value: ExpressionRef): ExpressionRef + fun extend16_s(value: ExpressionRef): ExpressionRef + fun extend32_s(value: ExpressionRef): ExpressionRef + fun extend_s(value: ExpressionRef): ExpressionRef + fun extend_u(value: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun div_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun div_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun rem_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun rem_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun and(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun or(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun xor(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun shl(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun shr_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun shr_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun rotl(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun rotr(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + var atomic: `T$10` + fun pop(): ExpressionRef +} + +external interface `T$12` { + fun load(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun store(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun const(value: Number): ExpressionRef + fun const_bits(value: Number): ExpressionRef + fun neg(value: ExpressionRef): ExpressionRef + fun abs(value: ExpressionRef): ExpressionRef + fun ceil(value: ExpressionRef): ExpressionRef + fun floor(value: ExpressionRef): ExpressionRef + fun trunc(value: ExpressionRef): ExpressionRef + fun nearest(value: ExpressionRef): ExpressionRef + fun sqrt(value: ExpressionRef): ExpressionRef + fun reinterpret(value: ExpressionRef): ExpressionRef + var convert_s: `T$6` + var convert_u: `T$6` + fun demote(value: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun div(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun copysign(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun min(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun max(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun pop(): ExpressionRef +} + +external interface `T$13` { + fun load(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun store(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun const(value: Number): ExpressionRef + fun const_bits(low: Number, high: Number): ExpressionRef + fun neg(value: ExpressionRef): ExpressionRef + fun abs(value: ExpressionRef): ExpressionRef + fun ceil(value: ExpressionRef): ExpressionRef + fun floor(value: ExpressionRef): ExpressionRef + fun trunc(value: ExpressionRef): ExpressionRef + fun nearest(value: ExpressionRef): ExpressionRef + fun sqrt(value: ExpressionRef): ExpressionRef + fun reinterpret(value: ExpressionRef): ExpressionRef + var convert_s: `T$6` + var convert_u: `T$6` + fun promote(value: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun div(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun copysign(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun min(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun max(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun pop(): ExpressionRef +} + +external interface `T$14` { + fun load(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun store(offset: Number, align: Number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef + fun const(value: Number): ExpressionRef + fun not(value: ExpressionRef): ExpressionRef + fun and(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun or(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun xor(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun andnot(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun bitselect(left: ExpressionRef, right: ExpressionRef, cond: ExpressionRef): ExpressionRef + fun pop(): ExpressionRef +} + +external interface `T$15` { + fun splat(value: ExpressionRef): ExpressionRef + fun extract_lane_s(vec: ExpressionRef, index: ExpressionRef): ExpressionRef + fun extract_lane_u(vec: ExpressionRef, index: ExpressionRef): ExpressionRef + fun replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef + fun eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun neg(value: ExpressionRef): ExpressionRef + fun any_true(value: ExpressionRef): ExpressionRef + fun all_true(value: ExpressionRef): ExpressionRef + fun shl(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun shr_s(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun shr_u(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun add_saturate_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun add_saturate_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub_saturate_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub_saturate_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun min_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun min_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun max_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun max_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun avgr_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun narrow_i16x8_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun narrow_i16x8_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef +} + +external interface `T$16` { + fun splat(value: ExpressionRef): ExpressionRef + fun extract_lane_s(vec: ExpressionRef, index: ExpressionRef): ExpressionRef + fun extract_lane_u(vec: ExpressionRef, index: ExpressionRef): ExpressionRef + fun replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef + fun eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun neg(value: ExpressionRef): ExpressionRef + fun any_true(value: ExpressionRef): ExpressionRef + fun all_true(value: ExpressionRef): ExpressionRef + fun shl(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun shr_s(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun shr_u(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun add_saturate_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun add_saturate_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub_saturate_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub_saturate_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun min_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun min_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun max_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun max_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun avgr_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun narrow_i32x4_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun narrow_i32x4_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun widen_low_i8x16_s(value: ExpressionRef): ExpressionRef + fun widen_high_i8x16_s(value: ExpressionRef): ExpressionRef + fun widen_low_i8x16_u(value: ExpressionRef): ExpressionRef + fun widen_high_i8x16_u(value: ExpressionRef): ExpressionRef + fun load8x8_s(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load8x8_u(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef +} + +external interface `T$17` { + fun splat(value: ExpressionRef): ExpressionRef + fun extract_lane(vec: ExpressionRef, index: ExpressionRef): ExpressionRef + fun replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef + fun eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun neg(value: ExpressionRef): ExpressionRef + fun any_true(value: ExpressionRef): ExpressionRef + fun all_true(value: ExpressionRef): ExpressionRef + fun shl(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun shr_s(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun shr_u(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun trunc_sat_f32x4_s(value: ExpressionRef): ExpressionRef + fun trunc_sat_f32x4_u(value: ExpressionRef): ExpressionRef + fun widen_low_i16x8_s(value: ExpressionRef): ExpressionRef + fun widen_high_i16x8_s(value: ExpressionRef): ExpressionRef + fun widen_low_i16x8_u(value: ExpressionRef): ExpressionRef + fun widen_high_i16x8_u(value: ExpressionRef): ExpressionRef + fun load16x4_s(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load16x4_u(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef +} + +external interface `T$18` { + fun splat(value: ExpressionRef): ExpressionRef + fun extract_lane(vec: ExpressionRef, index: ExpressionRef): ExpressionRef + fun replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef + fun neg(value: ExpressionRef): ExpressionRef + fun any_true(value: ExpressionRef): ExpressionRef + fun all_true(value: ExpressionRef): ExpressionRef + fun shl(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun shr_s(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun shr_u(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun trunc_sat_f64x2_s(value: ExpressionRef): ExpressionRef + fun trunc_sat_f64x2_u(value: ExpressionRef): ExpressionRef + fun load32x2_s(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef + fun load32x2_u(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef +} + +external interface `T$19` { + fun splat(value: ExpressionRef): ExpressionRef + fun extract_lane(vec: ExpressionRef, index: ExpressionRef): ExpressionRef + fun replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef + fun eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun lt(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun gt(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun le(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun ge(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun abs(value: ExpressionRef): ExpressionRef + fun neg(value: ExpressionRef): ExpressionRef + fun sqrt(value: ExpressionRef): ExpressionRef + fun qfma(a: ExpressionRef, b: ExpressionRef, c: ExpressionRef): ExpressionRef + fun qfms(a: ExpressionRef, b: ExpressionRef, c: ExpressionRef): ExpressionRef + fun add(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun div(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun min(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun max(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun convert_i32x4_s(value: ExpressionRef): ExpressionRef + fun convert_i32x4_u(value: ExpressionRef): ExpressionRef +} + +external interface `T$20` { + fun shuffle(left: ExpressionRef, right: ExpressionRef, mask: Array): ExpressionRef + fun swizzle(left: ExpressionRef, right: ExpressionRef): ExpressionRef + fun load_splat(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef +} + +external interface `T$21` { + fun load_splat(offset: Number, align: Number, ptr: ExpressionRef): ExpressionRef +} + +external interface `T$22` { + fun pop(): ExpressionRef +} + +external interface `T$23` { + fun `null`(): ExpressionRef + fun is_null(value: ExpressionRef): ExpressionRef + fun func(name: String): ExpressionRef +} + +external interface `T$24` { + fun notify(ptr: ExpressionRef, notifyCount: ExpressionRef): ExpressionRef + fun fence(): ExpressionRef +} + +external interface `T$25` { + fun make(elements: Array): ExpressionRef + fun extract(tuple: ExpressionRef, index: Number): ExpressionRef +} + +external interface `T$26` { + var imported: Boolean + var segments: Array +} + +external interface `T$27` { + var binary: Uint8Array + var sourceMap: String? +} + +open external class Module { + open var ptr: Number + open fun block(label: String, children: Array, resultType: Type = definedExternally): ExpressionRef + open fun `if`( + condition: ExpressionRef, + ifTrue: ExpressionRef, + ifFalse: ExpressionRef = definedExternally + ): ExpressionRef + + open fun loop(label: String, body: ExpressionRef): ExpressionRef + open fun br( + label: String, + condition: ExpressionRef = definedExternally, + value: ExpressionRef = definedExternally + ): ExpressionRef + + open fun br_if( + label: String, + condition: ExpressionRef = definedExternally, + value: ExpressionRef = definedExternally + ): ExpressionRef + + open fun switch( + labels: Array, + defaultLabel: String, + condition: ExpressionRef, + value: ExpressionRef = definedExternally + ): ExpressionRef + + open fun call(name: String, operands: Array, returnType: Type): ExpressionRef + open fun return_call(name: String, operands: Array, returnType: Type): ExpressionRef + open fun call_indirect( + target: ExpressionRef, + operands: Array, + params: Type, + results: Type + ): ExpressionRef + + open fun return_call_indirect( + target: ExpressionRef, + operands: Array, + params: Type, + results: Type + ): ExpressionRef + + open var local: `T$2` + open var global: `T$3` + open var memory: `T$4` + open var data: `T$5` + open var i32: `T$9` + open var i64: `T$11` + open var f32: `T$12` + open var f64: `T$13` + open var v128: `T$14` + open var i8x16: `T$15` + open var i16x8: `T$16` + open var i32x4: `T$17` + open var i64x2: `T$18` + open var f32x4: `T$19` + open var f64x2: `T$19` + open var v8x16: `T$20` + open var v16x8: `T$21` + open var v32x4: `T$21` + open var v64x2: `T$21` + open var funcref: `T$22` + open var anyref: `T$22` + open var nullref: `T$22` + open var exnref: `T$22` + open var ref: `T$23` + open var atomic: `T$24` + open var tuple: `T$25` + open fun `try`(body: ExpressionRef, catchBody: ExpressionRef): ExpressionRef + open fun `throw`(event: String, operands: Array): ExpressionRef + open fun rethrow(exnref: ExpressionRef): ExpressionRef + open fun br_on_exn(label: String, event: String, exnref: ExpressionRef): ExpressionRef + open fun push(value: ExpressionRef): ExpressionRef + open fun select( + condition: ExpressionRef, + ifTrue: ExpressionRef, + ifFalse: ExpressionRef, + type: Type = definedExternally + ): ExpressionRef + + open fun drop(value: ExpressionRef): ExpressionRef + open fun `return`(value: ExpressionRef = definedExternally): ExpressionRef + open fun host(op: Operations, name: String, operands: Array): ExpressionRef + open fun nop(): ExpressionRef + open fun unreachable(): ExpressionRef + open fun addFunction(name: String, params: Type, results: Type, vars: Array, body: ExpressionRef): FunctionRef + open fun getFunction(name: String): FunctionRef + open fun removeFunction(name: String) + open fun getNumFunctions(): Number + open fun getFunctionByIndex(index: Number): FunctionRef + open fun addGlobal(name: String, type: Type, mutable: Boolean, init: ExpressionRef): GlobalRef + open fun getGlobal(name: String): GlobalRef + open fun removeGlobal(name: String) + open fun addEvent(name: String, attribute: Number, params: Type, results: Type): EventRef + open fun getEvent(name: String): EventRef + open fun removeEvent(name: String) + open fun addFunctionImport( + internalName: String, + externalModuleName: String, + externalBaseName: String, + params: Type, + results: Type + ) + + open fun addTableImport(internalName: String, externalModuleName: String, externalBaseName: String) + open fun addMemoryImport(internalName: String, externalModuleName: String, externalBaseName: String) + open fun addGlobalImport( + internalName: String, + externalModuleName: String, + externalBaseName: String, + globalType: Type + ) + + open fun addEventImport( + internalName: String, + externalModuleName: String, + externalBaseName: String, + attribute: Number, + params: Type, + results: Type + ) + + open fun addFunctionExport(internalName: String, externalName: String): ExportRef + open fun addTableExport(internalName: String, externalName: String): ExportRef + open fun addMemoryExport(internalName: String, externalName: String): ExportRef + open fun addGlobalExport(internalName: String, externalName: String): ExportRef + open fun removeExport(externalName: String) + open fun getNumExports(): Number + open fun getExportByIndex(index: Number): ExportRef + open fun setFunctionTable( + initial: Number, + maximum: Number, + funcNames: Array, + offset: ExpressionRef = definedExternally + ) + + open fun getFunctionTable(): `T$26` + open fun setMemory( + initial: Number, + maximum: Number, + exportName: String? = definedExternally, + segments: Array? = definedExternally, + flags: Array? = definedExternally, + shared: Boolean = definedExternally + ) + + open fun getNumMemorySegments(): Number + open fun getMemorySegmentInfoByIndex(index: Number): MemorySegmentInfo + open fun setStart(start: FunctionRef) + open fun getFeatures(): Features + open fun setFeatures(features: Features) + open fun addCustomSection(name: String, contents: Uint8Array) + open fun emitText(): String + open fun emitStackIR(optimize: Boolean = definedExternally): String + open fun emitAsmjs(): String + open fun validate(): Number + open fun optimize() + open fun optimizeFunction(func: String) + open fun optimizeFunction(func: FunctionRef) + open fun runPasses(passes: Array) + open fun runPassesOnFunction(func: String, passes: Array) + open fun runPassesOnFunction(func: FunctionRef, passes: Array) + open fun autoDrop() + open fun dispose() + open fun emitBinary(): Uint8Array + open fun emitBinary(sourceMapUrl: String?): `T$27` + open fun interpret() + open fun addDebugInfoFileName(filename: String): Number + open fun getDebugInfoFileName(index: Number): String? + open fun setDebugLocation( + func: FunctionRef, + expr: ExpressionRef, + fileIndex: Number, + lineNumber: Number, + columnNumber: Number + ) + + open fun copyExpression(expr: ExpressionRef): ExpressionRef +} + +external interface MemorySegment { + var offset: ExpressionRef + var data: Uint8Array + var passive: Boolean? + get() = definedExternally + set(value) = definedExternally +} + +external interface TableElement { + var offset: ExpressionRef + var names: Array +} + +external fun wrapModule(ptr: Number): Module + +external fun getExpressionId(expression: ExpressionRef): Number + +external fun getExpressionType(expression: ExpressionRef): Type + +external fun getExpressionInfo(expression: ExpressionRef): ExpressionInfo + +external interface MemorySegmentInfo { + var offset: ExpressionRef + var data: Uint8Array + var passive: Boolean +} + +external interface ExpressionInfo { + var id: ExpressionIds + var type: Type +} + +external interface BlockInfo : ExpressionInfo { + var name: String + var children: Array +} + +external interface IfInfo : ExpressionInfo { + var condition: ExpressionRef + var ifTrue: ExpressionRef + var ifFalse: ExpressionRef +} + +external interface LoopInfo : ExpressionInfo { + var name: String + var body: ExpressionRef +} + +external interface BreakInfo : ExpressionInfo { + var name: String + var condition: ExpressionRef + var value: ExpressionRef +} + +external interface SwitchInfo : ExpressionInfo { + var names: Array + var defaultName: String? + var condition: ExpressionRef + var value: ExpressionRef +} + +external interface CallInfo : ExpressionInfo { + var isReturn: Boolean + var target: String + var operands: Array +} + +external interface CallIndirectInfo : ExpressionInfo { + var isReturn: Boolean + var target: ExpressionRef + var operands: Array +} + +external interface LocalGetInfo : ExpressionInfo { + var index: Number +} + +external interface LocalSetInfo : ExpressionInfo { + var isTee: Boolean + var index: Number + var value: ExpressionRef +} + +external interface GlobalGetInfo : ExpressionInfo { + var name: String +} + +external interface GlobalSetInfo : ExpressionInfo { + var name: String + var value: ExpressionRef +} + +external interface LoadInfo : ExpressionInfo { + var isAtomic: Boolean + var isSigned: Boolean + var offset: Number + var bytes: Number + var align: Number + var ptr: ExpressionRef +} + +external interface StoreInfo : ExpressionInfo { + var isAtomic: Boolean + var offset: Number + var bytes: Number + var align: Number + var ptr: ExpressionRef + var value: ExpressionRef +} + +external interface `T$28` { + var low: Number + var high: Number +} + +external interface ConstInfo : ExpressionInfo { + var value: dynamic /* Number | `T$28` */ + get() = definedExternally + set(value) = definedExternally +} + +external interface UnaryInfo : ExpressionInfo { + var op: Operations + var value: ExpressionRef +} + +external interface BinaryInfo : ExpressionInfo { + var op: Operations + var left: ExpressionRef + var right: ExpressionRef +} + +external interface SelectInfo : ExpressionInfo { + var ifTrue: ExpressionRef + var ifFalse: ExpressionRef + var condition: ExpressionRef +} + +external interface DropInfo : ExpressionInfo { + var value: ExpressionRef +} + +external interface ReturnInfo : ExpressionInfo { + var value: ExpressionRef +} + +external interface NopInfo : ExpressionInfo + +external interface UnreachableInfo : ExpressionInfo + +external interface HostInfo : ExpressionInfo { + var op: Operations + var nameOperand: String? + var operands: Array +} + +external interface AtomicRMWInfo : ExpressionInfo { + var op: Operations + var bytes: Number + var offset: Number + var ptr: ExpressionRef + var value: ExpressionRef +} + +external interface AtomicCmpxchgInfo : ExpressionInfo { + var bytes: Number + var offset: Number + var ptr: ExpressionRef + var expected: ExpressionRef + var replacement: ExpressionRef +} + +external interface AtomicWaitInfo : ExpressionInfo { + var ptr: ExpressionRef + var expected: ExpressionRef + var timeout: ExpressionRef + var expectedType: Type +} + +external interface AtomicNotifyInfo : ExpressionInfo { + var ptr: ExpressionRef + var notifyCount: ExpressionRef +} + +external interface AtomicFenceInfo : ExpressionInfo { + var order: Number +} + +external interface SIMDExtractInfo : ExpressionInfo { + var op: Operations + var vec: ExpressionRef + var index: ExpressionRef +} + +external interface SIMDReplaceInfo : ExpressionInfo { + var op: Operations + var vec: ExpressionRef + var index: ExpressionRef + var value: ExpressionRef +} + +external interface SIMDShuffleInfo : ExpressionInfo { + var left: ExpressionRef + var right: ExpressionRef + var mask: Array +} + +external interface SIMDTernaryInfo : ExpressionInfo { + var op: Operations + var a: ExpressionRef + var b: ExpressionRef + var c: ExpressionRef +} + +external interface SIMDShiftInfo : ExpressionInfo { + var op: Operations + var vec: ExpressionRef + var shift: ExpressionRef +} + +external interface SIMDLoadInfo : ExpressionInfo { + var op: Operations + var offset: Number + var align: Number + var ptr: ExpressionRef +} + +external interface MemoryInitInfo : ExpressionInfo { + var segment: Number + var dest: ExpressionRef + var offset: ExpressionRef + var size: ExpressionRef +} + +external interface MemoryDropInfo : ExpressionInfo { + var segment: Number +} + +external interface MemoryCopyInfo : ExpressionInfo { + var dest: ExpressionRef + var source: ExpressionRef + var size: ExpressionRef +} + +external interface MemoryFillInfo : ExpressionInfo { + var dest: ExpressionRef + var value: ExpressionRef + var size: ExpressionRef +} + +external interface RefNullInfo : ExpressionInfo + +external interface RefIsNullInfo : ExpressionInfo { + var value: ExpressionRef +} + +external interface RefFuncInfo : ExpressionInfo { + var func: String +} + +external interface TryInfo : ExpressionInfo { + var body: ExpressionRef + var catchBody: ExpressionRef +} + +external interface ThrowInfo : ExpressionInfo { + var event: String + var operands: Array +} + +external interface RethrowInfo : ExpressionInfo { + var exnref: ExpressionRef +} + +external interface BrOnExnInfo : ExpressionInfo { + var name: String + var event: String + var exnref: ExpressionRef +} + +external interface PopInfo : ExpressionInfo + +external interface PushInfo : ExpressionInfo { + var value: ExpressionRef +} + +external fun getFunctionInfo(func: FunctionRef): FunctionInfo + +external interface FunctionInfo { + var name: String + var module: String? + var base: String? + var params: Type + var results: Type + var vars: Array + var body: ExpressionRef +} + +external fun getGlobalInfo(global: GlobalRef): GlobalInfo + +external interface GlobalInfo { + var name: String + var module: String? + var base: String? + var type: Type + var mutable: Boolean + var init: ExpressionRef +} + +external fun getExportInfo(export_: ExportRef): ExportInfo + +external interface ExportInfo { + var kind: ExternalKinds + var name: String + var value: String +} + +external fun getEventInfo(event: EventRef): EventInfo + +external interface EventInfo { + var name: String + var module: String? + var base: String? + var attribute: Number + var params: Type + var results: Type +} + +external fun getSideEffects(expr: ExpressionRef, features: Features): SideEffects + +external enum class SideEffects { + None, + Branches, + Calls, + ReadsLocal, + WritesLocal, + ReadsGlobal, + WritesGlobal, + ReadsMemory, + WritesMemory, + ImplicitTrap, + IsAtomic, + Throws, + Any +} + +external fun emitText(expression: ExpressionRef): String + +external fun emitText(expression: Module): String + +external fun readBinary(data: Uint8Array): Module + +external fun parseText(text: String): Module + +external fun getOptimizeLevel(): Number + +external fun setOptimizeLevel(level: Number): Number + +external fun getShrinkLevel(): Number + +external fun setShrinkLevel(level: Number): Number + +external fun getDebugInfo(): Boolean + +external fun setDebugInfo(on: Boolean) + +external fun getLowMemoryUnused(): Boolean + +external fun setLowMemoryUnused(on: Boolean) + +external fun getPassArgument(key: String): String? + +external fun setPassArgument(key: String, value: String?) + +external fun clearPassArguments() + +external fun getAlwaysInlineMaxSize(): Number + +external fun setAlwaysInlineMaxSize(size: Number) + +external fun getFlexibleInlineMaxSize(): Number + +external fun setFlexibleInlineMaxSize(size: Number) + +external fun getOneCallerInlineMaxSize(): Number + +external fun setOneCallerInlineMaxSize(size: Number) + +external fun exit(status: Number) + +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 + open fun addBranchForSwitch( + from: RelooperBlockRef, + to: RelooperBlockRef, + indexes: Array, + code: ExpressionRef + ) + + open fun renderAndDispose(entry: RelooperBlockRef, labelHelper: Number): ExpressionRef +} diff --git a/kmath-ast/src/jsMain/kotlin/index.binaryen.typealiases.kt b/kmath-ast/src/jsMain/kotlin/index.binaryen.typealiases.kt new file mode 100644 index 000000000..fa110cf73 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/index.binaryen.typealiases.kt @@ -0,0 +1,11 @@ +@file:Suppress("PackageDirectoryMismatch", "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "KDocMissingDocumentation") + +package binaryen + +typealias Type = Number +typealias ExpressionRef = Number +typealias FunctionRef = Number +typealias GlobalRef = Number +typealias ExportRef = Number +typealias EventRef = Number +typealias RelooperBlockRef = Number diff --git a/kmath-ast/src/jsMain/kotlin/index.d.ts b/kmath-ast/src/jsMain/kotlin/index.d.ts new file mode 100644 index 000000000..77117fffb --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/index.d.ts @@ -0,0 +1,1787 @@ +declare module binaryen { + + const isReady: boolean; + const ready: Promise; + + type Type = number; + + const none: Type; + const i32: Type; + const i64: Type; + const f32: Type; + const f64: Type; + const v128: Type; + const funcref: Type; + const anyref: Type; + const nullref: Type; + const exnref: Type; + const unreachable: Type; + const auto: Type; + + function createType(types: Type[]): Type; + function expandType(type: Type): Type[]; + + const enum ExpressionIds { + Invalid, + Block, + If, + Loop, + Break, + Switch, + Call, + CallIndirect, + LocalGet, + LocalSet, + GlobalGet, + GlobalSet, + Load, + Store, + Const, + Unary, + Binary, + Select, + Drop, + Return, + Host, + Nop, + Unreachable, + AtomicCmpxchg, + AtomicRMW, + AtomicWait, + AtomicNotify, + AtomicFence, + SIMDExtract, + SIMDReplace, + SIMDShuffle, + SIMDTernary, + SIMDShift, + SIMDLoad, + MemoryInit, + DataDrop, + MemoryCopy, + MemoryFill, + RefNull, + RefIsNull, + RefFunc, + Try, + Throw, + Rethrow, + BrOnExn, + TupleMake, + TupleExtract, + Push, + Pop + } + + const InvalidId: ExpressionIds; + const BlockId: ExpressionIds; + const IfId: ExpressionIds; + const LoopId: ExpressionIds; + const BreakId: ExpressionIds; + const SwitchId: ExpressionIds; + const CallId: ExpressionIds; + const CallIndirectId: ExpressionIds; + const LocalGetId: ExpressionIds; + const LocalSetId: ExpressionIds; + const GlobalGetId: ExpressionIds; + const GlobalSetId: ExpressionIds; + const LoadId: ExpressionIds; + const StoreId: ExpressionIds; + const ConstId: ExpressionIds; + const UnaryId: ExpressionIds; + const BinaryId: ExpressionIds; + const SelectId: ExpressionIds; + const DropId: ExpressionIds; + const ReturnId: ExpressionIds; + const HostId: ExpressionIds; + const NopId: ExpressionIds; + const UnreachableId: ExpressionIds; + const AtomicCmpxchgId: ExpressionIds; + const AtomicRMWId: ExpressionIds; + const AtomicWaitId: ExpressionIds; + const AtomicNotifyId: ExpressionIds; + const AtomicFenceId: ExpressionIds; + const SIMDExtractId: ExpressionIds; + const SIMDReplaceId: ExpressionIds; + const SIMDShuffleId: ExpressionIds; + const SIMDTernaryId: ExpressionIds; + const SIMDShiftId: ExpressionIds; + const SIMDLoadId: ExpressionIds; + const MemoryInitId: ExpressionIds; + const DataDropId: ExpressionIds; + const MemoryCopyId: ExpressionIds; + const MemoryFillId: ExpressionIds; + const RefNullId: ExpressionIds; + const RefIsNullId: ExpressionIds; + const RefFuncId: ExpressionIds; + const TryId: ExpressionIds; + const ThrowId: ExpressionIds; + const RethrowId: ExpressionIds; + const BrOnExnId: ExpressionIds; + const TupleMakeId: ExpressionIds; + const TupleExtractId: ExpressionIds; + const PushId: ExpressionIds; + const PopId: ExpressionIds; + + const enum ExternalKinds { + Function, + Table, + Memory, + Global, + Event + } + + const ExternalFunction: ExternalKinds; + const ExternalTable: ExternalKinds; + const ExternalMemory: ExternalKinds; + const ExternalGlobal: ExternalKinds; + const ExternalEvent: ExternalKinds; + + enum Features { + MVP, + Atomics, + MutableGlobals, + TruncSat, + SIMD, + BulkMemory, + SignExt, + ExceptionHandling, + TailCall, + ReferenceTypes, + Multivalue, + GC, + Memory64, + All + } + + const enum Operations { + ClzInt32, + CtzInt32, + PopcntInt32, + NegFloat32, + AbsFloat32, + CeilFloat32, + FloorFloat32, + TruncFloat32, + NearestFloat32, + SqrtFloat32, + EqZInt32, + ClzInt64, + CtzInt64, + PopcntInt64, + NegFloat64, + AbsFloat64, + CeilFloat64, + FloorFloat64, + TruncFloat64, + NearestFloat64, + SqrtFloat64, + EqZInt64, + ExtendSInt32, + ExtendUInt32, + WrapInt64, + TruncSFloat32ToInt32, + TruncSFloat32ToInt64, + TruncUFloat32ToInt32, + TruncUFloat32ToInt64, + TruncSFloat64ToInt32, + TruncSFloat64ToInt64, + TruncUFloat64ToInt32, + TruncUFloat64ToInt64, + TruncSatSFloat32ToInt32, + TruncSatSFloat32ToInt64, + TruncSatUFloat32ToInt32, + TruncSatUFloat32ToInt64, + TruncSatSFloat64ToInt32, + TruncSatSFloat64ToInt64, + TruncSatUFloat64ToInt32, + TruncSatUFloat64ToInt64, + ReinterpretFloat32, + ReinterpretFloat64, + ConvertSInt32ToFloat32, + ConvertSInt32ToFloat64, + ConvertUInt32ToFloat32, + ConvertUInt32ToFloat64, + ConvertSInt64ToFloat32, + ConvertSInt64ToFloat64, + ConvertUInt64ToFloat32, + ConvertUInt64ToFloat64, + PromoteFloat32, + DemoteFloat64, + ReinterpretInt32, + ReinterpretInt64, + ExtendS8Int32, + ExtendS16Int32, + ExtendS8Int64, + ExtendS16Int64, + ExtendS32Int64, + AddInt32, + SubInt32, + MulInt32, + DivSInt32, + DivUInt32, + RemSInt32, + RemUInt32, + AndInt32, + OrInt32, + XorInt32, + ShlInt32, + ShrUInt32, + ShrSInt32, + RotLInt32, + RotRInt32, + EqInt32, + NeInt32, + LtSInt32, + LtUInt32, + LeSInt32, + LeUInt32, + GtSInt32, + GtUInt32, + GeSInt32, + GeUInt32, + AddInt64, + SubInt64, + MulInt64, + DivSInt64, + DivUInt64, + RemSInt64, + RemUInt64, + AndInt64, + OrInt64, + XorInt64, + ShlInt64, + ShrUInt64, + ShrSInt64, + RotLInt64, + RotRInt64, + EqInt64, + NeInt64, + LtSInt64, + LtUInt64, + LeSInt64, + LeUInt64, + GtSInt64, + GtUInt64, + GeSInt64, + GeUInt64, + AddFloat32, + SubFloat32, + MulFloat32, + DivFloat32, + CopySignFloat32, + MinFloat32, + MaxFloat32, + EqFloat32, + NeFloat32, + LtFloat32, + LeFloat32, + GtFloat32, + GeFloat32, + AddFloat64, + SubFloat64, + MulFloat64, + DivFloat64, + CopySignFloat64, + MinFloat64, + MaxFloat64, + EqFloat64, + NeFloat64, + LtFloat64, + LeFloat64, + GtFloat64, + GeFloat64, + MemorySize, + MemoryGrow, + AtomicRMWAdd, + AtomicRMWSub, + AtomicRMWAnd, + AtomicRMWOr, + AtomicRMWXor, + AtomicRMWXchg, + SplatVecI8x16, + ExtractLaneSVecI8x16, + ExtractLaneUVecI8x16, + ReplaceLaneVecI8x16, + SplatVecI16x8, + ExtractLaneSVecI16x8, + ExtractLaneUVecI16x8, + ReplaceLaneVecI16x8, + SplatVecI32x4, + ExtractLaneVecI32x4, + ReplaceLaneVecI32x4, + SplatVecI64x2, + ExtractLaneVecI64x2, + ReplaceLaneVecI64x2, + SplatVecF32x4, + ExtractLaneVecF32x4, + ReplaceLaneVecF32x4, + SplatVecF64x2, + ExtractLaneVecF64x2, + ReplaceLaneVecF64x2, + EqVecI8x16, + NeVecI8x16, + LtSVecI8x16, + LtUVecI8x16, + GtSVecI8x16, + GtUVecI8x16, + LeSVecI8x16, + LeUVecI8x16, + GeSVecI8x16, + GeUVecI8x16, + EqVecI16x8, + NeVecI16x8, + LtSVecI16x8, + LtUVecI16x8, + GtSVecI16x8, + GtUVecI16x8, + LeSVecI16x8, + LeUVecI16x8, + GeSVecI16x8, + GeUVecI16x8, + EqVecI32x4, + NeVecI32x4, + LtSVecI32x4, + LtUVecI32x4, + GtSVecI32x4, + GtUVecI32x4, + LeSVecI32x4, + LeUVecI32x4, + GeSVecI32x4, + GeUVecI32x4, + EqVecF32x4, + NeVecF32x4, + LtVecF32x4, + GtVecF32x4, + LeVecF32x4, + GeVecF32x4, + EqVecF64x2, + NeVecF64x2, + LtVecF64x2, + GtVecF64x2, + LeVecF64x2, + GeVecF64x2, + NotVec128, + AndVec128, + OrVec128, + XorVec128, + AndNotVec128, + BitselectVec128, + NegVecI8x16, + AnyTrueVecI8x16, + AllTrueVecI8x16, + ShlVecI8x16, + ShrSVecI8x16, + ShrUVecI8x16, + AddVecI8x16, + AddSatSVecI8x16, + AddSatUVecI8x16, + SubVecI8x16, + SubSatSVecI8x16, + SubSatUVecI8x16, + MulVecI8x16, + MinSVecI8x16, + MinUVecI8x16, + MaxSVecI8x16, + MaxUVecI8x16, + NegVecI16x8, + AnyTrueVecI16x8, + AllTrueVecI16x8, + ShlVecI16x8, + ShrSVecI16x8, + ShrUVecI16x8, + AddVecI16x8, + AddSatSVecI16x8, + AddSatUVecI16x8, + SubVecI16x8, + SubSatSVecI16x8, + SubSatUVecI16x8, + MulVecI16x8, + MinSVecI16x8, + MinUVecI16x8, + MaxSVecI16x8, + MaxUVecI16x8, + DotSVecI16x8ToVecI32x4, + NegVecI32x4, + AnyTrueVecI32x4, + AllTrueVecI32x4, + ShlVecI32x4, + ShrSVecI32x4, + ShrUVecI32x4, + AddVecI32x4, + SubVecI32x4, + MulVecI32x4, + MinSVecI32x4, + MinUVecI32x4, + MaxSVecI32x4, + MaxUVecI32x4, + NegVecI64x2, + AnyTrueVecI64x2, + AllTrueVecI64x2, + ShlVecI64x2, + ShrSVecI64x2, + ShrUVecI64x2, + AddVecI64x2, + SubVecI64x2, + AbsVecF32x4, + NegVecF32x4, + SqrtVecF32x4, + QFMAVecF32x4, + QFMSVecF32x4, + AddVecF32x4, + SubVecF32x4, + MulVecF32x4, + DivVecF32x4, + MinVecF32x4, + MaxVecF32x4, + AbsVecF64x2, + NegVecF64x2, + SqrtVecF64x2, + QFMAVecF64x2, + QFMSVecF64x2, + AddVecF64x2, + SubVecF64x2, + MulVecF64x2, + DivVecF64x2, + MinVecF64x2, + MaxVecF64x2, + TruncSatSVecF32x4ToVecI32x4, + TruncSatUVecF32x4ToVecI32x4, + TruncSatSVecF64x2ToVecI64x2, + TruncSatUVecF64x2ToVecI64x2, + ConvertSVecI32x4ToVecF32x4, + ConvertUVecI32x4ToVecF32x4, + ConvertSVecI64x2ToVecF64x2, + ConvertUVecI64x2ToVecF64x2, + LoadSplatVec8x16, + LoadSplatVec16x8, + LoadSplatVec32x4, + LoadSplatVec64x2, + LoadExtSVec8x8ToVecI16x8, + LoadExtUVec8x8ToVecI16x8, + LoadExtSVec16x4ToVecI32x4, + LoadExtUVec16x4ToVecI32x4, + LoadExtSVec32x2ToVecI64x2, + LoadExtUVec32x2ToVecI64x2, + NarrowSVecI16x8ToVecI8x16, + NarrowUVecI16x8ToVecI8x16, + NarrowSVecI32x4ToVecI16x8, + NarrowUVecI32x4ToVecI16x8, + WidenLowSVecI8x16ToVecI16x8, + WidenHighSVecI8x16ToVecI16x8, + WidenLowUVecI8x16ToVecI16x8, + WidenHighUVecI8x16ToVecI16x8, + WidenLowSVecI16x8ToVecI32x4, + WidenHighSVecI16x8ToVecI32x4, + WidenLowUVecI16x8ToVecI32x4, + WidenHighUVecI16x8ToVecI32x4, + SwizzleVec8x16 + } + + const ClzInt32: Operations; + const CtzInt32: Operations; + const PopcntInt32: Operations; + const NegFloat32: Operations; + const AbsFloat32: Operations; + const CeilFloat32: Operations; + const FloorFloat32: Operations; + const TruncFloat32: Operations; + const NearestFloat32: Operations; + const SqrtFloat32: Operations; + const EqZInt32: Operations; + const ClzInt64: Operations; + const CtzInt64: Operations; + const PopcntInt64: Operations; + const NegFloat64: Operations; + const AbsFloat64: Operations; + const CeilFloat64: Operations; + const FloorFloat64: Operations; + const TruncFloat64: Operations; + const NearestFloat64: Operations; + const SqrtFloat64: Operations; + const EqZInt64: Operations; + const ExtendSInt32: Operations; + const ExtendUInt32: Operations; + const WrapInt64: Operations; + const TruncSFloat32ToInt32: Operations; + const TruncSFloat32ToInt64: Operations; + const TruncUFloat32ToInt32: Operations; + const TruncUFloat32ToInt64: Operations; + const TruncSFloat64ToInt32: Operations; + const TruncSFloat64ToInt64: Operations; + const TruncUFloat64ToInt32: Operations; + const TruncUFloat64ToInt64: Operations; + const TruncSatSFloat32ToInt32: Operations; + const TruncSatSFloat32ToInt64: Operations; + const TruncSatUFloat32ToInt32: Operations; + const TruncSatUFloat32ToInt64: Operations; + const TruncSatSFloat64ToInt32: Operations; + const TruncSatSFloat64ToInt64: Operations; + const TruncSatUFloat64ToInt32: Operations; + const TruncSatUFloat64ToInt64: Operations; + const ReinterpretFloat32: Operations; + const ReinterpretFloat64: Operations; + const ConvertSInt32ToFloat32: Operations; + const ConvertSInt32ToFloat64: Operations; + const ConvertUInt32ToFloat32: Operations; + const ConvertUInt32ToFloat64: Operations; + const ConvertSInt64ToFloat32: Operations; + const ConvertSInt64ToFloat64: Operations; + const ConvertUInt64ToFloat32: Operations; + const ConvertUInt64ToFloat64: Operations; + const PromoteFloat32: Operations; + const DemoteFloat64: Operations; + const ReinterpretInt32: Operations; + const ReinterpretInt64: Operations; + const ExtendS8Int32: Operations; + const ExtendS16Int32: Operations; + const ExtendS8Int64: Operations; + const ExtendS16Int64: Operations; + const ExtendS32Int64: Operations; + const AddInt32: Operations; + const SubInt32: Operations; + const MulInt32: Operations; + const DivSInt32: Operations; + const DivUInt32: Operations; + const RemSInt32: Operations; + const RemUInt32: Operations; + const AndInt32: Operations; + const OrInt32: Operations; + const XorInt32: Operations; + const ShlInt32: Operations; + const ShrUInt32: Operations; + const ShrSInt32: Operations; + const RotLInt32: Operations; + const RotRInt32: Operations; + const EqInt32: Operations; + const NeInt32: Operations; + const LtSInt32: Operations; + const LtUInt32: Operations; + const LeSInt32: Operations; + const LeUInt32: Operations; + const GtSInt32: Operations; + const GtUInt32: Operations; + const GeSInt32: Operations; + const GeUInt32: Operations; + const AddInt64: Operations; + const SubInt64: Operations; + const MulInt64: Operations; + const DivSInt64: Operations; + const DivUInt64: Operations; + const RemSInt64: Operations; + const RemUInt64: Operations; + const AndInt64: Operations; + const OrInt64: Operations; + const XorInt64: Operations; + const ShlInt64: Operations; + const ShrUInt64: Operations; + const ShrSInt64: Operations; + const RotLInt64: Operations; + const RotRInt64: Operations; + const EqInt64: Operations; + const NeInt64: Operations; + const LtSInt64: Operations; + const LtUInt64: Operations; + const LeSInt64: Operations; + const LeUInt64: Operations; + const GtSInt64: Operations; + const GtUInt64: Operations; + const GeSInt64: Operations; + const GeUInt64: Operations; + const AddFloat32: Operations; + const SubFloat32: Operations; + const MulFloat32: Operations; + const DivFloat32: Operations; + const CopySignFloat32: Operations; + const MinFloat32: Operations; + const MaxFloat32: Operations; + const EqFloat32: Operations; + const NeFloat32: Operations; + const LtFloat32: Operations; + const LeFloat32: Operations; + const GtFloat32: Operations; + const GeFloat32: Operations; + const AddFloat64: Operations; + const SubFloat64: Operations; + const MulFloat64: Operations; + const DivFloat64: Operations; + const CopySignFloat64: Operations; + const MinFloat64: Operations; + const MaxFloat64: Operations; + const EqFloat64: Operations; + const NeFloat64: Operations; + const LtFloat64: Operations; + const LeFloat64: Operations; + const GtFloat64: Operations; + const GeFloat64: Operations; + const MemorySize: Operations; + const MemoryGrow: Operations; + const AtomicRMWAdd: Operations; + const AtomicRMWSub: Operations; + const AtomicRMWAnd: Operations; + const AtomicRMWOr: Operations; + const AtomicRMWXor: Operations; + const AtomicRMWXchg: Operations; + const SplatVecI8x16: Operations; + const ExtractLaneSVecI8x16: Operations; + const ExtractLaneUVecI8x16: Operations; + const ReplaceLaneVecI8x16: Operations; + const SplatVecI16x8: Operations; + const ExtractLaneSVecI16x8: Operations; + const ExtractLaneUVecI16x8: Operations; + const ReplaceLaneVecI16x8: Operations; + const SplatVecI32x4: Operations; + const ExtractLaneVecI32x4: Operations; + const ReplaceLaneVecI32x4: Operations; + const SplatVecI64x2: Operations; + const ExtractLaneVecI64x2: Operations; + const ReplaceLaneVecI64x2: Operations; + const SplatVecF32x4: Operations; + const ExtractLaneVecF32x4: Operations; + const ReplaceLaneVecF32x4: Operations; + const SplatVecF64x2: Operations; + const ExtractLaneVecF64x2: Operations; + const ReplaceLaneVecF64x2: Operations; + const EqVecI8x16: Operations; + const NeVecI8x16: Operations; + const LtSVecI8x16: Operations; + const LtUVecI8x16: Operations; + const GtSVecI8x16: Operations; + const GtUVecI8x16: Operations; + const LeSVecI8x16: Operations; + const LeUVecI8x16: Operations; + const GeSVecI8x16: Operations; + const GeUVecI8x16: Operations; + const EqVecI16x8: Operations; + const NeVecI16x8: Operations; + const LtSVecI16x8: Operations; + const LtUVecI16x8: Operations; + const GtSVecI16x8: Operations; + const GtUVecI16x8: Operations; + const LeSVecI16x8: Operations; + const LeUVecI16x8: Operations; + const GeSVecI16x8: Operations; + const GeUVecI16x8: Operations; + const EqVecI32x4: Operations; + const NeVecI32x4: Operations; + const LtSVecI32x4: Operations; + const LtUVecI32x4: Operations; + const GtSVecI32x4: Operations; + const GtUVecI32x4: Operations; + const LeSVecI32x4: Operations; + const LeUVecI32x4: Operations; + const GeSVecI32x4: Operations; + const GeUVecI32x4: Operations; + const EqVecF32x4: Operations; + const NeVecF32x4: Operations; + const LtVecF32x4: Operations; + const GtVecF32x4: Operations; + const LeVecF32x4: Operations; + const GeVecF32x4: Operations; + const EqVecF64x2: Operations; + const NeVecF64x2: Operations; + const LtVecF64x2: Operations; + const GtVecF64x2: Operations; + const LeVecF64x2: Operations; + const GeVecF64x2: Operations; + const NotVec128: Operations; + const AndVec128: Operations; + const OrVec128: Operations; + const XorVec128: Operations; + const AndNotVec128: Operations; + const BitselectVec128: Operations; + const NegVecI8x16: Operations; + const AnyTrueVecI8x16: Operations; + const AllTrueVecI8x16: Operations; + const ShlVecI8x16: Operations; + const ShrSVecI8x16: Operations; + const ShrUVecI8x16: Operations; + const AddVecI8x16: Operations; + const AddSatSVecI8x16: Operations; + const AddSatUVecI8x16: Operations; + const SubVecI8x16: Operations; + const SubSatSVecI8x16: Operations; + const SubSatUVecI8x16: Operations; + const MulVecI8x16: Operations; + const MinSVecI8x16: Operations; + const MinUVecI8x16: Operations; + const MaxSVecI8x16: Operations; + const MaxUVecI8x16: Operations; + const NegVecI16x8: Operations; + const AnyTrueVecI16x8: Operations; + const AllTrueVecI16x8: Operations; + const ShlVecI16x8: Operations; + const ShrSVecI16x8: Operations; + const ShrUVecI16x8: Operations; + const AddVecI16x8: Operations; + const AddSatSVecI16x8: Operations; + const AddSatUVecI16x8: Operations; + const SubVecI16x8: Operations; + const SubSatSVecI16x8: Operations; + const SubSatUVecI16x8: Operations; + const MulVecI16x8: Operations; + const MinSVecI16x8: Operations; + const MinUVecI16x8: Operations; + const MaxSVecI16x8: Operations; + const MaxUVecI16x8: Operations; + const DotSVecI16x8ToVecI32x4: Operations; + const NegVecI32x4: Operations; + const AnyTrueVecI32x4: Operations; + const AllTrueVecI32x4: Operations; + const ShlVecI32x4: Operations; + const ShrSVecI32x4: Operations; + const ShrUVecI32x4: Operations; + const AddVecI32x4: Operations; + const SubVecI32x4: Operations; + const MulVecI32x4: Operations; + const MinSVecI32x4: Operations; + const MinUVecI32x4: Operations; + const MaxSVecI32x4: Operations; + const MaxUVecI32x4: Operations; + const NegVecI64x2: Operations; + const AnyTrueVecI64x2: Operations; + const AllTrueVecI64x2: Operations; + const ShlVecI64x2: Operations; + const ShrSVecI64x2: Operations; + const ShrUVecI64x2: Operations; + const AddVecI64x2: Operations; + const SubVecI64x2: Operations; + const AbsVecF32x4: Operations; + const NegVecF32x4: Operations; + const SqrtVecF32x4: Operations; + const QFMAVecF32x4: Operations; + const QFMSVecF32x4: Operations; + const AddVecF32x4: Operations; + const SubVecF32x4: Operations; + const MulVecF32x4: Operations; + const DivVecF32x4: Operations; + const MinVecF32x4: Operations; + const MaxVecF32x4: Operations; + const AbsVecF64x2: Operations; + const NegVecF64x2: Operations; + const SqrtVecF64x2: Operations; + const QFMAVecF64x2: Operations; + const QFMSVecF64x2: Operations; + const AddVecF64x2: Operations; + const SubVecF64x2: Operations; + const MulVecF64x2: Operations; + const DivVecF64x2: Operations; + const MinVecF64x2: Operations; + const MaxVecF64x2: Operations; + const TruncSatSVecF32x4ToVecI32x4: Operations; + const TruncSatUVecF32x4ToVecI32x4: Operations; + const TruncSatSVecF64x2ToVecI64x2: Operations; + const TruncSatUVecF64x2ToVecI64x2: Operations; + const ConvertSVecI32x4ToVecF32x4: Operations; + const ConvertUVecI32x4ToVecF32x4: Operations; + const ConvertSVecI64x2ToVecF64x2: Operations; + const ConvertUVecI64x2ToVecF64x2: Operations; + const LoadSplatVec8x16: Operations; + const LoadSplatVec16x8: Operations; + const LoadSplatVec32x4: Operations; + const LoadSplatVec64x2: Operations; + const LoadExtSVec8x8ToVecI16x8: Operations; + const LoadExtUVec8x8ToVecI16x8: Operations; + const LoadExtSVec16x4ToVecI32x4: Operations; + const LoadExtUVec16x4ToVecI32x4: Operations; + const LoadExtSVec32x2ToVecI64x2: Operations; + const LoadExtUVec32x2ToVecI64x2: Operations; + const NarrowSVecI16x8ToVecI8x16: Operations; + const NarrowUVecI16x8ToVecI8x16: Operations; + const NarrowSVecI32x4ToVecI16x8: Operations; + const NarrowUVecI32x4ToVecI16x8: Operations; + const WidenLowSVecI8x16ToVecI16x8: Operations; + const WidenHighSVecI8x16ToVecI16x8: Operations; + const WidenLowUVecI8x16ToVecI16x8: Operations; + const WidenHighUVecI8x16ToVecI16x8: Operations; + const WidenLowSVecI16x8ToVecI32x4: Operations; + const WidenHighSVecI16x8ToVecI32x4: Operations; + const WidenLowUVecI16x8ToVecI32x4: Operations; + const WidenHighUVecI16x8ToVecI32x4: Operations; + const SwizzleVec8x16: Operations; + + type ExpressionRef = number; + type FunctionRef = number; + type GlobalRef = number; + type ExportRef = number; + type EventRef = number; + + class Module { + constructor(); + readonly ptr: number; + block(label: string, children: ExpressionRef[], resultType?: Type): ExpressionRef; + if(condition: ExpressionRef, ifTrue: ExpressionRef, ifFalse?: ExpressionRef): ExpressionRef; + loop(label: string, body: ExpressionRef): ExpressionRef; + br(label: string, condition?: ExpressionRef, value?: ExpressionRef): ExpressionRef; + br_if(label: string, condition?: ExpressionRef, value?: ExpressionRef): ExpressionRef; + switch(labels: string[], defaultLabel: string, condition: ExpressionRef, value?: ExpressionRef): ExpressionRef; + call(name: string, operands: ExpressionRef[], returnType: Type): ExpressionRef; + return_call(name: string, operands: ExpressionRef[], returnType: Type): ExpressionRef; + call_indirect(target: ExpressionRef, operands: ExpressionRef[], params: Type, results: Type): ExpressionRef; + return_call_indirect(target: ExpressionRef, operands: ExpressionRef[], params: Type, results: Type): ExpressionRef; + local: { + get(index: number, type: Type): ExpressionRef; + set(index: number, value: ExpressionRef): ExpressionRef; + tee(index: number, value: ExpressionRef, type: Type): ExpressionRef; + }; + global: { + get(name: string, type: Type): ExpressionRef; + set(name: string, value: ExpressionRef): ExpressionRef; + }; + memory: { + size(): ExpressionRef; + grow(value: ExpressionRef): ExpressionRef; + init(segment: number, dest: ExpressionRef, offset: ExpressionRef, size: ExpressionRef): ExpressionRef; + copy(dest: ExpressionRef, source: ExpressionRef, size: ExpressionRef): ExpressionRef; + fill(dest: ExpressionRef, value: ExpressionRef, size: ExpressionRef): ExpressionRef; + }; + data: { + drop(segment: number): ExpressionRef; + }; + i32: { + load(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load8_s(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load8_u(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load16_s(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load16_u(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + store(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store8(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store16(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + const(value: number): ExpressionRef; + clz(value: ExpressionRef): ExpressionRef; + ctz(value: ExpressionRef): ExpressionRef; + popcnt(value: ExpressionRef): ExpressionRef; + eqz(value: ExpressionRef): ExpressionRef; + trunc_s: { + f32(value: ExpressionRef): ExpressionRef; + f64(value: ExpressionRef): ExpressionRef; + }; + trunc_u: { + f32(value: ExpressionRef): ExpressionRef; + f64(value: ExpressionRef): ExpressionRef; + }; + trunc_s_sat: { + f32(value: ExpressionRef): ExpressionRef; + f64(value: ExpressionRef): ExpressionRef; + }; + trunc_u_sat: { + f32(value: ExpressionRef): ExpressionRef; + f64(value: ExpressionRef): ExpressionRef; + }; + reinterpret(value: ExpressionRef): ExpressionRef; + extend8_s(value: ExpressionRef): ExpressionRef; + extend16_s(value: ExpressionRef): ExpressionRef; + wrap(value: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + div_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + div_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + rem_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + rem_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + and(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + or(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + xor(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + shl(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + shr_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + shr_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + rotl(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + rotr(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + atomic: { + load(offset: number, ptr: ExpressionRef): ExpressionRef; + load8_u(offset: number, ptr: ExpressionRef): ExpressionRef; + load16_u(offset: number, ptr: ExpressionRef): ExpressionRef; + store(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store8(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store16(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + rmw: { + add(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + sub(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + and(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + or(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xor(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xchg(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + cmpxchg(offset: number, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef): ExpressionRef; + }, + rmw8_u: { + add(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + sub(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + and(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + or(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xor(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xchg(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + cmpxchg(offset: number, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef): ExpressionRef; + }, + rmw16_u: { + add(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + sub(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + and(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + or(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xor(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xchg(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + cmpxchg(offset: number, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef): ExpressionRef; + }, + wait(ptr: ExpressionRef, expected: ExpressionRef, timeout: ExpressionRef): ExpressionRef; + }, + pop(): ExpressionRef; + }; + i64: { + load(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load8_s(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load8_u(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load16_s(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load16_u(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load32_s(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load32_u(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + store(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store8(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store16(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store32(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + const(low: number, high: number): ExpressionRef; + clz(value: ExpressionRef): ExpressionRef; + ctz(value: ExpressionRef): ExpressionRef; + popcnt(value: ExpressionRef): ExpressionRef; + eqz(value: ExpressionRef): ExpressionRef; + trunc_s: { + f32(value: ExpressionRef): ExpressionRef; + f64(value: ExpressionRef): ExpressionRef; + }; + trunc_u: { + f32(value: ExpressionRef): ExpressionRef; + f64(value: ExpressionRef): ExpressionRef; + }; + trunc_s_sat: { + f32(value: ExpressionRef): ExpressionRef; + f64(value: ExpressionRef): ExpressionRef; + }; + trunc_u_sat: { + f32(value: ExpressionRef): ExpressionRef; + f64(value: ExpressionRef): ExpressionRef; + }; + reinterpret(value: ExpressionRef): ExpressionRef; + extend8_s(value: ExpressionRef): ExpressionRef; + extend16_s(value: ExpressionRef): ExpressionRef; + extend32_s(value: ExpressionRef): ExpressionRef; + extend_s(value: ExpressionRef): ExpressionRef; + extend_u(value: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + div_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + div_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + rem_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + rem_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + and(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + or(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + xor(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + shl(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + shr_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + shr_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + rotl(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + rotr(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + atomic: { + load(offset: number, ptr: ExpressionRef): ExpressionRef; + load8_u(offset: number, ptr: ExpressionRef): ExpressionRef; + load16_u(offset: number, ptr: ExpressionRef): ExpressionRef; + load32_u(offset: number, ptr: ExpressionRef): ExpressionRef; + store(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store8(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store16(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + store32(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + rmw: { + add(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + sub(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + and(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + or(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xor(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xchg(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + cmpxchg(offset: number, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef): ExpressionRef; + }, + rmw8_u: { + add(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + sub(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + and(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + or(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xor(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xchg(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + cmpxchg(offset: number, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef): ExpressionRef; + }, + rmw16_u: { + add(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + sub(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + and(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + or(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xor(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xchg(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + cmpxchg(offset: number, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef): ExpressionRef; + }, + rmw32_u: { + add(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + sub(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + and(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + or(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xor(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + xchg(offset: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + cmpxchg(offset: number, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef): ExpressionRef; + }, + wait(ptr: ExpressionRef, expected: ExpressionRef, timeout: ExpressionRef): ExpressionRef; + }, + pop(): ExpressionRef; + }; + f32: { + load(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + store(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + const(value: number): ExpressionRef; + const_bits(value: number): ExpressionRef; + neg(value: ExpressionRef): ExpressionRef; + abs(value: ExpressionRef): ExpressionRef; + ceil(value: ExpressionRef): ExpressionRef; + floor(value: ExpressionRef): ExpressionRef; + trunc(value: ExpressionRef): ExpressionRef; + nearest(value: ExpressionRef): ExpressionRef; + sqrt(value: ExpressionRef): ExpressionRef; + reinterpret(value: ExpressionRef): ExpressionRef; + convert_s: { + i32(value: ExpressionRef): ExpressionRef; + i64(value: ExpressionRef): ExpressionRef; + }; + convert_u: { + i32(value: ExpressionRef): ExpressionRef; + i64(value: ExpressionRef): ExpressionRef; + }; + demote(value: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + div(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + copysign(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + min(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + max(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + pop(): ExpressionRef; + }; + f64: { + load(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + store(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + const(value: number): ExpressionRef; + const_bits(low: number, high: number): ExpressionRef; + neg(value: ExpressionRef): ExpressionRef; + abs(value: ExpressionRef): ExpressionRef; + ceil(value: ExpressionRef): ExpressionRef; + floor(value: ExpressionRef): ExpressionRef; + trunc(value: ExpressionRef): ExpressionRef; + nearest(value: ExpressionRef): ExpressionRef; + sqrt(value: ExpressionRef): ExpressionRef; + reinterpret(value: ExpressionRef): ExpressionRef; + convert_s: { + i32(value: ExpressionRef): ExpressionRef; + i64(value: ExpressionRef): ExpressionRef; + }; + convert_u: { + i32(value: ExpressionRef): ExpressionRef; + i64(value: ExpressionRef): ExpressionRef; + }; + promote(value: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + div(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + copysign(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + min(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + max(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + pop(): ExpressionRef; + }; + v128: { + load(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + store(offset: number, align: number, ptr: ExpressionRef, value: ExpressionRef): ExpressionRef; + const(value: number): ExpressionRef; + not(value: ExpressionRef): ExpressionRef; + and(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + or(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + xor(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + andnot(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + bitselect(left: ExpressionRef, right: ExpressionRef, cond: ExpressionRef): ExpressionRef; + pop(): ExpressionRef; + }; + i8x16: { + splat(value: ExpressionRef): ExpressionRef; + extract_lane_s(vec: ExpressionRef, index: ExpressionRef): ExpressionRef; + extract_lane_u(vec: ExpressionRef, index: ExpressionRef): ExpressionRef; + replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + neg(value: ExpressionRef): ExpressionRef; + any_true(value: ExpressionRef): ExpressionRef; + all_true(value: ExpressionRef): ExpressionRef; + shl(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + shr_s(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + shr_u(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + add_saturate_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + add_saturate_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub_saturate_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub_saturate_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + min_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + min_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + max_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + max_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + avgr_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + narrow_i16x8_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + narrow_i16x8_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + }; + i16x8: { + splat(value: ExpressionRef): ExpressionRef; + extract_lane_s(vec: ExpressionRef, index: ExpressionRef): ExpressionRef; + extract_lane_u(vec: ExpressionRef, index: ExpressionRef): ExpressionRef; + replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + neg(value: ExpressionRef): ExpressionRef; + any_true(value: ExpressionRef): ExpressionRef; + all_true(value: ExpressionRef): ExpressionRef; + shl(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + shr_s(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + shr_u(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + add_saturate_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + add_saturate_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub_saturate_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub_saturate_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + min_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + min_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + max_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + max_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + avgr_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + narrow_i32x4_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + narrow_i32x4_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + widen_low_i8x16_s(value: ExpressionRef): ExpressionRef; + widen_high_i8x16_s(value: ExpressionRef): ExpressionRef; + widen_low_i8x16_u(value: ExpressionRef): ExpressionRef; + widen_high_i8x16_u(value: ExpressionRef): ExpressionRef; + load8x8_s(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load8x8_u(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + }; + i32x4: { + splat(value: ExpressionRef): ExpressionRef; + extract_lane(vec: ExpressionRef, index: ExpressionRef): ExpressionRef; + replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_s(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + neg(value: ExpressionRef): ExpressionRef; + any_true(value: ExpressionRef): ExpressionRef; + all_true(value: ExpressionRef): ExpressionRef; + shl(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + shr_s(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + shr_u(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + trunc_sat_f32x4_s(value: ExpressionRef): ExpressionRef; + trunc_sat_f32x4_u(value: ExpressionRef): ExpressionRef; + widen_low_i16x8_s(value: ExpressionRef): ExpressionRef; + widen_high_i16x8_s(value: ExpressionRef): ExpressionRef; + widen_low_i16x8_u(value: ExpressionRef): ExpressionRef; + widen_high_i16x8_u(value: ExpressionRef): ExpressionRef; + load16x4_s(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load16x4_u(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + }; + i64x2: { + splat(value: ExpressionRef): ExpressionRef; + extract_lane(vec: ExpressionRef, index: ExpressionRef): ExpressionRef; + replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef; + neg(value: ExpressionRef): ExpressionRef; + any_true(value: ExpressionRef): ExpressionRef; + all_true(value: ExpressionRef): ExpressionRef; + shl(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + shr_s(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + shr_u(vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + trunc_sat_f64x2_s(value: ExpressionRef): ExpressionRef; + trunc_sat_f64x2_u(value: ExpressionRef): ExpressionRef; + load32x2_s(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + load32x2_u(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + }; + f32x4: { + splat(value: ExpressionRef): ExpressionRef; + extract_lane(vec: ExpressionRef, index: ExpressionRef): ExpressionRef; + replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + abs(value: ExpressionRef): ExpressionRef; + neg(value: ExpressionRef): ExpressionRef; + sqrt(value: ExpressionRef): ExpressionRef; + qfma(a: ExpressionRef, b: ExpressionRef, c: ExpressionRef): ExpressionRef; + qfms(a: ExpressionRef, b: ExpressionRef, c: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + div(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + min(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + max(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + convert_i32x4_s(value: ExpressionRef): ExpressionRef; + convert_i32x4_u(value: ExpressionRef): ExpressionRef; + }; + f64x2: { + splat(value: ExpressionRef): ExpressionRef; + extract_lane(vec: ExpressionRef, index: ExpressionRef): ExpressionRef; + replace_lane(vec: ExpressionRef, index: ExpressionRef, value: ExpressionRef): ExpressionRef; + eq(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ne(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + lt(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + gt(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + le(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + ge(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + abs(value: ExpressionRef): ExpressionRef; + neg(value: ExpressionRef): ExpressionRef; + sqrt(value: ExpressionRef): ExpressionRef; + qfma(a: ExpressionRef, b: ExpressionRef, c: ExpressionRef): ExpressionRef; + qfms(a: ExpressionRef, b: ExpressionRef, c: ExpressionRef): ExpressionRef; + add(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + sub(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + mul(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + div(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + min(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + max(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + convert_i64x2_s(value: ExpressionRef): ExpressionRef; + convert_i64x2_u(value: ExpressionRef): ExpressionRef; + }; + v8x16: { + shuffle(left: ExpressionRef, right: ExpressionRef, mask: number[]): ExpressionRef; + swizzle(left: ExpressionRef, right: ExpressionRef): ExpressionRef; + load_splat(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + }; + v16x8: { + load_splat(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + }; + v32x4: { + load_splat(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + }; + v64x2: { + load_splat(offset: number, align: number, ptr: ExpressionRef): ExpressionRef; + }; + funcref: { + pop(): ExpressionRef; + }; + anyref: { + pop(): ExpressionRef; + }; + nullref: { + pop(): ExpressionRef; + }; + exnref: { + pop(): ExpressionRef; + }; + ref: { + null(): ExpressionRef; + is_null(value: ExpressionRef): ExpressionRef; + func(name: string): ExpressionRef; + }; + atomic: { + notify(ptr: ExpressionRef, notifyCount: ExpressionRef): ExpressionRef; + fence(): ExpressionRef; + }; + tuple: { + make(elements: ExportRef[]): ExpressionRef; + extract(tuple: ExpressionRef, index: number): ExpressionRef; + }; + try(body: ExpressionRef, catchBody: ExpressionRef): ExpressionRef; + throw(event: string, operands: ExpressionRef[]): ExpressionRef; + rethrow(exnref: ExpressionRef): ExpressionRef; + br_on_exn(label: string, event: string, exnref: ExpressionRef): ExpressionRef; + push(value: ExpressionRef): ExpressionRef; + select(condition: ExpressionRef, ifTrue: ExpressionRef, ifFalse: ExpressionRef, type?: Type): ExpressionRef; + drop(value: ExpressionRef): ExpressionRef; + return(value?: ExpressionRef): ExpressionRef; + host(op: Operations, name: string, operands: ExpressionRef[]): ExpressionRef; + nop(): ExpressionRef; + unreachable(): ExpressionRef; + addFunction(name: string, params: Type, results: Type, vars: Type[], body: ExpressionRef): FunctionRef; + getFunction(name: string): FunctionRef; + removeFunction(name: string): void; + getNumFunctions(): number; + getFunctionByIndex(index: number): FunctionRef; + addGlobal(name: string, type: Type, mutable: boolean, init: ExpressionRef): GlobalRef; + getGlobal(name: string): GlobalRef; + removeGlobal(name: string): void; + addEvent(name: string, attribute: number, params: Type, results: Type): EventRef; + getEvent(name: string): EventRef; + removeEvent(name: string): void; + addFunctionImport(internalName: string, externalModuleName: string, externalBaseName: string, params: Type, results: Type): void; + addTableImport(internalName: string, externalModuleName: string, externalBaseName: string): void; + addMemoryImport(internalName: string, externalModuleName: string, externalBaseName: string): void; + addGlobalImport(internalName: string, externalModuleName: string, externalBaseName: string, globalType: Type): void; + addEventImport(internalName: string, externalModuleName: string, externalBaseName: string, attribute: number, params: Type, results: Type): void; + addFunctionExport(internalName: string, externalName: string): ExportRef; + addTableExport(internalName: string, externalName: string): ExportRef; + addMemoryExport(internalName: string, externalName: string): ExportRef; + addGlobalExport(internalName: string, externalName: string): ExportRef; + removeExport(externalName: string): void; + getNumExports(): number; + getExportByIndex(index: number): ExportRef; + setFunctionTable(initial: number, maximum: number, funcNames: number[], offset?: ExpressionRef): void; + getFunctionTable(): { imported: boolean, segments: TableElement[] }; + setMemory(initial: number, maximum: number, exportName?: string | null, segments?: MemorySegment[] | null, flags?: number[] | null, shared?: boolean): void; + getNumMemorySegments(): number; + getMemorySegmentInfoByIndex(index: number): MemorySegmentInfo; + setStart(start: FunctionRef): void; + getFeatures(): Features; + setFeatures(features: Features): void; + addCustomSection(name: string, contents: Uint8Array): void; + emitText(): string; + emitStackIR(optimize?: boolean): string; + emitAsmjs(): string; + validate(): number; + optimize(): void; + optimizeFunction(func: string | FunctionRef): void; + runPasses(passes: string[]): void; + runPassesOnFunction(func: string | FunctionRef, passes: string[]): void; + autoDrop(): void; + dispose(): void; + emitBinary(): Uint8Array; + emitBinary(sourceMapUrl: string | null): { binary: Uint8Array; sourceMap: string | null; }; + interpret(): void; + addDebugInfoFileName(filename: string): number; + getDebugInfoFileName(index: number): string | null; + setDebugLocation(func: FunctionRef, expr: ExpressionRef, fileIndex: number, lineNumber: number, columnNumber: number): void; + copyExpression(expr: ExpressionRef): ExpressionRef; + } + + interface MemorySegment { + offset: ExpressionRef; + data: Uint8Array; + passive?: boolean; + } + + interface TableElement { + offset: ExpressionRef; + names: string[]; + } + + function wrapModule(ptr: number): Module; + + function getExpressionId(expression: ExpressionRef): number; + function getExpressionType(expression: ExpressionRef): Type; + function getExpressionInfo(expression: ExpressionRef): ExpressionInfo; + + interface MemorySegmentInfo { + offset: ExpressionRef; + data: Uint8Array; + passive: boolean; + } + + interface ExpressionInfo { + id: ExpressionIds; + type: Type; + } + + interface BlockInfo extends ExpressionInfo { + name: string; + children: ExpressionRef[]; + } + + interface IfInfo extends ExpressionInfo { + condition: ExpressionRef; + ifTrue: ExpressionRef; + ifFalse: ExpressionRef; + } + + interface LoopInfo extends ExpressionInfo { + name: string; + body: ExpressionRef; + } + + interface BreakInfo extends ExpressionInfo { + name: string; + condition: ExpressionRef; + value: ExpressionRef; + } + + interface SwitchInfo extends ExpressionInfo { + names: string[]; + defaultName: string | null; + condition: ExpressionRef; + value: ExpressionRef; + } + + interface CallInfo extends ExpressionInfo { + isReturn: boolean; + target: string; + operands: ExpressionRef[]; + } + + interface CallIndirectInfo extends ExpressionInfo { + isReturn: boolean; + target: ExpressionRef; + operands: ExpressionRef[]; + } + + interface LocalGetInfo extends ExpressionInfo { + index: number; + } + + interface LocalSetInfo extends ExpressionInfo { + isTee: boolean; + index: number; + value: ExpressionRef; + } + + interface GlobalGetInfo extends ExpressionInfo { + name: string; + } + + interface GlobalSetInfo extends ExpressionInfo { + name: string; + value: ExpressionRef; + } + + interface LoadInfo extends ExpressionInfo { + isAtomic: boolean; + isSigned: boolean; + offset: number; + bytes: number; + align: number; + ptr: ExpressionRef; + } + + interface StoreInfo extends ExpressionInfo { + isAtomic: boolean; + offset: number; + bytes: number; + align: number; + ptr: ExpressionRef; + value: ExpressionRef; + } + + interface ConstInfo extends ExpressionInfo { + value: number | { low: number, high: number }; + } + + interface UnaryInfo extends ExpressionInfo { + op: Operations; + value: ExpressionRef; + } + + interface BinaryInfo extends ExpressionInfo { + op: Operations; + left: ExpressionRef; + right: ExpressionRef; + } + + interface SelectInfo extends ExpressionInfo { + ifTrue: ExpressionRef; + ifFalse: ExpressionRef; + condition: ExpressionRef; + } + + interface DropInfo extends ExpressionInfo { + value: ExpressionRef; + } + + interface ReturnInfo extends ExpressionInfo { + value: ExpressionRef; + } + + interface NopInfo extends ExpressionInfo { + } + + interface UnreachableInfo extends ExpressionInfo { + } + + interface HostInfo extends ExpressionInfo { + op: Operations; + nameOperand: string | null; + operands: ExpressionRef[]; + } + + interface AtomicRMWInfo extends ExpressionInfo { + op: Operations; + bytes: number; + offset: number; + ptr: ExpressionRef; + value: ExpressionRef; + } + + interface AtomicCmpxchgInfo extends ExpressionInfo { + bytes: number; + offset: number; + ptr: ExpressionRef; + expected: ExpressionRef; + replacement: ExpressionRef; + } + + interface AtomicWaitInfo extends ExpressionInfo { + ptr: ExpressionRef; + expected: ExpressionRef; + timeout: ExpressionRef; + expectedType: Type; + } + + interface AtomicNotifyInfo extends ExpressionInfo { + ptr: ExpressionRef; + notifyCount: ExpressionRef; + } + + interface AtomicFenceInfo extends ExpressionInfo { + order: number; + } + + interface SIMDExtractInfo extends ExpressionInfo { + op: Operations; + vec: ExpressionRef; + index: ExpressionRef; + } + + interface SIMDReplaceInfo extends ExpressionInfo { + op: Operations; + vec: ExpressionRef; + index: ExpressionRef; + value: ExpressionRef; + } + + interface SIMDShuffleInfo extends ExpressionInfo { + left: ExpressionRef; + right: ExpressionRef; + mask: number[]; + } + + interface SIMDTernaryInfo extends ExpressionInfo { + op: Operations; + a: ExpressionRef; + b: ExpressionRef; + c: ExpressionRef; + } + + interface SIMDShiftInfo extends ExpressionInfo { + op: Operations; + vec: ExpressionRef; + shift: ExpressionRef; + } + + interface SIMDLoadInfo extends ExpressionInfo { + op: Operations; + offset: number; + align: number; + ptr: ExpressionRef; + } + + interface MemoryInitInfo extends ExpressionInfo { + segment: number; + dest: ExpressionRef; + offset: ExpressionRef; + size: ExpressionRef; + } + + interface MemoryDropInfo extends ExpressionInfo { + segment: number; + } + + interface MemoryCopyInfo extends ExpressionInfo { + dest: ExpressionRef; + source: ExpressionRef; + size: ExpressionRef; + } + + interface MemoryFillInfo extends ExpressionInfo { + dest: ExpressionRef; + value: ExpressionRef; + size: ExpressionRef; + } + + interface RefNullInfo extends ExpressionInfo { + } + + interface RefIsNullInfo extends ExpressionInfo { + value: ExpressionRef; + } + + interface RefFuncInfo extends ExpressionInfo { + func: string; + } + + interface TryInfo extends ExpressionInfo { + body: ExpressionRef; + catchBody: ExpressionRef; + } + + interface ThrowInfo extends ExpressionInfo { + event: string; + operands: ExpressionRef[]; + } + + interface RethrowInfo extends ExpressionInfo { + exnref: ExpressionRef; + } + + interface BrOnExnInfo extends ExpressionInfo { + name: string; + event: string; + exnref: ExpressionRef; + } + + interface PopInfo extends ExpressionInfo { + } + + interface PushInfo extends ExpressionInfo { + type: never; // ? + value: ExpressionRef; + } + + function getFunctionInfo(func: FunctionRef): FunctionInfo; + + interface FunctionInfo { + name: string; + module: string | null; + base: string | null; + params: Type; + results: Type; + vars: Type[]; + body: ExpressionRef; + } + + function getGlobalInfo(global: GlobalRef): GlobalInfo; + + interface GlobalInfo { + name: string; + module: string | null; + base: string | null; + type: Type; + mutable: boolean; + init: ExpressionRef; + } + + function getExportInfo(export_: ExportRef): ExportInfo; + + interface ExportInfo { + kind: ExternalKinds; + name: string; + value: string; + } + + function getEventInfo(event: EventRef): EventInfo; + + interface EventInfo { + name: string; + module: string | null; + base: string | null; + attribute: number; + params: Type; + results: Type; + } + + function getSideEffects(expr: ExpressionRef, features: Features): SideEffects; + + const enum SideEffects { + None, + Branches, + Calls, + ReadsLocal, + WritesLocal, + ReadsGlobal, + WritesGlobal, + ReadsMemory, + WritesMemory, + ImplicitTrap, + IsAtomic, + Throws, + Any + } + + function emitText(expression: ExpressionRef | Module): string; + function readBinary(data: Uint8Array): Module; + function parseText(text: string): Module; + function getOptimizeLevel(): number; + function setOptimizeLevel(level: number): number; + function getShrinkLevel(): number; + function setShrinkLevel(level: number): number; + function getDebugInfo(): boolean; + function setDebugInfo(on: boolean): void; + function getLowMemoryUnused(): boolean; + function setLowMemoryUnused(on: boolean): void; + function getPassArgument(key: string): string | null; + function setPassArgument(key: string, value: string | null): void; + function clearPassArguments(): void; + function getAlwaysInlineMaxSize(): number; + function setAlwaysInlineMaxSize(size: number): void; + function getFlexibleInlineMaxSize(): number; + function setFlexibleInlineMaxSize(size: number): void; + function getOneCallerInlineMaxSize(): number; + function setOneCallerInlineMaxSize(size: number): void; + function exit(status: number): void; + + type RelooperBlockRef = number; + + class Relooper { + constructor(module: Module); + addBlock(expression: ExpressionRef): RelooperBlockRef; + addBranch(from: RelooperBlockRef, to: RelooperBlockRef, condition: ExpressionRef, code: ExpressionRef): void; + addBlockWithSwitch(code: ExpressionRef, condition: ExpressionRef): RelooperBlockRef; + addBranchForSwitch(from: RelooperBlockRef, to: RelooperBlockRef, indexes: number[], code: ExpressionRef): void; + renderAndDispose(entry: RelooperBlockRef, labelHelper: number): ExpressionRef; + } +} + +export = binaryen; diff --git a/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/internal/WasmBuilder.kt b/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/internal/WasmBuilder.kt new file mode 100644 index 000000000..7d7ee4be1 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/internal/WasmBuilder.kt @@ -0,0 +1,140 @@ +package kscience.kmath.wasm.internal + +import WebAssembly.Instance +import binaryen.* +import kscience.kmath.ast.MST +import kscience.kmath.expressions.Expression +import kscience.kmath.expressions.StringSymbol +import kscience.kmath.operations.* +import WebAssembly.Module as WasmModule +import binaryen.Module as BinaryenModule + +private val spreader = eval("(obj, args) => obj(...args)") + +@Suppress("UnsafeCastFromDynamic") +internal sealed class WasmBuilder( + val binaryenType: Type, + val kmathAlgebra: Algebra, + val target: MST +) where T : Number { + val keys: MutableList = mutableListOf() + lateinit var ctx: BinaryenModule + + open fun visitSymbolic(mst: MST.Symbolic): ExpressionRef { + try { + kmathAlgebra.symbol(mst.value) + } catch (ignored: Throwable) { + null + }?.let { return visitNumeric(MST.Numeric(it)) } + + var idx = keys.indexOf(mst.value) + + if (idx == -1) { + keys += mst.value + idx = keys.lastIndex + } + + return ctx.local.get(idx, binaryenType) + } + + abstract fun visitNumeric(mst: MST.Numeric): ExpressionRef + + open fun visitUnary(mst: MST.Unary): ExpressionRef = + error("Unary operation ${mst.operation} not defined in $this") + + open fun visitBinary(mst: MST.Binary): ExpressionRef = + error("Binary operation ${mst.operation} not defined in $this") + + open fun createModule(): BinaryenModule = js("new \$module\$binaryen.Module()") + + fun visit(mst: MST): ExpressionRef = when (mst) { + is MST.Symbolic -> visitSymbolic(mst) + is MST.Numeric -> visitNumeric(mst) + is MST.Unary -> visitUnary(mst) + is MST.Binary -> visitBinary(mst) + } + + val instance by lazy { + val c = WasmModule(with(createModule()) { + ctx = this + val expr = visit(target) + + addFunction( + "executable", + createType(Array(keys.size) { binaryenType }), + binaryenType, + arrayOf(), + expr + ) + + setOptimizeLevel(3) + optimizeFunction("executable") + addFunctionExport("executable", "executable") + val res = emitBinary() + dispose() + res + }) + + val i = Instance(c, js("{}") as Any) + val symbols = keys.map(::StringSymbol) + keys.clear() + + Expression { args -> + val params = symbols.map(args::getValue).toTypedArray() + spreader(i.exports.asDynamic().executable, params) as T + } + } +} + +internal class RealWasmBuilder(target: MST) : WasmBuilder(f64, RealField, target) { + override fun createModule(): BinaryenModule = readBinary(f64StandardFunctions) + + override fun visitNumeric(mst: MST.Numeric): ExpressionRef = ctx.f64.const(mst.value) + + override fun visitUnary(mst: MST.Unary): ExpressionRef = when (mst.operation) { + SpaceOperations.MINUS_OPERATION -> ctx.f64.neg(visit(mst.value)) + SpaceOperations.PLUS_OPERATION -> visit(mst.value) + PowerOperations.SQRT_OPERATION -> ctx.f64.sqrt(visit(mst.value)) + TrigonometricOperations.SIN_OPERATION -> ctx.call("sin", arrayOf(visit(mst.value)), f64) + TrigonometricOperations.COS_OPERATION -> ctx.call("cos", arrayOf(visit(mst.value)), f64) + TrigonometricOperations.TAN_OPERATION -> ctx.call("tan", arrayOf(visit(mst.value)), f64) + TrigonometricOperations.ASIN_OPERATION -> ctx.call("asin", arrayOf(visit(mst.value)), f64) + TrigonometricOperations.ACOS_OPERATION -> ctx.call("acos", arrayOf(visit(mst.value)), f64) + TrigonometricOperations.ATAN_OPERATION -> ctx.call("atan", arrayOf(visit(mst.value)), f64) + HyperbolicOperations.SINH_OPERATION -> ctx.call("sinh", arrayOf(visit(mst.value)), f64) + HyperbolicOperations.COSH_OPERATION -> ctx.call("cosh", arrayOf(visit(mst.value)), f64) + HyperbolicOperations.TANH_OPERATION -> ctx.call("tanh", arrayOf(visit(mst.value)), f64) + HyperbolicOperations.ASINH_OPERATION -> ctx.call("asinh", arrayOf(visit(mst.value)), f64) + HyperbolicOperations.ACOSH_OPERATION -> ctx.call("acosh", arrayOf(visit(mst.value)), f64) + HyperbolicOperations.ATANH_OPERATION -> ctx.call("atanh", arrayOf(visit(mst.value)), f64) + ExponentialOperations.EXP_OPERATION -> ctx.call("exp", arrayOf(visit(mst.value)), f64) + ExponentialOperations.LN_OPERATION -> ctx.call("log", arrayOf(visit(mst.value)), f64) + else -> super.visitUnary(mst) + } + + override fun visitBinary(mst: MST.Binary): ExpressionRef = when (mst.operation) { + SpaceOperations.PLUS_OPERATION -> ctx.f64.add(visit(mst.left), visit(mst.right)) + SpaceOperations.MINUS_OPERATION -> ctx.f64.sub(visit(mst.left), visit(mst.right)) + RingOperations.TIMES_OPERATION -> ctx.f64.mul(visit(mst.left), visit(mst.right)) + FieldOperations.DIV_OPERATION -> ctx.f64.div(visit(mst.left), visit(mst.right)) + PowerOperations.POW_OPERATION -> ctx.call("pow", arrayOf(visit(mst.left), visit(mst.right)), f64) + else -> super.visitBinary(mst) + } +} + +internal class IntWasmBuilder(target: MST) : WasmBuilder(i32, IntRing, target) { + override fun visitNumeric(mst: MST.Numeric): ExpressionRef = ctx.i32.const(mst.value) + + override fun visitUnary(mst: MST.Unary): ExpressionRef = when (mst.operation) { + SpaceOperations.MINUS_OPERATION -> ctx.i32.sub(ctx.i32.const(0), visit(mst.value)) + SpaceOperations.PLUS_OPERATION -> visit(mst.value) + else -> super.visitUnary(mst) + } + + override fun visitBinary(mst: MST.Binary): ExpressionRef = when (mst.operation) { + SpaceOperations.PLUS_OPERATION -> ctx.i32.add(visit(mst.left), visit(mst.right)) + SpaceOperations.MINUS_OPERATION -> ctx.i32.sub(visit(mst.left), visit(mst.right)) + RingOperations.TIMES_OPERATION -> ctx.i32.mul(visit(mst.left), visit(mst.right)) + else -> super.visitBinary(mst) + } +} diff --git a/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/internal/f64StandardFunctions.kt b/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/internal/f64StandardFunctions.kt new file mode 100644 index 000000000..c50ad553d --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/internal/f64StandardFunctions.kt @@ -0,0 +1,6 @@ +package kscience.kmath.wasm.internal + +internal val f64StandardFunctions by laz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CMAQRBrIgEkACAAvSICQv///////////wCDvyEAAkACQCACQjSIp0H/D3EiA0GZCEkNACAAEBBE7zn6/kIu5j+gIQAMAQsCQCADQYAISQ0AIAAgAKBEAAAAAAAA8D8gACAAokQAAAAAAADwP6CfIACgo6AQECEADAELAkAgA0HlB0kNACAAIACiIgQgBEQAAAAAAADwP6CfRAAAAAAAAPA/oKMgAKAQESEADAELIAEgAEQAAAAAAABwR6A5AwgLIAFBEGokACAAmiAAIAJCAFMbC6gEBAF/AX4DfwJ8IwBBEGshASAAvSICQj+IpyEDAkACQAJAIAJCIIinQf////8HcSIEQYCAwKAESQ0AIAJC////////////AINCgICAgICAgPj/AFYNAUQYLURU+yH5v0QYLURU+yH5PyADGw8LAkACQCAEQf//7/4DSw0AQX8hBSAEQf////EDSw0BIARB//8/Sw0CIAEgALY4AgwgAA8LIACZIQACQAJAAkAgBEH//8v/A0sNACAEQf//l/8DSw0BIAAgAKBEAAAAAAAA8L+gIABEAAAAAAAAAECgoyEAQQAhBQwDCyAEQf//jYAESw0BIABEAAAAAAAA+L+gIABEAAAAAAAA+D+iRAAAAAAAAPA/oKMhAEECIQUMAgsgAEQAAAAAAADwv6AgAEQAAAAAAADwP6CjIQBBASEFDAELRAAAAAAAAPC/IACjIQBBAyEFCyAAIAAgAKIiBiAGoiIHIAcgByAHIAdEL2xqLES0or+iRJr93lIt3q2/oKJEbZp0r/Kws7+gokRxFiP+xnG8v6CiRMTrmJmZmcm/oKIgBiAHIAcgByAHIAdEEdoi4zqtkD+iROsNdiRLe6k/oKJEUT3QoGYNsT+gokRuIEzFzUW3P6CiRP+DAJIkScI/oKJEDVVVVVVV1T+goqCiIQcgBUF/TA0BIAVBA3QiBEGACGorAwAgByAEQaAIaisDAKEgAKGhIgCaIAAgAxshAAsgAA8LIAAgB6ELtgEEAX8BfgF/AXwjAEEQayIBJAAgAL0iAkL///////////8Ag78hAAJAAkACQCACQjSIp0H/D3EiA0H9B0sNACADQd4HSw0BIAMNAiABIAC2OA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ICbDADAmwxBAJsMggdAAJwMAECcDECAnAyAwJwMwQCcDQFAmwwBgJsMQcCbDIIAmwzCQJsNAoCbDULAmw2DAJsNw0CbDgOAmw5DwNsMTAQA2wxMREDbDEyEgNsMTMTA2wxNBQDbDE1FQNsMTYWA2wxNxcDbDE4GANsMTkZA2wyMBoDbDIxGwNsMjIcA2wyMwkMAAJwMAECcDECAmwwAwJsMQQCbDIFAmwzBgJsNAcCbDUIAmw2CQJsNwoCbDgLAmw5CgYAAnAwAQJwMQICcDIDAmwwBAJsMQUCbDILBAACcDABAmwwAgJsMQMCbDIMAQACcDANBAACcDABAmwwAgJsMQMCbDIOCAACcDABAmwwAgJsMQMCbDIEAmwzBQJsNAYCbDUHAmw2DwkAAnAwAQJsMAICbDEDAmwyBAJsMwUCbDQGAmw1BwJsNggCbDcQBwACcDABAmwwAgJsMQMCbDIEAmwzBQJsNAYCbDURBwACcDABAmwwAgJsMQMCbDIEAmwzBQJsNAYCbDUSFQACcDABAnAxAgJsMAMCbDEEAmwyBQJsMwYCbDQHAmw1CAJsNgkCbDcKAmw4CwJsOQwDbDEwDQNsMTEOA2wxMg8DbDEzEANsMTQRA2wxNRIDbDE2EwNsMTcUA2wxOBMDAAJwMAECcDECAmwwFAQAAnAwAQJsMAICbDEDAmwyFQUAAnAwAQJsMAICbDEDAmwyBAJsMxYJAAJwMAECcDECAnAyAwJsMAQCbDEFAmwyBgJsMwcCbDQIAmw1FwMAAnAwAQJsMAICbDEYBQACcDABAmwwAgJsMQMCbDIEAmwzGQcAAnAwAQJwMQICcDIDAmwwBAJsMQUCbDIGAmwz" diff --git a/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/wasm.kt b/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/wasm.kt new file mode 100644 index 000000000..1357fc3fe --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/kscience/kmath/wasm/wasm.kt @@ -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 = + RealWasmBuilder(mst).instance + +/** + * Compiles an [MST] to WASM in the context of integers. + * + * @author Iaroslav Postovalov. + */ +public fun IntRing.expression(mst: MST): Expression = + IntWasmBuilder(mst).instance + +/** + * Optimizes performance of an [MstExpression] using WASM codegen in the context of reals. + * + * @author Iaroslav Postovalov. + */ +public fun MstExpression.compile(): Expression = + RealWasmBuilder(mst).instance + +/** + * Optimizes performance of an [MstExpression] using WASM codegen in the context of integers. + * + * @author Iaroslav Postovalov. + */ +public fun MstExpression.compile(): Expression = + IntWasmBuilder(mst).instance diff --git a/kmath-ast/src/jsMain/kotlin/lib.dom.WebAssembly.module_dukat.kt b/kmath-ast/src/jsMain/kotlin/lib.dom.WebAssembly.module_dukat.kt new file mode 100644 index 000000000..e2a1342b8 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/lib.dom.WebAssembly.module_dukat.kt @@ -0,0 +1,228 @@ +@file:JsQualifier("WebAssembly") + +@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 +import org.khronos.webgl.ArrayBufferView +import org.khronos.webgl.Uint8Array +import org.w3c.fetch.Response +import tsstdlib.PromiseLike +import kotlin.js.Promise + +@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") +external interface CompileError { + companion object { + var prototype: CompileError + } +} + +@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") +external interface Global { + var value: Any + fun valueOf(): Any + + companion object { + var prototype: Global + } +} + +@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") +@JsName("Instance") +external interface Instance1 { + var exports: Exports + + companion object { + var prototype: Instance + } +} + +@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") +external interface LinkError { + companion object { + var prototype: LinkError + } +} + +@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") +external interface Memory { + var buffer: ArrayBuffer + fun grow(delta: Number): Number + + companion object { + var prototype: Memory + } +} + +@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") +@JsName("Module") +external interface Module1 { + companion object { + var prototype: Module + fun customSections(moduleObject: Module, sectionName: String): Array + fun exports(moduleObject: Module): Array + fun imports(moduleObject: Module): Array + } +} + +@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") +external interface RuntimeError { + companion object { + var prototype: RuntimeError + } +} + +@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") +external interface Table { + var length: Number + fun get(index: Number): Function<*>? + fun grow(delta: Number): Number + fun set(index: Number, value: Function<*>?) + + companion object { + var prototype: Table + } +} + +external interface GlobalDescriptor { + var mutable: Boolean? + get() = definedExternally + set(value) = definedExternally + var value: String /* "f32" | "f64" | "i32" | "i64" */ +} + +external interface MemoryDescriptor { + var initial: Number + var maximum: Number? + get() = definedExternally + set(value) = definedExternally +} + +external interface ModuleExportDescriptor { + var kind: String /* "function" | "global" | "memory" | "table" */ + var name: String +} + +external interface ModuleImportDescriptor { + var kind: String /* "function" | "global" | "memory" | "table" */ + var module: String + var name: String +} + +external interface TableDescriptor { + var element: String /* "anyfunc" */ + var initial: Number + var maximum: Number? + get() = definedExternally + set(value) = definedExternally +} + +external interface WebAssemblyInstantiatedSource { + var instance: Instance + var module: Module +} + +external fun compile(bytes: ArrayBufferView): Promise + +external fun compile(bytes: ArrayBuffer): Promise + +external fun compileStreaming(source: Response): Promise + +external fun compileStreaming(source: Promise): Promise + +external fun instantiate( + bytes: ArrayBufferView, + importObject: Imports = definedExternally +): Promise + +external fun instantiate(bytes: ArrayBufferView): Promise + +external fun instantiate(bytes: ArrayBuffer, importObject: Imports = definedExternally): dynamic /* Promise | Promise */ + +external fun instantiate(bytes: ArrayBuffer): dynamic /* Promise | Promise */ + +external fun instantiate(moduleObject: Module, importObject: Imports = definedExternally): Promise + +external fun instantiate(moduleObject: Module): Promise + +external fun instantiateStreaming( + response: Response, + importObject: Imports = definedExternally +): Promise + +external fun instantiateStreaming(response: Response): Promise + +external fun instantiateStreaming( + response: PromiseLike, + importObject: Imports = definedExternally +): Promise + +external fun instantiateStreaming(response: PromiseLike): Promise + +external fun validate(bytes: ArrayBufferView): Boolean + +external fun validate(bytes: ArrayBuffer): Boolean + +external interface `T$0` { + var name: String + var kind: String +} + +external interface `T$1` { + var module: String + var name: String + var kind: String +} + +open external class Module { + constructor(bufferSource: ArrayBuffer) + constructor(bufferSource: Uint8Array) + + companion object { + fun customSections(module: Module, sectionName: String): Array + fun exports(module: Module): Array<`T$0`> + fun imports(module: Module): Array<`T$1`> + } +} + +@JsName("Instance") +open external class Instance(module: Module, importObject: Any = definedExternally) { + open var exports: Any +} + +@JsName("Memory") +open external class Memory1(memoryDescriptor: MemoryDescriptor) { + open var buffer: ArrayBuffer + open fun grow(numPages: Number): Number +} + +@JsName("Table") +open external class Table1(tableDescriptor: TableDescriptor) { + open var length: Number + open fun get(index: Number): Function<*> + open fun grow(numElements: Number): Number + open fun set(index: Number, value: Function<*>) +} + +external fun compile(bufferSource: Uint8Array): Promise + +external interface ResultObject { + var module: Module + var instance: Instance +} + +external fun instantiate(bufferSource: Uint8Array, importObject: Any = definedExternally): Promise + +external fun instantiate(bufferSource: Uint8Array): Promise + +external fun validate(bufferSource: Uint8Array): Boolean diff --git a/kmath-ast/src/jsMain/kotlin/lib.es2015.iterable.kt b/kmath-ast/src/jsMain/kotlin/lib.es2015.iterable.kt new file mode 100644 index 000000000..761e2e209 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/lib.es2015.iterable.kt @@ -0,0 +1,44 @@ +@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.Promise + +external interface IteratorYieldResult { + var done: Boolean? + get() = definedExternally + set(value) = definedExternally + var value: TYield +} + +external interface IteratorReturnResult { + var done: Boolean + var value: TReturn +} + +external interface Iterator { + fun next(vararg args: Any /* JsTuple<> | JsTuple */): dynamic /* IteratorYieldResult | IteratorReturnResult */ + val `return`: ((value: TReturn) -> dynamic)? + val `throw`: ((e: Any) -> dynamic)? +} + +typealias Iterator__1 = Iterator + +external interface Iterable + +external interface IterableIterator : Iterator__1 + +external interface PromiseConstructor { + var prototype: Promise + fun all(values: Any /* JsTuple | JsTuple | JsTuple | JsTuple | JsTuple | JsTuple | JsTuple | JsTuple | JsTuple */): Promise | JsTuple | JsTuple | JsTuple | JsTuple | JsTuple | JsTuple | JsTuple | JsTuple */> + fun all(values: Array */>): Promise> + fun race(values: Array): Promise + fun reject(reason: Any = definedExternally): Promise + fun resolve(value: T): Promise + fun resolve(value: PromiseLike): Promise + fun resolve(): Promise + fun all(values: Iterable */>): Promise> + fun race(values: Iterable): Promise + fun race(values: Iterable */>): Promise +} diff --git a/kmath-ast/src/jsMain/kotlin/lib.es5.kt b/kmath-ast/src/jsMain/kotlin/lib.es5.kt new file mode 100644 index 000000000..9bd4ee9c3 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/lib.es5.kt @@ -0,0 +1,73 @@ +@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 org.khronos.webgl.ArrayBuffer +import org.khronos.webgl.Uint8Array + +external interface FunctionConstructor { + @nativeInvoke + operator fun invoke(vararg args: String): Function<*> + var prototype: Function<*> +} + +external interface ErrorConstructor { + @nativeInvoke + operator fun invoke(message: String = definedExternally): Error + var prototype: Error +} + +external interface PromiseLike { + fun then( + onfulfilled: ((value: T) -> Any?)? = definedExternally, + onrejected: ((reason: Any) -> Any?)? = definedExternally + ): PromiseLike +} + +external interface ArrayLike { + var length: Number + + @nativeGetter + operator fun get(n: Number): T? + + @nativeSetter + operator fun set(n: Number, value: T) +} + +typealias Record = Any + +external interface ArrayBufferTypes { + var ArrayBuffer: ArrayBuffer +} + +external interface ArrayBufferConstructor { + var prototype: ArrayBuffer + fun isView(arg: Any): Boolean +} + +external interface Uint8ArrayConstructor { + fun from( + arrayLike: Iterable, + mapfn: (v: Number, k: Number) -> Number = definedExternally, + thisArg: Any = definedExternally + ): Uint8Array + + fun from(arrayLike: Iterable): Uint8Array + fun from(arrayLike: Iterable, 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): Uint8Array + + fun from( + arrayLike: ArrayLike, + mapfn: (v: T, k: Number) -> Number, + thisArg: Any = definedExternally + ): Uint8Array + + fun from(arrayLike: ArrayLike, mapfn: (v: T, k: Number) -> Number): Uint8Array +} diff --git a/kmath-ast/src/jsMain/kotlin/nonDeclarations.WebAssembly.kt b/kmath-ast/src/jsMain/kotlin/nonDeclarations.WebAssembly.kt new file mode 100644 index 000000000..4b8766922 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/nonDeclarations.WebAssembly.kt @@ -0,0 +1,32 @@ +@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", + "UnusedImport", "PackageDirectoryMismatch", "PackageName", "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", + "KDocMissingDocumentation" +) +package WebAssembly + +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 tsstdlib.Record + +typealias Exports = Record | Global | Memory | Table */> + +typealias ModuleImports = Record | Global | Memory | Table | Number */> + +typealias Imports = Record + +typealias CompileError1 = Error + +typealias LinkError1 = Error + +typealias RuntimeError1 = Error diff --git a/kmath-ast/src/jsMain/kotlin/wasm.d.ts b/kmath-ast/src/jsMain/kotlin/wasm.d.ts new file mode 100644 index 000000000..34a92f928 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/wasm.d.ts @@ -0,0 +1,2 @@ +import * as binaryen from "./index"; +export = binaryen; diff --git a/kmath-ast/src/jsMain/kotlin/webassembly.d.ts b/kmath-ast/src/jsMain/kotlin/webassembly.d.ts new file mode 100644 index 000000000..347ef08f5 --- /dev/null +++ b/kmath-ast/src/jsMain/kotlin/webassembly.d.ts @@ -0,0 +1,102 @@ +/** + * WebAssembly v1 (MVP) declaration file for TypeScript + * Definitions by: 01alchemist (https://twitter.com/01alchemist) + */ +declare namespace WebAssembly { + /** + * WebAssembly.Module + **/ + class Module { + constructor (bufferSource: ArrayBuffer | Uint8Array); + + static customSections(module: Module, sectionName: string): ArrayBuffer[]; + static exports(module: Module): { + name: string; + kind: string; + }[]; + static imports(module: Module): { + module: string; + name: string; + kind: string; + }[]; + } + + /** + * WebAssembly.Instance + **/ + class Instance { + readonly exports: any; + constructor (module: Module, importObject?: any); + } + + /** + * WebAssembly.Memory + * Note: A WebAssembly page has a constant size of 65,536 bytes, i.e., 64KiB. + **/ + interface MemoryDescriptor { + initial: number; + maximum?: number; + } + + class Memory { + readonly buffer: ArrayBuffer; + constructor (memoryDescriptor: MemoryDescriptor); + grow(numPages: number): number; + } + + /** + * WebAssembly.Table + **/ + interface TableDescriptor { + element: "anyfunc", + initial: number; + maximum?: number; + } + + class Table { + readonly length: number; + constructor (tableDescriptor: TableDescriptor); + get(index: number): Function; + grow(numElements: number): number; + set(index: number, value: Function): void; + } + + /** + * Errors + */ + class CompileError extends Error { + readonly fileName: string; + readonly lineNumber: string; + readonly columnNumber: string; + constructor (message?:string, fileName?:string, lineNumber?:number); + toString(): string; + } + + class LinkError extends Error { + readonly fileName: string; + readonly lineNumber: string; + readonly columnNumber: string; + constructor (message?:string, fileName?:string, lineNumber?:number); + toString(): string; + } + + class RuntimeError extends Error { + readonly fileName: string; + readonly lineNumber: string; + readonly columnNumber: string; + constructor (message?:string, fileName?:string, lineNumber?:number); + toString(): string; + } + + function compile(bufferSource: ArrayBuffer | Uint8Array): Promise; + + interface ResultObject { + module: Module; + instance: Instance; + } + + function instantiate(bufferSource: ArrayBuffer | Uint8Array, importObject?: any): Promise; + function instantiate(module: Module, importObject?: any): Promise; + + function validate(bufferSource: ArrayBuffer | Uint8Array): boolean; +} diff --git a/kmath-ast/src/jsTest/kotlin/Test.kt b/kmath-ast/src/jsTest/kotlin/Test.kt new file mode 100644 index 000000000..21f7efed0 --- /dev/null +++ b/kmath-ast/src/jsTest/kotlin/Test.kt @@ -0,0 +1,64 @@ +package kscience.kmath.ast + +import kscience.kmath.expressions.Expression +import kscience.kmath.expressions.StringSymbol +import kscience.kmath.expressions.invoke +import kscience.kmath.operations.IntRing +import kscience.kmath.operations.RealField +import kscience.kmath.wasm.compile +import kotlin.math.pow +import kotlin.random.Random +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.time.measureTime + +internal class Test { + @Test + fun int() { + val res = IntRing.mstInRing { number(100000000) + number(10000000) }.compile()() + assertEquals(110000000, res) + } + + @Test + fun real() { + val res = RealField.mstInExtendedField { number(100000000) + number(2).pow(10) }.compile()() + assertEquals(100001024.0, res) + } + + @Test + fun argsPassing() { + val res = RealField + .mstInExtendedField { symbol("y") + symbol("x").pow(10) } + .compile()("x" to 2.0, "y" to 100000000.0) + + assertEquals(100001024.0, res) + } + + @Test + fun powFunction() { + val expr = RealField.mstInExtendedField { symbol("x").pow(1.0 / 6.0) }.compile() + assertEquals(0.9730585187140817, expr("x" to 0.8488554755054833)) + } + + @Test + fun manyRuns() { + println("Compiled") + val times = 1_000_000 + var rng = Random(0) + var sum1 = 0.0 + var sum2 = 0.0 + var sum3 = 0.0 + val e2 = RealField.mstInExtendedField { symbol("x").pow(1.0 / 6.0) } + val e1 = e2.compile() + measureTime { repeat(times) { sum1 += e1("x" to rng.nextDouble()) } }.also(::println) + println("MST") + rng = Random(0) + measureTime { repeat(times) { sum2 += e2("x" to rng.nextDouble()) } }.also(::println) + val e3 = Expression { args -> args.getValue(StringSymbol("x")).pow(1.0 / 6.0) } + println("JS Math") + rng = Random(0) + measureTime { repeat(times) { sum3 += e3("x" to rng.nextDouble()) } }.also(::println) + assertEquals(sum1, sum2) + assertEquals(sum1, sum3) + } +} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt index 12a45615a..d00d8d8f9 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt @@ -49,7 +49,7 @@ public interface NumericAlgebra : Algebra { * Dynamic call of binary operation [operation] on [left] and [right] where right element is [Number]. */ public fun rightSideNumberOperation(operation: String, left: T, right: Number): T = - leftSideNumberOperation(operation, right, left) + binaryOperation(operation, left, number(right)) } /**