diff --git a/dist/asc.js b/dist/asc.js index 82474489..fd475f3a 100644 --- a/dist/asc.js +++ b/dist/asc.js @@ -1,2 +1,2 @@ -!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(function(){try{return require("assemblyscript")}catch(n){}}()):"function"==typeof define&&define.amd?define(["assemblyscript"],e):"object"==typeof exports?exports.asc=e(function(){try{return require("assemblyscript")}catch(n){}}()):n.asc=e(n.assemblyscript)}("undefined"!=typeof self?self:this,function(__WEBPACK_EXTERNAL_MODULE__10__){return function(n){var e={};function t(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return n[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var i in n)t.d(r,i,function(e){return n[e]}.bind(null,i));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=4)}([function(n,e,t){var r,i;e.nextTick=function(n){setTimeout(n,0)},e.platform=e.arch=e.execPath=e.title="browser",e.pid=1,e.browser=!0,e.env={},e.argv=[],e.binding=function(n){throw new Error("No such module. (Possibly not yet loaded)")},i="/",e.cwd=function(){return i},e.chdir=function(n){r||(r=t(1)),i=r.resolve(n,i)},e.exit=e.kill=e.umask=e.dlopen=e.uptime=e.memoryUsage=e.uvCounters=function(){},e.features={}},function(n,e,t){(function(n){function t(n,e){for(var t=0,r=n.length-1;r>=0;r--){var i=n[r];"."===i?n.splice(r,1):".."===i?(n.splice(r,1),t++):t&&(n.splice(r,1),t--)}if(e)for(;t--;t)n.unshift("..");return n}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(n){return r.exec(n).slice(1)};function o(n,e){if(n.filter)return n.filter(e);for(var t=[],r=0;r=-1&&!r;i--){var a=i>=0?arguments[i]:n.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,r="/"===a.charAt(0))}return(r?"/":"")+(e=t(o(e.split("/"),function(n){return!!n}),!r).join("/"))||"."},e.normalize=function(n){var r=e.isAbsolute(n),i="/"===a(n,-1);return(n=t(o(n.split("/"),function(n){return!!n}),!r).join("/"))||r||(n="."),n&&i&&(n+="/"),(r?"/":"")+n},e.isAbsolute=function(n){return"/"===n.charAt(0)},e.join=function(){var n=Array.prototype.slice.call(arguments,0);return e.normalize(o(n,function(n,e){if("string"!=typeof n)throw new TypeError("Arguments to path.join must be strings");return n}).join("/"))},e.relative=function(n,t){function r(n){for(var e=0;e=0&&""===n[t];t--);return e>t?[]:n.slice(e,t-e+1)}n=e.resolve(n).substr(1),t=e.resolve(t).substr(1);for(var i=r(n.split("/")),o=r(t.split("/")),a=Math.min(i.length,o.length),s=a,l=0;l{try{assemblyscript=__webpack_require__(10)}catch(e){try{__webpack_require__(!function(){var n=new Error("Cannot find module 'ts-node'");throw n.code="MODULE_NOT_FOUND",n}()).register({project:path.join(".","..","src","tsconfig.json")}),__webpack_require__(!function(){var n=new Error("Cannot find module '../src/glue/js'");throw n.code="MODULE_NOT_FOUND",n}()),assemblyscript=__webpack_require__(!function(){var n=new Error("Cannot find module '../src'");throw n.code="MODULE_NOT_FOUND",n}()),isDev=!0}catch(e_ts){try{assemblyscript=eval("require('./assemblyscript')")}catch(n){throw n.stack=e_ts.stack+"\n---\n"+n.stack,n}}}})(),exports.isBundle=!0,exports.isDev=isDev,exports.version=exports.isBundle?"0.7.0":__webpack_require__(!function(){var n=new Error("Cannot find module '../package.json'");throw n.code="MODULE_NOT_FOUND",n}()).version,exports.options=__webpack_require__(11),exports.sourceMapRoot="assemblyscript:///",exports.libraryPrefix=assemblyscript.LIBRARY_PREFIX,exports.defaultOptimizeLevel=3,exports.defaultShrinkLevel=1,exports.libraryFiles=exports.isBundle?Object({array:'/// \n\nimport { BLOCK_MAXSIZE } from "./rt/common";\nimport { COMPARATOR, SORT } from "./util/sort";\nimport { ArrayBuffer, ArrayBufferView } from "./arraybuffer";\nimport { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./util/number";\nimport { idof, isArray as builtin_isArray } from "./builtins";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";\n\n/** Ensures that the given array has _at least_ the specified backing size. */\nfunction ensureSize(array: usize, minSize: usize, alignLog2: u32): void {\n var oldCapacity = changetype(array).dataLength;\n if (minSize > oldCapacity >>> alignLog2) {\n if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n let oldData = changetype(changetype(array).data);\n let newCapacity = minSize << alignLog2;\n let newData = __realloc(oldData, newCapacity);\n memory.fill(newData + oldCapacity, 0, newCapacity - oldCapacity);\n if (newData !== oldData) { // oldData has been free\'d\n store(changetype(array), __retain(newData), offsetof("data"));\n changetype(array).dataStart = newData;\n }\n changetype(array).dataLength = newCapacity;\n }\n}\n\nexport class Array extends ArrayBufferView {\n [key: number]: T;\n\n // Implementing ArrayBufferView isn\'t strictly necessary here but is done to allow glue code\n // to work with typed and normal arrays interchangeably. Technically, normal arrays do not need\n // `dataStart` (equals `data`) and `dataLength` (equals computed `data.byteLength`).\n\n // Also note that Array with non-nullable T must guard against implicit null values whenever\n // length is modified in a way that a null value would exist. Otherwise, the compiler wouldn\'t be\n // able to guarantee type-safety anymore. For lack of a better word, such an array is "holey".\n\n private length_: i32;\n\n static isArray(value: U): bool {\n return builtin_isArray(value) && value !== null;\n }\n\n static create(capacity: i32 = 0): Array {\n if (capacity > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH);\n var array = changetype>(__allocArray(capacity, alignof(), idof())); // retains\n changetype>(array).length_ = 0; // safe even if T is a non-nullable reference\n memory.fill(array.dataStart, 0, array.dataLength);\n return array;\n }\n\n constructor(length: i32 = 0) {\n super(length, alignof());\n if (isReference()) {\n if (!isNullable()) {\n if (length) throw new Error(E_HOLEYARRAY);\n }\n }\n this.length_ = length;\n }\n\n @unsafe get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.length_;\n }\n\n set length(length: i32) {\n if (isReference()) {\n if (!isNullable()) {\n if (length > this.length_) throw new Error(E_HOLEYARRAY);\n }\n }\n ensureSize(changetype(this), length, alignof());\n this.length_ = length;\n }\n\n every(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (!callbackfn(load(this.dataStart + (index << alignof())), index, this)) return false;\n }\n return true;\n }\n\n findIndex(predicate: (element: T, index: i32, array: Array) => bool): i32 {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (predicate(load(this.dataStart + (index << alignof())), index, this)) return index;\n }\n return -1;\n }\n\n @operator("[]") private __get(index: i32): T {\n if (isReference()) {\n if (!isNullable()) {\n if (index >= this.length_) throw new Error(E_HOLEYARRAY);\n }\n }\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_get(index);\n }\n\n @operator("{}") private __unchecked_get(index: i32): T {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") private __set(index: i32, value: T): void {\n var length = this.length_;\n if (isReference()) {\n if (!isNullable()) {\n if (index > length) throw new Error(E_HOLEYARRAY);\n }\n }\n ensureSize(changetype(this), index + 1, alignof());\n this.__unchecked_set(index, value);\n if (index >= length) this.length_ = index + 1;\n }\n\n @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = this.dataStart + (index << alignof());\n let oldRef: usize = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n store(this.dataStart + (index << alignof()), value);\n }\n }\n\n fill(value: T, start: i32 = 0, end: i32 = i32.MAX_VALUE): this {\n var dataStart = this.dataStart;\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n end = end < 0 ? max(length + end, 0) : min(end, length);\n if (sizeof() == 1) {\n if (start < end) {\n memory.fill(\n dataStart + start,\n u8(value),\n (end - start)\n );\n }\n } else {\n for (; start < end; ++start) {\n store(dataStart + (start << alignof()), value);\n }\n }\n return this;\n }\n\n includes(searchElement: T, fromIndex: i32 = 0): bool {\n return this.indexOf(searchElement, fromIndex) >= 0;\n }\n\n indexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n var length = this.length_;\n if (length == 0 || fromIndex >= length) return -1;\n if (fromIndex < 0) fromIndex = max(length + fromIndex, 0);\n var dataStart = this.dataStart;\n while (fromIndex < length) {\n if (load(dataStart + (fromIndex << alignof())) == searchElement) return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(searchElement: T, fromIndex: i32 = this.length_): i32 {\n var length = this.length_;\n if (length == 0) return -1;\n if (fromIndex < 0) fromIndex = length + fromIndex;\n else if (fromIndex >= length) fromIndex = length - 1;\n var dataStart = this.dataStart;\n while (fromIndex >= 0) {\n if (load(dataStart + (fromIndex << alignof())) == searchElement) return fromIndex;\n --fromIndex;\n }\n return -1;\n }\n\n push(value: T): i32 {\n var length = this.length_;\n var newLength = length + 1;\n ensureSize(changetype(this), newLength, alignof());\n if (isManaged()) {\n let offset = this.dataStart + (length << alignof());\n let oldRef: usize = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n store(this.dataStart + (length << alignof()), value);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n concat(other: Array): Array {\n var thisLen = this.length_;\n var otherLen = select(0, other.length_, other === null);\n var outLen = thisLen + otherLen;\n if (outLen > BLOCK_MAXSIZE >>> alignof()) throw new Error(E_INVALIDLENGTH);\n var out = changetype>(__allocArray(outLen, alignof(), idof>())); // retains\n var outStart = out.dataStart;\n var thisSize = thisLen << alignof();\n if (isManaged()) {\n let thisStart = this.dataStart;\n for (let offset: usize = 0; offset < thisSize; offset += sizeof()) {\n let ref = load(thisStart + offset);\n store(outStart + offset, __retain(ref));\n }\n outStart += thisSize;\n let otherStart = other.dataStart;\n let otherSize = otherLen << alignof();\n for (let offset: usize = 0; offset < otherSize; offset += sizeof()) {\n let ref = load(otherStart + offset);\n store(outStart + offset, __retain(ref));\n }\n } else {\n memory.copy(outStart, this.dataStart, thisSize);\n memory.copy(outStart + thisSize, other.dataStart, otherLen << alignof());\n }\n return out;\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): this {\n var dataStart = this.dataStart;\n var len = this.length_;\n\n end = min(end, len);\n var to = target < 0 ? max(len + target, 0) : min(target, len);\n var from = start < 0 ? max(len + start, 0) : min(start, len);\n var last = end < 0 ? max(len + end, 0) : min(end, len);\n var count = min(last - from, len - to);\n\n if (from < to && to < (from + count)) {\n from += count - 1;\n to += count - 1;\n while (count) {\n store(dataStart + (to << alignof()), load(dataStart + (from << alignof())));\n --from, --to, --count;\n }\n } else {\n memory.copy(\n dataStart + (to << alignof()),\n dataStart + (from << alignof()),\n count << alignof()\n );\n }\n return this;\n }\n\n pop(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError(E_EMPTYARRAY);\n var element = load(this.dataStart + ((--length) << alignof()));\n this.length_ = length;\n return element;\n }\n\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n callbackfn(load(this.dataStart + (index << alignof())), index, this);\n }\n }\n\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array {\n var length = this.length_;\n var out = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var outStart = out.dataStart;\n for (let index = 0; index < min(length, this.length_); ++index) {\n let result = callbackfn(load(this.dataStart + (index << alignof())), index, this); // retains\n if (isManaged()) {\n store(outStart + (index << alignof()), __retain(changetype(result)));\n } else {\n store(outStart + (index << alignof()), result);\n }\n // releases result\n }\n return out;\n }\n\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array {\n var result = changetype>(__allocArray(0, alignof(), idof>())); // retains\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n let value = load(this.dataStart + (index << alignof()));\n if (callbackfn(value, index, this)) result.push(value);\n }\n return result;\n }\n\n reduce(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n accum = callbackfn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n reduceRight(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = this.length_ - 1; index >= 0; --index) {\n accum = callbackfn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n shift(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError(E_EMPTYARRAY);\n var base = this.dataStart;\n var element = load(base);\n var lastIndex = length - 1;\n memory.copy(\n base,\n base + sizeof(),\n lastIndex << alignof()\n );\n store(base + (lastIndex << alignof()),\n // @ts-ignore: cast\n null\n );\n this.length_ = lastIndex;\n return element;\n }\n\n some(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (callbackfn(load(this.dataStart + (index << alignof())), index, this)) return true;\n }\n return false;\n }\n\n unshift(element: T): i32 {\n var newLength = this.length_ + 1;\n ensureSize(changetype(this), newLength, alignof());\n var dataStart = this.dataStart;\n memory.copy(\n dataStart + sizeof(),\n dataStart,\n (newLength - 1) << alignof()\n );\n if (isManaged()) {\n store(dataStart, __retain(changetype(element)));\n } else {\n store(dataStart, element);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n begin = begin < 0 ? max(begin + length, 0) : min(begin, length);\n end = end < 0 ? max(end + length, 0) : min(end , length);\n length = max(end - begin, 0);\n var slice = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var sliceBase = slice.dataStart;\n var thisBase = this.dataStart + (begin << alignof());\n if (isManaged()) {\n let off = 0;\n let end = length << alignof();\n while (off < end) {\n let ref = load(thisBase + off);\n store(sliceBase + off, __retain(ref));\n off += sizeof();\n }\n } else {\n memory.copy(sliceBase, thisBase, length << alignof());\n }\n return slice;\n }\n\n splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n deleteCount = max(min(deleteCount, length - start), 0);\n var result = changetype>(__allocArray(deleteCount, alignof(), idof>())); // retains\n var resultStart = result.dataStart;\n var thisStart = this.dataStart;\n var thisBase = thisStart + (start << alignof());\n if (isManaged()) {\n for (let i = 0; i < deleteCount; ++i) {\n store(resultStart + (i << alignof()),\n load(thisBase + (i << alignof()))\n );\n // element is moved, so refcount doesn\'t change\n }\n } else {\n memory.copy(\n resultStart,\n thisBase,\n deleteCount << alignof()\n );\n }\n var offset = start + deleteCount;\n if (length != offset) {\n memory.copy(\n thisBase,\n thisStart + (offset << alignof()),\n (length - offset) << alignof()\n );\n }\n this.length_ = length - deleteCount;\n return result;\n }\n\n reverse(): Array {\n var length = this.length_;\n if (length) {\n let front = this.dataStart;\n let back = this.dataStart + ((length - 1) << alignof());\n while (front < back) {\n let temp = load(front);\n store(front, load(back));\n store(back, temp);\n front += sizeof();\n back -= sizeof();\n }\n }\n return this;\n }\n\n sort(comparator: (a: T, b: T) => i32 = COMPARATOR()): this {\n var length = this.length_;\n if (length <= 1) return this;\n var base = this.dataStart;\n if (length == 2) {\n let a: T = load(base, sizeof()); // a = arr[1]\n let b: T = load(base); // b = arr[0]\n if (comparator(a, b) < 0) {\n store(base, b, sizeof()); // arr[1] = b;\n store(base, a); // arr[0] = a;\n }\n return this;\n }\n SORT(base, length, comparator);\n return this;\n }\n\n join(separator: string = ","): string {\n if (isBoolean()) return this.join_bool(separator);\n if (isInteger()) return this.join_int(separator);\n if (isFloat()) return this.join_flt(separator);\n if (isString()) return this.join_str(separator);\n if (isArray()) return this.join_arr(separator);\n if (isReference()) return this.join_ref(separator);\n ERROR("unspported element type");\n return unreachable();\n }\n\n private join_bool(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) return select("true", "false", load(dataStart));\n\n var sepLen = separator.length;\n var valueLen = 5; // max possible length of element len("false")\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: bool;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + i);\n valueLen = 4 + i32(!value);\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(select("true", "false", value)),\n valueLen << 1\n );\n offset += valueLen;\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + lastIndex);\n valueLen = 4 + i32(!value);\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(select("true", "false", value)),\n valueLen << 1\n );\n offset += valueLen;\n\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_int(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n // @ts-ignore: type\n if (!lastIndex) return changetype(itoa(load(dataStart))); // retains\n\n var sepLen = separator.length;\n const valueLen = (sizeof() <= 4 ? 10 : 20) + i32(isSigned());\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n // @ts-ignore: type\n offset += itoa_stream(changetype(result), offset, value);\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n // @ts-ignore: type\n offset += itoa_stream(changetype(result), offset, value);\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_flt(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) {\n return changetype(dtoa(\n // @ts-ignore: type\n load(dataStart))\n ); // retains\n }\n\n const valueLen = MAX_DOUBLE_LENGTH;\n var sepLen = separator.length;\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n offset += dtoa_stream(changetype(result), offset,\n // @ts-ignore: type\n value\n );\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n offset += dtoa_stream(changetype(result), offset,\n // @ts-ignore: type\n value\n );\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_str(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) return load(dataStart);\n\n var sepLen = separator.length;\n var estLen = 0;\n var value: string | null;\n for (let i = 0, len = lastIndex + 1; i < len; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) estLen += value.length;\n }\n var offset = 0;\n var result = changetype(__alloc((estLen + sepLen * lastIndex) << 1, idof())); // retains\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) {\n let valueLen = changetype(value).length;\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(value),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n if (value !== null) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(value),\n changetype(value).length << 1\n );\n }\n return result;\n }\n\n private join_arr(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n\n var result = "";\n var sepLen = separator.length;\n var base = this.dataStart;\n var value: T;\n if (!lastIndex) {\n value = load(base);\n // @ts-ignore: type\n return value ? value.join(separator) : "";\n }\n for (let i = 0; i < lastIndex; ++i) {\n value = load(base + (i << alignof()));\n // @ts-ignore: type\n if (value) result += value.join(separator);\n if (sepLen) result += separator;\n }\n value = load(base + (lastIndex << alignof()));\n // @ts-ignore: type\n if (value) result += value.join(separator);\n return result; // registered by concatenation (FIXME: lots of garbage)\n }\n\n private join_ref(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var base = this.dataStart;\n if (!lastIndex) return "[object Object]";\n\n const valueLen = 15; // max possible length of element len("[object Object]")\n var sepLen = separator.length;\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof()));\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(base + (i << alignof()));\n if (value) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype("[object Object]"),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n if (load(base + (lastIndex << alignof()))) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype("[object Object]"),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n toString(): string {\n return this.join();\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n if (isManaged()) {\n let cur = this.dataStart;\n let end = cur + this.dataLength;\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n // automatically visits ArrayBufferView (.data) next\n }\n}\n',arraybuffer:'/// \n\nimport { BLOCK, BLOCK_MAXSIZE, BLOCK_OVERHEAD } from "./rt/common";\nimport { idof } from "./builtins";\nimport { E_INVALIDLENGTH } from "./util/error";\n\nexport abstract class ArrayBufferView {\n\n @unsafe data: ArrayBuffer;\n @unsafe dataStart: usize;\n @unsafe dataLength: u32;\n\n protected constructor(length: i32, alignLog2: i32) {\n if (length > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n var buffer = __alloc(length = length << alignLog2, idof());\n this.data = changetype(buffer); // retains\n this.dataStart = buffer;\n this.dataLength = length;\n }\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.data));\n }\n\n get byteLength(): i32 {\n return this.dataLength;\n }\n\n get length(): i32 {\n ERROR("missing implementation: subclasses must implement ArrayBufferView#length");\n return unreachable();\n }\n}\n\n@sealed export class ArrayBuffer {\n\n static isView(value: T): bool {\n if (value) {\n if (value instanceof Int8Array) return true;\n if (value instanceof Uint8Array) return true;\n if (value instanceof Uint8ClampedArray) return true;\n if (value instanceof Int16Array) return true;\n if (value instanceof Uint16Array) return true;\n if (value instanceof Int32Array) return true;\n if (value instanceof Uint32Array) return true;\n if (value instanceof Int64Array) return true;\n if (value instanceof Uint64Array) return true;\n if (value instanceof Float32Array) return true;\n if (value instanceof Float64Array) return true;\n if (value instanceof DataView) return true;\n }\n return false;\n }\n\n constructor(length: i32) {\n if (length > BLOCK_MAXSIZE) throw new RangeError(E_INVALIDLENGTH);\n var buffer = __alloc(length, idof());\n memory.fill(buffer, 0, length);\n return changetype(buffer); // retains\n }\n\n get byteLength(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize;\n }\n\n slice(begin: i32 = 0, end: i32 = BLOCK_MAXSIZE): ArrayBuffer {\n var length = this.byteLength;\n begin = begin < 0 ? max(length + begin, 0) : min(begin, length);\n end = end < 0 ? max(length + end , 0) : min(end , length);\n var outSize = max(end - begin, 0);\n var out = __alloc(outSize, idof());\n memory.copy(out, changetype(this) + begin, outSize);\n return changetype(out); // retains\n }\n\n toString(): string {\n return "[object ArrayBuffer]";\n }\n}\n',"bindings/Date":"export declare function UTC(\n // NOTE: Using i32 below saves us a f64.convert_s instruction and moves the responsibility for\n // converting the value to the WASM/JS boundary.\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: f64\n): f64;\nexport declare function now(): f64;\n","bindings/Math":"export declare const E: f64;\nexport declare const LN2: f64;\nexport declare const LN10: f64;\nexport declare const LOG2E: f64;\nexport declare const LOG10E: f64;\nexport declare const PI: f64;\nexport declare const SQRT1_2: f64;\nexport declare const SQRT2: f64;\n\nexport declare function abs(x: f64): f64;\nexport declare function acos(x: f64): f64;\nexport declare function acosh(x: f64): f64;\nexport declare function asin(x: f64): f64;\nexport declare function asinh(x: f64): f64;\nexport declare function atan(x: f64): f64;\nexport declare function atan2(y: f64, x: f64): f64;\nexport declare function atanh(x: f64): f64;\nexport declare function cbrt(x: f64): f64;\nexport declare function ceil(x: f64): f64;\nexport declare function clz32(x: f64): f64;\nexport declare function cos(x: f64): f64;\nexport declare function cosh(x: f64): f64;\nexport declare function exp(x: f64): f64;\nexport declare function expm1(x: f64): f64;\nexport declare function floor(x: f64): f64;\nexport declare function fround(x: f64): f32;\nexport declare function hypot(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function imul(a: f64, b: f64): f64;\nexport declare function log(x: f64): f64;\nexport declare function log10(x: f64): f64;\nexport declare function log1p(x: f64): f64;\nexport declare function log2(x: f64): f64;\nexport declare function max(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function min(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function pow(base: f64, exponent: f64): f64;\nexport declare function random(): f64;\nexport declare function round(x: f64): f64;\nexport declare function sign(x: f64): f64;\nexport declare function sin(x: f64): f64;\nexport declare function sinh(x: f64): f64;\nexport declare function sqrt(x: f64): f64;\nexport declare function tan(x: f64): f64;\nexport declare function tanh(x: f64): f64;\nexport declare function trunc(x: f64): f64;\n","bindings/wasi_unstable":"// see: https://wasi.dev\n\n/* tslint:disable:max-line-length */\n\n// helper types to be more explicit\ntype char = u8;\ntype ptr = usize; // all pointers are usize'd\ntype struct = T; // structs are references already in AS\n\n/** Read command-line argument data. */\nexport declare function args_get(\n /** Input: Pointer to a buffer to write the argument pointers. */\n argv: ptr>,\n /** Input: Pointer to a buffer to write the argument string data. */\n argv_buf: ptr\n): errno;\n\n/** Return command-line argument data sizes. */\nexport declare function args_sizes_get(\n /** Output: Number of arguments. */\n argc: ptr,\n /** Output: Size of the argument string data. */\n argv_buf_size: ptr\n): errno;\n\n/** Return the resolution of a clock. */\nexport declare function clock_res_get(\n /** Input: The clock for which to return the resolution. */\n clock: clockid,\n /** Output: The resolution of the clock. */\n resolution: ptr\n): errno;\n\n/** Return the time value of a clock. */\nexport declare function clock_time_get(\n /** Input: Cock for which to return the time. */\n clock: clockid,\n /** Input: Maximum lag (exclusive) that the returned time value may have, compared to its actual value. */\n precision: timestamp,\n /** Output: Time value of the clock. */\n time: ptr\n): errno;\n\n/** Read environment variable data. */\nexport declare function environ_get(\n /** Input: Pointer to a buffer to write the environment variable pointers. */\n environ: ptr,\n /** Input: Pointer to a buffer to write the environment variable string data. */\n environ_buf: usize\n): errno;\n\n/** Return command-line argument data sizes. */\nexport declare function environ_sizes_get(\n /** Output: The number of environment variables. */\n environ_count: ptr,\n /** Output: The size of the environment variable string data. */\n environ_buf_size: ptr\n): errno;\n\n/** Provide file advisory information on a file descriptor. */\nexport declare function fd_advise(\n /** Input: The file descriptor for the file for which to provide file advisory information. */\n fd: fd,\n /** Input: The offset within the file to which the advisory applies. */\n offset: filesize,\n /** Input: The length of the region to which the advisory applies. */\n len: filesize,\n /** Input: The advice. */\n advice: advice\n): errno;\n\n/** Provide file advisory information on a file descriptor. */\nexport declare function fd_allocate(\n /** Input: The file descriptor for the file in which to allocate space. */\n fd: fd,\n /** Input: The offset at which to start the allocation. */\n offset: filesize,\n /** Input: The length of the area that is allocated. */\n len: filesize\n): errno;\n\n/** Close a file descriptor. */\nexport declare function fd_close(\n /** Input: The file descriptor to close. */\n fd: fd\n): errno;\n\n/** Synchronize the data of a file to disk. */\nexport declare function fd_datasync(\n /** Input: The file descriptor of the file to synchronize to disk. */\n fd: fd\n): errno;\n\n/** Get the attributes of a file descriptor. */\nexport declare function fd_fdstat_get(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Input: The buffer where the file descriptor's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the flags associated with a file descriptor. */\nexport declare function fd_fdstat_set_flags(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired values of the file descriptor flags. */\n flags: fdflags\n): errno;\n\n/** Adjust the rights associated with a file descriptor. */\nexport declare function fd_fdstat_set_rights(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired rights of the file descriptor. */\n fs_rights_base: rights,\n /** Input: The desired rights of the file descriptor. */\n fs_rights_inheriting: rights\n): errno;\n\n/** Return the attributes of an open file. */\nexport declare function fd_filestat_get(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Input: The buffer where the file's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros. */\nexport declare function fd_filestat_set_size(\n /** Input: A file descriptor for the file to adjust. */\n fd: fd,\n /** Input: The desired file size. */\n size: filesize\n): errno;\n\n/** Adjust the timestamps of an open file or directory. */\nexport declare function fd_filestat_set_times(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired values of the data access timestamp. */\n st_atim: timestamp,\n /** Input: The desired values of the data modification timestamp. */\n st_mtim: timestamp,\n /** Input: A bitmask indicating which timestamps to adjust. */\n fstflags: fstflags\n): errno;\n\n/** Read from a file descriptor, without using and updating the file descriptor's offset. */\nexport declare function fd_pread(\n /** Input: The file descriptor from which to read data. */\n fd: fd,\n /** Input: List of scatter/gather vectors in which to store data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors in which to store data. */\n iovs_len: usize,\n /** Input: The offset within the file at which to read. */\n offset: filesize,\n /** Output: The number of bytes read. */\n nread: ptr\n): errno;\n\n/** Return a description of the given preopened file descriptor. */\nexport declare function fd_prestat_get(\n /** Input: The file descriptor about which to retrieve information. */\n fd: fd,\n /** Input: The buffer where the description is stored. */\n buf: struct\n): errno;\n\n/** Return a description of the given preopened file descriptor. */\nexport declare function fd_prestat_dir_name(\n /** Input: The file descriptor about which to retrieve information. */\n fd: fd,\n /** Input: Buffer into which to write the preopened directory name. */\n path: ptr,\n /** Input: Length of the buffer into which to write the preopened directory name. */\n path_len: usize\n): errno;\n\n/** Write to a file descriptor, without using and updating the file descriptor's offset. */\nexport declare function fd_pwrite(\n /** Input: The file descriptor to which to write data. */\n fd: fd,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors from which to retrieve data. */\n iovs_len: usize,\n /** Input: The offset within the file at which to write. */\n offset: filesize,\n /** Output: The number of bytes written. */\n nwritten: ptr\n): errno;\n\n/** Read from a file descriptor. */\nexport declare function fd_read(\n /** Input: The file descriptor from which to read data. */\n fd: fd,\n /** Input: List of scatter/gather vectors to which to store data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors to which to store data. */\n iovs_len: usize,\n /** Output: The number of bytes read. */\n nread: ptr\n): errno;\n\n/** Read directory entries from a directory. */\nexport declare function fd_readdir(\n /** Input: Directory from which to read the directory entries. */\n fd: fd,\n /** Input: Buffer where directory entries are stored. */\n buf: ptr>,\n /** Input: Length of the buffer where directory entries are stored. */\n buf_len: usize,\n /** Input: Location within the directory to start reading. */\n cookie: dircookie,\n /** Output: Number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached. */\n buf_used: ptr\n): errno;\n\n/** Atomically replace a file descriptor by renumbering another file descriptor. */\nexport declare function fd_renumber(\n /** Input: The file descriptor to renumber. */\n from: fd,\n /** Input: The file descriptor to overwrite. */\n to: fd\n): errno;\n\n/** Move the offset of a file descriptor. */\nexport declare function fd_seek(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The number of bytes to move. */\n offset: filedelta,\n /** Input: The base from which the offset is relative. */\n whence: whence,\n /** Output: The new offset of the file descriptor, relative to the start of the file. */\n newoffset: ptr\n): errno;\n\n/** Synchronize the data and metadata of a file to disk. */\nexport declare function fd_sync(\n /** Input: The file descriptor of the file containing the data and metadata to synchronize to disk. */\n fd: fd\n): errno;\n\n/** Return the current offset of a file descriptor. */\nexport declare function fd_tell(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Output: The current offset of the file descriptor, relative to the start of the file. */\n newoffset: ptr\n): errno;\n\n/** Write to a file descriptor. */\nexport declare function fd_write(\n /** Input: The file descriptor to which to write data. */\n fd: fd,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs: ptr>,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs_len: usize,\n /** Output: The number of bytes written. */\n nwritten: ptr\n): errno;\n\n/* Create a directory. */\nexport declare function path_create_directory(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path at which to create the directory. */\n path: ptr,\n /** Input: The path at which to create the directory. */\n path_len: usize\n): errno;\n\n/** Return the attributes of a file or directory. */\nexport declare function path_filestat_get(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n flags: lookupflags,\n /** Input: The path of the file or directory to inspect. */\n path: ptr,\n /** Input: The path of the file or directory to inspect. */\n path_len: usize,\n /** Input: The buffer where the file's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the timestamps of a file or directory. */\nexport declare function path_filestat_set_times(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n flags: lookupflags,\n /** Input: The path of the file or directory to operate on. */\n path: ptr,\n /** Input: The path of the file or directory to operate on. */\n path_len: usize,\n /** Input: The desired values of the data access timestamp. */\n st_atim: timestamp,\n /** Input: The desired values of the data modification timestamp. */\n st_mtim: timestamp,\n /** Input: A bitmask indicating which timestamps to adjust. */\n fstflags: fstflags\n): errno;\n\n/** Create a hard link. */\nexport declare function path_link(\n /** Input: The working directory at which the resolution of the old path starts. */\n old_fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n old_flags: lookupflags,\n /** Input: The source path from which to link. */\n old_path: ptr,\n /** Input: The source path from which to link. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the new path starts. */\n new_fd: fd,\n /** Input: The destination path at which to create the hard link. */\n new_path: ptr,\n /** Input: The length of the destination path at which to create the hard link. */\n new_path_len: usize\n): errno;\n\n/** Open a file or directory. */\nexport declare function path_open(\n /** Input: The working directory at which the resolution of the path starts. */\n dirfd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n dirflags: lookupflags,\n /** Input: The path of the file or directory to open. */\n path: ptr,\n /** Input: The length of the path of the file or directory to open. */\n path_len: usize,\n /** Input: The method by which to open the file. */\n oflags: oflags,\n /** Input: The initial base rights that apply to operations using the file descriptor itself. */\n fs_rights_base: rights,\n /** Input: The initial inheriting rights that apply to file descriptors derived from it. */\n fs_rights_inheriting: rights,\n /** Input: The initial flags of the file descriptor. */\n fs_flags: fdflags,\n /** Output: The file descriptor of the file that has been opened. */\n fd: ptr\n): errno;\n\n/** Read the contents of a symbolic link. */\nexport declare function path_readlink(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path of the symbolic link from which to read. */\n path: ptr,\n /** Input: The length of the path of the symbolic link from which to read. */\n path_len: usize,\n /** Input: The buffer to which to write the contents of the symbolic link. */\n buf: ptr,\n /** Input: The length of the buffer to which to write the contents of the symbolic link. */\n buf_len: usize,\n /** Output: The number of bytes placed in the buffer. */\n buf_used: ptr\n): errno;\n\n/** Remove a directory. */\nexport declare function path_remove_directory(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path to a directory to remove. */\n path: ptr,\n /** Input: The length of the path to a directory to remove. */\n path_len: usize\n): errno;\n\n/** Rename a file or directory. */\nexport declare function path_rename(\n /** Input: The working directory at which the resolution of the old path starts. */\n old_fd: fd,\n /** Input: The source path of the file or directory to rename. */\n old_path: ptr,\n /** Input: The length of the source path of the file or directory to rename. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the new path starts. */\n new_fd: fd,\n /** Input: The destination path to which to rename the file or directory. */\n new_path: ptr,\n /** Input: The length of the destination path to which to rename the file or directory. */\n new_path_len: usize\n): errno;\n\n/** Create a symbolic link. */\nexport declare function path_symlink(\n /** Input: The contents of the symbolic link. */\n old_path: ptr,\n /** Input: The length of the contents of the symbolic link. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The destination path at which to create the symbolic link. */\n new_path: ptr,\n /** Input: The length of the destination path at which to create the symbolic link. */\n new_path_len: usize\n): errno;\n\n/** Unlink a file. */\nexport declare function path_unlink_file(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path to a file to unlink. */\n path: ptr,\n /** Input: The length of the path to a file to unlink. */\n path_len: usize\n): errno;\n\n/** Concurrently poll for the occurrence of a set of events. */\nexport declare function poll_oneoff(\n /** Input: The events to which to subscribe. */\n in_: ptr>,\n /** Input: The events that have occurred. */\n out: ptr>,\n /** Input: Both the number of subscriptions and events. */\n nsubscriptions: usize,\n /** Output: The number of events stored. */\n nevents: ptr\n): errno;\n\n/** Terminate the process normally. An exit code of 0 indicates successful termination of the program. The meanings of other values is dependent on the environment. */\nexport declare function proc_exit(\n /** Input: The exit code returned by the process. */\n rval: u32\n): void;\n\n/** Send a signal to the process of the calling thread. */\nexport declare function proc_raise(\n /** Input: The signal condition to trigger. */\n sig: signal\n): errno;\n\n/** Write high-quality random data into a buffer. */\nexport declare function random_get(\n /** Input: The buffer to fill with random data. */\n buf: usize,\n /** Input: The length of the buffer to fill with random data. */\n buf_len: usize\n): errno;\n\n/** Temporarily yield execution of the calling thread. */\nexport declare function sched_yield(): errno;\n\n/** Receive a message from a socket. */\nexport declare function sock_recv(\n /** Input: The socket on which to receive data. */\n sock: fd,\n /** Input: List of scatter/gather vectors to which to store data. */\n ri_data: ptr>,\n /** Input: The length of the list of scatter/gather vectors to which to store data. */\n ri_data_len: usize,\n /** Input: Message flags. */\n ri_flags: riflags,\n /** Output: Number of bytes stored in `ri_data`. */\n ro_datalen: ptr,\n /** Output: Message flags. */\n ro_flags: ptr\n): errno;\n\n/** Send a message on a socket. */\nexport declare function sock_send(\n /** Input: The socket on which to send data. */\n sock: fd,\n /** Input: List of scatter/gather vectors to which to retrieve data */\n si_data: ptr>,\n /** Input: The length of the list of scatter/gather vectors to which to retrieve data */\n si_data_len: usize,\n /** Input: Message flags. */\n si_flags: siflags,\n /** Output: Number of bytes transmitted. */\n so_datalen: ptr\n): errno;\n\n/** Shut down socket send and receive channels. */\nexport declare function sock_shutdown(\n /** Input: The socket on which to shutdown channels. */\n sock: fd,\n /** Input: Which channels on the socket to shut down. */\n how: sdflags\n): errno;\n\n// === Types ======================================================================================\n\n/** File or memory access pattern advisory information. */\nexport namespace advice {\n /** The application has no advice to give on its behavior with respect to the specified data. */\n // @ts-ignore: decorator\n @inline\n export const NORMAL: advice = 0;\n /** The application expects to access the specified data sequentially from lower offsets to higher offsets. */\n // @ts-ignore: decorator\n @inline\n export const SEQUENTIAL : advice = 1;\n /** The application expects to access the specified data in a random order. */\n // @ts-ignore: decorator\n @inline\n export const RANDOM: advice = 2;\n /** The application expects to access the specified data in the near future. */\n // @ts-ignore: decorator\n @inline\n export const WILLNEED: advice = 3;\n /** The application expects that it will not access the specified data in the near future. */\n // @ts-ignore: decorator\n @inline\n export const DONTNEED: advice = 4;\n /** The application expects to access the specified data once and then not reuse it thereafter. */\n // @ts-ignore: decorator\n @inline\n export const NOREUSE: advice = 5;\n}\nexport type advice = u8;\n\n/** Identifiers for clocks. */\nexport namespace clockid {\n /** The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z. */\n // @ts-ignore: decorator\n @inline\n export const REALTIME: clockid = 0;\n /** The store-wide monotonic clock. Absolute value has no meaning. */\n // @ts-ignore: decorator\n @inline\n export const MONOTONIC: clockid = 1;\n /** The CPU-time clock associated with the current process. */\n // @ts-ignore: decorator\n @inline\n export const PROCESS_CPUTIME_ID: clockid = 2;\n /** The CPU-time clock associated with the current thread. */\n // @ts-ignore: decorator\n @inline\n export const THREAD_CPUTIME_ID: clockid = 3;\n}\nexport type clockid = u32;\n\n/** Identifier for a device containing a file system. Can be used in combination with `inode` to uniquely identify a file or directory in the filesystem. */\nexport type device = u64;\n\n/** A reference to the offset of a directory entry. */\nexport type dircookie = u64;\n\n/** A directory entry. */\n@unmanaged export class dirent {\n /** The offset of the next directory entry stored in this directory. */\n next: dircookie;\n /** The serial number of the file referred to by this directory entry. */\n ino: inode;\n /** The length of the name of the directory entry. */\n namlen: u32;\n /** The type of the file referred to by this directory entry. */\n type: filetype;\n private __padding0: u16;\n}\n\n/** Error codes returned by functions. */\nexport namespace errno {\n /** No error occurred. System call completed successfully. */\n // @ts-ignore: decorator\n @inline\n export const SUCCESS: errno = 0;\n /** Argument list too long. */\n // @ts-ignore: decorator\n @inline\n export const TOOBIG: errno = 1;\n /** Permission denied. */\n // @ts-ignore: decorator\n @inline\n export const ACCES: errno = 2;\n /** Address in use. */\n // @ts-ignore: decorator\n @inline\n export const ADDRINUSE: errno = 3;\n /** Address not available. */\n // @ts-ignore: decorator\n @inline\n export const ADDRNOTAVAIL: errno = 4;\n /** Address family not supported. */\n // @ts-ignore: decorator\n @inline\n export const AFNOSUPPORT: errno = 5;\n /** Resource unavailable, or operation would block. */\n // @ts-ignore: decorator\n @inline\n export const AGAIN: errno = 6;\n /** Connection already in progress. */\n // @ts-ignore: decorator\n @inline\n export const ALREADY: errno = 7;\n /** Bad file descriptor. */\n // @ts-ignore: decorator\n @inline\n export const BADF: errno = 8;\n /** Bad message. */\n // @ts-ignore: decorator\n @inline\n export const BADMSG: errno = 9;\n /** Device or resource busy. */\n // @ts-ignore: decorator\n @inline\n export const BUSY: errno = 10;\n /** Operation canceled. */\n // @ts-ignore: decorator\n @inline\n export const CANCELED: errno = 11;\n /** No child processes. */\n // @ts-ignore: decorator\n @inline\n export const CHILD: errno = 12;\n /** Connection aborted. */\n // @ts-ignore: decorator\n @inline\n export const CONNABORTED: errno = 13;\n /** Connection refused. */\n // @ts-ignore: decorator\n @inline\n export const CONNREFUSED: errno = 14;\n /** Connection reset. */\n // @ts-ignore: decorator\n @inline\n export const CONNRESET: errno = 15;\n /** Resource deadlock would occur. */\n // @ts-ignore: decorator\n @inline\n export const DEADLK: errno = 16;\n /** Destination address required. */\n // @ts-ignore: decorator\n @inline\n export const DESTADDRREQ: errno = 17;\n /** Mathematics argument out of domain of function. */\n // @ts-ignore: decorator\n @inline\n export const DOM: errno = 18;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const DQUOT: errno = 19;\n /** File exists. */\n // @ts-ignore: decorator\n @inline\n export const EXIST: errno = 20;\n /** Bad address. */\n // @ts-ignore: decorator\n @inline\n export const FAULT: errno = 21;\n /** File too large. */\n // @ts-ignore: decorator\n @inline\n export const FBIG: errno = 22;\n /** Host is unreachable. */\n // @ts-ignore: decorator\n @inline\n export const HOSTUNREACH: errno = 23;\n /** Identifier removed. */\n // @ts-ignore: decorator\n @inline\n export const IDRM: errno = 24;\n /** Illegal byte sequence. */\n // @ts-ignore: decorator\n @inline\n export const ILSEQ: errno = 25;\n /** Operation in progress. */\n // @ts-ignore: decorator\n @inline\n export const INPROGRESS: errno = 26;\n /** Interrupted function. */\n // @ts-ignore: decorator\n @inline\n export const INTR: errno = 27;\n /** Invalid argument. */\n // @ts-ignore: decorator\n @inline\n export const INVAL: errno = 28;\n /** I/O error. */\n // @ts-ignore: decorator\n @inline\n export const IO: errno = 29;\n /** Socket is connected. */\n // @ts-ignore: decorator\n @inline\n export const ISCONN: errno = 30;\n /** Is a directory. */\n // @ts-ignore: decorator\n @inline\n export const ISDIR: errno = 31;\n /** Too many levels of symbolic links. */\n // @ts-ignore: decorator\n @inline\n export const LOOP: errno = 32;\n /** File descriptor value too large. */\n // @ts-ignore: decorator\n @inline\n export const MFILE: errno = 33;\n /** Too many links. */\n // @ts-ignore: decorator\n @inline\n export const MLINK: errno = 34;\n /** Message too large. */\n // @ts-ignore: decorator\n @inline\n export const MSGSIZE: errno = 35;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const MULTIHOP: errno = 36;\n /** Filename too long. */\n // @ts-ignore: decorator\n @inline\n export const NAMETOOLONG: errno = 37;\n /** Network is down. */\n // @ts-ignore: decorator\n @inline\n export const NETDOWN: errno = 38;\n /** Connection aborted by network. */\n // @ts-ignore: decorator\n @inline\n export const NETRESET: errno = 39;\n /** Network unreachable. */\n // @ts-ignore: decorator\n @inline\n export const NETUNREACH: errno = 40;\n /** Too many files open in system. */\n // @ts-ignore: decorator\n @inline\n export const NFILE: errno = 41;\n /** No buffer space available. */\n // @ts-ignore: decorator\n @inline\n export const NOBUFS: errno = 42;\n /** No such device. */\n // @ts-ignore: decorator\n @inline\n export const NODEV: errno = 43;\n /** No such file or directory. */\n // @ts-ignore: decorator\n @inline\n export const NOENT: errno = 44;\n /** Executable file format error. */\n // @ts-ignore: decorator\n @inline\n export const NOEXEC: errno = 45;\n /** No locks available. */\n // @ts-ignore: decorator\n @inline\n export const NOLCK: errno = 46;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const NOLINK: errno = 47;\n /** Not enough space. */\n // @ts-ignore: decorator\n @inline\n export const NOMEM: errno = 48;\n /** No message of the desired type. */\n // @ts-ignore: decorator\n @inline\n export const NOMSG: errno = 49;\n /** Protocol not available. */\n // @ts-ignore: decorator\n @inline\n export const NOPROTOOPT: errno = 50;\n /** No space left on device. */\n // @ts-ignore: decorator\n @inline\n export const NOSPC: errno = 51;\n /** Function not supported. */\n // @ts-ignore: decorator\n @inline\n export const NOSYS: errno = 52;\n /** The socket is not connected. */\n // @ts-ignore: decorator\n @inline\n export const NOTCONN: errno = 53;\n /** Not a directory or a symbolic link to a directory. */\n // @ts-ignore: decorator\n @inline\n export const NOTDIR: errno = 54;\n /** Directory not empty. */\n // @ts-ignore: decorator\n @inline\n export const NOTEMPTY: errno = 55;\n /** State not recoverable. */\n // @ts-ignore: decorator\n @inline\n export const NOTRECOVERABLE: errno = 56;\n /** Not a socket. */\n // @ts-ignore: decorator\n @inline\n export const NOTSOCK: errno = 57;\n /** Not supported, or operation not supported on socket. */\n // @ts-ignore: decorator\n @inline\n export const NOTSUP: errno = 58;\n /** Inappropriate I/O control operation. */\n // @ts-ignore: decorator\n @inline\n export const NOTTY: errno = 59;\n /** No such device or address. */\n // @ts-ignore: decorator\n @inline\n export const NXIO: errno = 60;\n /** Value too large to be stored in data type. */\n // @ts-ignore: decorator\n @inline\n export const OVERFLOW: errno = 61;\n /** Previous owner died. */\n // @ts-ignore: decorator\n @inline\n export const OWNERDEAD: errno = 62;\n /** Operation not permitted. */\n // @ts-ignore: decorator\n @inline\n export const PERM: errno = 63;\n /** Broken pipe. */\n // @ts-ignore: decorator\n @inline\n export const PIPE: errno = 64;\n /** Protocol error. */\n // @ts-ignore: decorator\n @inline\n export const PROTO: errno = 65;\n /** Protocol not supported. */\n // @ts-ignore: decorator\n @inline\n export const PROTONOSUPPORT: errno = 66;\n /** Protocol wrong type for socket. */\n // @ts-ignore: decorator\n @inline\n export const PROTOTYPE: errno = 67;\n /** Result too large. */\n // @ts-ignore: decorator\n @inline\n export const RANGE: errno = 68;\n /** Read-only file system. */\n // @ts-ignore: decorator\n @inline\n export const ROFS: errno = 69;\n /** Invalid seek. */\n // @ts-ignore: decorator\n @inline\n export const SPIPE: errno = 70;\n /** No such process. */\n // @ts-ignore: decorator\n @inline\n export const SRCH: errno = 71;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const STALE: errno = 72;\n /** Connection timed out. */\n // @ts-ignore: decorator\n @inline\n export const TIMEDOUT: errno = 73;\n /** Text file busy. */\n // @ts-ignore: decorator\n @inline\n export const TXTBSY: errno = 74;\n /** Cross-device link. */\n // @ts-ignore: decorator\n @inline\n export const XDEV: errno = 75;\n /** Extension: Capabilities insufficient. */\n // @ts-ignore: decorator\n @inline\n export const NOTCAPABLE: errno = 76;\n}\nexport type errno = u16;\n\n/** An event that occurred. */\n@unmanaged export abstract class event {\n /** User-provided value that got attached to `subscription#userdata`. */\n userdata: userdata;\n /** If non-zero, an error that occurred while processing the subscription request. */\n error: errno;\n /* The type of the event that occurred. */\n type: eventtype;\n private __padding0: u16;\n}\n\n/** An event that occurred when type is `eventtype.FD_READ` or `eventtype.FD_WRITE`. */\n@unmanaged export class rwevent extends event {\n /* The number of bytes available for reading or writing. */\n nbytes: filesize;\n /* The state of the file descriptor. */\n flags: eventrwflags;\n private __padding1: u32;\n}\n\n/** The state of the file descriptor subscribed to with `eventtype.FD_READ` or `eventtype.FD_WRITE`. */\nexport namespace eventrwflags {\n /** The peer of this socket has closed or disconnected. */\n // @ts-ignore: decorator\n @inline\n export const HANGUP: eventrwflags = 1;\n}\nexport type eventrwflags = u16;\n\n/** Type of a subscription to an event or its occurrence. */\nexport namespace eventtype {\n /** The time value of clock has reached the timestamp. */\n // @ts-ignore: decorator\n @inline\n export const CLOCK: eventtype = 0;\n /** File descriptor has data available for reading. */\n // @ts-ignore: decorator\n @inline\n export const FD_READ: eventtype = 1;\n /** File descriptor has capacity available for writing */\n // @ts-ignore: decorator\n @inline\n export const FD_WRITE: eventtype = 2;\n}\nexport type eventtype = u8;\n\n/** Exit code generated by a process when exiting. */\nexport type exitcode = u32;\n\n/** A file descriptor number. */\nexport type fd = u32;\n\n/** File descriptor flags. */\nexport namespace fdflags {\n /** Append mode: Data written to the file is always appended to the file's end. */\n // @ts-ignore: decorator\n @inline\n export const APPEND: fdflags = 1;\n /** Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. */\n // @ts-ignore: decorator\n @inline\n export const DSYNC: fdflags = 2;\n /** Non-blocking mode. */\n // @ts-ignore: decorator\n @inline\n export const NONBLOCK: fdflags = 4;\n /** Synchronized read I/O operations. */\n // @ts-ignore: decorator\n @inline\n export const RSYNC: fdflags = 8;\n /** Write according to synchronized I/O file integrity completion. */\n // @ts-ignore: decorator\n @inline\n export const SYNC: fdflags = 16;\n}\nexport type fdflags = u16;\n\n/** File descriptor attributes. */\n@unmanaged export class fdstat {\n /** File type. */\n filetype: filetype;\n /** File descriptor flags. */\n flags: fdflags;\n /** Rights that apply to this file descriptor. */\n rights_base: rights;\n /** Maximum set of rights that may be installed on new file descriptors that are created through this file descriptor, e.g., through `path_open`. */\n rights_inheriting: rights;\n}\n\n/** Relative offset within a file. */\nexport type filedelta = i64;\n\n/** Non-negative file size or length of a region within a file. */\nexport type filesize = u64;\n\n/** File attributes. */\n@unmanaged export class filestat {\n /** Device ID of device containing the file. */\n dev: device;\n /** File serial number. */\n ino: inode;\n /** File type. */\n filetype: filetype;\n /** Number of hard links to the file. */\n nlink: linkcount;\n /** For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link. */\n size: filesize;\n /** Last data access timestamp. */\n atim: timestamp;\n /** Last data modification timestamp. */\n mtim: timestamp;\n /** Last file status change timestamp. */\n ctim: timestamp;\n}\n\n/** The type of a file descriptor or file. */\nexport namespace filetype {\n /** The type of the file descriptor or file is unknown or is different from any of the other types specified. */\n // @ts-ignore: decorator\n @inline\n export const UNKNOWN: filetype = 0;\n /** The file descriptor or file refers to a block device inode. */\n // @ts-ignore: decorator\n @inline\n export const BLOCK_DEVICE: filetype = 1;\n /** The file descriptor or file refers to a character device inode. */\n // @ts-ignore: decorator\n @inline\n export const CHARACTER_DEVICE: filetype = 2;\n /** The file descriptor or file refers to a directory inode. */\n // @ts-ignore: decorator\n @inline\n export const DIRECTORY: filetype = 3;\n /** The file descriptor or file refers to a regular file inode. */\n // @ts-ignore: decorator\n @inline\n export const REGULAR_FILE: filetype = 4;\n /** The file descriptor or file refers to a datagram socket. */\n // @ts-ignore: decorator\n @inline\n export const SOCKET_DGRAM: filetype = 5;\n /** The file descriptor or file refers to a byte-stream socket. */\n // @ts-ignore: decorator\n @inline\n export const SOCKET_STREAM: filetype = 6;\n /** The file refers to a symbolic link inode. */\n // @ts-ignore: decorator\n @inline\n export const SYMBOLIC_LINK: filetype = 7;\n}\nexport type filetype = u8;\n\n/** Which file time attributes to adjust. */\nexport namespace fstflags {\n /** Adjust the last data access timestamp to the value stored in `filestat#st_atim`. */\n // @ts-ignore: decorator\n @inline\n export const SET_ATIM: fstflags = 1;\n /** Adjust the last data access timestamp to the time of clock `clockid.REALTIME`. */\n // @ts-ignore: decorator\n @inline\n export const SET_ATIM_NOW: fstflags = 2;\n /** Adjust the last data modification timestamp to the value stored in `filestat#st_mtim`. */\n // @ts-ignore: decorator\n @inline\n export const SET_MTIM: fstflags = 4;\n /** Adjust the last data modification timestamp to the time of clock `clockid.REALTIME`. */\n // @ts-ignore: decorator\n @inline\n export const SET_MTIM_NOW: fstflags = 8;\n}\nexport type fstflags = u16;\n\n/** File serial number that is unique within its file system. */\nexport type inode = u64;\n\n/** A region of memory for scatter/gather reads. */\n@unmanaged export class iovec {\n /** The address of the buffer to be filled. */\n buf: usize;\n /** The length of the buffer to be filled. */\n buf_len: usize;\n}\n\n/** Number of hard links to an inode. */\nexport type linkcount = u32;\n\n/** Flags determining the method of how paths are resolved. */\nexport namespace lookupflags {\n /** As long as the resolved path corresponds to a symbolic link, it is expanded. */\n // @ts-ignore: decorator\n @inline\n export const SYMLINK_FOLLOW: lookupflags = 1;\n}\nexport type lookupflags = u32;\n\n/** Open flags. */\nexport namespace oflags {\n /** Create file if it does not exist. */\n // @ts-ignore: decorator\n @inline\n export const CREAT: oflags = 1;\n /** Fail if not a directory. */\n // @ts-ignore: decorator\n @inline\n export const DIRECTORY: oflags = 2;\n /** Fail if file already exists. */\n // @ts-ignore: decorator\n @inline\n export const EXCL: oflags = 4;\n /** Truncate file to size 0. */\n // @ts-ignore: decorator\n @inline\n export const TRUNC: oflags = 8;\n}\nexport type oflags = u16;\n\n// TODO: undocumented\nexport namespace preopentype {\n // @ts-ignore: decorator\n @inline\n export const DIR: preopentype = 0;\n}\nexport type preopentype = u8;\n\n// TODO: undocumented\nexport abstract class prestat {\n type: preopentype;\n}\n\n// TODO: undocumented\nexport class dirprestat extends prestat {\n name_len: usize;\n}\n\n/** Flags provided to `sock_recv`. */\nexport namespace riflags {\n /** Returns the message without removing it from the socket's receive queue. */\n // @ts-ignore: decorator\n @inline\n export const PEEK: riflags = 1;\n /** On byte-stream sockets, block until the full amount of data can be returned. */\n // @ts-ignore: decorator\n @inline\n export const WAITALL: riflags = 2;\n}\nexport type riflags = u16;\n\n/** File descriptor rights, determining which actions may be performed. */\nexport namespace rights {\n /** The right to invoke `fd_datasync`. */\n // @ts-ignore: decorator\n @inline\n export const FD_DATASYNC: rights = 1;\n /** The right to invoke `fd_read` and `sock_recv`. */\n // @ts-ignore: decorator\n @inline\n export const FD_READ: rights = 2;\n /** The right to invoke `fd_seek`. This flag implies `rights.FD_TELL`. */\n // @ts-ignore: decorator\n @inline\n export const FD_SEEK: rights = 4;\n /** The right to invoke `fd_fdstat_set_flags`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FDSTAT_SET_FLAGS: rights = 8;\n /** The right to invoke `fd_sync`. */\n // @ts-ignore: decorator\n @inline\n export const FD_SYNC: rights = 16;\n /** The right to invoke `fd_seek` in such a way that the file offset remains unaltered (i.e., `whence.CUR` with offset zero), or to invoke `fd_tell`). */\n // @ts-ignore: decorator\n @inline\n export const FD_TELL: rights = 32;\n /** The right to invoke `fd_write` and `sock_send`. If `rights.FD_SEEK` is set, includes the right to invoke `fd_pwrite`. */\n // @ts-ignore: decorator\n @inline\n export const FD_WRITE: rights = 64;\n /** The right to invoke `fd_advise`. */\n // @ts-ignore: decorator\n @inline\n export const FD_ADVISE: rights = 128;\n /** The right to invoke `fd_allocate`. */\n // @ts-ignore: decorator\n @inline\n export const FD_ALLOCATE: rights = 256;\n /** The right to invoke `path_create_directory`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_CREATE_DIRECTORY: rights = 512;\n /** If `rights.PATH_OPEN` is set, the right to invoke `path_open` with `oflags.CREAT`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_CREATE_FILE: rights = 1024;\n /** The right to invoke `path_link` with the file descriptor as the source directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_LINK_SOURCE: rights = 2048;\n /** The right to invoke `path_link` with the file descriptor as the target directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_LINK_TARGET: rights = 4096;\n /** The right to invoke `path_open`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_OPEN: rights = 8192;\n /** The right to invoke `fd_readdir`. */\n // @ts-ignore: decorator\n @inline\n export const FD_READDIR: rights = 16384;\n /** The right to invoke `path_readlink`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_READLINK: rights = 32768;\n /** The right to invoke `path_rename` with the file descriptor as the source directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_RENAME_SOURCE: rights = 65536;\n /** The right to invoke `path_rename` with the file descriptor as the target directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_RENAME_TARGET: rights = 131072;\n /** The right to invoke `path_filestat_get`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_GET: rights = 262144;\n /** The right to change a file's size (there is no `path_filestat_set_size`). If `rights.PATH_OPEN` is set, includes the right to invoke `path_open` with `oflags.TRUNC`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_SET_SIZE: rights = 524288;\n /** The right to invoke `path_filestat_set_times`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_SET_TIMES: rights = 1048576;\n /** The right to invoke `fd_filestat_get`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_GET: rights = 2097152;\n /** The right to invoke `fd_filestat_set_size`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_SET_SIZE: rights = 4194304;\n /** The right to invoke `fd_filestat_set_times`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_SET_TIMES: rights = 8388608;\n /** The right to invoke `path_symlink`. */\n // @ts-ignore: decorator\n @inline\n export const RIGHT_PATH_SYMLINK: rights = 16777216;\n /** The right to invoke `path_remove_directory`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_REMOVE_DIRECTORY: rights = 33554432;\n /** The right to invoke `path_unlink_file`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_UNLINK_FILE: rights = 67108864;\n /** If `rights.FD_READ` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_READ`. If `rights.FD_WRITE` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_WRITE`. */\n // @ts-ignore: decorator\n @inline\n export const POLL_FD_READWRITE: rights = 134217728;\n /** The right to invoke `sock_shutdown`. */\n // @ts-ignore: decorator\n @inline\n export const SOCK_SHUTDOWN: rights = 268435456;\n}\nexport type rights = u64;\n\n/** Flags returned by `sock_recv`. */\nexport namespace roflags {\n /** Message data has been truncated. */\n // @ts-ignore: decorator\n @inline\n export const DATA_TRUNCATED: roflags = 1;\n}\nexport type roflags = u16;\n\n/** Which channels on a socket to shut down. */\nexport namespace sdflags {\n /** Disables further receive operations. */\n // @ts-ignore: decorator\n @inline\n export const RD: sdflags = 1;\n /** Disables further send operations. */\n // @ts-ignore: decorator\n @inline\n export const WR: sdflags = 2;\n}\nexport type sdflags = u8;\n\n/** Flags provided to `sock_send`. */\nexport namespace siflags {\n // As there are currently no flags defined, it must be set to zero.\n}\nexport type siflags = u16;\n\n/** Signal condition. */\nexport namespace signal {\n /** Hangup. */\n // @ts-ignore: decorator\n @inline\n export const HUP: signal = 1;\n /** Terminate interrupt signal. */\n // @ts-ignore: decorator\n @inline\n export const INT: signal = 2;\n /** Terminal quit signal. */\n // @ts-ignore: decorator\n @inline\n export const QUIT: signal = 3;\n /** Illegal instruction. */\n // @ts-ignore: decorator\n @inline\n export const ILL: signal = 4;\n /** Trace/breakpoint trap. */\n // @ts-ignore: decorator\n @inline\n export const TRAP: signal = 5;\n /** Process abort signal. */\n // @ts-ignore: decorator\n @inline\n export const ABRT: signal = 6;\n /** Access to an undefined portion of a memory object. */\n // @ts-ignore: decorator\n @inline\n export const BUS: signal = 7;\n /** Erroneous arithmetic operation. */\n // @ts-ignore: decorator\n @inline\n export const FPE: signal = 8;\n /** Kill. */\n // @ts-ignore: decorator\n @inline\n export const KILL: signal = 9;\n /** User-defined signal 1. */\n // @ts-ignore: decorator\n @inline\n export const USR1: signal = 10;\n /** Invalid memory reference. */\n // @ts-ignore: decorator\n @inline\n export const SEGV: signal = 11;\n /** User-defined signal 2. */\n // @ts-ignore: decorator\n @inline\n export const USR2: signal = 12;\n /** Write on a pipe with no one to read it. */\n // @ts-ignore: decorator\n @inline\n export const PIPE: signal = 13;\n /** Alarm clock. */\n // @ts-ignore: decorator\n @inline\n export const ALRM: signal = 14;\n /** Termination signal. */\n // @ts-ignore: decorator\n @inline\n export const TERM: signal = 15;\n /** Child process terminated, stopped, or continued. */\n // @ts-ignore: decorator\n @inline\n export const CHLD: signal = 16;\n /** Continue executing, if stopped. */\n // @ts-ignore: decorator\n @inline\n export const CONT: signal = 17;\n /** Stop executing. */\n // @ts-ignore: decorator\n @inline\n export const STOP: signal = 18;\n /** Terminal stop signal. */\n // @ts-ignore: decorator\n @inline\n export const TSTP: signal = 19;\n /** Background process attempting read. */\n // @ts-ignore: decorator\n @inline\n export const TTIN: signal = 20;\n /** Background process attempting write. */\n // @ts-ignore: decorator\n @inline\n export const TTOU: signal = 21;\n /** High bandwidth data is available at a socket. */\n // @ts-ignore: decorator\n @inline\n export const URG: signal = 22;\n /** CPU time limit exceeded. */\n // @ts-ignore: decorator\n @inline\n export const XCPU: signal = 23;\n /** File size limit exceeded. */\n // @ts-ignore: decorator\n @inline\n export const XFSZ: signal = 24;\n /** Virtual timer expired. */\n // @ts-ignore: decorator\n @inline\n export const VTALRM: signal = 25;\n // @ts-ignore: decorator\n @inline\n export const PROF: signal = 26;\n // @ts-ignore: decorator\n @inline\n export const WINCH: signal = 27;\n // @ts-ignore: decorator\n @inline\n export const POLL: signal = 28;\n // @ts-ignore: decorator\n @inline\n export const PWR: signal = 29;\n /** Bad system call. */\n // @ts-ignore: decorator\n @inline\n export const SYS: signal = 30;\n}\nexport type signal = u8;\n\n/** Flags determining how to interpret the timestamp provided in `subscription_t::u.clock.timeout. */\nexport namespace subclockflags {\n /** If set, treat the timestamp provided in `clocksubscription` as an absolute timestamp. */\n // @ts-ignore: decorator\n @inline\n export const ABSTIME: subclockflags = 1;\n}\nexport type subclockflags = u16;\n\n/** Subscription to an event. */\n@unmanaged export abstract class subscription {\n /** User-provided value that is attached to the subscription. */\n userdata: userdata;\n /** The type of the event to which to subscribe. */\n type: eventtype;\n private __padding0: u32;\n}\n\n/* Subscription to an event of type `eventtype.CLOCK`.**/\n@unmanaged export class clocksubscription extends subscription {\n /** The user-defined unique identifier of the clock. */\n identifier: userdata;\n /** The clock against which to compare the timestamp. */\n clock_id: clockid;\n /** The absolute or relative timestamp. */\n timeout: timestamp;\n /** The amount of time that the implementation may wait additionally to coalesce with other events. */\n precision: timestamp;\n /** Flags specifying whether the timeout is absolute or relative. */\n flags: subclockflags;\n private __padding1: u32;\n}\n\n/* Subscription to an event of type `eventtype.FD_READ` or `eventtype.FD_WRITE`.**/\n@unmanaged export class fdsubscription extends subscription {\n /** The file descriptor on which to wait for it to become ready for reading or writing. */\n fd: fd;\n}\n\n/** Timestamp in nanoseconds. */\nexport type timestamp = u64;\n\n/** User-provided value that may be attached to objects that is retained when extracted from the implementation. */\nexport type userdata = u64;\n\n/** The position relative to which to set the offset of the file descriptor. */\nexport namespace whence {\n /** Seek relative to current position. */\n // @ts-ignore: decorator\n @inline\n export const CUR: whence = 0;\n /** Seek relative to end-of-file. */\n // @ts-ignore: decorator\n @inline\n export const END: whence = 1;\n /** Seek relative to start-of-file. */\n // @ts-ignore: decorator\n @inline\n export const SET: whence = 2;\n}\nexport type whence = u8;\n","bindings/wasi":'export * from "./wasi_unstable";\n',builtins:'// @ts-ignore: decorator\n@builtin @inline\nexport const NaN: f64 = 0 / 0;\n\n// @ts-ignore: decorator\n@builtin @inline\nexport const Infinity: f64 = 1 / 0;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isInteger(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFloat(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isBoolean(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isSigned(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isReference(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isString(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isArray(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isArrayLike(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFunction(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isNullable(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isDefined(expression: void): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isConstant(expression: void): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isManaged(value?: T): bool;\n\nexport function isNaN(value: T): bool {\n if (!isFloat()) {\n if (!isInteger()) ERROR("numeric type expected");\n }\n return value != value;\n}\n\nexport function isFinite(value: T): bool {\n if (!isFloat()) {\n if (!isInteger()) ERROR("numeric type expected");\n }\n return value - value == 0;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function clz(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function ctz(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function popcnt(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function rotl(value: T, shift: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function rotr(value: T, shift: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function abs(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function max(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function min(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function ceil(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function floor(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function copysign(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function nearest(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function reinterpret(value: number): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function sqrt(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function trunc(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function load(offset: usize, immOffset?: usize, immAlign?: usize): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function store(offset: usize, value: void, immOffset?: usize, immAlign?: usize): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function sizeof(): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function alignof(): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function offsetof(fieldName?: string): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function idof(): u32;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n\n// @ts-ignore: decorator\n@unsafe @builtin\nexport declare function unreachable(): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function changetype(value: void): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function assert(isTrueish: T, message?: string): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function unchecked(expr: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function call_indirect(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function call_direct(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function instantiate(...args: void[]): T;\n\nexport namespace atomic {\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: T, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;\n\n // @ts-ignore: decorator\n @builtin\n export declare function notify(ptr: usize, count: i32): i32;\n}\n\n// @ts-ignore: decorator\n@lazy\nexport const enum AtomicWaitResult {\n OK = 0,\n NOT_EQUAL = 1,\n TIMED_OUT = 2\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i8(value: void): i8;\n\nexport namespace i8 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i8 = -128;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i8 = 127;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i16(value: void): i16;\n\nexport namespace i16 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i16 = -32768;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i16 = 32767;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i32(value: void): i32;\n\nexport namespace i32 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i32 = -2147483648;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i32 = 2147483647;\n\n // @ts-ignore: decorator\n @builtin\n export declare function clz(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ctz(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function popcnt(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotl(value: i32, shift: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotr(value: i32, shift: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_f32(value: f32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n export namespace atomic {\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;\n\n export namespace rmw8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n\n export namespace rmw16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n\n export namespace rmw {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n }\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i64(value: void): i64;\n\nexport namespace i64 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i64 = -9223372036854775808;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i64 = 9223372036854775807;\n\n // @ts-ignore: decorator\n @builtin\n export declare function clz(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ctz(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function popcnt(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotl(value: i64, shift: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotr(value: i64, shift: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_f64(value: f64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n export namespace atomic {\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store32(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;\n\n export namespace rmw8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw32 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n }\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isize(value: void): isize;\n\nexport namespace isize {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: isize = sizeof() == sizeof()\n ? -2147483648\n : -9223372036854775808;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: isize = sizeof() == sizeof()\n ? 2147483647\n : 9223372036854775807;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u8(value: void): u8;\n\nexport namespace u8 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u8 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u8 = 255;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u16(value: void): u16;\n\nexport namespace u16 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u16 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u16 = 65535;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u32(value: void): u32;\n\nexport namespace u32 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u32 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u32 = 4294967295;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u64(value: void): u64;\n\nexport namespace u64 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u64 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u64 = 18446744073709551615;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function usize(value: void): usize;\n\nexport namespace usize {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: usize = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: usize = sizeof() == sizeof()\n ? 4294967295\n : 18446744073709551615;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function bool(value: void): bool;\n\nexport namespace bool {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: bool = false;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: bool = true;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f32(value: void): f32;\n\nexport namespace f32 {\n\n // @ts-ignore: decorator\n @lazy\n export const EPSILON = reinterpret(0x34000000); // 0x1p-23f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE = reinterpret(0x00000001); // 0x0.000001p+0f\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE = reinterpret(0x7F7FFFFF); // 0x1.fffffep+127f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_NORMAL_VALUE = reinterpret(0x00800000); // 0x1p-126f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_SAFE_INTEGER: f32 = -16777215;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_SAFE_INTEGER: f32 = 16777215;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ceil(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function copysign(x: f32, y: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function floor(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(left: f32, right: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(left: f32, right: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function nearest(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_i32(value: i32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(value: f32): f32;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f64(value: void): f64;\n\nexport namespace f64 {\n\n // @ts-ignore: decorator\n @lazy\n export const EPSILON = reinterpret(0x3CB0000000000000); // 0x1p-52\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE = reinterpret(0x0000000000000001); // 0x0.0000000000001p+0\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE = reinterpret(0x7FEFFFFFFFFFFFFF); // 0x1.fffffffffffffp+1023\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_NORMAL_VALUE = reinterpret(0x0010000000000000); // 0x1p-1022\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_SAFE_INTEGER: f64 = -9007199254740991;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_SAFE_INTEGER: f64 = 9007199254740991;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ceil(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function copysign(x: f64, y: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function floor(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(left: f64, right: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(left: f64, right: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function nearest(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_i64(value: i64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(value: f64): f64;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function v128(\n a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8,\n i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8\n): v128;\n\nexport namespace v128 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: T): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: T): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128; // except i64\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function not(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function bitselect(v1: v128, v2: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i8x16(\n a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8,\n i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8\n): v128;\n\nexport namespace i8x16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i8): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_s(x: v128, idx: u8): i8;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_u(x: v128, idx: u8): u8;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i8): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;\n\nexport namespace i16x8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i16): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_s(x: v128, idx: u8): i16;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_u(x: v128, idx: u8): u16;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i16): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;\n\nexport namespace i32x4 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_s_f32x4_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_u_f32x4_sat(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i64x2(a: i64, b: i64): v128;\n\nexport namespace i64x2 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_s_f64x2_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_u_f64x2_sat(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;\n\nexport namespace f32x4 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: f32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: f32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_s_i32x4(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_u_i32x4(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f64x2(a: f64, b: f64): v128;\n\nexport namespace f64x2 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: f64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: f64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_s_i64x2(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_u_i64x2(a: v128): v128;\n}\n\nexport namespace v8x16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function shuffle(\n a: v128, b: v128,\n l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8,\n l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8\n ): v128;\n}\n\n// @ts-ignore: decorator\n@external("env", "abort")\ndeclare function abort(\n message?: string | null,\n fileName?: string | null,\n lineNumber?: u32,\n columnNumber?: u32\n): void;\n\n// @ts-ignore: decorator\n@external("env", "trace")\ndeclare function trace(\n message: string,\n n?: i32,\n a0?: f64,\n a1?: f64,\n a2?: f64,\n a3?: f64,\n a4?: f64\n): void;\n',dataview:'import { BLOCK_MAXSIZE } from "./rt/common";\nimport { ArrayBuffer } from "./arraybuffer";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH } from "./util/error";\n\n// TODO: there is probably a smarter way to check byteOffset for accesses larger than 1 byte\n\nexport class DataView {\n\n private data: ArrayBuffer;\n private dataStart: usize;\n private dataLength: i32;\n\n constructor(\n buffer: ArrayBuffer,\n byteOffset: i32 = 0,\n byteLength: i32 = buffer.byteLength\n ) {\n if (\n i32(byteLength > BLOCK_MAXSIZE) |\n i32(byteOffset + byteLength > buffer.byteLength)\n ) throw new RangeError(E_INVALIDLENGTH);\n this.data = buffer; // retains\n var dataStart = changetype(buffer) + byteOffset;\n this.dataStart = dataStart;\n this.dataLength = byteLength;\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.data));\n }\n\n get byteLength(): i32 {\n return this.dataLength;\n }\n\n getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n return littleEndian\n ? load(this.dataStart + byteOffset)\n : reinterpret(\n bswap(\n load(this.dataStart + byteOffset)\n )\n );\n }\n\n getFloat64(byteOffset: i32, littleEndian: boolean = false): f64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n return littleEndian\n ? load(this.dataStart + byteOffset)\n : reinterpret(\n bswap(\n load(this.dataStart + byteOffset)\n )\n );\n }\n\n getInt8(byteOffset: i32): i8 {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getInt16(byteOffset: i32, littleEndian: boolean = false): i16 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i16 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getInt32(byteOffset: i32, littleEndian: boolean = false): i32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i32 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint8(byteOffset: i32): u8 {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getUint16(byteOffset: i32, littleEndian: boolean = false): u16 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: u16 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint32(byteOffset: i32, littleEndian: boolean = false): u32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: u32 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n setFloat32(byteOffset: i32, value: f32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n if (littleEndian) store(this.dataStart + byteOffset, value);\n else store(this.dataStart + byteOffset, bswap(reinterpret(value)));\n }\n\n setFloat64(byteOffset: i32, value: f64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n if (littleEndian) store(this.dataStart + byteOffset, value);\n else store(this.dataStart + byteOffset, bswap(reinterpret(value)));\n }\n\n setInt8(byteOffset: i32, value: i8): void {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, value);\n }\n\n setInt16(byteOffset: i32, value: i16, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setInt32(byteOffset: i32, value: i32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint8(byteOffset: i32, value: u8): void {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, value);\n }\n\n setUint16(byteOffset: i32, value: u16, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint32(byteOffset: i32, value: u32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n // Non-standard additions that make sense in WebAssembly, but won\'t work in JS:\n\n getInt64(byteOffset: i32, littleEndian: boolean = false): i64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i64 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint64(byteOffset: i32, littleEndian: boolean = false): u64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n setInt64(byteOffset: i32, value: i64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint64(byteOffset: i32, value: u64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n toString(): string {\n return "[object DataView]";\n }\n}\n',date:'import {\n UTC as Date_UTC,\n now as Date_now\n} from "./bindings/Date";\n\nexport class Date {\n\n @inline static UTC(\n year: i32,\n month: i32 = 0,\n day: i32 = 1,\n hour: i32 = 0,\n minute: i32 = 0,\n second: i32 = 0,\n millisecond: i64 = 0\n ): i64 {\n return Date_UTC(year, month, day, hour, minute, second, millisecond);\n }\n\n @inline static now(): i64 {\n return Date_now();\n }\n\n private value: i64;\n\n constructor(value: i64) {\n this.value = value;\n }\n\n getTime(): i64 {\n return this.value;\n }\n\n setTime(value: i64): i64 {\n this.value = value;\n return value;\n }\n}\n',diagnostics:"// @ts-ignore: decorator\n@builtin\nexport declare function ERROR(message?: string): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function WARNING(message?: string): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function INFO(message?: string): void;\n",error:'export class Error {\n\n name: string = "Error";\n stack: string = ""; // TODO\n\n constructor(\n public message: string = ""\n ) {}\n\n toString(): string {\n var message = this.message;\n return message.length\n ? this.name + ": " + message\n : this.name;\n }\n}\n\nexport class RangeError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "RangeError";\n }\n}\n\nexport class TypeError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "TypeError";\n }\n}\n\nexport class SyntaxError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "SyntaxError";\n }\n}\n',fixedarray:'/// \n\nimport { BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "./rt/common";\nimport { idof } from "./builtins";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_HOLEYARRAY } from "./util/error";\n\n// NOTE: DO NOT USE YET!\n\n// TODO: FixedArray with S being the static size, i.e. `new FixedArray`.\n// Then hard-wire this special type to the compiler and do static length checks instead :)\n\nexport class FixedArray {\n [key: number]: T;\n\n constructor(length: i32) {\n if (length > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH);\n if (isReference()) {\n if (!isNullable()) {\n if (length) throw new Error(E_HOLEYARRAY);\n }\n }\n var outSize = length << alignof();\n var out = __alloc(outSize, idof>());\n memory.fill(out, 0, outSize);\n return changetype>(out); // retains\n }\n\n get length(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize >>> alignof();\n }\n\n @operator("[]") private __get(index: i32): T {\n if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_get(index);\n }\n\n @operator("[]=") private __set(index: i32, value: T): void {\n if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_set(index, value);\n }\n\n @operator("{}") private __unchecked_get(index: i32): T {\n return load(changetype(this) + (index << alignof()));\n }\n\n @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = changetype(this) + (index << alignof());\n let oldValue = load(offset);\n if (changetype(value) != oldValue) {\n store(offset, __retain(changetype(value)));\n __release(changetype(oldValue));\n }\n } else {\n store(changetype(this) + (index << alignof()), value);\n }\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n if (isManaged()) {\n let cur = changetype(this);\n let end = cur + changetype(changetype(this) - BLOCK_OVERHEAD).rtSize;\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n }\n}\n',heap:"// @ts-ignore: decorator\n@builtin\nexport declare const HEAP_BASE: usize;\n",iterator:"export abstract class Iterable {\n // ?\n}\n\n@sealed\nexport abstract class Iterator {\n\n // private constructor(iterable: Iterable) {\n // }\n\n // TODO: these need to evaluate the classId at the respective reference in order to obtain the\n // next value, i.e. arrays work differently than maps. we'd then have:\n //\n // ╒═══════════════════ Iterator layout (32-bit) ══════════════════╕\n // 3 2 1\n // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n // ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n // │ index │\n // ├─────────────────────────────────────────────────────────┬───┬─┤\n // │ reference │ 0 │D│\n // └─────────────────────────────────────────────────────────┴───┴─┘\n // D: Done flag\n\n // get value(this: u64): T {\n // ?\n // }\n\n // next(this: u64): Iterator {\n // ?\n // }\n\n done(this: u64): bool {\n return (this & 1);\n }\n}\n",map:'/// \n\nimport { HASH } from "./util/hash";\n\n// A deterministic hash map based on CloseTable from https://github.com/jorendorff/dht\n\n// @ts-ignore: decorator\n@inline\nconst INITIAL_CAPACITY = 4;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR: f64 = 8 / 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR: f64 = 3 / 4;\n\n/** Structure of a map entry. */\n@unmanaged class MapEntry {\n key: K;\n value: V;\n taggedNext: usize; // LSB=1 indicates EMPTY\n}\n\n/** Empty bit. */\n// @ts-ignore: decorator\n@inline\nconst EMPTY: usize = 1 << 0;\n\n/** Size of a bucket. */\n// @ts-ignore: decorator\n@inline\nconst BUCKET_SIZE = sizeof();\n\n/** Computes the alignment of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_ALIGN(): usize {\n // can align to 4 instead of 8 if 32-bit and K/V is <= 32-bits\n const maxkv = sizeof() > sizeof() ? sizeof() : sizeof();\n const align = (maxkv > sizeof() ? maxkv : sizeof()) - 1;\n return align;\n}\n\n/** Computes the aligned size of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_SIZE(): usize {\n const align = ENTRY_ALIGN();\n const size = (offsetof>() + align) & ~align;\n return size;\n}\n\nexport class Map {\n\n // buckets holding references to the respective first entry within\n private buckets: ArrayBuffer; // usize[bucketsMask + 1]\n private bucketsMask: u32;\n\n // entries in insertion order\n private entries: ArrayBuffer; // MapEntry[entriesCapacity]\n private entriesCapacity: i32;\n private entriesOffset: i32;\n private entriesCount: i32;\n\n get size(): i32 { return this.entriesCount; }\n\n constructor() {\n this.clear();\n }\n\n clear(): void {\n const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE;\n this.buckets = new ArrayBuffer(bucketsSize);\n this.bucketsMask = INITIAL_CAPACITY - 1;\n const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE();\n this.entries = new ArrayBuffer(entriesSize);\n this.entriesCapacity = INITIAL_CAPACITY;\n this.entriesOffset = 0;\n this.entriesCount = 0;\n }\n\n private find(key: K, hashCode: u32): MapEntry | null {\n var entry = load>( // unmanaged!\n changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE\n );\n while (entry) {\n if (!(entry.taggedNext & EMPTY) && entry.key == key) return entry;\n entry = changetype>(entry.taggedNext & ~EMPTY);\n }\n return null;\n }\n\n has(key: K): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n get(key: K): V {\n var entry = this.find(key, HASH(key));\n return entry ? entry.value : unreachable();\n }\n\n set(key: K, value: V): void {\n var hashCode = HASH(key);\n var entry = this.find(key, hashCode); // unmanaged!\n if (entry) {\n if (isManaged()) {\n let oldRef = changetype(entry.value);\n if (changetype(value) != oldRef) {\n entry.value = changetype(__retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n entry.value = value;\n }\n } else {\n // check if rehashing is necessary\n if (this.entriesOffset == this.entriesCapacity) {\n this.rehash(\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ? this.bucketsMask // just rehash if 1/4+ entries are empty\n : (this.bucketsMask << 1) | 1 // grow capacity to next 2^N\n );\n }\n // append new entry\n let entries = this.entries;\n entry = changetype>(changetype(entries) + this.entriesOffset++ * ENTRY_SIZE());\n // link with the map\n entry.key = isManaged()\n ? changetype(__retain(changetype(key)))\n : key;\n entry.value = isManaged()\n ? changetype(__retain(changetype(value)))\n : value;\n ++this.entriesCount;\n // link with previous entry in bucket\n let bucketPtrBase = changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE;\n entry.taggedNext = load(bucketPtrBase);\n store(bucketPtrBase, changetype(entry));\n }\n }\n\n delete(key: K): bool {\n var entry = this.find(key, HASH(key));\n if (!entry) return false;\n if (isManaged()) __release(changetype(entry.key));\n if (isManaged()) __release(changetype(entry.value));\n entry.taggedNext |= EMPTY;\n --this.entriesCount;\n // check if rehashing is appropriate\n var halfBucketsMask = this.bucketsMask >> 1;\n if (\n halfBucketsMask + 1 >= max(INITIAL_CAPACITY, this.entriesCount) &&\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ) this.rehash(halfBucketsMask);\n return true;\n }\n\n private rehash(newBucketsMask: u32): void {\n var newBucketsCapacity = (newBucketsMask + 1);\n var newBuckets = new ArrayBuffer(newBucketsCapacity * BUCKET_SIZE);\n var newEntriesCapacity = (newBucketsCapacity * FILL_FACTOR);\n var newEntries = new ArrayBuffer(newEntriesCapacity * ENTRY_SIZE());\n\n // copy old entries to new entries\n var oldPtr = changetype(this.entries);\n var oldEnd = oldPtr + this.entriesOffset * ENTRY_SIZE();\n var newPtr = changetype(newEntries);\n while (oldPtr != oldEnd) {\n let oldEntry = changetype>(oldPtr);\n if (!(oldEntry.taggedNext & EMPTY)) {\n let newEntry = changetype>(newPtr);\n newEntry.key = oldEntry.key;\n newEntry.value = oldEntry.value;\n let newBucketIndex = HASH(oldEntry.key) & newBucketsMask;\n let newBucketPtrBase = changetype(newBuckets) + newBucketIndex * BUCKET_SIZE;\n newEntry.taggedNext = load(newBucketPtrBase);\n store(newBucketPtrBase, newPtr);\n newPtr += ENTRY_SIZE();\n }\n oldPtr += ENTRY_SIZE();\n }\n\n this.buckets = newBuckets;\n this.bucketsMask = newBucketsMask;\n this.entries = newEntries;\n this.entriesCapacity = newEntriesCapacity;\n this.entriesOffset = this.entriesCount;\n }\n\n toString(): string {\n return "[object Map]";\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n __visit(changetype(this.buckets), cookie);\n var entries = changetype(this.entries);\n if (isManaged() || isManaged()) {\n let cur = entries;\n let end = cur + this.entriesOffset * ENTRY_SIZE();\n while (cur < end) {\n let entry = changetype>(cur);\n if (!(entry.taggedNext & EMPTY)) {\n if (isManaged()) {\n let val = changetype(entry.key);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n if (isManaged()) {\n let val = changetype(entry.value);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n }\n cur += ENTRY_SIZE();\n }\n }\n __visit(entries, cookie);\n }\n}\n',math:'import * as JSMath from "./bindings/Math";\nexport { JSMath };\n\nimport {\n abs as builtin_abs,\n ceil as builtin_ceil,\n clz as builtin_clz,\n copysign as builtin_copysign,\n floor as builtin_floor,\n max as builtin_max,\n min as builtin_min,\n sqrt as builtin_sqrt,\n trunc as builtin_trunc\n} from "./builtins";\n\n// SUN COPYRIGHT NOTICE\n//\n// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n// Developed at SunPro, a Sun Microsystems, Inc. business.\n// Permission to use, copy, modify, and distribute this software\n// is freely granted, provided that this notice is preserved.\n//\n// Applies to all functions marked with a comment referring here.\n\n// TODO: sin, cos, tan for Math namespace\n\n/** @internal */\nfunction R(z: f64): f64 { // Rational approximation of (asin(x)-x)/x^3\n const // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above\n pS0 = reinterpret(0x3FC5555555555555), // 1.66666666666666657415e-01\n pS1 = reinterpret(0xBFD4D61203EB6F7D), // -3.25565818622400915405e-01\n pS2 = reinterpret(0x3FC9C1550E884455), // 2.01212532134862925881e-01\n pS3 = reinterpret(0xBFA48228B5688F3B), // -4.00555345006794114027e-02\n pS4 = reinterpret(0x3F49EFE07501B288), // 7.91534994289814532176e-04\n pS5 = reinterpret(0x3F023DE10DFDF709), // 3.47933107596021167570e-05\n qS1 = reinterpret(0xC0033A271C8A2D4B), // -2.40339491173441421878e+00\n qS2 = reinterpret(0x40002AE59C598AC8), // 2.02094576023350569471e+00\n qS3 = reinterpret(0xBFE6066C1B8D0159), // -6.88283971605453293030e-01\n qS4 = reinterpret(0x3FB3B8C5B12E9282); // 7.70381505559019352791e-02\n var p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));\n var q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));\n return p / q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction expo2(x: f64): f64 { // exp(x)/2 for x >= log(DBL_MAX)\n const // see: musl/src/math/__expo2.c\n k = 2043,\n kln2 = reinterpret(0x40962066151ADD8B); // 0x1.62066151add8bp+10\n var scale = reinterpret(((0x3FF + k / 2) << 20) << 32);\n return NativeMath.exp(x - kln2) * scale * scale;\n}\n\n// @ts-ignore: decorator\n@lazy\nvar random_seeded = false;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state0_64: u64;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state1_64: u64;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state0_32: u32;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state1_32: u32;\n\nfunction murmurHash3(h: u64): u64 { // Force all bits of a hash block to avalanche\n h ^= h >> 33; // see: https://github.com/aappleby/smhasher\n h *= 0xFF51AFD7ED558CCD;\n h ^= h >> 33;\n h *= 0xC4CEB9FE1A85EC53;\n h ^= h >> 33;\n return h;\n}\n\nfunction splitMix32(h: u32): u32 {\n h += 0x6D2B79F5;\n h = (h ^ (h >> 15)) * (h | 1);\n h ^= h + (h ^ (h >> 7)) * (h | 61);\n return h ^ (h >> 14);\n}\n\nexport namespace NativeMath {\n\n // @ts-ignore: decorator\n @lazy\n export const E = reinterpret(0x4005BF0A8B145769); // 2.7182818284590452354\n\n // @ts-ignore: decorator\n @lazy\n export const LN2 = reinterpret(0x3FE62E42FEFA39EF); // 0.69314718055994530942\n\n // @ts-ignore: decorator\n @lazy\n export const LN10 = reinterpret(0x40026BB1BBB55516); // 2.30258509299404568402\n\n // @ts-ignore: decorator\n @lazy\n export const LOG2E = reinterpret(0x3FF71547652B82FE); // 1.4426950408889634074\n\n // @ts-ignore: decorator\n @lazy\n export const LOG10E = reinterpret(0x3FDBCB7B1526E50E); // 0.43429448190325182765\n\n // @ts-ignore: decorator\n @lazy\n export const PI = reinterpret(0x400921FB54442D18); // 3.14159265358979323846\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT1_2 = reinterpret(0x3FE6A09E667F3BCD); // 0.70710678118654752440\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT2 = reinterpret(0x3FF6A09E667F3BCD); // 1.41421356237309504880\n\n // @ts-ignore: decorator\n @inline export function abs(x: f64): f64 {\n return builtin_abs(x);\n }\n\n export function acos(x: f64): f64 { // see: musl/src/math/acos.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n pio2_lo = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n Ox1p_120f = reinterpret(0x03800000);\n var hx = (reinterpret(x) >> 32);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3FF00000) {\n let lx = reinterpret(x);\n if ((ix - 0x3FF00000 | lx) == 0) {\n if (hx >> 31) return 2 * pio2_hi + Ox1p_120f;\n return 0;\n }\n return 0 / (x - x);\n }\n if (ix < 0x3FE00000) {\n if (ix <= 0x3C600000) return pio2_hi + Ox1p_120f;\n return pio2_hi - (x - (pio2_lo - x * R(x * x)));\n }\n var s: f64, w: f64, z: f64;\n if (hx >> 31) {\n // z = (1.0 + x) * 0.5;\n z = 0.5 + x * 0.5;\n s = builtin_sqrt(z);\n w = R(z) * s - pio2_lo;\n return 2 * (pio2_hi - (s + w));\n }\n // z = (1.0 - x) * 0.5;\n z = 0.5 - x * 0.5;\n s = builtin_sqrt(z);\n var df = reinterpret(reinterpret(s) & 0xFFFFFFFF00000000);\n var c = (z - df * df) / (s + df);\n w = R(z) * s + c;\n return 2 * (df + w);\n }\n\n export function acosh(x: f64): f64 { // see: musl/src/math/acosh.c\n const s = reinterpret(0x3FE62E42FEFA39EF);\n var e = reinterpret(x) >> 52 & 0x7FF;\n if (e < 0x3FF + 1) return log1p(x - 1 + builtin_sqrt((x - 1) * (x - 1) + 2 * (x - 1)));\n if (e < 0x3FF + 26) return log(2 * x - 1 / (x + builtin_sqrt(x * x - 1)));\n return log(x) + s;\n }\n\n export function asin(x: f64): f64 { // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n pio2_lo = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n Ox1p_120f = reinterpret(0x03800000);\n var hx = (reinterpret(x) >> 32);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3FF00000) {\n let lx = reinterpret(x);\n if ((ix - 0x3FF00000 | lx) == 0) return x * pio2_hi + Ox1p_120f;\n return 0 / (x - x);\n }\n if (ix < 0x3FE00000) {\n if (ix < 0x3E500000 && ix >= 0x00100000) return x;\n return x + x * R(x * x);\n }\n // var z = (1.0 - builtin_abs(x)) * 0.5;\n var z = 0.5 - builtin_abs(x) * 0.5;\n var s = builtin_sqrt(z);\n var r = R(z);\n if (ix >= 0x3FEF3333) x = pio2_hi - (2 * (s + s * r) - pio2_lo);\n else {\n let f = reinterpret(reinterpret(s) & 0xFFFFFFFF00000000);\n let c = (z - f * f) / (s + f);\n x = 0.5 * pio2_hi - (2 * s * r - (pio2_lo - 2 * c) - (0.5 * pio2_hi - 2 * f));\n }\n if (hx >> 31) return -x;\n return x;\n }\n\n export function asinh(x: f64): f64 { // see: musl/src/math/asinh.c\n const c = reinterpret(0x3FE62E42FEFA39EF); // 0.693147180559945309417232121458176568\n var u = reinterpret(x);\n var e = u >> 52 & 0x7FF;\n var y = reinterpret(u & 0x7FFFFFFFFFFFFFFF);\n if (e >= 0x3FF + 26) y = log(y) + c;\n else if (e >= 0x3FF + 1) y = log(2 * y + 1 / (builtin_sqrt(y * y + 1) + y));\n else if (e >= 0x3FF - 26) y = log1p(y + y * y / (builtin_sqrt(y * y + 1) + 1));\n return builtin_copysign(y, x);\n }\n\n export function atan(x: f64): f64 { // see musl/src/math/atan.c and SUN COPYRIGHT NOTICE above\n const\n atanhi0 = reinterpret(0x3FDDAC670561BB4F), // 4.63647609000806093515e-01\n atanhi1 = reinterpret(0x3FE921FB54442D18), // 7.85398163397448278999e-01\n atanhi2 = reinterpret(0x3FEF730BD281F69B), // 9.82793723247329054082e-01\n atanhi3 = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n atanlo0 = reinterpret(0x3C7A2B7F222F65E2), // 2.26987774529616870924e-17\n atanlo1 = reinterpret(0x3C81A62633145C07), // 3.06161699786838301793e-17\n atanlo2 = reinterpret(0x3C7007887AF0CBBD), // 1.39033110312309984516e-17\n atanlo3 = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n aT0 = reinterpret(0x3FD555555555550D), // 3.33333333333329318027e-01\n aT1 = reinterpret(0xBFC999999998EBC4), // -1.99999999998764832476e-01\n aT2 = reinterpret(0x3FC24924920083FF), // 1.42857142725034663711e-01\n aT3 = reinterpret(0xBFBC71C6FE231671), // -1.11111104054623557880e-01,\n aT4 = reinterpret(0x3FB745CDC54C206E), // 9.09088713343650656196e-02\n aT5 = reinterpret(0xBFB3B0F2AF749A6D), // -7.69187620504482999495e-02\n aT6 = reinterpret(0x3FB10D66A0D03D51), // 6.66107313738753120669e-02\n aT7 = reinterpret(0xBFADDE2D52DEFD9A), // -5.83357013379057348645e-02\n aT8 = reinterpret(0x3FA97B4B24760DEB), // 4.97687799461593236017e-02\n aT9 = reinterpret(0xBFA2B4442C6A6C2F), // -3.65315727442169155270e-02\n aT10 = reinterpret(0x3F90AD3AE322DA11), // 1.62858201153657823623e-02\n Ox1p_120f = reinterpret(0x03800000);\n var ix = (reinterpret(x) >> 32);\n var sx = x;\n ix &= 0x7FFFFFFF;\n var z: f64;\n if (ix >= 0x44100000) {\n if (isNaN(x)) return x;\n z = atanhi3 + Ox1p_120f;\n return builtin_copysign(z, sx);\n }\n var id: i32;\n if (ix < 0x3FDC0000) {\n if (ix < 0x3E400000) return x;\n id = -1;\n } else {\n x = builtin_abs(x);\n if (ix < 0x3FF30000) {\n if (ix < 0x3FE60000) {\n id = 0;\n x = (2.0 * x - 1.0) / (2.0 + x);\n } else {\n id = 1;\n x = (x - 1.0) / (x + 1.0);\n }\n } else {\n if (ix < 0x40038000) {\n id = 2;\n x = (x - 1.5) / (1.0 + 1.5 * x);\n } else {\n id = 3;\n x = -1.0 / x;\n }\n }\n }\n z = x * x;\n var w = z * z;\n var s1 = z * (aT0 + w * (aT2 + w * (aT4 + w * (aT6 + w * (aT8 + w * aT10)))));\n var s2 = w * (aT1 + w * (aT3 + w * (aT5 + w * (aT7 + w * aT9))));\n var s3 = x * (s1 + s2);\n if (id < 0) return x - s3;\n switch (id) {\n case 0: { z = atanhi0 - ((s3 - atanlo0) - x); break; }\n case 1: { z = atanhi1 - ((s3 - atanlo1) - x); break; }\n case 2: { z = atanhi2 - ((s3 - atanlo2) - x); break; }\n case 3: { z = atanhi3 - ((s3 - atanlo3) - x); break; }\n default: unreachable();\n }\n return builtin_copysign(z, sx);\n }\n\n export function atanh(x: f64): f64 { // see: musl/src/math/atanh.c\n var u = reinterpret(x);\n var e = u >> 52 & 0x7FF;\n var s = u >> 63;\n u &= 0x7FFFFFFFFFFFFFFF;\n var y = reinterpret(u);\n if (e < 0x3FF - 1) {\n if (e >= 0x3FF - 32) y = 0.5 * log1p(2 * y + 2 * y * y / (1 - y));\n } else {\n y = 0.5 * log1p(2 * (y / (1 - y)));\n }\n return builtin_copysign(y, x);\n }\n\n export function atan2(y: f64, x: f64): f64 { // see: musl/src/math/atan2.c and SUN COPYRIGHT NOTICE above\n const pi_lo = reinterpret(0x3CA1A62633145C07); // 1.2246467991473531772E-16\n if (isNaN(x) || isNaN(y)) return x + y;\n var u = reinterpret(x);\n var ix = (u >> 32);\n var lx = u;\n u = reinterpret(y);\n var iy = (u >> 32);\n var ly = u;\n if ((ix - 0x3FF00000 | lx) == 0) return atan(y);\n var m = ((iy >> 31) & 1) | ((ix >> 30) & 2);\n ix = ix & 0x7FFFFFFF;\n iy = iy & 0x7FFFFFFF;\n if ((iy | ly) == 0) {\n switch (m) {\n case 0:\n case 1: return y;\n case 2: return PI;\n case 3: return -PI;\n }\n }\n if ((ix | lx) == 0) return m & 1 ? -PI / 2 : PI / 2;\n if (ix == 0x7FF00000) {\n if (iy == 0x7FF00000) {\n switch (m) {\n case 0: return PI / 4;\n case 1: return -PI / 4;\n case 2: return 3 * PI / 4;\n case 3: return -3 * PI / 4;\n }\n } else {\n switch (m) {\n case 0: return 0.0;\n case 1: return -0.0;\n case 2: return PI;\n case 3: return -PI;\n }\n }\n }\n var z: f64;\n if (ix + (64 << 20) < iy || iy == 0x7FF00000) return m & 1 ? -PI / 2 : PI / 2;\n if ((m & 2) && iy + (64 << 20) < ix) z = 0;\n else z = atan(builtin_abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return PI - (z - pi_lo);\n case 3: return (z - pi_lo) - PI;\n }\n unreachable();\n return 0;\n }\n\n export function cbrt(x: f64): f64 { // see: musl/src/math/cbrt.c and SUN COPYRIGHT NOTICE above\n const\n B1 = 715094163,\n B2 = 696219795,\n P0 = reinterpret(0x3FFE03E60F61E692), // 1.87595182427177009643\n P1 = reinterpret(0xBFFE28E092F02420), // -1.88497979543377169875\n P2 = reinterpret(0x3FF9F1604A49D6C2), // 1.621429720105354466140\n P3 = reinterpret(0xBFE844CBBEE751D9), // -0.758397934778766047437\n P4 = reinterpret(0x3FC2B000D4E4EDD7), // 0.145996192886612446982\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32) & 0x7FFFFFFF;\n if (hx >= 0x7FF00000) return x + x;\n if (hx < 0x00100000) {\n u = reinterpret(x * Ox1p54);\n hx = (u >> 32) & 0x7FFFFFFF;\n if (hx == 0) return x;\n hx = hx / 3 + B2;\n } else {\n hx = hx / 3 + B1;\n }\n u &= 1 << 63;\n u |= hx << 32;\n var t = reinterpret(u);\n var r = (t * t) * (t / x);\n t = t * ((P0 + r * (P1 + r * P2)) + ((r * r) * r) * (P3 + r * P4));\n t = reinterpret((reinterpret(t) + 0x80000000) & 0xFFFFFFFFC0000000);\n var s = t * t;\n r = x / s;\n r = (r - t) / (2 * t + r);\n t = t + t * r;\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function ceil(x: f64): f64 {\n return builtin_ceil(x);\n }\n\n export function clz32(x: f64): f64 {\n if (!isFinite(x)) return 32;\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n return builtin_clz(\n (x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))\n );\n }\n\n export function cos(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function cosh(x: f64): f64 { // see: musl/src/math/cosh.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFFFFFFFFFF;\n x = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n if (w < 0x3FE62E42) {\n if (w < 0x3FF00000 - (26 << 20)) return 1;\n t = expm1(x);\n // return 1 + t * t / (2 * (1 + t));\n return 1 + t * t / (2 + 2 * t);\n }\n if (w < 0x40862E42) {\n t = exp(x);\n return 0.5 * (t + 1 / t);\n }\n t = expo2(x);\n return t;\n }\n\n export function exp(x: f64): f64 { // see: musl/src/math/exp.c and SUN COPYRIGHT NOTICE above\n const\n ln2hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n invln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n P1 = reinterpret(0x3FC555555555553E), // 1.66666666666666019037e-01\n P2 = reinterpret(0xBF66C16C16BEBD93), // -2.77777777770155933842e-03\n P3 = reinterpret(0x3F11566AAF25DE2C), // 6.61375632143793436117e-05\n P4 = reinterpret(0xBEBBBD41C5D26BF1), // -1.65339022054652515390e-06\n P5 = reinterpret(0x3E66376972BEA4D0), // 4.13813679705723846039e-08\n overflow = reinterpret(0x40862E42FEFA39EF), // 709.782712893383973096\n underflow = reinterpret(0xC0874910D52D3051), // -745.13321910194110842\n Ox1p1023 = reinterpret(0x7FE0000000000000);\n var hx = (reinterpret(x) >> 32);\n var sign_ = (hx >> 31);\n hx &= 0x7FFFFFFF;\n if (hx >= 0x4086232B) {\n if (isNaN(x)) return x;\n if (x > overflow) return x * Ox1p1023;\n if (x < underflow) return 0;\n }\n var hi: f64, lo: f64 = 0;\n var k = 0;\n if (hx > 0x3FD62E42) {\n if (hx >= 0x3FF0A2B2) {\n k = (invln2 * x + builtin_copysign(0.5, x));\n } else {\n k = 1 - (sign_ << 1);\n }\n hi = x - k * ln2hi;\n lo = k * ln2lo;\n x = hi - lo;\n } else if (hx > 0x3E300000) {\n hi = x;\n } else return 1.0 + x;\n var xs = x * x;\n // var c = x - xp2 * (P1 + xp2 * (P2 + xp2 * (P3 + xp2 * (P4 + xp2 * P5))));\n var xq = xs * xs;\n var c = x - (xs * P1 + xq * ((P2 + xs * P3) + xq * (P4 + xs * P5)));\n var y = 1.0 + (x * c / (2 - c) - lo + hi);\n if (k == 0) return y;\n return scalbn(y, k);\n }\n\n export function expm1(x: f64): f64 { // see: musl/src/math/expm1.c and SUN COPYRIGHT NOTICE above\n const\n o_threshold = reinterpret(0x40862E42FEFA39EF), // 7.09782712893383973096e+02\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n invln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n Q1 = reinterpret(0xBFA11111111110F4), // -3.33333333333331316428e-02\n Q2 = reinterpret(0x3F5A01A019FE5585), // 1.58730158725481460165e-03\n Q3 = reinterpret(0xBF14CE199EAADBB7), // -7.93650757867487942473e-05\n Q4 = reinterpret(0x3ED0CFCA86E65239), // 4.00821782732936239552e-06\n Q5 = reinterpret(0xBE8AFDB76E09C32D), // -2.01099218183624371326e-07\n Ox1p1023 = reinterpret(0x7FE0000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32 & 0x7FFFFFFF);\n var k = 0, sign_ = (u >> 63);\n if (hx >= 0x4043687A) {\n if (isNaN(x)) return x;\n if (sign_) return -1;\n if (x > o_threshold) return x * Ox1p1023;\n }\n var c = 0.0, t: f64;\n if (hx > 0x3FD62E42) {\n k = select(\n 1 - (sign_ << 1),\n (invln2 * x + builtin_copysign(0.5, x)),\n hx < 0x3FF0A2B2\n );\n t = k;\n let hi = x - t * ln2_hi;\n let lo = t * ln2_lo;\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (hx < 0x3C900000) return x;\n var hfx = 0.5 * x;\n var hxs = x * hfx;\n // var r1 = 1.0 + hxs * (Q1 + hxs * (Q2 + hxs * (Q3 + hxs * (Q4 + hxs * Q5))));\n var hxq = hxs * hxs;\n var r1 = (1.0 + hxs * Q1) + hxq * ((Q2 + hxs * Q3) + hxq * (Q4 + hxs * Q5));\n t = 3.0 - r1 * hfx;\n var e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k == 0) return x - (x * e - hxs);\n e = x * (e - c) - c;\n e -= hxs;\n if (k == -1) return 0.5 * (x - e) - 0.5;\n if (k == 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n u = (0x3FF + k) << 52;\n var twopk = reinterpret(u);\n var y: f64;\n if (k < 0 || k > 56) {\n y = x - e + 1.0;\n if (k == 1024) y = y * 2.0 * Ox1p1023;\n else y = y * twopk;\n return y - 1.0;\n }\n u = (0x3FF - k) << 52;\n y = reinterpret(u);\n if (k < 20) y = (1 - y) - e;\n else y = 1 - (e + y);\n return (x + y) * twopk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function floor(x: f64): f64 {\n return builtin_floor(x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function fround(x: f64): f32 {\n return x;\n }\n\n export function hypot(x: f64, y: f64): f64 { // see: musl/src/math/hypot.c\n const\n SPLIT = reinterpret(0x41A0000000000000) + 1, // 0x1p27 + 1\n Ox1p700 = reinterpret(0x6BB0000000000000),\n Ox1p_700 = reinterpret(0x1430000000000000);\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n ux &= 0x7FFFFFFFFFFFFFFF;\n uy &= 0x7FFFFFFFFFFFFFFF;\n if (ux < uy) {\n let ut = ux;\n ux = uy;\n uy = ut;\n }\n var ex = (ux >> 52);\n var ey = (uy >> 52);\n y = reinterpret(uy);\n if (ey == 0x7FF) return y;\n x = reinterpret(ux);\n if (ex == 0x7FF || uy == 0) return x;\n if (ex - ey > 64) return x + y;\n var z = 1.0;\n if (ex > 0x3FF + 510) {\n z = Ox1p700;\n x *= Ox1p_700;\n y *= Ox1p_700;\n } else if (ey < 0x3FF - 450) {\n z = Ox1p_700;\n x *= Ox1p700;\n y *= Ox1p700;\n }\n var c = x * SPLIT;\n var h = x - c + c;\n var l = x - h;\n var hx = x * x;\n var lx = h * h - hx + (2 * h + l) * l;\n c = y * SPLIT;\n h = y - c + c;\n l = y - h;\n var hy = y * y;\n var ly = h * h - hy + (2 * h + l) * l;\n return z * builtin_sqrt(ly + lx + hy + hx);\n }\n\n export function imul(x: f64, y: f64): f64 {\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n if (!isFinite(x + y)) return 0;\n const inv32 = 1.0 / 4294967296;\n return (\n (x - 4294967296 * builtin_floor(x * inv32)) *\n (y - 4294967296 * builtin_floor(y * inv32))\n );\n }\n\n export function log(x: f64): f64 { // see: musl/src/math/log.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var dk = k;\n return s * (hfsq + r) + dk * ln2_lo - hfsq + f + dk * ln2_hi;\n }\n\n export function log10(x: f64): f64 { // see: musl/src/math/log10.c and SUN COPYRIGHT NOTICE above\n const\n ivln10hi = reinterpret(0x3FDBCB7B15200000), // 4.34294481878168880939e-01\n ivln10lo = reinterpret(0x3DBB9438CA9AADD5), // 2.50829467116452752298e-11\n log10_2hi = reinterpret(0x3FD34413509F6000), // 3.01029995663611771306e-01\n log10_2lo = reinterpret(0x3D59FEF311F12B36), // 3.69423907715893078616e-13\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var hi = f - hfsq;\n u = reinterpret(hi);\n u &= 0xFFFFFFFF00000000;\n hi = reinterpret(u);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var val_hi = hi * ivln10hi;\n var dk = k;\n var y = dk * log10_2hi;\n var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi;\n w = y + val_hi;\n val_lo += (y - w) + val_hi;\n return val_lo + w;\n }\n\n export function log1p(x: f64): f64 { // see: musl/src/math/log1p.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244); // 1.479819860511658591e-01\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 1;\n var c = 0.0, f = 0.0;\n if (hx < 0x3FDA827A || (hx >> 31)) {\n if (hx >= 0xBFF00000) {\n if (x == -1) return x / 0.0;\n return (x - x) / 0.0;\n }\n if (hx << 1 < 0x3CA00000 << 1) return x;\n if (hx <= 0xBFD2BEC4) {\n k = 0;\n c = 0;\n f = x;\n }\n } else if (hx >= 0x7FF00000) return x;\n if (k) {\n u = reinterpret(1 + x);\n let hu = (u >> 32);\n hu += 0x3FF00000 - 0x3FE6A09E;\n k = (hu >> 20) - 0x3FF;\n if (k < 54) {\n let uf = reinterpret(u);\n c = k >= 2 ? 1 - (uf - x) : x - (uf - 1);\n c /= uf;\n } else c = 0;\n hu = (hu & 0x000FFFFF) + 0x3FE6A09E;\n u = hu << 32 | (u & 0xFFFFFFFF);\n f = reinterpret(u) - 1;\n }\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var dk = k;\n return s * (hfsq + r) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;\n }\n\n export function log2(x: f64): f64 { // see: musl/src/math/log2.c and SUN COPYRIGHT NOTICE above\n const\n ivln2hi = reinterpret(0x3FF7154765200000), // 1.44269504072144627571e+00\n ivln2lo = reinterpret(0x3DE705FC2EEFA200), // 1.67517131648865118353e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var hi = f - hfsq;\n u = reinterpret(hi);\n u &= 0xFFFFFFFF00000000;\n hi = reinterpret(u);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var val_hi = hi * ivln2hi;\n var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi;\n var y = k;\n w = y + val_hi;\n val_lo += (y - w) + val_hi;\n val_hi = w;\n return val_lo + val_hi;\n }\n\n // @ts-ignore: decorator\n @inline\n export function max(value1: f64, value2: f64): f64 {\n return builtin_max(value1, value2);\n }\n\n // @ts-ignore: decorator\n @inline\n export function min(value1: f64, value2: f64): f64 {\n return builtin_min(value1, value2);\n }\n\n export function pow(x: f64, y: f64): f64 { // see: musl/src/math/pow.c and SUN COPYRIGHT NOTICE above\n const\n dp_h1 = reinterpret(0x3FE2B80340000000), // 5.84962487220764160156e-01\n dp_l1 = reinterpret(0x3E4CFDEB43CFD006), // 1.35003920212974897128e-08\n two53 = reinterpret(0x4340000000000000), // 9007199254740992.0\n huge = reinterpret(0x7E37E43C8800759C), // 1e+300\n tiny = reinterpret(0x01A56E1FC2F8F359), // 1e-300\n L1 = reinterpret(0x3FE3333333333303), // 5.99999999999994648725e-01\n L2 = reinterpret(0x3FDB6DB6DB6FABFF), // 4.28571428578550184252e-01\n L3 = reinterpret(0x3FD55555518F264D), // 3.33333329818377432918e-01\n L4 = reinterpret(0x3FD17460A91D4101), // 2.72728123808534006489e-01\n L5 = reinterpret(0x3FCD864A93C9DB65), // 2.30660745775561754067e-01\n L6 = reinterpret(0x3FCA7E284A454EEF), // 2.06975017800338417784e-01\n P1 = reinterpret(0x3FC555555555553E), // 1.66666666666666019037e-01\n P2 = reinterpret(0xBF66C16C16BEBD93), // -2.77777777770155933842e-03\n P3 = reinterpret(0x3F11566AAF25DE2C), // 6.61375632143793436117e-05\n P4 = reinterpret(0xBEBBBD41C5D26BF1), // -1.65339022054652515390e-06\n P5 = reinterpret(0x3E66376972BEA4D0), // 4.13813679705723846039e-08\n lg2 = reinterpret(0x3FE62E42FEFA39EF), // 6.93147180559945286227e-01\n lg2_h = reinterpret(0x3FE62E4300000000), // 6.93147182464599609375e-01\n lg2_l = reinterpret(0xBE205C610CA86C39), // -1.90465429995776804525e-09\n ovt = reinterpret(0x3C971547652B82FE), // 8.0085662595372944372e-017\n cp = reinterpret(0x3FEEC709DC3A03FD), // 9.61796693925975554329e-01\n cp_h = reinterpret(0x3FEEC709E0000000), // 9.61796700954437255859e-01\n cp_l = reinterpret(0xBE3E2FE0145B01F5), // -7.02846165095275826516e-09\n ivln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n ivln2_h = reinterpret(0x3FF7154760000000), // 1.44269502162933349609e+00\n ivln2_l = reinterpret(0x3E54AE0BF85DDF44), // 1.92596299112661746887e-08\n inv3 = reinterpret(0x3FD5555555555555); // 0.3333333333333333333333\n var u_ = reinterpret(x);\n var hx = (u_ >> 32);\n var lx = u_;\n u_ = reinterpret(y);\n var hy = (u_ >> 32);\n var ly = u_;\n var ix = hx & 0x7FFFFFFF;\n var iy = hy & 0x7FFFFFFF;\n if ((iy | ly) == 0) return 1.0; // x**0 = 1, even if x is NaN\n // if (hx == 0x3FF00000 && lx == 0) return 1.0; // C: 1**y = 1, even if y is NaN, JS: NaN\n if ( // NaN if either arg is NaN\n ix > 0x7FF00000 || (ix == 0x7FF00000 && lx != 0) ||\n iy > 0x7FF00000 || (iy == 0x7FF00000 && ly != 0)\n ) return x + y;\n var yisint = 0, k: i32;\n if (hx < 0) {\n if (iy >= 0x43400000) yisint = 2;\n else if (iy >= 0x3FF00000) {\n k = (iy >> 20) - 0x3FF;\n let kcond = k > 20;\n let offset = select(52, 20, kcond) - k;\n let Ly = select(ly, iy, kcond);\n let jj = Ly >> offset;\n if ((jj << offset) == Ly) yisint = 2 - (jj & 1);\n }\n }\n if (ly == 0) {\n if (iy == 0x7FF00000) { // y is +-inf\n if (((ix - 0x3FF00000) | lx) == 0) return NaN; // C: (-1)**+-inf is 1, JS: NaN\n else if (ix >= 0x3FF00000) return hy >= 0 ? y : 0.0; // (|x|>1)**+-inf = inf,0\n else return hy >= 0 ? 0.0 : -y; // (|x|<1)**+-inf = 0,inf\n }\n if (iy == 0x3FF00000) {\n if (hy >= 0) return x;\n return 1 / x;\n }\n if (hy == 0x40000000) return x * x;\n if (hy == 0x3FE00000) {\n if (hx >= 0) return builtin_sqrt(x);\n }\n }\n var ax = builtin_abs(x), z: f64;\n if (lx == 0) {\n if (ix == 0 || ix == 0x7FF00000 || ix == 0x3FF00000) {\n z = ax;\n if (hy < 0) z = 1.0 / z;\n if (hx < 0) {\n if (((ix - 0x3FF00000) | yisint) == 0) {\n let d = z - z;\n z = d / d;\n } else if (yisint == 1) z = -z;\n }\n return z;\n }\n }\n var s = 1.0;\n if (hx < 0) {\n if (yisint == 0) {\n let d = x - x;\n return d / d;\n }\n if (yisint == 1) s = -1.0;\n }\n var t1: f64, t2: f64, p_h: f64, p_l: f64, r: f64, t: f64, u: f64, v: f64, w: f64;\n var j: i32, n: i32;\n if (iy > 0x41E00000) {\n if (iy > 0x43F00000) {\n if (ix <= 0x3FEFFFFF) return hy < 0 ? huge * huge : tiny * tiny;\n if (ix >= 0x3FF00000) return hy > 0 ? huge * huge : tiny * tiny;\n }\n if (ix < 0x3FEFFFFF) return hy < 0 ? s * huge * huge : s * tiny * tiny;\n if (ix > 0x3FF00000) return hy > 0 ? s * huge * huge : s * tiny * tiny;\n t = ax - 1.0;\n w = (t * t) * (0.5 - t * (inv3 - t * 0.25));\n u = ivln2_h * t;\n v = t * ivln2_l - w * ivln2;\n t1 = u + v;\n t1 = reinterpret(reinterpret(t1) & 0xFFFFFFFF00000000);\n t2 = v - (t1 - u);\n } else {\n let ss: f64, s2: f64, s_h: f64, s_l: f64, t_h: f64, t_l: f64;\n n = 0;\n if (ix < 0x00100000) {\n ax *= two53;\n n -= 53;\n ix = (reinterpret(ax) >> 32);\n }\n n += (ix >> 20) - 0x3FF;\n j = ix & 0x000FFFFF;\n ix = j | 0x3FF00000;\n if (j <= 0x3988E) k = 0;\n else if (j < 0xBB67A) k = 1;\n else {\n k = 0;\n n += 1;\n ix -= 0x00100000;\n }\n ax = reinterpret(reinterpret(ax) & 0xFFFFFFFF | (ix << 32));\n let bp = select(1.5, 1.0, k); // k ? 1.5 : 1.0\n u = ax - bp;\n v = 1.0 / (ax + bp);\n ss = u * v;\n s_h = ss;\n s_h = reinterpret(reinterpret(s_h) & 0xFFFFFFFF00000000);\n t_h = reinterpret((((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18)) << 32);\n t_l = ax - (t_h - bp);\n s_l = v * ((u - s_h * t_h) - s_h * t_l);\n s2 = ss * ss;\n r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));\n r += s_l * (s_h + ss);\n s2 = s_h * s_h;\n t_h = 3.0 + s2 + r;\n t_h = reinterpret(reinterpret(t_h) & 0xFFFFFFFF00000000);\n t_l = r - ((t_h - 3.0) - s2);\n u = s_h * t_h;\n v = s_l * t_h + t_l * ss;\n p_h = u + v;\n p_h = reinterpret(reinterpret(p_h) & 0xFFFFFFFF00000000);\n p_l = v - (p_h - u);\n let z_h = cp_h * p_h;\n let dp_l = select(dp_l1, 0.0, k);\n let z_l = cp_l * p_h + p_l * cp + dp_l;\n t = n;\n let dp_h = select(dp_h1, 0.0, k);\n t1 = ((z_h + z_l) + dp_h) + t;\n t1 = reinterpret(reinterpret(t1) & 0xFFFFFFFF00000000);\n t2 = z_l - (((t1 - t) - dp_h) - z_h);\n }\n var y1 = y;\n y1 = reinterpret(reinterpret(y1) & 0xFFFFFFFF00000000);\n p_l = (y - y1) * t1 + y * t2;\n p_h = y1 * t1;\n z = p_l + p_h;\n u_ = reinterpret(z);\n j = (u_ >> 32);\n var i = u_;\n if (j >= 0x40900000) {\n if (((j - 0x40900000) | i) != 0) return s * huge * huge;\n if (p_l + ovt > z - p_h) return s * huge * huge;\n } else if ((j & 0x7FFFFFFF) >= 0x4090CC00) {\n if (((j - 0xC090CC00) | i) != 0) return s * tiny * tiny;\n if (p_l <= z - p_h) return s * tiny * tiny;\n }\n i = j & 0x7FFFFFFF;\n k = (i >> 20) - 0x3FF;\n n = 0;\n if (i > 0x3FE00000) {\n n = j + (0x00100000 >> (k + 1));\n k = ((n & 0x7FFFFFFF) >> 20) - 0x3FF;\n t = 0.0;\n t = reinterpret((n & ~(0x000FFFFF >> k)) << 32);\n n = ((n & 0x000FFFFF) | 0x00100000) >> (20 - k);\n if (j < 0) n = -n;\n p_h -= t;\n }\n t = p_l + p_h;\n t = reinterpret(reinterpret(t) & 0xFFFFFFFF00000000);\n u = t * lg2_h;\n v = (p_l - (t - p_h)) * lg2 + t * lg2_l;\n z = u + v;\n w = v - (z - u);\n t = z * z;\n t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n r = (z * t1) / (t1 - 2.0) - (w + z * w);\n z = 1.0 - (r - z);\n j = (reinterpret(z) >> 32);\n j += n << 20;\n if ((j >> 20) <= 0) z = scalbn(z, n);\n else z = reinterpret(reinterpret(z) & 0xFFFFFFFF | (j << 32));\n return s * z;\n }\n\n export function seedRandom(value: i64): void {\n assert(value);\n random_seeded = true;\n random_state0_64 = murmurHash3(value);\n random_state1_64 = murmurHash3(~random_state0_64);\n random_state0_32 = splitMix32(value);\n random_state1_32 = splitMix32(random_state0_32);\n }\n\n export function random(): f64 { // see: v8/src/base/random-number-generator.cc\n if (!random_seeded) throw new Error("PRNG must be seeded.");\n var s1 = random_state0_64;\n var s0 = random_state1_64;\n random_state0_64 = s0;\n s1 ^= s1 << 23;\n s1 ^= s1 >> 17;\n s1 ^= s0;\n s1 ^= s0 >> 26;\n random_state1_64 = s1;\n var r = ((s0 + s1) & 0x000FFFFFFFFFFFFF) | 0x3FF0000000000000;\n return reinterpret(r) - 1;\n }\n\n // @ts-ignore: decorator\n @inline\n export function round(x: f64): f64 {\n return builtin_copysign(builtin_floor(x + 0.5), x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function sign(x: f64): f64 {\n if (ASC_SHRINK_LEVEL > 0) {\n return builtin_abs(x) > 0 ? builtin_copysign(1, x) : x;\n } else {\n return x > 0 ? 1 : x < 0 ? -1 : x;\n }\n }\n\n // @ts-ignore: decorator\n @inline\n export function signbit(x: f64): bool {\n // In ECMAScript all NaN values are indistinguishable from each other\n // so we need handle NaN and negative NaN in similar way\n return ((reinterpret(x) >>> 63) & i32(x == x));\n }\n\n export function sin(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function sinh(x: f64): f64 { // see: musl/src/math/sinh.c\n var u = reinterpret(x) & 0x7FFFFFFFFFFFFFFF;\n var absx = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n var h = builtin_copysign(0.5, x);\n if (w < 0x40862E42) {\n t = expm1(absx);\n if (w < 0x3FF00000) {\n if (w < 0x3FF00000 - (26 << 20)) return x;\n return h * (2 * t - t * t / (t + 1));\n }\n return h * (t + t / (t + 1));\n }\n t = 2 * h * expo2(absx);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function sqrt(x: f64): f64 {\n return builtin_sqrt(x);\n }\n\n export function tan(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function tanh(x: f64): f64 { // see: musl/src/math/tanh.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFFFFFFFFFF;\n var y = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n if (w > 0x3FE193EA) {\n if (w > 0x40340000) {\n t = 1 - 0 / y;\n } else {\n t = expm1(2 * y);\n t = 1 - 2 / (t + 2);\n }\n } else if (w > 0x3FD058AE) {\n t = expm1(2 * y);\n t = t / (t + 2);\n } else if (w >= 0x00100000) {\n t = expm1(-2 * y);\n t = -t / (t + 2);\n } else t = y;\n return builtin_copysign(t, x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function trunc(x: f64): f64 {\n return builtin_trunc(x);\n }\n\n export function scalbn(x: f64, n: i32): f64 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbn.c\n const\n Ox1p53 = reinterpret(0x4340000000000000),\n Ox1p1023 = reinterpret(0x7FE0000000000000),\n Ox1p_1022 = reinterpret(0x0010000000000000);\n var y = x;\n if (n > 1023) {\n y *= Ox1p1023;\n n -= 1023;\n if (n > 1023) {\n y *= Ox1p1023;\n n = builtin_min(n - 1023, 1023);\n }\n } else if (n < -1022) {\n /* make sure final n < -53 to avoid double\n rounding in the subnormal range */\n y *= Ox1p_1022 * Ox1p53;\n n += 1022 - 53;\n if (n < -1022) {\n y *= Ox1p_1022 * Ox1p53;\n n = builtin_max(n + 1022 - 53, -1022);\n }\n }\n return y * reinterpret((0x3FF + n) << 52);\n }\n\n export function mod(x: f64, y: f64): f64 { // see: musl/src/math/fmod.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 52 & 0x7FF);\n var ey = (uy >> 52 & 0x7FF);\n var sx = ux >> 63;\n var uy1 = uy << 1;\n if (uy1 == 0 || ex == 0x7FF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n var ux1 = ux << 1;\n if (ux1 <= uy1) {\n if (ux1 == uy1) return 0 * x;\n return x;\n }\n if (!ex) {\n ex -= builtin_clz(ux << 12);\n ux <<= -ex + 1;\n } else {\n ux &= -1 >> 12;\n ux |= 1 << 52;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 12);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 12;\n uy |= 1 << 52;\n }\n while (ex > ey) {\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n ux <<= 1;\n --ex;\n }\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n // for (; !(ux >> 52); ux <<= 1) --ex;\n var shift = builtin_clz(ux << 11);\n ex -= shift;\n ux <<= shift;\n if (ex > 0) {\n ux -= 1 << 52;\n ux |= ex << 52;\n } else {\n ux >>= -ex + 1;\n }\n ux |= sx << 63;\n return reinterpret(ux);\n }\n\n export function rem(x: f64, y: f64): f64 { // see: musl/src/math/remquo.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 52 & 0x7FF);\n var ey = (uy >> 52 & 0x7FF);\n var sx = (ux >> 63);\n if (uy << 1 == 0 || ex == 0x7FF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n if (ux << 1 == 0) return x;\n var uxi = ux;\n if (!ex) {\n ex -= builtin_clz(uxi << 12);\n uxi <<= -ex + 1;\n } else {\n uxi &= -1 >> 12;\n uxi |= 1 << 52;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 12);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 12;\n uy |= 1 << 52;\n }\n var q: u32 = 0;\n do {\n if (ex < ey) {\n if (ex + 1 == ey) break; // goto end\n return x;\n }\n while (ex > ey) {\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n uxi <<= 1;\n q <<= 1;\n --ex;\n }\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n if (uxi == 0) ex = -60;\n else {\n let shift = builtin_clz(uxi << 11);\n ex -= shift;\n uxi <<= shift;\n }\n break;\n } while (false);\n // end:\n if (ex > 0) {\n uxi -= 1 << 52;\n uxi |= ex << 52;\n } else {\n uxi >>= -ex + 1;\n }\n x = reinterpret(uxi);\n y = builtin_abs(y);\n var x2 = x + x;\n if (ex == ey || (ex + 1 == ey && (x2 > y || (x2 == y && (q & 1))))) {\n x -= y;\n // ++q;\n }\n return sx ? -x : x;\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar rempio2f_y: f64;\n\n// @ts-ignore: decorator\n@lazy\nconst PIO2_TABLE: u64[] = [\n 0xA2F9836E4E441529,\n 0xFC2757D1F534DDC0,\n 0xDB6295993C439041,\n 0xFE5163ABDEBBC561\n];\n\nfunction Rf(z: f32): f32 { // Rational approximation of (asin(x)-x)/x^3\n const // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above\n pS0 = reinterpret(0x3E2AAA75), // 1.6666586697e-01f\n pS1 = reinterpret(0xBD2F13BA), // -4.2743422091e-02f\n pS2 = reinterpret(0xBC0DD36B), // -8.6563630030e-03f\n qS1 = reinterpret(0xBF34E5AE); // -7.0662963390e-01f\n var p = z * (pS0 + z * (pS1 + z * pS2));\n var q: f32 = 1 + z * qS1;\n return p / q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction expo2f(x: f32): f32 { // exp(x)/2 for x >= log(DBL_MAX)\n const // see: musl/src/math/__expo2f.c\n k = 235,\n kln2 = reinterpret(0x4322E3BC); // 0x1.45c778p+7f\n var scale = reinterpret((0x7F + (k >> 1)) << 23);\n return NativeMathf.exp(x - kln2) * scale * scale;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction pio2_large_quot(x: f32, u: i32): i32 { // see: jdh8/metallic/blob/master/src/math/float/rem_pio2f.c\n const coeff = reinterpret(0x3BF921FB54442D18); // π * 0x1p-65 = 8.51530395021638647334e-20\n const bits = PIO2_TABLE;\n\n var offset = (u >> 23) - 152;\n var index = offset >> 6;\n var shift = offset & 63;\n\n var b0 = unchecked(bits[index + 0]);\n var b1 = unchecked(bits[index + 1]);\n var lo: u64;\n\n if (shift > 32) {\n let b2 = unchecked(bits[index + 2]);\n lo = b2 >> (96 - shift);\n lo |= b1 << (shift - 32);\n } else {\n lo = b1 >> (32 - shift);\n }\n\n var hi = (b1 >> (64 - shift)) | (b0 << shift);\n var mantissa: u64 = (u & 0x007FFFFF) | 0x00800000;\n var product: u64 = mantissa * hi + (mantissa * lo >> 32);\n var r: i64 = product << 2;\n var q: i32 = ((product >> 62) + (r >>> 63));\n rempio2f_y = copysign(coeff, x) * r;\n return q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction rempio2f(x: f32, u: u32, sign: i32): i32 { // see: jdh8/metallic/blob/master/src/math/float/rem_pio2f.c\n const pi2hi = reinterpret(0x3FF921FB50000000); // 1.57079631090164184570\n const pi2lo = reinterpret(0x3E5110B4611A6263); // 1.58932547735281966916e-8\n const _2_pi = reinterpret(0x3FE45F306DC9C883); // 0.63661977236758134308\n\n if (u < 0x4DC90FDB) { /* π * 0x1p28 */\n let q = nearest(x * _2_pi);\n rempio2f_y = x - q * pi2hi - q * pi2lo;\n return q;\n }\n\n var q = pio2_large_quot(x, u);\n return select(-q, q, sign);\n}\n\n/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */\n// @ts-ignore: decorator\n@inline\nfunction sin_kernf(x: f64): f32 { // see: musl/tree/src/math/__sindf.c\n const S1 = reinterpret(0xBFC5555554CBAC77); // -0x15555554cbac77.0p-55\n const S2 = reinterpret(0x3F811110896EFBB2); // 0x111110896efbb2.0p-59\n const S3 = reinterpret(0xBF2A00F9E2CAE774); // -0x1a00f9e2cae774.0p-65\n const S4 = reinterpret(0x3EC6CD878C3B46A7); // 0x16cd878c3b46a7.0p-71\n\n var z = x * x;\n var w = z * z;\n var r = S3 + z * S4;\n var s = z * x;\n return ((x + s * (S1 + z * S2)) + s * w * r);\n}\n\n/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */\n// @ts-ignore: decorator\n@inline\nfunction cos_kernf(x: f64): f32 { // see: musl/tree/src/math/__cosdf.c\n const C0 = reinterpret(0xBFDFFFFFFD0C5E81); // -0x1ffffffd0c5e81.0p-54\n const C1 = reinterpret(0x3FA55553E1053A42); // 0x155553e1053a42.0p-57\n const C2 = reinterpret(0xBF56C087E80F1E27); // -0x16c087e80f1e27.0p-62\n const C3 = reinterpret(0x3EF99342E0EE5069); // 0x199342e0ee5069.0p-68\n\n var z = x * x;\n var w = z * z;\n var r = C2 + z * C3;\n return (((1 + z * C0) + w * C1) + (w * z) * r);\n}\n\n/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */\n// @ts-ignore: decorator\n@inline\nfunction tan_kernf(x: f64, odd: i32): f32 { // see: musl/tree/src/math/__tandf.c\n\n const T0 = reinterpret(0x3FD5554D3418C99F); /* 0x15554d3418c99f.0p-54 */\n const T1 = reinterpret(0x3FC112FD38999F72); /* 0x1112fd38999f72.0p-55 */\n const T2 = reinterpret(0x3FAB54C91D865AFE); /* 0x1b54c91d865afe.0p-57 */\n const T3 = reinterpret(0x3F991DF3908C33CE); /* 0x191df3908c33ce.0p-58 */\n const T4 = reinterpret(0x3F685DADFCECF44E); /* 0x185dadfcecf44e.0p-61 */\n const T5 = reinterpret(0x3F8362B9BF971BCD); /* 0x1362b9bf971bcd.0p-59 */\n\n var z = x * x;\n var r = T4 + z * T5;\n var t = T2 + z * T3;\n var w = z * z;\n var s = z * x;\n var u = T0 + z * T1;\n\n r = (x + s * u) + (s * w) * (t + w * r);\n return (odd ? -1 / r : r);\n}\n\nexport namespace NativeMathf {\n\n // @ts-ignore: decorator\n @lazy\n export const E = NativeMath.E;\n\n // @ts-ignore: decorator\n @lazy\n export const LN2 = NativeMath.LN2;\n\n // @ts-ignore: decorator\n @lazy\n export const LN10 = NativeMath.LN10;\n\n // @ts-ignore: decorator\n @lazy\n export const LOG2E = NativeMath.LOG2E;\n\n // @ts-ignore: decorator\n @lazy\n export const LOG10E = NativeMath.LOG10E;\n\n // @ts-ignore: decorator\n @lazy\n export const PI = NativeMath.PI;\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT1_2 = NativeMath.SQRT1_2;\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT2 = NativeMath.SQRT2;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_sin: f32 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_cos: f32 = 0;\n\n // @ts-ignore: decorator\n @inline\n export function abs(x: f32): f32 {\n return builtin_abs(x);\n }\n\n export function acos(x: f32): f32 { // see: musl/src/math/acosf.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FC90FDA), // 1.5707962513e+00f\n pio2_lo = reinterpret(0x33A22168), // 7.5497894159e-08f\n Ox1p_120f = reinterpret(0x03800000);\n var hx = reinterpret(x);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3F800000) {\n if (ix == 0x3F800000) {\n if (hx >> 31) return 2 * pio2_hi + Ox1p_120f;\n return 0;\n }\n return 0 / (x - x);\n }\n if (ix < 0x3F000000) {\n if (ix <= 0x32800000) return pio2_hi + Ox1p_120f;\n return pio2_hi - (x - (pio2_lo - x * Rf(x * x)));\n }\n var z: f32, w: f32, s: f32;\n if (hx >> 31) {\n // z = (1 + x) * 0.5;\n z = 0.5 + x * 0.5;\n s = builtin_sqrt(z);\n w = Rf(z) * s - pio2_lo;\n return 2 * (pio2_hi - (s + w));\n }\n // z = (1 - x) * 0.5;\n z = 0.5 - x * 0.5;\n s = builtin_sqrt(z);\n hx = reinterpret(s);\n var df = reinterpret(hx & 0xFFFFF000);\n var c = (z - df * df) / (s + df);\n w = Rf(z) * s + c;\n return 2 * (df + w);\n }\n\n export function acosh(x: f32): f32 { // see: musl/src/math/acoshf.c\n const s = reinterpret(0x3F317218); // 0.693147180559945309417232121458176568f\n var u = reinterpret(x);\n var a = u & 0x7FFFFFFF;\n if (a < 0x3F800000 + (1 << 23)) {\n let xm1 = x - 1;\n return log1p(xm1 + builtin_sqrt(xm1 * (xm1 + 2)));\n }\n if (a < 0x3F800000 + (12 << 23)) return log(2 * x - 1 / (x + builtin_sqrt(x * x - 1)));\n return log(x) + s;\n }\n\n export function asin(x: f32): f32 { // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above\n const\n pio2 = reinterpret(0x3FC90FDB), // 1.570796326794896558e+00f\n Ox1p_120f = reinterpret(0x03800000);\n var sx = x;\n var hx = reinterpret(x) & 0x7FFFFFFF;\n if (hx >= 0x3F800000) {\n if (hx == 0x3F800000) return x * pio2 + Ox1p_120f;\n return 0 / (x - x);\n }\n if (hx < 0x3F000000) {\n if (hx < 0x39800000 && hx >= 0x00800000) return x;\n return x + x * Rf(x * x);\n }\n // var z: f32 = (1 - builtin_abs(x)) * 0.5;\n var z: f32 = 0.5 - builtin_abs(x) * 0.5;\n var s = builtin_sqrt(z); // sic\n x = (pio2 - 2 * (s + s * Rf(z)));\n return builtin_copysign(x, sx);\n }\n\n export function asinh(x: f32): f32 { // see: musl/src/math/asinhf.c\n const c = reinterpret(0x3F317218); // 0.693147180559945309417232121458176568f\n var u = reinterpret(x) & 0x7FFFFFFF;\n var y = reinterpret(u);\n if (u >= 0x3F800000 + (12 << 23)) y = log(y) + c;\n else if (u >= 0x3F800000 + (1 << 23)) y = log(2 * y + 1 / (builtin_sqrt(y * y + 1) + y));\n else if (u >= 0x3F800000 - (12 << 23)) y = log1p(y + y * y / (builtin_sqrt(y * y + 1) + 1));\n return builtin_copysign(y, x);\n }\n\n export function atan(x: f32): f32 { // see: musl/src/math/atanf.c and SUN COPYRIGHT NOTICE above\n const\n atanhi0 = reinterpret(0x3EED6338), // 4.6364760399e-01f\n atanhi1 = reinterpret(0x3F490FDA), // 7.8539812565e-01f\n atanhi2 = reinterpret(0x3F7B985E), // 9.8279368877e-01f\n atanhi3 = reinterpret(0x3FC90FDA), // 1.5707962513e+00f\n atanlo0 = reinterpret(0x31AC3769), // 5.0121582440e-09f\n atanlo1 = reinterpret(0x33222168), // 3.7748947079e-08f\n atanlo2 = reinterpret(0x33140FB4), // 3.4473217170e-08f\n atanlo3 = reinterpret(0x33A22168), // 7.5497894159e-08f\n aT0 = reinterpret(0x3EAAAAA9), // 3.3333328366e-01f\n aT1 = reinterpret(0xBE4CCA98), // -1.9999158382e-01f\n aT2 = reinterpret(0x3E11F50D), // 1.4253635705e-01f\n aT3 = reinterpret(0xBDDA1247), // -1.0648017377e-01f\n aT4 = reinterpret(0x3D7CAC25), // 6.1687607318e-02f\n Ox1p_120f = reinterpret(0x03800000);\n var ix = reinterpret(x);\n var sx = x;\n ix &= 0x7FFFFFFF;\n var z: f32;\n if (ix >= 0x4C800000) {\n if (isNaN(x)) return x;\n z = atanhi3 + Ox1p_120f;\n return builtin_copysign(z, sx);\n }\n var id: i32;\n if (ix < 0x3EE00000) {\n if (ix < 0x39800000) return x;\n id = -1;\n } else {\n x = builtin_abs(x);\n if (ix < 0x3F980000) {\n if (ix < 0x3F300000) {\n id = 0;\n x = (2.0 * x - 1.0) / (2.0 + x);\n } else {\n id = 1;\n x = (x - 1.0) / (x + 1.0);\n }\n } else {\n if (ix < 0x401C0000) {\n id = 2;\n x = (x - 1.5) / (1.0 + 1.5 * x);\n } else {\n id = 3;\n x = -1.0 / x;\n }\n }\n }\n z = x * x;\n var w = z * z;\n var s1 = z * (aT0 + w * (aT2 + w * aT4));\n var s2 = w * (aT1 + w * aT3);\n var s3 = x * (s1 + s2);\n if (id < 0) return x - s3;\n switch (id) {\n case 0: { z = atanhi0 - ((s3 - atanlo0) - x); break; }\n case 1: { z = atanhi1 - ((s3 - atanlo1) - x); break; }\n case 2: { z = atanhi2 - ((s3 - atanlo2) - x); break; }\n case 3: { z = atanhi3 - ((s3 - atanlo3) - x); break; }\n default: unreachable();\n }\n return builtin_copysign(z, sx);\n }\n\n export function atanh(x: f32): f32 { // see: musl/src/math/atanhf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n var y = reinterpret(u);\n if (u < 0x3F800000 - (1 << 23)) {\n if (u >= 0x3F800000 - (32 << 23)) y = 0.5 * log1p(2 * y * (1.0 + y / (1 - y)));\n } else y = 0.5 * log1p(2 * (y / (1 - y)));\n return builtin_copysign(y, x);\n }\n\n export function atan2(y: f32, x: f32): f32 { // see: musl/src/math/atan2f.c and SUN COPYRIGHT NOTICE above\n const\n pi = reinterpret(0x40490FDB), // 3.1415927410e+00f\n pi_lo = reinterpret(0xB3BBBD2E); // -8.7422776573e-08f\n if (isNaN(x) || isNaN(y)) return x + y;\n var ix = reinterpret(x);\n var iy = reinterpret(y);\n if (ix == 0x3F800000) return atan(y);\n var m = (((iy >> 31) & 1) | ((ix >> 30) & 2));\n ix &= 0x7FFFFFFF;\n iy &= 0x7FFFFFFF;\n if (iy == 0) {\n switch (m) {\n case 0:\n case 1: return y;\n case 2: return pi;\n case 3: return -pi;\n }\n }\n if (ix == 0) return m & 1 ? -pi / 2 : pi / 2;\n if (ix == 0x7F800000) {\n if (iy == 0x7F800000) {\n switch (m) {\n case 0: return pi / 4;\n case 1: return -pi / 4;\n case 2: return 3 * pi / 4;\n case 3: return -3 * pi / 4;\n }\n } else {\n switch (m) {\n case 0: return 0;\n case 1: return -0;\n case 2: return pi;\n case 3: return -pi;\n }\n }\n }\n if (ix + (26 << 23) < iy || iy == 0x7F800000) return m & 1 ? -pi / 2 : pi / 2;\n var z: f32;\n if ((m & 2) && iy + (26 << 23) < ix) z = 0.0;\n else z = atan(builtin_abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return pi - (z - pi_lo);\n case 3: return (z - pi_lo) - pi;\n }\n unreachable();\n return 0;\n }\n\n export function cbrt(x: f32): f32 { // see: musl/src/math/cbrtf.c and SUN COPYRIGHT NOTICE above\n const\n B1 = 709958130,\n B2 = 642849266,\n Ox1p24f = reinterpret(0x4B800000);\n var u = reinterpret(x);\n var hx = u & 0x7FFFFFFF;\n if (hx >= 0x7F800000) return x + x;\n if (hx < 0x00800000) {\n if (hx == 0) return x;\n u = reinterpret(x * Ox1p24f);\n hx = u & 0x7FFFFFFF;\n hx = hx / 3 + B2;\n } else {\n hx = hx / 3 + B1;\n }\n u &= 0x80000000;\n u |= hx;\n var t = reinterpret(u);\n var r = t * t * t;\n t = t * (x + x + r) / (x + r + r);\n r = t * t * t;\n t = t * (x + x + r) / (x + r + r);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function ceil(x: f32): f32 {\n return builtin_ceil(x);\n }\n\n export function clz32(x: f32): f32 {\n if (!isFinite(x)) return 32;\n return builtin_clz(\n (x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))\n );\n }\n\n export function cos(x: f32): f32 { // see: musl/src/math/cosf.c\n const c1pio2 = reinterpret(0x3FF921FB54442D18); // M_PI_2 * 1\n const c2pio2 = reinterpret(0x400921FB54442D18); // M_PI_2 * 2\n const c3pio2 = reinterpret(0x4012D97C7F3321D2); // M_PI_2 * 3\n const c4pio2 = reinterpret(0x401921FB54442D18); // M_PI_2 * 4\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n /* raise inexact if x != 0 */\n return 1;\n }\n return cos_kernf(x);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix > 0x4016cbe3) { /* |x| ~> 3π/4 */\n return -cos_kernf(sign ? x + c2pio2 : x - c2pio2);\n } else {\n return sign ? sin_kernf(x + c1pio2) : sin_kernf(c1pio2 - x);\n }\n }\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix > 0x40afeddf) { /* |x| ~> 7π/4 */\n return cos_kernf(sign ? x + c4pio2 : x - c4pio2);\n } else {\n return sign ? sin_kernf(-x - c3pio2) : sin_kernf(x - c3pio2);\n }\n }\n }\n\n /* cos(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n /* general argument reduction needed */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n\n var t = n & 1 ? sin_kernf(y) : cos_kernf(y);\n return (n + 1) & 2 ? -t : t;\n }\n\n export function cosh(x: f32): f32 { // see: musl/src/math/coshf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n x = reinterpret(u);\n if (u < 0x3F317217) {\n if (u < 0x3F800000 - (12 << 23)) return 1;\n let t = expm1(x);\n // return 1 + t * t / (2 * (1 + t));\n return 1 + t * t / (2 + 2 * t);\n }\n if (u < 0x42B17217) {\n let t = exp(x);\n // return 0.5 * (t + 1 / t);\n return 0.5 * t + 0.5 / t;\n }\n return expo2f(x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function floor(x: f32): f32 {\n return builtin_floor(x);\n }\n\n export function exp(x: f32): f32 { // see: musl/src/math/expf.c and SUN COPYRIGHT NOTICE above\n const\n ln2hi = reinterpret(0x3F317200), // 6.9314575195e-1f\n ln2lo = reinterpret(0x35BFBE8E), // 1.4286067653e-6f\n invln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+0f\n P1 = reinterpret(0x3E2AAA8F), // 1.6666625440e-1f\n P2 = reinterpret(0xBB355215), // -2.7667332906e-3f\n Ox1p127f = reinterpret(0x7F000000);\n var hx = reinterpret(x);\n var sign_ = (hx >> 31);\n hx &= 0x7FFFFFFF;\n if (hx >= 0x42AEAC50) {\n if (hx >= 0x42B17218) {\n if (!sign_) return x * Ox1p127f;\n else if (hx >= 0x42CFF1B5) return 0;\n }\n }\n var hi: f32, lo: f32;\n var k: i32;\n if (hx > 0x3EB17218) {\n if (hx > 0x3F851592) {\n k = (invln2 * x + builtin_copysign(0.5, x));\n } else {\n k = 1 - (sign_ << 1);\n }\n hi = x - k * ln2hi;\n lo = k * ln2lo;\n x = hi - lo;\n } else if (hx > 0x39000000) {\n k = 0;\n hi = x;\n lo = 0;\n } else {\n return 1 + x;\n }\n var xx = x * x;\n var c = x - xx * (P1 + xx * P2);\n var y: f32 = 1 + (x * c / (2 - c) - lo + hi);\n if (k == 0) return y;\n return scalbn(y, k);\n }\n\n export function expm1(x: f32): f32 { // see: musl/src/math/expm1f.c and SUN COPYRIGHT NOTICE above\n const\n o_threshold = reinterpret(0x42B17180), // 8.8721679688e+01f\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01f\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06f\n invln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+00f\n Q1 = reinterpret(0xBD088868), // -3.3333212137e-02f\n Q2 = reinterpret(0x3ACF3010), // 1.5807170421e-03f\n Ox1p127f = reinterpret(0x7F000000);\n var u = reinterpret(x);\n var hx = u & 0x7FFFFFFF;\n var sign_ = (u >> 31);\n if (hx >= 0x4195B844) {\n if (hx > 0x7F800000) return x;\n if (sign_) return -1;\n if (x > o_threshold) {\n x *= Ox1p127f;\n return x;\n }\n }\n var c: f32 = 0.0, t: f32, k: i32;\n if (hx > 0x3EB17218) {\n k = select(\n 1 - (sign_ << 1),\n (invln2 * x + builtin_copysign(0.5, x)),\n hx < 0x3F851592\n );\n t = k;\n let hi = x - t * ln2_hi;\n let lo = t * ln2_lo;\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (hx < 0x33000000) {\n return x;\n } else k = 0;\n var hfx: f32 = 0.5 * x;\n var hxs: f32 = x * hfx;\n var r1: f32 = 1.0 + hxs * (Q1 + hxs * Q2);\n t = 3.0 - r1 * hfx;\n var e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k == 0) return x - (x * e - hxs);\n e = x * (e - c) - c;\n e -= hxs;\n if (k == -1) return 0.5 * (x - e) - 0.5;\n if (k == 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n u = (0x7F + k) << 23;\n var twopk = reinterpret(u);\n var y: f32;\n if (k < 0 || k > 56) {\n y = x - e + 1.0;\n if (k == 128) y = y * 2.0 * Ox1p127f;\n else y = y * twopk;\n return y - 1.0;\n }\n u = (0x7F - k) << 23;\n y = reinterpret(u);\n if (k < 20) y = (1 - y) - e;\n else y = 1 - (e + y);\n return (x + y) * twopk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function fround(x: f32): f32 {\n return x;\n }\n\n export function hypot(x: f32, y: f32): f32 { // see: musl/src/math/hypotf.c\n const\n Ox1p90f = reinterpret(0x6C800000),\n Ox1p_90f = reinterpret(0x12800000);\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n ux &= 0x7FFFFFFF;\n uy &= 0x7FFFFFFF;\n if (ux < uy) {\n let ut = ux;\n ux = uy;\n uy = ut;\n }\n x = reinterpret(ux);\n y = reinterpret(uy);\n if (uy == 0xFF << 23) return y;\n if (ux >= 0xFF << 23 || uy == 0 || ux - uy >= 25 << 23) return x + y;\n var z: f32 = 1;\n if (ux >= (0x7F + 60) << 23) {\n z = Ox1p90f;\n x *= Ox1p_90f;\n y *= Ox1p_90f;\n } else if (uy < (0x7F - 60) << 23) {\n z = Ox1p_90f;\n x *= Ox1p90f;\n y *= Ox1p90f;\n }\n return z * builtin_sqrt((x * x + y * y));\n }\n\n // @ts-ignore: decorator\n @inline\n export function imul(x: f32, y: f32): f32 {\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n if (!isFinite(x + y)) return 0;\n const inv32 = 1.0 / 4294967296;\n return (\n (x - 4294967296 * builtin_floor(x * inv32)) *\n (y - 4294967296 * builtin_floor(y * inv32))\n );\n }\n\n export function log(x: f32): f32 { // see: musl/src/math/logf.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01f\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06f\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f\n Ox1p25f = reinterpret(0x4C000000);\n var u = reinterpret(x);\n var k = 0;\n if (u < 0x00800000 || (u >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (u >> 31) return (x - x) / 0;\n k -= 25;\n x *= Ox1p25f;\n u = reinterpret(x);\n } else if (u >= 0x7F800000) return x;\n else if (u == 0x3F800000) return 0;\n u += 0x3F800000 - 0x3F3504F3;\n k += (u >> 23) - 0x7F;\n u = (u & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(u);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq = 0.5 * f * f;\n var dk = k;\n return s * (hfsq + r) + dk * ln2_lo - hfsq + f + dk * ln2_hi;\n }\n\n export function log10(x: f32): f32 { // see: musl/src/math/log10f.c and SUN COPYRIGHT NOTICE above\n const\n ivln10hi = reinterpret(0x3EDE6000), // 4.3432617188e-01f\n ivln10lo = reinterpret(0xB804EAD9), // -3.1689971365e-05f\n log10_2hi = reinterpret(0x3E9A2080), // 3.0102920532e-01f\n log10_2lo = reinterpret(0x355427DB), // 7.9034151668e-07f\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f, 0.24279078841f\n Ox1p25f = reinterpret(0x4C000000);\n var ix = reinterpret(x);\n var k = 0;\n if (ix < 0x00800000 || (ix >> 31)) {\n if (ix << 1 == 0) return -1 / (x * x);\n if (ix >> 31) return (x - x) / 0.0;\n k -= 25;\n x *= Ox1p25f;\n ix = reinterpret(x);\n } else if (ix >= 0x7F800000) return x;\n else if (ix == 0x3F800000) return 0;\n ix += 0x3F800000 - 0x3F3504F3;\n k += (ix >> 23) - 0x7F;\n ix = (ix & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(ix);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var hi = f - hfsq;\n ix = reinterpret(hi);\n ix &= 0xFFFFF000;\n hi = reinterpret(ix);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var dk = k;\n return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi;\n }\n\n export function log1p(x: f32): f32 { // see: musl/src/math/log1pf.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26); // 0xf89e26.0p-26f, 0.24279078841f\n var ix = reinterpret(x);\n var c: f32 = 0, f: f32 = 0;\n var k: i32 = 1;\n if (ix < 0x3ED413D0 || (ix >> 31)) {\n if (ix >= 0xBF800000) {\n if (x == -1) return x / 0.0;\n return (x - x) / 0.0;\n }\n if (ix << 1 < 0x33800000 << 1) return x;\n if (ix <= 0xBE95F619) {\n k = 0;\n c = 0;\n f = x;\n }\n } else if (ix >= 0x7F800000) return x;\n if (k) {\n let uf: f32 = 1 + x;\n let iu = reinterpret(uf);\n iu += 0x3F800000 - 0x3F3504F3;\n k = (iu >> 23) - 0x7F;\n if (k < 25) {\n c = k >= 2 ? 1 - (uf - x) : x - (uf - 1);\n c /= uf;\n } else c = 0;\n iu = (iu & 0x007FFFFF) + 0x3F3504F3;\n f = reinterpret(iu) - 1;\n }\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var dk = k;\n return s * (hfsq + r) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;\n }\n\n export function log2(x: f32): f32 { // see: musl/src/math/log2f.c and SUN COPYRIGHT NOTICE above\n const\n ivln2hi = reinterpret(0x3FB8B000), // 1.4428710938e+00f\n ivln2lo = reinterpret(0xB9389AD4), // -1.7605285393e-04\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f, 0.24279078841f\n Ox1p25f = reinterpret(0x4C000000);\n var ix = reinterpret(x);\n var k: i32 = 0;\n if (ix < 0x00800000 || (ix >> 31)) {\n if (ix << 1 == 0) return -1 / (x * x);\n if (ix >> 31) return (x - x) / 0.0;\n k -= 25;\n x *= Ox1p25f;\n ix = reinterpret(x);\n } else if (ix >= 0x7F800000) return x;\n else if (ix == 0x3F800000) return 0;\n ix += 0x3F800000 - 0x3F3504F3;\n k += (ix >> 23) - 0x7F;\n ix = (ix & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(ix);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var hi = f - hfsq;\n var u = reinterpret(hi);\n u &= 0xFFFFF000;\n hi = reinterpret(u);\n var lo: f32 = f - hi - hfsq + s * (hfsq + r);\n var dk = k;\n return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + dk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function max(value1: f32, value2: f32): f32 {\n return builtin_max(value1, value2);\n }\n\n // @ts-ignore: decorator\n @inline\n export function min(value1: f32, value2: f32): f32 {\n return builtin_min(value1, value2);\n }\n\n export function pow(x: f32, y: f32): f32 { // see: musl/src/math/powf.c and SUN COPYRIGHT NOTICE above\n const\n dp_h1 = reinterpret(0x3F15C000), // 5.84960938e-01f\n dp_l1 = reinterpret(0x35D1CFDC), // 1.56322085e-06f\n two24 = reinterpret(0x4B800000), // 16777216f\n huge = reinterpret(0x7149F2CA), // 1.0e+30f\n tiny = reinterpret(0x0DA24260), // 1.0e-30f\n L1 = reinterpret(0x3F19999A), // 6.0000002384e-01f\n L2 = reinterpret(0x3EDB6DB7), // 4.2857143283e-01f\n L3 = reinterpret(0x3EAAAAAB), // 3.3333334327e-01f\n L4 = reinterpret(0x3E8BA305), // 2.7272811532e-01f\n L5 = reinterpret(0x3E6C3255), // 2.3066075146e-01f\n L6 = reinterpret(0x3E53F142), // 2.0697501302e-01f\n P1 = reinterpret(0x3E2AAAAB), // 1.6666667163e-01f\n P2 = reinterpret(0xBB360B61), // -2.7777778450e-03f\n P3 = reinterpret(0x388AB355), // 6.6137559770e-05f\n P4 = reinterpret(0xB5DDEA0E), // -1.6533901999e-06f\n P5 = reinterpret(0x3331BB4C), // 4.1381369442e-08f\n lg2 = reinterpret(0x3F317218), // 6.9314718246e-01f\n lg2_h = reinterpret(0x3F317200), // 6.93145752e-01f\n lg2_l = reinterpret(0x35BFBE8C), // 1.42860654e-06f\n ovt = reinterpret(0x3338AA3C), // 4.2995665694e-08f\n cp = reinterpret(0x3F76384F), // 9.6179670095e-01\n cp_h = reinterpret(0x3F764000), // 9.6191406250e-01\n cp_l = reinterpret(0xB8F623C6), // -1.1736857402e-04\n ivln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+00\n ivln2_h = reinterpret(0x3FB8AA00), // 1.4426879883e+00\n ivln2_l = reinterpret(0x36ECA570), // 7.0526075433e-06\n inv3 = reinterpret(0x3EAAAAAB); // 0.333333333333\n var hx = reinterpret(x);\n var hy = reinterpret(y);\n var ix = hx & 0x7FFFFFFF;\n var iy = hy & 0x7FFFFFFF;\n if (iy == 0) return 1.0; // x**0 = 1, even if x is NaN\n // if (hx == 0x3F800000) return 1.0; // C: 1**y = 1, even if y is NaN, JS: NaN\n if (ix > 0x7F800000 || iy > 0x7F800000) return x + y; // NaN if either arg is NaN\n var yisint = 0, j: i32, k: i32;\n if (hx < 0) {\n if (iy >= 0x4B800000) yisint = 2;\n else if (iy >= 0x3F800000) {\n k = (iy >> 23) - 0x7F;\n let ki = 23 - k;\n j = iy >> ki;\n if ((j << ki) == iy) yisint = 2 - (j & 1);\n }\n }\n if (iy == 0x7F800000) { // y is +-inf\n if (ix == 0x3F800000) return NaN; // C: (-1)**+-inf is 1, JS: NaN\n else if (ix > 0x3F800000) return hy >= 0 ? y : 0.0; // (|x|>1)**+-inf = inf,0\n else return hy >= 0 ? 0.0 : -y; // (|x|<1)**+-inf = 0,inf\n }\n if (iy == 0x3F800000) return hy >= 0 ? x : 1.0 / x;\n if (hy == 0x40000000) return x * x;\n if (hy == 0x3F000000) {\n if (hx >= 0) return builtin_sqrt(x);\n }\n var ax = builtin_abs(x);\n var z: f32;\n if (ix == 0x7F800000 || ix == 0 || ix == 0x3F800000) {\n z = ax;\n if (hy < 0) z = 1.0 / z;\n if (hx < 0) {\n if (((ix - 0x3F800000) | yisint) == 0) {\n let d = z - z;\n z = d / d;\n }\n else if (yisint == 1) z = -z;\n }\n return z;\n }\n var sn = 1.0;\n if (hx < 0) {\n if (yisint == 0) {\n let d = x - x;\n return d / d;\n }\n if (yisint == 1) sn = -1.0;\n }\n var t1: f32, t2: f32, r: f32, s: f32, t: f32, u: f32, v: f32, w: f32, p_h: f32, p_l: f32;\n var n: i32, is: i32;\n if (iy > 0x4D000000) {\n if (ix < 0x3F7FFFF8) return hy < 0 ? sn * huge * huge : sn * tiny * tiny;\n if (ix > 0x3F800007) return hy > 0 ? sn * huge * huge : sn * tiny * tiny;\n t = ax - 1;\n w = (t * t) * (0.5 - t * (inv3 - t * 0.25));\n u = ivln2_h * t;\n v = t * ivln2_l - w * ivln2;\n t1 = u + v;\n is = reinterpret(t1);\n t1 = reinterpret(is & 0xFFFFF000);\n t2 = v - (t1 - u);\n } else {\n let s2: f32, s_h: f32, s_l: f32, t_h: f32, t_l: f32;\n n = 0;\n if (ix < 0x00800000) {\n ax *= two24;\n n -= 24;\n ix = reinterpret(ax);\n }\n n += (ix >> 23) - 0x7F;\n j = ix & 0x007FFFFF;\n ix = j | 0x3F800000;\n if (j <= 0x1CC471) k = 0;\n else if (j < 0x5DB3D7) k = 1;\n else {\n k = 0;\n n += 1;\n ix -= 0x00800000;\n }\n ax = reinterpret(ix);\n let bp = select(1.5, 1.0, k); // k ? 1.5 : 1.0\n u = ax - bp;\n v = 1.0 / (ax + bp);\n s = u * v;\n s_h = s;\n is = reinterpret(s_h);\n s_h = reinterpret(is & 0xFFFFF000);\n is = ((ix >> 1) & 0xFFFFF000) | 0x20000000;\n t_h = reinterpret(is + 0x00400000 + (k << 21));\n t_l = ax - (t_h - bp);\n s_l = v * ((u - s_h * t_h) - s_h * t_l);\n s2 = s * s;\n r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));\n r += s_l * (s_h + s);\n s2 = s_h * s_h;\n t_h = 3.0 + s2 + r;\n is = reinterpret(t_h);\n t_h = reinterpret(is & 0xFFFFF000);\n t_l = r - ((t_h - 3.0) - s2);\n u = s_h * t_h;\n v = s_l * t_h + t_l * s;\n p_h = u + v;\n is = reinterpret(p_h);\n p_h = reinterpret(is & 0xFFFFF000);\n p_l = v - (p_h - u);\n let z_h = cp_h * p_h;\n let dp_l = select(dp_l1, 0.0, k);\n let z_l = cp_l * p_h + p_l * cp + dp_l;\n t = n;\n let dp_h = select(dp_h1, 0.0, k);\n t1 = (((z_h + z_l) + dp_h) + t);\n is = reinterpret(t1);\n t1 = reinterpret(is & 0xFFFFF000);\n t2 = z_l - (((t1 - t) - dp_h) - z_h);\n }\n is = reinterpret(y);\n var y1 = reinterpret(is & 0xFFFFF000);\n p_l = (y - y1) * t1 + y * t2;\n p_h = y1 * t1;\n z = p_l + p_h;\n j = reinterpret(z);\n if (j > 0x43000000) {\n return sn * huge * huge;\n } else if (j == 0x43000000) {\n if (p_l + ovt > z - p_h) return sn * huge * huge;\n } else if ((j & 0x7FFFFFFF) > 0x43160000) {\n return sn * tiny * tiny;\n } else if (j == 0xC3160000) {\n if (p_l <= z - p_h) return sn * tiny * tiny;\n }\n var i = j & 0x7FFFFFFF;\n k = (i >> 23) - 0x7F;\n n = 0;\n if (i > 0x3F000000) {\n n = j + (0x00800000 >> (k + 1));\n k = ((n & 0x7FFFFFFF) >> 23) - 0x7F;\n t = reinterpret(n & ~(0x007FFFFF >> k));\n n = ((n & 0x007FFFFF) | 0x00800000) >> (23 - k);\n if (j < 0) n = -n;\n p_h -= t;\n }\n t = p_l + p_h;\n is = reinterpret(t);\n t = reinterpret(is & 0xFFFF8000);\n u = t * lg2_h;\n v = (p_l - (t - p_h)) * lg2 + t * lg2_l;\n z = u + v;\n w = v - (z - u);\n t = z * z;\n t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n r = (z * t1) / (t1 - 2.0) - (w + z * w);\n z = 1.0 - (r - z);\n j = reinterpret(z);\n j += n << 23;\n if ((j >> 23) <= 0) z = scalbn(z, n);\n else z = reinterpret(j);\n return sn * z;\n }\n\n // @ts-ignore: decorator\n @inline\n export function seedRandom(value: i64): void {\n NativeMath.seedRandom(value);\n }\n\n // Using xoroshiro64starstar from http://xoshiro.di.unimi.it/xoroshiro64starstar.c\n export function random(): f32 {\n if (!random_seeded) throw new Error("PRNG must be seeded.");\n\n var s0 = random_state0_32;\n var s1 = random_state1_32;\n var r = rotl(s0 * 0x9E3779BB, 5) * 5;\n\n s1 ^= s0;\n random_state0_32 = rotl(s0, 26) ^ s1 ^ (s1 << 9);\n random_state1_32 = rotl(s1, 13);\n\n return reinterpret((r >> 9) | (127 << 23)) - 1.0;\n }\n\n // @ts-ignore: decorator\n @inline\n export function round(x: f32): f32 {\n return builtin_copysign(builtin_floor(x + 0.5), x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function sign(x: f32): f32 {\n if (ASC_SHRINK_LEVEL > 0) {\n return builtin_abs(x) > 0 ? builtin_copysign(1, x) : x;\n } else {\n return x > 0 ? 1 : x < 0 ? -1 : x;\n }\n }\n\n // @ts-ignore: decorator\n @inline\n export function signbit(x: f32): bool {\n // @ts-ignore: type\n return ((reinterpret(x) >>> 31) & (x == x));\n }\n\n export function sin(x: f32): f32 { // see: musl/src/math/sinf.c\n const s1pio2 = reinterpret(0x3FF921FB54442D18); // M_PI_2 * 1\n const s2pio2 = reinterpret(0x400921FB54442D18); // M_PI_2 * 2\n const s3pio2 = reinterpret(0x4012D97C7F3321D2); // M_PI_2 * 3\n const s4pio2 = reinterpret(0x401921FB54442D18); // M_PI_2 * 4\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n return x;\n }\n return sin_kernf(x);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n return sign ? -cos_kernf(x + s1pio2) : cos_kernf(x - s1pio2);\n }\n return sin_kernf(-(sign ? x + s2pio2 : x - s2pio2));\n }\n\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n return sign ? cos_kernf(x + s3pio2) : -cos_kernf(x - s3pio2);\n }\n return sin_kernf(sign ? x + s4pio2 : x - s4pio2);\n }\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n\n var t = n & 1 ? cos_kernf(y) : sin_kernf(y);\n return n & 2 ? -t : t;\n }\n\n export function sinh(x: f32): f32 { // see: musl/src/math/sinhf.c\n var u = reinterpret(x) & 0x7FFFFFFF;\n var absx = reinterpret(u);\n var t: f32;\n var h = builtin_copysign(0.5, x);\n if (u < 0x42B17217) {\n t = expm1(absx);\n if (u < 0x3F800000) {\n if (u < 0x3F800000 - (12 << 23)) return x;\n return h * (2 * t - t * t / (t + 1));\n }\n return h * (t + t / (t + 1));\n }\n t = 2 * h * expo2f(absx);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function sqrt(x: f32): f32 {\n return builtin_sqrt(x);\n }\n\n export function tan(x: f32): f32 { // see: musl/src/math/tanf.c\n const t1pio2 = reinterpret(0x3FF921FB54442D18); // 1 * M_PI_2\n const t2pio2 = reinterpret(0x400921FB54442D18); // 2 * M_PI_2\n const t3pio2 = reinterpret(0x4012D97C7F3321D2); // 3 * M_PI_2\n const t4pio2 = reinterpret(0x401921FB54442D18); // 4 * M_PI_2\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n return x;\n }\n return tan_kernf(x, 0);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n return tan_kernf((sign ? x + t1pio2 : x - t1pio2), 1);\n } else {\n return tan_kernf((sign ? x + t2pio2 : x - t2pio2), 0);\n }\n }\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n return tan_kernf((sign ? x + t3pio2 : x - t3pio2), 1);\n } else {\n return tan_kernf((sign ? x + t4pio2 : x - t4pio2), 0);\n }\n }\n }\n\n /* tan(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n /* argument reduction */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n return tan_kernf(y, n & 1);\n }\n\n export function tanh(x: f32): f32 { // see: musl/src/math/tanhf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n var y = reinterpret(u);\n var t: f32;\n if (u > 0x3F0C9F54) {\n if (u > 0x41200000) t = 1 + 0 / y;\n else {\n t = expm1(2 * y);\n t = 1 - 2 / (t + 2);\n }\n } else if (u > 0x3E82C578) {\n t = expm1(2 * y);\n t = t / (t + 2);\n } else if (u >= 0x00800000) {\n t = expm1(-2 * y);\n t = -t / (t + 2);\n } else t = y;\n return builtin_copysign(t, x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function trunc(x: f32): f32 {\n return builtin_trunc(x);\n }\n\n export function scalbn(x: f32, n: i32): f32 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbnf.c\n const\n Ox1p24f = reinterpret(0x4B800000),\n Ox1p127f = reinterpret(0x7F000000),\n Ox1p_126f = reinterpret(0x00800000);\n var y = x;\n if (n > 127) {\n y *= Ox1p127f;\n n -= 127;\n if (n > 127) {\n y *= Ox1p127f;\n n = builtin_min(n - 127, 127);\n }\n } else if (n < -126) {\n y *= Ox1p_126f * Ox1p24f;\n n += 126 - 24;\n if (n < -126) {\n y *= Ox1p_126f * Ox1p24f;\n n = builtin_max(n + 126 - 24, -126);\n }\n }\n return y * reinterpret((0x7F + n) << 23);\n }\n\n export function mod(x: f32, y: f32): f32 { // see: musl/src/math/fmodf.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 23 & 0xFF);\n var ey = (uy >> 23 & 0xFF);\n var sx = ux & 0x80000000;\n var uy1 = uy << 1;\n if (uy1 == 0 || ex == 0xFF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n var ux1 = ux << 1;\n if (ux1 <= uy1) {\n if (ux1 == uy1) return 0 * x;\n return x;\n }\n if (!ex) {\n ex -= builtin_clz(ux << 9);\n ux <<= -ex + 1;\n } else {\n ux &= -1 >> 9;\n ux |= 1 << 23;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 9);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 9;\n uy |= 1 << 23;\n }\n while (ex > ey) {\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n ux <<= 1;\n --ex;\n }\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n // for (; !(ux >> 23); ux <<= 1) --ex;\n var shift = builtin_clz(ux << 8);\n ex -= shift;\n ux <<= shift;\n if (ex > 0) {\n ux -= 1 << 23;\n ux |= ex << 23;\n } else {\n ux >>= -ex + 1;\n }\n ux |= sx;\n return reinterpret(ux);\n }\n\n export function rem(x: f32, y: f32): f32 { // see: musl/src/math/remquof.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 23 & 0xFF);\n var ey = (uy >> 23 & 0xFF);\n var sx = (ux >> 31);\n var uxi = ux;\n if (uy << 1 == 0 || ex == 0xFF || isNaN(y)) return (x * y) / (x * y);\n if (ux << 1 == 0) return x;\n if (!ex) {\n ex -= builtin_clz(uxi << 9);\n uxi <<= -ex + 1;\n } else {\n uxi &= -1 >> 9;\n uxi |= 1 << 23;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 9);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 9;\n uy |= 1 << 23;\n }\n var q = 0;\n do {\n if (ex < ey) {\n if (ex + 1 == ey) break; // goto end\n return x;\n }\n while (ex > ey) {\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n uxi <<= 1;\n q <<= 1;\n --ex;\n }\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n if (uxi == 0) ex = -30;\n else {\n let shift = builtin_clz(uxi << 8);\n ex -= shift;\n uxi <<= shift;\n }\n break;\n } while (false);\n // end\n if (ex > 0) {\n uxi -= 1 << 23;\n uxi |= ex << 23;\n } else {\n uxi >>= -ex + 1;\n }\n x = reinterpret(uxi);\n y = builtin_abs(y);\n var x2 = x + x;\n if (ex == ey || (ex + 1 == ey && (x2 > y || (x2 == y && (q & 1))))) {\n x -= y;\n // q++;\n }\n return sx ? -x : x;\n }\n\n export function sincos(x: f32): void { // see: musl/tree/src/math/sincosf.c\n const s1pio2 = reinterpret(0x3FF921FB54442D18); // 1 * M_PI_2\n const s2pio2 = reinterpret(0x400921FB54442D18); // 2 * M_PI_2\n const s3pio2 = reinterpret(0x4012D97C7F3321D2); // 3 * M_PI_2\n const s4pio2 = reinterpret(0x401921FB54442D18); // 4 * M_PI_2\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7fffffff;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n sincos_sin = x;\n sincos_cos = 1;\n return;\n }\n sincos_sin = sin_kernf(x);\n sincos_cos = cos_kernf(x);\n return;\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n if (sign) {\n sincos_sin = -cos_kernf(x + s1pio2);\n sincos_cos = sin_kernf(x + s1pio2);\n } else {\n sincos_sin = cos_kernf(s1pio2 - x);\n sincos_cos = sin_kernf(s1pio2 - x);\n }\n return;\n }\n /* -sin(x + c) is not correct if x+c could be 0: -0 vs +0 */\n sincos_sin = -sin_kernf(sign ? x + s2pio2 : x - s2pio2);\n sincos_cos = -cos_kernf(sign ? x + s2pio2 : x - s2pio2);\n return;\n }\n\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n if (sign) {\n sincos_sin = cos_kernf(x + s3pio2);\n sincos_cos = -sin_kernf(x + s3pio2);\n } else {\n sincos_sin = -cos_kernf(x - s3pio2);\n sincos_cos = sin_kernf(x - s3pio2);\n }\n return;\n }\n sincos_sin = sin_kernf(sign ? x + s4pio2 : x - s4pio2);\n sincos_cos = cos_kernf(sign ? x + s4pio2 : x - s4pio2);\n return;\n }\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) {\n let xx = x - x;\n sincos_sin = xx;\n sincos_cos = xx;\n return;\n }\n\n /* general argument reduction needed */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n var s = sin_kernf(y);\n var c = cos_kernf(y);\n\n switch (n & 3) {\n case 0: {\n sincos_sin = s;\n sincos_cos = c;\n break;\n }\n case 1: {\n sincos_sin = c;\n sincos_cos = -s;\n break;\n }\n case 2: {\n sincos_sin = -s;\n sincos_cos = -c;\n break;\n }\n case 3:\n default: {\n sincos_sin = -c;\n sincos_cos = s;\n break;\n }\n }\n }\n}\n\nexport function ipow32(x: i32, e: i32): i32 {\n var out = 1;\n if (ASC_SHRINK_LEVEL < 1) {\n if (e < 0) return 0;\n\n switch (e) {\n case 0: return 1;\n case 1: return x;\n case 2: return x * x;\n }\n\n let log = 32 - clz(e);\n if (log <= 5) {\n // 32 = 2 ^ 5, so need only five cases.\n // But some extra cases needs for properly overflowing\n switch (log) {\n case 5: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 4: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 3: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 2: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 1: {\n if (e & 1) out *= x;\n }\n }\n return out;\n }\n }\n\n while (e > 0) {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n return out;\n}\n\nexport function ipow64(x: i64, e: i32): i64 {\n var out: i64 = 1;\n if (ASC_SHRINK_LEVEL < 1) {\n if (e < 0) return 0;\n switch (e) {\n case 0: return 1;\n case 1: return x;\n case 2: return x * x;\n }\n\n let log = 32 - clz(e);\n if (log <= 6) {\n // 64 = 2 ^ 6, so need only six cases.\n // But some extra cases needs for properly overflowing\n switch (log) {\n case 6: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 5: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 4: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 3: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 2: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 1: {\n if (e & 1) out *= x;\n }\n }\n return out;\n }\n }\n\n while (e > 0) {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n return out;\n}\n\nexport function ipow32f(x: f32, e: i32): f32 {\n var sign = e >> 31;\n e = (e + sign) ^ sign; // abs(e)\n var out: f32 = 1;\n while (e) {\n out *= select(x, 1.0, e & 1);\n e >>= 1;\n x *= x;\n }\n return sign ? 1.0 / out : out;\n}\n\nexport function ipow64f(x: f64, e: i32): f64 {\n var sign = e >> 31;\n e = (e + sign) ^ sign; // abs(e)\n var out = 1.0;\n while (e) {\n out *= select(x, 1.0, e & 1);\n e >>= 1;\n x *= x;\n }\n return sign ? 1.0 / out : out;\n}\n',memory:'import { memcmp, memmove, memset } from "./util/memory";\nimport { E_NOTIMPLEMENTED } from "./util/error";\n\n/** Memory manager interface. */\nexport namespace memory {\n\n /** Gets the size of the memory in pages. */\n // @ts-ignore: decorator\n @builtin\n export declare function size(): i32;\n\n /** Grows the memory by the given size in pages and returns the previous size in pages. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function grow(pages: i32): i32;\n\n /** Fills a section in memory with the specified byte value. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export function fill(dst: usize, c: u8, n: usize): void {\n memset(dst, c, n); // fallback if "bulk-memory" isn\'t enabled\n }\n\n /** Copies a section of memory to another. Has move semantics. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export function copy(dst: usize, src: usize, n: usize): void {\n memmove(dst, src, n); // fallback if "bulk-memory" isn\'t enabled\n }\n\n /** Initializes a memory segment. */\n // @ts-ignore: decorator\n @unsafe\n export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n /** Drops a memory segment. */\n // @ts-ignore: decorator\n @unsafe\n export function drop(segmentIndex: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n /** Repeats a section of memory at a specific address. */\n // @ts-ignore: decorator\n @unsafe\n export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void {\n var index: usize = 0;\n var total = srcLength * count;\n while (index < total) {\n memory.copy(dst + index, src, srcLength);\n index += srcLength;\n }\n }\n\n /** Compares a section of memory to another. */\n // @ts-ignore: decorator\n @inline\n export function compare(vl: usize, vr: usize, n: usize): i32 {\n return memcmp(vl, vr, n);\n }\n}\n',number:'import { itoa, dtoa } from "./util/number";\nimport { isNaN as builtin_isNaN, isFinite as builtin_isFinite } from "./builtins";\n\n@sealed @unmanaged\nexport abstract class I8 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i8 = i8.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i8 = i8.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i8 {\n return parseI32(value, radix);\n }\n\n toString(this: i8): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I16 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i16 = i16.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i16 = i16.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i16 {\n return parseI32(value, radix);\n }\n\n toString(this: i16): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i32 = i32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i32 = i32.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i32 {\n return parseI32(value, radix);\n }\n\n toString(this: i32): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i64 = i64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i64 = i64.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i64 {\n return parseI64(value, radix);\n }\n\n toString(this: i64): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Isize {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: isize = isize.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: isize = isize.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): isize {\n return parseI64(value, radix);\n }\n\n toString(this: isize): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U8 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u8 = u8.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u8 = u8.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u8 {\n return parseI32(value, radix);\n }\n\n toString(this: u8): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U16 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u16 = u16.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u16 = u16.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u16 {\n return parseI32(value, radix);\n }\n\n toString(this: u16): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u32 = u32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u32 = u32.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u32 {\n return parseI32(value, radix);\n }\n\n toString(this: u32): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u64 = u64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u64 = u64.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u64 {\n return parseI64(value, radix);\n }\n\n toString(this: u64): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Usize {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: usize = usize.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: usize = usize.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): usize {\n return parseI64(value, radix);\n }\n\n toString(this: usize): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Bool {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: bool = bool.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: bool = bool.MAX_VALUE;\n\n toString(this: bool): String {\n // TODO: radix?\n return this ? "true" : "false";\n }\n}\n\nexport { Bool as Boolean };\n\n@sealed @unmanaged\nexport abstract class F32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly EPSILON: f32 = f32.EPSILON;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: f32 = f32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: f32 = f32.MAX_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_SAFE_INTEGER: f32 = f32.MIN_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_SAFE_INTEGER: f32 = f32.MAX_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly POSITIVE_INFINITY: f32 = Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NEGATIVE_INFINITY: f32 = -Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NaN: f32 = NaN;\n\n static isNaN(value: f32): bool {\n return isNaN(value);\n }\n\n static isFinite(value: f32): bool {\n return isFinite(value);\n }\n\n static isSafeInteger(value: f32): bool {\n return abs(value) <= f32.MAX_SAFE_INTEGER && trunc(value) == value;\n }\n\n static isInteger(value: f32): bool {\n return isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f32 {\n return parseI64(value, radix);\n }\n\n static parseFloat(value: string): f32 {\n return parseFloat(value);\n }\n\n toString(this: f32): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class F64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly EPSILON: f64 = f64.EPSILON;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: f64 = f64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: f64 = f64.MAX_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_SAFE_INTEGER: f64 = f64.MIN_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_SAFE_INTEGER: f64 = f64.MAX_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly POSITIVE_INFINITY: f64 = Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NEGATIVE_INFINITY: f64 = -Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NaN: f64 = NaN;\n\n static isNaN(value: f64): bool {\n return builtin_isNaN(value);\n }\n\n static isFinite(value: f64): bool {\n return builtin_isFinite(value);\n }\n\n static isSafeInteger(value: f64): bool {\n return abs(value) <= f64.MAX_SAFE_INTEGER && trunc(value) == value;\n }\n\n static isInteger(value: f64): bool {\n return builtin_isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f64 {\n return parseI64(value, radix);\n }\n\n static parseFloat(value: string): f64 {\n return parseFloat(value);\n }\n\n toString(this: f64): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\nexport { F64 as Number };\n',polyfills:"export function bswap(value: T): T {\n if (isInteger()) {\n if (sizeof() == 2) {\n return ((value << 8) | ((value >> 8) & 0x00FF));\n }\n if (sizeof() == 4) {\n return (\n rotl(value & 0xFF00FF00, 8) |\n rotr(value & 0x00FF00FF, 8)\n );\n }\n if (sizeof() == 8) {\n let a = (value >> 8) & 0x00FF00FF00FF00FF;\n let b = (value & 0x00FF00FF00FF00FF) << 8;\n let v = a | b;\n\n a = (v >> 16) & 0x0000FFFF0000FFFF;\n b = (v & 0x0000FFFF0000FFFF) << 16;\n\n return rotr(a | b, 32);\n }\n return value;\n }\n assert(false);\n return value;\n}\n\nexport function bswap16(value: T): T {\n if (isInteger() && sizeof() <= 4) {\n if (sizeof() == 2) {\n return ((value << 8) | ((value >> 8) & 0x00FF));\n } else if (sizeof() == 4) {\n return (((value << 8) & 0xFF00) | ((value >> 8) & 0x00FF) | (value & 0xFFFF0000));\n }\n return value;\n }\n assert(false);\n return value;\n}\n",regexp:'export class RegExp {\n\n // @binding(CALL_NEW, [ STRING, STRING], OBJECT_HANDLE)\n constructor(pattern: string, flags: string = "") { throw new Error("unreachable"); }\n\n // @binding(CALL_THIS, [ STRING ], PASS_THRU)\n test(search: string): bool { throw new Error("unreachable"); }\n\n // @binding(CALL_THIS, [], STRING)\n toString(): string { throw new Error("unreachable"); }\n\n}\n',rt:'import { Typeinfo, TypeinfoFlags } from "./shared/typeinfo";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\nimport { BLOCK, BLOCK_OVERHEAD } from "./rt/common";\nimport { ArrayBufferView } from "./arraybuffer";\n\n// @ts-ignore: decorator\n@builtin\nexport declare const RTTI_BASE: usize;\n\n// @ts-ignore: decorator\n@builtin @unsafe\nexport declare function __visit_globals(cookie: u32): void;\n\n// @ts-ignore: decorator\n@builtin @unsafe\nexport declare function __visit_members(ref: usize, cookie: u32): void;\n\n// @ts-ignore: decorator\n@unsafe\nexport function __typeinfo(id: u32): TypeinfoFlags {\n var ptr = RTTI_BASE;\n if (id > load(ptr)) throw new Error(E_INDEXOUTOFRANGE);\n return changetype(ptr + sizeof() + id * offsetof()).flags;\n}\n\n// @ts-ignore: decorator\n@unsafe\nexport function __instanceof(ref: usize, superId: u32): bool { // keyword\n var id = changetype(ref - BLOCK_OVERHEAD).rtId;\n var ptr = RTTI_BASE;\n if (id <= load(ptr)) {\n do if (id == superId) return true;\n while (id = changetype(ptr + sizeof() + id * offsetof()).base);\n }\n return false;\n}\n\n// @ts-ignore: decorator\n@unsafe\nexport function __allocArray(length: i32, alignLog2: usize, id: u32, data: usize = 0): usize {\n var array = __alloc(offsetof(), id);\n var bufferSize = length << alignLog2;\n var buffer = __alloc(bufferSize, idof());\n store(array, __retain(buffer), offsetof("data"));\n changetype(array).dataStart = buffer;\n changetype(array).dataLength = bufferSize;\n store(changetype(array), length, offsetof("length_"));\n if (data) memory.copy(buffer, data, bufferSize);\n return array;\n}\n\n// These are provided by the respective implementation, included as another entry file by asc:\n\n// @builtin @unsafe\n// export declare function __alloc(size: usize, id: u32): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __realloc(ref: usize, size: usize): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __free(ref: usize): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __retain(ref: usize): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __release(ref: usize): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __collect(): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __visit(ref: usize, cookie: u32): void;\n',"rt/common":"// Alignment guarantees\n\n// @ts-ignore: decorator\n@inline export const AL_BITS: u32 = 4; // 16 bytes to fit up to v128\n// @ts-ignore: decorator\n@inline export const AL_SIZE: usize = 1 << AL_BITS;\n// @ts-ignore: decorator\n@inline export const AL_MASK: usize = AL_SIZE - 1;\n\n// Extra debugging\n\n// @ts-ignore: decorator\n@inline export const DEBUG = true;\n\n// ╒════════════════ Common block layout (32-bit) ═════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n// │ MM info │ -16\n// ├───────────────────────────────────────────────────────────────┤\n// │ GC info │ -12\n// ├───────────────────────────────────────────────────────────────┤\n// │ runtime id │ -8\n// ├───────────────────────────────────────────────────────────────┤\n// │ runtime size │ -4\n// ╞═══════════════════════════════════════════════════════════════╡\n// │ ... │ ref\n@unmanaged export class BLOCK {\n /** Memory manager info. */\n mmInfo: usize; // WASM64 needs adaption\n /** Garbage collector info. */\n gcInfo: u32;\n /** Runtime class id. */\n rtId: u32;\n /** Runtime object size. */\n rtSize: u32;\n}\n\n// @ts-ignore: decorator\n@inline export const BLOCK_OVERHEAD = (offsetof() + AL_MASK) & ~AL_MASK;\n\n// @ts-ignore: decorator\n@inline export const BLOCK_MAXSIZE: usize = (1 << 30) - BLOCK_OVERHEAD;\n","rt/index-full":'export { __alloc } from "rt/tlsf";\nexport { __retain, __release, __collect } from "rt/pure";\nexport { RTTI_BASE as __rtti } from "rt";\n',"rt/index-half":'import "rt/index-full";\n',"rt/index-none":'import "rt/index-stub";\n',"rt/index-stub":'export { __alloc, __retain, __release, __collect } from "rt/stub";\nexport { RTTI_BASE as __rtti } from "rt";\n',"rt/pure":'import { DEBUG, BLOCK_OVERHEAD } from "rt/common";\nimport { Block, freeBlock, ROOT } from "rt/tlsf";\nimport { TypeinfoFlags } from "shared/typeinfo";\nimport { onincrement, ondecrement, onfree, onalloc } from "./rtrace";\n\n/////////////////////////// A Pure Reference Counting Garbage Collector ///////////////////////////\n// see: https://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon03Pure.pdf\n\n// ╒══════════════════════ GC Info structure ══════════════════════╕\n// │ 3 2 1 │\n// │1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0│\n// ├─┼─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n// │B│color│ refCount │\n// └─┴─────┴───────────────────────────────────────────────────────┘\n// B: buffered\n\n// @ts-ignore: decorator\n@inline const BUFFERED_MASK: u32 = 1 << (sizeof() * 8 - 1);\n// @ts-ignore: decorator\n@inline const COLOR_BITS = 3;\n// @ts-ignore: decorator\n@inline const COLOR_SHIFT: u32 = ctz(BUFFERED_MASK) - COLOR_BITS;\n// @ts-ignore: decorator\n@inline const COLOR_MASK: u32 = ((1 << COLOR_BITS) - 1) << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const REFCOUNT_MASK: u32 = (1 << COLOR_SHIFT) - 1;\n\n// ╒════════╤═══════════════════ Colors ═══════════════════════════╕\n// │ Color │ Meaning │\n// ├────────┼──────────────────────────────────────────────────────┤\n// │ BLACK │ In use or free │\n// │ GRAY │ Possible member of cycle │\n// │ WHITE │ Member of garbage cycle │\n// │ PURPLE │ Possible root of cycle │\n// │ RED │ Candidate cycle undergoing Σ-computation *concurrent │\n// │ ORANGE │ Candidate cycle awaiting epoch boundary *concurrent │\n// └────────┴──────────────────────────────────────────────────────┘\n// Acyclic detection has been decoupled, hence no GREEN.\n\n// @ts-ignore: decorator\n@inline const COLOR_BLACK: u32 = 0 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_GRAY: u32 = 1 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_WHITE: u32 = 2 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_PURPLE: u32 = 3 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_RED: u32 = 4 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_ORANGE: u32 = 5 << COLOR_SHIFT;\n\n// @ts-ignore: decorator\n@inline const VISIT_DECREMENT = 1; // guard 0\n// @ts-ignore: decorator\n@inline const VISIT_MARKGRAY = 2;\n// @ts-ignore: decorator\n@inline const VISIT_SCAN = 3;\n// @ts-ignore: decorator\n@inline const VISIT_SCANBLACK = 4;\n// @ts-ignore: decorator\n@inline const VISIT_COLLECTWHITE = 5;\n\n// @ts-ignore: decorator\n@global @unsafe\nfunction __visit(ref: usize, cookie: i32): void {\n if (ref < HEAP_BASE) return;\n var s = changetype(ref - BLOCK_OVERHEAD);\n switch (cookie) {\n case VISIT_DECREMENT: {\n decrement(s);\n break;\n }\n case VISIT_MARKGRAY: {\n if (DEBUG) assert((s.gcInfo & REFCOUNT_MASK) > 0);\n s.gcInfo = s.gcInfo - 1;\n markGray(s);\n break;\n }\n case VISIT_SCAN: {\n scan(s);\n break;\n }\n case VISIT_SCANBLACK: {\n let info = s.gcInfo;\n assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow\n s.gcInfo = info + 1;\n if ((info & COLOR_MASK) != COLOR_BLACK) {\n scanBlack(s);\n }\n break;\n }\n case VISIT_COLLECTWHITE: {\n collectWhite(s);\n break;\n }\n default: if (DEBUG) assert(false);\n }\n}\n\n/** Increments the reference count of the specified block by one.*/\nfunction increment(s: Block): void {\n var info = s.gcInfo;\n assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow\n s.gcInfo = info + 1;\n if (isDefined(ASC_RTRACE)) onincrement(s);\n if (DEBUG) assert(!(s.mmInfo & 1)); // used\n}\n\n/** Decrements the reference count of the specified block by one, possibly freeing it. */\nfunction decrement(s: Block): void {\n var info = s.gcInfo;\n var rc = info & REFCOUNT_MASK;\n if (isDefined(ASC_RTRACE)) ondecrement(s);\n if (DEBUG) assert(!(s.mmInfo & 1)); // used\n if (rc == 1) {\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_DECREMENT);\n if (!(info & BUFFERED_MASK)) {\n freeBlock(ROOT, s);\n } else {\n s.gcInfo = BUFFERED_MASK | COLOR_BLACK | 0;\n }\n } else {\n if (DEBUG) assert(rc > 0);\n if (!(__typeinfo(s.rtId) & TypeinfoFlags.ACYCLIC)) {\n s.gcInfo = BUFFERED_MASK | COLOR_PURPLE | (rc - 1);\n if (!(info & BUFFERED_MASK)) {\n appendRoot(s);\n }\n } else {\n s.gcInfo = (info & ~REFCOUNT_MASK) | (rc - 1);\n }\n }\n}\n\n/** Buffer of possible roots. */\n// @ts-ignore: decorator\n@lazy var ROOTS: usize;\n/** Current absolute offset into the `ROOTS` buffer. */\n// @ts-ignore: decorator\n@lazy var CUR: usize = 0;\n/** Current absolute end offset into the `ROOTS` buffer. */\n// @ts-ignore: decorator\n@lazy var END: usize = 0;\n\n/** Appends a block to possible roots. */\nfunction appendRoot(s: Block): void {\n var cur = CUR;\n if (cur >= END) {\n growRoots(); // TBD: either that or pick a default and force collection on overflow\n cur = CUR;\n }\n store(cur, s);\n CUR = cur + sizeof();\n}\n\n/** Grows the roots buffer if it ran full. */\nfunction growRoots(): void {\n var oldRoots = ROOTS;\n var oldSize = CUR - oldRoots;\n var newSize = max(oldSize * 2, 64 << alignof());\n var newRoots = __alloc(newSize, 0);\n if (isDefined(ASC_RTRACE)) onfree(changetype(newRoots - BLOCK_OVERHEAD)); // neglect unmanaged\n memory.copy(newRoots, oldRoots, oldSize);\n if (oldRoots) {\n if (isDefined(ASC_RTRACE)) onalloc(changetype(oldRoots - BLOCK_OVERHEAD)); // neglect unmanaged\n __free(oldRoots);\n }\n ROOTS = newRoots;\n CUR = newRoots + oldSize;\n END = newRoots + newSize;\n}\n\n/** Collects cyclic garbage. */\n// @ts-ignore: decorator\n@global @unsafe\nexport function __collect(): void {\n\n // markRoots\n var roots = ROOTS;\n var cur = roots;\n for (let pos = cur, end = CUR; pos < end; pos += sizeof()) {\n let s = load(pos);\n let info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_PURPLE && (info & REFCOUNT_MASK) > 0) {\n markGray(s);\n store(cur, s);\n cur += sizeof();\n } else {\n if ((info & COLOR_MASK) == COLOR_BLACK && !(info & REFCOUNT_MASK)) {\n freeBlock(ROOT, s);\n } else {\n s.gcInfo = info & ~BUFFERED_MASK;\n }\n }\n }\n CUR = cur;\n\n // scanRoots\n for (let pos = roots; pos < cur; pos += sizeof()) {\n scan(load(pos));\n }\n\n // collectRoots\n for (let pos = roots; pos < cur; pos += sizeof()) {\n let s = load(pos);\n s.gcInfo = s.gcInfo & ~BUFFERED_MASK;\n collectWhite(s);\n }\n CUR = roots;\n}\n\n/** Marks a block as gray (possible member of cycle) during the collection phase. */\nfunction markGray(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) != COLOR_GRAY) {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_GRAY;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_MARKGRAY);\n }\n}\n\n/** Scans a block during the collection phase, determining whether it is garbage or not. */\nfunction scan(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_GRAY) {\n if ((info & REFCOUNT_MASK) > 0) {\n scanBlack(s);\n } else {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_WHITE;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_SCAN);\n }\n }\n}\n\n/** Marks a block as black (in use) if it was found to be reachable during the collection phase. */\nfunction scanBlack(s: Block): void {\n s.gcInfo = (s.gcInfo & ~COLOR_MASK) | COLOR_BLACK;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_SCANBLACK);\n}\n\n/** Collects all white (member of a garbage cycle) nodes when completing the collection phase. */\nfunction collectWhite(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_WHITE && !(info & BUFFERED_MASK)) {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_BLACK;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_COLLECTWHITE);\n freeBlock(ROOT, s);\n }\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __retain(ref: usize): usize {\n if (ref > HEAP_BASE) increment(changetype(ref - BLOCK_OVERHEAD));\n return ref;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __release(ref: usize): void {\n if (ref > HEAP_BASE) decrement(changetype(ref - BLOCK_OVERHEAD));\n}\n',"rt/rtrace":'import { BLOCK } from "./common";\n\nexport declare function onalloc(s: BLOCK): void;\nexport declare function onincrement(s: BLOCK): void;\nexport declare function ondecrement(s: BLOCK): void;\nexport declare function onfree(s: BLOCK): void;\n',"rt/stub":'import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "rt/common";\n\n// @ts-ignore: decorator\n@lazy\nvar startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n\n// @ts-ignore: decorator\n@lazy\nvar offset: usize = startOffset;\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __alloc(size: usize, id: u32): usize {\n if (size > BLOCK_MAXSIZE) unreachable();\n var ptr = offset + BLOCK_OVERHEAD;\n var newPtr = (ptr + max(size, 1) + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n if (newPtr > pagesBefore << 16) {\n let pagesNeeded = ((newPtr - ptr + 0xffff) & ~0xffff) >>> 16;\n let pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) unreachable(); // out of memory\n }\n }\n offset = newPtr;\n var block = changetype(ptr - BLOCK_OVERHEAD);\n block.rtId = id;\n block.rtSize = size;\n return ptr;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __realloc(ref: usize, size: usize): usize {\n var block = changetype(ref - BLOCK_OVERHEAD);\n var oldSize = block.rtSize;\n if (size > oldSize) {\n let newRef = __alloc(size, block.rtId);\n memory.copy(newRef, ref, oldSize);\n ref = newRef;\n } else {\n block.rtSize = size;\n }\n return ref;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __free(ref: usize): void {\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nfunction __reset(): void { // special\n offset = startOffset;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __retain(ref: usize): usize {\n return ref;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __release(ref: usize): void {\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __visit(ref: usize, cookie: u32): void {\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __collect(): void {\n}\n',"rt/tlsf":"import { AL_BITS, AL_MASK, DEBUG, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from \"rt/common\";\nimport { onfree, onalloc } from \"./rtrace\";\n\n/////////////////////// The TLSF (Two-Level Segregate Fit) memory allocator ///////////////////////\n// see: http://www.gii.upv.es/tlsf/\n\n// - `ffs(x)` is equivalent to `ctz(x)` with x != 0\n// - `fls(x)` is equivalent to `sizeof(x) * 8 - clz(x) - 1`\n\n// ╒══════════════ Block size interpretation (32-bit) ═════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─╫─┴─┴─┴─┤\n// │ | FL │ SB = SL + AL │ ◄─ usize\n// └───────────────────────────────────────────────┴───────╨───────┘\n// FL: first level, SL: second level, AL: alignment, SB: small block\n\n// @ts-ignore: decorator\n@inline const SL_BITS: u32 = 4;\n// @ts-ignore: decorator\n@inline const SL_SIZE: usize = 1 << SL_BITS;\n\n// @ts-ignore: decorator\n@inline const SB_BITS: usize = (SL_BITS + AL_BITS);\n// @ts-ignore: decorator\n@inline const SB_SIZE: usize = 1 << SB_BITS;\n\n// @ts-ignore: decorator\n@inline const FL_BITS: u32 = 31 - SB_BITS;\n\n// [00]: < 256B (SB) [12]: < 1M\n// [01]: < 512B [13]: < 2M\n// [02]: < 1K [14]: < 4M\n// [03]: < 2K [15]: < 8M\n// [04]: < 4K [16]: < 16M\n// [05]: < 8K [17]: < 32M\n// [06]: < 16K [18]: < 64M\n// [07]: < 32K [19]: < 128M\n// [08]: < 64K [20]: < 256M\n// [09]: < 128K [21]: < 512M\n// [10]: < 256K [22]: <= 1G - OVERHEAD\n// [11]: < 512K\n// VMs limit to 2GB total (currently), making one 1G block max (or three 512M etc.) due to block overhead\n\n// Tags stored in otherwise unused alignment bits\n\n// @ts-ignore: decorator\n@inline const FREE: usize = 1 << 0;\n// @ts-ignore: decorator\n@inline const LEFTFREE: usize = 1 << 1;\n// @ts-ignore: decorator\n@inline const TAGS_MASK: usize = FREE | LEFTFREE; // <= AL_MASK\n\n// ╒════════════════════ Block layout (32-bit) ════════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┼─┼─┤ overhead ┐\n// │ size │0│L│F│ ◄─┐ info\n// ├─────────────────────────────────────────────────────────┴─┴─┴─┤ │\n// │ │ │\n// │ ... additional runtime overhead ... │ │\n// │ │ │\n// ╞═══════════════════════════════════════════════════════════════╡ │ ┐ ┘\n// │ if free: ◄ prev │ ◄─┤ usize\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: next ► │ ◄─┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ │ = 0\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: back ▲ │ ◄─┘\n// └───────────────────────────────────────────────────────────────┘ payload ┘ >= MIN SIZE\n// F: FREE, L: LEFTFREE\n@unmanaged export class Block extends BLOCK {\n\n /** Previous free block, if any. Only valid if free, otherwise part of payload. */\n prev: Block | null;\n /** Next free block, if any. Only valid if free, otherwise part of payload. */\n next: Block | null;\n\n // If the block is free, there is a 'back'reference at its end pointing at its start.\n}\n\n// Block constants. A block must have a minimum size of three pointers so it can hold `prev`,\n// `next` and `back` if free.\n\n// @ts-ignore: decorator\n@inline const BLOCK_MINSIZE: usize = (3 * sizeof() + AL_MASK) & ~AL_MASK; // prev + next + back\n// @ts-ignore: decorator\n// @inline const BLOCK_MAXSIZE: usize = 1 << (FL_BITS + SB_BITS - 1); // exclusive, lives in common.ts\n\n/** Gets the left block of a block. Only valid if the left block is free. */\n// @ts-ignore: decorator\n@inline function GETFREELEFT(block: Block): Block {\n return load(changetype(block) - sizeof());\n}\n\n/** Gets the right block of of a block by advancing to the right by its size. */\n// @ts-ignore: decorator\n@inline function GETRIGHT(block: Block): Block {\n return changetype(changetype(block) + BLOCK_OVERHEAD + (block.mmInfo & ~TAGS_MASK));\n}\n\n// ╒═════════════════════ Root layout (32-bit) ════════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ┐\n// │ 0 | flMap S│ ◄────┐\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ slMap[0] S │ ◄─┐ │\n// ├───────────────────────────────────────────────────────────────┤ │ │\n// │ slMap[1] │ ◄─┤ │\n// ├───────────────────────────────────────────────────────────────┤ u32 │\n// │ slMap[22] │ ◄─┘ │\n// ╞═══════════════════════════════════════════════════════════════╡ usize\n// │ head[0] │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ head[367] │ ◄────┤\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ tail │ ◄────┘\n// └───────────────────────────────────────────────────────────────┘ SIZE ┘\n// S: Small blocks map\n@unmanaged class Root {\n /** First level bitmap. */\n flMap: usize;\n}\n\n// Root constants. Where stuff is stored inside of the root structure.\n\n// @ts-ignore: decorator\n@inline const SL_START = sizeof();\n// @ts-ignore: decorator\n@inline const SL_END = SL_START + (FL_BITS << alignof());\n// @ts-ignore: decorator\n@inline const HL_START = (SL_END + AL_MASK) & ~AL_MASK;\n// @ts-ignore: decorator\n@inline const HL_END = HL_START + FL_BITS * SL_SIZE * sizeof();\n// @ts-ignore: decorator\n@inline const ROOT_SIZE = HL_END + sizeof();\n\n// @ts-ignore: decorator\n@lazy export var ROOT: Root;\n\n/** Gets the second level map of the specified first level. */\n// @ts-ignore: decorator\n@inline function GETSL(root: Root, fl: usize): u32 {\n return load(\n changetype(root) + (fl << alignof()),\n SL_START\n );\n}\n\n/** Sets the second level map of the specified first level. */\n// @ts-ignore: decorator\n@inline function SETSL(root: Root, fl: usize, slMap: u32): void {\n store(\n changetype(root) + (fl << alignof()),\n slMap,\n SL_START\n );\n}\n\n/** Gets the head of the free list for the specified combination of first and second level. */\n// @ts-ignore: decorator\n@inline function GETHEAD(root: Root, fl: usize, sl: u32): Block | null {\n return load(\n changetype(root) + (((fl << SL_BITS) + sl) << alignof()),\n HL_START\n );\n}\n\n/** Sets the head of the free list for the specified combination of first and second level. */\n// @ts-ignore: decorator\n@inline function SETHEAD(root: Root, fl: usize, sl: u32, head: Block | null): void {\n store(\n changetype(root) + (((fl << SL_BITS) + sl) << alignof()),\n head,\n HL_START\n );\n}\n\n/** Gets the tail block.. */\n// @ts-ignore: decorator\n@inline function GETTAIL(root: Root): Block {\n return load(\n changetype(root),\n HL_END\n );\n}\n\n/** Sets the tail block. */\n// @ts-ignore: decorator\n@inline function SETTAIL(root: Root, tail: Block): void {\n store(\n changetype(root),\n tail,\n HL_END\n );\n}\n\n/** Inserts a previously used block back into the free list. */\nfunction insertBlock(root: Root, block: Block): void {\n if (DEBUG) assert(block); // cannot be null\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(blockInfo & FREE); // must be free\n\n var right = GETRIGHT(block);\n var rightInfo = right.mmInfo;\n\n // merge with right block if also free\n if (rightInfo & FREE) {\n let newSize = (blockInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (rightInfo & ~TAGS_MASK);\n if (newSize < BLOCK_MAXSIZE) {\n removeBlock(root, right);\n block.mmInfo = blockInfo = (blockInfo & TAGS_MASK) | newSize;\n right = GETRIGHT(block);\n rightInfo = right.mmInfo;\n // 'back' is set below\n }\n }\n\n // merge with left block if also free\n if (blockInfo & LEFTFREE) {\n let left = GETFREELEFT(block);\n let leftInfo = left.mmInfo;\n if (DEBUG) assert(leftInfo & FREE); // must be free according to right tags\n let newSize = (leftInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (blockInfo & ~TAGS_MASK);\n if (newSize < BLOCK_MAXSIZE) {\n removeBlock(root, left);\n left.mmInfo = blockInfo = (leftInfo & TAGS_MASK) | newSize;\n block = left;\n // 'back' is set below\n }\n }\n\n right.mmInfo = rightInfo | LEFTFREE;\n // right is no longer used now, hence rightInfo is not synced\n\n // we now know the size of the block\n var size = blockInfo & ~TAGS_MASK;\n if (DEBUG) assert(size >= BLOCK_MINSIZE && size < BLOCK_MAXSIZE); // must be a valid size\n if (DEBUG) assert(changetype(block) + BLOCK_OVERHEAD + size == changetype(right)); // must match\n\n // set 'back' to itself at the end of block\n store(changetype(right) - sizeof(), block);\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const inv: usize = sizeof() * 8 - 1;\n fl = inv - clz(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // perform insertion\n var head = GETHEAD(root, fl, sl);\n block.prev = null;\n block.next = head;\n if (head) head.prev = block;\n SETHEAD(root, fl, sl, block);\n\n // update first and second level maps\n root.flMap |= (1 << fl);\n SETSL(root, fl, GETSL(root, fl) | (1 << sl));\n}\n\n/** Removes a free block from internal lists. */\nfunction removeBlock(root: Root, block: Block): void {\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(blockInfo & FREE); // must be free\n var size = blockInfo & ~TAGS_MASK;\n if (DEBUG) assert(size >= BLOCK_MINSIZE && size < BLOCK_MAXSIZE); // must be valid\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const inv: usize = sizeof() * 8 - 1;\n fl = inv - clz(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // link previous and next free block\n var prev = block.prev;\n var next = block.next;\n if (prev) prev.next = next;\n if (next) next.prev = prev;\n\n // update head if we are removing it\n if (block == GETHEAD(root, fl, sl)) {\n SETHEAD(root, fl, sl, next);\n\n // clear second level map if head is empty now\n if (!next) {\n let slMap = GETSL(root, fl);\n SETSL(root, fl, slMap &= ~(1 << sl));\n\n // clear first level map if second level is empty now\n if (!slMap) root.flMap &= ~(1 << fl);\n }\n }\n // note: does not alter left/back because it is likely that splitting\n // is performed afterwards, invalidating those changes. so, the caller\n // must perform those updates.\n}\n\n/** Searches for a free block of at least the specified size. */\nfunction searchBlock(root: Root, size: usize): Block | null {\n // size was already asserted by caller\n\n // mapping_search\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const halfMaxSize = BLOCK_MAXSIZE >> 1; // don't round last fl\n const inv: usize = sizeof() * 8 - 1;\n const invRound = inv - SL_BITS;\n let requestSize = size < halfMaxSize\n ? size + (1 << (invRound - clz(size))) - 1\n : size;\n fl = inv - clz(requestSize);\n sl = ((requestSize >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // search second level\n var slMap = GETSL(root, fl) & (~0 << sl);\n var head: Block | null = null;\n if (!slMap) {\n // search next larger first level\n let flMap = root.flMap & (~0 << (fl + 1));\n if (!flMap) {\n head = null;\n } else {\n fl = ctz(flMap);\n slMap = GETSL(root, fl);\n if (DEBUG) assert(slMap); // can't be zero if fl points here\n head = GETHEAD(root, fl, ctz(slMap));\n }\n } else {\n head = GETHEAD(root, fl, ctz(slMap));\n }\n return head;\n}\n\n/** Prepares the specified block before (re-)use, possibly splitting it. */\nfunction prepareBlock(root: Root, block: Block, size: usize): void {\n // size was already asserted by caller\n\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(!(size & AL_MASK)); // size must be aligned so the new block is\n\n // split if the block can hold another MINSIZE block incl. overhead\n var remaining = (blockInfo & ~TAGS_MASK) - size;\n if (remaining >= BLOCK_OVERHEAD + BLOCK_MINSIZE) {\n block.mmInfo = size | (blockInfo & LEFTFREE); // also discards FREE\n\n let spare = changetype(changetype(block) + BLOCK_OVERHEAD + size);\n spare.mmInfo = (remaining - BLOCK_OVERHEAD) | FREE; // not LEFTFREE\n insertBlock(root, spare); // also sets 'back'\n\n // otherwise tag block as no longer FREE and right as no longer LEFTFREE\n } else {\n block.mmInfo = blockInfo & ~FREE;\n GETRIGHT(block).mmInfo &= ~LEFTFREE;\n }\n}\n\n/** Adds more memory to the pool. */\nfunction addMemory(root: Root, start: usize, end: usize): bool {\n if (DEBUG) {\n assert(\n start <= end && // must be valid\n !(start & AL_MASK) && // must be aligned\n !(end & AL_MASK) // must be aligned\n );\n }\n\n var tail = GETTAIL(root);\n var tailInfo: usize = 0;\n if (tail) { // more memory\n if (DEBUG) assert(start >= changetype(tail) + BLOCK_OVERHEAD);\n\n // merge with current tail if adjacent\n if (start - BLOCK_OVERHEAD == changetype(tail)) {\n start -= BLOCK_OVERHEAD;\n tailInfo = tail.mmInfo;\n } else {\n // We don't do this, but a user might `memory.grow` manually\n // leading to non-adjacent pages managed by TLSF.\n }\n\n } else if (DEBUG) { // first memory\n assert(start >= changetype(root) + ROOT_SIZE); // starts after root\n }\n\n // check if size is large enough for a free block and the tail block\n var size = end - start;\n if (size < BLOCK_OVERHEAD + BLOCK_MINSIZE + BLOCK_OVERHEAD) {\n return false;\n }\n\n // left size is total minus its own and the zero-length tail's header\n var leftSize = size - 2 * BLOCK_OVERHEAD;\n var left = changetype(start);\n left.mmInfo = leftSize | FREE | (tailInfo & LEFTFREE);\n left.prev = null;\n left.next = null;\n\n // tail is a zero-length used block\n tail = changetype(start + size - BLOCK_OVERHEAD);\n tail.mmInfo = 0 | LEFTFREE;\n SETTAIL(root, tail);\n\n insertBlock(root, left); // also merges with free left before tail / sets 'back'\n\n return true;\n}\n\n/** Grows memory to fit at least another block of the specified size. */\nfunction growMemory(root: Root, size: usize): void {\n var pagesBefore = memory.size();\n var pagesNeeded = (((size + 0xffff) & ~0xffff) >>> 16);\n var pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) unreachable();\n }\n var pagesAfter = memory.size();\n addMemory(root, pagesBefore << 16, pagesAfter << 16);\n}\n\n/** Prepares and checks an allocation size. */\nfunction prepareSize(size: usize): usize {\n if (size >= BLOCK_MAXSIZE) throw new Error(\"allocation too large\");\n return max((size + AL_MASK) & ~AL_MASK, BLOCK_MINSIZE); // align and ensure min size\n}\n\n/** Initilizes the root structure. */\nexport function initializeRoot(): void {\n var rootOffset = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n var pagesNeeded = ((((rootOffset + ROOT_SIZE) + 0xffff) & ~0xffff) >>> 16);\n if (pagesNeeded > pagesBefore && memory.grow(pagesNeeded - pagesBefore) < 0) unreachable();\n var root = changetype(rootOffset);\n root.flMap = 0;\n SETTAIL(root, changetype(0));\n for (let fl: usize = 0; fl < FL_BITS; ++fl) {\n SETSL(root, fl, 0);\n for (let sl: u32 = 0; sl < SL_SIZE; ++sl) {\n SETHEAD(root, fl, sl, null);\n }\n }\n addMemory(root, (rootOffset + ROOT_SIZE + AL_MASK) & ~AL_MASK, memory.size() << 16);\n ROOT = root;\n}\n\n/** Allocates a block of the specified size. */\nexport function allocateBlock(root: Root, size: usize): Block {\n var payloadSize = prepareSize(size);\n var block = searchBlock(root, payloadSize);\n if (!block) {\n growMemory(root, payloadSize);\n block = searchBlock(root, payloadSize);\n if (DEBUG) assert(block); // must be found now\n }\n if (DEBUG) assert((block.mmInfo & ~TAGS_MASK) >= payloadSize); // must fit\n block.gcInfo = 0; // RC=0\n // block.rtId = 0; // set by the caller (__alloc)\n block.rtSize = size;\n removeBlock(root, block);\n prepareBlock(root, block, payloadSize);\n if (isDefined(ASC_RTRACE)) onalloc(block);\n return block;\n}\n\n/** Reallocates a block to the specified size. */\nexport function reallocateBlock(root: Root, block: Block, size: usize): Block {\n var payloadSize = prepareSize(size);\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(!(blockInfo & FREE)); // must be used\n\n // possibly split and update runtime size if it still fits\n if (payloadSize <= (blockInfo & ~TAGS_MASK)) {\n prepareBlock(root, block, payloadSize);\n block.rtSize = size;\n return block;\n }\n\n // merge with right free block if merger is large enough\n var right = GETRIGHT(block);\n var rightInfo = right.mmInfo;\n if (rightInfo & FREE) {\n let mergeSize = (blockInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (rightInfo & ~TAGS_MASK);\n if (mergeSize >= payloadSize) {\n removeBlock(root, right);\n // TODO: this can yield an intermediate block larger than BLOCK_MAXSIZE, which\n // is immediately split though. does this trigger any assertions / issues?\n block.mmInfo = (blockInfo & TAGS_MASK) | mergeSize;\n block.rtSize = size;\n prepareBlock(root, block, payloadSize);\n return block;\n }\n }\n\n // otherwise move the block\n var newBlock = allocateBlock(root, size);\n newBlock.gcInfo = block.gcInfo;\n newBlock.rtId = block.rtId;\n memory.copy(changetype(newBlock) + BLOCK_OVERHEAD, changetype(block) + BLOCK_OVERHEAD, size);\n block.mmInfo = blockInfo | FREE;\n insertBlock(root, block);\n return newBlock;\n}\n\n/** Frees a block. */\nexport function freeBlock(root: Root, block: Block): void {\n var blockInfo = block.mmInfo;\n assert(!(blockInfo & FREE)); // must be used (user might call through to this)\n block.mmInfo = blockInfo | FREE;\n insertBlock(root, block);\n if (isDefined(ASC_RTRACE)) onfree(block);\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __alloc(size: usize, id: u32): usize {\n var root = ROOT;\n if (!root) {\n initializeRoot();\n root = ROOT;\n }\n var block = allocateBlock(root, size);\n block.rtId = id;\n return changetype(block) + BLOCK_OVERHEAD;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __realloc(ref: usize, size: usize): usize {\n if (DEBUG) assert(ROOT); // must be initialized\n assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned\n return changetype(reallocateBlock(ROOT, changetype(ref - BLOCK_OVERHEAD), size)) + BLOCK_OVERHEAD;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __free(ref: usize): void {\n if (DEBUG) assert(ROOT); // must be initialized\n assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned\n freeBlock(ROOT, changetype(ref - BLOCK_OVERHEAD));\n}\n",set:'/// \n\nimport { HASH } from "./util/hash";\n\n// A deterministic hash set based on CloseTable from https://github.com/jorendorff/dht\n\n// @ts-ignore: decorator\n@inline\nconst INITIAL_CAPACITY = 4;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR: f64 = 8 / 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR: f64 = 3 / 4;\n\n/** Structure of a set entry. */\n@unmanaged class SetEntry {\n key: K;\n taggedNext: usize; // LSB=1 indicates EMPTY\n}\n\n/** Empty bit. */\n// @ts-ignore: decorator\n@inline\nconst EMPTY: usize = 1 << 0;\n\n/** Size of a bucket. */\n// @ts-ignore: decorator\n@inline\nconst BUCKET_SIZE = sizeof();\n\n/** Computes the alignment of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_ALIGN(): usize {\n // can align to 4 instead of 8 if 32-bit and K is <= 32-bits\n const align = (sizeof() > sizeof() ? sizeof() : sizeof()) - 1;\n return align;\n}\n\n/** Computes the aligned size of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_SIZE(): usize {\n const align = ENTRY_ALIGN();\n const size = (offsetof>() + align) & ~align;\n return size;\n}\n\nexport class Set {\n\n // buckets holding references to the respective first entry within\n private buckets: ArrayBuffer; // usize[bucketsMask + 1]\n private bucketsMask: u32;\n\n // entries in insertion order\n private entries: ArrayBuffer; // SetEntry[entriesCapacity]\n private entriesCapacity: i32;\n private entriesOffset: i32;\n private entriesCount: i32;\n\n get size(): i32 { return this.entriesCount; }\n\n constructor() { this.clear(); }\n\n clear(): void {\n const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE;\n this.buckets = new ArrayBuffer(bucketsSize);\n this.bucketsMask = INITIAL_CAPACITY - 1;\n const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE();\n this.entries = new ArrayBuffer(entriesSize);\n this.entriesCapacity = INITIAL_CAPACITY;\n this.entriesOffset = 0;\n this.entriesCount = 0;\n }\n\n private find(key: K, hashCode: u32): SetEntry | null {\n var entry = load>( // unmanaged!\n changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE\n );\n while (entry) {\n if (!(entry.taggedNext & EMPTY) && entry.key == key) return entry;\n entry = changetype>(entry.taggedNext & ~EMPTY);\n }\n return null;\n }\n\n has(key: K): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n add(key: K): void {\n var hashCode = HASH(key);\n var entry = this.find(key, hashCode); // unmanaged!\n if (!entry) {\n // check if rehashing is necessary\n if (this.entriesOffset == this.entriesCapacity) {\n this.rehash(\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ? this.bucketsMask // just rehash if 1/4+ entries are empty\n : (this.bucketsMask << 1) | 1 // grow capacity to next 2^N\n );\n }\n // append new entry\n entry = changetype>(changetype(this.entries) + this.entriesOffset++ * ENTRY_SIZE());\n entry.key = isManaged()\n ? changetype(__retain(changetype(key)))\n : key;\n ++this.entriesCount;\n // link with previous entry in bucket\n let bucketPtrBase = changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE;\n entry.taggedNext = load(bucketPtrBase);\n store(bucketPtrBase, changetype(entry));\n }\n }\n\n delete(key: K): bool {\n var entry = this.find(key, HASH(key)); // unmanaged!\n if (!entry) return false;\n if (isManaged()) __release(changetype(entry.key)); // exact \'key\'\n entry.taggedNext |= EMPTY;\n --this.entriesCount;\n // check if rehashing is appropriate\n var halfBucketsMask = this.bucketsMask >> 1;\n if (\n halfBucketsMask + 1 >= max(INITIAL_CAPACITY, this.entriesCount) &&\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ) this.rehash(halfBucketsMask);\n return true;\n }\n\n private rehash(newBucketsMask: u32): void {\n var newBucketsCapacity = (newBucketsMask + 1);\n var newBuckets = new ArrayBuffer(newBucketsCapacity * BUCKET_SIZE);\n var newEntriesCapacity = (newBucketsCapacity * FILL_FACTOR);\n var newEntries = new ArrayBuffer(newEntriesCapacity * ENTRY_SIZE());\n\n // copy old entries to new entries\n var oldPtr = changetype(this.entries);\n var oldEnd = oldPtr + this.entriesOffset * ENTRY_SIZE();\n var newPtr = changetype(newEntries);\n while (oldPtr != oldEnd) {\n let oldEntry = changetype>(oldPtr); // unmanaged!\n if (!(oldEntry.taggedNext & EMPTY)) {\n let newEntry = changetype>(newPtr); // unmanaged!\n newEntry.key = oldEntry.key;\n let newBucketIndex = HASH(oldEntry.key) & newBucketsMask;\n let newBucketPtrBase = changetype(newBuckets) + newBucketIndex * BUCKET_SIZE;\n newEntry.taggedNext = load(newBucketPtrBase);\n store(newBucketPtrBase, newPtr);\n newPtr += ENTRY_SIZE();\n }\n oldPtr += ENTRY_SIZE();\n }\n\n this.buckets = newBuckets;\n this.bucketsMask = newBucketsMask;\n this.entries = newEntries;\n this.entriesCapacity = newEntriesCapacity;\n this.entriesOffset = this.entriesCount;\n }\n\n toString(): string {\n return "[object Set]";\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n __visit(changetype(this.buckets), cookie);\n var entries = changetype(this.entries);\n if (isManaged()) {\n let cur = entries;\n let end = cur + this.entriesOffset * ENTRY_SIZE();\n while (cur < end) {\n let entry = changetype>(cur);\n if (!(entry.taggedNext & EMPTY)) {\n let val = changetype(entry.key);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n cur += ENTRY_SIZE();\n }\n }\n __visit(entries, cookie);\n }\n}\n',"shared/feature":"// This file is shared with the compiler and must remain portable\n\n/** Indicates specific features to activate. */\nexport const enum Feature {\n /** No additional features. */\n NONE = 0,\n /** Sign extension operations. */\n SIGN_EXTENSION = 1 << 0, // see: https://github.com/WebAssembly/sign-extension-ops\n /** Mutable global imports and exports. */\n MUTABLE_GLOBAL = 1 << 1, // see: https://github.com/WebAssembly/mutable-global\n /** Bulk memory operations. */\n BULK_MEMORY = 1 << 2, // see: https://github.com/WebAssembly/bulk-memory-operations\n /** SIMD types and operations. */\n SIMD = 1 << 3, // see: https://github.com/WebAssembly/simd\n /** Threading and atomic operations. */\n THREADS = 1 << 4 // see: https://github.com/WebAssembly/threads\n}\n","shared/target":"// This file is shared with the compiler and must remain portable\n\n/** Compilation target. */\nexport enum Target {\n /** WebAssembly with 32-bit pointers. */\n WASM32,\n /** WebAssembly with 64-bit pointers. Experimental and not supported by any runtime yet. */\n WASM64,\n /** Portable. */\n JS\n}\n","shared/typeinfo":"// This file is shared with the compiler and must remain portable\n\n// ╒═══════════════════ Typeinfo interpretation ═══════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ◄─ RTTI_BASE\n// │ count │\n// ╞═══════════════════════════════════════════════════════════════╡ ┐\n// │ Typeinfo#flags [id=0] │ id < count\n// ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤\n// │ Typeinfo#base [id=0] │\n// ├───────────────────────────────────────────────────────────────┤\n// │ ... │\n\n/** Runtime type information data structure. */\n@unmanaged\nexport class Typeinfo {\n /** Flags describing the shape of this class type. */\n flags: TypeinfoFlags;\n /** Base class id or `0` if none. */\n base: u32;\n}\n\n/** Runtime type information flags. */\nexport const enum TypeinfoFlags {\n /** No specific flags. */\n NONE = 0,\n /** Type is an `ArrayBufferView`. */\n ARRAYBUFFERVIEW = 1 << 0,\n /** Type is an `Array`. */\n ARRAY = 1 << 1,\n /** Type is a `Set`. */\n SET = 1 << 2,\n /** Type is a `Map`. */\n MAP = 1 << 3,\n /** Type is inherently acyclic. */\n ACYCLIC = 1 << 4,\n /** Value alignment of 1 byte. */\n VALUE_ALIGN_0 = 1 << 5,\n /** Value alignment of 2 bytes. */\n VALUE_ALIGN_1 = 1 << 6,\n /** Value alignment of 4 bytes. */\n VALUE_ALIGN_2 = 1 << 7,\n /** Value alignment of 8 bytes. */\n VALUE_ALIGN_3 = 1 << 8,\n /** Value alignment of 16 bytes. */\n VALUE_ALIGN_4 = 1 << 9,\n /** Value is a signed type. */\n VALUE_SIGNED = 1 << 10,\n /** Value is a float type. */\n VALUE_FLOAT = 1 << 11,\n /** Value type is nullable. */\n VALUE_NULLABLE = 1 << 12,\n /** Value type is managed. */\n VALUE_MANAGED = 1 << 13,\n /** Key alignment of 1 byte. */\n KEY_ALIGN_0 = 1 << 14,\n /** Key alignment of 2 bytes. */\n KEY_ALIGN_1 = 1 << 15,\n /** Key alignment of 4 bytes. */\n KEY_ALIGN_2 = 1 << 16,\n /** Key alignment of 8 bytes. */\n KEY_ALIGN_3 = 1 << 17,\n /** Key alignment of 16 bytes. */\n KEY_ALIGN_4 = 1 << 18,\n /** Value is a signed type. */\n KEY_SIGNED = 1 << 19,\n /** Value is a float type. */\n KEY_FLOAT = 1 << 20,\n /** Key type is nullable. */\n KEY_NULLABLE = 1 << 21,\n /** Key type is managed. */\n KEY_MANAGED = 1 << 22\n}\n",string:'/// \n\nimport { BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "./rt/common";\nimport { compareImpl, parse, CharCode, isWhiteSpaceOrLineTerminator } from "./util/string";\nimport { E_INVALIDLENGTH } from "./util/error";\nimport { ArrayBufferView } from "./arraybuffer";\nimport { idof } from "./builtins";\n\n@sealed export abstract class String {\n\n @lazy static readonly MAX_LENGTH: i32 = BLOCK_MAXSIZE >>> alignof();\n\n // TODO Add and handle second argument\n static fromCharCode(code: i32): string {\n var out = __alloc(2, idof());\n store(out, code);\n return changetype(out); // retains\n }\n\n static fromCodePoint(code: i32): string {\n assert(code <= 0x10FFFF);\n var sur = code > 0xFFFF;\n var out = __alloc((i32(sur) + 1) << 1, idof());\n if (!sur) {\n store(out, code);\n } else {\n code -= 0x10000;\n let hi: u32 = (code >>> 10) + 0xD800;\n let lo: u32 = (code & 0x3FF) + 0xDC00;\n store(out, (hi << 16) | lo);\n }\n return changetype(out); // retains\n }\n\n get length(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize >> 1;\n }\n\n @operator("[]") charAt(pos: i32): String {\n assert(this !== null);\n if (pos >= this.length) return changetype("");\n var out = __alloc(2, idof());\n store(out, load(changetype(this) + (pos << 1)));\n return changetype(out); // retains\n }\n\n charCodeAt(pos: i32): i32 {\n if (pos >= this.length) return -1; // (NaN)\n return load(changetype(this) + (pos << 1));\n }\n\n codePointAt(pos: i32): i32 {\n if (pos >= this.length) return -1; // (undefined)\n var first = load(changetype(this) + (pos << 1));\n if (first < 0xD800 || first > 0xDBFF || pos + 1 == this.length) return first;\n var second = load(changetype(this) + ((pos + 1) << 1));\n if (second < 0xDC00 || second > 0xDFFF) return first;\n return ((first - 0xD800) << 10) + (second - 0xDC00) + 0x10000;\n }\n\n @operator("+") private static __concat(left: String, right: String): String {\n return select(left, changetype("null"), left !== null).concat(right);\n }\n\n concat(other: String): String {\n if (other === null) other = changetype("null");\n var thisSize: isize = this.length << 1;\n var otherSize: isize = other.length << 1;\n var outSize: usize = thisSize + otherSize;\n if (outSize == 0) return changetype("");\n var out = changetype(__alloc(outSize, idof())); // retains\n memory.copy(changetype(out), changetype(this), thisSize);\n memory.copy(changetype(out) + thisSize, changetype(other), otherSize);\n return out;\n }\n\n endsWith(searchString: String, endPosition: i32 = String.MAX_LENGTH): bool {\n assert(this !== null);\n if (searchString === null) return false;\n var end = min(max(endPosition, 0), this.length);\n var searchLength: isize = searchString.length;\n var start: isize = end - searchLength;\n if (start < 0) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, start, searchString, 0, searchLength);\n }\n\n @operator("==") private static __eq(left: String | null, right: String | null): bool {\n if (left === right) return true;\n if (left === null || right === null) return false;\n var leftLength = left.length;\n if (leftLength != right.length) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(left, 0, right, 0, leftLength);\n }\n\n @operator.prefix("!")\n private static __not(str: String | null): bool {\n return str === null || !str.length;\n }\n\n @operator("!=")\n private static __ne(left: String | null, right: String | null): bool {\n return !this.__eq(left, right);\n }\n\n @operator(">") private static __gt(left: String | null, right: String | null): bool {\n if (left === right || left === null || right === null) return false;\n var leftLength = left.length;\n var rightLength = right.length;\n if (!leftLength) return false;\n if (!rightLength) return true;\n // @ts-ignore: string <-> String\n return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) > 0;\n }\n\n @operator(">=") private static __gte(left: String, right: String): bool {\n return !this.__lt(left, right);\n }\n\n @operator("<") private static __lt(left: String, right: String): bool {\n if (left === right || left === null || right === null) return false;\n var leftLength = left.length;\n var rightLength = right.length;\n if (!rightLength) return false;\n if (!leftLength) return true;\n // @ts-ignore: string <-> String\n return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) < 0;\n }\n\n @operator("<=") private static __lte(left: String, right: String): bool {\n return !this.__gt(left, right);\n }\n\n @inline includes(searchString: String, position: i32 = 0): bool {\n return this.indexOf(searchString, position) != -1;\n }\n\n indexOf(searchString: String, fromIndex: i32 = 0): i32 {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var searchLen: isize = searchString.length;\n if (!searchLen) return 0;\n var len: isize = this.length;\n if (!len) return -1;\n var start = min(max(fromIndex, 0), len);\n len -= searchLen;\n for (let k: isize = start; k <= len; ++k) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, k, searchString, 0, searchLen)) return k;\n }\n return -1;\n }\n\n lastIndexOf(searchString: String, fromIndex: i32 = i32.MAX_VALUE): i32 {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var len: isize = this.length;\n var searchLen: isize = searchString.length;\n if (!searchLen) return len;\n if (!len) return -1;\n var start = min(max(fromIndex, 0), len - searchLen);\n for (let k = start; k >= 0; --k) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, k, searchString, 0, searchLen)) return k;\n }\n return -1;\n }\n\n startsWith(searchString: String, position: i32 = 0): bool {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var pos: isize = position;\n var len: isize = this.length;\n var start = min(max(pos, 0), len);\n var searchLength: isize = searchString.length;\n if (searchLength + start > len) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, start, searchString, 0, searchLength);\n }\n\n substr(start: i32, length: i32 = i32.MAX_VALUE): String {\n assert(this !== null);\n var intStart: isize = start;\n var end: isize = length;\n var size: isize = this.length;\n if (intStart < 0) intStart = max(size + intStart, 0);\n var resultLength = min(max(end, 0), size - intStart);\n if (resultLength <= 0) return changetype("");\n var out = __alloc(resultLength << 1, idof());\n memory.copy(out, changetype(this) + intStart, resultLength);\n return changetype(out); // retains\n }\n\n substring(start: i32, end: i32 = i32.MAX_VALUE): String {\n assert(this !== null);\n var len: isize = this.length;\n var finalStart = min(max(start, 0), len);\n var finalEnd = min(max(end, 0), len);\n var fromPos = min(finalStart, finalEnd) << 1;\n var toPos = max(finalStart, finalEnd) << 1;\n len = toPos - fromPos;\n if (!len) return changetype("");\n if (!fromPos && toPos == this.length << 1) return this;\n var out = __alloc(len, idof());\n memory.copy(out, changetype(this) + fromPos, len);\n return changetype(out); // retains\n }\n\n trim(): String {\n assert(this !== null);\n var length = this.length;\n var size: usize = length << 1;\n while (\n size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + size)\n )\n ) {\n size -= 2;\n }\n var offset: usize = 0;\n while (\n offset < size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + offset)\n )\n ) {\n offset += 2; size -= 2;\n }\n if (!size) return changetype("");\n if (!start && size == length << 1) return this;\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this) + offset, size);\n return changetype(out); // retains\n }\n\n @inline\n trimLeft(): String {\n return this.trimStart();\n }\n\n @inline\n trimRight(): String {\n return this.trimEnd();\n }\n\n trimStart(): String {\n assert(this !== null);\n var size = this.length << 1;\n var offset: usize = 0;\n while (\n offset < size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + offset)\n )\n ) {\n offset += 2;\n }\n if (!offset) return this;\n size -= offset;\n if (!size) return changetype("");\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this) + offset, size);\n return changetype(out); // retains\n }\n\n trimEnd(): String {\n assert(this !== null);\n var originalSize = this.length << 1;\n var size = originalSize;\n while (\n size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + size)\n )\n ) {\n size -= 2;\n }\n if (!size) return changetype("");\n if (size == originalSize) return this;\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this), size);\n return changetype(out); // retains\n }\n\n padStart(targetLength: i32, padString: string = " "): String {\n assert(this !== null);\n var thisSize = this.length << 1;\n var targetSize = targetLength << 1;\n var padSize = padString.length << 1;\n if (targetSize < thisSize || !padSize) return this;\n var prependSize = targetSize - thisSize;\n var out = __alloc(targetSize, idof());\n if (prependSize > padSize) {\n let repeatCount = (prependSize - 2) / padSize;\n let restBase = repeatCount * padSize;\n let restSize = prependSize - restBase;\n memory.repeat(out, changetype(padString), padSize, repeatCount);\n memory.copy(out + restBase, changetype(padString), restSize);\n } else {\n memory.copy(out, changetype(padString), prependSize);\n }\n memory.copy(out + prependSize, changetype(this), thisSize);\n return changetype(out); // retains\n }\n\n padEnd(targetLength: i32, padString: string = " "): String {\n assert(this !== null);\n var thisSize = this.length << 1;\n var targetSize = targetLength << 1;\n var padSize = padString.length << 1;\n if (targetSize < thisSize || !padSize) return this;\n var appendSize = targetSize - thisSize;\n var out = __alloc(targetSize, idof());\n memory.copy(out, changetype(this), thisSize);\n if (appendSize > padSize) {\n let repeatCount = (appendSize - 2) / padSize;\n let restBase = repeatCount * padSize;\n let restSize = appendSize - restBase;\n memory.repeat(out + thisSize, changetype(padString), padSize, repeatCount);\n memory.copy(out + thisSize + restBase, changetype(padString), restSize);\n } else {\n memory.copy(out + thisSize, changetype(padString), appendSize);\n }\n return changetype(out); // retains\n }\n\n repeat(count: i32 = 0): String {\n assert(this !== null);\n var length = this.length;\n\n // Most browsers can\'t handle strings 1 << 28 chars or longer\n if (count < 0 || length * count > (1 << 28)) {\n throw new RangeError(E_INVALIDLENGTH);\n }\n\n if (count == 0 || !length) return changetype("");\n if (count == 1) return this;\n var out = __alloc((length * count) << 1, idof());\n memory.repeat(out, changetype(this), length << 1, count);\n return changetype(out); // retains\n }\n\n slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String {\n var len = this.length;\n var begin = beginIndex < 0 ? max(beginIndex + len, 0) : min(beginIndex, len);\n var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len);\n len = end - begin;\n if (len <= 0) return changetype("");\n var out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (begin << 1), len << 1);\n return changetype(out); // retains\n }\n\n split(separator: String | null = null, limit: i32 = i32.MAX_VALUE): String[] {\n assert(this !== null);\n if (!limit) return changetype>(__allocArray(0, alignof(), idof>())); // retains\n if (separator === null) return [this];\n var length: isize = this.length;\n var sepLen: isize = separator.length;\n if (limit < 0) limit = i32.MAX_VALUE;\n if (!sepLen) {\n if (!length) return changetype>(__allocArray(0, alignof(), idof>())); // retains\n // split by chars\n length = min(length, limit);\n let result = __allocArray(length, alignof(), idof>());\n let resultStart = changetype(result).dataStart;\n for (let i: isize = 0; i < length; ++i) {\n let charStr = __alloc(2, idof());\n store(charStr, load(changetype(this) + (i << 1)));\n store(resultStart + (i << alignof()), charStr); // result[i] = charStr\n if (isManaged()) __retain(charStr);\n }\n return changetype>(result); // retains\n } else if (!length) {\n let result = __allocArray(1, alignof(), idof>());\n store(changetype(result).dataStart, changetype("")); // static ""\n return changetype>(result); // retains\n }\n var result = changetype>(__allocArray(0, alignof(), idof>())); // retains\n var end = 0, start = 0, i = 0;\n while ((end = this.indexOf(separator, start)) != -1) {\n let len = end - start;\n if (len > 0) {\n let out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n result.push(changetype(out));\n } else {\n result.push(changetype(""));\n }\n if (++i == limit) return changetype>(result); // retains\n start = end + sepLen;\n }\n if (!start) { // also means: loop above didn\'t do anything\n result.push(this);\n return changetype>(result); // retains\n }\n var len = length - start;\n if (len > 0) {\n let out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n result.push(changetype(out)); // retains\n } else {\n result.push(changetype("")); // static ""\n }\n return changetype>(result); // retains\n // releases result\n }\n\n toString(): String {\n return this;\n }\n\n get lengthUTF8(): i32 {\n var len = 1; // null terminated\n var pos: usize = 0;\n var end = this.length;\n while (pos < end) {\n let c = load(changetype(this) + (pos << 1));\n if (c < 128) {\n len += 1; ++pos;\n } else if (c < 2048) {\n len += 2; ++pos;\n } else {\n if (\n (c & 0xFC00) == 0xD800 && pos + 1 < end &&\n (load(changetype(this) + ((pos + 1) << 1)) & 0xFC00) == 0xDC00\n ) {\n len += 4; pos += 2;\n } else {\n len += 3; ++pos;\n }\n }\n }\n return len;\n }\n\n static fromUTF8(ptr: usize, len: usize): String {\n if (len < 1) return changetype("");\n var ptrPos = 0;\n var buf = __alloc(len << 1, 0);\n var bufPos = 0;\n while (ptrPos < len) {\n let cp = load(ptr + ptrPos++);\n if (cp < 128) {\n store(buf + bufPos, cp);\n bufPos += 2;\n } else if (cp > 191 && cp < 224) {\n assert(ptrPos + 1 <= len);\n store(buf + bufPos, (cp & 31) << 6 | load(ptr + ptrPos++) & 63);\n bufPos += 2;\n } else if (cp > 239 && cp < 365) {\n assert(ptrPos + 3 <= len);\n cp = (\n (cp & 7) << 18 |\n (load(ptr + ptrPos++) & 63) << 12 |\n (load(ptr + ptrPos++) & 63) << 6 |\n load(ptr + ptrPos++) & 63\n ) - 0x10000;\n store(buf + bufPos, 0xD800 + (cp >> 10));\n bufPos += 2;\n store(buf + bufPos, 0xDC00 + (cp & 1023));\n bufPos += 2;\n } else {\n assert(ptrPos + 2 <= len);\n store(buf + bufPos,\n (cp & 15) << 12 |\n (load(ptr + ptrPos++) & 63) << 6 |\n load(ptr + ptrPos++) & 63\n );\n bufPos += 2;\n }\n }\n assert(ptrPos == len);\n var out = __alloc(bufPos, idof());\n memory.copy(out, buf, bufPos);\n __free(buf);\n return changetype(out); // retains\n }\n\n toUTF8(): usize {\n var buf = __alloc(this.lengthUTF8, 0);\n var pos: usize = 0;\n var end = this.length;\n var off: usize = 0;\n while (pos < end) {\n let c1 = load(changetype(this) + (pos << 1));\n if (c1 < 128) {\n store(buf + off, c1);\n ++off; ++pos;\n } else if (c1 < 2048) {\n let ptr = buf + off;\n store(ptr, c1 >> 6 | 192);\n store(ptr, c1 & 63 | 128, 1);\n off += 2; ++pos;\n } else {\n let ptr = buf + off;\n if ((c1 & 0xFC00) == 0xD800 && pos + 1 < end) {\n let c2 = load(changetype(this) + ((pos + 1) << 1));\n if ((c2 & 0xFC00) == 0xDC00) {\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\n store(ptr, c1 >> 18 | 240);\n store(ptr, c1 >> 12 & 63 | 128, 1);\n store(ptr, c1 >> 6 & 63 | 128, 2);\n store(ptr, c1 & 63 | 128, 3);\n off += 4; pos += 2;\n continue;\n }\n }\n store(ptr, c1 >> 12 | 224);\n store(ptr, c1 >> 6 & 63 | 128, 1);\n store(ptr, c1 & 63 | 128, 2);\n off += 3; ++pos;\n }\n }\n store(buf + off, 0);\n return buf;\n }\n}\n\n// @ts-ignore: nolib\nexport type string = String;\n\nexport function parseInt(str: String, radix: i32 = 0): f64 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\nexport function parseI32(str: String, radix: i32 = 0): i32 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\nexport function parseI64(str: String, radix: i32 = 0): i64 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\n// FIXME: naive implementation\nexport function parseFloat(str: String): f64 {\n var len: i32 = str.length;\n if (!len) return NaN;\n\n var ptr = changetype(str);\n var code = load(ptr);\n\n // determine sign\n var sign: f64;\n if (code == CharCode.MINUS) {\n if (!--len) return NaN;\n code = load(ptr += 2);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len) return NaN;\n code = load(ptr += 2);\n sign = 1;\n } else {\n sign = 1;\n }\n\n // calculate value\n var num: f64 = 0;\n while (len--) {\n code = load(ptr);\n if (code == CharCode.DOT) {\n ptr += 2;\n let fac: f64 = 0.1; // precision :(\n while (len--) {\n code = load(ptr);\n if (code == CharCode.E || code == CharCode.e) {\n assert(false); // TODO\n }\n code -= CharCode._0;\n if (code > 9) break;\n num += code * fac;\n fac *= 0.1;\n ptr += 2;\n }\n break;\n }\n code -= CharCode._0;\n if (code >= 10) break;\n num = (num * 10) + code;\n ptr += 2;\n }\n return sign * num;\n}\n',symbol:'import { Map } from "./map";\n\n// @ts-ignore: decorator\n@lazy\nvar stringToId: Map;\n\n// @ts-ignore: decorator\n@lazy\nvar idToString: Map;\n\n// @ts-ignore: decorator\n@lazy\nvar nextId: usize = 12; // Symbol.unscopables + 1\n\n@unmanaged @sealed abstract class _Symbol {\n\n // TODO: all of the following default symbols are unused currently yet add to\n // binary size if #toString becomes compiled. Ultimately we\'ll most likely want\n // to remove the unsupported ones and only keep what\'s actually supported.\n\n // @ts-ignore: decorator\n @lazy\n static readonly hasInstance: symbol = changetype(1);\n\n // @ts-ignore: decorator\n @lazy\n static readonly isConcatSpreadable: symbol = changetype(2);\n\n // @ts-ignore: decorator\n @lazy\n static readonly isRegExp: symbol = changetype(3);\n\n // @ts-ignore: decorator\n @lazy\n static readonly iterator: symbol = changetype(3);\n\n // @ts-ignore: decorator\n @lazy\n static readonly match: symbol = changetype(4);\n\n // @ts-ignore: decorator\n @lazy\n static readonly replace: symbol = changetype(5);\n\n // @ts-ignore: decorator\n @lazy\n static readonly search: symbol = changetype(6);\n\n // @ts-ignore: decorator\n @lazy\n static readonly species: symbol = changetype(7);\n\n // @ts-ignore: decorator\n @lazy\n static readonly split: symbol = changetype(8);\n\n // @ts-ignore: decorator\n @lazy\n static readonly toPrimitive: symbol = changetype(9);\n\n // @ts-ignore: decorator\n @lazy\n static readonly toStringTag: symbol = changetype(10);\n\n // @ts-ignore: decorator\n @lazy\n static readonly unscopables: symbol = changetype(11);\n\n static for(key: string): symbol {\n if (!stringToId) { stringToId = new Map(); idToString = new Map(); }\n else if (stringToId.has(key)) return changetype(stringToId.get(key));\n var id = nextId++;\n if (!id) unreachable(); // out of ids\n stringToId.set(key, id);\n idToString.set(id, key);\n return changetype(id);\n }\n\n static keyFor(sym: symbol): string | null {\n return idToString !== null && idToString.has(changetype(sym))\n ? idToString.get(changetype(sym))\n : null;\n }\n\n toString(): string {\n var id = changetype(this);\n var str = "";\n switch (id) {\n case 1: { str = "hasInstance"; break; }\n case 2: { str = "isConcatSpreadable"; break; }\n case 3: { str = "isRegExp"; break; }\n case 4: { str = "match"; break; }\n case 5: { str = "replace"; break; }\n case 6: { str = "search"; break; }\n case 7: { str = "species"; break; }\n case 8: { str = "split"; break; }\n case 9: { str = "toPrimitive"; break; }\n case 10: { str = "toStringTag"; break; }\n case 11: { str = "unscopables"; break; }\n default: {\n if (idToString !== null && idToString.has(id)) str = idToString.get(id);\n break;\n }\n }\n return "Symbol(" + str + ")";\n }\n}\n\nexport function Symbol(description: string | null = null): symbol {\n var id = nextId++;\n if (!id) unreachable(); // out of ids\n return changetype(id);\n}\n\nexport type Symbol = _Symbol;\n\n// @ts-ignore: nolib\nexport type symbol = _Symbol;\n',table:'import { E_NOTIMPLEMENTED } from "./util/error";\n\nexport namespace table {\n\n export function copy(dst: u32, src: u32, n: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n export function drop(elementIndex: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n}\n',typedarray:'import { COMPARATOR, SORT as SORT_IMPL } from "./util/sort";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\nimport { idof } from "./builtins";\nimport { ArrayBufferView } from "./arraybuffer";\n\nexport class Int8Array extends ArrayBufferView {\n [key: number]: i8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i8, b: i8) => i32 = COMPARATOR()): Int8Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int8Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i8, index: i32, self: Int8Array) => i8): Int8Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i8, index: i32, self: Int8Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint8Array extends ArrayBufferView {\n [key: number]: u8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u8, index: i32, self: Uint8Array) => u8): Uint8Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u8, index: i32, self: Uint8Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint8ClampedArray extends ArrayBufferView {\n [key: number]: u8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, ~(value >> 31) & (((255 - value) >> 31) | value));\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8ClampedArray {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8ClampedArray {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => u8): Uint8ClampedArray {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int16Array extends ArrayBufferView {\n [key: number]: i16;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i16 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i16, b: i16) => i32 = COMPARATOR()): Int16Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int16Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i16, index: i32, self: Int16Array) => i16): Int16Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i16, index: i32, self: Int16Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint16Array extends ArrayBufferView {\n [key: number]: u16;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u16 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u16, b: u16) => i32 = COMPARATOR()): Uint16Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint16Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u16, index: i32, self: Uint16Array) => u16): Uint16Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u16, index: i32, self: Uint16Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int32Array extends ArrayBufferView {\n [key: number]: i32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: i32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i32, b: i32) => i32 = COMPARATOR()): Int32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i32, index: i32, self: Int32Array) => i32): Int32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i32, index: i32, self: Int32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint32Array extends ArrayBufferView {\n [key: number]: u32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: u32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u32, b: u32) => i32 = COMPARATOR()): Uint32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u32, index: i32, self: Uint32Array) => u32): Uint32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u32, index: i32, self: Uint32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int64Array extends ArrayBufferView {\n [key: number]: i64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: i64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i64, b: i64) => i32 = COMPARATOR()): Int64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i64, index: i32, self: Int64Array) => i64): Int64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i64, index: i32, self: Int64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint64Array extends ArrayBufferView {\n [key: number]: u64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: u64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u64, b: u64) => i32 = COMPARATOR()): Uint64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u64, index: i32, self: Uint64Array) => u64): Uint64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u64, index: i32, self: Uint64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Float32Array extends ArrayBufferView {\n [key: number]: f32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): f32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: f32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: f32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: f32, b: f32) => i32 = COMPARATOR()): Float32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: f32, index: i32, self: Float32Array) => f32): Float32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: f32, index: i32, self: Float32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Float64Array extends ArrayBufferView {\n [key: number]: f64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): f64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: f64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: f64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: f64, b: f64) => i32 = COMPARATOR()): Float64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: f64, index: i32, self: Float64Array) => f64): Float64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: f64, index: i32, self: Float64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FILL(\n array: TArray,\n value: native,\n start: i32,\n end: i32\n): TArray {\n var dataStart = array.dataStart;\n var length = array.length;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n end = end < 0 ? max(length + end, 0) : min(end, length);\n if (sizeof() == 1) {\n if (start < end) memory.fill(dataStart + start, value, (end - start));\n } else {\n for (; start < end; ++start) {\n store(dataStart + (start << alignof()), value);\n }\n }\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SORT(\n array: TArray,\n comparator: (a: T, b: T) => i32\n): TArray {\n var length = array.length;\n if (length <= 1) return array;\n var base = array.dataStart;\n if (length == 2) {\n let a: T = load(base, sizeof()); // a = arr[1]\n let b: T = load(base); // b = arr[0]\n if (comparator(a, b) < 0) {\n store(base, b, sizeof()); // arr[1] = b\n store(base, a); // arr[0] = a\n }\n return array;\n }\n SORT_IMPL(base, length, comparator);\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SUBARRAY(\n array: TArray,\n begin: i32,\n end: i32\n): TArray {\n var len = array.length;\n begin = begin < 0 ? max(len + begin, 0) : min(begin, len);\n end = end < 0 ? max(len + end, 0) : min(end, len);\n end = max(end, begin);\n var out = changetype(__alloc(offsetof(), idof())); // retains\n out.data = array.data; // retains\n out.dataStart = array.dataStart + (begin << alignof());\n out.dataLength = (end - begin) << alignof();\n return out;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE(\n array: TArray,\n callbackfn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,\n initialValue: TRet\n): TRet {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n initialValue = callbackfn(initialValue, load(dataStart + (i << alignof())), i, array);\n }\n return initialValue;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE_RIGHT(\n array: TArray,\n callbackfn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,\n initialValue: TRet\n): TRet {\n var dataStart = array.dataStart;\n for (let i = array.length - 1; i >= 0; i--) {\n initialValue = callbackfn(initialValue, load(dataStart + (i << alignof())), i, array);\n }\n return initialValue;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction MAP(\n array: TArray,\n callbackfn: (value: T, index: i32, self: TArray) => T,\n): TArray {\n var length = array.length;\n var dataStart = array.dataStart;\n var out = instantiate(length);\n var outDataStart = out.dataStart;\n for (let i = 0; i < length; i++) {\n store(\n outDataStart + (i << alignof()),\n callbackfn(load(dataStart + (i << alignof())), i, array)\n );\n }\n return out;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FIND_INDEX(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): i32 {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) return i;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SOME(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): bool {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) return true;\n }\n return false;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction EVERY(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): bool {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) continue;\n return false;\n }\n return true;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FOREACH(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => void,\n): void {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n callbackfn(load(dataStart + (i << alignof())), i, array);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function REVERSE(array: TArray): TArray {\n var dataStart = array.dataStart;\n for (let front = 0, back = array.length - 1; front < back; ++front, --back) {\n let frontPtr = dataStart + (front << alignof());\n let backPtr = dataStart + (back << alignof());\n let temp = load(frontPtr);\n store(frontPtr, load(backPtr));\n store(backPtr, temp);\n }\n return array;\n}\n',"util/error":'// Common error messages for use accross the standard library. Keeping error messages compact\n// and reusing them where possible ensures minimal static data in binaries.\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_INDEXOUTOFRANGE: string = "Index out of range";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_INVALIDLENGTH: string = "Invalid length";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_EMPTYARRAY: string = "Array is empty";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_HOLEYARRAY: string = "Element type must be nullable if array is holey";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_NOTIMPLEMENTED: string = "Not implemented";\n',"util/hash":"// @ts-ignore: decorator\n@inline\nexport function HASH(key: T): u32 {\n if (isString()) {\n return hashStr(changetype(key));\n } else if (isReference()) {\n if (sizeof() == 4) return hash32(changetype(key));\n if (sizeof() == 8) return hash64(changetype(key));\n } else if (isFloat()) {\n if (sizeof() == 4) return hash32(reinterpret(f32(key)));\n if (sizeof() == 8) return hash64(reinterpret(f64(key)));\n } else {\n if (sizeof() == 1) return hash8 (u32(key));\n if (sizeof() == 2) return hash16(u32(key));\n if (sizeof() == 4) return hash32(u32(key));\n if (sizeof() == 8) return hash64(u64(key));\n }\n return unreachable();\n}\n\n// FNV-1a 32-bit as a starting point, see: http://isthe.com/chongo/tech/comp/fnv/\n\n// @ts-ignore: decorator\n@inline\nconst FNV_OFFSET: u32 = 2166136261;\n\n// @ts-ignore: decorator\n@inline\nconst FNV_PRIME: u32 = 16777619;\n\nfunction hash8(key: u32): u32 {\n return (FNV_OFFSET ^ key) * FNV_PRIME;\n}\n\nfunction hash16(key: u32): u32 {\n var v = FNV_OFFSET;\n v = (v ^ ( key & 0xff)) * FNV_PRIME;\n v = (v ^ ( key >> 8 )) * FNV_PRIME;\n return v;\n}\n\nfunction hash32(key: u32): u32 {\n var v = FNV_OFFSET;\n v = (v ^ ( key & 0xff)) * FNV_PRIME;\n v = (v ^ ((key >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((key >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( key >> 24 )) * FNV_PRIME;\n return v;\n}\n\nfunction hash64(key: u64): u32 {\n var l = key;\n var h = (key >>> 32);\n var v = FNV_OFFSET;\n v = (v ^ ( l & 0xff)) * FNV_PRIME;\n v = (v ^ ((l >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((l >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( l >> 24 )) * FNV_PRIME;\n v = (v ^ ( h & 0xff)) * FNV_PRIME;\n v = (v ^ ((h >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((h >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( h >> 24 )) * FNV_PRIME;\n return v;\n}\n\nfunction hashStr(key: string): u32 {\n var v = FNV_OFFSET;\n if (key !== null) {\n for (let i: usize = 0, k: usize = key.length << 1; i < k; ++i) {\n v = (v ^ load(changetype(key) + i)) * FNV_PRIME;\n }\n }\n return v;\n}\n","util/memory":"export function memcpy(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memcpy.c\n if (ASC_SHRINK_LEVEL > 1) {\n while (n) {\n store(dest++, load(src++));\n --n;\n }\n } else {\n let w: u32, x: u32;\n\n // copy 1 byte each until src is aligned to 4 bytes\n while (n && (src & 3)) {\n store(dest++, load(src++));\n n--;\n }\n\n // if dst is aligned to 4 bytes as well, copy 4 bytes each\n if ((dest & 3) == 0) {\n while (n >= 16) {\n store(dest , load(src ));\n store(dest + 4, load(src + 4));\n store(dest + 8, load(src + 8));\n store(dest + 12, load(src + 12));\n src += 16; dest += 16; n -= 16;\n }\n if (n & 8) {\n store(dest , load(src ));\n store(dest + 4, load(src + 4));\n dest += 8; src += 8;\n }\n if (n & 4) {\n store(dest, load(src));\n dest += 4; src += 4;\n }\n if (n & 2) { // drop to 2 bytes each\n store(dest, load(src));\n dest += 2; src += 2;\n }\n if (n & 1) { // drop to 1 byte\n store(dest++, load(src++));\n }\n return;\n }\n\n // if dst is not aligned to 4 bytes, use alternating shifts to copy 4 bytes each\n // doing shifts if faster when copying enough bytes (here: 32 or more)\n if (n >= 32) {\n switch (dest & 3) {\n // known to be != 0\n case 1: {\n w = load(src);\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n n -= 3;\n while (n >= 17) {\n x = load(src + 1);\n store(dest, w >> 24 | x << 8);\n w = load(src + 5);\n store(dest + 4, x >> 24 | w << 8);\n x = load(src + 9);\n store(dest + 8, w >> 24 | x << 8);\n w = load(src + 13);\n store(dest + 12, x >> 24 | w << 8);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n case 2: {\n w = load(src);\n store(dest++, load(src++));\n store(dest++, load(src++));\n n -= 2;\n while (n >= 18) {\n x = load(src + 2);\n store(dest, w >> 16 | x << 16);\n w = load(src + 6);\n store(dest + 4, x >> 16 | w << 16);\n x = load(src + 10);\n store(dest + 8, w >> 16 | x << 16);\n w = load(src + 14);\n store(dest + 12, x >> 16 | w << 16);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n case 3: {\n w = load(src);\n store(dest++, load(src++));\n n -= 1;\n while (n >= 19) {\n x = load(src + 3);\n store(dest, w >> 8 | x << 24);\n w = load(src + 7);\n store(dest + 4, x >> 8 | w << 24);\n x = load(src + 11);\n store(dest + 8, w >> 8 | x << 24);\n w = load(src + 15);\n store(dest + 12, x >> 8 | w << 24);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n }\n }\n\n // copy remaining bytes one by one\n if (n & 16) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 8) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 4) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 2) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 1) {\n store(dest++, load(src++));\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memmove(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memmove.c\n if (dest === src) return;\n if (ASC_SHRINK_LEVEL < 1) {\n if (src + n <= dest || dest + n <= src) {\n memcpy(dest, src, n);\n return;\n }\n }\n if (dest < src) {\n if ((src & 7) == (dest & 7)) {\n while (dest & 7) {\n if (!n) return;\n --n;\n store(dest++, load(src++));\n }\n while (n >= 8) {\n store(dest, load(src));\n n -= 8;\n dest += 8;\n src += 8;\n }\n }\n while (n) {\n store(dest++, load(src++));\n --n;\n }\n } else {\n if ((src & 7) == (dest & 7)) {\n while ((dest + n) & 7) {\n if (!n) return;\n store(dest + --n, load(src + n));\n }\n while (n >= 8) {\n n -= 8;\n store(dest + n, load(src + n));\n }\n }\n while (n) {\n store(dest + --n, load(src + n));\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memset(dest: usize, c: u8, n: usize): void { // see: musl/src/string/memset\n if (ASC_SHRINK_LEVEL > 1) {\n while (n) {\n store(dest++, c);\n --n;\n }\n } else {\n // fill head and tail with minimal branching\n if (!n) return;\n store(dest, c);\n store(dest + n - 1, c);\n if (n <= 2) return;\n\n store(dest + 1, c);\n store(dest + 2, c);\n store(dest + n - 2, c);\n store(dest + n - 3, c);\n if (n <= 6) return;\n store(dest + 3, c);\n store(dest + n - 4, c);\n if (n <= 8) return;\n\n // advance pointer to align it at 4-byte boundary\n let k: usize = -dest & 3;\n dest += k;\n n -= k;\n n &= -4;\n\n let c32: u32 = -1 / 255 * c;\n\n // fill head/tail up to 28 bytes each in preparation\n store(dest, c32);\n store(dest + n - 4, c32);\n if (n <= 8) return;\n store(dest + 4, c32);\n store(dest + 8, c32);\n store(dest + n - 12, c32);\n store(dest + n - 8, c32);\n if (n <= 24) return;\n store(dest + 12, c32);\n store(dest + 16, c32);\n store(dest + 20, c32);\n store(dest + 24, c32);\n store(dest + n - 28, c32);\n store(dest + n - 24, c32);\n store(dest + n - 20, c32);\n store(dest + n - 16, c32);\n\n // align to a multiple of 8\n k = 24 + (dest & 4);\n dest += k;\n n -= k;\n\n // copy 32 bytes each\n let c64: u64 = c32 | (c32 << 32);\n while (n >= 32) {\n store(dest, c64);\n store(dest + 8, c64);\n store(dest + 16, c64);\n store(dest + 24, c64);\n n -= 32;\n dest += 32;\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memcmp(vl: usize, vr: usize, n: usize): i32 { // see: musl/src/string/memcmp.c\n if (vl == vr) return 0;\n while (n != 0 && load(vl) == load(vr)) {\n n--; vl++; vr++;\n }\n return n ? load(vl) - load(vr) : 0;\n}\n","util/number":'/// \n\nimport { idof } from "../builtins";\nimport { CharCode } from "./string";\nimport { ArrayBufferView } from "../arraybuffer";\n\n// @ts-ignore: decorator\n@inline\nexport const MAX_DOUBLE_LENGTH = 28;\n\n// @ts-ignore: decorator\n@lazy @inline\nconst POWERS10: u32[] = [\n 1,\n 10,\n 100,\n 1000,\n 10000,\n 100000,\n 1000000,\n 10000000,\n 100000000,\n 1000000000\n];\n\n/*\n Lookup table for pairwise char codes in range [0-99]\n\n "00", "01", "02", "03", "04", "05", "06", "07", "08", "09",\n "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",\n "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",\n "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",\n "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",\n "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",\n "60", "61", "62", "63", "64", "65", "66", "67", "68", "69",\n "70", "71", "72", "73", "74", "75", "76", "77", "78", "79",\n "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",\n "90", "91", "92", "93", "94", "95", "96", "97", "98", "99"\n*/\n// @ts-ignore: decorator\n@lazy @inline\nconst DIGITS: u32[] = [\n 0x00300030, 0x00310030, 0x00320030, 0x00330030, 0x00340030,\n 0x00350030, 0x00360030, 0x00370030, 0x00380030, 0x00390030,\n 0x00300031, 0x00310031, 0x00320031, 0x00330031, 0x00340031,\n 0x00350031, 0x00360031, 0x00370031, 0x00380031, 0x00390031,\n 0x00300032, 0x00310032, 0x00320032, 0x00330032, 0x00340032,\n 0x00350032, 0x00360032, 0x00370032, 0x00380032, 0x00390032,\n 0x00300033, 0x00310033, 0x00320033, 0x00330033, 0x00340033,\n 0x00350033, 0x00360033, 0x00370033, 0x00380033, 0x00390033,\n 0x00300034, 0x00310034, 0x00320034, 0x00330034, 0x00340034,\n 0x00350034, 0x00360034, 0x00370034, 0x00380034, 0x00390034,\n 0x00300035, 0x00310035, 0x00320035, 0x00330035, 0x00340035,\n 0x00350035, 0x00360035, 0x00370035, 0x00380035, 0x00390035,\n 0x00300036, 0x00310036, 0x00320036, 0x00330036, 0x00340036,\n 0x00350036, 0x00360036, 0x00370036, 0x00380036, 0x00390036,\n 0x00300037, 0x00310037, 0x00320037, 0x00330037, 0x00340037,\n 0x00350037, 0x00360037, 0x00370037, 0x00380037, 0x00390037,\n 0x00300038, 0x00310038, 0x00320038, 0x00330038, 0x00340038,\n 0x00350038, 0x00360038, 0x00370038, 0x00380038, 0x00390038,\n 0x00300039, 0x00310039, 0x00320039, 0x00330039, 0x00340039,\n 0x00350039, 0x00360039, 0x00370039, 0x00380039, 0x00390039\n];\n\n// @ts-ignore: decorator\n@lazy @inline\nconst EXP_POWERS: i16[] = [\n -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980,\n -954, -927, -901, -874, -847, -821, -794, -768, -741, -715,\n -688, -661, -635, -608, -582, -555, -529, -502, -475, -449,\n -422, -396, -369, -343, -316, -289, -263, -236, -210, -183,\n -157, -130, -103, -77, -50, -24, 3, 30, 56, 83,\n 109, 136, 162, 189, 216, 242, 269, 295, 322, 348,\n 375, 402, 428, 455, 481, 508, 534, 561, 588, 614,\n 641, 667, 694, 720, 747, 774, 800, 827, 853, 880,\n 907, 933, 960, 986, 1013, 1039, 1066\n];\n\n// 1e-348, 1e-340, ..., 1e340\n// @ts-ignore: decorator\n@lazy @inline\nconst FRC_POWERS: u64[] = [\n 0xFA8FD5A0081C0288, 0xBAAEE17FA23EBF76, 0x8B16FB203055AC76, 0xCF42894A5DCE35EA,\n 0x9A6BB0AA55653B2D, 0xE61ACF033D1A45DF, 0xAB70FE17C79AC6CA, 0xFF77B1FCBEBCDC4F,\n 0xBE5691EF416BD60C, 0x8DD01FAD907FFC3C, 0xD3515C2831559A83, 0x9D71AC8FADA6C9B5,\n 0xEA9C227723EE8BCB, 0xAECC49914078536D, 0x823C12795DB6CE57, 0xC21094364DFB5637,\n 0x9096EA6F3848984F, 0xD77485CB25823AC7, 0xA086CFCD97BF97F4, 0xEF340A98172AACE5,\n 0xB23867FB2A35B28E, 0x84C8D4DFD2C63F3B, 0xC5DD44271AD3CDBA, 0x936B9FCEBB25C996,\n 0xDBAC6C247D62A584, 0xA3AB66580D5FDAF6, 0xF3E2F893DEC3F126, 0xB5B5ADA8AAFF80B8,\n 0x87625F056C7C4A8B, 0xC9BCFF6034C13053, 0x964E858C91BA2655, 0xDFF9772470297EBD,\n 0xA6DFBD9FB8E5B88F, 0xF8A95FCF88747D94, 0xB94470938FA89BCF, 0x8A08F0F8BF0F156B,\n 0xCDB02555653131B6, 0x993FE2C6D07B7FAC, 0xE45C10C42A2B3B06, 0xAA242499697392D3,\n 0xFD87B5F28300CA0E, 0xBCE5086492111AEB, 0x8CBCCC096F5088CC, 0xD1B71758E219652C,\n 0x9C40000000000000, 0xE8D4A51000000000, 0xAD78EBC5AC620000, 0x813F3978F8940984,\n 0xC097CE7BC90715B3, 0x8F7E32CE7BEA5C70, 0xD5D238A4ABE98068, 0x9F4F2726179A2245,\n 0xED63A231D4C4FB27, 0xB0DE65388CC8ADA8, 0x83C7088E1AAB65DB, 0xC45D1DF942711D9A,\n 0x924D692CA61BE758, 0xDA01EE641A708DEA, 0xA26DA3999AEF774A, 0xF209787BB47D6B85,\n 0xB454E4A179DD1877, 0x865B86925B9BC5C2, 0xC83553C5C8965D3D, 0x952AB45CFA97A0B3,\n 0xDE469FBD99A05FE3, 0xA59BC234DB398C25, 0xF6C69A72A3989F5C, 0xB7DCBF5354E9BECE,\n 0x88FCF317F22241E2, 0xCC20CE9BD35C78A5, 0x98165AF37B2153DF, 0xE2A0B5DC971F303A,\n 0xA8D9D1535CE3B396, 0xFB9B7CD9A4A7443C, 0xBB764C4CA7A44410, 0x8BAB8EEFB6409C1A,\n 0xD01FEF10A657842C, 0x9B10A4E5E9913129, 0xE7109BFBA19C0C9D, 0xAC2820D9623BF429,\n 0x80444B5E7AA7CF85, 0xBF21E44003ACDD2D, 0x8E679C2F5E44FF8F, 0xD433179D9C8CB841,\n 0x9E19DB92B4E31BA9, 0xEB96BF6EBADF77D9, 0xAF87023B9BF0EE6B\n];\n\n// Count number of decimals for u32 values\n// In our case input value always non-zero so we can simplify some parts\nexport function decimalCount32(value: u32): u32 {\n if (value < 100000) {\n if (value < 100) {\n return select(1, 2, value < 10);\n } else {\n let m = select(4, 5, value < 10000);\n return select(3, m, value < 1000);\n }\n } else {\n if (value < 10000000) {\n return select(6, 7, value < 1000000);\n } else {\n let m = select(9, 10, value < 1000000000);\n return select(8, m, value < 100000000);\n }\n }\n}\n\n// Count number of decimals for u64 values\n// In our case input value always greater than 2^32-1 so we can skip some parts\nexport function decimalCount64(value: u64): u32 {\n if (value < 1000000000000000) {\n if (value < 1000000000000) {\n return select(11, 12, value < 100000000000);\n } else {\n let m = select(14, 15, value < 100000000000000);\n return select(13, m, value < 10000000000000);\n }\n } else {\n if (value < 100000000000000000) {\n return select(16, 17, value < 10000000000000000);\n } else {\n let m = select(19, 20, value < 10000000000000000000);\n return select(18, m, value < 1000000000000000000);\n }\n }\n}\n\nfunction utoa32_lut(buffer: usize, num: u32, offset: usize): void {\n var lut = changetype(DIGITS).dataStart;\n while (num >= 10000) {\n // in most VMs i32/u32 div and modulo by constant can be shared and simplificate\n let t = num / 10000;\n let r = num % 10000;\n num = t;\n\n let d1 = r / 100;\n let d2 = r % 100;\n\n let digits1 = load(lut + (d1 << alignof()));\n let digits2 = load(lut + (d2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n }\n\n if (num >= 100) {\n let t = num / 100;\n let d1 = num % 100;\n num = t;\n offset -= 2;\n let digits = load(lut + (d1 << alignof()));\n store(buffer + (offset << 1), digits);\n }\n\n if (num >= 10) {\n offset -= 2;\n let digits = load(lut + (num << alignof()));\n store(buffer + (offset << 1), digits);\n } else {\n offset -= 1;\n let digit = CharCode._0 + num;\n store(buffer + (offset << 1), digit);\n }\n}\n\nfunction utoa64_lut(buffer: usize, num: u64, offset: usize): void {\n var lut = changetype(DIGITS).dataStart;\n while (num >= 100000000) {\n let t = num / 100000000;\n let r = (num - t * 100000000);\n num = t;\n\n let b = r / 10000;\n let c = r % 10000;\n\n let b1 = b / 100;\n let b2 = b % 100;\n let c1 = c / 100;\n let c2 = c % 100;\n\n let digits1 = load(lut + (c1 << alignof()));\n let digits2 = load(lut + (c2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n\n digits1 = load(lut + (b1 << alignof()));\n digits2 = load(lut + (b2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n }\n\n utoa32_lut(buffer, num, offset);\n}\n\nfunction utoa_simple(buffer: usize, num: T, offset: usize): void {\n do {\n let t = num / 10;\n let r = (num % 10);\n num = changetype(t);\n offset -= 1;\n store(buffer + (offset << 1), CharCode._0 + r);\n } while (num);\n}\n\n// @ts-ignore: decorator\n@inline\nexport function utoa32_core(buffer: usize, num: u32, offset: u32): void {\n if (ASC_SHRINK_LEVEL >= 1) {\n utoa_simple(buffer, num, offset);\n } else {\n utoa32_lut(buffer, num, offset);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function utoa64_core(buffer: usize, num: u64, offset: u32): void {\n if (ASC_SHRINK_LEVEL >= 1) {\n utoa_simple(buffer, num, offset);\n } else {\n utoa64_lut(buffer, num, offset);\n }\n}\n\nexport function utoa32(value: u32): String {\n if (!value) return "0";\n\n var decimals = decimalCount32(value);\n var out = __alloc(decimals << 1, idof());\n\n utoa32_core(out, value, decimals);\n return changetype(out); // retains\n}\n\nexport function itoa32(value: i32): String {\n if (!value) return "0";\n\n var sign = value < 0;\n if (sign) value = -value;\n\n var decimals = decimalCount32(value) + u32(sign);\n var out = __alloc(decimals << 1, idof());\n\n utoa32_core(out, value, decimals);\n if (sign) store(out, CharCode.MINUS);\n return changetype(out); // retains\n}\n\nexport function utoa64(value: u64): String {\n if (!value) return "0";\n\n var out: usize;\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n let decimals = decimalCount32(val32);\n out = __alloc(decimals << 1, idof());\n utoa32_core(out, val32, decimals);\n } else {\n let decimals = decimalCount64(value);\n out = __alloc(decimals << 1, idof());\n utoa64_core(out, value, decimals);\n }\n return changetype(out); // retains\n}\n\nexport function itoa64(value: i64): String {\n if (!value) return "0";\n\n var sign = value < 0;\n if (sign) value = -value;\n\n var out: usize;\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n let decimals = decimalCount32(val32) + u32(sign);\n out = __alloc(decimals << 1, idof());\n utoa32_core(out, val32, decimals);\n } else {\n let decimals = decimalCount64(value) + u32(sign);\n out = __alloc(decimals << 1, idof());\n utoa64_core(out, value, decimals);\n }\n if (sign) store(out, CharCode.MINUS);\n\n return changetype(out); // retains\n}\n\nexport function itoa(value: T): String {\n if (!isInteger()) ERROR("integer type expected");\n if (isSigned()) {\n if (sizeof() <= 4) {\n return itoa32(value);\n } else {\n return itoa64(value);\n }\n } else {\n if (sizeof() <= 4) {\n return utoa32(value);\n } else {\n return utoa64(value);\n }\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar _K: i32 = 0;\n\n// // @ts-ignore: decorator\n// @lazy\n// var _frc: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _exp: i32 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_minus: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_plus: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_pow: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _exp_pow: i32 = 0;\n\n// @ts-ignore: decorator\n@inline\nfunction umul64f(u: u64, v: u64): u64 {\n var u0 = u & 0xFFFFFFFF;\n var v0 = v & 0xFFFFFFFF;\n\n var u1 = u >> 32;\n var v1 = v >> 32;\n\n var l = u0 * v0;\n var t = u1 * v0 + (l >> 32);\n var w = u0 * v1 + (t & 0xFFFFFFFF);\n\n w += 0x7FFFFFFF; // rounding\n\n t >>= 32;\n w >>= 32;\n\n return u1 * v1 + t + w;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction umul64e(e1: i32, e2: i32): i32 {\n return e1 + e2 + 64; // where 64 is significand size\n}\n\n// @ts-ignore: decorator\n@inline\nfunction normalizedBoundaries(f: u64, e: i32): void {\n var frc = (f << 1) + 1;\n var exp = e - 1;\n var off = clz(frc);\n frc <<= off;\n exp -= off;\n\n var m = 1 + i32(f == 0x0010000000000000);\n\n _frc_plus = frc;\n _frc_minus = ((f << m) - 1) << e - m - exp;\n _exp = exp;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction grisuRound(buffer: usize, len: i32, delta: u64, rest: u64, ten_kappa: u64, wp_w: u64): void {\n var lastp = buffer + ((len - 1) << 1);\n var digit = load(lastp);\n while (\n rest < wp_w &&\n delta - rest >= ten_kappa && (\n rest + ten_kappa < wp_w ||\n wp_w - rest > rest + ten_kappa - wp_w\n )\n ) {\n --digit;\n rest += ten_kappa;\n }\n store(lastp, digit);\n}\n\n// @ts-ignore: decorator\n@inline\nfunction getCachedPower(minExp: i32): void {\n const c = reinterpret(0x3FD34413509F79FE); // 1 / lg(10) = 0.30102999566398114\n var dk = (-61 - minExp) * c + 347;\t // dk must be positive, so can do ceiling in positive\n var k = dk;\n k += i32(k != dk); // conversion with ceil\n\n var index = (k >> 3) + 1;\n _K = 348 - (index << 3);\t// decimal exponent no need lookup table\n _frc_pow = unchecked(FRC_POWERS[index]);\n _exp_pow = unchecked(EXP_POWERS[index]);\n}\n\n// @ts-ignore: decorator\n@inline\nfunction grisu2(value: f64, buffer: usize, sign: i32): i32 {\n\n // frexp routine\n var uv = reinterpret(value);\n var exp = ((uv & 0x7FF0000000000000) >>> 52);\n var sid = uv & 0x000FFFFFFFFFFFFF;\n var frc = (u64(exp != 0) << 52) + sid;\n exp = select(exp, 1, exp != 0) - (0x3FF + 52);\n\n normalizedBoundaries(frc, exp);\n getCachedPower(_exp);\n\n // normalize\n var off = clz(frc);\n frc <<= off;\n exp -= off;\n\n var frc_pow = _frc_pow;\n var exp_pow = _exp_pow;\n\n var w_frc = umul64f(frc, frc_pow);\n var w_exp = umul64e(exp, exp_pow);\n\n var wp_frc = umul64f(_frc_plus, frc_pow) - 1;\n var wp_exp = umul64e(_exp, exp_pow);\n\n var wm_frc = umul64f(_frc_minus, frc_pow) + 1;\n var delta = wp_frc - wm_frc;\n\n return genDigits(buffer, w_frc, w_exp, wp_frc, wp_exp, delta, sign);\n}\n\nfunction genDigits(buffer: usize, w_frc: u64, w_exp: i32, mp_frc: u64, mp_exp: i32, delta: u64, sign: i32): i32 {\n var one_exp = -mp_exp;\n var one_frc = (1) << one_exp;\n var mask = one_frc - 1;\n\n var wp_w_frc = mp_frc - w_frc;\n var wp_w_exp = mp_exp;\n\n var p1 = (mp_frc >> one_exp);\n var p2 = mp_frc & mask;\n\n var kappa = decimalCount32(p1);\n var len = sign;\n\n var lut = changetype(POWERS10).dataStart;\n\n while (kappa > 0) {\n let d: u32;\n switch (kappa) {\n case 10: { d = p1 / 1000000000; p1 %= 1000000000; break; }\n case 9: { d = p1 / 100000000; p1 %= 100000000; break; }\n case 8: { d = p1 / 10000000; p1 %= 10000000; break; }\n case 7: { d = p1 / 1000000; p1 %= 1000000; break; }\n case 6: { d = p1 / 100000; p1 %= 100000; break; }\n case 5: { d = p1 / 10000; p1 %= 10000; break; }\n case 4: { d = p1 / 1000; p1 %= 1000; break; }\n case 3: { d = p1 / 100; p1 %= 100; break; }\n case 2: { d = p1 / 10; p1 %= 10; break; }\n case 1: { d = p1; p1 = 0; break; }\n default: { d = 0; break; }\n }\n\n if (d | len) store(buffer + (len++ << 1), CharCode._0 + d);\n\n --kappa;\n let tmp = ((p1) << one_exp) + p2;\n if (tmp <= delta) {\n _K += kappa;\n grisuRound(buffer, len, delta, tmp, load(lut + (kappa << alignof())) << one_exp, wp_w_frc);\n return len;\n }\n }\n\n while (1) {\n p2 *= 10;\n delta *= 10;\n\n let d = p2 >> one_exp;\n if (d | len) store(buffer + (len++ << 1), CharCode._0 + d);\n\n p2 &= mask;\n --kappa;\n if (p2 < delta) {\n _K += kappa;\n wp_w_frc *= load(lut + (-kappa << alignof()));\n grisuRound(buffer, len, delta, p2, one_frc, wp_w_frc);\n return len;\n }\n }\n\n return len;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction genExponent(buffer: usize, k: i32): i32 {\n var sign = k < 0;\n if (sign) k = -k;\n var decimals = decimalCount32(k) + 1;\n utoa32_core(buffer, k, decimals);\n store(buffer, select(CharCode.MINUS, CharCode.PLUS, sign));\n return decimals;\n}\n\nfunction prettify(buffer: usize, length: i32, k: i32): i32 {\n if (!k) {\n store(buffer + (length << 1), CharCode.DOT | (CharCode._0 << 16));\n return length + 2;\n }\n\n var kk = length + k;\n if (length <= kk && kk <= 21) {\n // 1234e7 -> 12340000000\n for (let i = length; i < kk; ++i) {\n store(buffer + (i << 1), CharCode._0);\n }\n store(buffer + (kk << 1), CharCode.DOT | (CharCode._0 << 16));\n return kk + 2;\n } else if (kk > 0 && kk <= 21) {\n // 1234e-2 -> 12.34\n let ptr = buffer + (kk << 1);\n memory.copy(\n ptr + 2,\n ptr,\n -k << 1\n );\n store(buffer + (kk << 1), CharCode.DOT);\n return length + 1;\n } else if (-6 < kk && kk <= 0) {\n // 1234e-6 -> 0.001234\n let offset = 2 - kk;\n memory.copy(\n buffer + (offset << 1),\n buffer,\n length << 1\n );\n store(buffer, CharCode._0 | (CharCode.DOT << 16));\n for (let i = 2; i < offset; ++i) {\n store(buffer + (i << 1), CharCode._0);\n }\n return length + offset;\n } else if (length == 1) {\n // 1e30\n store(buffer, CharCode.e, 2);\n length = genExponent(buffer + 4, kk - 1);\n return length + 2;\n } else {\n let len = length << 1;\n memory.copy(\n buffer + 4,\n buffer + 2,\n len - 2\n );\n store(buffer, CharCode.DOT, 2);\n store(buffer + len, CharCode.e, 2);\n length += genExponent(buffer + len + 4, kk - 1);\n return length + 2;\n }\n}\n\nexport function dtoa_core(buffer: usize, value: f64): i32 {\n var sign = i32(value < 0);\n if (sign) {\n value = -value;\n store(buffer, CharCode.MINUS);\n }\n // assert(value > 0 && value <= 1.7976931348623157e308);\n var len = grisu2(value, buffer, sign);\n len = prettify(buffer + (sign << 1), len - sign, _K);\n return len + sign;\n}\n\nexport function dtoa(value: f64): String {\n if (value == 0) return "0.0";\n if (!isFinite(value)) {\n if (isNaN(value)) return "NaN";\n return select("-Infinity", "Infinity", value < 0);\n }\n var buffer = __alloc(MAX_DOUBLE_LENGTH << 1, idof());\n var length = dtoa_core(buffer, value);\n if (length == MAX_DOUBLE_LENGTH) return changetype(buffer);\n var result = changetype(buffer).substring(0, length);\n __free(buffer);\n return result;\n}\n\nexport function itoa_stream(buffer: usize, offset: usize, value: T): u32 {\n buffer += (offset << 1);\n if (!value) {\n store(buffer, CharCode._0);\n return 1;\n }\n var decimals: u32 = 0;\n if (isSigned()) {\n let sign = i32(value < 0);\n if (sign) value = changetype(-value);\n if (sizeof() <= 4) {\n decimals = decimalCount32(value) + sign;\n utoa32_core(buffer, value, decimals);\n } else {\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n decimals = decimalCount32(val32) + sign;\n utoa32_core(buffer, val32, decimals);\n } else {\n decimals = decimalCount64(value) + sign;\n utoa64_core(buffer, value, decimals);\n }\n }\n if (sign) store(buffer, CharCode.MINUS);\n } else {\n if (sizeof() <= 4) {\n decimals = decimalCount32(value);\n utoa32_core(buffer, value, decimals);\n } else {\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n decimals = decimalCount32(val32);\n utoa32_core(buffer, val32, decimals);\n } else {\n decimals = decimalCount64(value);\n utoa64_core(buffer, value, decimals);\n }\n }\n }\n return decimals;\n}\n\nexport function dtoa_stream(buffer: usize, offset: usize, value: f64): u32 {\n buffer += (offset << 1);\n if (value == 0.0) {\n store(buffer, CharCode._0);\n store(buffer, CharCode.DOT, 2);\n store(buffer, CharCode._0, 4);\n return 3;\n }\n if (!isFinite(value)) {\n if (isNaN(value)) {\n store(buffer, CharCode.N);\n store(buffer, CharCode.a, 2);\n store(buffer, CharCode.N, 4);\n return 3;\n } else {\n let sign = i32(value < 0);\n let len = 8 + sign;\n memory.copy(buffer, changetype(select("-Infinity", "Infinity", sign)), len << 1);\n return len;\n }\n }\n return dtoa_core(buffer, value);\n}\n',"util/sort":'import { compareImpl } from "./string";\n\n// @ts-ignore: decorator\n@inline\nexport function COMPARATOR(): (a: T, b: T) => i32 {\n if (isInteger()) {\n if (isSigned() && sizeof() <= 4) {\n return (a: T, b: T): i32 => (i32(a) - i32(b));\n } else {\n return (a: T, b: T): i32 => (i32(a > b) - i32(a < b));\n }\n } else if (isFloat()) {\n if (sizeof() == 4) {\n return (a: T, b: T): i32 => {\n var ia = reinterpret(f32(a));\n var ib = reinterpret(f32(b));\n ia ^= (ia >> 31) >>> 1;\n ib ^= (ib >> 31) >>> 1;\n return i32(ia > ib) - i32(ia < ib);\n };\n } else {\n return (a: T, b: T): i32 => {\n var ia = reinterpret(f64(a));\n var ib = reinterpret(f64(b));\n ia ^= (ia >> 63) >>> 1;\n ib ^= (ib >> 63) >>> 1;\n return i32(ia > ib) - i32(ia < ib);\n };\n }\n } else if (isString()) {\n return (a: T, b: T): i32 => {\n if (a === b || a === null || b === null) return 0;\n var alen = changetype(a).length;\n var blen = changetype(b).length;\n if (!alen && !blen) return 0;\n if (!alen) return -1;\n if (!blen) return 1;\n return compareImpl(changetype(a), 0, changetype(b), 0, min(alen, blen));\n };\n } else {\n return (a: T, b: T): i32 => (i32(a > b) - i32(a < b));\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function SORT(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n if (isReference()) {\n // TODO replace this to faster stable sort (TimSort) when it implemented\n insertionSort(dataStart, length, comparator);\n } else {\n if (length < 256) {\n insertionSort(dataStart, length, comparator);\n } else {\n weakHeapSort(dataStart, length, comparator);\n }\n }\n}\n\nfunction insertionSort(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n for (let i = 0; i < length; i++) {\n let a: T = load(dataStart + (i << alignof())); // a = arr[i]\n let j = i - 1;\n while (j >= 0) {\n let b: T = load(dataStart + (j << alignof())); // b = arr[j]\n if (comparator(a, b) < 0) {\n store(dataStart + ((j-- + 1) << alignof()), b); // arr[j + 1] = b\n } else break;\n }\n store(dataStart + ((j + 1) << alignof()), a); // arr[j + 1] = a\n }\n}\n\nfunction weakHeapSort(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n const shift32 = alignof();\n\n var bitsetSize = (length + 31) >> 5 << shift32;\n var bitset = __alloc(bitsetSize, 0); // indexed in 32-bit chunks below\n memory.fill(bitset, 0, bitsetSize);\n\n // see: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf\n\n for (let i = length - 1; i > 0; i--) {\n let j = i;\n while ((j & 1) == (load(bitset + (j >> 6 << shift32)) >> (j >> 1 & 31) & 1)) j >>= 1;\n\n let p = j >> 1;\n let a: T = load(dataStart + (p << alignof())); // a = arr[p]\n let b: T = load(dataStart + (i << alignof())); // b = arr[i]\n if (comparator(a, b) < 0) {\n store(\n bitset + (i >> 5 << shift32),\n load(bitset + (i >> 5 << shift32)) ^ (1 << (i & 31))\n );\n store(dataStart + (i << alignof()), a); // arr[i] = a\n store(dataStart + (p << alignof()), b); // arr[p] = b\n }\n }\n\n for (let i = length - 1; i >= 2; i--) {\n let a: T = load(dataStart); // a = arr[0]\n store(dataStart, load(dataStart + (i << alignof()))); // arr[0] = arr[i]\n store(dataStart + (i << alignof()), a); // arr[i] = a\n\n let x = 1, y: i32;\n while ((y = (x << 1) + ((load(bitset + (x >> 5 << shift32)) >> (x & 31)) & 1)) < i) x = y;\n\n while (x > 0) {\n a = load(dataStart); // a = arr[0]\n let b: T = load(dataStart + (x << alignof())); // b = arr[x]\n\n if (comparator(a, b) < 0) {\n store(\n bitset + (x >> 5 << shift32),\n load(bitset + (x >> 5 << shift32)) ^ (1 << (x & 31))\n );\n store(dataStart + (x << alignof()), a); // arr[x] = a\n store(dataStart, b); // arr[0] = b\n }\n x >>= 1;\n }\n }\n\n __free(bitset);\n\n var t: T = load(dataStart, sizeof()); // t = arr[1]\n store(dataStart, load(dataStart), sizeof()); // arr[1] = arr[0]\n store(dataStart, t); // arr[0] = t\n}\n',"util/string":"export function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 {\n var result: i32 = 0;\n var ptr1 = changetype(str1) + (index1 << 1);\n var ptr2 = changetype(str2) + (index2 << 1);\n while (len && !(result = load(ptr1) - load(ptr2))) {\n --len, ptr1 += 2, ptr2 += 2;\n }\n return result;\n}\n\n// @ts-ignore: decorator\n@inline\nexport const enum CharCode {\n PLUS = 0x2B,\n MINUS = 0x2D,\n DOT = 0x2E,\n _0 = 0x30,\n _1 = 0x31,\n _2 = 0x32,\n _3 = 0x33,\n _4 = 0x34,\n _5 = 0x35,\n _6 = 0x36,\n _7 = 0x37,\n _8 = 0x38,\n _9 = 0x39,\n A = 0x41,\n B = 0x42,\n E = 0x45,\n N = 0x4E,\n O = 0x4F,\n X = 0x58,\n Z = 0x5a,\n a = 0x61,\n b = 0x62,\n e = 0x65,\n n = 0x6E,\n o = 0x6F,\n x = 0x78,\n z = 0x7A\n}\n\nexport function isWhiteSpaceOrLineTerminator(c: u16): bool {\n switch (c) {\n case 9: // \n case 10: // \n case 13: // \n case 11: // \n case 12: // \n case 32: // \n case 160: // \n case 8232: // \n case 8233: // \n case 65279: return true; // \n default: return false;\n }\n}\n\n/** Parses a string to an integer (usually), using the specified radix. */\nexport function parse(str: string, radix: i32 = 0): T {\n var len: i32 = str.length;\n // @ts-ignore: cast\n if (!len) return NaN;\n\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr);\n\n // determine sign\n var sign: T;\n if (code == CharCode.MINUS) {\n // @ts-ignore: cast\n if (!--len) return NaN;\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = -1;\n } else if (code == CharCode.PLUS) {\n // @ts-ignore: cast\n if (!--len) return NaN;\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = 1;\n } else {\n // @ts-ignore: type\n sign = 1;\n }\n\n // determine radix\n if (!radix) {\n if (code == CharCode._0 && len > 2) {\n switch (load(ptr + 2)) {\n case CharCode.B:\n case CharCode.b: {\n ptr += 4; len -= 2;\n radix = 2;\n break;\n }\n case CharCode.O:\n case CharCode.o: {\n ptr += 4; len -= 2;\n radix = 8;\n break;\n }\n case CharCode.X:\n case CharCode.x: {\n ptr += 4; len -= 2;\n radix = 16;\n break;\n }\n default: radix = 10;\n }\n } else radix = 10;\n } else if (radix < 2 || radix > 36) {\n // @ts-ignore: cast\n return NaN;\n }\n\n // calculate value\n // @ts-ignore: type\n var num: T = 0;\n while (len--) {\n code = load(ptr);\n if (code >= CharCode._0 && code <= CharCode._9) {\n code -= CharCode._0;\n } else if (code >= CharCode.A && code <= CharCode.Z) {\n code -= CharCode.A - 10;\n } else if (code >= CharCode.a && code <= CharCode.z) {\n code -= CharCode.a - 10;\n } else break;\n if (code >= radix) break;\n // @ts-ignore: type\n num = (num * radix) + code;\n ptr += 2;\n }\n // @ts-ignore: type\n return sign * num;\n}\n",vector:"/** Vector abstraction. */\n@sealed export class V128 {\n}\n"}):(()=>{const n=path.join(".","..","std","assembly"),e=__webpack_require__(!function(){var n=new Error("Cannot find module 'glob'");throw n.code="MODULE_NOT_FOUND",n}()).sync("**/!(*.d).ts",{cwd:n}),t={};return e.forEach(e=>t[e.replace(/\.ts$/,"")]=fs.readFileSync(path.join(n,e),"utf8")),t})(),exports.definitionFiles=exports.isBundle?Object({assembly:'/**\n * Environment definitions for compiling AssemblyScript to WebAssembly using asc.\n * @module std/assembly\n *//***/\n\n/// \n\n// Types\n\n/** An 8-bit signed integer. */\ndeclare type i8 = number;\n/** A 16-bit signed integer. */\ndeclare type i16 = number;\n/** A 32-bit signed integer. */\ndeclare type i32 = number;\n/** A 64-bit signed integer. */\ndeclare type i64 = number;\n/** A 32-bit signed integer when targeting 32-bit WebAssembly or a 64-bit signed integer when targeting 64-bit WebAssembly. */\ndeclare type isize = number;\n/** An 8-bit unsigned integer. */\ndeclare type u8 = number;\n/** A 16-bit unsigned integer. */\ndeclare type u16 = number;\n/** A 32-bit unsigned integer. */\ndeclare type u32 = number;\n/** A 64-bit unsigned integer. */\ndeclare type u64 = number;\n/** A 32-bit unsigned integer when targeting 32-bit WebAssembly or a 64-bit unsigned integer when targeting 64-bit WebAssembly. */\ndeclare type usize = number;\n/** A 1-bit unsigned integer. */\ndeclare type bool = boolean | number;\n/** A 32-bit float. */\ndeclare type f32 = number;\n/** A 64-bit float. */\ndeclare type f64 = number;\n/** A 128-bit vector. */\ndeclare type v128 = object;\n\n// Compiler hints\n\n/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */\ndeclare const ASC_TARGET: i32;\n/** Provided noAssert option. */\ndeclare const ASC_NO_ASSERT: bool;\n/** Provided memoryBase option. */\ndeclare const ASC_MEMORY_BASE: i32;\n/** Provided optimizeLevel option. */\ndeclare const ASC_OPTIMIZE_LEVEL: i32;\n/** Provided shrinkLevel option. */\ndeclare const ASC_SHRINK_LEVEL: i32;\n/** Whether the mutable global feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBAL: bool;\n/** Whether the sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n/** Whether the bulk memory feature is enabled. */\ndeclare const ASC_FEATURE_BULK_MEMORY: bool;\n/** Whether the SIMD feature is enabled. */\ndeclare const ASC_FEATURE_SIMD: bool;\n/** Whether the threads feature is enabled. */\ndeclare const ASC_FEATURE_THREADS: bool;\n\n// Builtins\n\n/** Performs the sign-agnostic count leading zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered leading if the value is zero. */\ndeclare function clz(value: T): T;\n/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered trailing if the value is zero. */\ndeclare function ctz(value: T): T;\n/** Performs the sign-agnostic count number of one bits operation on a 32-bit or 64-bit integer. */\ndeclare function popcnt(value: T): T;\n/** Performs the sign-agnostic rotate left operation on a 32-bit or 64-bit integer. */\ndeclare function rotl(value: T, shift: T): T;\n/** Performs the sign-agnostic rotate right operation on a 32-bit or 64-bit integer. */\ndeclare function rotr(value: T, shift: T): T;\n/** Computes the absolute value of an integer or float. */\ndeclare function abs(value: T): T;\n/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function max(left: T, right: T): T;\n/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function min(left: T, right: T): T;\n/** Performs the ceiling operation on a 32-bit or 64-bit float. */\ndeclare function ceil(value: T): T;\n/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */\ndeclare function copysign(x: T, y: T): T;\n/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(value: T): T;\n/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */\ndeclare function nearest(value: T): T;\n/** Reinterprets the bits of the specified value as type `T`. Valid reinterpretations are u32/i32 to/from f32 and u64/i64 to/from f64. */\ndeclare function reinterpret(value: number): T;\n/** Selects one of two pre-evaluated values depending on the condition. */\ndeclare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n/** Calculates the square root of a 32-bit or 64-bit float. */\ndeclare function sqrt(value: T): T;\n/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */\ndeclare function trunc(value: T): T;\n/** Loads a value of the specified type from memory. Equivalent to dereferncing a pointer in other languages. */\ndeclare function load(ptr: usize, immOffset?: usize, immAlign?: usize): T;\n/** Stores a value of the specified type to memory. Equivalent to dereferencing a pointer in other languages when assigning a value. */\ndeclare function store(ptr: usize, value: any, immOffset?: usize, immAlign?: usize): void;\n/** Emits an unreachable operation that results in a runtime error when executed. Both a statement and an expression of any type. */\ndeclare function unreachable(): any; // sic\n\n/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */\ndeclare const NaN: f32 | f64;\n/** Positive infinity as a 32-bit or 64-bit float depending on context. */\ndeclare const Infinity: f32 | f64;\n/** Heap base offset. */\ndeclare const HEAP_BASE: usize;\n/** Determines the byte size of the specified underlying core type. Compiles to a constant. */\ndeclare function sizeof(): usize;\n/** Determines the alignment (log2) of the specified underlying core type. Compiles to a constant. */\ndeclare function alignof(): usize;\n/** Determines the offset of the specified field within the given class type. Returns the class type\'s end offset if field name has been omitted. Compiles to a constant. */\ndeclare function offsetof(fieldName?: string): usize;\n/** Determines the unique runtime id of a class type. Compiles to a constant. */\ndeclare function idof(): u32;\n/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/\ndeclare function changetype(value: any): T;\n/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */\ndeclare function unchecked(value: T): T;\n/** Emits a `call_indirect` instruction, calling the specified function in the function table by index with the specified arguments. Does result in a runtime error if the arguments do not match the called function. */\ndeclare function call_indirect(target: Function | u32, ...args: any[]): T;\n/** Emits a `call` instruction, calling the specified function in the function table directly with the specified arguments. Function index must be a compile-time constant. */\ndeclare function call_direct(target: Function | u32, ...args: any[]): T;\n/** Instantiates a new instance of `T` using the specified constructor arguments. */\ndeclare function instantiate(...args: any[]): T;\n/** Tests if a 32-bit or 64-bit float is `NaN`. */\ndeclare function isNaN(value: T): bool;\n/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */\ndeclare function isFinite(value: T): bool;\n/** Tests if the specified type *or* expression is of an integer type and not a reference. Compiles to a constant. */\ndeclare function isInteger(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a float type. Compiles to a constant. */\ndeclare function isFloat(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a boolean type. */\ndeclare function isBoolean(value?: any): value is number;\n/** Tests if the specified type *or* expression can represent negative numbers. Compiles to a constant. */\ndeclare function isSigned(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a reference type. Compiles to a constant. */\ndeclare function isReference(value?: any): value is object | string;\n/** Tests if the specified type *or* expression can be used as a string. Compiles to a constant. */\ndeclare function isString(value?: any): value is string | String;\n/** Tests if the specified type *or* expression can be used as an array. Compiles to a constant. */\ndeclare function isArray(value?: any): value is Array;\n/** Tests if the specified type *or* expression can be used as an array like object. Compiles to a constant. */\ndeclare function isArrayLike(value?: any): value is ArrayLike;\n/** Tests if the specified type *or* expression is of a function type. Compiles to a constant. */\ndeclare function isFunction(value?: any): value is (...args: any) => any;\n/** Tests if the specified type *or* expression is of a nullable reference type. Compiles to a constant. */\ndeclare function isNullable(value?: any): bool;\n/** Tests if the specified expression resolves to a defined element. Compiles to a constant. */\ndeclare function isDefined(expression: any): bool;\n/** Tests if the specified expression evaluates to a constant value. Compiles to a constant. */\ndeclare function isConstant(expression: any): bool;\n/** Tests if the specified type *or* expression is of a managed type. Compiles to a constant. */\ndeclare function isManaged(value?: any): bool;\n/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */\ndeclare function assert(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses an integer string to a 64-bit integer. */\ndeclare function parseI64(str: string, radix?: i32): i64;\n/** Parses a string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n/** Returns the 64-bit floating-point remainder of `x/y`. */\ndeclare function fmod(x: f64, y: f64): f64;\n/** Returns the 32-bit floating-point remainder of `x/y`. */\ndeclare function fmodf(x: f32, y: f32): f32;\n\n/** Atomic operations. */\ndeclare namespace atomic {\n /** Atomically loads an integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): T;\n /** Atomically stores an integer value to memory. */\n export function store(offset: usize, value: T, immOffset?: usize): void;\n /** Atomically adds an integer value in memory. */\n export function add(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically subtracts an integer value in memory. */\n export function sub(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise AND operation on an integer value in memory. */\n export function and(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise OR operation on an integer value in memory. */\n export function or(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise XOR operation on an integer value in memory. */\n export function xor(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically exchanges an integer value in memory. */\n export function xchg(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically compares and exchanges an integer value in memory if the condition is met. */\n export function cmpxchg(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;\n /** Performs a wait operation on an address in memory suspending this agent if the integer condition is met. */\n export function wait(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;\n /** Performs a notify operation on an address in memory waking up suspended agents. */\n export function notify(ptr: usize, count: i32): i32;\n}\n\n/** Describes the result of an atomic wait operation. */\ndeclare enum AtomicWaitResult {\n /** Woken by another agent. */\n OK,\n /** Loaded value did not match the expected value. */\n NOT_EQUAL,\n /** Not woken before the timeout expired. */\n TIMED_OUT\n}\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: any): i8;\ndeclare namespace i8 {\n /** Smallest representable value. */\n export const MIN_VALUE: i8;\n /** Largest representable value. */\n export const MAX_VALUE: i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: any): i8;\ndeclare namespace i16 {\n /** Smallest representable value. */\n export const MIN_VALUE: i16;\n /** Largest representable value. */\n export const MAX_VALUE: i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: any): i32;\ndeclare namespace i32 {\n /** Smallest representable value. */\n export const MIN_VALUE: i32;\n /** Largest representable value. */\n export const MAX_VALUE: i32;\n /** Loads an 8-bit signed integer value from memory and returns it as a 32-bit integer. */\n export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 16-bit signed integer value from memory and returns it as a 32-bit integer. */\n export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 32-bit integer value from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory. */\n export function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Atomic 32-bit integer operations. */\n export namespace atomic {\n /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize): i32;\n /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize): i32;\n /** Atomically loads a 32-bit integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): i32;\n /** Atomically stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory. */\n export function store(offset: usize, value: i32, immOffset?: usize): void;\n /** Performs a wait operation on a 32-bit integer value in memory suspending this agent if the condition is met. */\n export function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;\n /** Atomic 32-bit integer read-modify-write operations on 8-bit values. */\n export namespace rmw8 {\n /** Atomically adds an 8-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation an 8-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation an 8-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation an 8-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n /** Atomic 32-bit integer read-modify-write operations on 16-bit values. */\n export namespace rmw16 {\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 16-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 16-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 16-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n /** Atomic 32-bit integer read-modify-write operations. */\n export namespace rmw {\n /** Atomically adds a 32-bit integer value in memory. */\n export function add(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts a 32-bit integer value in memory. */\n export function sub(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 32-bit integer value in memory. */\n export function and(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 32-bit integer value in memory. */\n export function or(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 32-bit integer value in memory. */\n export function xor(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 32-bit integer value in memory. */\n export function xchg(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges a 32-bit integer value in memory if the condition is met. */\n export function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n }\n}\n/** Converts any other numeric value to a 64-bit signed integer. */\ndeclare function i64(value: any): i64;\ndeclare namespace i64 {\n /** Smallest representable value. */\n export const MIN_VALUE: i64;\n /** Largest representable value. */\n export const MAX_VALUE: i64;\n /** Loads an 8-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 16-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 32-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 64-bit unsigned integer value from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory as a 32-bit integer. */\n export function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory. */\n export function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Atomic 64-bit integer operations. */\n export namespace atomic {\n /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load32_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 64-bit integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): i64;\n /** Atomically stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory as a 32-bit integer. */\n export function store32(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory. */\n export function store(offset: usize, value: i64, immOffset?: usize): void;\n /** Performs a wait operation on a 64-bit integer value in memory suspending this agent if the condition is met. */\n export function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;\n /** Atomic 64-bit integer read-modify-write operations on 8-bit values. */\n export namespace rmw8 {\n /** Atomically adds an 8-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on an 8-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on an 8-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on an 8-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations on 16-bit values. */\n export namespace rmw16 {\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 16-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 16-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 16-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 16-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations on 32-bit values. */\n export namespace rmw32 {\n /** Atomically adds a 32-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 32-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 32-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 32-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 32-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 32-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 32-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations. */\n export namespace rmw {\n /** Atomically adds a 64-bit integer value in memory. */\n export function add(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 64-bit integer value in memory. */\n export function sub(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 64-bit integer value in memory. */\n export function and(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 64-bit integer value in memory. */\n export function or(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 64-bit integer value in memory. */\n export function xor(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 64-bit integer value in memory. */\n export function xchg(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 64-bit integer value in memory if the condition is met. */\n export function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n }\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare var isize: typeof i32 | typeof i64;\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: any): i8;\ndeclare namespace u8 {\n /** Smallest representable value. */\n export const MIN_VALUE: u8;\n /** Largest representable value. */\n export const MAX_VALUE: u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: any): i8;\ndeclare namespace u16 {\n /** Smallest representable value. */\n export const MIN_VALUE: u16;\n /** Largest representable value. */\n export const MAX_VALUE: u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: any): i32;\ndeclare namespace u32 {\n /** Smallest representable value. */\n export const MIN_VALUE: u32;\n /** Largest representable value. */\n export const MAX_VALUE: u32;\n}\n/** Converts any other numeric value to a 64-bit unsigned integer. */\ndeclare function u64(value: any): i64;\ndeclare namespace u64 {\n /** Smallest representable value. */\n export const MIN_VALUE: u64;\n /** Largest representable value. */\n export const MAX_VALUE: u64;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */\ndeclare var usize: typeof u32 | typeof u64;\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: any): bool;\ndeclare namespace bool {\n /** Smallest representable value. */\n export const MIN_VALUE: bool;\n /** Largest representable value. */\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: any): f32;\ndeclare namespace f32 {\n /** Smallest representable value. */\n export const MIN_VALUE: f32;\n /** Largest representable value. */\n export const MAX_VALUE: f32;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f32;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f32;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f32;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f32;\n /** Loads a 32-bit float from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;\n /** Stores a 32-bit float to memory. */\n export function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;\n}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: any): f64;\ndeclare namespace f64 {\n /** Smallest representable value. */\n export const MIN_VALUE: f64;\n /** Largest representable value. */\n export const MAX_VALUE: f64;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f64;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f64;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f64;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f64;\n /** Loads a 64-bit float from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;\n /** Stores a 64-bit float to memory. */\n export function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;\n}\n/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */\ndeclare function v128(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;\ndeclare namespace v128 {\n /** Creates a 128-bit vector with identical lanes. */\n export function splat(x: T): v128;\n /** Extracts one lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): T;\n /** Replaces one lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: T): v128;\n /** Selects lanes from either 128-bit vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n /** Loads a 128-bit vector from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;\n /** Stores a 128-bit vector to memory. */\n export function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n /** Adds each lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128; // except i64\n /** Divides each lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each lane of a 128-bit vector */\n export function neg(a: v128): v128;\n /** Adds each lane of two 128-bit vectors using saturation. */\n export function add_saturate(a: v128, b: v128): v128;\n /** Subtracts each lane of two 128-bit vectors using saturation. */\n export function sub_saturate(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise right shift on each lane of a 128-bit vector by a scalar. */\n export function shr(a: v128, b: i32): v128;\n /** Performs the bitwise AND operation on each lane of two 128-bit vectors. */\n export function and(a: v128, b: v128): v128;\n /** Performs the bitwise OR operation on each lane of two 128-bit vectors. */\n export function or(a: v128, b: v128): v128;\n /** Performs the bitwise XOR operation on each lane of two 128-bit vectors. */\n export function xor(a: v128, b: v128): v128;\n /** Performs the bitwise NOT operation on each lane of a 128-bit vector. */\n export function not(a: v128): v128;\n /** Selects bits of either 128-bit vector according to the specified mask. */\n export function bitselect(v1: v128, v2: v128, mask: v128): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes the minimum of each lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each lane of a 128-bit vector from integer to floating point. */\n export function convert(a: v128): v128;\n /** Truncates each lane of a 128-bit vector from floating point to integer with saturation. */\n export function trunc(a: v128): v128;\n}\n/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */\ndeclare function i8x16(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;\ndeclare namespace i8x16 {\n /** Creates a vector with sixteen identical 8-bit integer lanes. */\n export function splat(x: i8): v128;\n /** Extracts one 8-bit integer lane from a 128-bit vector as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i8;\n /** Extracts one 8-bit integer lane from a 128-bit vector as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u8;\n /** Replaces one 8-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i8): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 8-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 8-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function sub_saturate_u(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 8-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 8-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 8-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 8-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n}\n/** Initializes a 128-bit vector from eight 16-bit integer values. Arguments must be compile-time constants. */\ndeclare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;\ndeclare namespace i16x8 {\n /** Creates a vector with eight identical 16-bit integer lanes. */\n export function splat(x: i16): v128;\n /** Extracts one 16-bit integer lane from a 128-bit vector as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i16;\n /** Extracts one 16-bit integer lane from a 128-bit vector as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u16;\n /** Replaces one 16-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i16): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 16-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 16-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function sub_saturate_u(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 16-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 16-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 16-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 16-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n}\n/** Initializes a 128-bit vector from four 32-bit integer values. Arguments must be compile-time constants. */\ndeclare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;\ndeclare namespace i32x4 {\n /** Creates a 128-bit vector with four identical 32-bit integer lanes. */\n export function splat(x: i32): v128;\n /** Extracts one 32-bit integer lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): i32;\n /** Replaces one 32-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i32): v128;\n /** Adds each 32-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 32-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 32-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 32-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 32-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n /** Truncates each 32-bit float lane of a 128-bit vector to a signed integer with saturation. */\n export function trunc_s_f32x4_sat(a: v128): v128;\n /** Truncates each 32-bit float lane of a 128-bit vector to an unsigned integer with saturation. */\n export function trunc_u_f32x4_sat(a: v128): v128;\n}\n/** Initializes a 128-bit vector from two 64-bit integer values. Arguments must be compile-time constants. */\ndeclare function i64x2(a: i64, b: i64): v128;\ndeclare namespace i64x2 {\n /** Creates a 128-bit vector with two identical 64-bit integer lanes. */\n export function splat(x: i64): v128;\n /** Extracts one 64-bit integer lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): i64;\n /** Replaces one 64-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i64): v128;\n /** Adds each 64-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 64-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 64-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 64-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Truncates each 64-bit float lane of a 128-bit vector to a signed integer with saturation. */\n export function trunc_s_f64x2_sat(a: v128): v128;\n /** Truncates each 64-bit float lane of a 128-bit vector to an unsigned integer with saturation. */\n export function trunc_u_f64x2_sat(a: v128): v128;\n}\n/** Initializes a 128-bit vector from four 32-bit float values. Arguments must be compile-time constants. */\ndeclare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;\ndeclare namespace f32x4 {\n /** Creates a 128-bit vector with four identical 32-bit float lanes. */\n export function splat(x: f32): v128;\n /** Extracts one 32-bit float lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): f32;\n /** Replaces one 32-bit float lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: f32): v128;\n /** Adds each 32-bit float lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit float lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit float lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 32-bit float lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 32-bit float lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 32-bit float lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 32-bit float lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 32-bit float lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 32-bit float lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which 32-bit float lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each 32-bit signed integer lane of a 128-bit vector to floating point. */\n export function convert_s_i32x4(a: v128): v128;\n /** Converts each 32-bit unsigned integer lane of a 128-bit vector to floating point. */\n export function convert_u_i32x4(a: v128): v128;\n}\n/** Initializes a 128-bit vector from two 64-bit float values. Arguments must be compile-time constants. */\ndeclare function f64x2(a: f64, b: f64): v128;\ndeclare namespace f64x2 {\n /** Creates a 128-bit vector with two identical 64-bit float lanes. */\n export function splat(x: f64): v128;\n /** Extracts one 64-bit float lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): f64;\n /** Replaces one 64-bit float lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: f64): v128;\n /** Adds each 64-bit float lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit float lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit float lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 64-bit float lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 64-bit float lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 64-bit float lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 64-bit float lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 64-bit float lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 64-bit float lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which 64-bit float lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each 64-bit signed integer lane of a 128-bit vector to floating point. */\n export function convert_s_i64x2(a: v128): v128;\n /** Converts each 64-bit unsigned integer lane of a 128-bit vector to floating point. */\n export function convert_u_i64x2(a: v128): v128;\n}\ndeclare namespace v8x16 {\n /** Selects 8-bit lanes from either 128-bit vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8, l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8): v128;\n}\n/** Macro type evaluating to the underlying native WebAssembly type. */\ndeclare type native = T;\n\n/** Pseudo-class representing the backing class of integer types. */\ndeclare class _Integer {\n /** Smallest representable value. */\n static readonly MIN_VALUE: number;\n /** Largest representable value. */\n static readonly MAX_VALUE: number;\n /** Converts a string to an integer of this type. */\n static parseInt(value: string, radix?: number): number;\n /** Converts this integer to a string. */\n toString(): string;\n}\n\n/** Pseudo-class representing the backing class of floating-point types. */\ndeclare class _Float {\n /** Difference between 1 and the smallest representable value greater than 1. */\n static readonly EPSILON: f32 | f64;\n /** Smallest representable value. */\n static readonly MIN_VALUE: f32 | f64;\n /** Largest representable value. */\n static readonly MAX_VALUE: f32 | f64;\n /** Smallest safely representable integer value. */\n static readonly MIN_SAFE_INTEGER: f32 | f64;\n /** Largest safely representable integer value. */\n static readonly MAX_SAFE_INTEGER: f32 | f64;\n /** Value representing positive infinity. */\n static readonly POSITIVE_INFINITY: f32 | f64;\n /** Value representing negative infinity. */\n static readonly NEGATIVE_INFINITY: f32 | f64;\n /** Value representing \'not a number\'. */\n static readonly NaN: f32 | f64;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n static isNaN(value: f32 | f64): bool;\n /** Returns true if passed value is finite. */\n static isFinite(value: f32 | f64): bool;\n /** Returns true if the value passed is a safe integer. */\n static isSafeInteger(value: f32 | f64): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n static isInteger(value: f32 | f64): bool;\n /** Converts a string to an integer. */\n static parseInt(value: string, radix?: i32): f32 | f64;\n /** Converts a string to a floating-point number. */\n static parseFloat(value: string): f32 | f64;\n /** Converts this floating-point number to a string. */\n toString(this: f64): string;\n}\n\n/** Backing class of signed 8-bit integers. */\ndeclare const I8: typeof _Integer;\n/** Backing class of signed 16-bit integers. */\ndeclare const I16: typeof _Integer;\n/** Backing class of signed 32-bit integers. */\ndeclare const I32: typeof _Integer;\n/** Backing class of signed 64-bit integers. */\ndeclare const I64: typeof _Integer;\n/** Backing class of signed size integers. */\ndeclare const Isize: typeof _Integer;\n/** Backing class of unsigned 8-bit integers. */\ndeclare const U8: typeof _Integer;\n/** Backing class of unsigned 16-bit integers. */\ndeclare const U16: typeof _Integer;\n/** Backing class of unsigned 32-bit integers. */\ndeclare const U32: typeof _Integer;\n/** Backing class of unsigned 64-bit integers. */\ndeclare const U64: typeof _Integer;\n/** Backing class of unsigned size integers. */\ndeclare const Usize: typeof _Integer;\n/** Backing class of 32-bit floating-point values. */\ndeclare const F32: typeof _Float;\n/** Backing class of 64-bit floating-point values. */\ndeclare const F64: typeof _Float;\n\n// User-defined diagnostic macros\n\n/** Emits a user-defined diagnostic error when encountered. */\ndeclare function ERROR(message?: any): void;\n/** Emits a user-defined diagnostic warning when encountered. */\ndeclare function WARNING(message?: any): void;\n/** Emits a user-defined diagnostic info when encountered. */\ndeclare function INFO(message?: any): void;\n\n// Polyfills\n\n/** Performs the sign-agnostic reverse bytes **/\ndeclare function bswap(value: T): T;\n/** Performs the sign-agnostic reverse bytes only for last 16-bit **/\ndeclare function bswap16(value: T): T;\n\n// Standard library\n\n/** Memory operations. */\ndeclare namespace memory {\n /** Whether the memory managed interface is implemented. */\n export const implemented: bool;\n /** Returns the current memory size in units of pages. One page is 64kb. */\n export function size(): i32;\n /** Grows linear memory by a given unsigned delta of pages. One page is 64kb. Returns the previous memory size in units of pages or `-1` on failure. */\n export function grow(value: i32): i32;\n /** Sets n bytes beginning at the specified destination in memory to the specified byte value. */\n export function fill(dst: usize, value: u8, count: usize): void;\n /** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\n export function copy(dst: usize, src: usize, n: usize): void;\n /** Repeats `src` of length `srcLength` `count` times at `dst`. */\n export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void;\n /** Copies elements from a passive element segment to a table. */\n export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void;\n /** Prevents further use of a passive element segment. */\n export function drop(segmentIndex: u32): void;\n /** Compares two chunks of memory. Returns `0` if equal, otherwise the difference of the first differing bytes. */\n export function compare(vl: usize, vr: usize, n: usize): i32;\n}\n\n/** Garbage collector operations. */\ndeclare namespace gc {\n /** Whether the garbage collector interface is implemented. */\n export const implemented: bool;\n /** Performs a full garbage collection cycle. */\n export function collect(): void;\n /** Retains a reference, making sure that it doesn\'t become collected. */\n export function retain(ref: usize): void;\n /** Releases a reference, allowing it to become collected. */\n export function release(ref: usize): void;\n}\n\n/** Table operations. */\ndeclare namespace table {\n /** Copies elements from a passive element segment to a table. */\n export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void;\n /** Prevents further use of a passive element segment. */\n export function drop(elementIndex: u32): void;\n /** Copies elements from one region of a table to another region. */\n export function copy(dest: u32, src: u32, n: u32): void;\n}\n\n/** Class representing a generic, fixed-length raw binary data buffer. */\ndeclare class ArrayBuffer {\n /** The size, in bytes, of the array. */\n readonly byteLength: i32;\n /** Returns true if value is one of the ArrayBuffer views, such as typed array or a DataView **/\n static isView(value: T): bool;\n /** Constructs a new array buffer of the given length in bytes. */\n constructor(length: i32);\n /** Returns a copy of this array buffer\'s bytes from begin, inclusive, up to end, exclusive. */\n slice(begin?: i32, end?: i32): ArrayBuffer;\n /** Returns a string representation of ArrayBuffer. */\n toString(): string;\n}\n\n/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform\'s endianness. */\ndeclare class DataView {\n /** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */\n readonly buffer: ArrayBuffer;\n /** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteLength: i32;\n /** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteOffset: i32;\n /** Constructs a new `DataView` with the given properties */\n constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);\n /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */\n getFloat32(byteOffset: i32, littleEndian?: boolean): f32;\n /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */\n getFloat64(byteOffset: i32, littleEndian?: boolean): f64;\n /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */\n getInt8(byteOffset: i32): i8;\n /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */\n getInt16(byteOffset: i32, littleEndian?: boolean): i16;\n /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */\n getInt32(byteOffset: i32, littleEndian?: boolean): i32;\n /** The `getInt64()` method gets a signed 64-bit integer (long long) at the specified byte offset from the start of the `DataView`. */\n getInt64(byteOffset: i32, littleEndian?: boolean): i64;\n /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */\n getUint8(byteOffset: i32): u8;\n /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */\n getUint16(byteOffset: i32, littleEndian?: boolean): u16;\n /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */\n getUint32(byteOffset: i32, littleEndian?: boolean): u32;\n /** The `getUint64()` method gets an unsigned 64-bit integer (unsigned long long) at the specified byte offset from the start of the `DataView`. */\n getUint64(byteOffset: i32, littleEndian?: boolean): u64;\n /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */\n setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;\n /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */\n setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;\n /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setInt8(byteOffset: i32, value: i8): void;\n /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */\n setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;\n /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */\n setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;\n /** The `setInt64()` method stores a signed 64-bit integer (long long) value at the specified byte offset from the start of the `DataView`. */\n setInt64(byteOffset: i32, value: i64, littleEndian?: boolean): void;\n /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setUint8(byteOffset: i32, value: u8): void;\n /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */\n setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;\n /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */\n setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;\n /** The `setUint64()` method stores an unsigned 64-bit integer (unsigned long long) value at the specified byte offset from the start of the `DataView`. */\n setUint64(byteOffset: i32, value: u64, littleEndian?: boolean): void;\n /** Returns a string representation of DataView. */\n toString(): string;\n}\n\ninterface ArrayLike {\n length: i32;\n // [key: number]: T;\n}\n\n/** Interface for a typed view on an array buffer. */\ninterface ArrayBufferView {\n [key: number]: T;\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n}\n\n/* @internal */\ndeclare abstract class TypedArray implements ArrayBufferView {\n [key: number]: T;\n /** Number of bytes per element. */\n static readonly BYTES_PER_ELEMENT: usize;\n /** Constructs a new typed array. */\n constructor(length: i32);\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n /** The length (in elements). */\n readonly length: i32;\n /** Returns a new TypedArray of this type on the same ArrayBuffer from begin inclusive to end exclusive. */\n subarray(begin?: i32, end?: i32): this;\n /** The reduce() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value. This method has the same algorithm as Array.prototype.reduce(). */\n reduce(\n callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,\n initialValue: W,\n ): W;\n /** The reduceRight() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value, starting from the end of the array. This method has the same algorithm as Array.prototype.reduceRight(). */\n reduceRight(\n callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,\n initialValue: W,\n ): W;\n /** The some() method tests whether some element in the typed array passes the test implemented by the provided function. This method has the same algorithm as Array.prototype.some().*/\n some(callbackfn: (value: T, index: i32, self: this) => bool): bool;\n /** The map() method creates a new typed array with the results of calling a provided function on every element in this typed array. This method has the same algorithm as Array.prototype.map().*/\n map(callbackfn: (value: T, index: i32, self: this) => T): this;\n /** The sort() method sorts the elements of a typed array numerically in place and returns the typed array. This method has the same algorithm as Array.prototype.sort(), except that sorts the values numerically instead of as strings. TypedArray is one of the typed array types here. */\n sort(callback?: (a: T, b: T) => i32): this;\n /** The fill() method fills all the elements of a typed array from a start index to an end index with a static value. This method has the same algorithm as Array.prototype.fill(). */\n fill(value: T, start?: i32, end?: i32): this;\n /** The findIndex() method returns an index in the typed array, if an element in the typed array satisfies the provided testing function. Otherwise -1 is returned. See also the find() [not implemented] method, which returns the value of a found element in the typed array instead of its index. */\n findIndex(callbackfn: (value: T, index: i32, self: this) => bool): i32;\n /** The every() method tests whether all elements in the typed array pass the test implemented by the provided function. This method has the same algorithm as Array.prototype.every(). */\n every(callbackfn: (value: T, index: i32, self: this) => bool): bool;\n /** The forEach() method executes a provided function once per array element. This method has the same algorithm as Array.prototype.forEach().*/\n forEach(callbackfn: (value: T, index: i32, self: this) => void): void;\n /** The reverse() method reverses a typed array in place. The first typed array element becomes the last and the last becomes the first. This method has the same algorithm as Array.prototype.reverse(). */\n reverse(): this;\n}\n\n/** An array of twos-complement 8-bit signed integers. */\ndeclare class Int8Array extends TypedArray {}\n/** An array of 8-bit unsigned integers. */\ndeclare class Uint8Array extends TypedArray {}\n/** A clamped array of 8-bit unsigned integers. */\ndeclare class Uint8ClampedArray extends TypedArray {}\n/** An array of twos-complement 16-bit signed integers. */\ndeclare class Int16Array extends TypedArray {}\n/** An array of 16-bit unsigned integers. */\ndeclare class Uint16Array extends TypedArray {}\n/** An array of twos-complement 32-bit signed integers. */\ndeclare class Int32Array extends TypedArray {}\n/** An array of 32-bit unsigned integers. */\ndeclare class Uint32Array extends TypedArray {}\n/** An array of twos-complement 64-bit signed integers. */\ndeclare class Int64Array extends TypedArray {}\n/** An array of 64-bit unsigned integers. */\ndeclare class Uint64Array extends TypedArray {}\n/** An array of 32-bit floating point numbers. */\ndeclare class Float32Array extends TypedArray {}\n/** An array of 64-bit floating point numbers. */\ndeclare class Float64Array extends TypedArray {}\n\n/** Class representing a sequence of values of type `T`. */\ndeclare class Array {\n\n /** Tests if a value is an array. */\n static isArray(value: any): value is Array;\n /** Creates a new array with at least the specified capacity and length zero. */\n static create(capacity?: i32): Array;\n\n [key: number]: T;\n /** Current length of the array. */\n length: i32;\n /** Constructs a new array. If length is greater than zero and T is a non-nullable reference, use `Array.create` instead.*/\n constructor(capacity?: i32);\n\n fill(value: T, start?: i32, end?: i32): this;\n every(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n findIndex(predicate: (element: T, index: i32, array?: Array) => bool): i32;\n includes(searchElement: T, fromIndex?: i32): bool;\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): i32;\n concat(items: T[]): T[];\n copyWithin(target: i32, start: i32, end?: i32): this;\n pop(): T;\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void;\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array;\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array;\n reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n shift(): T;\n some(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n unshift(element: T): i32;\n slice(from: i32, to?: i32): Array;\n splice(start: i32, deleteCount?: i32): Array;\n sort(comparator?: (a: T, b: T) => i32): this;\n join(separator?: string): string;\n reverse(): T[];\n toString(): string;\n}\n\n/** Class representing a fixed sequence of values of type `T`. */\ndeclare class FixedArray {\n [key: number]: T;\n readonly length: i32;\n constructor(capacity?: i32);\n}\n\n/** Class representing a sequence of characters. */\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(code: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: i32;\n readonly lengthUTF8: i32;\n\n charAt(index: u32): string;\n charCodeAt(index: u32): u16;\n concat(other: string): string;\n endsWith(other: string): bool;\n indexOf(other: string, fromIndex?: i32): u32;\n lastIndexOf(other: string, fromIndex?: i32): i32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(start: u32, end?: u32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n trimStart(): string;\n trimEnd(): string;\n padStart(targetLength: i32, padString?: string): string;\n padEnd(targetLength: i32, padString?: string): string;\n repeat(count?: i32): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n static fromUTF8(ptr: usize, len: usize): string;\n toUTF8(): usize;\n}\n\n/** Class for representing a runtime error. Base class of all errors. */\ndeclare class Error {\n\n /** Error name. */\n name: string;\n\n /** Message provided on construction. */\n message: string;\n\n /** Stack trace. */\n stack?: string;\n\n /** Constructs a new error, optionally with a message. */\n constructor(message?: string);\n\n /** Method returns a string representing the specified Error class. */\n toString(): string;\n}\n\n/** Class for indicating an error when a value is not in the set or range of allowed values. */\ndeclare class RangeError extends Error { }\n\n/** Class for indicating an error when a value is not of the expected type. */\ndeclare class TypeError extends Error { }\n\n/** Class for indicating an error when trying to interpret syntactically invalid code. */\ndeclare class SyntaxError extends Error { }\n\ninterface Boolean {}\ninterface Function {}\ninterface IArguments {}\ninterface Number {}\ninterface Object {}\ninterface RegExp {}\n\ndeclare class Map {\n readonly size: i32;\n has(key: K): bool;\n set(key: K, value: V): void;\n get(key: K): V;\n delete(key: K): bool;\n clear(): void;\n toString(): string;\n}\n\ndeclare class Set {\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n toString(): string;\n}\n\ninterface SymbolConstructor {\n readonly hasInstance: symbol;\n readonly isConcatSpreadable: symbol;\n readonly isRegExp: symbol;\n readonly iterator: symbol;\n readonly match: symbol;\n readonly replace: symbol;\n readonly search: symbol;\n readonly species: symbol;\n readonly split: symbol;\n readonly toPrimitive: symbol;\n readonly toStringTag: symbol;\n readonly unscopables: symbol;\n (description?: string | null): symbol;\n for(key: string): symbol;\n keyFor(sym: symbol): string | null;\n}\n\ndeclare const Symbol: SymbolConstructor;\n\ninterface IMath {\n /** The base of natural logarithms, e, approximately 2.718. */\n readonly E: T;\n /** The natural logarithm of 2, approximately 0.693. */\n readonly LN2: T;\n /** The natural logarithm of 10, approximately 2.302. */\n readonly LN10: T;\n /** The base 2 logarithm of e, approximately 1.442. */\n readonly LOG2E: T;\n /** The base 10 logarithm of e, approximately 0.434. */\n readonly LOG10E: T;\n /** The ratio of the circumference of a circle to its diameter, approximately 3.14159. */\n readonly PI: T;\n /** The square root of 1/2, approximately 0.707. */\n readonly SQRT1_2: T;\n /** The square root of 2, approximately 1.414. */\n readonly SQRT2: T;\n /** Returns the absolute value of `x`. */\n abs(x: T): T;\n /** Returns the arccosine (in radians) of `x`. */\n acos(x: T): T;\n /** Returns the hyperbolic arc-cosine of `x`. */\n acosh(x: T): T;\n /** Returns the arcsine (in radians) of `x` */\n asin(x: T): T;\n /** Returns the hyperbolic arcsine of `x`. */\n asinh(x: T): T;\n /** Returns the arctangent (in radians) of `x`. */\n atan(x: T): T;\n /** Returns the arctangent of the quotient of its arguments. */\n atan2(y: T, x: T): T;\n /** Returns the hyperbolic arctangent of `x`. */\n atanh(x: T): T;\n /** Returns the cube root of `x`. */\n cbrt(x: T): T;\n /** Returns the smallest integer greater than or equal to `x`. */\n ceil(x: T): T;\n /** Returns the number of leading zero bits in the 32-bit binary representation of `x`. */\n clz32(x: T): T;\n /** Returns the cosine (in radians) of `x`. */\n cos(x: T): T;\n /** Returns the hyperbolic cosine of `x`. */\n cosh(x: T): T;\n /** Returns e to the power of `x`. */\n exp(x: T): T;\n /** Returns e to the power of `x`, minus 1. */\n expm1(x: T): T;\n /** Returns the largest integer less than or equal to `x`. */\n floor(x: T): T;\n /** Returns the nearest 32-bit single precision float representation of `x`. */\n fround(x: T): f32;\n /** Returns the square root of the sum of squares of its arguments. */\n hypot(value1: T, value2: T): T; // TODO: rest\n /** Returns the result of the C-like 32-bit multiplication of `a` and `b`. */\n imul(a: T, b: T): T;\n /** Returns the natural logarithm (base e) of `x`. */\n log(x: T): T;\n /** Returns the base 10 logarithm of `x`. */\n log10(x: T): T;\n /** Returns the natural logarithm (base e) of 1 + `x`. */\n log1p(x: T): T;\n /** Returns the base 2 logarithm of `x`. */\n log2(x: T): T;\n /** Returns the largest-valued number of its arguments. */\n max(value1: T, value2: T): T; // TODO: rest\n /** Returns the lowest-valued number of its arguments. */\n min(value1: T, value2: T): T; // TODO: rest\n /** Returns `base` to the power of `exponent`. */\n pow(base: T, exponent: T): T;\n /** Returns a pseudo-random number in the range from 0.0 inclusive up to but not including 1.0. */\n random(): T;\n /** Returns the value of `x` rounded to the nearest integer. */\n round(x: T): T;\n /** Returns the sign of `x`, indicating whether the number is positive, negative or zero. */\n sign(x: T): T;\n /** Returns whether the sign bit of `x` is set */\n signbit(x: T): bool;\n /** Returns the sine of `x`. */\n sin(x: T): T;\n /** Returns the hyperbolic sine of `x`. */\n sinh(x: T): T;\n /** Returns the square root of `x`. */\n sqrt(x: T): T;\n /** Returns the tangent of `x`. */\n tan(x: T): T;\n /** Returns the hyperbolic tangent of `x`. */\n tanh(x: T): T;\n /** Returns the integer part of `x` by removing any fractional digits. */\n trunc(x: T): T;\n}\n\ninterface INativeMath extends IMath {\n /** Contains sin value produced after Math/Mathf.sincos */\n sincos_sin: T;\n /** Contains cos value produced after Math/Mathf.sincos */\n sincos_cos: T;\n /** Seeds the random number generator. */\n seedRandom(value: i64): void;\n /** Returns the floating-point remainder of `x / y` (rounded towards zero). */\n mod(x: T, y: T): T;\n /** Returns the floating-point remainder of `x / y` (rounded to nearest). */\n rem(x: T, y: T): T;\n /** Returns sin and cos simultaneously for same angle. Results stored to `sincos_s32/64` and `sincos_c32/64` globals */\n sincos(x: T): void;\n}\n\n/** Double precision math imported from JavaScript. */\ndeclare const JSMath: IMath;\n/** Double precision math implemented natively. */\ndeclare const NativeMath: INativeMath;\n/** Single precision math implemented natively. */\ndeclare const NativeMathf: INativeMath;\n/** Alias of {@link NativeMath} or {@link JSMath} respectively. Defaults to `NativeMath`. */\ndeclare const Math: IMath;\n/** Alias of {@link NativeMathf} or {@link JSMath} respectively. Defaults to `NativeMathf`. */\ndeclare const Mathf: IMath;\n\ndeclare class Date {\n /** Returns the UTC timestamp in milliseconds of the specified date. */\n static UTC(\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: i32\n ): i64;\n /** Returns the current UTC timestamp in milliseconds. */\n static now(): i64;\n /** Constructs a new date object from an UTC timestamp in milliseconds. */\n constructor(value: i64);\n /** Returns the UTC timestamp of this date in milliseconds. */\n getTime(): i64;\n /** Sets the UTC timestamp of this date in milliseconds. */\n setTime(value: i64): i64;\n}\n\n/** Environmental tracing function for debugging purposes. */\ndeclare function trace(msg: string, n?: i32, a0?: f64, a1?: f64, a2?: f64, a3?: f64, a4?: f64): void;\n\n// Decorators\n\ninterface TypedPropertyDescriptor {\n configurable?: boolean;\n enumerable?: boolean;\n writable?: boolean;\n value?: T;\n get?(): T;\n set?(value: T): void;\n}\n\n/** Annotates a method as a binary operator overload for the specified `token`. */\ndeclare function operator(token:\n "[]" | "[]=" | "{}" | "{}=" | "==" | "!=" | ">" | "<" | "<=" | ">=" |\n ">>" | ">>>" | "<<" | "&" | "|" | "^" | "+" | "-" | "*" | "**" | "/" | "%"\n): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n) => TypedPropertyDescriptor | void;\n\ndeclare namespace operator {\n /** Annotates a method as a binary operator overload for the specified `token`. */\n export function binary(token:\n "[]" | "[]=" | "{}" | "{}=" | "==" | "!=" | ">" | "<" | "<=" | ">=" |\n ">>" | ">>>" | "<<" | "&" | "|" | "^" | "+" | "-" | "*" | "**" | "/" | "%"\n ): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n /** Annotates a method as an unary prefix operator overload for the specified `token`. */\n export function prefix(token: "!" | "~" | "+" | "-" | "++" | "--"): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n /** Annotates a method as an unary postfix operator overload for the specified `token`. */\n export function postfix(token: "++" | "--"): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n}\n\n/** Annotates an element as a program global. */\ndeclare function global(...args: any[]): any;\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(constructor: Function): void;\n\n/** Annotates a class as being sealed / non-derivable. */\ndeclare function sealed(constructor: Function): void;\n\n/** Annotates a method, function or constant global as always inlined. */\ndeclare function inline(...args: any[]): any;\n\n/** Annotates a method, function or constant global as unsafe. */\ndeclare function unsafe(...args: any[]): any;\n\n/** Annotates an explicit external name of a function or global. */\ndeclare function external(...args: any[]): any;\n\n/** Annotates a global for lazy compilation. */\ndeclare function lazy(...args: any[]): any;\n\n/** Annotates a function as the explicit start function. */\ndeclare function start(...args: any[]): any;\n',portable:"/**\n * Environment definitions for compiling AssemblyScript to JavaScript using tsc.\n *\n * Note that semantic differences require additional explicit conversions for full compatibility.\n * For example, when casting an i32 to an u8, doing `(someI32 & 0xff)` will yield the same\n * result when compiling to WebAssembly or JS while `someI32` alone does nothing in JS.\n *\n * Note that i64's are not portable (JS numbers are IEEE754 doubles with a maximum safe integer\n * value of 2^53-1) and instead require a compatibility layer to work in JS as well, as for example\n * {@link glue/js/i64} respectively {@link glue/wasm/i64}.\n *\n * @module std/portable\n *//***/\n\n/// \n\n// Types\n\ndeclare type bool = boolean;\ndeclare type i8 = number;\ndeclare type i16 = number;\ndeclare type i32 = number;\ndeclare type isize = number;\ndeclare type u8 = number;\ndeclare type u16 = number;\ndeclare type u32 = number;\ndeclare type usize = number;\ndeclare type f32 = number;\ndeclare type f64 = number;\n\n// Compiler hints\n\n/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */\ndeclare const ASC_TARGET: i32;\n/** Provided noAssert option. */\ndeclare const ASC_NO_ASSERT: bool;\n/** Provided memoryBase option. */\ndeclare const ASC_MEMORY_BASE: i32;\n/** Provided optimizeLevel option. */\ndeclare const ASC_OPTIMIZE_LEVEL: i32;\n/** Provided shrinkLevel option. */\ndeclare const ASC_SHRINK_LEVEL: i32;\n/** Whether the mutable global feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBAL: bool;\n/** Whether the sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n\n// Builtins\n\n/** Performs the sign-agnostic count leading zero bits operation on a 32-bit integer. All zero bits are considered leading if the value is zero. */\ndeclare function clz(value: T): T;\n/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit integer. All zero bits are considered trailing if the value is zero. */\ndeclare function ctz(value: T): T;\n/** Performs the sign-agnostic count number of one bits operation on a 32-bit integer. */\ndeclare function popcnt(value: T): T;\n/** Performs the sign-agnostic rotate left operation on a 32-bit integer. */\ndeclare function rotl(value: T, shift: T): T;\n/** Performs the sign-agnostic rotate right operation on a 32-bit integer. */\ndeclare function rotr(value: T, shift: T): T;\n/** Computes the absolute value of an integer or float. */\ndeclare function abs(value: T): T;\n/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function max(left: T, right: T): T;\n/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function min(left: T, right: T): T;\n/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */\ndeclare function copysign(x: T, y: T): T;\n/** Performs the ceiling operation on a 32-bit or 64-bit float. */\ndeclare function ceil(value: T): T;\n/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(value: T): T;\n/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */\ndeclare function nearest(value: T): T;\n/** Selects one of two pre-evaluated values depending on the condition. */\ndeclare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n/** Calculates the square root of a 32-bit or 64-bit float. */\ndeclare function sqrt(value: T): T;\n/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */\ndeclare function trunc(value: T): T;\n/** Loads a value of the specified type from memory. Type must be `u8`. */\ndeclare function load(ptr: usize, constantOffset?: usize): T;\n/** Stores a value of the specified type to memory. Type must be `u8`. */\ndeclare function store(ptr: usize, value: T, constantOffset?: usize): void;\n/** Emits an unreachable operation that results in a runtime error when executed. */\ndeclare function unreachable(): any; // sic\n\n/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */\ndeclare const NaN: f32 | f64;\n/** Positive infinity as a 32-bit or 64-bit float depending on context. */\ndeclare const Infinity: f32 | f64;\n/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/\ndeclare function changetype(value: any): T;\n/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */\ndeclare function unchecked(value: T): T;\n/** Tests if a 32-bit or 64-bit float is `NaN`. */\ndeclare function isNaN(value: T): bool;\n/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */\ndeclare function isFinite(value: T): bool;\n/** Tests if the specified value is a valid integer. Can't distinguish an integer from an integral float. */\ndeclare function isInteger(value: any): value is number;\n/** Tests if the specified value is a valid float. Can't distinguish a float from an integer. */\ndeclare function isFloat(value: any): value is number;\n/** Tests if the specified value is of a nullable reference type. */\ndeclare function isNullable(value: any): bool;\n/** Tests if the specified value is of a reference type. */\ndeclare function isReference(value: any): value is object | string;\n/** Tests if the specified value is of a function type */\ndeclare function isFunction(value: any): value is Function;\n/** Tests if the specified value can be used as a string. */\ndeclare function isString(value: any): value is string | String;\n/** Tests if the specified value can be used as an array. */\ndeclare function isArray(value: any): value is Array;\n/** Tests if the specified type *or* expression can be used as an array like object. */\ndeclare function isArrayLike(value: any): value is ArrayLike;\n/** Tests if the specified expression resolves to a defined element. */\ndeclare function isDefined(expression: any): bool;\n/** Tests if the specified expression evaluates to a constant value. */\ndeclare function isConstant(expression: any): bool;\n/** Traps if the specified value is not true-ish, otherwise returns the value. */\ndeclare function assert(isTrueish: T | null, message?: string): T;\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses a floating point string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n/** Returns the 64-bit floating-point remainder of `x/y`. */\ndeclare function fmod(x: f64, y: f64): f64;\n/** Returns the 32-bit floating-point remainder of `x/y`. */\ndeclare function fmodf(x: f32, y: f32): f32;\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: any): i8;\ndeclare namespace i8 {\n /** Smallest representable value. */\n export const MIN_VALUE: i8;\n /** Largest representable value. */\n export const MAX_VALUE: i8;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i8;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: any): i16;\ndeclare namespace i16 {\n /** Smallest representable value. */\n export const MIN_VALUE: i16;\n /** Largest representable value. */\n export const MAX_VALUE: i16;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i16;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: any): i32;\ndeclare namespace i32 {\n /** Smallest representable value. */\n export const MIN_VALUE: i32;\n /** Largest representable value. */\n export const MAX_VALUE: i32;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i32;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare function isize(value: any): isize;\ndeclare namespace isize {\n /** Smallest representable value. */\n export const MIN_VALUE: isize;\n /** Largest representable value. */\n export const MAX_VALUE: isize;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): isize;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): isize;\n}\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: any): u8;\ndeclare namespace u8 {\n /** Smallest representable value. */\n export const MIN_VALUE: u8;\n /** Largest representable value. */\n export const MAX_VALUE: u8;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u8;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: any): u16;\ndeclare namespace u16 {\n /** Smallest representable value. */\n export const MIN_VALUE: u16;\n /** Largest representable value. */\n export const MAX_VALUE: u16;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u16;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: any): u32;\ndeclare namespace u32 {\n /** Smallest representable value. */\n export const MIN_VALUE: u32;\n /** Largest representable value. */\n export const MAX_VALUE: u32;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u32;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */\ndeclare function usize(value: any): isize;\ndeclare namespace usize {\n /** Smallest representable value. */\n export const MIN_VALUE: usize;\n /** Largest representable value. */\n export const MAX_VALUE: usize;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): usize;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): usize;\n}\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: any): bool;\ndeclare namespace bool {\n /** Smallest representable value. */\n export const MIN_VALUE: bool;\n /** Largest representable value. */\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: any): f32;\ndeclare namespace f32 {\n /** Smallest representable value. */\n export const MIN_VALUE: f32;\n /** Largest representable value. */\n export const MAX_VALUE: f32;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f32;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f32;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f32;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f32;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n export function isNaN(value: f32): bool;\n /** Returns true if passed value is finite. */\n export function isFinite(value: f32): bool;\n /** Returns true if the value passed is a safe integer. */\n export function isSafeInteger(value: f32): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n export function isInteger(value: f32): bool;\n /** Converts a string to a floating-point number. */\n export function parseFloat(string: string): f32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): f32;\n}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: any): f64;\ndeclare namespace f64 {\n /** Smallest representable value. */\n export const MIN_VALUE: f64;\n /** Largest representable value. */\n export const MAX_VALUE: f64;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f64;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f64;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f64;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f64;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n export function isNaN(value: f32): bool;\n /** Returns true if passed value is finite. */\n export function isFinite(value: f32): bool;\n /** Returns true if the value passed is a safe integer. */\n export function isSafeInteger(value: f64): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n export function isInteger(value: f64): bool;\n /** Converts a string to a floating-point number. */\n export function parseFloat(string: string): f64;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): f64;\n}\n\n// Polyfills\n\n/** [Polyfill] Performs the sign-agnostic reverse bytes **/\ndeclare function bswap(value: T): T;\n/** [Polyfill] Performs the sign-agnostic reverse bytes only for last 16-bit **/\ndeclare function bswap16(value: T): T;\n\n// Standard library\n\n/** Memory operations. */\ndeclare namespace memory {\n /** Allocates a chunk of memory of the specified size and returns a pointer to it. */\n function allocate(size: usize): usize;\n /** Disposes a chunk of memory by its pointer. */\n function free(ptr: usize): void;\n /** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\n function copy(dst: usize, src: usize, n: usize): void;\n /** Fills size bytes from from the specified destination by same value in memory. */\n function fill(dst: usize, value: u8, size: usize): void;\n /** Resets the allocator to its initial state, if supported. */\n function reset(): void;\n}\n\n/** Class representing a generic, fixed-length raw binary data buffer. */\ndeclare class ArrayBuffer {\n /** The size, in bytes, of the array. */\n readonly byteLength: i32;\n /** Returns true if value is one of the ArrayBuffer views, such as typed array or a DataView **/\n static isView(value: T): bool;\n /** Constructs a new array buffer of the given length in bytes. */\n constructor(length: i32);\n /** Returns a copy of this array buffer's bytes from begin, inclusive, up to end, exclusive. */\n slice(begin?: i32, end?: i32): ArrayBuffer;\n /** Returns a string representation of ArrayBuffer. */\n toString(): string;\n}\n\n/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform's endianness. */\ndeclare class DataView {\n /** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */\n readonly buffer: ArrayBuffer;\n /** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteLength: i32;\n /** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteOffset: i32;\n /** Constructs a new `DataView` with the given properties */\n constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);\n /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */\n getFloat32(byteOffset: i32, littleEndian?: boolean): f32;\n /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */\n getFloat64(byteOffset: i32, littleEndian?: boolean): f64;\n /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */\n getInt8(byteOffset: i32): i8;\n /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */\n getInt16(byteOffset: i32, littleEndian?: boolean): i16;\n /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */\n getInt32(byteOffset: i32, littleEndian?: boolean): i32;\n /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */\n getUint8(byteOffset: i32): u8;\n /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */\n getUint16(byteOffset: i32, littleEndian?: boolean): u16;\n /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */\n getUint32(byteOffset: i32, littleEndian?: boolean): u32;\n /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */\n setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;\n /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */\n setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;\n /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setInt8(byteOffset: i32, value: i8): void;\n /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */\n setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;\n /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */\n setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;\n /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setUint8(byteOffset: i32, value: u8): void;\n /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */\n setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;\n /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */\n setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;\n /** Returns a string representation of DataView. */\n toString(): string;\n}\n\ndeclare class Array {\n\n static isArray(value: any): value is Array;\n static create(capacity?: i32): Array;\n\n [key: number]: T;\n length: i32;\n constructor(capacity?: i32);\n\n fill(value: T, start?: i32, end?: i32): this;\n every(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n findIndex(predicate: (element: T, index: i32, array?: Array) => bool): i32;\n includes(searchElement: T, fromIndex?: i32): bool;\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): i32;\n concat(items: T[]): T[];\n copyWithin(target: i32, start: i32, end?: i32): this;\n pop(): T;\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void;\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array;\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array;\n reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n shift(): T;\n some(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n unshift(element: T): i32;\n slice(from?: i32, to?: i32): Array;\n splice(start: i32, deleteCount?: i32): Array;\n sort(comparator?: (a: T, b: T) => i32): this;\n join(separator?: string): string;\n reverse(): T[];\n toString(): string;\n}\n\ndeclare class Uint8Array extends Array {}\ndeclare class Uint8ClampedArray extends Array {}\ndeclare class Uint16Array extends Array {}\ndeclare class Uint32Array extends Array {}\ndeclare class Int8Array extends Array {}\ndeclare class Int16Array extends Array {}\ndeclare class Int32Array extends Array {}\ndeclare class Float32Array extends Array {}\ndeclare class Float64Array extends Array {}\n\ninterface ArrayLike {\n length: i32;\n [key: number]: T;\n}\n\n/** Interface for a typed view on an array buffer. */\ninterface ArrayBufferView {\n [key: number]: T;\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n}\n\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(code: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: i32;\n\n private constructor();\n\n charAt(index: i32): string;\n charCodeAt(index: i32): i32;\n concat(other: string): string;\n indexOf(other: string, fromIndex?: i32): i32;\n lastIndexOf(other: string, fromIndex?: i32): i32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n endsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(from: i32, to?: i32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n trimStart(): string;\n trimEnd(): string;\n padStart(targetLength: i32, padString?: string): string;\n padEnd(targetLength: i32, padString?: string): string;\n replace(search: string, replacement: string): string;\n repeat(count?: i32): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n}\n\ninterface Boolean {}\n\ndeclare class Number {\n private constructor();\n toString(radix?: i32): string;\n}\n\ninterface Object {}\n\ninterface Function {}\n\ninterface RegExp {}\n\ninterface IArguments {}\n\n/** Class for representing a runtime error. Base class of all errors. */\ndeclare class Error {\n\n /** Error name. */\n name: string;\n\n /** Message provided on construction. */\n message: string;\n\n /** Stack trace. */\n stack?: string;\n\n /** Constructs a new error, optionally with a message. */\n constructor(message?: string);\n\n /** Method returns a string representing the specified Error class. */\n toString(): string;\n}\n\n/** Class for indicating an error when a value is not in the set or range of allowed values. */\ndeclare class RangeError extends Error { }\n\n/** Class for indicating an error when a value is not of the expected type. */\ndeclare class TypeError extends Error { }\n\n/** Class for indicating an error when trying to interpret syntactically invalid code. */\ndeclare class SyntaxError extends Error { }\n\ndeclare class Set {\n constructor(entries?: T[]);\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n toString(): string;\n [Symbol.iterator](): Iterator;\n}\n\ndeclare class Map {\n constructor(entries?: [K, V][]);\n readonly size: i32;\n set(key: K, value: V): void;\n has(key: K): bool;\n get(key: K): V | null;\n clear(): void;\n entries(): Iterable<[K, V]>;\n keys(): Iterable;\n values(): Iterable;\n delete(key: K): bool;\n toString(): string;\n [Symbol.iterator](): Iterator<[K,V]>;\n}\n\ninterface SymbolConstructor {\n readonly hasInstance: symbol;\n readonly isConcatSpreadable: symbol;\n readonly isRegExp: symbol;\n readonly iterator: symbol;\n readonly match: symbol;\n readonly replace: symbol;\n readonly search: symbol;\n readonly species: symbol;\n readonly split: symbol;\n readonly toPrimitive: symbol;\n readonly toStringTag: symbol;\n readonly unscopables: symbol;\n (description?: string | null): symbol;\n for(key: string): symbol;\n keyFor(sym: symbol): string | null;\n}\ndeclare const Symbol: SymbolConstructor;\n\ninterface Iterable {\n [Symbol.iterator](): Iterator;\n}\n\ninterface Iterator {}\n\ninterface IMath {\n readonly E: f64;\n readonly LN2: f64;\n readonly LN10: f64;\n readonly LOG2E: f64;\n readonly LOG10E: f64;\n readonly PI: f64;\n readonly SQRT1_2: f64;\n readonly SQRT2: f64;\n\n sincos_sin: f64;\n sincos_cos: f64;\n\n abs(x: f64): f64;\n acos(x: f64): f64;\n acosh(x: f64): f64;\n asin(x: f64): f64;\n asinh(x: f64): f64;\n atan(x: f64): f64;\n atan2(y: f64, x: f64): f64;\n atanh(x: f64): f64;\n cbrt(x: f64): f64;\n ceil(x: f64): f64;\n clz32(x: f64): i32;\n cos(x: f64): f64;\n cosh(x: f64): f64;\n exp(x: f64): f64;\n expm1(x: f64): f64;\n floor(x: f64): f64;\n fround(x: f64): f32;\n hypot(value1: f64, value2: f64): f64; // TODO: see std/math\n imul(a: f64, b: f64): i32;\n log(x: f64): f64;\n log10(x: f64): f64;\n log1p(x: f64): f64;\n log2(x: f64): f64;\n max(value1: f64, value2: f64): f64; // TODO: see std/math\n min(value1: f64, value2: f64): f64; // TODO: see std/math\n pow(base: f64, exponent: f64): f64;\n random(): f64;\n round(x: f64): f64;\n sign(x: f64): f64;\n signbit(x: f64): bool;\n sin(x: f64): f64;\n sincos(x: f64): f64;\n sinh(x: f64): f64;\n sqrt(x: f64): f64;\n tan(x: f64): f64;\n tanh(x: f64): f64;\n trunc(x: f64): f64;\n}\n\ndeclare const Math: IMath;\ndeclare const Mathf: IMath;\ndeclare const JSMath: IMath;\n\ndeclare class Date {\n /** Returns the UTC timestamp in milliseconds of the specified date. */\n static UTC(\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: i32\n ): number;\n /** Returns the current UTC timestamp in milliseconds. */\n static now(): number;\n /** Constructs a new date object from an UTC timestamp in milliseconds. */\n constructor(value: number);\n /** Returns the UTC timestamp of this date in milliseconds. */\n getTime(): number;\n /** Sets the UTC timestamp of this date in milliseconds. */\n setTime(value: number): number;\n}\n\ndeclare namespace console {\n /** @deprecated */\n function log(message: string): void;\n}\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(constructor: Function): void;\n"}):(()=>{const n=path.join(".","..","std");return{assembly:fs.readFileSync(path.join(n,"assembly","index.d.ts"),"utf8"),portable:fs.readFileSync(path.join(n,"portable","index.d.ts"),"utf8")}})(),exports.compileString=((n,e)=>{"string"==typeof n&&(n={"input.ts":n});const t=Object.create({stdout:createMemoryStream(),stderr:createMemoryStream()});var r=["--binaryFile","binary","--textFile","text"];return Object.keys(e||{}).forEach(n=>{var t=e[n];Array.isArray(t)?t.forEach(e=>r.push("--"+n,String(e))):r.push("--"+n,String(t))}),exports.main(r.concat(Object.keys(n)),{stdout:t.stdout,stderr:t.stderr,readFile:e=>n.hasOwnProperty(e)?n[e]:null,writeFile:(n,e)=>t[n]=e,listFiles:()=>[]}),t}),exports.main=function(n,e,t){"function"==typeof e?(t=e,e={}):e||(e={});const r=e.stdout||process.stdout,i=e.stderr||process.stderr,o=e.readFile||F,a=e.writeFile||z,s=e.listFiles||S,l=e.stats||createStats();if(!r)throw Error("'options.stdout' must be specified");if(!i)throw Error("'options.stderr' must be specified");const u=optionsUtil.parse(n,exports.options),f=u.options;if(n=u.arguments,f.noColors?colorsUtil.stdout.supported=colorsUtil.stderr.supported=!1:(colorsUtil.stdout=colorsUtil.from(r),colorsUtil.stderr=colorsUtil.from(i)),u.unknown.length&&u.unknown.forEach(n=>{i.write(colorsUtil.stderr.yellow("WARN: ")+"Unknown option '"+n+"'"+EOL)}),u.trailing.length&&i.write(colorsUtil.stderr.yellow("WARN: ")+"Unsupported trailing arguments: "+u.trailing.join(" ")+EOL),t||(t=function(n){var e=0;return n&&(i.write(colorsUtil.stderr.red("ERROR: ")+n.stack.replace(/^ERROR: /i,"")+EOL),e=1),e}),f.version)return r.write("Version "+exports.version+(isDev?"-dev":"")+EOL),t(null);if(f.help||!n.length){var c=f.help?r:i,d=f.help?colorsUtil.stdout:colorsUtil.stderr;return c.write([d.white("SYNTAX")," "+d.cyan("asc")+" [entryFile ...] [options]","",d.white("EXAMPLES")," "+d.cyan("asc")+" hello.ts"," "+d.cyan("asc")+" hello.ts -b hello.wasm -t hello.wat"," "+d.cyan("asc")+" hello1.ts hello2.ts -b -O > hello.wasm","",d.white("OPTIONS")].concat(optionsUtil.help(exports.options,24,EOL)).join(EOL)+EOL),t(null)}if(!fs.readFileSync){if(o===F)throw Error("'options.readFile' must be specified");if(a===z)throw Error("'options.writeFile' must be specified");if(s===S)throw Error("'options.listFiles' must be specified")}const p=f.baseDir?path.resolve(f.baseDir):".",h=[];f.transform&&f.transform.forEach(n=>h.push(__webpack_require__(12)(path.isAbsolute(n=n.trim())?n:path.join(process.cwd(),n))));var g=null;Object.keys(exports.libraryFiles).forEach(n=>{n.indexOf("/")>=0||(l.parseCount++,l.parseTime+=measure(()=>{g=assemblyscript.parseFile(exports.libraryFiles[n],exports.libraryPrefix+n+".ts",!1,g)}))});const x=[];if(f.lib){let n=f.lib;"string"==typeof n&&(n=n.split(",")),Array.prototype.push.apply(x,n.map(n=>n.trim()));for(let n=0,e=x.length;n{g=assemblyscript.parseFile(a,exports.libraryPrefix+i,!1,g)})}}}function v(){for(var n,e;null!=(n=g.nextFile());){if(n.startsWith(exports.libraryPrefix)){const t=n.substring(exports.libraryPrefix.length),r=n.substring(exports.libraryPrefix.length)+"/index";if(exports.libraryFiles.hasOwnProperty(t))e=exports.libraryFiles[t],n=exports.libraryPrefix+t+".ts";else if(exports.libraryFiles.hasOwnProperty(r))e=exports.libraryFiles[r],n=exports.libraryPrefix+r+".ts";else for(let i=0,a=x.length;i{assemblyscript.parseFile(e,n,!1,g)})}if(checkDiagnostics(g,i))return t(Error("Parse error"))}{let n=String(f.runtime),e=exports.libraryFiles["rt/index-"+n];if(null==e&&null==(e=o(n+".ts",p)))return t(Error("Runtime template '"+n+"' not found."));l.parseCount++,l.parseTime+=measure(()=>{g=assemblyscript.parseFile(e,n,!0,g)})}for(let e=0,r=n.length;e{g=assemblyscript.parseFile(a,i,!0,g)})}{let n=v();if(n)return n}!function(n,...e){h.forEach(t=>{"function"==typeof t[n]&&t[n](...e)})}("afterParse",g);{let n=v();if(n)return n}const m=assemblyscript.finishParsing(g);var b=0,y=0;f.optimize&&(b=exports.defaultOptimizeLevel,y=exports.defaultShrinkLevel),"number"==typeof f.optimizeLevel&&(b=f.optimizeLevel),"number"==typeof f.shrinkLevel&&(y=f.shrinkLevel),b=Math.min(Math.max(b,0),3),y=Math.min(Math.max(y,0),2);const _=assemblyscript.createOptions();if(assemblyscript.setTarget(_,0),assemblyscript.setNoAssert(_,f.noAssert),assemblyscript.setImportMemory(_,f.importMemory),assemblyscript.setSharedMemory(_,f.sharedMemory),assemblyscript.setImportTable(_,f.importTable),assemblyscript.setMemoryBase(_,f.memoryBase>>>0),assemblyscript.setSourceMap(_,null!=f.sourceMap),assemblyscript.setOptimizeLevelHints(_,b,y),assemblyscript.setGlobalAlias(_,"Math","NativeMath"),assemblyscript.setGlobalAlias(_,"Mathf","NativeMathf"),assemblyscript.setGlobalAlias(_,"abort","~lib/builtins/abort"),assemblyscript.setGlobalAlias(_,"trace","~lib/builtins/trace"),f.use){let n=f.use;for(let e=0,r=n.length;e{T=assemblyscript.compileProgram(m,_)})}catch(n){return t(n)}if(checkDiagnostics(g,i))return T&&T.dispose(),t(Error("Compile error"));if(f.validate&&(l.validateCount++,l.validateTime+=measure(()=>{if(!T.validate())return T.dispose(),t(Error("Validate error"))})),"clamp"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(["trap-mode-clamp"])});else if("js"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(["trap-mode-js"])});else if("allow"!==f.trapMode)return T.dispose(),t(Error("Unsupported trap mode"));(b>=3||y>=2)&&(b=4),T.setOptimizeLevel(b),T.setShrinkLevel(y),T.setDebugInfo(f.debug);var A=[];if(f.runPasses&&("string"==typeof f.runPasses&&(f.runPasses=f.runPasses.split(",")),f.runPasses.length&&f.runPasses.forEach(n=>{A.indexOf(n)<0&&A.push(n)})),(b>0||y>0)&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{T.optimize()})),A.length&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(A.map(n=>n.trim()))})),!f.noEmit){let n=!1,e=!1;if(null!=f.outFile&&(/\.was?t$/.test(f.outFile)&&null==f.textFile?f.textFile=f.outFile:/\.js$/.test(f.outFile)&&null==f.asmjsFile?f.asmjsFile=f.outFile:null==f.binaryFile&&(f.binaryFile=f.outFile)),null!=f.binaryFile){let r,s=null!=f.sourceMap?f.sourceMap.length?f.sourceMap:path.basename(f.binaryFile)+".map":null;if(l.emitCount++,l.emitTime+=measure(()=>{r=T.toBinary(s)}),f.binaryFile.length?a(f.binaryFile,r.output,p):(I(r.output),n=!0),e=!0,null!=r.sourceMap)if(f.binaryFile.length){let n=JSON.parse(r.sourceMap);n.sourceRoot=exports.sourceMapRoot,n.sources.forEach((e,r)=>{let i=null;if(e.startsWith(exports.libraryPrefix)){let n=e.substring(exports.libraryPrefix.length).replace(/\.ts$/,"");if(exports.libraryFiles.hasOwnProperty(n))i=exports.libraryFiles[n];else for(let n=0,t=x.length;n{t=T.toAsmjs()}),a(f.asmjsFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=T.toAsmjs()}),I(t),n=!0),e=!0}if(null!=f.idlFile){let t;f.idlFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(m)}),a(f.idlFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(m)}),I(t),n=!0),e=!0}if(null!=f.tsdFile){let t;f.tsdFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(m)}),a(f.tsdFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(m)}),I(t),n=!0),e=!0}if(null!=f.textFile||!e){let e;f.textFile&&f.textFile.length?(l.emitCount++,l.emitTime+=measure(()=>{e=T.toText()}),a(f.textFile,e,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{e=T.toText()}),I(e))}}return T.dispose(),f.measure&&printStats(l,i),t(null);function F(n,e){try{let t;return l.readCount++,l.readTime+=measure(()=>{t=fs.readFileSync(path.join(e,n),{encoding:"utf8"})}),t}catch(n){return null}}function z(n,e,t){try{return l.writeCount++,l.writeTime+=measure(()=>{mkdirp(path.join(t,path.dirname(n))),"string"==typeof e?fs.writeFileSync(path.join(t,n),e,{encoding:"utf8"}):fs.writeFileSync(path.join(t,n),e)}),!0}catch(n){return!1}}function S(n,e){var t;try{return l.readTime+=measure(()=>{t=fs.readdirSync(path.join(e,n)).filter(n=>/^(?!.*\.d\.ts$).*\.ts$/.test(n))}),t}catch(n){return[]}}function I(n){I.used||(l.writeCount++,I.used=!0),l.writeTime+=measure(()=>{"string"==typeof n?r.write(n,{encoding:"utf8"}):r.write(n)})}},exports.checkDiagnostics=checkDiagnostics,exports.createStats=createStats,process.hrtime||(process.hrtime=__webpack_require__(13)),exports.measure=measure,exports.formatTime=formatTime,exports.printStats=printStats;var allocBuffer=void 0!==global&&global.Buffer?global.Buffer.allocUnsafe||function(n){return new global.Buffer(n)}:function(n){return new Uint8Array(n)};function createMemoryStream(n){var e=[];return e.write=function(e){if(n&&n(e),"string"==typeof e){let n=allocBuffer(utf8.length(e));utf8.write(e,n,0),e=n}this.push(e)},e.reset=function(){e.length=0},e.toBuffer=function(){for(var n=0,e=0,t=this.length;e191&&r<224?o[a++]=(31&r)<<6|63&n[e++]:r>239&&r<365?(r=((7&r)<<18|(63&n[e++])<<12|(63&n[e++])<<6|63&n[e++])-65536,o[a++]=55296+(r>>10),o[a++]=56320+(1023&r)):o[a++]=(15&r)<<12|(63&n[e++])<<6|63&n[e++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))},r.write=function(n,e,t){for(var r,i,o=t,a=0;a>6|192,e[t++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=n.charCodeAt(a+1)))?(r=65536+((1023&r)<<10)+(1023&i),++a,e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=63&r|128):(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=63&r|128);return t-o}},function(n,e,t){(function(n){var t=void 0!==n&&n||{},r=t.env&&"CI"in t.env;function i(n,t){var i=t||{};return i.supported=n&&!!n.isTTY||r,i.gray=(n=>i.supported?e.GRAY+n+e.RESET:n),i.red=(n=>i.supported?e.RED+n+e.RESET:n),i.green=(n=>i.supported?e.GREEN+n+e.RESET:n),i.yellow=(n=>i.supported?e.YELLOW+n+e.RESET:n),i.blue=(n=>i.supported?e.BLUE+n+e.RESET:n),i.magenta=(n=>i.supported?e.MAGENTA+n+e.RESET:n),i.cyan=(n=>i.supported?e.CYAN+n+e.RESET:n),i.white=(n=>i.supported?e.WHITE+n+e.RESET:n),i}e.stdout=i(t.stdout,e),e.stderr=i(t.stderr),e.from=i,e.GRAY="",e.RED="",e.GREEN="",e.YELLOW="",e.BLUE="",e.MAGENTA="",e.CYAN="",e.WHITE="",e.RESET=""}).call(this,t(0))},function(n,e){e.parse=function(n,e){var t={},r=[],arguments=[],i=[],o={};Object.keys(e).forEach(n=>{if(!n.startsWith(" ")){var r=e[n];null!=r.alias&&("string"==typeof r.alias?o[r.alias]=n:Array.isArray(r.alias)&&r.alias.forEach(e=>o[e]=n)),null!=r.default&&(t[n]=r.default)}});for(var a=0,s=(n=n.slice()).length;at[n]=s.value[n])}else r.push(i)}for(;a{var a=n[e];if(null!=a.description){for(var s="";s.length{for(let e=0;e=0;r--){var i=n[r];"."===i?n.splice(r,1):".."===i?(n.splice(r,1),t++):t&&(n.splice(r,1),t--)}if(e)for(;t--;t)n.unshift("..");return n}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(n){return r.exec(n).slice(1)};function o(n,e){if(n.filter)return n.filter(e);for(var t=[],r=0;r=-1&&!r;i--){var a=i>=0?arguments[i]:n.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,r="/"===a.charAt(0))}return(r?"/":"")+(e=t(o(e.split("/"),function(n){return!!n}),!r).join("/"))||"."},e.normalize=function(n){var r=e.isAbsolute(n),i="/"===a(n,-1);return(n=t(o(n.split("/"),function(n){return!!n}),!r).join("/"))||r||(n="."),n&&i&&(n+="/"),(r?"/":"")+n},e.isAbsolute=function(n){return"/"===n.charAt(0)},e.join=function(){var n=Array.prototype.slice.call(arguments,0);return e.normalize(o(n,function(n,e){if("string"!=typeof n)throw new TypeError("Arguments to path.join must be strings");return n}).join("/"))},e.relative=function(n,t){function r(n){for(var e=0;e=0&&""===n[t];t--);return e>t?[]:n.slice(e,t-e+1)}n=e.resolve(n).substr(1),t=e.resolve(t).substr(1);for(var i=r(n.split("/")),o=r(t.split("/")),a=Math.min(i.length,o.length),s=a,l=0;l{try{assemblyscript=__webpack_require__(10)}catch(e){try{__webpack_require__(!function(){var n=new Error("Cannot find module 'ts-node'");throw n.code="MODULE_NOT_FOUND",n}()).register({project:path.join(".","..","src","tsconfig.json")}),__webpack_require__(!function(){var n=new Error("Cannot find module '../src/glue/js'");throw n.code="MODULE_NOT_FOUND",n}()),assemblyscript=__webpack_require__(!function(){var n=new Error("Cannot find module '../src'");throw n.code="MODULE_NOT_FOUND",n}()),isDev=!0}catch(e_ts){try{assemblyscript=eval("require('./assemblyscript')")}catch(n){throw n.stack=e_ts.stack+"\n---\n"+n.stack,n}}}})(),exports.isBundle=!0,exports.isDev=isDev,exports.version=exports.isBundle?"0.7.0":__webpack_require__(!function(){var n=new Error("Cannot find module '../package.json'");throw n.code="MODULE_NOT_FOUND",n}()).version,exports.options=__webpack_require__(11),exports.sourceMapRoot="assemblyscript:///",exports.libraryPrefix=assemblyscript.LIBRARY_PREFIX,exports.defaultOptimizeLevel=3,exports.defaultShrinkLevel=1,exports.libraryFiles=exports.isBundle?Object({array:'/// \n\nimport { BLOCK_MAXSIZE } from "./rt/common";\nimport { COMPARATOR, SORT } from "./util/sort";\nimport { ArrayBuffer, ArrayBufferView } from "./arraybuffer";\nimport { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./util/number";\nimport { idof, isArray as builtin_isArray } from "./builtins";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";\n\n/** Ensures that the given array has _at least_ the specified backing size. */\nfunction ensureSize(array: usize, minSize: usize, alignLog2: u32): void {\n var oldCapacity = changetype(array).dataLength;\n if (minSize > oldCapacity >>> alignLog2) {\n if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n let oldData = changetype(changetype(array).data);\n let newCapacity = minSize << alignLog2;\n let newData = __realloc(oldData, newCapacity);\n memory.fill(newData + oldCapacity, 0, newCapacity - oldCapacity);\n if (newData !== oldData) { // oldData has been free\'d\n store(changetype(array), __retain(newData), offsetof("data"));\n changetype(array).dataStart = newData;\n }\n changetype(array).dataLength = newCapacity;\n }\n}\n\nexport class Array extends ArrayBufferView {\n [key: number]: T;\n\n // Implementing ArrayBufferView isn\'t strictly necessary here but is done to allow glue code\n // to work with typed and normal arrays interchangeably. Technically, normal arrays do not need\n // `dataStart` (equals `data`) and `dataLength` (equals computed `data.byteLength`).\n\n // Also note that Array with non-nullable T must guard against implicit null values whenever\n // length is modified in a way that a null value would exist. Otherwise, the compiler wouldn\'t be\n // able to guarantee type-safety anymore. For lack of a better word, such an array is "holey".\n\n private length_: i32;\n\n static isArray(value: U): bool {\n return builtin_isArray(value) && value !== null;\n }\n\n static create(capacity: i32 = 0): Array {\n if (capacity > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH);\n var array = changetype>(__allocArray(capacity, alignof(), idof())); // retains\n changetype>(array).length_ = 0; // safe even if T is a non-nullable reference\n memory.fill(array.dataStart, 0, array.dataLength);\n return array;\n }\n\n constructor(length: i32 = 0) {\n super(length, alignof());\n if (isReference()) {\n if (!isNullable()) {\n if (length) throw new Error(E_HOLEYARRAY);\n }\n }\n this.length_ = length;\n }\n\n @unsafe get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.length_;\n }\n\n set length(length: i32) {\n if (isReference()) {\n if (!isNullable()) {\n if (length > this.length_) throw new Error(E_HOLEYARRAY);\n }\n }\n ensureSize(changetype(this), length, alignof());\n this.length_ = length;\n }\n\n every(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (!callbackfn(load(this.dataStart + (index << alignof())), index, this)) return false;\n }\n return true;\n }\n\n findIndex(predicate: (element: T, index: i32, array: Array) => bool): i32 {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (predicate(load(this.dataStart + (index << alignof())), index, this)) return index;\n }\n return -1;\n }\n\n @operator("[]") private __get(index: i32): T {\n if (isReference()) {\n if (!isNullable()) {\n if (index >= this.length_) throw new Error(E_HOLEYARRAY);\n }\n }\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_get(index);\n }\n\n @operator("{}") private __unchecked_get(index: i32): T {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") private __set(index: i32, value: T): void {\n var length = this.length_;\n if (isReference()) {\n if (!isNullable()) {\n if (index > length) throw new Error(E_HOLEYARRAY);\n }\n }\n ensureSize(changetype(this), index + 1, alignof());\n this.__unchecked_set(index, value);\n if (index >= length) this.length_ = index + 1;\n }\n\n @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = this.dataStart + (index << alignof());\n let oldRef: usize = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n store(this.dataStart + (index << alignof()), value);\n }\n }\n\n fill(value: T, start: i32 = 0, end: i32 = i32.MAX_VALUE): this {\n var dataStart = this.dataStart;\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n end = end < 0 ? max(length + end, 0) : min(end, length);\n if (sizeof() == 1) {\n if (start < end) {\n memory.fill(\n dataStart + start,\n u8(value),\n (end - start)\n );\n }\n } else {\n for (; start < end; ++start) {\n store(dataStart + (start << alignof()), value);\n }\n }\n return this;\n }\n\n includes(searchElement: T, fromIndex: i32 = 0): bool {\n return this.indexOf(searchElement, fromIndex) >= 0;\n }\n\n indexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n var length = this.length_;\n if (length == 0 || fromIndex >= length) return -1;\n if (fromIndex < 0) fromIndex = max(length + fromIndex, 0);\n var dataStart = this.dataStart;\n while (fromIndex < length) {\n if (load(dataStart + (fromIndex << alignof())) == searchElement) return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(searchElement: T, fromIndex: i32 = this.length_): i32 {\n var length = this.length_;\n if (length == 0) return -1;\n if (fromIndex < 0) fromIndex = length + fromIndex;\n else if (fromIndex >= length) fromIndex = length - 1;\n var dataStart = this.dataStart;\n while (fromIndex >= 0) {\n if (load(dataStart + (fromIndex << alignof())) == searchElement) return fromIndex;\n --fromIndex;\n }\n return -1;\n }\n\n push(value: T): i32 {\n var length = this.length_;\n var newLength = length + 1;\n ensureSize(changetype(this), newLength, alignof());\n if (isManaged()) {\n let offset = this.dataStart + (length << alignof());\n let oldRef: usize = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n store(this.dataStart + (length << alignof()), value);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n concat(other: Array): Array {\n var thisLen = this.length_;\n var otherLen = select(0, other.length_, other === null);\n var outLen = thisLen + otherLen;\n if (outLen > BLOCK_MAXSIZE >>> alignof()) throw new Error(E_INVALIDLENGTH);\n var out = changetype>(__allocArray(outLen, alignof(), idof>())); // retains\n var outStart = out.dataStart;\n var thisSize = thisLen << alignof();\n if (isManaged()) {\n let thisStart = this.dataStart;\n for (let offset: usize = 0; offset < thisSize; offset += sizeof()) {\n let ref = load(thisStart + offset);\n store(outStart + offset, __retain(ref));\n }\n outStart += thisSize;\n let otherStart = other.dataStart;\n let otherSize = otherLen << alignof();\n for (let offset: usize = 0; offset < otherSize; offset += sizeof()) {\n let ref = load(otherStart + offset);\n store(outStart + offset, __retain(ref));\n }\n } else {\n memory.copy(outStart, this.dataStart, thisSize);\n memory.copy(outStart + thisSize, other.dataStart, otherLen << alignof());\n }\n return out;\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): this {\n var dataStart = this.dataStart;\n var len = this.length_;\n\n end = min(end, len);\n var to = target < 0 ? max(len + target, 0) : min(target, len);\n var from = start < 0 ? max(len + start, 0) : min(start, len);\n var last = end < 0 ? max(len + end, 0) : min(end, len);\n var count = min(last - from, len - to);\n\n if (from < to && to < (from + count)) {\n from += count - 1;\n to += count - 1;\n while (count) {\n store(dataStart + (to << alignof()), load(dataStart + (from << alignof())));\n --from, --to, --count;\n }\n } else {\n memory.copy(\n dataStart + (to << alignof()),\n dataStart + (from << alignof()),\n count << alignof()\n );\n }\n return this;\n }\n\n pop(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError(E_EMPTYARRAY);\n var element = load(this.dataStart + ((--length) << alignof()));\n this.length_ = length;\n return element;\n }\n\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n callbackfn(load(this.dataStart + (index << alignof())), index, this);\n }\n }\n\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array {\n var length = this.length_;\n var out = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var outStart = out.dataStart;\n for (let index = 0; index < min(length, this.length_); ++index) {\n let result = callbackfn(load(this.dataStart + (index << alignof())), index, this); // retains\n if (isManaged()) {\n store(outStart + (index << alignof()), __retain(changetype(result)));\n } else {\n store(outStart + (index << alignof()), result);\n }\n // releases result\n }\n return out;\n }\n\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array {\n var result = changetype>(__allocArray(0, alignof(), idof>())); // retains\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n let value = load(this.dataStart + (index << alignof()));\n if (callbackfn(value, index, this)) result.push(value);\n }\n return result;\n }\n\n reduce(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n accum = callbackfn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n reduceRight(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = this.length_ - 1; index >= 0; --index) {\n accum = callbackfn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n shift(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError(E_EMPTYARRAY);\n var base = this.dataStart;\n var element = load(base);\n var lastIndex = length - 1;\n memory.copy(\n base,\n base + sizeof(),\n lastIndex << alignof()\n );\n store(base + (lastIndex << alignof()),\n // @ts-ignore: cast\n null\n );\n this.length_ = lastIndex;\n return element;\n }\n\n some(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (callbackfn(load(this.dataStart + (index << alignof())), index, this)) return true;\n }\n return false;\n }\n\n unshift(element: T): i32 {\n var newLength = this.length_ + 1;\n ensureSize(changetype(this), newLength, alignof());\n var dataStart = this.dataStart;\n memory.copy(\n dataStart + sizeof(),\n dataStart,\n (newLength - 1) << alignof()\n );\n if (isManaged()) {\n store(dataStart, __retain(changetype(element)));\n } else {\n store(dataStart, element);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n begin = begin < 0 ? max(begin + length, 0) : min(begin, length);\n end = end < 0 ? max(end + length, 0) : min(end , length);\n length = max(end - begin, 0);\n var slice = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var sliceBase = slice.dataStart;\n var thisBase = this.dataStart + (begin << alignof());\n if (isManaged()) {\n let off = 0;\n let end = length << alignof();\n while (off < end) {\n let ref = load(thisBase + off);\n store(sliceBase + off, __retain(ref));\n off += sizeof();\n }\n } else {\n memory.copy(sliceBase, thisBase, length << alignof());\n }\n return slice;\n }\n\n splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n deleteCount = max(min(deleteCount, length - start), 0);\n var result = changetype>(__allocArray(deleteCount, alignof(), idof>())); // retains\n var resultStart = result.dataStart;\n var thisStart = this.dataStart;\n var thisBase = thisStart + (start << alignof());\n if (isManaged()) {\n for (let i = 0; i < deleteCount; ++i) {\n store(resultStart + (i << alignof()),\n load(thisBase + (i << alignof()))\n );\n // element is moved, so refcount doesn\'t change\n }\n } else {\n memory.copy(\n resultStart,\n thisBase,\n deleteCount << alignof()\n );\n }\n var offset = start + deleteCount;\n if (length != offset) {\n memory.copy(\n thisBase,\n thisStart + (offset << alignof()),\n (length - offset) << alignof()\n );\n }\n this.length_ = length - deleteCount;\n return result;\n }\n\n reverse(): Array {\n var length = this.length_;\n if (length) {\n let front = this.dataStart;\n let back = this.dataStart + ((length - 1) << alignof());\n while (front < back) {\n let temp = load(front);\n store(front, load(back));\n store(back, temp);\n front += sizeof();\n back -= sizeof();\n }\n }\n return this;\n }\n\n sort(comparator: (a: T, b: T) => i32 = COMPARATOR()): this {\n var length = this.length_;\n if (length <= 1) return this;\n var base = this.dataStart;\n if (length == 2) {\n let a: T = load(base, sizeof()); // a = arr[1]\n let b: T = load(base); // b = arr[0]\n if (comparator(a, b) < 0) {\n store(base, b, sizeof()); // arr[1] = b;\n store(base, a); // arr[0] = a;\n }\n return this;\n }\n SORT(base, length, comparator);\n return this;\n }\n\n join(separator: string = ","): string {\n if (isBoolean()) return this.join_bool(separator);\n if (isInteger()) return this.join_int(separator);\n if (isFloat()) return this.join_flt(separator);\n if (isString()) return this.join_str(separator);\n if (isArray()) return this.join_arr(separator);\n if (isReference()) return this.join_ref(separator);\n ERROR("unspported element type");\n return unreachable();\n }\n\n private join_bool(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) return select("true", "false", load(dataStart));\n\n var sepLen = separator.length;\n var valueLen = 5; // max possible length of element len("false")\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: bool;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + i);\n valueLen = 4 + i32(!value);\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(select("true", "false", value)),\n valueLen << 1\n );\n offset += valueLen;\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + lastIndex);\n valueLen = 4 + i32(!value);\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(select("true", "false", value)),\n valueLen << 1\n );\n offset += valueLen;\n\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_int(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n // @ts-ignore: type\n if (!lastIndex) return changetype(itoa(load(dataStart))); // retains\n\n var sepLen = separator.length;\n const valueLen = (sizeof() <= 4 ? 10 : 20) + i32(isSigned());\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n // @ts-ignore: type\n offset += itoa_stream(changetype(result), offset, value);\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n // @ts-ignore: type\n offset += itoa_stream(changetype(result), offset, value);\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_flt(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) {\n return changetype(dtoa(\n // @ts-ignore: type\n load(dataStart))\n ); // retains\n }\n\n const valueLen = MAX_DOUBLE_LENGTH;\n var sepLen = separator.length;\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof())); // retains\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n offset += dtoa_stream(changetype(result), offset,\n // @ts-ignore: type\n value\n );\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n offset += dtoa_stream(changetype(result), offset,\n // @ts-ignore: type\n value\n );\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n private join_str(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var dataStart = this.dataStart;\n if (!lastIndex) return load(dataStart);\n\n var sepLen = separator.length;\n var estLen = 0;\n var value: string | null;\n for (let i = 0, len = lastIndex + 1; i < len; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) estLen += value.length;\n }\n var offset = 0;\n var result = changetype(__alloc((estLen + sepLen * lastIndex) << 1, idof())); // retains\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) {\n let valueLen = changetype(value).length;\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(value),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n value = load(dataStart + (lastIndex << alignof()));\n if (value !== null) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(value),\n changetype(value).length << 1\n );\n }\n return result;\n }\n\n private join_arr(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n\n var result = "";\n var sepLen = separator.length;\n var base = this.dataStart;\n var value: T;\n if (!lastIndex) {\n value = load(base);\n // @ts-ignore: type\n return value ? value.join(separator) : "";\n }\n for (let i = 0; i < lastIndex; ++i) {\n value = load(base + (i << alignof()));\n // @ts-ignore: type\n if (value) result += value.join(separator);\n if (sepLen) result += separator;\n }\n value = load(base + (lastIndex << alignof()));\n // @ts-ignore: type\n if (value) result += value.join(separator);\n return result; // registered by concatenation (FIXME: lots of garbage)\n }\n\n private join_ref(separator: string = ","): string {\n var lastIndex = this.length_ - 1;\n if (lastIndex < 0) return "";\n var base = this.dataStart;\n if (!lastIndex) return "[object Object]";\n\n const valueLen = 15; // max possible length of element len("[object Object]")\n var sepLen = separator.length;\n var estLen = (valueLen + sepLen) * lastIndex + valueLen;\n var result = changetype(__alloc(estLen << 1, idof()));\n var offset = 0;\n var value: T;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(base + (i << alignof()));\n if (value) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype("[object Object]"),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype(separator),\n sepLen << 1\n );\n offset += sepLen;\n }\n }\n if (load(base + (lastIndex << alignof()))) {\n memory.copy(\n changetype(result) + (offset << 1),\n changetype("[object Object]"),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (estLen > offset) return result.substring(0, offset);\n return result;\n }\n\n toString(): string {\n return this.join();\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n if (isManaged()) {\n let cur = this.dataStart;\n let end = cur + this.dataLength;\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n // automatically visits ArrayBufferView (.data) next\n }\n}\n',arraybuffer:'/// \n\nimport { BLOCK, BLOCK_MAXSIZE, BLOCK_OVERHEAD } from "./rt/common";\nimport { idof } from "./builtins";\nimport { E_INVALIDLENGTH } from "./util/error";\n\nexport abstract class ArrayBufferView {\n\n @unsafe data: ArrayBuffer;\n @unsafe dataStart: usize;\n @unsafe dataLength: u32;\n\n protected constructor(length: i32, alignLog2: i32) {\n if (length > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n var buffer = __alloc(length = length << alignLog2, idof());\n this.data = changetype(buffer); // retains\n this.dataStart = buffer;\n this.dataLength = length;\n }\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.data));\n }\n\n get byteLength(): i32 {\n return this.dataLength;\n }\n\n get length(): i32 {\n ERROR("missing implementation: subclasses must implement ArrayBufferView#length");\n return unreachable();\n }\n}\n\n@sealed export class ArrayBuffer {\n\n static isView(value: T): bool {\n if (value) {\n if (value instanceof Int8Array) return true;\n if (value instanceof Uint8Array) return true;\n if (value instanceof Uint8ClampedArray) return true;\n if (value instanceof Int16Array) return true;\n if (value instanceof Uint16Array) return true;\n if (value instanceof Int32Array) return true;\n if (value instanceof Uint32Array) return true;\n if (value instanceof Int64Array) return true;\n if (value instanceof Uint64Array) return true;\n if (value instanceof Float32Array) return true;\n if (value instanceof Float64Array) return true;\n if (value instanceof DataView) return true;\n }\n return false;\n }\n\n constructor(length: i32) {\n if (length > BLOCK_MAXSIZE) throw new RangeError(E_INVALIDLENGTH);\n var buffer = __alloc(length, idof());\n memory.fill(buffer, 0, length);\n return changetype(buffer); // retains\n }\n\n get byteLength(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize;\n }\n\n slice(begin: i32 = 0, end: i32 = BLOCK_MAXSIZE): ArrayBuffer {\n var length = this.byteLength;\n begin = begin < 0 ? max(length + begin, 0) : min(begin, length);\n end = end < 0 ? max(length + end , 0) : min(end , length);\n var outSize = max(end - begin, 0);\n var out = __alloc(outSize, idof());\n memory.copy(out, changetype(this) + begin, outSize);\n return changetype(out); // retains\n }\n\n toString(): string {\n return "[object ArrayBuffer]";\n }\n}\n',"bindings/Date":"export declare function UTC(\n // NOTE: Using i32 below saves us a f64.convert_s instruction and moves the responsibility for\n // converting the value to the WASM/JS boundary.\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: f64\n): f64;\nexport declare function now(): f64;\n","bindings/Math":"export declare const E: f64;\nexport declare const LN2: f64;\nexport declare const LN10: f64;\nexport declare const LOG2E: f64;\nexport declare const LOG10E: f64;\nexport declare const PI: f64;\nexport declare const SQRT1_2: f64;\nexport declare const SQRT2: f64;\n\nexport declare function abs(x: f64): f64;\nexport declare function acos(x: f64): f64;\nexport declare function acosh(x: f64): f64;\nexport declare function asin(x: f64): f64;\nexport declare function asinh(x: f64): f64;\nexport declare function atan(x: f64): f64;\nexport declare function atan2(y: f64, x: f64): f64;\nexport declare function atanh(x: f64): f64;\nexport declare function cbrt(x: f64): f64;\nexport declare function ceil(x: f64): f64;\nexport declare function clz32(x: f64): f64;\nexport declare function cos(x: f64): f64;\nexport declare function cosh(x: f64): f64;\nexport declare function exp(x: f64): f64;\nexport declare function expm1(x: f64): f64;\nexport declare function floor(x: f64): f64;\nexport declare function fround(x: f64): f32;\nexport declare function hypot(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function imul(a: f64, b: f64): f64;\nexport declare function log(x: f64): f64;\nexport declare function log10(x: f64): f64;\nexport declare function log1p(x: f64): f64;\nexport declare function log2(x: f64): f64;\nexport declare function max(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function min(value1: f64, value2: f64): f64; // TODO: rest\nexport declare function pow(base: f64, exponent: f64): f64;\nexport declare function random(): f64;\nexport declare function round(x: f64): f64;\nexport declare function sign(x: f64): f64;\nexport declare function sin(x: f64): f64;\nexport declare function sinh(x: f64): f64;\nexport declare function sqrt(x: f64): f64;\nexport declare function tan(x: f64): f64;\nexport declare function tanh(x: f64): f64;\nexport declare function trunc(x: f64): f64;\n","bindings/wasi_unstable":"// see: https://wasi.dev\n\n/* tslint:disable:max-line-length */\n\n// helper types to be more explicit\ntype char = u8;\ntype ptr = usize; // all pointers are usize'd\ntype struct = T; // structs are references already in AS\n\n/** Read command-line argument data. */\nexport declare function args_get(\n /** Input: Pointer to a buffer to write the argument pointers. */\n argv: ptr>,\n /** Input: Pointer to a buffer to write the argument string data. */\n argv_buf: ptr\n): errno;\n\n/** Return command-line argument data sizes. */\nexport declare function args_sizes_get(\n /** Output: Number of arguments. */\n argc: ptr,\n /** Output: Size of the argument string data. */\n argv_buf_size: ptr\n): errno;\n\n/** Return the resolution of a clock. */\nexport declare function clock_res_get(\n /** Input: The clock for which to return the resolution. */\n clock: clockid,\n /** Output: The resolution of the clock. */\n resolution: ptr\n): errno;\n\n/** Return the time value of a clock. */\nexport declare function clock_time_get(\n /** Input: Cock for which to return the time. */\n clock: clockid,\n /** Input: Maximum lag (exclusive) that the returned time value may have, compared to its actual value. */\n precision: timestamp,\n /** Output: Time value of the clock. */\n time: ptr\n): errno;\n\n/** Read environment variable data. */\nexport declare function environ_get(\n /** Input: Pointer to a buffer to write the environment variable pointers. */\n environ: ptr,\n /** Input: Pointer to a buffer to write the environment variable string data. */\n environ_buf: usize\n): errno;\n\n/** Return command-line argument data sizes. */\nexport declare function environ_sizes_get(\n /** Output: The number of environment variables. */\n environ_count: ptr,\n /** Output: The size of the environment variable string data. */\n environ_buf_size: ptr\n): errno;\n\n/** Provide file advisory information on a file descriptor. */\nexport declare function fd_advise(\n /** Input: The file descriptor for the file for which to provide file advisory information. */\n fd: fd,\n /** Input: The offset within the file to which the advisory applies. */\n offset: filesize,\n /** Input: The length of the region to which the advisory applies. */\n len: filesize,\n /** Input: The advice. */\n advice: advice\n): errno;\n\n/** Provide file advisory information on a file descriptor. */\nexport declare function fd_allocate(\n /** Input: The file descriptor for the file in which to allocate space. */\n fd: fd,\n /** Input: The offset at which to start the allocation. */\n offset: filesize,\n /** Input: The length of the area that is allocated. */\n len: filesize\n): errno;\n\n/** Close a file descriptor. */\nexport declare function fd_close(\n /** Input: The file descriptor to close. */\n fd: fd\n): errno;\n\n/** Synchronize the data of a file to disk. */\nexport declare function fd_datasync(\n /** Input: The file descriptor of the file to synchronize to disk. */\n fd: fd\n): errno;\n\n/** Get the attributes of a file descriptor. */\nexport declare function fd_fdstat_get(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Input: The buffer where the file descriptor's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the flags associated with a file descriptor. */\nexport declare function fd_fdstat_set_flags(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired values of the file descriptor flags. */\n flags: fdflags\n): errno;\n\n/** Adjust the rights associated with a file descriptor. */\nexport declare function fd_fdstat_set_rights(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired rights of the file descriptor. */\n fs_rights_base: rights,\n /** Input: The desired rights of the file descriptor. */\n fs_rights_inheriting: rights\n): errno;\n\n/** Return the attributes of an open file. */\nexport declare function fd_filestat_get(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Input: The buffer where the file's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros. */\nexport declare function fd_filestat_set_size(\n /** Input: A file descriptor for the file to adjust. */\n fd: fd,\n /** Input: The desired file size. */\n size: filesize\n): errno;\n\n/** Adjust the timestamps of an open file or directory. */\nexport declare function fd_filestat_set_times(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The desired values of the data access timestamp. */\n st_atim: timestamp,\n /** Input: The desired values of the data modification timestamp. */\n st_mtim: timestamp,\n /** Input: A bitmask indicating which timestamps to adjust. */\n fstflags: fstflags\n): errno;\n\n/** Read from a file descriptor, without using and updating the file descriptor's offset. */\nexport declare function fd_pread(\n /** Input: The file descriptor from which to read data. */\n fd: fd,\n /** Input: List of scatter/gather vectors in which to store data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors in which to store data. */\n iovs_len: usize,\n /** Input: The offset within the file at which to read. */\n offset: filesize,\n /** Output: The number of bytes read. */\n nread: ptr\n): errno;\n\n/** Return a description of the given preopened file descriptor. */\nexport declare function fd_prestat_get(\n /** Input: The file descriptor about which to retrieve information. */\n fd: fd,\n /** Input: The buffer where the description is stored. */\n buf: struct\n): errno;\n\n/** Return a description of the given preopened file descriptor. */\nexport declare function fd_prestat_dir_name(\n /** Input: The file descriptor about which to retrieve information. */\n fd: fd,\n /** Input: Buffer into which to write the preopened directory name. */\n path: ptr,\n /** Input: Length of the buffer into which to write the preopened directory name. */\n path_len: usize\n): errno;\n\n/** Write to a file descriptor, without using and updating the file descriptor's offset. */\nexport declare function fd_pwrite(\n /** Input: The file descriptor to which to write data. */\n fd: fd,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors from which to retrieve data. */\n iovs_len: usize,\n /** Input: The offset within the file at which to write. */\n offset: filesize,\n /** Output: The number of bytes written. */\n nwritten: ptr\n): errno;\n\n/** Read from a file descriptor. */\nexport declare function fd_read(\n /** Input: The file descriptor from which to read data. */\n fd: fd,\n /** Input: List of scatter/gather vectors to which to store data. */\n iovs: ptr>,\n /** Input: Length of the list of scatter/gather vectors to which to store data. */\n iovs_len: usize,\n /** Output: The number of bytes read. */\n nread: ptr\n): errno;\n\n/** Read directory entries from a directory. */\nexport declare function fd_readdir(\n /** Input: Directory from which to read the directory entries. */\n fd: fd,\n /** Input: Buffer where directory entries are stored. */\n buf: ptr>,\n /** Input: Length of the buffer where directory entries are stored. */\n buf_len: usize,\n /** Input: Location within the directory to start reading. */\n cookie: dircookie,\n /** Output: Number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached. */\n buf_used: ptr\n): errno;\n\n/** Atomically replace a file descriptor by renumbering another file descriptor. */\nexport declare function fd_renumber(\n /** Input: The file descriptor to renumber. */\n from: fd,\n /** Input: The file descriptor to overwrite. */\n to: fd\n): errno;\n\n/** Move the offset of a file descriptor. */\nexport declare function fd_seek(\n /** Input: The file descriptor to operate on. */\n fd: fd,\n /** Input: The number of bytes to move. */\n offset: filedelta,\n /** Input: The base from which the offset is relative. */\n whence: whence,\n /** Output: The new offset of the file descriptor, relative to the start of the file. */\n newoffset: ptr\n): errno;\n\n/** Synchronize the data and metadata of a file to disk. */\nexport declare function fd_sync(\n /** Input: The file descriptor of the file containing the data and metadata to synchronize to disk. */\n fd: fd\n): errno;\n\n/** Return the current offset of a file descriptor. */\nexport declare function fd_tell(\n /** Input: The file descriptor to inspect. */\n fd: fd,\n /** Output: The current offset of the file descriptor, relative to the start of the file. */\n newoffset: ptr\n): errno;\n\n/** Write to a file descriptor. */\nexport declare function fd_write(\n /** Input: The file descriptor to which to write data. */\n fd: fd,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs: ptr>,\n /** Input: List of scatter/gather vectors from which to retrieve data. */\n iovs_len: usize,\n /** Output: The number of bytes written. */\n nwritten: ptr\n): errno;\n\n/* Create a directory. */\nexport declare function path_create_directory(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path at which to create the directory. */\n path: ptr,\n /** Input: The path at which to create the directory. */\n path_len: usize\n): errno;\n\n/** Return the attributes of a file or directory. */\nexport declare function path_filestat_get(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n flags: lookupflags,\n /** Input: The path of the file or directory to inspect. */\n path: ptr,\n /** Input: The path of the file or directory to inspect. */\n path_len: usize,\n /** Input: The buffer where the file's attributes are stored. */\n buf: struct\n): errno;\n\n/** Adjust the timestamps of a file or directory. */\nexport declare function path_filestat_set_times(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n flags: lookupflags,\n /** Input: The path of the file or directory to operate on. */\n path: ptr,\n /** Input: The path of the file or directory to operate on. */\n path_len: usize,\n /** Input: The desired values of the data access timestamp. */\n st_atim: timestamp,\n /** Input: The desired values of the data modification timestamp. */\n st_mtim: timestamp,\n /** Input: A bitmask indicating which timestamps to adjust. */\n fstflags: fstflags\n): errno;\n\n/** Create a hard link. */\nexport declare function path_link(\n /** Input: The working directory at which the resolution of the old path starts. */\n old_fd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n old_flags: lookupflags,\n /** Input: The source path from which to link. */\n old_path: ptr,\n /** Input: The source path from which to link. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the new path starts. */\n new_fd: fd,\n /** Input: The destination path at which to create the hard link. */\n new_path: ptr,\n /** Input: The length of the destination path at which to create the hard link. */\n new_path_len: usize\n): errno;\n\n/** Open a file or directory. */\nexport declare function path_open(\n /** Input: The working directory at which the resolution of the path starts. */\n dirfd: fd,\n /** Input: Flags determining the method of how the path is resolved. */\n dirflags: lookupflags,\n /** Input: The path of the file or directory to open. */\n path: ptr,\n /** Input: The length of the path of the file or directory to open. */\n path_len: usize,\n /** Input: The method by which to open the file. */\n oflags: oflags,\n /** Input: The initial base rights that apply to operations using the file descriptor itself. */\n fs_rights_base: rights,\n /** Input: The initial inheriting rights that apply to file descriptors derived from it. */\n fs_rights_inheriting: rights,\n /** Input: The initial flags of the file descriptor. */\n fs_flags: fdflags,\n /** Output: The file descriptor of the file that has been opened. */\n fd: ptr\n): errno;\n\n/** Read the contents of a symbolic link. */\nexport declare function path_readlink(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path of the symbolic link from which to read. */\n path: ptr,\n /** Input: The length of the path of the symbolic link from which to read. */\n path_len: usize,\n /** Input: The buffer to which to write the contents of the symbolic link. */\n buf: ptr,\n /** Input: The length of the buffer to which to write the contents of the symbolic link. */\n buf_len: usize,\n /** Output: The number of bytes placed in the buffer. */\n buf_used: ptr\n): errno;\n\n/** Remove a directory. */\nexport declare function path_remove_directory(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path to a directory to remove. */\n path: ptr,\n /** Input: The length of the path to a directory to remove. */\n path_len: usize\n): errno;\n\n/** Rename a file or directory. */\nexport declare function path_rename(\n /** Input: The working directory at which the resolution of the old path starts. */\n old_fd: fd,\n /** Input: The source path of the file or directory to rename. */\n old_path: ptr,\n /** Input: The length of the source path of the file or directory to rename. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the new path starts. */\n new_fd: fd,\n /** Input: The destination path to which to rename the file or directory. */\n new_path: ptr,\n /** Input: The length of the destination path to which to rename the file or directory. */\n new_path_len: usize\n): errno;\n\n/** Create a symbolic link. */\nexport declare function path_symlink(\n /** Input: The contents of the symbolic link. */\n old_path: ptr,\n /** Input: The length of the contents of the symbolic link. */\n old_path_len: usize,\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The destination path at which to create the symbolic link. */\n new_path: ptr,\n /** Input: The length of the destination path at which to create the symbolic link. */\n new_path_len: usize\n): errno;\n\n/** Unlink a file. */\nexport declare function path_unlink_file(\n /** Input: The working directory at which the resolution of the path starts. */\n fd: fd,\n /** Input: The path to a file to unlink. */\n path: ptr,\n /** Input: The length of the path to a file to unlink. */\n path_len: usize\n): errno;\n\n/** Concurrently poll for the occurrence of a set of events. */\nexport declare function poll_oneoff(\n /** Input: The events to which to subscribe. */\n in_: ptr>,\n /** Input: The events that have occurred. */\n out: ptr>,\n /** Input: Both the number of subscriptions and events. */\n nsubscriptions: usize,\n /** Output: The number of events stored. */\n nevents: ptr\n): errno;\n\n/** Terminate the process normally. An exit code of 0 indicates successful termination of the program. The meanings of other values is dependent on the environment. */\nexport declare function proc_exit(\n /** Input: The exit code returned by the process. */\n rval: u32\n): void;\n\n/** Send a signal to the process of the calling thread. */\nexport declare function proc_raise(\n /** Input: The signal condition to trigger. */\n sig: signal\n): errno;\n\n/** Write high-quality random data into a buffer. */\nexport declare function random_get(\n /** Input: The buffer to fill with random data. */\n buf: usize,\n /** Input: The length of the buffer to fill with random data. */\n buf_len: usize\n): errno;\n\n/** Temporarily yield execution of the calling thread. */\nexport declare function sched_yield(): errno;\n\n/** Receive a message from a socket. */\nexport declare function sock_recv(\n /** Input: The socket on which to receive data. */\n sock: fd,\n /** Input: List of scatter/gather vectors to which to store data. */\n ri_data: ptr>,\n /** Input: The length of the list of scatter/gather vectors to which to store data. */\n ri_data_len: usize,\n /** Input: Message flags. */\n ri_flags: riflags,\n /** Output: Number of bytes stored in `ri_data`. */\n ro_datalen: ptr,\n /** Output: Message flags. */\n ro_flags: ptr\n): errno;\n\n/** Send a message on a socket. */\nexport declare function sock_send(\n /** Input: The socket on which to send data. */\n sock: fd,\n /** Input: List of scatter/gather vectors to which to retrieve data */\n si_data: ptr>,\n /** Input: The length of the list of scatter/gather vectors to which to retrieve data */\n si_data_len: usize,\n /** Input: Message flags. */\n si_flags: siflags,\n /** Output: Number of bytes transmitted. */\n so_datalen: ptr\n): errno;\n\n/** Shut down socket send and receive channels. */\nexport declare function sock_shutdown(\n /** Input: The socket on which to shutdown channels. */\n sock: fd,\n /** Input: Which channels on the socket to shut down. */\n how: sdflags\n): errno;\n\n// === Types ======================================================================================\n\n/** File or memory access pattern advisory information. */\nexport namespace advice {\n /** The application has no advice to give on its behavior with respect to the specified data. */\n // @ts-ignore: decorator\n @inline\n export const NORMAL: advice = 0;\n /** The application expects to access the specified data sequentially from lower offsets to higher offsets. */\n // @ts-ignore: decorator\n @inline\n export const SEQUENTIAL : advice = 1;\n /** The application expects to access the specified data in a random order. */\n // @ts-ignore: decorator\n @inline\n export const RANDOM: advice = 2;\n /** The application expects to access the specified data in the near future. */\n // @ts-ignore: decorator\n @inline\n export const WILLNEED: advice = 3;\n /** The application expects that it will not access the specified data in the near future. */\n // @ts-ignore: decorator\n @inline\n export const DONTNEED: advice = 4;\n /** The application expects to access the specified data once and then not reuse it thereafter. */\n // @ts-ignore: decorator\n @inline\n export const NOREUSE: advice = 5;\n}\nexport type advice = u8;\n\n/** Identifiers for clocks. */\nexport namespace clockid {\n /** The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z. */\n // @ts-ignore: decorator\n @inline\n export const REALTIME: clockid = 0;\n /** The store-wide monotonic clock. Absolute value has no meaning. */\n // @ts-ignore: decorator\n @inline\n export const MONOTONIC: clockid = 1;\n /** The CPU-time clock associated with the current process. */\n // @ts-ignore: decorator\n @inline\n export const PROCESS_CPUTIME_ID: clockid = 2;\n /** The CPU-time clock associated with the current thread. */\n // @ts-ignore: decorator\n @inline\n export const THREAD_CPUTIME_ID: clockid = 3;\n}\nexport type clockid = u32;\n\n/** Identifier for a device containing a file system. Can be used in combination with `inode` to uniquely identify a file or directory in the filesystem. */\nexport type device = u64;\n\n/** A reference to the offset of a directory entry. */\nexport type dircookie = u64;\n\n/** A directory entry. */\n@unmanaged export class dirent {\n /** The offset of the next directory entry stored in this directory. */\n next: dircookie;\n /** The serial number of the file referred to by this directory entry. */\n ino: inode;\n /** The length of the name of the directory entry. */\n namlen: u32;\n /** The type of the file referred to by this directory entry. */\n type: filetype;\n private __padding0: u16;\n}\n\n/** Error codes returned by functions. */\nexport namespace errno {\n /** No error occurred. System call completed successfully. */\n // @ts-ignore: decorator\n @inline\n export const SUCCESS: errno = 0;\n /** Argument list too long. */\n // @ts-ignore: decorator\n @inline\n export const TOOBIG: errno = 1;\n /** Permission denied. */\n // @ts-ignore: decorator\n @inline\n export const ACCES: errno = 2;\n /** Address in use. */\n // @ts-ignore: decorator\n @inline\n export const ADDRINUSE: errno = 3;\n /** Address not available. */\n // @ts-ignore: decorator\n @inline\n export const ADDRNOTAVAIL: errno = 4;\n /** Address family not supported. */\n // @ts-ignore: decorator\n @inline\n export const AFNOSUPPORT: errno = 5;\n /** Resource unavailable, or operation would block. */\n // @ts-ignore: decorator\n @inline\n export const AGAIN: errno = 6;\n /** Connection already in progress. */\n // @ts-ignore: decorator\n @inline\n export const ALREADY: errno = 7;\n /** Bad file descriptor. */\n // @ts-ignore: decorator\n @inline\n export const BADF: errno = 8;\n /** Bad message. */\n // @ts-ignore: decorator\n @inline\n export const BADMSG: errno = 9;\n /** Device or resource busy. */\n // @ts-ignore: decorator\n @inline\n export const BUSY: errno = 10;\n /** Operation canceled. */\n // @ts-ignore: decorator\n @inline\n export const CANCELED: errno = 11;\n /** No child processes. */\n // @ts-ignore: decorator\n @inline\n export const CHILD: errno = 12;\n /** Connection aborted. */\n // @ts-ignore: decorator\n @inline\n export const CONNABORTED: errno = 13;\n /** Connection refused. */\n // @ts-ignore: decorator\n @inline\n export const CONNREFUSED: errno = 14;\n /** Connection reset. */\n // @ts-ignore: decorator\n @inline\n export const CONNRESET: errno = 15;\n /** Resource deadlock would occur. */\n // @ts-ignore: decorator\n @inline\n export const DEADLK: errno = 16;\n /** Destination address required. */\n // @ts-ignore: decorator\n @inline\n export const DESTADDRREQ: errno = 17;\n /** Mathematics argument out of domain of function. */\n // @ts-ignore: decorator\n @inline\n export const DOM: errno = 18;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const DQUOT: errno = 19;\n /** File exists. */\n // @ts-ignore: decorator\n @inline\n export const EXIST: errno = 20;\n /** Bad address. */\n // @ts-ignore: decorator\n @inline\n export const FAULT: errno = 21;\n /** File too large. */\n // @ts-ignore: decorator\n @inline\n export const FBIG: errno = 22;\n /** Host is unreachable. */\n // @ts-ignore: decorator\n @inline\n export const HOSTUNREACH: errno = 23;\n /** Identifier removed. */\n // @ts-ignore: decorator\n @inline\n export const IDRM: errno = 24;\n /** Illegal byte sequence. */\n // @ts-ignore: decorator\n @inline\n export const ILSEQ: errno = 25;\n /** Operation in progress. */\n // @ts-ignore: decorator\n @inline\n export const INPROGRESS: errno = 26;\n /** Interrupted function. */\n // @ts-ignore: decorator\n @inline\n export const INTR: errno = 27;\n /** Invalid argument. */\n // @ts-ignore: decorator\n @inline\n export const INVAL: errno = 28;\n /** I/O error. */\n // @ts-ignore: decorator\n @inline\n export const IO: errno = 29;\n /** Socket is connected. */\n // @ts-ignore: decorator\n @inline\n export const ISCONN: errno = 30;\n /** Is a directory. */\n // @ts-ignore: decorator\n @inline\n export const ISDIR: errno = 31;\n /** Too many levels of symbolic links. */\n // @ts-ignore: decorator\n @inline\n export const LOOP: errno = 32;\n /** File descriptor value too large. */\n // @ts-ignore: decorator\n @inline\n export const MFILE: errno = 33;\n /** Too many links. */\n // @ts-ignore: decorator\n @inline\n export const MLINK: errno = 34;\n /** Message too large. */\n // @ts-ignore: decorator\n @inline\n export const MSGSIZE: errno = 35;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const MULTIHOP: errno = 36;\n /** Filename too long. */\n // @ts-ignore: decorator\n @inline\n export const NAMETOOLONG: errno = 37;\n /** Network is down. */\n // @ts-ignore: decorator\n @inline\n export const NETDOWN: errno = 38;\n /** Connection aborted by network. */\n // @ts-ignore: decorator\n @inline\n export const NETRESET: errno = 39;\n /** Network unreachable. */\n // @ts-ignore: decorator\n @inline\n export const NETUNREACH: errno = 40;\n /** Too many files open in system. */\n // @ts-ignore: decorator\n @inline\n export const NFILE: errno = 41;\n /** No buffer space available. */\n // @ts-ignore: decorator\n @inline\n export const NOBUFS: errno = 42;\n /** No such device. */\n // @ts-ignore: decorator\n @inline\n export const NODEV: errno = 43;\n /** No such file or directory. */\n // @ts-ignore: decorator\n @inline\n export const NOENT: errno = 44;\n /** Executable file format error. */\n // @ts-ignore: decorator\n @inline\n export const NOEXEC: errno = 45;\n /** No locks available. */\n // @ts-ignore: decorator\n @inline\n export const NOLCK: errno = 46;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const NOLINK: errno = 47;\n /** Not enough space. */\n // @ts-ignore: decorator\n @inline\n export const NOMEM: errno = 48;\n /** No message of the desired type. */\n // @ts-ignore: decorator\n @inline\n export const NOMSG: errno = 49;\n /** Protocol not available. */\n // @ts-ignore: decorator\n @inline\n export const NOPROTOOPT: errno = 50;\n /** No space left on device. */\n // @ts-ignore: decorator\n @inline\n export const NOSPC: errno = 51;\n /** Function not supported. */\n // @ts-ignore: decorator\n @inline\n export const NOSYS: errno = 52;\n /** The socket is not connected. */\n // @ts-ignore: decorator\n @inline\n export const NOTCONN: errno = 53;\n /** Not a directory or a symbolic link to a directory. */\n // @ts-ignore: decorator\n @inline\n export const NOTDIR: errno = 54;\n /** Directory not empty. */\n // @ts-ignore: decorator\n @inline\n export const NOTEMPTY: errno = 55;\n /** State not recoverable. */\n // @ts-ignore: decorator\n @inline\n export const NOTRECOVERABLE: errno = 56;\n /** Not a socket. */\n // @ts-ignore: decorator\n @inline\n export const NOTSOCK: errno = 57;\n /** Not supported, or operation not supported on socket. */\n // @ts-ignore: decorator\n @inline\n export const NOTSUP: errno = 58;\n /** Inappropriate I/O control operation. */\n // @ts-ignore: decorator\n @inline\n export const NOTTY: errno = 59;\n /** No such device or address. */\n // @ts-ignore: decorator\n @inline\n export const NXIO: errno = 60;\n /** Value too large to be stored in data type. */\n // @ts-ignore: decorator\n @inline\n export const OVERFLOW: errno = 61;\n /** Previous owner died. */\n // @ts-ignore: decorator\n @inline\n export const OWNERDEAD: errno = 62;\n /** Operation not permitted. */\n // @ts-ignore: decorator\n @inline\n export const PERM: errno = 63;\n /** Broken pipe. */\n // @ts-ignore: decorator\n @inline\n export const PIPE: errno = 64;\n /** Protocol error. */\n // @ts-ignore: decorator\n @inline\n export const PROTO: errno = 65;\n /** Protocol not supported. */\n // @ts-ignore: decorator\n @inline\n export const PROTONOSUPPORT: errno = 66;\n /** Protocol wrong type for socket. */\n // @ts-ignore: decorator\n @inline\n export const PROTOTYPE: errno = 67;\n /** Result too large. */\n // @ts-ignore: decorator\n @inline\n export const RANGE: errno = 68;\n /** Read-only file system. */\n // @ts-ignore: decorator\n @inline\n export const ROFS: errno = 69;\n /** Invalid seek. */\n // @ts-ignore: decorator\n @inline\n export const SPIPE: errno = 70;\n /** No such process. */\n // @ts-ignore: decorator\n @inline\n export const SRCH: errno = 71;\n /** Reserved. */\n // @ts-ignore: decorator\n @inline\n export const STALE: errno = 72;\n /** Connection timed out. */\n // @ts-ignore: decorator\n @inline\n export const TIMEDOUT: errno = 73;\n /** Text file busy. */\n // @ts-ignore: decorator\n @inline\n export const TXTBSY: errno = 74;\n /** Cross-device link. */\n // @ts-ignore: decorator\n @inline\n export const XDEV: errno = 75;\n /** Extension: Capabilities insufficient. */\n // @ts-ignore: decorator\n @inline\n export const NOTCAPABLE: errno = 76;\n}\nexport type errno = u16;\n\n/** An event that occurred. */\n@unmanaged export abstract class event {\n /** User-provided value that got attached to `subscription#userdata`. */\n userdata: userdata;\n /** If non-zero, an error that occurred while processing the subscription request. */\n error: errno;\n /* The type of the event that occurred. */\n type: eventtype;\n private __padding0: u16;\n}\n\n/** An event that occurred when type is `eventtype.FD_READ` or `eventtype.FD_WRITE`. */\n@unmanaged export class rwevent extends event {\n /* The number of bytes available for reading or writing. */\n nbytes: filesize;\n /* The state of the file descriptor. */\n flags: eventrwflags;\n private __padding1: u32;\n}\n\n/** The state of the file descriptor subscribed to with `eventtype.FD_READ` or `eventtype.FD_WRITE`. */\nexport namespace eventrwflags {\n /** The peer of this socket has closed or disconnected. */\n // @ts-ignore: decorator\n @inline\n export const HANGUP: eventrwflags = 1;\n}\nexport type eventrwflags = u16;\n\n/** Type of a subscription to an event or its occurrence. */\nexport namespace eventtype {\n /** The time value of clock has reached the timestamp. */\n // @ts-ignore: decorator\n @inline\n export const CLOCK: eventtype = 0;\n /** File descriptor has data available for reading. */\n // @ts-ignore: decorator\n @inline\n export const FD_READ: eventtype = 1;\n /** File descriptor has capacity available for writing */\n // @ts-ignore: decorator\n @inline\n export const FD_WRITE: eventtype = 2;\n}\nexport type eventtype = u8;\n\n/** Exit code generated by a process when exiting. */\nexport type exitcode = u32;\n\n/** A file descriptor number. */\nexport type fd = u32;\n\n/** File descriptor flags. */\nexport namespace fdflags {\n /** Append mode: Data written to the file is always appended to the file's end. */\n // @ts-ignore: decorator\n @inline\n export const APPEND: fdflags = 1;\n /** Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. */\n // @ts-ignore: decorator\n @inline\n export const DSYNC: fdflags = 2;\n /** Non-blocking mode. */\n // @ts-ignore: decorator\n @inline\n export const NONBLOCK: fdflags = 4;\n /** Synchronized read I/O operations. */\n // @ts-ignore: decorator\n @inline\n export const RSYNC: fdflags = 8;\n /** Write according to synchronized I/O file integrity completion. */\n // @ts-ignore: decorator\n @inline\n export const SYNC: fdflags = 16;\n}\nexport type fdflags = u16;\n\n/** File descriptor attributes. */\n@unmanaged export class fdstat {\n /** File type. */\n filetype: filetype;\n /** File descriptor flags. */\n flags: fdflags;\n /** Rights that apply to this file descriptor. */\n rights_base: rights;\n /** Maximum set of rights that may be installed on new file descriptors that are created through this file descriptor, e.g., through `path_open`. */\n rights_inheriting: rights;\n}\n\n/** Relative offset within a file. */\nexport type filedelta = i64;\n\n/** Non-negative file size or length of a region within a file. */\nexport type filesize = u64;\n\n/** File attributes. */\n@unmanaged export class filestat {\n /** Device ID of device containing the file. */\n dev: device;\n /** File serial number. */\n ino: inode;\n /** File type. */\n filetype: filetype;\n /** Number of hard links to the file. */\n nlink: linkcount;\n /** For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link. */\n size: filesize;\n /** Last data access timestamp. */\n atim: timestamp;\n /** Last data modification timestamp. */\n mtim: timestamp;\n /** Last file status change timestamp. */\n ctim: timestamp;\n}\n\n/** The type of a file descriptor or file. */\nexport namespace filetype {\n /** The type of the file descriptor or file is unknown or is different from any of the other types specified. */\n // @ts-ignore: decorator\n @inline\n export const UNKNOWN: filetype = 0;\n /** The file descriptor or file refers to a block device inode. */\n // @ts-ignore: decorator\n @inline\n export const BLOCK_DEVICE: filetype = 1;\n /** The file descriptor or file refers to a character device inode. */\n // @ts-ignore: decorator\n @inline\n export const CHARACTER_DEVICE: filetype = 2;\n /** The file descriptor or file refers to a directory inode. */\n // @ts-ignore: decorator\n @inline\n export const DIRECTORY: filetype = 3;\n /** The file descriptor or file refers to a regular file inode. */\n // @ts-ignore: decorator\n @inline\n export const REGULAR_FILE: filetype = 4;\n /** The file descriptor or file refers to a datagram socket. */\n // @ts-ignore: decorator\n @inline\n export const SOCKET_DGRAM: filetype = 5;\n /** The file descriptor or file refers to a byte-stream socket. */\n // @ts-ignore: decorator\n @inline\n export const SOCKET_STREAM: filetype = 6;\n /** The file refers to a symbolic link inode. */\n // @ts-ignore: decorator\n @inline\n export const SYMBOLIC_LINK: filetype = 7;\n}\nexport type filetype = u8;\n\n/** Which file time attributes to adjust. */\nexport namespace fstflags {\n /** Adjust the last data access timestamp to the value stored in `filestat#st_atim`. */\n // @ts-ignore: decorator\n @inline\n export const SET_ATIM: fstflags = 1;\n /** Adjust the last data access timestamp to the time of clock `clockid.REALTIME`. */\n // @ts-ignore: decorator\n @inline\n export const SET_ATIM_NOW: fstflags = 2;\n /** Adjust the last data modification timestamp to the value stored in `filestat#st_mtim`. */\n // @ts-ignore: decorator\n @inline\n export const SET_MTIM: fstflags = 4;\n /** Adjust the last data modification timestamp to the time of clock `clockid.REALTIME`. */\n // @ts-ignore: decorator\n @inline\n export const SET_MTIM_NOW: fstflags = 8;\n}\nexport type fstflags = u16;\n\n/** File serial number that is unique within its file system. */\nexport type inode = u64;\n\n/** A region of memory for scatter/gather reads. */\n@unmanaged export class iovec {\n /** The address of the buffer to be filled. */\n buf: usize;\n /** The length of the buffer to be filled. */\n buf_len: usize;\n}\n\n/** Number of hard links to an inode. */\nexport type linkcount = u32;\n\n/** Flags determining the method of how paths are resolved. */\nexport namespace lookupflags {\n /** As long as the resolved path corresponds to a symbolic link, it is expanded. */\n // @ts-ignore: decorator\n @inline\n export const SYMLINK_FOLLOW: lookupflags = 1;\n}\nexport type lookupflags = u32;\n\n/** Open flags. */\nexport namespace oflags {\n /** Create file if it does not exist. */\n // @ts-ignore: decorator\n @inline\n export const CREAT: oflags = 1;\n /** Fail if not a directory. */\n // @ts-ignore: decorator\n @inline\n export const DIRECTORY: oflags = 2;\n /** Fail if file already exists. */\n // @ts-ignore: decorator\n @inline\n export const EXCL: oflags = 4;\n /** Truncate file to size 0. */\n // @ts-ignore: decorator\n @inline\n export const TRUNC: oflags = 8;\n}\nexport type oflags = u16;\n\n// TODO: undocumented\nexport namespace preopentype {\n // @ts-ignore: decorator\n @inline\n export const DIR: preopentype = 0;\n}\nexport type preopentype = u8;\n\n// TODO: undocumented\nexport abstract class prestat {\n type: preopentype;\n}\n\n// TODO: undocumented\nexport class dirprestat extends prestat {\n name_len: usize;\n}\n\n/** Flags provided to `sock_recv`. */\nexport namespace riflags {\n /** Returns the message without removing it from the socket's receive queue. */\n // @ts-ignore: decorator\n @inline\n export const PEEK: riflags = 1;\n /** On byte-stream sockets, block until the full amount of data can be returned. */\n // @ts-ignore: decorator\n @inline\n export const WAITALL: riflags = 2;\n}\nexport type riflags = u16;\n\n/** File descriptor rights, determining which actions may be performed. */\nexport namespace rights {\n /** The right to invoke `fd_datasync`. */\n // @ts-ignore: decorator\n @inline\n export const FD_DATASYNC: rights = 1;\n /** The right to invoke `fd_read` and `sock_recv`. */\n // @ts-ignore: decorator\n @inline\n export const FD_READ: rights = 2;\n /** The right to invoke `fd_seek`. This flag implies `rights.FD_TELL`. */\n // @ts-ignore: decorator\n @inline\n export const FD_SEEK: rights = 4;\n /** The right to invoke `fd_fdstat_set_flags`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FDSTAT_SET_FLAGS: rights = 8;\n /** The right to invoke `fd_sync`. */\n // @ts-ignore: decorator\n @inline\n export const FD_SYNC: rights = 16;\n /** The right to invoke `fd_seek` in such a way that the file offset remains unaltered (i.e., `whence.CUR` with offset zero), or to invoke `fd_tell`). */\n // @ts-ignore: decorator\n @inline\n export const FD_TELL: rights = 32;\n /** The right to invoke `fd_write` and `sock_send`. If `rights.FD_SEEK` is set, includes the right to invoke `fd_pwrite`. */\n // @ts-ignore: decorator\n @inline\n export const FD_WRITE: rights = 64;\n /** The right to invoke `fd_advise`. */\n // @ts-ignore: decorator\n @inline\n export const FD_ADVISE: rights = 128;\n /** The right to invoke `fd_allocate`. */\n // @ts-ignore: decorator\n @inline\n export const FD_ALLOCATE: rights = 256;\n /** The right to invoke `path_create_directory`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_CREATE_DIRECTORY: rights = 512;\n /** If `rights.PATH_OPEN` is set, the right to invoke `path_open` with `oflags.CREAT`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_CREATE_FILE: rights = 1024;\n /** The right to invoke `path_link` with the file descriptor as the source directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_LINK_SOURCE: rights = 2048;\n /** The right to invoke `path_link` with the file descriptor as the target directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_LINK_TARGET: rights = 4096;\n /** The right to invoke `path_open`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_OPEN: rights = 8192;\n /** The right to invoke `fd_readdir`. */\n // @ts-ignore: decorator\n @inline\n export const FD_READDIR: rights = 16384;\n /** The right to invoke `path_readlink`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_READLINK: rights = 32768;\n /** The right to invoke `path_rename` with the file descriptor as the source directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_RENAME_SOURCE: rights = 65536;\n /** The right to invoke `path_rename` with the file descriptor as the target directory. */\n // @ts-ignore: decorator\n @inline\n export const PATH_RENAME_TARGET: rights = 131072;\n /** The right to invoke `path_filestat_get`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_GET: rights = 262144;\n /** The right to change a file's size (there is no `path_filestat_set_size`). If `rights.PATH_OPEN` is set, includes the right to invoke `path_open` with `oflags.TRUNC`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_SET_SIZE: rights = 524288;\n /** The right to invoke `path_filestat_set_times`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_FILESTAT_SET_TIMES: rights = 1048576;\n /** The right to invoke `fd_filestat_get`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_GET: rights = 2097152;\n /** The right to invoke `fd_filestat_set_size`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_SET_SIZE: rights = 4194304;\n /** The right to invoke `fd_filestat_set_times`. */\n // @ts-ignore: decorator\n @inline\n export const FD_FILESTAT_SET_TIMES: rights = 8388608;\n /** The right to invoke `path_symlink`. */\n // @ts-ignore: decorator\n @inline\n export const RIGHT_PATH_SYMLINK: rights = 16777216;\n /** The right to invoke `path_remove_directory`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_REMOVE_DIRECTORY: rights = 33554432;\n /** The right to invoke `path_unlink_file`. */\n // @ts-ignore: decorator\n @inline\n export const PATH_UNLINK_FILE: rights = 67108864;\n /** If `rights.FD_READ` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_READ`. If `rights.FD_WRITE` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_WRITE`. */\n // @ts-ignore: decorator\n @inline\n export const POLL_FD_READWRITE: rights = 134217728;\n /** The right to invoke `sock_shutdown`. */\n // @ts-ignore: decorator\n @inline\n export const SOCK_SHUTDOWN: rights = 268435456;\n}\nexport type rights = u64;\n\n/** Flags returned by `sock_recv`. */\nexport namespace roflags {\n /** Message data has been truncated. */\n // @ts-ignore: decorator\n @inline\n export const DATA_TRUNCATED: roflags = 1;\n}\nexport type roflags = u16;\n\n/** Which channels on a socket to shut down. */\nexport namespace sdflags {\n /** Disables further receive operations. */\n // @ts-ignore: decorator\n @inline\n export const RD: sdflags = 1;\n /** Disables further send operations. */\n // @ts-ignore: decorator\n @inline\n export const WR: sdflags = 2;\n}\nexport type sdflags = u8;\n\n/** Flags provided to `sock_send`. */\nexport namespace siflags {\n // As there are currently no flags defined, it must be set to zero.\n}\nexport type siflags = u16;\n\n/** Signal condition. */\nexport namespace signal {\n /** Hangup. */\n // @ts-ignore: decorator\n @inline\n export const HUP: signal = 1;\n /** Terminate interrupt signal. */\n // @ts-ignore: decorator\n @inline\n export const INT: signal = 2;\n /** Terminal quit signal. */\n // @ts-ignore: decorator\n @inline\n export const QUIT: signal = 3;\n /** Illegal instruction. */\n // @ts-ignore: decorator\n @inline\n export const ILL: signal = 4;\n /** Trace/breakpoint trap. */\n // @ts-ignore: decorator\n @inline\n export const TRAP: signal = 5;\n /** Process abort signal. */\n // @ts-ignore: decorator\n @inline\n export const ABRT: signal = 6;\n /** Access to an undefined portion of a memory object. */\n // @ts-ignore: decorator\n @inline\n export const BUS: signal = 7;\n /** Erroneous arithmetic operation. */\n // @ts-ignore: decorator\n @inline\n export const FPE: signal = 8;\n /** Kill. */\n // @ts-ignore: decorator\n @inline\n export const KILL: signal = 9;\n /** User-defined signal 1. */\n // @ts-ignore: decorator\n @inline\n export const USR1: signal = 10;\n /** Invalid memory reference. */\n // @ts-ignore: decorator\n @inline\n export const SEGV: signal = 11;\n /** User-defined signal 2. */\n // @ts-ignore: decorator\n @inline\n export const USR2: signal = 12;\n /** Write on a pipe with no one to read it. */\n // @ts-ignore: decorator\n @inline\n export const PIPE: signal = 13;\n /** Alarm clock. */\n // @ts-ignore: decorator\n @inline\n export const ALRM: signal = 14;\n /** Termination signal. */\n // @ts-ignore: decorator\n @inline\n export const TERM: signal = 15;\n /** Child process terminated, stopped, or continued. */\n // @ts-ignore: decorator\n @inline\n export const CHLD: signal = 16;\n /** Continue executing, if stopped. */\n // @ts-ignore: decorator\n @inline\n export const CONT: signal = 17;\n /** Stop executing. */\n // @ts-ignore: decorator\n @inline\n export const STOP: signal = 18;\n /** Terminal stop signal. */\n // @ts-ignore: decorator\n @inline\n export const TSTP: signal = 19;\n /** Background process attempting read. */\n // @ts-ignore: decorator\n @inline\n export const TTIN: signal = 20;\n /** Background process attempting write. */\n // @ts-ignore: decorator\n @inline\n export const TTOU: signal = 21;\n /** High bandwidth data is available at a socket. */\n // @ts-ignore: decorator\n @inline\n export const URG: signal = 22;\n /** CPU time limit exceeded. */\n // @ts-ignore: decorator\n @inline\n export const XCPU: signal = 23;\n /** File size limit exceeded. */\n // @ts-ignore: decorator\n @inline\n export const XFSZ: signal = 24;\n /** Virtual timer expired. */\n // @ts-ignore: decorator\n @inline\n export const VTALRM: signal = 25;\n // @ts-ignore: decorator\n @inline\n export const PROF: signal = 26;\n // @ts-ignore: decorator\n @inline\n export const WINCH: signal = 27;\n // @ts-ignore: decorator\n @inline\n export const POLL: signal = 28;\n // @ts-ignore: decorator\n @inline\n export const PWR: signal = 29;\n /** Bad system call. */\n // @ts-ignore: decorator\n @inline\n export const SYS: signal = 30;\n}\nexport type signal = u8;\n\n/** Flags determining how to interpret the timestamp provided in `subscription_t::u.clock.timeout. */\nexport namespace subclockflags {\n /** If set, treat the timestamp provided in `clocksubscription` as an absolute timestamp. */\n // @ts-ignore: decorator\n @inline\n export const ABSTIME: subclockflags = 1;\n}\nexport type subclockflags = u16;\n\n/** Subscription to an event. */\n@unmanaged export abstract class subscription {\n /** User-provided value that is attached to the subscription. */\n userdata: userdata;\n /** The type of the event to which to subscribe. */\n type: eventtype;\n private __padding0: u32;\n}\n\n/* Subscription to an event of type `eventtype.CLOCK`.**/\n@unmanaged export class clocksubscription extends subscription {\n /** The user-defined unique identifier of the clock. */\n identifier: userdata;\n /** The clock against which to compare the timestamp. */\n clock_id: clockid;\n /** The absolute or relative timestamp. */\n timeout: timestamp;\n /** The amount of time that the implementation may wait additionally to coalesce with other events. */\n precision: timestamp;\n /** Flags specifying whether the timeout is absolute or relative. */\n flags: subclockflags;\n private __padding1: u32;\n}\n\n/* Subscription to an event of type `eventtype.FD_READ` or `eventtype.FD_WRITE`.**/\n@unmanaged export class fdsubscription extends subscription {\n /** The file descriptor on which to wait for it to become ready for reading or writing. */\n fd: fd;\n}\n\n/** Timestamp in nanoseconds. */\nexport type timestamp = u64;\n\n/** User-provided value that may be attached to objects that is retained when extracted from the implementation. */\nexport type userdata = u64;\n\n/** The position relative to which to set the offset of the file descriptor. */\nexport namespace whence {\n /** Seek relative to current position. */\n // @ts-ignore: decorator\n @inline\n export const CUR: whence = 0;\n /** Seek relative to end-of-file. */\n // @ts-ignore: decorator\n @inline\n export const END: whence = 1;\n /** Seek relative to start-of-file. */\n // @ts-ignore: decorator\n @inline\n export const SET: whence = 2;\n}\nexport type whence = u8;\n","bindings/wasi":'export * from "./wasi_unstable";\n',builtins:'// @ts-ignore: decorator\n@builtin @inline\nexport const NaN: f64 = 0 / 0;\n\n// @ts-ignore: decorator\n@builtin @inline\nexport const Infinity: f64 = 1 / 0;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isInteger(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFloat(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isBoolean(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isSigned(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isReference(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isString(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isArray(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isArrayLike(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFunction(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isNullable(value?: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isDefined(expression: void): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isConstant(expression: void): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isManaged(value?: T): bool;\n\nexport function isNaN(value: T): bool {\n if (!isFloat()) {\n if (!isInteger()) ERROR("numeric type expected");\n }\n return value != value;\n}\n\nexport function isFinite(value: T): bool {\n if (!isFloat()) {\n if (!isInteger()) ERROR("numeric type expected");\n }\n return value - value == 0;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function clz(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function ctz(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function popcnt(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function rotl(value: T, shift: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function rotr(value: T, shift: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function abs(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function max(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function min(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function ceil(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function floor(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function copysign(left: T, right: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function nearest(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function reinterpret(value: number): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function sqrt(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function trunc(value: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function load(offset: usize, immOffset?: usize, immAlign?: usize): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function store(offset: usize, value: void, immOffset?: usize, immAlign?: usize): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function sizeof(): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function alignof(): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function offsetof(fieldName?: string): usize; // | u32 / u64\n\n// @ts-ignore: decorator\n@builtin\nexport declare function idof(): u32;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n\n// @ts-ignore: decorator\n@unsafe @builtin\nexport declare function unreachable(): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function changetype(value: void): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function assert(isTrueish: T, message?: string): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function unchecked(expr: T): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function call_indirect(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function call_direct(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function instantiate(...args: void[]): T;\n\nexport namespace atomic {\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: T, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;\n\n // @ts-ignore: decorator\n @builtin\n export declare function notify(ptr: usize, count: i32): i32;\n}\n\n// @ts-ignore: decorator\n@lazy\nexport const enum AtomicWaitResult {\n OK = 0,\n NOT_EQUAL = 1,\n TIMED_OUT = 2\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i8(value: void): i8;\n\nexport namespace i8 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i8 = -128;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i8 = 127;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i16(value: void): i16;\n\nexport namespace i16 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i16 = -32768;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i16 = 32767;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i32(value: void): i32;\n\nexport namespace i32 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i32 = -2147483648;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i32 = 2147483647;\n\n // @ts-ignore: decorator\n @builtin\n export declare function clz(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ctz(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function popcnt(value: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotl(value: i32, shift: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotr(value: i32, shift: i32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_f32(value: f32): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n export namespace atomic {\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;\n\n export namespace rmw8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n\n export namespace rmw16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n\n export namespace rmw {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(offset: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n }\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i64(value: void): i64;\n\nexport namespace i64 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: i64 = -9223372036854775808;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: i64 = 9223372036854775807;\n\n // @ts-ignore: decorator\n @builtin\n export declare function clz(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ctz(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function popcnt(value: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotl(value: i64, shift: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function rotr(value: i64, shift: i64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_f64(value: f64): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n export namespace atomic {\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store8(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store16(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store32(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;\n\n export namespace rmw8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw32 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n\n export namespace rmw {\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xchg(offset: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n }\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isize(value: void): isize;\n\nexport namespace isize {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: isize = sizeof() == sizeof()\n ? -2147483648\n : -9223372036854775808;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: isize = sizeof() == sizeof()\n ? 2147483647\n : 9223372036854775807;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u8(value: void): u8;\n\nexport namespace u8 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u8 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u8 = 255;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u16(value: void): u16;\n\nexport namespace u16 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u16 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u16 = 65535;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u32(value: void): u32;\n\nexport namespace u32 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u32 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u32 = 4294967295;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function u64(value: void): u64;\n\nexport namespace u64 {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: u64 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: u64 = 18446744073709551615;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function usize(value: void): usize;\n\nexport namespace usize {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: usize = 0;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: usize = sizeof() == sizeof()\n ? 4294967295\n : 18446744073709551615;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function bool(value: void): bool;\n\nexport namespace bool {\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE: bool = false;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE: bool = true;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f32(value: void): f32;\n\nexport namespace f32 {\n\n // @ts-ignore: decorator\n @lazy\n export const EPSILON = reinterpret(0x34000000); // 0x1p-23f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE = reinterpret(0x00000001); // 0x0.000001p+0f\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE = reinterpret(0x7F7FFFFF); // 0x1.fffffep+127f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_NORMAL_VALUE = reinterpret(0x00800000); // 0x1p-126f\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_SAFE_INTEGER: f32 = -16777215;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_SAFE_INTEGER: f32 = 16777215;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ceil(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function copysign(x: f32, y: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function floor(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(left: f32, right: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(left: f32, right: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function nearest(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_i32(value: i32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(value: f32): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(value: f32): f32;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f64(value: void): f64;\n\nexport namespace f64 {\n\n // @ts-ignore: decorator\n @lazy\n export const EPSILON = reinterpret(0x3CB0000000000000); // 0x1p-52\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_VALUE = reinterpret(0x0000000000000001); // 0x0.0000000000001p+0\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_VALUE = reinterpret(0x7FEFFFFFFFFFFFFF); // 0x1.fffffffffffffp+1023\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_NORMAL_VALUE = reinterpret(0x0010000000000000); // 0x1p-1022\n\n // @ts-ignore: decorator\n @lazy\n export const MIN_SAFE_INTEGER: f64 = -9007199254740991;\n\n // @ts-ignore: decorator\n @lazy\n export const MAX_SAFE_INTEGER: f64 = 9007199254740991;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ceil(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function copysign(x: f64, y: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function floor(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(left: f64, right: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(left: f64, right: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function nearest(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function reinterpret_i64(value: i64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(value: f64): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(value: f64): f64;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function v128(\n a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8,\n i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8\n): v128;\n\nexport namespace v128 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: T): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): T;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: T): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128; // except i64\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function not(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function bitselect(v1: v128, v2: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128; // f32, f64 only\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i8x16(\n a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8,\n i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8\n): v128;\n\nexport namespace i8x16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i8): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_s(x: v128, idx: u8): i8;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_u(x: v128, idx: u8): u8;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i8): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;\n\nexport namespace i16x8 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i16): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_s(x: v128, idx: u8): i16;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane_u(x: v128, idx: u8): u16;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i16): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_saturate_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;\n\nexport namespace i32x4 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_s_f32x4_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_u_f32x4_sat(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function i64x2(a: i64, b: i64): v128;\n\nexport namespace i64x2 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: i64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: i64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shl(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_s(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function shr_u(a: v128, b: i32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function any_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function all_true(a: v128): bool;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_s_f64x2_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_u_f64x2_sat(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;\n\nexport namespace f32x4 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: f32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): f32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: f32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_s_i32x4(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_u_i32x4(a: v128): v128;\n}\n\n// @ts-ignore: decorator\n@builtin\nexport declare function f64x2(a: f64, b: f64): v128;\n\nexport namespace f64x2 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function splat(x: f64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function extract_lane(x: v128, idx: u8): f64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function replace_lane(x: v128, idx: u8, value: f64): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function add(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function mul(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function div(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function neg(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function abs(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sqrt(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function eq(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ne(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function lt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function le(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function gt(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function ge(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_s_i64x2(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_u_i64x2(a: v128): v128;\n}\n\nexport namespace v8x16 {\n\n // @ts-ignore: decorator\n @builtin\n export declare function shuffle(\n a: v128, b: v128,\n l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8,\n l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8\n ): v128;\n}\n\n// @ts-ignore: decorator\n@external("env", "abort")\ndeclare function abort(\n message?: string | null,\n fileName?: string | null,\n lineNumber?: u32,\n columnNumber?: u32\n): void;\n\n// @ts-ignore: decorator\n@external("env", "trace")\ndeclare function trace(\n message: string,\n n?: i32,\n a0?: f64,\n a1?: f64,\n a2?: f64,\n a3?: f64,\n a4?: f64\n): void;\n',dataview:'import { BLOCK_MAXSIZE } from "./rt/common";\nimport { ArrayBuffer } from "./arraybuffer";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH } from "./util/error";\n\n// TODO: there is probably a smarter way to check byteOffset for accesses larger than 1 byte\n\nexport class DataView {\n\n private data: ArrayBuffer;\n private dataStart: usize;\n private dataLength: i32;\n\n constructor(\n buffer: ArrayBuffer,\n byteOffset: i32 = 0,\n byteLength: i32 = buffer.byteLength\n ) {\n if (\n i32(byteLength > BLOCK_MAXSIZE) |\n i32(byteOffset + byteLength > buffer.byteLength)\n ) throw new RangeError(E_INVALIDLENGTH);\n this.data = buffer; // retains\n var dataStart = changetype(buffer) + byteOffset;\n this.dataStart = dataStart;\n this.dataLength = byteLength;\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.data));\n }\n\n get byteLength(): i32 {\n return this.dataLength;\n }\n\n getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n return littleEndian\n ? load(this.dataStart + byteOffset)\n : reinterpret(\n bswap(\n load(this.dataStart + byteOffset)\n )\n );\n }\n\n getFloat64(byteOffset: i32, littleEndian: boolean = false): f64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n return littleEndian\n ? load(this.dataStart + byteOffset)\n : reinterpret(\n bswap(\n load(this.dataStart + byteOffset)\n )\n );\n }\n\n getInt8(byteOffset: i32): i8 {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getInt16(byteOffset: i32, littleEndian: boolean = false): i16 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i16 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getInt32(byteOffset: i32, littleEndian: boolean = false): i32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i32 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint8(byteOffset: i32): u8 {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getUint16(byteOffset: i32, littleEndian: boolean = false): u16 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: u16 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint32(byteOffset: i32, littleEndian: boolean = false): u32 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: u32 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n setFloat32(byteOffset: i32, value: f32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n if (littleEndian) store(this.dataStart + byteOffset, value);\n else store(this.dataStart + byteOffset, bswap(reinterpret(value)));\n }\n\n setFloat64(byteOffset: i32, value: f64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n if (littleEndian) store(this.dataStart + byteOffset, value);\n else store(this.dataStart + byteOffset, bswap(reinterpret(value)));\n }\n\n setInt8(byteOffset: i32, value: i8): void {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, value);\n }\n\n setInt16(byteOffset: i32, value: i16, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setInt32(byteOffset: i32, value: i32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint8(byteOffset: i32, value: u8): void {\n if (byteOffset >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, value);\n }\n\n setUint16(byteOffset: i32, value: u16, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 2 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint32(byteOffset: i32, value: u32, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 4 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n // Non-standard additions that make sense in WebAssembly, but won\'t work in JS:\n\n getInt64(byteOffset: i32, littleEndian: boolean = false): i64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result: i64 = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n getUint64(byteOffset: i32, littleEndian: boolean = false): u64 {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n var result = load(this.dataStart + byteOffset);\n return littleEndian ? result : bswap(result);\n }\n\n setInt64(byteOffset: i32, value: i64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n setUint64(byteOffset: i32, value: u64, littleEndian: boolean = false): void {\n if (\n i32(byteOffset < 0) |\n i32(byteOffset + 8 > this.dataLength)\n ) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + byteOffset, littleEndian ? value : bswap(value));\n }\n\n toString(): string {\n return "[object DataView]";\n }\n}\n',date:'import {\n UTC as Date_UTC,\n now as Date_now\n} from "./bindings/Date";\n\nexport class Date {\n\n @inline static UTC(\n year: i32,\n month: i32 = 0,\n day: i32 = 1,\n hour: i32 = 0,\n minute: i32 = 0,\n second: i32 = 0,\n millisecond: i64 = 0\n ): i64 {\n return Date_UTC(year, month, day, hour, minute, second, millisecond);\n }\n\n @inline static now(): i64 {\n return Date_now();\n }\n\n private value: i64;\n\n constructor(value: i64) {\n this.value = value;\n }\n\n getTime(): i64 {\n return this.value;\n }\n\n setTime(value: i64): i64 {\n this.value = value;\n return value;\n }\n}\n',diagnostics:"// @ts-ignore: decorator\n@builtin\nexport declare function ERROR(message?: string): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function WARNING(message?: string): void;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function INFO(message?: string): void;\n",error:'export class Error {\n\n name: string = "Error";\n stack: string = ""; // TODO\n\n constructor(\n public message: string = ""\n ) {}\n\n toString(): string {\n var message = this.message;\n return message.length\n ? this.name + ": " + message\n : this.name;\n }\n}\n\nexport class RangeError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "RangeError";\n }\n}\n\nexport class TypeError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "TypeError";\n }\n}\n\nexport class SyntaxError extends Error {\n constructor(message: string = "") {\n super(message);\n this.name = "SyntaxError";\n }\n}\n',fixedarray:'/// \n\nimport { BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "./rt/common";\nimport { idof } from "./builtins";\nimport { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_HOLEYARRAY } from "./util/error";\n\n// NOTE: DO NOT USE YET!\n\n// TODO: FixedArray with S being the static size, i.e. `new FixedArray`.\n// Then hard-wire this special type to the compiler and do static length checks instead :)\n\nexport class FixedArray {\n [key: number]: T;\n\n constructor(length: i32) {\n if (length > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH);\n if (isReference()) {\n if (!isNullable()) {\n if (length) throw new Error(E_HOLEYARRAY);\n }\n }\n var outSize = length << alignof();\n var out = __alloc(outSize, idof>());\n memory.fill(out, 0, outSize);\n return changetype>(out); // retains\n }\n\n get length(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize >>> alignof();\n }\n\n @operator("[]") private __get(index: i32): T {\n if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE);\n return this.__unchecked_get(index);\n }\n\n @operator("[]=") private __set(index: i32, value: T): void {\n if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE);\n this.__unchecked_set(index, value);\n }\n\n @operator("{}") private __unchecked_get(index: i32): T {\n return load(changetype(this) + (index << alignof()));\n }\n\n @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = changetype(this) + (index << alignof());\n let oldValue = load(offset);\n if (changetype(value) != oldValue) {\n store(offset, __retain(changetype(value)));\n __release(changetype(oldValue));\n }\n } else {\n store(changetype(this) + (index << alignof()), value);\n }\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n if (isManaged()) {\n let cur = changetype(this);\n let end = cur + changetype(changetype(this) - BLOCK_OVERHEAD).rtSize;\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n }\n}\n',heap:"// @ts-ignore: decorator\n@builtin\nexport declare const HEAP_BASE: usize;\n",iterator:"export abstract class Iterable {\n // ?\n}\n\n@sealed\nexport abstract class Iterator {\n\n // private constructor(iterable: Iterable) {\n // }\n\n // TODO: these need to evaluate the classId at the respective reference in order to obtain the\n // next value, i.e. arrays work differently than maps. we'd then have:\n //\n // ╒═══════════════════ Iterator layout (32-bit) ══════════════════╕\n // 3 2 1\n // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n // ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n // │ index │\n // ├─────────────────────────────────────────────────────────┬───┬─┤\n // │ reference │ 0 │D│\n // └─────────────────────────────────────────────────────────┴───┴─┘\n // D: Done flag\n\n // get value(this: u64): T {\n // ?\n // }\n\n // next(this: u64): Iterator {\n // ?\n // }\n\n done(this: u64): bool {\n return (this & 1);\n }\n}\n",map:'/// \n\nimport { HASH } from "./util/hash";\n\n// A deterministic hash map based on CloseTable from https://github.com/jorendorff/dht\n\n// @ts-ignore: decorator\n@inline\nconst INITIAL_CAPACITY = 4;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR: f64 = 8 / 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR: f64 = 3 / 4;\n\n/** Structure of a map entry. */\n@unmanaged class MapEntry {\n key: K;\n value: V;\n taggedNext: usize; // LSB=1 indicates EMPTY\n}\n\n/** Empty bit. */\n// @ts-ignore: decorator\n@inline\nconst EMPTY: usize = 1 << 0;\n\n/** Size of a bucket. */\n// @ts-ignore: decorator\n@inline\nconst BUCKET_SIZE = sizeof();\n\n/** Computes the alignment of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_ALIGN(): usize {\n // can align to 4 instead of 8 if 32-bit and K/V is <= 32-bits\n const maxkv = sizeof() > sizeof() ? sizeof() : sizeof();\n const align = (maxkv > sizeof() ? maxkv : sizeof()) - 1;\n return align;\n}\n\n/** Computes the aligned size of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_SIZE(): usize {\n const align = ENTRY_ALIGN();\n const size = (offsetof>() + align) & ~align;\n return size;\n}\n\nexport class Map {\n\n // buckets holding references to the respective first entry within\n private buckets: ArrayBuffer; // usize[bucketsMask + 1]\n private bucketsMask: u32;\n\n // entries in insertion order\n private entries: ArrayBuffer; // MapEntry[entriesCapacity]\n private entriesCapacity: i32;\n private entriesOffset: i32;\n private entriesCount: i32;\n\n get size(): i32 { return this.entriesCount; }\n\n constructor() {\n this.clear();\n }\n\n clear(): void {\n const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE;\n this.buckets = new ArrayBuffer(bucketsSize);\n this.bucketsMask = INITIAL_CAPACITY - 1;\n const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE();\n this.entries = new ArrayBuffer(entriesSize);\n this.entriesCapacity = INITIAL_CAPACITY;\n this.entriesOffset = 0;\n this.entriesCount = 0;\n }\n\n private find(key: K, hashCode: u32): MapEntry | null {\n var entry = load>( // unmanaged!\n changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE\n );\n while (entry) {\n if (!(entry.taggedNext & EMPTY) && entry.key == key) return entry;\n entry = changetype>(entry.taggedNext & ~EMPTY);\n }\n return null;\n }\n\n has(key: K): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n get(key: K): V {\n var entry = this.find(key, HASH(key));\n return entry ? entry.value : unreachable();\n }\n\n set(key: K, value: V): void {\n var hashCode = HASH(key);\n var entry = this.find(key, hashCode); // unmanaged!\n if (entry) {\n if (isManaged()) {\n let oldRef = changetype(entry.value);\n if (changetype(value) != oldRef) {\n entry.value = changetype(__retain(changetype(value)));\n __release(oldRef);\n }\n } else {\n entry.value = value;\n }\n } else {\n // check if rehashing is necessary\n if (this.entriesOffset == this.entriesCapacity) {\n this.rehash(\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ? this.bucketsMask // just rehash if 1/4+ entries are empty\n : (this.bucketsMask << 1) | 1 // grow capacity to next 2^N\n );\n }\n // append new entry\n let entries = this.entries;\n entry = changetype>(changetype(entries) + this.entriesOffset++ * ENTRY_SIZE());\n // link with the map\n entry.key = isManaged()\n ? changetype(__retain(changetype(key)))\n : key;\n entry.value = isManaged()\n ? changetype(__retain(changetype(value)))\n : value;\n ++this.entriesCount;\n // link with previous entry in bucket\n let bucketPtrBase = changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE;\n entry.taggedNext = load(bucketPtrBase);\n store(bucketPtrBase, changetype(entry));\n }\n }\n\n delete(key: K): bool {\n var entry = this.find(key, HASH(key));\n if (!entry) return false;\n if (isManaged()) __release(changetype(entry.key));\n if (isManaged()) __release(changetype(entry.value));\n entry.taggedNext |= EMPTY;\n --this.entriesCount;\n // check if rehashing is appropriate\n var halfBucketsMask = this.bucketsMask >> 1;\n if (\n halfBucketsMask + 1 >= max(INITIAL_CAPACITY, this.entriesCount) &&\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ) this.rehash(halfBucketsMask);\n return true;\n }\n\n private rehash(newBucketsMask: u32): void {\n var newBucketsCapacity = (newBucketsMask + 1);\n var newBuckets = new ArrayBuffer(newBucketsCapacity * BUCKET_SIZE);\n var newEntriesCapacity = (newBucketsCapacity * FILL_FACTOR);\n var newEntries = new ArrayBuffer(newEntriesCapacity * ENTRY_SIZE());\n\n // copy old entries to new entries\n var oldPtr = changetype(this.entries);\n var oldEnd = oldPtr + this.entriesOffset * ENTRY_SIZE();\n var newPtr = changetype(newEntries);\n while (oldPtr != oldEnd) {\n let oldEntry = changetype>(oldPtr);\n if (!(oldEntry.taggedNext & EMPTY)) {\n let newEntry = changetype>(newPtr);\n newEntry.key = oldEntry.key;\n newEntry.value = oldEntry.value;\n let newBucketIndex = HASH(oldEntry.key) & newBucketsMask;\n let newBucketPtrBase = changetype(newBuckets) + newBucketIndex * BUCKET_SIZE;\n newEntry.taggedNext = load(newBucketPtrBase);\n store(newBucketPtrBase, newPtr);\n newPtr += ENTRY_SIZE();\n }\n oldPtr += ENTRY_SIZE();\n }\n\n this.buckets = newBuckets;\n this.bucketsMask = newBucketsMask;\n this.entries = newEntries;\n this.entriesCapacity = newEntriesCapacity;\n this.entriesOffset = this.entriesCount;\n }\n\n toString(): string {\n return "[object Map]";\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n __visit(changetype(this.buckets), cookie);\n var entries = changetype(this.entries);\n if (isManaged() || isManaged()) {\n let cur = entries;\n let end = cur + this.entriesOffset * ENTRY_SIZE();\n while (cur < end) {\n let entry = changetype>(cur);\n if (!(entry.taggedNext & EMPTY)) {\n if (isManaged()) {\n let val = changetype(entry.key);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n if (isManaged()) {\n let val = changetype(entry.value);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n }\n cur += ENTRY_SIZE();\n }\n }\n __visit(entries, cookie);\n }\n}\n',math:'import * as JSMath from "./bindings/Math";\nexport { JSMath };\n\nimport {\n abs as builtin_abs,\n ceil as builtin_ceil,\n clz as builtin_clz,\n copysign as builtin_copysign,\n floor as builtin_floor,\n max as builtin_max,\n min as builtin_min,\n sqrt as builtin_sqrt,\n trunc as builtin_trunc\n} from "./builtins";\n\n// SUN COPYRIGHT NOTICE\n//\n// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n// Developed at SunPro, a Sun Microsystems, Inc. business.\n// Permission to use, copy, modify, and distribute this software\n// is freely granted, provided that this notice is preserved.\n//\n// Applies to all functions marked with a comment referring here.\n\n// TODO: sin, cos, tan for Math namespace\n\n/** @internal */\nfunction R(z: f64): f64 { // Rational approximation of (asin(x)-x)/x^3\n const // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above\n pS0 = reinterpret(0x3FC5555555555555), // 1.66666666666666657415e-01\n pS1 = reinterpret(0xBFD4D61203EB6F7D), // -3.25565818622400915405e-01\n pS2 = reinterpret(0x3FC9C1550E884455), // 2.01212532134862925881e-01\n pS3 = reinterpret(0xBFA48228B5688F3B), // -4.00555345006794114027e-02\n pS4 = reinterpret(0x3F49EFE07501B288), // 7.91534994289814532176e-04\n pS5 = reinterpret(0x3F023DE10DFDF709), // 3.47933107596021167570e-05\n qS1 = reinterpret(0xC0033A271C8A2D4B), // -2.40339491173441421878e+00\n qS2 = reinterpret(0x40002AE59C598AC8), // 2.02094576023350569471e+00\n qS3 = reinterpret(0xBFE6066C1B8D0159), // -6.88283971605453293030e-01\n qS4 = reinterpret(0x3FB3B8C5B12E9282); // 7.70381505559019352791e-02\n var p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))));\n var q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4)));\n return p / q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction expo2(x: f64): f64 { // exp(x)/2 for x >= log(DBL_MAX)\n const // see: musl/src/math/__expo2.c\n k = 2043,\n kln2 = reinterpret(0x40962066151ADD8B); // 0x1.62066151add8bp+10\n var scale = reinterpret(((0x3FF + k / 2) << 20) << 32);\n return NativeMath.exp(x - kln2) * scale * scale;\n}\n\n// @ts-ignore: decorator\n@lazy\nvar random_seeded = false;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state0_64: u64;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state1_64: u64;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state0_32: u32;\n\n// @ts-ignore: decorator\n@lazy\nvar random_state1_32: u32;\n\nfunction murmurHash3(h: u64): u64 { // Force all bits of a hash block to avalanche\n h ^= h >> 33; // see: https://github.com/aappleby/smhasher\n h *= 0xFF51AFD7ED558CCD;\n h ^= h >> 33;\n h *= 0xC4CEB9FE1A85EC53;\n h ^= h >> 33;\n return h;\n}\n\nfunction splitMix32(h: u32): u32 {\n h += 0x6D2B79F5;\n h = (h ^ (h >> 15)) * (h | 1);\n h ^= h + (h ^ (h >> 7)) * (h | 61);\n return h ^ (h >> 14);\n}\n\nexport namespace NativeMath {\n\n // @ts-ignore: decorator\n @lazy\n export const E = reinterpret(0x4005BF0A8B145769); // 2.7182818284590452354\n\n // @ts-ignore: decorator\n @lazy\n export const LN2 = reinterpret(0x3FE62E42FEFA39EF); // 0.69314718055994530942\n\n // @ts-ignore: decorator\n @lazy\n export const LN10 = reinterpret(0x40026BB1BBB55516); // 2.30258509299404568402\n\n // @ts-ignore: decorator\n @lazy\n export const LOG2E = reinterpret(0x3FF71547652B82FE); // 1.4426950408889634074\n\n // @ts-ignore: decorator\n @lazy\n export const LOG10E = reinterpret(0x3FDBCB7B1526E50E); // 0.43429448190325182765\n\n // @ts-ignore: decorator\n @lazy\n export const PI = reinterpret(0x400921FB54442D18); // 3.14159265358979323846\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT1_2 = reinterpret(0x3FE6A09E667F3BCD); // 0.70710678118654752440\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT2 = reinterpret(0x3FF6A09E667F3BCD); // 1.41421356237309504880\n\n // @ts-ignore: decorator\n @inline export function abs(x: f64): f64 {\n return builtin_abs(x);\n }\n\n export function acos(x: f64): f64 { // see: musl/src/math/acos.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n pio2_lo = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n Ox1p_120f = reinterpret(0x03800000);\n var hx = (reinterpret(x) >> 32);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3FF00000) {\n let lx = reinterpret(x);\n if ((ix - 0x3FF00000 | lx) == 0) {\n if (hx >> 31) return 2 * pio2_hi + Ox1p_120f;\n return 0;\n }\n return 0 / (x - x);\n }\n if (ix < 0x3FE00000) {\n if (ix <= 0x3C600000) return pio2_hi + Ox1p_120f;\n return pio2_hi - (x - (pio2_lo - x * R(x * x)));\n }\n var s: f64, w: f64, z: f64;\n if (hx >> 31) {\n // z = (1.0 + x) * 0.5;\n z = 0.5 + x * 0.5;\n s = builtin_sqrt(z);\n w = R(z) * s - pio2_lo;\n return 2 * (pio2_hi - (s + w));\n }\n // z = (1.0 - x) * 0.5;\n z = 0.5 - x * 0.5;\n s = builtin_sqrt(z);\n var df = reinterpret(reinterpret(s) & 0xFFFFFFFF00000000);\n var c = (z - df * df) / (s + df);\n w = R(z) * s + c;\n return 2 * (df + w);\n }\n\n export function acosh(x: f64): f64 { // see: musl/src/math/acosh.c\n const s = reinterpret(0x3FE62E42FEFA39EF);\n var e = reinterpret(x) >> 52 & 0x7FF;\n if (e < 0x3FF + 1) return log1p(x - 1 + builtin_sqrt((x - 1) * (x - 1) + 2 * (x - 1)));\n if (e < 0x3FF + 26) return log(2 * x - 1 / (x + builtin_sqrt(x * x - 1)));\n return log(x) + s;\n }\n\n export function asin(x: f64): f64 { // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n pio2_lo = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n Ox1p_120f = reinterpret(0x03800000);\n var hx = (reinterpret(x) >> 32);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3FF00000) {\n let lx = reinterpret(x);\n if ((ix - 0x3FF00000 | lx) == 0) return x * pio2_hi + Ox1p_120f;\n return 0 / (x - x);\n }\n if (ix < 0x3FE00000) {\n if (ix < 0x3E500000 && ix >= 0x00100000) return x;\n return x + x * R(x * x);\n }\n // var z = (1.0 - builtin_abs(x)) * 0.5;\n var z = 0.5 - builtin_abs(x) * 0.5;\n var s = builtin_sqrt(z);\n var r = R(z);\n if (ix >= 0x3FEF3333) x = pio2_hi - (2 * (s + s * r) - pio2_lo);\n else {\n let f = reinterpret(reinterpret(s) & 0xFFFFFFFF00000000);\n let c = (z - f * f) / (s + f);\n x = 0.5 * pio2_hi - (2 * s * r - (pio2_lo - 2 * c) - (0.5 * pio2_hi - 2 * f));\n }\n if (hx >> 31) return -x;\n return x;\n }\n\n export function asinh(x: f64): f64 { // see: musl/src/math/asinh.c\n const c = reinterpret(0x3FE62E42FEFA39EF); // 0.693147180559945309417232121458176568\n var u = reinterpret(x);\n var e = u >> 52 & 0x7FF;\n var y = reinterpret(u & 0x7FFFFFFFFFFFFFFF);\n if (e >= 0x3FF + 26) y = log(y) + c;\n else if (e >= 0x3FF + 1) y = log(2 * y + 1 / (builtin_sqrt(y * y + 1) + y));\n else if (e >= 0x3FF - 26) y = log1p(y + y * y / (builtin_sqrt(y * y + 1) + 1));\n return builtin_copysign(y, x);\n }\n\n export function atan(x: f64): f64 { // see musl/src/math/atan.c and SUN COPYRIGHT NOTICE above\n const\n atanhi0 = reinterpret(0x3FDDAC670561BB4F), // 4.63647609000806093515e-01\n atanhi1 = reinterpret(0x3FE921FB54442D18), // 7.85398163397448278999e-01\n atanhi2 = reinterpret(0x3FEF730BD281F69B), // 9.82793723247329054082e-01\n atanhi3 = reinterpret(0x3FF921FB54442D18), // 1.57079632679489655800e+00\n atanlo0 = reinterpret(0x3C7A2B7F222F65E2), // 2.26987774529616870924e-17\n atanlo1 = reinterpret(0x3C81A62633145C07), // 3.06161699786838301793e-17\n atanlo2 = reinterpret(0x3C7007887AF0CBBD), // 1.39033110312309984516e-17\n atanlo3 = reinterpret(0x3C91A62633145C07), // 6.12323399573676603587e-17\n aT0 = reinterpret(0x3FD555555555550D), // 3.33333333333329318027e-01\n aT1 = reinterpret(0xBFC999999998EBC4), // -1.99999999998764832476e-01\n aT2 = reinterpret(0x3FC24924920083FF), // 1.42857142725034663711e-01\n aT3 = reinterpret(0xBFBC71C6FE231671), // -1.11111104054623557880e-01,\n aT4 = reinterpret(0x3FB745CDC54C206E), // 9.09088713343650656196e-02\n aT5 = reinterpret(0xBFB3B0F2AF749A6D), // -7.69187620504482999495e-02\n aT6 = reinterpret(0x3FB10D66A0D03D51), // 6.66107313738753120669e-02\n aT7 = reinterpret(0xBFADDE2D52DEFD9A), // -5.83357013379057348645e-02\n aT8 = reinterpret(0x3FA97B4B24760DEB), // 4.97687799461593236017e-02\n aT9 = reinterpret(0xBFA2B4442C6A6C2F), // -3.65315727442169155270e-02\n aT10 = reinterpret(0x3F90AD3AE322DA11), // 1.62858201153657823623e-02\n Ox1p_120f = reinterpret(0x03800000);\n var ix = (reinterpret(x) >> 32);\n var sx = x;\n ix &= 0x7FFFFFFF;\n var z: f64;\n if (ix >= 0x44100000) {\n if (isNaN(x)) return x;\n z = atanhi3 + Ox1p_120f;\n return builtin_copysign(z, sx);\n }\n var id: i32;\n if (ix < 0x3FDC0000) {\n if (ix < 0x3E400000) return x;\n id = -1;\n } else {\n x = builtin_abs(x);\n if (ix < 0x3FF30000) {\n if (ix < 0x3FE60000) {\n id = 0;\n x = (2.0 * x - 1.0) / (2.0 + x);\n } else {\n id = 1;\n x = (x - 1.0) / (x + 1.0);\n }\n } else {\n if (ix < 0x40038000) {\n id = 2;\n x = (x - 1.5) / (1.0 + 1.5 * x);\n } else {\n id = 3;\n x = -1.0 / x;\n }\n }\n }\n z = x * x;\n var w = z * z;\n var s1 = z * (aT0 + w * (aT2 + w * (aT4 + w * (aT6 + w * (aT8 + w * aT10)))));\n var s2 = w * (aT1 + w * (aT3 + w * (aT5 + w * (aT7 + w * aT9))));\n var s3 = x * (s1 + s2);\n if (id < 0) return x - s3;\n switch (id) {\n case 0: { z = atanhi0 - ((s3 - atanlo0) - x); break; }\n case 1: { z = atanhi1 - ((s3 - atanlo1) - x); break; }\n case 2: { z = atanhi2 - ((s3 - atanlo2) - x); break; }\n case 3: { z = atanhi3 - ((s3 - atanlo3) - x); break; }\n default: unreachable();\n }\n return builtin_copysign(z, sx);\n }\n\n export function atanh(x: f64): f64 { // see: musl/src/math/atanh.c\n var u = reinterpret(x);\n var e = u >> 52 & 0x7FF;\n var s = u >> 63;\n u &= 0x7FFFFFFFFFFFFFFF;\n var y = reinterpret(u);\n if (e < 0x3FF - 1) {\n if (e >= 0x3FF - 32) y = 0.5 * log1p(2 * y + 2 * y * y / (1 - y));\n } else {\n y = 0.5 * log1p(2 * (y / (1 - y)));\n }\n return builtin_copysign(y, x);\n }\n\n export function atan2(y: f64, x: f64): f64 { // see: musl/src/math/atan2.c and SUN COPYRIGHT NOTICE above\n const pi_lo = reinterpret(0x3CA1A62633145C07); // 1.2246467991473531772E-16\n if (isNaN(x) || isNaN(y)) return x + y;\n var u = reinterpret(x);\n var ix = (u >> 32);\n var lx = u;\n u = reinterpret(y);\n var iy = (u >> 32);\n var ly = u;\n if ((ix - 0x3FF00000 | lx) == 0) return atan(y);\n var m = ((iy >> 31) & 1) | ((ix >> 30) & 2);\n ix = ix & 0x7FFFFFFF;\n iy = iy & 0x7FFFFFFF;\n if ((iy | ly) == 0) {\n switch (m) {\n case 0:\n case 1: return y;\n case 2: return PI;\n case 3: return -PI;\n }\n }\n if ((ix | lx) == 0) return m & 1 ? -PI / 2 : PI / 2;\n if (ix == 0x7FF00000) {\n if (iy == 0x7FF00000) {\n switch (m) {\n case 0: return PI / 4;\n case 1: return -PI / 4;\n case 2: return 3 * PI / 4;\n case 3: return -3 * PI / 4;\n }\n } else {\n switch (m) {\n case 0: return 0.0;\n case 1: return -0.0;\n case 2: return PI;\n case 3: return -PI;\n }\n }\n }\n var z: f64;\n if (ix + (64 << 20) < iy || iy == 0x7FF00000) return m & 1 ? -PI / 2 : PI / 2;\n if ((m & 2) && iy + (64 << 20) < ix) z = 0;\n else z = atan(builtin_abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return PI - (z - pi_lo);\n case 3: return (z - pi_lo) - PI;\n }\n unreachable();\n return 0;\n }\n\n export function cbrt(x: f64): f64 { // see: musl/src/math/cbrt.c and SUN COPYRIGHT NOTICE above\n const\n B1 = 715094163,\n B2 = 696219795,\n P0 = reinterpret(0x3FFE03E60F61E692), // 1.87595182427177009643\n P1 = reinterpret(0xBFFE28E092F02420), // -1.88497979543377169875\n P2 = reinterpret(0x3FF9F1604A49D6C2), // 1.621429720105354466140\n P3 = reinterpret(0xBFE844CBBEE751D9), // -0.758397934778766047437\n P4 = reinterpret(0x3FC2B000D4E4EDD7), // 0.145996192886612446982\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32) & 0x7FFFFFFF;\n if (hx >= 0x7FF00000) return x + x;\n if (hx < 0x00100000) {\n u = reinterpret(x * Ox1p54);\n hx = (u >> 32) & 0x7FFFFFFF;\n if (hx == 0) return x;\n hx = hx / 3 + B2;\n } else {\n hx = hx / 3 + B1;\n }\n u &= 1 << 63;\n u |= hx << 32;\n var t = reinterpret(u);\n var r = (t * t) * (t / x);\n t = t * ((P0 + r * (P1 + r * P2)) + ((r * r) * r) * (P3 + r * P4));\n t = reinterpret((reinterpret(t) + 0x80000000) & 0xFFFFFFFFC0000000);\n var s = t * t;\n r = x / s;\n r = (r - t) / (2 * t + r);\n t = t + t * r;\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function ceil(x: f64): f64 {\n return builtin_ceil(x);\n }\n\n export function clz32(x: f64): f64 {\n if (!isFinite(x)) return 32;\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n return builtin_clz(\n (x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))\n );\n }\n\n export function cos(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function cosh(x: f64): f64 { // see: musl/src/math/cosh.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFFFFFFFFFF;\n x = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n if (w < 0x3FE62E42) {\n if (w < 0x3FF00000 - (26 << 20)) return 1;\n t = expm1(x);\n // return 1 + t * t / (2 * (1 + t));\n return 1 + t * t / (2 + 2 * t);\n }\n if (w < 0x40862E42) {\n t = exp(x);\n return 0.5 * (t + 1 / t);\n }\n t = expo2(x);\n return t;\n }\n\n export function exp(x: f64): f64 { // see: musl/src/math/exp.c and SUN COPYRIGHT NOTICE above\n const\n ln2hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n invln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n P1 = reinterpret(0x3FC555555555553E), // 1.66666666666666019037e-01\n P2 = reinterpret(0xBF66C16C16BEBD93), // -2.77777777770155933842e-03\n P3 = reinterpret(0x3F11566AAF25DE2C), // 6.61375632143793436117e-05\n P4 = reinterpret(0xBEBBBD41C5D26BF1), // -1.65339022054652515390e-06\n P5 = reinterpret(0x3E66376972BEA4D0), // 4.13813679705723846039e-08\n overflow = reinterpret(0x40862E42FEFA39EF), // 709.782712893383973096\n underflow = reinterpret(0xC0874910D52D3051), // -745.13321910194110842\n Ox1p1023 = reinterpret(0x7FE0000000000000);\n var hx = (reinterpret(x) >> 32);\n var sign_ = (hx >> 31);\n hx &= 0x7FFFFFFF;\n if (hx >= 0x4086232B) {\n if (isNaN(x)) return x;\n if (x > overflow) return x * Ox1p1023;\n if (x < underflow) return 0;\n }\n var hi: f64, lo: f64 = 0;\n var k = 0;\n if (hx > 0x3FD62E42) {\n if (hx >= 0x3FF0A2B2) {\n k = (invln2 * x + builtin_copysign(0.5, x));\n } else {\n k = 1 - (sign_ << 1);\n }\n hi = x - k * ln2hi;\n lo = k * ln2lo;\n x = hi - lo;\n } else if (hx > 0x3E300000) {\n hi = x;\n } else return 1.0 + x;\n var xs = x * x;\n // var c = x - xp2 * (P1 + xp2 * (P2 + xp2 * (P3 + xp2 * (P4 + xp2 * P5))));\n var xq = xs * xs;\n var c = x - (xs * P1 + xq * ((P2 + xs * P3) + xq * (P4 + xs * P5)));\n var y = 1.0 + (x * c / (2 - c) - lo + hi);\n if (k == 0) return y;\n return scalbn(y, k);\n }\n\n export function expm1(x: f64): f64 { // see: musl/src/math/expm1.c and SUN COPYRIGHT NOTICE above\n const\n o_threshold = reinterpret(0x40862E42FEFA39EF), // 7.09782712893383973096e+02\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n invln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n Q1 = reinterpret(0xBFA11111111110F4), // -3.33333333333331316428e-02\n Q2 = reinterpret(0x3F5A01A019FE5585), // 1.58730158725481460165e-03\n Q3 = reinterpret(0xBF14CE199EAADBB7), // -7.93650757867487942473e-05\n Q4 = reinterpret(0x3ED0CFCA86E65239), // 4.00821782732936239552e-06\n Q5 = reinterpret(0xBE8AFDB76E09C32D), // -2.01099218183624371326e-07\n Ox1p1023 = reinterpret(0x7FE0000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32 & 0x7FFFFFFF);\n var k = 0, sign_ = (u >> 63);\n if (hx >= 0x4043687A) {\n if (isNaN(x)) return x;\n if (sign_) return -1;\n if (x > o_threshold) return x * Ox1p1023;\n }\n var c = 0.0, t: f64;\n if (hx > 0x3FD62E42) {\n k = select(\n 1 - (sign_ << 1),\n (invln2 * x + builtin_copysign(0.5, x)),\n hx < 0x3FF0A2B2\n );\n t = k;\n let hi = x - t * ln2_hi;\n let lo = t * ln2_lo;\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (hx < 0x3C900000) return x;\n var hfx = 0.5 * x;\n var hxs = x * hfx;\n // var r1 = 1.0 + hxs * (Q1 + hxs * (Q2 + hxs * (Q3 + hxs * (Q4 + hxs * Q5))));\n var hxq = hxs * hxs;\n var r1 = (1.0 + hxs * Q1) + hxq * ((Q2 + hxs * Q3) + hxq * (Q4 + hxs * Q5));\n t = 3.0 - r1 * hfx;\n var e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k == 0) return x - (x * e - hxs);\n e = x * (e - c) - c;\n e -= hxs;\n if (k == -1) return 0.5 * (x - e) - 0.5;\n if (k == 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n u = (0x3FF + k) << 52;\n var twopk = reinterpret(u);\n var y: f64;\n if (k < 0 || k > 56) {\n y = x - e + 1.0;\n if (k == 1024) y = y * 2.0 * Ox1p1023;\n else y = y * twopk;\n return y - 1.0;\n }\n u = (0x3FF - k) << 52;\n y = reinterpret(u);\n if (k < 20) y = (1 - y) - e;\n else y = 1 - (e + y);\n return (x + y) * twopk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function floor(x: f64): f64 {\n return builtin_floor(x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function fround(x: f64): f32 {\n return x;\n }\n\n export function hypot(x: f64, y: f64): f64 { // see: musl/src/math/hypot.c\n const\n SPLIT = reinterpret(0x41A0000000000000) + 1, // 0x1p27 + 1\n Ox1p700 = reinterpret(0x6BB0000000000000),\n Ox1p_700 = reinterpret(0x1430000000000000);\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n ux &= 0x7FFFFFFFFFFFFFFF;\n uy &= 0x7FFFFFFFFFFFFFFF;\n if (ux < uy) {\n let ut = ux;\n ux = uy;\n uy = ut;\n }\n var ex = (ux >> 52);\n var ey = (uy >> 52);\n y = reinterpret(uy);\n if (ey == 0x7FF) return y;\n x = reinterpret(ux);\n if (ex == 0x7FF || uy == 0) return x;\n if (ex - ey > 64) return x + y;\n var z = 1.0;\n if (ex > 0x3FF + 510) {\n z = Ox1p700;\n x *= Ox1p_700;\n y *= Ox1p_700;\n } else if (ey < 0x3FF - 450) {\n z = Ox1p_700;\n x *= Ox1p700;\n y *= Ox1p700;\n }\n var c = x * SPLIT;\n var h = x - c + c;\n var l = x - h;\n var hx = x * x;\n var lx = h * h - hx + (2 * h + l) * l;\n c = y * SPLIT;\n h = y - c + c;\n l = y - h;\n var hy = y * y;\n var ly = h * h - hy + (2 * h + l) * l;\n return z * builtin_sqrt(ly + lx + hy + hx);\n }\n\n export function imul(x: f64, y: f64): f64 {\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n if (!isFinite(x + y)) return 0;\n const inv32 = 1.0 / 4294967296;\n return (\n (x - 4294967296 * builtin_floor(x * inv32)) *\n (y - 4294967296 * builtin_floor(y * inv32))\n );\n }\n\n export function log(x: f64): f64 { // see: musl/src/math/log.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var dk = k;\n return s * (hfsq + r) + dk * ln2_lo - hfsq + f + dk * ln2_hi;\n }\n\n export function log10(x: f64): f64 { // see: musl/src/math/log10.c and SUN COPYRIGHT NOTICE above\n const\n ivln10hi = reinterpret(0x3FDBCB7B15200000), // 4.34294481878168880939e-01\n ivln10lo = reinterpret(0x3DBB9438CA9AADD5), // 2.50829467116452752298e-11\n log10_2hi = reinterpret(0x3FD34413509F6000), // 3.01029995663611771306e-01\n log10_2lo = reinterpret(0x3D59FEF311F12B36), // 3.69423907715893078616e-13\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var hi = f - hfsq;\n u = reinterpret(hi);\n u &= 0xFFFFFFFF00000000;\n hi = reinterpret(u);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var val_hi = hi * ivln10hi;\n var dk = k;\n var y = dk * log10_2hi;\n var val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi;\n w = y + val_hi;\n val_lo += (y - w) + val_hi;\n return val_lo + w;\n }\n\n export function log1p(x: f64): f64 { // see: musl/src/math/log1p.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3FE62E42FEE00000), // 6.93147180369123816490e-01\n ln2_lo = reinterpret(0x3DEA39EF35793C76), // 1.90821492927058770002e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244); // 1.479819860511658591e-01\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 1;\n var c = 0.0, f = 0.0;\n if (hx < 0x3FDA827A || (hx >> 31)) {\n if (hx >= 0xBFF00000) {\n if (x == -1) return x / 0.0;\n return (x - x) / 0.0;\n }\n if (hx << 1 < 0x3CA00000 << 1) return x;\n if (hx <= 0xBFD2BEC4) {\n k = 0;\n c = 0;\n f = x;\n }\n } else if (hx >= 0x7FF00000) return x;\n if (k) {\n u = reinterpret(1 + x);\n let hu = (u >> 32);\n hu += 0x3FF00000 - 0x3FE6A09E;\n k = (hu >> 20) - 0x3FF;\n if (k < 54) {\n let uf = reinterpret(u);\n c = k >= 2 ? 1 - (uf - x) : x - (uf - 1);\n c /= uf;\n } else c = 0;\n hu = (hu & 0x000FFFFF) + 0x3FE6A09E;\n u = hu << 32 | (u & 0xFFFFFFFF);\n f = reinterpret(u) - 1;\n }\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var dk = k;\n return s * (hfsq + r) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;\n }\n\n export function log2(x: f64): f64 { // see: musl/src/math/log2.c and SUN COPYRIGHT NOTICE above\n const\n ivln2hi = reinterpret(0x3FF7154765200000), // 1.44269504072144627571e+00\n ivln2lo = reinterpret(0x3DE705FC2EEFA200), // 1.67517131648865118353e-10\n Lg1 = reinterpret(0x3FE5555555555593), // 6.666666666666735130e-01\n Lg2 = reinterpret(0x3FD999999997FA04), // 3.999999999940941908e-01\n Lg3 = reinterpret(0x3FD2492494229359), // 2.857142874366239149e-01\n Lg4 = reinterpret(0x3FCC71C51D8E78AF), // 2.222219843214978396e-01\n Lg5 = reinterpret(0x3FC7466496CB03DE), // 1.818357216161805012e-01\n Lg6 = reinterpret(0x3FC39A09D078C69F), // 1.531383769920937332e-01\n Lg7 = reinterpret(0x3FC2F112DF3E5244), // 1.479819860511658591e-01\n Ox1p54 = reinterpret(0x4350000000000000);\n var u = reinterpret(x);\n var hx = (u >> 32);\n var k = 0;\n if (hx < 0x00100000 || (hx >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (hx >> 31) return (x - x) / 0.0;\n k -= 54;\n x *= Ox1p54;\n u = reinterpret(x);\n hx = (u >> 32);\n } else if (hx >= 0x7FF00000) return x;\n else if (hx == 0x3FF00000 && u << 32 == 0) return 0;\n hx += 0x3FF00000 - 0x3FE6A09E;\n k += (hx >> 20) - 0x3FF;\n hx = (hx & 0x000FFFFF) + 0x3FE6A09E;\n u = hx << 32 | (u & 0xFFFFFFFF);\n x = reinterpret(u);\n var f = x - 1.0;\n var hfsq = 0.5 * f * f;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * (Lg4 + w * Lg6));\n var t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));\n var r = t2 + t1;\n var hi = f - hfsq;\n u = reinterpret(hi);\n u &= 0xFFFFFFFF00000000;\n hi = reinterpret(u);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var val_hi = hi * ivln2hi;\n var val_lo = (lo + hi) * ivln2lo + lo * ivln2hi;\n var y = k;\n w = y + val_hi;\n val_lo += (y - w) + val_hi;\n val_hi = w;\n return val_lo + val_hi;\n }\n\n // @ts-ignore: decorator\n @inline\n export function max(value1: f64, value2: f64): f64 {\n return builtin_max(value1, value2);\n }\n\n // @ts-ignore: decorator\n @inline\n export function min(value1: f64, value2: f64): f64 {\n return builtin_min(value1, value2);\n }\n\n export function pow(x: f64, y: f64): f64 { // see: musl/src/math/pow.c and SUN COPYRIGHT NOTICE above\n const\n dp_h1 = reinterpret(0x3FE2B80340000000), // 5.84962487220764160156e-01\n dp_l1 = reinterpret(0x3E4CFDEB43CFD006), // 1.35003920212974897128e-08\n two53 = reinterpret(0x4340000000000000), // 9007199254740992.0\n huge = reinterpret(0x7E37E43C8800759C), // 1e+300\n tiny = reinterpret(0x01A56E1FC2F8F359), // 1e-300\n L1 = reinterpret(0x3FE3333333333303), // 5.99999999999994648725e-01\n L2 = reinterpret(0x3FDB6DB6DB6FABFF), // 4.28571428578550184252e-01\n L3 = reinterpret(0x3FD55555518F264D), // 3.33333329818377432918e-01\n L4 = reinterpret(0x3FD17460A91D4101), // 2.72728123808534006489e-01\n L5 = reinterpret(0x3FCD864A93C9DB65), // 2.30660745775561754067e-01\n L6 = reinterpret(0x3FCA7E284A454EEF), // 2.06975017800338417784e-01\n P1 = reinterpret(0x3FC555555555553E), // 1.66666666666666019037e-01\n P2 = reinterpret(0xBF66C16C16BEBD93), // -2.77777777770155933842e-03\n P3 = reinterpret(0x3F11566AAF25DE2C), // 6.61375632143793436117e-05\n P4 = reinterpret(0xBEBBBD41C5D26BF1), // -1.65339022054652515390e-06\n P5 = reinterpret(0x3E66376972BEA4D0), // 4.13813679705723846039e-08\n lg2 = reinterpret(0x3FE62E42FEFA39EF), // 6.93147180559945286227e-01\n lg2_h = reinterpret(0x3FE62E4300000000), // 6.93147182464599609375e-01\n lg2_l = reinterpret(0xBE205C610CA86C39), // -1.90465429995776804525e-09\n ovt = reinterpret(0x3C971547652B82FE), // 8.0085662595372944372e-017\n cp = reinterpret(0x3FEEC709DC3A03FD), // 9.61796693925975554329e-01\n cp_h = reinterpret(0x3FEEC709E0000000), // 9.61796700954437255859e-01\n cp_l = reinterpret(0xBE3E2FE0145B01F5), // -7.02846165095275826516e-09\n ivln2 = reinterpret(0x3FF71547652B82FE), // 1.44269504088896338700e+00\n ivln2_h = reinterpret(0x3FF7154760000000), // 1.44269502162933349609e+00\n ivln2_l = reinterpret(0x3E54AE0BF85DDF44), // 1.92596299112661746887e-08\n inv3 = reinterpret(0x3FD5555555555555); // 0.3333333333333333333333\n var u_ = reinterpret(x);\n var hx = (u_ >> 32);\n var lx = u_;\n u_ = reinterpret(y);\n var hy = (u_ >> 32);\n var ly = u_;\n var ix = hx & 0x7FFFFFFF;\n var iy = hy & 0x7FFFFFFF;\n if ((iy | ly) == 0) return 1.0; // x**0 = 1, even if x is NaN\n // if (hx == 0x3FF00000 && lx == 0) return 1.0; // C: 1**y = 1, even if y is NaN, JS: NaN\n if ( // NaN if either arg is NaN\n ix > 0x7FF00000 || (ix == 0x7FF00000 && lx != 0) ||\n iy > 0x7FF00000 || (iy == 0x7FF00000 && ly != 0)\n ) return x + y;\n var yisint = 0, k: i32;\n if (hx < 0) {\n if (iy >= 0x43400000) yisint = 2;\n else if (iy >= 0x3FF00000) {\n k = (iy >> 20) - 0x3FF;\n let kcond = k > 20;\n let offset = select(52, 20, kcond) - k;\n let Ly = select(ly, iy, kcond);\n let jj = Ly >> offset;\n if ((jj << offset) == Ly) yisint = 2 - (jj & 1);\n }\n }\n if (ly == 0) {\n if (iy == 0x7FF00000) { // y is +-inf\n if (((ix - 0x3FF00000) | lx) == 0) return NaN; // C: (-1)**+-inf is 1, JS: NaN\n else if (ix >= 0x3FF00000) return hy >= 0 ? y : 0.0; // (|x|>1)**+-inf = inf,0\n else return hy >= 0 ? 0.0 : -y; // (|x|<1)**+-inf = 0,inf\n }\n if (iy == 0x3FF00000) {\n if (hy >= 0) return x;\n return 1 / x;\n }\n if (hy == 0x40000000) return x * x;\n if (hy == 0x3FE00000) {\n if (hx >= 0) return builtin_sqrt(x);\n }\n }\n var ax = builtin_abs(x), z: f64;\n if (lx == 0) {\n if (ix == 0 || ix == 0x7FF00000 || ix == 0x3FF00000) {\n z = ax;\n if (hy < 0) z = 1.0 / z;\n if (hx < 0) {\n if (((ix - 0x3FF00000) | yisint) == 0) {\n let d = z - z;\n z = d / d;\n } else if (yisint == 1) z = -z;\n }\n return z;\n }\n }\n var s = 1.0;\n if (hx < 0) {\n if (yisint == 0) {\n let d = x - x;\n return d / d;\n }\n if (yisint == 1) s = -1.0;\n }\n var t1: f64, t2: f64, p_h: f64, p_l: f64, r: f64, t: f64, u: f64, v: f64, w: f64;\n var j: i32, n: i32;\n if (iy > 0x41E00000) {\n if (iy > 0x43F00000) {\n if (ix <= 0x3FEFFFFF) return hy < 0 ? huge * huge : tiny * tiny;\n if (ix >= 0x3FF00000) return hy > 0 ? huge * huge : tiny * tiny;\n }\n if (ix < 0x3FEFFFFF) return hy < 0 ? s * huge * huge : s * tiny * tiny;\n if (ix > 0x3FF00000) return hy > 0 ? s * huge * huge : s * tiny * tiny;\n t = ax - 1.0;\n w = (t * t) * (0.5 - t * (inv3 - t * 0.25));\n u = ivln2_h * t;\n v = t * ivln2_l - w * ivln2;\n t1 = u + v;\n t1 = reinterpret(reinterpret(t1) & 0xFFFFFFFF00000000);\n t2 = v - (t1 - u);\n } else {\n let ss: f64, s2: f64, s_h: f64, s_l: f64, t_h: f64, t_l: f64;\n n = 0;\n if (ix < 0x00100000) {\n ax *= two53;\n n -= 53;\n ix = (reinterpret(ax) >> 32);\n }\n n += (ix >> 20) - 0x3FF;\n j = ix & 0x000FFFFF;\n ix = j | 0x3FF00000;\n if (j <= 0x3988E) k = 0;\n else if (j < 0xBB67A) k = 1;\n else {\n k = 0;\n n += 1;\n ix -= 0x00100000;\n }\n ax = reinterpret(reinterpret(ax) & 0xFFFFFFFF | (ix << 32));\n let bp = select(1.5, 1.0, k); // k ? 1.5 : 1.0\n u = ax - bp;\n v = 1.0 / (ax + bp);\n ss = u * v;\n s_h = ss;\n s_h = reinterpret(reinterpret(s_h) & 0xFFFFFFFF00000000);\n t_h = reinterpret((((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18)) << 32);\n t_l = ax - (t_h - bp);\n s_l = v * ((u - s_h * t_h) - s_h * t_l);\n s2 = ss * ss;\n r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));\n r += s_l * (s_h + ss);\n s2 = s_h * s_h;\n t_h = 3.0 + s2 + r;\n t_h = reinterpret(reinterpret(t_h) & 0xFFFFFFFF00000000);\n t_l = r - ((t_h - 3.0) - s2);\n u = s_h * t_h;\n v = s_l * t_h + t_l * ss;\n p_h = u + v;\n p_h = reinterpret(reinterpret(p_h) & 0xFFFFFFFF00000000);\n p_l = v - (p_h - u);\n let z_h = cp_h * p_h;\n let dp_l = select(dp_l1, 0.0, k);\n let z_l = cp_l * p_h + p_l * cp + dp_l;\n t = n;\n let dp_h = select(dp_h1, 0.0, k);\n t1 = ((z_h + z_l) + dp_h) + t;\n t1 = reinterpret(reinterpret(t1) & 0xFFFFFFFF00000000);\n t2 = z_l - (((t1 - t) - dp_h) - z_h);\n }\n var y1 = y;\n y1 = reinterpret(reinterpret(y1) & 0xFFFFFFFF00000000);\n p_l = (y - y1) * t1 + y * t2;\n p_h = y1 * t1;\n z = p_l + p_h;\n u_ = reinterpret(z);\n j = (u_ >> 32);\n var i = u_;\n if (j >= 0x40900000) {\n if (((j - 0x40900000) | i) != 0) return s * huge * huge;\n if (p_l + ovt > z - p_h) return s * huge * huge;\n } else if ((j & 0x7FFFFFFF) >= 0x4090CC00) {\n if (((j - 0xC090CC00) | i) != 0) return s * tiny * tiny;\n if (p_l <= z - p_h) return s * tiny * tiny;\n }\n i = j & 0x7FFFFFFF;\n k = (i >> 20) - 0x3FF;\n n = 0;\n if (i > 0x3FE00000) {\n n = j + (0x00100000 >> (k + 1));\n k = ((n & 0x7FFFFFFF) >> 20) - 0x3FF;\n t = 0.0;\n t = reinterpret((n & ~(0x000FFFFF >> k)) << 32);\n n = ((n & 0x000FFFFF) | 0x00100000) >> (20 - k);\n if (j < 0) n = -n;\n p_h -= t;\n }\n t = p_l + p_h;\n t = reinterpret(reinterpret(t) & 0xFFFFFFFF00000000);\n u = t * lg2_h;\n v = (p_l - (t - p_h)) * lg2 + t * lg2_l;\n z = u + v;\n w = v - (z - u);\n t = z * z;\n t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n r = (z * t1) / (t1 - 2.0) - (w + z * w);\n z = 1.0 - (r - z);\n j = (reinterpret(z) >> 32);\n j += n << 20;\n if ((j >> 20) <= 0) z = scalbn(z, n);\n else z = reinterpret(reinterpret(z) & 0xFFFFFFFF | (j << 32));\n return s * z;\n }\n\n export function seedRandom(value: i64): void {\n assert(value);\n random_seeded = true;\n random_state0_64 = murmurHash3(value);\n random_state1_64 = murmurHash3(~random_state0_64);\n random_state0_32 = splitMix32(value);\n random_state1_32 = splitMix32(random_state0_32);\n }\n\n export function random(): f64 { // see: v8/src/base/random-number-generator.cc\n if (!random_seeded) throw new Error("PRNG must be seeded.");\n var s1 = random_state0_64;\n var s0 = random_state1_64;\n random_state0_64 = s0;\n s1 ^= s1 << 23;\n s1 ^= s1 >> 17;\n s1 ^= s0;\n s1 ^= s0 >> 26;\n random_state1_64 = s1;\n var r = ((s0 + s1) & 0x000FFFFFFFFFFFFF) | 0x3FF0000000000000;\n return reinterpret(r) - 1;\n }\n\n // @ts-ignore: decorator\n @inline\n export function round(x: f64): f64 {\n return builtin_copysign(builtin_floor(x + 0.5), x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function sign(x: f64): f64 {\n if (ASC_SHRINK_LEVEL > 0) {\n return builtin_abs(x) > 0 ? builtin_copysign(1, x) : x;\n } else {\n return x > 0 ? 1 : x < 0 ? -1 : x;\n }\n }\n\n // @ts-ignore: decorator\n @inline\n export function signbit(x: f64): bool {\n // In ECMAScript all NaN values are indistinguishable from each other\n // so we need handle NaN and negative NaN in similar way\n return ((reinterpret(x) >>> 63) & i32(x == x));\n }\n\n export function sin(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function sinh(x: f64): f64 { // see: musl/src/math/sinh.c\n var u = reinterpret(x) & 0x7FFFFFFFFFFFFFFF;\n var absx = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n var h = builtin_copysign(0.5, x);\n if (w < 0x40862E42) {\n t = expm1(absx);\n if (w < 0x3FF00000) {\n if (w < 0x3FF00000 - (26 << 20)) return x;\n return h * (2 * t - t * t / (t + 1));\n }\n return h * (t + t / (t + 1));\n }\n t = 2 * h * expo2(absx);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function sqrt(x: f64): f64 {\n return builtin_sqrt(x);\n }\n\n export function tan(x: f64): f64 { // TODO\n unreachable();\n return 0;\n }\n\n export function tanh(x: f64): f64 { // see: musl/src/math/tanh.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFFFFFFFFFF;\n var y = reinterpret(u);\n var w = (u >> 32);\n var t: f64;\n if (w > 0x3FE193EA) {\n if (w > 0x40340000) {\n t = 1 - 0 / y;\n } else {\n t = expm1(2 * y);\n t = 1 - 2 / (t + 2);\n }\n } else if (w > 0x3FD058AE) {\n t = expm1(2 * y);\n t = t / (t + 2);\n } else if (w >= 0x00100000) {\n t = expm1(-2 * y);\n t = -t / (t + 2);\n } else t = y;\n return builtin_copysign(t, x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function trunc(x: f64): f64 {\n return builtin_trunc(x);\n }\n\n export function scalbn(x: f64, n: i32): f64 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbn.c\n const\n Ox1p53 = reinterpret(0x4340000000000000),\n Ox1p1023 = reinterpret(0x7FE0000000000000),\n Ox1p_1022 = reinterpret(0x0010000000000000);\n var y = x;\n if (n > 1023) {\n y *= Ox1p1023;\n n -= 1023;\n if (n > 1023) {\n y *= Ox1p1023;\n n = builtin_min(n - 1023, 1023);\n }\n } else if (n < -1022) {\n /* make sure final n < -53 to avoid double\n rounding in the subnormal range */\n y *= Ox1p_1022 * Ox1p53;\n n += 1022 - 53;\n if (n < -1022) {\n y *= Ox1p_1022 * Ox1p53;\n n = builtin_max(n + 1022 - 53, -1022);\n }\n }\n return y * reinterpret((0x3FF + n) << 52);\n }\n\n export function mod(x: f64, y: f64): f64 { // see: musl/src/math/fmod.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 52 & 0x7FF);\n var ey = (uy >> 52 & 0x7FF);\n var sx = ux >> 63;\n var uy1 = uy << 1;\n if (uy1 == 0 || ex == 0x7FF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n var ux1 = ux << 1;\n if (ux1 <= uy1) {\n if (ux1 == uy1) return 0 * x;\n return x;\n }\n if (!ex) {\n ex -= builtin_clz(ux << 12);\n ux <<= -ex + 1;\n } else {\n ux &= -1 >> 12;\n ux |= 1 << 52;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 12);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 12;\n uy |= 1 << 52;\n }\n while (ex > ey) {\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n ux <<= 1;\n --ex;\n }\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n // for (; !(ux >> 52); ux <<= 1) --ex;\n var shift = builtin_clz(ux << 11);\n ex -= shift;\n ux <<= shift;\n if (ex > 0) {\n ux -= 1 << 52;\n ux |= ex << 52;\n } else {\n ux >>= -ex + 1;\n }\n ux |= sx << 63;\n return reinterpret(ux);\n }\n\n export function rem(x: f64, y: f64): f64 { // see: musl/src/math/remquo.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 52 & 0x7FF);\n var ey = (uy >> 52 & 0x7FF);\n var sx = (ux >> 63);\n if (uy << 1 == 0 || ex == 0x7FF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n if (ux << 1 == 0) return x;\n var uxi = ux;\n if (!ex) {\n ex -= builtin_clz(uxi << 12);\n uxi <<= -ex + 1;\n } else {\n uxi &= -1 >> 12;\n uxi |= 1 << 52;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 12);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 12;\n uy |= 1 << 52;\n }\n var q: u32 = 0;\n do {\n if (ex < ey) {\n if (ex + 1 == ey) break; // goto end\n return x;\n }\n while (ex > ey) {\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n uxi <<= 1;\n q <<= 1;\n --ex;\n }\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n if (uxi == 0) ex = -60;\n else {\n let shift = builtin_clz(uxi << 11);\n ex -= shift;\n uxi <<= shift;\n }\n break;\n } while (false);\n // end:\n if (ex > 0) {\n uxi -= 1 << 52;\n uxi |= ex << 52;\n } else {\n uxi >>= -ex + 1;\n }\n x = reinterpret(uxi);\n y = builtin_abs(y);\n var x2 = x + x;\n if (ex == ey || (ex + 1 == ey && (x2 > y || (x2 == y && (q & 1))))) {\n x -= y;\n // ++q;\n }\n return sx ? -x : x;\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar rempio2f_y: f64;\n\n// @ts-ignore: decorator\n@lazy\nconst PIO2_TABLE: u64[] = [\n 0xA2F9836E4E441529,\n 0xFC2757D1F534DDC0,\n 0xDB6295993C439041,\n 0xFE5163ABDEBBC561\n];\n\nfunction Rf(z: f32): f32 { // Rational approximation of (asin(x)-x)/x^3\n const // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above\n pS0 = reinterpret(0x3E2AAA75), // 1.6666586697e-01f\n pS1 = reinterpret(0xBD2F13BA), // -4.2743422091e-02f\n pS2 = reinterpret(0xBC0DD36B), // -8.6563630030e-03f\n qS1 = reinterpret(0xBF34E5AE); // -7.0662963390e-01f\n var p = z * (pS0 + z * (pS1 + z * pS2));\n var q: f32 = 1 + z * qS1;\n return p / q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction expo2f(x: f32): f32 { // exp(x)/2 for x >= log(DBL_MAX)\n const // see: musl/src/math/__expo2f.c\n k = 235,\n kln2 = reinterpret(0x4322E3BC); // 0x1.45c778p+7f\n var scale = reinterpret((0x7F + (k >> 1)) << 23);\n return NativeMathf.exp(x - kln2) * scale * scale;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction pio2_large_quot(x: f32, u: i32): i32 { // see: jdh8/metallic/blob/master/src/math/float/rem_pio2f.c\n const coeff = reinterpret(0x3BF921FB54442D18); // π * 0x1p-65 = 8.51530395021638647334e-20\n const bits = PIO2_TABLE;\n\n var offset = (u >> 23) - 152;\n var index = offset >> 6;\n var shift = offset & 63;\n\n var b0 = unchecked(bits[index + 0]);\n var b1 = unchecked(bits[index + 1]);\n var lo: u64;\n\n if (shift > 32) {\n let b2 = unchecked(bits[index + 2]);\n lo = b2 >> (96 - shift);\n lo |= b1 << (shift - 32);\n } else {\n lo = b1 >> (32 - shift);\n }\n\n var hi = (b1 >> (64 - shift)) | (b0 << shift);\n var mantissa: u64 = (u & 0x007FFFFF) | 0x00800000;\n var product: u64 = mantissa * hi + (mantissa * lo >> 32);\n var r: i64 = product << 2;\n var q: i32 = ((product >> 62) + (r >>> 63));\n rempio2f_y = copysign(coeff, x) * r;\n return q;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction rempio2f(x: f32, u: u32, sign: i32): i32 { // see: jdh8/metallic/blob/master/src/math/float/rem_pio2f.c\n const pi2hi = reinterpret(0x3FF921FB50000000); // 1.57079631090164184570\n const pi2lo = reinterpret(0x3E5110B4611A6263); // 1.58932547735281966916e-8\n const _2_pi = reinterpret(0x3FE45F306DC9C883); // 0.63661977236758134308\n\n if (u < 0x4DC90FDB) { /* π * 0x1p28 */\n let q = nearest(x * _2_pi);\n rempio2f_y = x - q * pi2hi - q * pi2lo;\n return q;\n }\n\n var q = pio2_large_quot(x, u);\n return select(-q, q, sign);\n}\n\n/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */\n// @ts-ignore: decorator\n@inline\nfunction sin_kernf(x: f64): f32 { // see: musl/tree/src/math/__sindf.c\n const S1 = reinterpret(0xBFC5555554CBAC77); // -0x15555554cbac77.0p-55\n const S2 = reinterpret(0x3F811110896EFBB2); // 0x111110896efbb2.0p-59\n const S3 = reinterpret(0xBF2A00F9E2CAE774); // -0x1a00f9e2cae774.0p-65\n const S4 = reinterpret(0x3EC6CD878C3B46A7); // 0x16cd878c3b46a7.0p-71\n\n var z = x * x;\n var w = z * z;\n var r = S3 + z * S4;\n var s = z * x;\n return ((x + s * (S1 + z * S2)) + s * w * r);\n}\n\n/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */\n// @ts-ignore: decorator\n@inline\nfunction cos_kernf(x: f64): f32 { // see: musl/tree/src/math/__cosdf.c\n const C0 = reinterpret(0xBFDFFFFFFD0C5E81); // -0x1ffffffd0c5e81.0p-54\n const C1 = reinterpret(0x3FA55553E1053A42); // 0x155553e1053a42.0p-57\n const C2 = reinterpret(0xBF56C087E80F1E27); // -0x16c087e80f1e27.0p-62\n const C3 = reinterpret(0x3EF99342E0EE5069); // 0x199342e0ee5069.0p-68\n\n var z = x * x;\n var w = z * z;\n var r = C2 + z * C3;\n return (((1 + z * C0) + w * C1) + (w * z) * r);\n}\n\n/* |tan(x)/x - t(x)| < 2**-25.5 (~[-2e-08, 2e-08]). */\n// @ts-ignore: decorator\n@inline\nfunction tan_kernf(x: f64, odd: i32): f32 { // see: musl/tree/src/math/__tandf.c\n\n const T0 = reinterpret(0x3FD5554D3418C99F); /* 0x15554d3418c99f.0p-54 */\n const T1 = reinterpret(0x3FC112FD38999F72); /* 0x1112fd38999f72.0p-55 */\n const T2 = reinterpret(0x3FAB54C91D865AFE); /* 0x1b54c91d865afe.0p-57 */\n const T3 = reinterpret(0x3F991DF3908C33CE); /* 0x191df3908c33ce.0p-58 */\n const T4 = reinterpret(0x3F685DADFCECF44E); /* 0x185dadfcecf44e.0p-61 */\n const T5 = reinterpret(0x3F8362B9BF971BCD); /* 0x1362b9bf971bcd.0p-59 */\n\n var z = x * x;\n var r = T4 + z * T5;\n var t = T2 + z * T3;\n var w = z * z;\n var s = z * x;\n var u = T0 + z * T1;\n\n r = (x + s * u) + (s * w) * (t + w * r);\n return (odd ? -1 / r : r);\n}\n\nexport namespace NativeMathf {\n\n // @ts-ignore: decorator\n @lazy\n export const E = NativeMath.E;\n\n // @ts-ignore: decorator\n @lazy\n export const LN2 = NativeMath.LN2;\n\n // @ts-ignore: decorator\n @lazy\n export const LN10 = NativeMath.LN10;\n\n // @ts-ignore: decorator\n @lazy\n export const LOG2E = NativeMath.LOG2E;\n\n // @ts-ignore: decorator\n @lazy\n export const LOG10E = NativeMath.LOG10E;\n\n // @ts-ignore: decorator\n @lazy\n export const PI = NativeMath.PI;\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT1_2 = NativeMath.SQRT1_2;\n\n // @ts-ignore: decorator\n @lazy\n export const SQRT2 = NativeMath.SQRT2;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_sin: f32 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_cos: f32 = 0;\n\n // @ts-ignore: decorator\n @inline\n export function abs(x: f32): f32 {\n return builtin_abs(x);\n }\n\n export function acos(x: f32): f32 { // see: musl/src/math/acosf.c and SUN COPYRIGHT NOTICE above\n const\n pio2_hi = reinterpret(0x3FC90FDA), // 1.5707962513e+00f\n pio2_lo = reinterpret(0x33A22168), // 7.5497894159e-08f\n Ox1p_120f = reinterpret(0x03800000);\n var hx = reinterpret(x);\n var ix = hx & 0x7FFFFFFF;\n if (ix >= 0x3F800000) {\n if (ix == 0x3F800000) {\n if (hx >> 31) return 2 * pio2_hi + Ox1p_120f;\n return 0;\n }\n return 0 / (x - x);\n }\n if (ix < 0x3F000000) {\n if (ix <= 0x32800000) return pio2_hi + Ox1p_120f;\n return pio2_hi - (x - (pio2_lo - x * Rf(x * x)));\n }\n var z: f32, w: f32, s: f32;\n if (hx >> 31) {\n // z = (1 + x) * 0.5;\n z = 0.5 + x * 0.5;\n s = builtin_sqrt(z);\n w = Rf(z) * s - pio2_lo;\n return 2 * (pio2_hi - (s + w));\n }\n // z = (1 - x) * 0.5;\n z = 0.5 - x * 0.5;\n s = builtin_sqrt(z);\n hx = reinterpret(s);\n var df = reinterpret(hx & 0xFFFFF000);\n var c = (z - df * df) / (s + df);\n w = Rf(z) * s + c;\n return 2 * (df + w);\n }\n\n export function acosh(x: f32): f32 { // see: musl/src/math/acoshf.c\n const s = reinterpret(0x3F317218); // 0.693147180559945309417232121458176568f\n var u = reinterpret(x);\n var a = u & 0x7FFFFFFF;\n if (a < 0x3F800000 + (1 << 23)) {\n let xm1 = x - 1;\n return log1p(xm1 + builtin_sqrt(xm1 * (xm1 + 2)));\n }\n if (a < 0x3F800000 + (12 << 23)) return log(2 * x - 1 / (x + builtin_sqrt(x * x - 1)));\n return log(x) + s;\n }\n\n export function asin(x: f32): f32 { // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above\n const\n pio2 = reinterpret(0x3FC90FDB), // 1.570796326794896558e+00f\n Ox1p_120f = reinterpret(0x03800000);\n var sx = x;\n var hx = reinterpret(x) & 0x7FFFFFFF;\n if (hx >= 0x3F800000) {\n if (hx == 0x3F800000) return x * pio2 + Ox1p_120f;\n return 0 / (x - x);\n }\n if (hx < 0x3F000000) {\n if (hx < 0x39800000 && hx >= 0x00800000) return x;\n return x + x * Rf(x * x);\n }\n // var z: f32 = (1 - builtin_abs(x)) * 0.5;\n var z: f32 = 0.5 - builtin_abs(x) * 0.5;\n var s = builtin_sqrt(z); // sic\n x = (pio2 - 2 * (s + s * Rf(z)));\n return builtin_copysign(x, sx);\n }\n\n export function asinh(x: f32): f32 { // see: musl/src/math/asinhf.c\n const c = reinterpret(0x3F317218); // 0.693147180559945309417232121458176568f\n var u = reinterpret(x) & 0x7FFFFFFF;\n var y = reinterpret(u);\n if (u >= 0x3F800000 + (12 << 23)) y = log(y) + c;\n else if (u >= 0x3F800000 + (1 << 23)) y = log(2 * y + 1 / (builtin_sqrt(y * y + 1) + y));\n else if (u >= 0x3F800000 - (12 << 23)) y = log1p(y + y * y / (builtin_sqrt(y * y + 1) + 1));\n return builtin_copysign(y, x);\n }\n\n export function atan(x: f32): f32 { // see: musl/src/math/atanf.c and SUN COPYRIGHT NOTICE above\n const\n atanhi0 = reinterpret(0x3EED6338), // 4.6364760399e-01f\n atanhi1 = reinterpret(0x3F490FDA), // 7.8539812565e-01f\n atanhi2 = reinterpret(0x3F7B985E), // 9.8279368877e-01f\n atanhi3 = reinterpret(0x3FC90FDA), // 1.5707962513e+00f\n atanlo0 = reinterpret(0x31AC3769), // 5.0121582440e-09f\n atanlo1 = reinterpret(0x33222168), // 3.7748947079e-08f\n atanlo2 = reinterpret(0x33140FB4), // 3.4473217170e-08f\n atanlo3 = reinterpret(0x33A22168), // 7.5497894159e-08f\n aT0 = reinterpret(0x3EAAAAA9), // 3.3333328366e-01f\n aT1 = reinterpret(0xBE4CCA98), // -1.9999158382e-01f\n aT2 = reinterpret(0x3E11F50D), // 1.4253635705e-01f\n aT3 = reinterpret(0xBDDA1247), // -1.0648017377e-01f\n aT4 = reinterpret(0x3D7CAC25), // 6.1687607318e-02f\n Ox1p_120f = reinterpret(0x03800000);\n var ix = reinterpret(x);\n var sx = x;\n ix &= 0x7FFFFFFF;\n var z: f32;\n if (ix >= 0x4C800000) {\n if (isNaN(x)) return x;\n z = atanhi3 + Ox1p_120f;\n return builtin_copysign(z, sx);\n }\n var id: i32;\n if (ix < 0x3EE00000) {\n if (ix < 0x39800000) return x;\n id = -1;\n } else {\n x = builtin_abs(x);\n if (ix < 0x3F980000) {\n if (ix < 0x3F300000) {\n id = 0;\n x = (2.0 * x - 1.0) / (2.0 + x);\n } else {\n id = 1;\n x = (x - 1.0) / (x + 1.0);\n }\n } else {\n if (ix < 0x401C0000) {\n id = 2;\n x = (x - 1.5) / (1.0 + 1.5 * x);\n } else {\n id = 3;\n x = -1.0 / x;\n }\n }\n }\n z = x * x;\n var w = z * z;\n var s1 = z * (aT0 + w * (aT2 + w * aT4));\n var s2 = w * (aT1 + w * aT3);\n var s3 = x * (s1 + s2);\n if (id < 0) return x - s3;\n switch (id) {\n case 0: { z = atanhi0 - ((s3 - atanlo0) - x); break; }\n case 1: { z = atanhi1 - ((s3 - atanlo1) - x); break; }\n case 2: { z = atanhi2 - ((s3 - atanlo2) - x); break; }\n case 3: { z = atanhi3 - ((s3 - atanlo3) - x); break; }\n default: unreachable();\n }\n return builtin_copysign(z, sx);\n }\n\n export function atanh(x: f32): f32 { // see: musl/src/math/atanhf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n var y = reinterpret(u);\n if (u < 0x3F800000 - (1 << 23)) {\n if (u >= 0x3F800000 - (32 << 23)) y = 0.5 * log1p(2 * y * (1.0 + y / (1 - y)));\n } else y = 0.5 * log1p(2 * (y / (1 - y)));\n return builtin_copysign(y, x);\n }\n\n export function atan2(y: f32, x: f32): f32 { // see: musl/src/math/atan2f.c and SUN COPYRIGHT NOTICE above\n const\n pi = reinterpret(0x40490FDB), // 3.1415927410e+00f\n pi_lo = reinterpret(0xB3BBBD2E); // -8.7422776573e-08f\n if (isNaN(x) || isNaN(y)) return x + y;\n var ix = reinterpret(x);\n var iy = reinterpret(y);\n if (ix == 0x3F800000) return atan(y);\n var m = (((iy >> 31) & 1) | ((ix >> 30) & 2));\n ix &= 0x7FFFFFFF;\n iy &= 0x7FFFFFFF;\n if (iy == 0) {\n switch (m) {\n case 0:\n case 1: return y;\n case 2: return pi;\n case 3: return -pi;\n }\n }\n if (ix == 0) return m & 1 ? -pi / 2 : pi / 2;\n if (ix == 0x7F800000) {\n if (iy == 0x7F800000) {\n switch (m) {\n case 0: return pi / 4;\n case 1: return -pi / 4;\n case 2: return 3 * pi / 4;\n case 3: return -3 * pi / 4;\n }\n } else {\n switch (m) {\n case 0: return 0;\n case 1: return -0;\n case 2: return pi;\n case 3: return -pi;\n }\n }\n }\n if (ix + (26 << 23) < iy || iy == 0x7F800000) return m & 1 ? -pi / 2 : pi / 2;\n var z: f32;\n if ((m & 2) && iy + (26 << 23) < ix) z = 0.0;\n else z = atan(builtin_abs(y / x));\n switch (m) {\n case 0: return z;\n case 1: return -z;\n case 2: return pi - (z - pi_lo);\n case 3: return (z - pi_lo) - pi;\n }\n unreachable();\n return 0;\n }\n\n export function cbrt(x: f32): f32 { // see: musl/src/math/cbrtf.c and SUN COPYRIGHT NOTICE above\n const\n B1 = 709958130,\n B2 = 642849266,\n Ox1p24f = reinterpret(0x4B800000);\n var u = reinterpret(x);\n var hx = u & 0x7FFFFFFF;\n if (hx >= 0x7F800000) return x + x;\n if (hx < 0x00800000) {\n if (hx == 0) return x;\n u = reinterpret(x * Ox1p24f);\n hx = u & 0x7FFFFFFF;\n hx = hx / 3 + B2;\n } else {\n hx = hx / 3 + B1;\n }\n u &= 0x80000000;\n u |= hx;\n var t = reinterpret(u);\n var r = t * t * t;\n t = t * (x + x + r) / (x + r + r);\n r = t * t * t;\n t = t * (x + x + r) / (x + r + r);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function ceil(x: f32): f32 {\n return builtin_ceil(x);\n }\n\n export function clz32(x: f32): f32 {\n if (!isFinite(x)) return 32;\n return builtin_clz(\n (x - 4294967296 * builtin_floor(x * (1.0 / 4294967296)))\n );\n }\n\n export function cos(x: f32): f32 { // see: musl/src/math/cosf.c\n const c1pio2 = reinterpret(0x3FF921FB54442D18); // M_PI_2 * 1\n const c2pio2 = reinterpret(0x400921FB54442D18); // M_PI_2 * 2\n const c3pio2 = reinterpret(0x4012D97C7F3321D2); // M_PI_2 * 3\n const c4pio2 = reinterpret(0x401921FB54442D18); // M_PI_2 * 4\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n /* raise inexact if x != 0 */\n return 1;\n }\n return cos_kernf(x);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix > 0x4016cbe3) { /* |x| ~> 3π/4 */\n return -cos_kernf(sign ? x + c2pio2 : x - c2pio2);\n } else {\n return sign ? sin_kernf(x + c1pio2) : sin_kernf(c1pio2 - x);\n }\n }\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix > 0x40afeddf) { /* |x| ~> 7π/4 */\n return cos_kernf(sign ? x + c4pio2 : x - c4pio2);\n } else {\n return sign ? sin_kernf(-x - c3pio2) : sin_kernf(x - c3pio2);\n }\n }\n }\n\n /* cos(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n /* general argument reduction needed */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n\n var t = n & 1 ? sin_kernf(y) : cos_kernf(y);\n return (n + 1) & 2 ? -t : t;\n }\n\n export function cosh(x: f32): f32 { // see: musl/src/math/coshf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n x = reinterpret(u);\n if (u < 0x3F317217) {\n if (u < 0x3F800000 - (12 << 23)) return 1;\n let t = expm1(x);\n // return 1 + t * t / (2 * (1 + t));\n return 1 + t * t / (2 + 2 * t);\n }\n if (u < 0x42B17217) {\n let t = exp(x);\n // return 0.5 * (t + 1 / t);\n return 0.5 * t + 0.5 / t;\n }\n return expo2f(x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function floor(x: f32): f32 {\n return builtin_floor(x);\n }\n\n export function exp(x: f32): f32 { // see: musl/src/math/expf.c and SUN COPYRIGHT NOTICE above\n const\n ln2hi = reinterpret(0x3F317200), // 6.9314575195e-1f\n ln2lo = reinterpret(0x35BFBE8E), // 1.4286067653e-6f\n invln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+0f\n P1 = reinterpret(0x3E2AAA8F), // 1.6666625440e-1f\n P2 = reinterpret(0xBB355215), // -2.7667332906e-3f\n Ox1p127f = reinterpret(0x7F000000);\n var hx = reinterpret(x);\n var sign_ = (hx >> 31);\n hx &= 0x7FFFFFFF;\n if (hx >= 0x42AEAC50) {\n if (hx >= 0x42B17218) {\n if (!sign_) return x * Ox1p127f;\n else if (hx >= 0x42CFF1B5) return 0;\n }\n }\n var hi: f32, lo: f32;\n var k: i32;\n if (hx > 0x3EB17218) {\n if (hx > 0x3F851592) {\n k = (invln2 * x + builtin_copysign(0.5, x));\n } else {\n k = 1 - (sign_ << 1);\n }\n hi = x - k * ln2hi;\n lo = k * ln2lo;\n x = hi - lo;\n } else if (hx > 0x39000000) {\n k = 0;\n hi = x;\n lo = 0;\n } else {\n return 1 + x;\n }\n var xx = x * x;\n var c = x - xx * (P1 + xx * P2);\n var y: f32 = 1 + (x * c / (2 - c) - lo + hi);\n if (k == 0) return y;\n return scalbn(y, k);\n }\n\n export function expm1(x: f32): f32 { // see: musl/src/math/expm1f.c and SUN COPYRIGHT NOTICE above\n const\n o_threshold = reinterpret(0x42B17180), // 8.8721679688e+01f\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01f\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06f\n invln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+00f\n Q1 = reinterpret(0xBD088868), // -3.3333212137e-02f\n Q2 = reinterpret(0x3ACF3010), // 1.5807170421e-03f\n Ox1p127f = reinterpret(0x7F000000);\n var u = reinterpret(x);\n var hx = u & 0x7FFFFFFF;\n var sign_ = (u >> 31);\n if (hx >= 0x4195B844) {\n if (hx > 0x7F800000) return x;\n if (sign_) return -1;\n if (x > o_threshold) {\n x *= Ox1p127f;\n return x;\n }\n }\n var c: f32 = 0.0, t: f32, k: i32;\n if (hx > 0x3EB17218) {\n k = select(\n 1 - (sign_ << 1),\n (invln2 * x + builtin_copysign(0.5, x)),\n hx < 0x3F851592\n );\n t = k;\n let hi = x - t * ln2_hi;\n let lo = t * ln2_lo;\n x = hi - lo;\n c = (hi - x) - lo;\n } else if (hx < 0x33000000) {\n return x;\n } else k = 0;\n var hfx: f32 = 0.5 * x;\n var hxs: f32 = x * hfx;\n var r1: f32 = 1.0 + hxs * (Q1 + hxs * Q2);\n t = 3.0 - r1 * hfx;\n var e = hxs * ((r1 - t) / (6.0 - x * t));\n if (k == 0) return x - (x * e - hxs);\n e = x * (e - c) - c;\n e -= hxs;\n if (k == -1) return 0.5 * (x - e) - 0.5;\n if (k == 1) {\n if (x < -0.25) return -2.0 * (e - (x + 0.5));\n return 1.0 + 2.0 * (x - e);\n }\n u = (0x7F + k) << 23;\n var twopk = reinterpret(u);\n var y: f32;\n if (k < 0 || k > 56) {\n y = x - e + 1.0;\n if (k == 128) y = y * 2.0 * Ox1p127f;\n else y = y * twopk;\n return y - 1.0;\n }\n u = (0x7F - k) << 23;\n y = reinterpret(u);\n if (k < 20) y = (1 - y) - e;\n else y = 1 - (e + y);\n return (x + y) * twopk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function fround(x: f32): f32 {\n return x;\n }\n\n export function hypot(x: f32, y: f32): f32 { // see: musl/src/math/hypotf.c\n const\n Ox1p90f = reinterpret(0x6C800000),\n Ox1p_90f = reinterpret(0x12800000);\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n ux &= 0x7FFFFFFF;\n uy &= 0x7FFFFFFF;\n if (ux < uy) {\n let ut = ux;\n ux = uy;\n uy = ut;\n }\n x = reinterpret(ux);\n y = reinterpret(uy);\n if (uy == 0xFF << 23) return y;\n if (ux >= 0xFF << 23 || uy == 0 || ux - uy >= 25 << 23) return x + y;\n var z: f32 = 1;\n if (ux >= (0x7F + 60) << 23) {\n z = Ox1p90f;\n x *= Ox1p_90f;\n y *= Ox1p_90f;\n } else if (uy < (0x7F - 60) << 23) {\n z = Ox1p_90f;\n x *= Ox1p90f;\n y *= Ox1p90f;\n }\n return z * builtin_sqrt((x * x + y * y));\n }\n\n // @ts-ignore: decorator\n @inline\n export function imul(x: f32, y: f32): f32 {\n /*\n * Wasm (MVP) and JS have different approaches for double->int conversions.\n *\n * For emulate JS conversion behavior and avoid trapping from wasm we should modulate by MAX_INT\n * our float-point arguments before actual convertion to integers.\n */\n if (!isFinite(x + y)) return 0;\n const inv32 = 1.0 / 4294967296;\n return (\n (x - 4294967296 * builtin_floor(x * inv32)) *\n (y - 4294967296 * builtin_floor(y * inv32))\n );\n }\n\n export function log(x: f32): f32 { // see: musl/src/math/logf.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01f\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06f\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f\n Ox1p25f = reinterpret(0x4C000000);\n var u = reinterpret(x);\n var k = 0;\n if (u < 0x00800000 || (u >> 31)) {\n if (u << 1 == 0) return -1 / (x * x);\n if (u >> 31) return (x - x) / 0;\n k -= 25;\n x *= Ox1p25f;\n u = reinterpret(x);\n } else if (u >= 0x7F800000) return x;\n else if (u == 0x3F800000) return 0;\n u += 0x3F800000 - 0x3F3504F3;\n k += (u >> 23) - 0x7F;\n u = (u & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(u);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq = 0.5 * f * f;\n var dk = k;\n return s * (hfsq + r) + dk * ln2_lo - hfsq + f + dk * ln2_hi;\n }\n\n export function log10(x: f32): f32 { // see: musl/src/math/log10f.c and SUN COPYRIGHT NOTICE above\n const\n ivln10hi = reinterpret(0x3EDE6000), // 4.3432617188e-01f\n ivln10lo = reinterpret(0xB804EAD9), // -3.1689971365e-05f\n log10_2hi = reinterpret(0x3E9A2080), // 3.0102920532e-01f\n log10_2lo = reinterpret(0x355427DB), // 7.9034151668e-07f\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f, 0.24279078841f\n Ox1p25f = reinterpret(0x4C000000);\n var ix = reinterpret(x);\n var k = 0;\n if (ix < 0x00800000 || (ix >> 31)) {\n if (ix << 1 == 0) return -1 / (x * x);\n if (ix >> 31) return (x - x) / 0.0;\n k -= 25;\n x *= Ox1p25f;\n ix = reinterpret(x);\n } else if (ix >= 0x7F800000) return x;\n else if (ix == 0x3F800000) return 0;\n ix += 0x3F800000 - 0x3F3504F3;\n k += (ix >> 23) - 0x7F;\n ix = (ix & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(ix);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var hi = f - hfsq;\n ix = reinterpret(hi);\n ix &= 0xFFFFF000;\n hi = reinterpret(ix);\n var lo = f - hi - hfsq + s * (hfsq + r);\n var dk = k;\n return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi;\n }\n\n export function log1p(x: f32): f32 { // see: musl/src/math/log1pf.c and SUN COPYRIGHT NOTICE above\n const\n ln2_hi = reinterpret(0x3F317180), // 6.9313812256e-01\n ln2_lo = reinterpret(0x3717F7D1), // 9.0580006145e-06\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26); // 0xf89e26.0p-26f, 0.24279078841f\n var ix = reinterpret(x);\n var c: f32 = 0, f: f32 = 0;\n var k: i32 = 1;\n if (ix < 0x3ED413D0 || (ix >> 31)) {\n if (ix >= 0xBF800000) {\n if (x == -1) return x / 0.0;\n return (x - x) / 0.0;\n }\n if (ix << 1 < 0x33800000 << 1) return x;\n if (ix <= 0xBE95F619) {\n k = 0;\n c = 0;\n f = x;\n }\n } else if (ix >= 0x7F800000) return x;\n if (k) {\n let uf: f32 = 1 + x;\n let iu = reinterpret(uf);\n iu += 0x3F800000 - 0x3F3504F3;\n k = (iu >> 23) - 0x7F;\n if (k < 25) {\n c = k >= 2 ? 1 - (uf - x) : x - (uf - 1);\n c /= uf;\n } else c = 0;\n iu = (iu & 0x007FFFFF) + 0x3F3504F3;\n f = reinterpret(iu) - 1;\n }\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var dk = k;\n return s * (hfsq + r) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi;\n }\n\n export function log2(x: f32): f32 { // see: musl/src/math/log2f.c and SUN COPYRIGHT NOTICE above\n const\n ivln2hi = reinterpret(0x3FB8B000), // 1.4428710938e+00f\n ivln2lo = reinterpret(0xB9389AD4), // -1.7605285393e-04\n Lg1 = reinterpret(0x3F2AAAAA), // 0xaaaaaa.0p-24f, 0.66666662693f\n Lg2 = reinterpret(0x3ECCCE13), // 0xccce13.0p-25f, 0.40000972152f\n Lg3 = reinterpret(0x3E91E9EE), // 0x91e9ee.0p-25f, 0.28498786688f\n Lg4 = reinterpret(0x3E789E26), // 0xf89e26.0p-26f, 0.24279078841f\n Ox1p25f = reinterpret(0x4C000000);\n var ix = reinterpret(x);\n var k: i32 = 0;\n if (ix < 0x00800000 || (ix >> 31)) {\n if (ix << 1 == 0) return -1 / (x * x);\n if (ix >> 31) return (x - x) / 0.0;\n k -= 25;\n x *= Ox1p25f;\n ix = reinterpret(x);\n } else if (ix >= 0x7F800000) return x;\n else if (ix == 0x3F800000) return 0;\n ix += 0x3F800000 - 0x3F3504F3;\n k += (ix >> 23) - 0x7F;\n ix = (ix & 0x007FFFFF) + 0x3F3504F3;\n x = reinterpret(ix);\n var f = x - 1.0;\n var s = f / (2.0 + f);\n var z = s * s;\n var w = z * z;\n var t1 = w * (Lg2 + w * Lg4);\n var t2 = z * (Lg1 + w * Lg3);\n var r = t2 + t1;\n var hfsq: f32 = 0.5 * f * f;\n var hi = f - hfsq;\n var u = reinterpret(hi);\n u &= 0xFFFFF000;\n hi = reinterpret(u);\n var lo: f32 = f - hi - hfsq + s * (hfsq + r);\n var dk = k;\n return (lo + hi) * ivln2lo + lo * ivln2hi + hi * ivln2hi + dk;\n }\n\n // @ts-ignore: decorator\n @inline\n export function max(value1: f32, value2: f32): f32 {\n return builtin_max(value1, value2);\n }\n\n // @ts-ignore: decorator\n @inline\n export function min(value1: f32, value2: f32): f32 {\n return builtin_min(value1, value2);\n }\n\n export function pow(x: f32, y: f32): f32 { // see: musl/src/math/powf.c and SUN COPYRIGHT NOTICE above\n const\n dp_h1 = reinterpret(0x3F15C000), // 5.84960938e-01f\n dp_l1 = reinterpret(0x35D1CFDC), // 1.56322085e-06f\n two24 = reinterpret(0x4B800000), // 16777216f\n huge = reinterpret(0x7149F2CA), // 1.0e+30f\n tiny = reinterpret(0x0DA24260), // 1.0e-30f\n L1 = reinterpret(0x3F19999A), // 6.0000002384e-01f\n L2 = reinterpret(0x3EDB6DB7), // 4.2857143283e-01f\n L3 = reinterpret(0x3EAAAAAB), // 3.3333334327e-01f\n L4 = reinterpret(0x3E8BA305), // 2.7272811532e-01f\n L5 = reinterpret(0x3E6C3255), // 2.3066075146e-01f\n L6 = reinterpret(0x3E53F142), // 2.0697501302e-01f\n P1 = reinterpret(0x3E2AAAAB), // 1.6666667163e-01f\n P2 = reinterpret(0xBB360B61), // -2.7777778450e-03f\n P3 = reinterpret(0x388AB355), // 6.6137559770e-05f\n P4 = reinterpret(0xB5DDEA0E), // -1.6533901999e-06f\n P5 = reinterpret(0x3331BB4C), // 4.1381369442e-08f\n lg2 = reinterpret(0x3F317218), // 6.9314718246e-01f\n lg2_h = reinterpret(0x3F317200), // 6.93145752e-01f\n lg2_l = reinterpret(0x35BFBE8C), // 1.42860654e-06f\n ovt = reinterpret(0x3338AA3C), // 4.2995665694e-08f\n cp = reinterpret(0x3F76384F), // 9.6179670095e-01\n cp_h = reinterpret(0x3F764000), // 9.6191406250e-01\n cp_l = reinterpret(0xB8F623C6), // -1.1736857402e-04\n ivln2 = reinterpret(0x3FB8AA3B), // 1.4426950216e+00\n ivln2_h = reinterpret(0x3FB8AA00), // 1.4426879883e+00\n ivln2_l = reinterpret(0x36ECA570), // 7.0526075433e-06\n inv3 = reinterpret(0x3EAAAAAB); // 0.333333333333\n var hx = reinterpret(x);\n var hy = reinterpret(y);\n var ix = hx & 0x7FFFFFFF;\n var iy = hy & 0x7FFFFFFF;\n if (iy == 0) return 1.0; // x**0 = 1, even if x is NaN\n // if (hx == 0x3F800000) return 1.0; // C: 1**y = 1, even if y is NaN, JS: NaN\n if (ix > 0x7F800000 || iy > 0x7F800000) return x + y; // NaN if either arg is NaN\n var yisint = 0, j: i32, k: i32;\n if (hx < 0) {\n if (iy >= 0x4B800000) yisint = 2;\n else if (iy >= 0x3F800000) {\n k = (iy >> 23) - 0x7F;\n let ki = 23 - k;\n j = iy >> ki;\n if ((j << ki) == iy) yisint = 2 - (j & 1);\n }\n }\n if (iy == 0x7F800000) { // y is +-inf\n if (ix == 0x3F800000) return NaN; // C: (-1)**+-inf is 1, JS: NaN\n else if (ix > 0x3F800000) return hy >= 0 ? y : 0.0; // (|x|>1)**+-inf = inf,0\n else return hy >= 0 ? 0.0 : -y; // (|x|<1)**+-inf = 0,inf\n }\n if (iy == 0x3F800000) return hy >= 0 ? x : 1.0 / x;\n if (hy == 0x40000000) return x * x;\n if (hy == 0x3F000000) {\n if (hx >= 0) return builtin_sqrt(x);\n }\n var ax = builtin_abs(x);\n var z: f32;\n if (ix == 0x7F800000 || ix == 0 || ix == 0x3F800000) {\n z = ax;\n if (hy < 0) z = 1.0 / z;\n if (hx < 0) {\n if (((ix - 0x3F800000) | yisint) == 0) {\n let d = z - z;\n z = d / d;\n }\n else if (yisint == 1) z = -z;\n }\n return z;\n }\n var sn = 1.0;\n if (hx < 0) {\n if (yisint == 0) {\n let d = x - x;\n return d / d;\n }\n if (yisint == 1) sn = -1.0;\n }\n var t1: f32, t2: f32, r: f32, s: f32, t: f32, u: f32, v: f32, w: f32, p_h: f32, p_l: f32;\n var n: i32, is: i32;\n if (iy > 0x4D000000) {\n if (ix < 0x3F7FFFF8) return hy < 0 ? sn * huge * huge : sn * tiny * tiny;\n if (ix > 0x3F800007) return hy > 0 ? sn * huge * huge : sn * tiny * tiny;\n t = ax - 1;\n w = (t * t) * (0.5 - t * (inv3 - t * 0.25));\n u = ivln2_h * t;\n v = t * ivln2_l - w * ivln2;\n t1 = u + v;\n is = reinterpret(t1);\n t1 = reinterpret(is & 0xFFFFF000);\n t2 = v - (t1 - u);\n } else {\n let s2: f32, s_h: f32, s_l: f32, t_h: f32, t_l: f32;\n n = 0;\n if (ix < 0x00800000) {\n ax *= two24;\n n -= 24;\n ix = reinterpret(ax);\n }\n n += (ix >> 23) - 0x7F;\n j = ix & 0x007FFFFF;\n ix = j | 0x3F800000;\n if (j <= 0x1CC471) k = 0;\n else if (j < 0x5DB3D7) k = 1;\n else {\n k = 0;\n n += 1;\n ix -= 0x00800000;\n }\n ax = reinterpret(ix);\n let bp = select(1.5, 1.0, k); // k ? 1.5 : 1.0\n u = ax - bp;\n v = 1.0 / (ax + bp);\n s = u * v;\n s_h = s;\n is = reinterpret(s_h);\n s_h = reinterpret(is & 0xFFFFF000);\n is = ((ix >> 1) & 0xFFFFF000) | 0x20000000;\n t_h = reinterpret(is + 0x00400000 + (k << 21));\n t_l = ax - (t_h - bp);\n s_l = v * ((u - s_h * t_h) - s_h * t_l);\n s2 = s * s;\n r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));\n r += s_l * (s_h + s);\n s2 = s_h * s_h;\n t_h = 3.0 + s2 + r;\n is = reinterpret(t_h);\n t_h = reinterpret(is & 0xFFFFF000);\n t_l = r - ((t_h - 3.0) - s2);\n u = s_h * t_h;\n v = s_l * t_h + t_l * s;\n p_h = u + v;\n is = reinterpret(p_h);\n p_h = reinterpret(is & 0xFFFFF000);\n p_l = v - (p_h - u);\n let z_h = cp_h * p_h;\n let dp_l = select(dp_l1, 0.0, k);\n let z_l = cp_l * p_h + p_l * cp + dp_l;\n t = n;\n let dp_h = select(dp_h1, 0.0, k);\n t1 = (((z_h + z_l) + dp_h) + t);\n is = reinterpret(t1);\n t1 = reinterpret(is & 0xFFFFF000);\n t2 = z_l - (((t1 - t) - dp_h) - z_h);\n }\n is = reinterpret(y);\n var y1 = reinterpret(is & 0xFFFFF000);\n p_l = (y - y1) * t1 + y * t2;\n p_h = y1 * t1;\n z = p_l + p_h;\n j = reinterpret(z);\n if (j > 0x43000000) {\n return sn * huge * huge;\n } else if (j == 0x43000000) {\n if (p_l + ovt > z - p_h) return sn * huge * huge;\n } else if ((j & 0x7FFFFFFF) > 0x43160000) {\n return sn * tiny * tiny;\n } else if (j == 0xC3160000) {\n if (p_l <= z - p_h) return sn * tiny * tiny;\n }\n var i = j & 0x7FFFFFFF;\n k = (i >> 23) - 0x7F;\n n = 0;\n if (i > 0x3F000000) {\n n = j + (0x00800000 >> (k + 1));\n k = ((n & 0x7FFFFFFF) >> 23) - 0x7F;\n t = reinterpret(n & ~(0x007FFFFF >> k));\n n = ((n & 0x007FFFFF) | 0x00800000) >> (23 - k);\n if (j < 0) n = -n;\n p_h -= t;\n }\n t = p_l + p_h;\n is = reinterpret(t);\n t = reinterpret(is & 0xFFFF8000);\n u = t * lg2_h;\n v = (p_l - (t - p_h)) * lg2 + t * lg2_l;\n z = u + v;\n w = v - (z - u);\n t = z * z;\n t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));\n r = (z * t1) / (t1 - 2.0) - (w + z * w);\n z = 1.0 - (r - z);\n j = reinterpret(z);\n j += n << 23;\n if ((j >> 23) <= 0) z = scalbn(z, n);\n else z = reinterpret(j);\n return sn * z;\n }\n\n // @ts-ignore: decorator\n @inline\n export function seedRandom(value: i64): void {\n NativeMath.seedRandom(value);\n }\n\n // Using xoroshiro64starstar from http://xoshiro.di.unimi.it/xoroshiro64starstar.c\n export function random(): f32 {\n if (!random_seeded) throw new Error("PRNG must be seeded.");\n\n var s0 = random_state0_32;\n var s1 = random_state1_32;\n var r = rotl(s0 * 0x9E3779BB, 5) * 5;\n\n s1 ^= s0;\n random_state0_32 = rotl(s0, 26) ^ s1 ^ (s1 << 9);\n random_state1_32 = rotl(s1, 13);\n\n return reinterpret((r >> 9) | (127 << 23)) - 1.0;\n }\n\n // @ts-ignore: decorator\n @inline\n export function round(x: f32): f32 {\n return builtin_copysign(builtin_floor(x + 0.5), x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function sign(x: f32): f32 {\n if (ASC_SHRINK_LEVEL > 0) {\n return builtin_abs(x) > 0 ? builtin_copysign(1, x) : x;\n } else {\n return x > 0 ? 1 : x < 0 ? -1 : x;\n }\n }\n\n // @ts-ignore: decorator\n @inline\n export function signbit(x: f32): bool {\n // @ts-ignore: type\n return ((reinterpret(x) >>> 31) & (x == x));\n }\n\n export function sin(x: f32): f32 { // see: musl/src/math/sinf.c\n const s1pio2 = reinterpret(0x3FF921FB54442D18); // M_PI_2 * 1\n const s2pio2 = reinterpret(0x400921FB54442D18); // M_PI_2 * 2\n const s3pio2 = reinterpret(0x4012D97C7F3321D2); // M_PI_2 * 3\n const s4pio2 = reinterpret(0x401921FB54442D18); // M_PI_2 * 4\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n return x;\n }\n return sin_kernf(x);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n return sign ? -cos_kernf(x + s1pio2) : cos_kernf(x - s1pio2);\n }\n return sin_kernf(-(sign ? x + s2pio2 : x - s2pio2));\n }\n\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n return sign ? cos_kernf(x + s3pio2) : -cos_kernf(x - s3pio2);\n }\n return sin_kernf(sign ? x + s4pio2 : x - s4pio2);\n }\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n\n var t = n & 1 ? cos_kernf(y) : sin_kernf(y);\n return n & 2 ? -t : t;\n }\n\n export function sinh(x: f32): f32 { // see: musl/src/math/sinhf.c\n var u = reinterpret(x) & 0x7FFFFFFF;\n var absx = reinterpret(u);\n var t: f32;\n var h = builtin_copysign(0.5, x);\n if (u < 0x42B17217) {\n t = expm1(absx);\n if (u < 0x3F800000) {\n if (u < 0x3F800000 - (12 << 23)) return x;\n return h * (2 * t - t * t / (t + 1));\n }\n return h * (t + t / (t + 1));\n }\n t = 2 * h * expo2f(absx);\n return t;\n }\n\n // @ts-ignore: decorator\n @inline\n export function sqrt(x: f32): f32 {\n return builtin_sqrt(x);\n }\n\n export function tan(x: f32): f32 { // see: musl/src/math/tanf.c\n const t1pio2 = reinterpret(0x3FF921FB54442D18); // 1 * M_PI_2\n const t2pio2 = reinterpret(0x400921FB54442D18); // 2 * M_PI_2\n const t3pio2 = reinterpret(0x4012D97C7F3321D2); // 3 * M_PI_2\n const t4pio2 = reinterpret(0x401921FB54442D18); // 4 * M_PI_2\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n return x;\n }\n return tan_kernf(x, 0);\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n return tan_kernf((sign ? x + t1pio2 : x - t1pio2), 1);\n } else {\n return tan_kernf((sign ? x + t2pio2 : x - t2pio2), 0);\n }\n }\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n return tan_kernf((sign ? x + t3pio2 : x - t3pio2), 1);\n } else {\n return tan_kernf((sign ? x + t4pio2 : x - t4pio2), 0);\n }\n }\n }\n\n /* tan(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) return x - x;\n\n /* argument reduction */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n return tan_kernf(y, n & 1);\n }\n\n export function tanh(x: f32): f32 { // see: musl/src/math/tanhf.c\n var u = reinterpret(x);\n u &= 0x7FFFFFFF;\n var y = reinterpret(u);\n var t: f32;\n if (u > 0x3F0C9F54) {\n if (u > 0x41200000) t = 1 + 0 / y;\n else {\n t = expm1(2 * y);\n t = 1 - 2 / (t + 2);\n }\n } else if (u > 0x3E82C578) {\n t = expm1(2 * y);\n t = t / (t + 2);\n } else if (u >= 0x00800000) {\n t = expm1(-2 * y);\n t = -t / (t + 2);\n } else t = y;\n return builtin_copysign(t, x);\n }\n\n // @ts-ignore: decorator\n @inline\n export function trunc(x: f32): f32 {\n return builtin_trunc(x);\n }\n\n export function scalbn(x: f32, n: i32): f32 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbnf.c\n const\n Ox1p24f = reinterpret(0x4B800000),\n Ox1p127f = reinterpret(0x7F000000),\n Ox1p_126f = reinterpret(0x00800000);\n var y = x;\n if (n > 127) {\n y *= Ox1p127f;\n n -= 127;\n if (n > 127) {\n y *= Ox1p127f;\n n = builtin_min(n - 127, 127);\n }\n } else if (n < -126) {\n y *= Ox1p_126f * Ox1p24f;\n n += 126 - 24;\n if (n < -126) {\n y *= Ox1p_126f * Ox1p24f;\n n = builtin_max(n + 126 - 24, -126);\n }\n }\n return y * reinterpret((0x7F + n) << 23);\n }\n\n export function mod(x: f32, y: f32): f32 { // see: musl/src/math/fmodf.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 23 & 0xFF);\n var ey = (uy >> 23 & 0xFF);\n var sx = ux & 0x80000000;\n var uy1 = uy << 1;\n if (uy1 == 0 || ex == 0xFF || isNaN(y)) {\n let m = x * y;\n return m / m;\n }\n var ux1 = ux << 1;\n if (ux1 <= uy1) {\n if (ux1 == uy1) return 0 * x;\n return x;\n }\n if (!ex) {\n ex -= builtin_clz(ux << 9);\n ux <<= -ex + 1;\n } else {\n ux &= -1 >> 9;\n ux |= 1 << 23;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 9);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 9;\n uy |= 1 << 23;\n }\n while (ex > ey) {\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n ux <<= 1;\n --ex;\n }\n if (ux >= uy) {\n if (ux == uy) return 0 * x;\n ux -= uy;\n }\n // for (; !(ux >> 23); ux <<= 1) --ex;\n var shift = builtin_clz(ux << 8);\n ex -= shift;\n ux <<= shift;\n if (ex > 0) {\n ux -= 1 << 23;\n ux |= ex << 23;\n } else {\n ux >>= -ex + 1;\n }\n ux |= sx;\n return reinterpret(ux);\n }\n\n export function rem(x: f32, y: f32): f32 { // see: musl/src/math/remquof.c\n var ux = reinterpret(x);\n var uy = reinterpret(y);\n var ex = (ux >> 23 & 0xFF);\n var ey = (uy >> 23 & 0xFF);\n var sx = (ux >> 31);\n var uxi = ux;\n if (uy << 1 == 0 || ex == 0xFF || isNaN(y)) return (x * y) / (x * y);\n if (ux << 1 == 0) return x;\n if (!ex) {\n ex -= builtin_clz(uxi << 9);\n uxi <<= -ex + 1;\n } else {\n uxi &= -1 >> 9;\n uxi |= 1 << 23;\n }\n if (!ey) {\n ey -= builtin_clz(uy << 9);\n uy <<= -ey + 1;\n } else {\n uy &= -1 >> 9;\n uy |= 1 << 23;\n }\n var q = 0;\n do {\n if (ex < ey) {\n if (ex + 1 == ey) break; // goto end\n return x;\n }\n while (ex > ey) {\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n uxi <<= 1;\n q <<= 1;\n --ex;\n }\n if (uxi >= uy) {\n uxi -= uy;\n ++q;\n }\n if (uxi == 0) ex = -30;\n else {\n let shift = builtin_clz(uxi << 8);\n ex -= shift;\n uxi <<= shift;\n }\n break;\n } while (false);\n // end\n if (ex > 0) {\n uxi -= 1 << 23;\n uxi |= ex << 23;\n } else {\n uxi >>= -ex + 1;\n }\n x = reinterpret(uxi);\n y = builtin_abs(y);\n var x2 = x + x;\n if (ex == ey || (ex + 1 == ey && (x2 > y || (x2 == y && (q & 1))))) {\n x -= y;\n // q++;\n }\n return sx ? -x : x;\n }\n\n export function sincos(x: f32): void { // see: musl/tree/src/math/sincosf.c\n const s1pio2 = reinterpret(0x3FF921FB54442D18); // 1 * M_PI_2\n const s2pio2 = reinterpret(0x400921FB54442D18); // 2 * M_PI_2\n const s3pio2 = reinterpret(0x4012D97C7F3321D2); // 3 * M_PI_2\n const s4pio2 = reinterpret(0x401921FB54442D18); // 4 * M_PI_2\n\n var ix = reinterpret(x);\n var sign = ix >> 31;\n ix &= 0x7fffffff;\n\n if (ix <= 0x3f490fda) { /* |x| ~<= π/4 */\n if (ix < 0x39800000) { /* |x| < 2**-12 */\n sincos_sin = x;\n sincos_cos = 1;\n return;\n }\n sincos_sin = sin_kernf(x);\n sincos_cos = cos_kernf(x);\n return;\n }\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */\n if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */\n if (sign) {\n sincos_sin = -cos_kernf(x + s1pio2);\n sincos_cos = sin_kernf(x + s1pio2);\n } else {\n sincos_sin = cos_kernf(s1pio2 - x);\n sincos_cos = sin_kernf(s1pio2 - x);\n }\n return;\n }\n /* -sin(x + c) is not correct if x+c could be 0: -0 vs +0 */\n sincos_sin = -sin_kernf(sign ? x + s2pio2 : x - s2pio2);\n sincos_cos = -cos_kernf(sign ? x + s2pio2 : x - s2pio2);\n return;\n }\n\n if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */\n if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */\n if (sign) {\n sincos_sin = cos_kernf(x + s3pio2);\n sincos_cos = -sin_kernf(x + s3pio2);\n } else {\n sincos_sin = -cos_kernf(x - s3pio2);\n sincos_cos = sin_kernf(x - s3pio2);\n }\n return;\n }\n sincos_sin = sin_kernf(sign ? x + s4pio2 : x - s4pio2);\n sincos_cos = cos_kernf(sign ? x + s4pio2 : x - s4pio2);\n return;\n }\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7f800000) {\n let xx = x - x;\n sincos_sin = xx;\n sincos_cos = xx;\n return;\n }\n\n /* general argument reduction needed */\n var n = rempio2f(x, ix, sign);\n var y = rempio2f_y;\n var s = sin_kernf(y);\n var c = cos_kernf(y);\n\n switch (n & 3) {\n case 0: {\n sincos_sin = s;\n sincos_cos = c;\n break;\n }\n case 1: {\n sincos_sin = c;\n sincos_cos = -s;\n break;\n }\n case 2: {\n sincos_sin = -s;\n sincos_cos = -c;\n break;\n }\n case 3:\n default: {\n sincos_sin = -c;\n sincos_cos = s;\n break;\n }\n }\n }\n}\n\nexport function ipow32(x: i32, e: i32): i32 {\n var out = 1;\n if (ASC_SHRINK_LEVEL < 1) {\n if (e < 0) return 0;\n\n switch (e) {\n case 0: return 1;\n case 1: return x;\n case 2: return x * x;\n }\n\n let log = 32 - clz(e);\n if (log <= 5) {\n // 32 = 2 ^ 5, so need only five cases.\n // But some extra cases needs for properly overflowing\n switch (log) {\n case 5: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 4: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 3: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 2: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 1: {\n if (e & 1) out *= x;\n }\n }\n return out;\n }\n }\n\n while (e > 0) {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n return out;\n}\n\nexport function ipow64(x: i64, e: i32): i64 {\n var out: i64 = 1;\n if (ASC_SHRINK_LEVEL < 1) {\n if (e < 0) return 0;\n switch (e) {\n case 0: return 1;\n case 1: return x;\n case 2: return x * x;\n }\n\n let log = 32 - clz(e);\n if (log <= 6) {\n // 64 = 2 ^ 6, so need only six cases.\n // But some extra cases needs for properly overflowing\n switch (log) {\n case 6: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 5: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 4: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 3: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 2: {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n case 1: {\n if (e & 1) out *= x;\n }\n }\n return out;\n }\n }\n\n while (e > 0) {\n if (e & 1) out *= x;\n e >>= 1;\n x *= x;\n }\n return out;\n}\n\nexport function ipow32f(x: f32, e: i32): f32 {\n var sign = e >> 31;\n e = (e + sign) ^ sign; // abs(e)\n var out: f32 = 1;\n while (e) {\n out *= select(x, 1.0, e & 1);\n e >>= 1;\n x *= x;\n }\n return sign ? 1.0 / out : out;\n}\n\nexport function ipow64f(x: f64, e: i32): f64 {\n var sign = e >> 31;\n e = (e + sign) ^ sign; // abs(e)\n var out = 1.0;\n while (e) {\n out *= select(x, 1.0, e & 1);\n e >>= 1;\n x *= x;\n }\n return sign ? 1.0 / out : out;\n}\n',memory:'import { memcmp, memmove, memset } from "./util/memory";\nimport { E_NOTIMPLEMENTED } from "./util/error";\n\n/** Memory manager interface. */\nexport namespace memory {\n\n /** Gets the size of the memory in pages. */\n // @ts-ignore: decorator\n @builtin\n export declare function size(): i32;\n\n /** Grows the memory by the given size in pages and returns the previous size in pages. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function grow(pages: i32): i32;\n\n /** Fills a section in memory with the specified byte value. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export function fill(dst: usize, c: u8, n: usize): void {\n memset(dst, c, n); // fallback if "bulk-memory" isn\'t enabled\n }\n\n /** Copies a section of memory to another. Has move semantics. */\n // @ts-ignore: decorator\n @unsafe @builtin\n export function copy(dst: usize, src: usize, n: usize): void {\n memmove(dst, src, n); // fallback if "bulk-memory" isn\'t enabled\n }\n\n /** Initializes a memory segment. */\n // @ts-ignore: decorator\n @unsafe\n export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n /** Drops a memory segment. */\n // @ts-ignore: decorator\n @unsafe\n export function drop(segmentIndex: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n /** Repeats a section of memory at a specific address. */\n // @ts-ignore: decorator\n @unsafe\n export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void {\n var index: usize = 0;\n var total = srcLength * count;\n while (index < total) {\n memory.copy(dst + index, src, srcLength);\n index += srcLength;\n }\n }\n\n /** Compares a section of memory to another. */\n // @ts-ignore: decorator\n @inline\n export function compare(vl: usize, vr: usize, n: usize): i32 {\n return memcmp(vl, vr, n);\n }\n}\n',number:'import { itoa, dtoa } from "./util/number";\nimport { isNaN as builtin_isNaN, isFinite as builtin_isFinite } from "./builtins";\n\n@sealed @unmanaged\nexport abstract class I8 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i8 = i8.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i8 = i8.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i8 {\n return parseI32(value, radix);\n }\n\n toString(this: i8): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I16 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i16 = i16.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i16 = i16.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i16 {\n return parseI32(value, radix);\n }\n\n toString(this: i16): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i32 = i32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i32 = i32.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i32 {\n return parseI32(value, radix);\n }\n\n toString(this: i32): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class I64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: i64 = i64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: i64 = i64.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): i64 {\n return parseI64(value, radix);\n }\n\n toString(this: i64): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Isize {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: isize = isize.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: isize = isize.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): isize {\n return parseI64(value, radix);\n }\n\n toString(this: isize): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U8 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u8 = u8.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u8 = u8.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u8 {\n return parseI32(value, radix);\n }\n\n toString(this: u8): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U16 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u16 = u16.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u16 = u16.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u16 {\n return parseI32(value, radix);\n }\n\n toString(this: u16): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u32 = u32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u32 = u32.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u32 {\n return parseI32(value, radix);\n }\n\n toString(this: u32): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class U64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: u64 = u64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: u64 = u64.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): u64 {\n return parseI64(value, radix);\n }\n\n toString(this: u64): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Usize {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: usize = usize.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: usize = usize.MAX_VALUE;\n\n static parseInt(value: string, radix: i32 = 0): usize {\n return parseI64(value, radix);\n }\n\n toString(this: usize): String {\n // TODO: radix\n return itoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class Bool {\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: bool = bool.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: bool = bool.MAX_VALUE;\n\n toString(this: bool): String {\n // TODO: radix?\n return this ? "true" : "false";\n }\n}\n\nexport { Bool as Boolean };\n\n@sealed @unmanaged\nexport abstract class F32 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly EPSILON: f32 = f32.EPSILON;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: f32 = f32.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: f32 = f32.MAX_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_SAFE_INTEGER: f32 = f32.MIN_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_SAFE_INTEGER: f32 = f32.MAX_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly POSITIVE_INFINITY: f32 = Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NEGATIVE_INFINITY: f32 = -Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NaN: f32 = NaN;\n\n static isNaN(value: f32): bool {\n return isNaN(value);\n }\n\n static isFinite(value: f32): bool {\n return isFinite(value);\n }\n\n static isSafeInteger(value: f32): bool {\n return abs(value) <= f32.MAX_SAFE_INTEGER && trunc(value) == value;\n }\n\n static isInteger(value: f32): bool {\n return isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f32 {\n return parseI64(value, radix);\n }\n\n static parseFloat(value: string): f32 {\n return parseFloat(value);\n }\n\n toString(this: f32): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\n@sealed @unmanaged\nexport abstract class F64 {\n\n // @ts-ignore: decorator\n @lazy\n static readonly EPSILON: f64 = f64.EPSILON;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_VALUE: f64 = f64.MIN_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_VALUE: f64 = f64.MAX_VALUE;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MIN_SAFE_INTEGER: f64 = f64.MIN_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly MAX_SAFE_INTEGER: f64 = f64.MAX_SAFE_INTEGER;\n\n // @ts-ignore: decorator\n @lazy\n static readonly POSITIVE_INFINITY: f64 = Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NEGATIVE_INFINITY: f64 = -Infinity;\n\n // @ts-ignore: decorator\n @lazy\n static readonly NaN: f64 = NaN;\n\n static isNaN(value: f64): bool {\n return builtin_isNaN(value);\n }\n\n static isFinite(value: f64): bool {\n return builtin_isFinite(value);\n }\n\n static isSafeInteger(value: f64): bool {\n return abs(value) <= f64.MAX_SAFE_INTEGER && trunc(value) == value;\n }\n\n static isInteger(value: f64): bool {\n return builtin_isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f64 {\n return parseI64(value, radix);\n }\n\n static parseFloat(value: string): f64 {\n return parseFloat(value);\n }\n\n toString(this: f64): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\nexport { F64 as Number };\n',polyfills:"export function bswap(value: T): T {\n if (isInteger()) {\n if (sizeof() == 2) {\n return ((value << 8) | ((value >> 8) & 0x00FF));\n }\n if (sizeof() == 4) {\n return (\n rotl(value & 0xFF00FF00, 8) |\n rotr(value & 0x00FF00FF, 8)\n );\n }\n if (sizeof() == 8) {\n let a = (value >> 8) & 0x00FF00FF00FF00FF;\n let b = (value & 0x00FF00FF00FF00FF) << 8;\n let v = a | b;\n\n a = (v >> 16) & 0x0000FFFF0000FFFF;\n b = (v & 0x0000FFFF0000FFFF) << 16;\n\n return rotr(a | b, 32);\n }\n return value;\n }\n assert(false);\n return value;\n}\n\nexport function bswap16(value: T): T {\n if (isInteger() && sizeof() <= 4) {\n if (sizeof() == 2) {\n return ((value << 8) | ((value >> 8) & 0x00FF));\n } else if (sizeof() == 4) {\n return (((value << 8) & 0xFF00) | ((value >> 8) & 0x00FF) | (value & 0xFFFF0000));\n }\n return value;\n }\n assert(false);\n return value;\n}\n",regexp:'export class RegExp {\n\n // @binding(CALL_NEW, [ STRING, STRING], OBJECT_HANDLE)\n constructor(pattern: string, flags: string = "") { throw new Error("unreachable"); }\n\n // @binding(CALL_THIS, [ STRING ], PASS_THRU)\n test(search: string): bool { throw new Error("unreachable"); }\n\n // @binding(CALL_THIS, [], STRING)\n toString(): string { throw new Error("unreachable"); }\n\n}\n',rt:'import { Typeinfo, TypeinfoFlags } from "./shared/typeinfo";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\nimport { BLOCK, BLOCK_OVERHEAD } from "./rt/common";\nimport { ArrayBufferView } from "./arraybuffer";\n\n// @ts-ignore: decorator\n@builtin\nexport declare const RTTI_BASE: usize;\n\n// @ts-ignore: decorator\n@builtin @unsafe\nexport declare function __visit_globals(cookie: u32): void;\n\n// @ts-ignore: decorator\n@builtin @unsafe\nexport declare function __visit_members(ref: usize, cookie: u32): void;\n\n// @ts-ignore: decorator\n@unsafe\nexport function __typeinfo(id: u32): TypeinfoFlags {\n var ptr = RTTI_BASE;\n if (id > load(ptr)) throw new Error(E_INDEXOUTOFRANGE);\n return changetype(ptr + sizeof() + id * offsetof()).flags;\n}\n\n// @ts-ignore: decorator\n@unsafe\nexport function __instanceof(ref: usize, superId: u32): bool { // keyword\n var id = changetype(ref - BLOCK_OVERHEAD).rtId;\n var ptr = RTTI_BASE;\n if (id <= load(ptr)) {\n do if (id == superId) return true;\n while (id = changetype(ptr + sizeof() + id * offsetof()).base);\n }\n return false;\n}\n\n// @ts-ignore: decorator\n@unsafe\nexport function __allocArray(length: i32, alignLog2: usize, id: u32, data: usize = 0): usize {\n var array = __alloc(offsetof(), id);\n var bufferSize = length << alignLog2;\n var buffer = __alloc(bufferSize, idof());\n store(array, __retain(buffer), offsetof("data"));\n changetype(array).dataStart = buffer;\n changetype(array).dataLength = bufferSize;\n store(changetype(array), length, offsetof("length_"));\n if (data) memory.copy(buffer, data, bufferSize);\n return array;\n}\n\n// These are provided by the respective implementation, included as another entry file by asc:\n\n// @builtin @unsafe\n// export declare function __alloc(size: usize, id: u32): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __realloc(ref: usize, size: usize): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __free(ref: usize): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __retain(ref: usize): usize;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __release(ref: usize): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __collect(): void;\n\n// // @ts-ignore: decorator\n// @builtin @unsafe\n// export declare function __visit(ref: usize, cookie: u32): void;\n',"rt/common":"// Alignment guarantees\n\n// @ts-ignore: decorator\n@inline export const AL_BITS: u32 = 4; // 16 bytes to fit up to v128\n// @ts-ignore: decorator\n@inline export const AL_SIZE: usize = 1 << AL_BITS;\n// @ts-ignore: decorator\n@inline export const AL_MASK: usize = AL_SIZE - 1;\n\n// Extra debugging\n\n// @ts-ignore: decorator\n@inline export const DEBUG = true;\n\n// ╒════════════════ Common block layout (32-bit) ═════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n// │ MM info │ -16\n// ├───────────────────────────────────────────────────────────────┤\n// │ GC info │ -12\n// ├───────────────────────────────────────────────────────────────┤\n// │ runtime id │ -8\n// ├───────────────────────────────────────────────────────────────┤\n// │ runtime size │ -4\n// ╞═══════════════════════════════════════════════════════════════╡\n// │ ... │ ref\n@unmanaged export class BLOCK {\n /** Memory manager info. */\n mmInfo: usize; // WASM64 needs adaption\n /** Garbage collector info. */\n gcInfo: u32;\n /** Runtime class id. */\n rtId: u32;\n /** Runtime object size. */\n rtSize: u32;\n}\n\n// @ts-ignore: decorator\n@inline export const BLOCK_OVERHEAD = (offsetof() + AL_MASK) & ~AL_MASK;\n\n// @ts-ignore: decorator\n@inline export const BLOCK_MAXSIZE: usize = (1 << 30) - BLOCK_OVERHEAD;\n","rt/index-full":'export { __alloc } from "rt/tlsf";\nexport { __retain, __release, __collect } from "rt/pure";\nexport { RTTI_BASE as __rtti } from "rt";\n',"rt/index-half":'import "rt/index-full";\n',"rt/index-none":'import "rt/index-stub";\n',"rt/index-stub":'export { __alloc, __retain, __release, __collect } from "rt/stub";\nexport { RTTI_BASE as __rtti } from "rt";\n',"rt/pure":'import { DEBUG, BLOCK_OVERHEAD } from "rt/common";\nimport { Block, freeBlock, ROOT } from "rt/tlsf";\nimport { TypeinfoFlags } from "shared/typeinfo";\nimport { onincrement, ondecrement, onfree, onalloc } from "./rtrace";\n\n/////////////////////////// A Pure Reference Counting Garbage Collector ///////////////////////////\n// see: https://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon03Pure.pdf\n\n// ╒══════════════════════ GC Info structure ══════════════════════╕\n// │ 3 2 1 │\n// │1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0│\n// ├─┼─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤\n// │B│color│ refCount │\n// └─┴─────┴───────────────────────────────────────────────────────┘\n// B: buffered\n\n// @ts-ignore: decorator\n@inline const BUFFERED_MASK: u32 = 1 << (sizeof() * 8 - 1);\n// @ts-ignore: decorator\n@inline const COLOR_BITS = 3;\n// @ts-ignore: decorator\n@inline const COLOR_SHIFT: u32 = ctz(BUFFERED_MASK) - COLOR_BITS;\n// @ts-ignore: decorator\n@inline const COLOR_MASK: u32 = ((1 << COLOR_BITS) - 1) << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const REFCOUNT_MASK: u32 = (1 << COLOR_SHIFT) - 1;\n\n// ╒════════╤═══════════════════ Colors ═══════════════════════════╕\n// │ Color │ Meaning │\n// ├────────┼──────────────────────────────────────────────────────┤\n// │ BLACK │ In use or free │\n// │ GRAY │ Possible member of cycle │\n// │ WHITE │ Member of garbage cycle │\n// │ PURPLE │ Possible root of cycle │\n// │ RED │ Candidate cycle undergoing Σ-computation *concurrent │\n// │ ORANGE │ Candidate cycle awaiting epoch boundary *concurrent │\n// └────────┴──────────────────────────────────────────────────────┘\n// Acyclic detection has been decoupled, hence no GREEN.\n\n// @ts-ignore: decorator\n@inline const COLOR_BLACK: u32 = 0 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_GRAY: u32 = 1 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_WHITE: u32 = 2 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_PURPLE: u32 = 3 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_RED: u32 = 4 << COLOR_SHIFT;\n// @ts-ignore: decorator\n@inline const COLOR_ORANGE: u32 = 5 << COLOR_SHIFT;\n\n// @ts-ignore: decorator\n@inline const VISIT_DECREMENT = 1; // guard 0\n// @ts-ignore: decorator\n@inline const VISIT_MARKGRAY = 2;\n// @ts-ignore: decorator\n@inline const VISIT_SCAN = 3;\n// @ts-ignore: decorator\n@inline const VISIT_SCANBLACK = 4;\n// @ts-ignore: decorator\n@inline const VISIT_COLLECTWHITE = 5;\n\n// @ts-ignore: decorator\n@global @unsafe\nfunction __visit(ref: usize, cookie: i32): void {\n if (ref < HEAP_BASE) return;\n var s = changetype(ref - BLOCK_OVERHEAD);\n switch (cookie) {\n case VISIT_DECREMENT: {\n decrement(s);\n break;\n }\n case VISIT_MARKGRAY: {\n if (DEBUG) assert((s.gcInfo & REFCOUNT_MASK) > 0);\n s.gcInfo = s.gcInfo - 1;\n markGray(s);\n break;\n }\n case VISIT_SCAN: {\n scan(s);\n break;\n }\n case VISIT_SCANBLACK: {\n let info = s.gcInfo;\n assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow\n s.gcInfo = info + 1;\n if ((info & COLOR_MASK) != COLOR_BLACK) {\n scanBlack(s);\n }\n break;\n }\n case VISIT_COLLECTWHITE: {\n collectWhite(s);\n break;\n }\n default: if (DEBUG) assert(false);\n }\n}\n\n/** Increments the reference count of the specified block by one.*/\nfunction increment(s: Block): void {\n var info = s.gcInfo;\n assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow\n s.gcInfo = info + 1;\n if (isDefined(ASC_RTRACE)) onincrement(s);\n if (DEBUG) assert(!(s.mmInfo & 1)); // used\n}\n\n/** Decrements the reference count of the specified block by one, possibly freeing it. */\nfunction decrement(s: Block): void {\n var info = s.gcInfo;\n var rc = info & REFCOUNT_MASK;\n if (isDefined(ASC_RTRACE)) ondecrement(s);\n if (DEBUG) assert(!(s.mmInfo & 1)); // used\n if (rc == 1) {\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_DECREMENT);\n if (!(info & BUFFERED_MASK)) {\n freeBlock(ROOT, s);\n } else {\n s.gcInfo = BUFFERED_MASK | COLOR_BLACK | 0;\n }\n } else {\n if (DEBUG) assert(rc > 0);\n if (!(__typeinfo(s.rtId) & TypeinfoFlags.ACYCLIC)) {\n s.gcInfo = BUFFERED_MASK | COLOR_PURPLE | (rc - 1);\n if (!(info & BUFFERED_MASK)) {\n appendRoot(s);\n }\n } else {\n s.gcInfo = (info & ~REFCOUNT_MASK) | (rc - 1);\n }\n }\n}\n\n/** Buffer of possible roots. */\n// @ts-ignore: decorator\n@lazy var ROOTS: usize;\n/** Current absolute offset into the `ROOTS` buffer. */\n// @ts-ignore: decorator\n@lazy var CUR: usize = 0;\n/** Current absolute end offset into the `ROOTS` buffer. */\n// @ts-ignore: decorator\n@lazy var END: usize = 0;\n\n/** Appends a block to possible roots. */\nfunction appendRoot(s: Block): void {\n var cur = CUR;\n if (cur >= END) {\n growRoots(); // TBD: either that or pick a default and force collection on overflow\n cur = CUR;\n }\n store(cur, s);\n CUR = cur + sizeof();\n}\n\n/** Grows the roots buffer if it ran full. */\nfunction growRoots(): void {\n var oldRoots = ROOTS;\n var oldSize = CUR - oldRoots;\n var newSize = max(oldSize * 2, 64 << alignof());\n var newRoots = __alloc(newSize, 0);\n if (isDefined(ASC_RTRACE)) onfree(changetype(newRoots - BLOCK_OVERHEAD)); // neglect unmanaged\n memory.copy(newRoots, oldRoots, oldSize);\n if (oldRoots) {\n if (isDefined(ASC_RTRACE)) onalloc(changetype(oldRoots - BLOCK_OVERHEAD)); // neglect unmanaged\n __free(oldRoots);\n }\n ROOTS = newRoots;\n CUR = newRoots + oldSize;\n END = newRoots + newSize;\n}\n\n/** Collects cyclic garbage. */\n// @ts-ignore: decorator\n@global @unsafe\nexport function __collect(): void {\n\n // markRoots\n var roots = ROOTS;\n var cur = roots;\n for (let pos = cur, end = CUR; pos < end; pos += sizeof()) {\n let s = load(pos);\n let info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_PURPLE && (info & REFCOUNT_MASK) > 0) {\n markGray(s);\n store(cur, s);\n cur += sizeof();\n } else {\n if ((info & COLOR_MASK) == COLOR_BLACK && !(info & REFCOUNT_MASK)) {\n freeBlock(ROOT, s);\n } else {\n s.gcInfo = info & ~BUFFERED_MASK;\n }\n }\n }\n CUR = cur;\n\n // scanRoots\n for (let pos = roots; pos < cur; pos += sizeof()) {\n scan(load(pos));\n }\n\n // collectRoots\n for (let pos = roots; pos < cur; pos += sizeof()) {\n let s = load(pos);\n s.gcInfo = s.gcInfo & ~BUFFERED_MASK;\n collectWhite(s);\n }\n CUR = roots;\n}\n\n/** Marks a block as gray (possible member of cycle) during the collection phase. */\nfunction markGray(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) != COLOR_GRAY) {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_GRAY;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_MARKGRAY);\n }\n}\n\n/** Scans a block during the collection phase, determining whether it is garbage or not. */\nfunction scan(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_GRAY) {\n if ((info & REFCOUNT_MASK) > 0) {\n scanBlack(s);\n } else {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_WHITE;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_SCAN);\n }\n }\n}\n\n/** Marks a block as black (in use) if it was found to be reachable during the collection phase. */\nfunction scanBlack(s: Block): void {\n s.gcInfo = (s.gcInfo & ~COLOR_MASK) | COLOR_BLACK;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_SCANBLACK);\n}\n\n/** Collects all white (member of a garbage cycle) nodes when completing the collection phase. */\nfunction collectWhite(s: Block): void {\n var info = s.gcInfo;\n if ((info & COLOR_MASK) == COLOR_WHITE && !(info & BUFFERED_MASK)) {\n s.gcInfo = (info & ~COLOR_MASK) | COLOR_BLACK;\n __visit_members(changetype(s) + BLOCK_OVERHEAD, VISIT_COLLECTWHITE);\n freeBlock(ROOT, s);\n }\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __retain(ref: usize): usize {\n if (ref > HEAP_BASE) increment(changetype(ref - BLOCK_OVERHEAD));\n return ref;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __release(ref: usize): void {\n if (ref > HEAP_BASE) decrement(changetype(ref - BLOCK_OVERHEAD));\n}\n',"rt/rtrace":'import { BLOCK } from "./common";\n\nexport declare function onalloc(s: BLOCK): void;\nexport declare function onincrement(s: BLOCK): void;\nexport declare function ondecrement(s: BLOCK): void;\nexport declare function onfree(s: BLOCK): void;\n',"rt/stub":'import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "rt/common";\n\n// @ts-ignore: decorator\n@lazy\nvar startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n\n// @ts-ignore: decorator\n@lazy\nvar offset: usize = startOffset;\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __alloc(size: usize, id: u32): usize {\n if (size > BLOCK_MAXSIZE) unreachable();\n var ptr = offset + BLOCK_OVERHEAD;\n var newPtr = (ptr + max(size, 1) + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n if (newPtr > pagesBefore << 16) {\n let pagesNeeded = ((newPtr - ptr + 0xffff) & ~0xffff) >>> 16;\n let pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) unreachable(); // out of memory\n }\n }\n offset = newPtr;\n var block = changetype(ptr - BLOCK_OVERHEAD);\n block.rtId = id;\n block.rtSize = size;\n return ptr;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __realloc(ref: usize, size: usize): usize {\n var block = changetype(ref - BLOCK_OVERHEAD);\n var oldSize = block.rtSize;\n if (size > oldSize) {\n let newRef = __alloc(size, block.rtId);\n memory.copy(newRef, ref, oldSize);\n ref = newRef;\n } else {\n block.rtSize = size;\n }\n return ref;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __free(ref: usize): void {\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nfunction __reset(): void { // special\n offset = startOffset;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __retain(ref: usize): usize {\n return ref;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __release(ref: usize): void {\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __visit(ref: usize, cookie: u32): void {\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __collect(): void {\n}\n',"rt/tlsf":"import { AL_BITS, AL_MASK, DEBUG, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from \"rt/common\";\nimport { onfree, onalloc } from \"./rtrace\";\n\n/////////////////////// The TLSF (Two-Level Segregate Fit) memory allocator ///////////////////////\n// see: http://www.gii.upv.es/tlsf/\n\n// - `ffs(x)` is equivalent to `ctz(x)` with x != 0\n// - `fls(x)` is equivalent to `sizeof(x) * 8 - clz(x) - 1`\n\n// ╒══════════════ Block size interpretation (32-bit) ═════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─╫─┴─┴─┴─┤\n// │ | FL │ SB = SL + AL │ ◄─ usize\n// └───────────────────────────────────────────────┴───────╨───────┘\n// FL: first level, SL: second level, AL: alignment, SB: small block\n\n// @ts-ignore: decorator\n@inline const SL_BITS: u32 = 4;\n// @ts-ignore: decorator\n@inline const SL_SIZE: usize = 1 << SL_BITS;\n\n// @ts-ignore: decorator\n@inline const SB_BITS: usize = (SL_BITS + AL_BITS);\n// @ts-ignore: decorator\n@inline const SB_SIZE: usize = 1 << SB_BITS;\n\n// @ts-ignore: decorator\n@inline const FL_BITS: u32 = 31 - SB_BITS;\n\n// [00]: < 256B (SB) [12]: < 1M\n// [01]: < 512B [13]: < 2M\n// [02]: < 1K [14]: < 4M\n// [03]: < 2K [15]: < 8M\n// [04]: < 4K [16]: < 16M\n// [05]: < 8K [17]: < 32M\n// [06]: < 16K [18]: < 64M\n// [07]: < 32K [19]: < 128M\n// [08]: < 64K [20]: < 256M\n// [09]: < 128K [21]: < 512M\n// [10]: < 256K [22]: <= 1G - OVERHEAD\n// [11]: < 512K\n// VMs limit to 2GB total (currently), making one 1G block max (or three 512M etc.) due to block overhead\n\n// Tags stored in otherwise unused alignment bits\n\n// @ts-ignore: decorator\n@inline const FREE: usize = 1 << 0;\n// @ts-ignore: decorator\n@inline const LEFTFREE: usize = 1 << 1;\n// @ts-ignore: decorator\n@inline const TAGS_MASK: usize = FREE | LEFTFREE; // <= AL_MASK\n\n// ╒════════════════════ Block layout (32-bit) ════════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┼─┼─┤ overhead ┐\n// │ size │0│L│F│ ◄─┐ info\n// ├─────────────────────────────────────────────────────────┴─┴─┴─┤ │\n// │ │ │\n// │ ... additional runtime overhead ... │ │\n// │ │ │\n// ╞═══════════════════════════════════════════════════════════════╡ │ ┐ ┘\n// │ if free: ◄ prev │ ◄─┤ usize\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: next ► │ ◄─┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ │ = 0\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: back ▲ │ ◄─┘\n// └───────────────────────────────────────────────────────────────┘ payload ┘ >= MIN SIZE\n// F: FREE, L: LEFTFREE\n@unmanaged export class Block extends BLOCK {\n\n /** Previous free block, if any. Only valid if free, otherwise part of payload. */\n prev: Block | null;\n /** Next free block, if any. Only valid if free, otherwise part of payload. */\n next: Block | null;\n\n // If the block is free, there is a 'back'reference at its end pointing at its start.\n}\n\n// Block constants. A block must have a minimum size of three pointers so it can hold `prev`,\n// `next` and `back` if free.\n\n// @ts-ignore: decorator\n@inline const BLOCK_MINSIZE: usize = (3 * sizeof() + AL_MASK) & ~AL_MASK; // prev + next + back\n// @ts-ignore: decorator\n// @inline const BLOCK_MAXSIZE: usize = 1 << (FL_BITS + SB_BITS - 1); // exclusive, lives in common.ts\n\n/** Gets the left block of a block. Only valid if the left block is free. */\n// @ts-ignore: decorator\n@inline function GETFREELEFT(block: Block): Block {\n return load(changetype(block) - sizeof());\n}\n\n/** Gets the right block of of a block by advancing to the right by its size. */\n// @ts-ignore: decorator\n@inline function GETRIGHT(block: Block): Block {\n return changetype(changetype(block) + BLOCK_OVERHEAD + (block.mmInfo & ~TAGS_MASK));\n}\n\n// ╒═════════════════════ Root layout (32-bit) ════════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ┐\n// │ 0 | flMap S│ ◄────┐\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ slMap[0] S │ ◄─┐ │\n// ├───────────────────────────────────────────────────────────────┤ │ │\n// │ slMap[1] │ ◄─┤ │\n// ├───────────────────────────────────────────────────────────────┤ u32 │\n// │ slMap[22] │ ◄─┘ │\n// ╞═══════════════════════════════════════════════════════════════╡ usize\n// │ head[0] │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ head[367] │ ◄────┤\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ tail │ ◄────┘\n// └───────────────────────────────────────────────────────────────┘ SIZE ┘\n// S: Small blocks map\n@unmanaged class Root {\n /** First level bitmap. */\n flMap: usize;\n}\n\n// Root constants. Where stuff is stored inside of the root structure.\n\n// @ts-ignore: decorator\n@inline const SL_START = sizeof();\n// @ts-ignore: decorator\n@inline const SL_END = SL_START + (FL_BITS << alignof());\n// @ts-ignore: decorator\n@inline const HL_START = (SL_END + AL_MASK) & ~AL_MASK;\n// @ts-ignore: decorator\n@inline const HL_END = HL_START + FL_BITS * SL_SIZE * sizeof();\n// @ts-ignore: decorator\n@inline const ROOT_SIZE = HL_END + sizeof();\n\n// @ts-ignore: decorator\n@lazy export var ROOT: Root;\n\n/** Gets the second level map of the specified first level. */\n// @ts-ignore: decorator\n@inline function GETSL(root: Root, fl: usize): u32 {\n return load(\n changetype(root) + (fl << alignof()),\n SL_START\n );\n}\n\n/** Sets the second level map of the specified first level. */\n// @ts-ignore: decorator\n@inline function SETSL(root: Root, fl: usize, slMap: u32): void {\n store(\n changetype(root) + (fl << alignof()),\n slMap,\n SL_START\n );\n}\n\n/** Gets the head of the free list for the specified combination of first and second level. */\n// @ts-ignore: decorator\n@inline function GETHEAD(root: Root, fl: usize, sl: u32): Block | null {\n return load(\n changetype(root) + (((fl << SL_BITS) + sl) << alignof()),\n HL_START\n );\n}\n\n/** Sets the head of the free list for the specified combination of first and second level. */\n// @ts-ignore: decorator\n@inline function SETHEAD(root: Root, fl: usize, sl: u32, head: Block | null): void {\n store(\n changetype(root) + (((fl << SL_BITS) + sl) << alignof()),\n head,\n HL_START\n );\n}\n\n/** Gets the tail block.. */\n// @ts-ignore: decorator\n@inline function GETTAIL(root: Root): Block {\n return load(\n changetype(root),\n HL_END\n );\n}\n\n/** Sets the tail block. */\n// @ts-ignore: decorator\n@inline function SETTAIL(root: Root, tail: Block): void {\n store(\n changetype(root),\n tail,\n HL_END\n );\n}\n\n/** Inserts a previously used block back into the free list. */\nfunction insertBlock(root: Root, block: Block): void {\n if (DEBUG) assert(block); // cannot be null\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(blockInfo & FREE); // must be free\n\n var right = GETRIGHT(block);\n var rightInfo = right.mmInfo;\n\n // merge with right block if also free\n if (rightInfo & FREE) {\n let newSize = (blockInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (rightInfo & ~TAGS_MASK);\n if (newSize < BLOCK_MAXSIZE) {\n removeBlock(root, right);\n block.mmInfo = blockInfo = (blockInfo & TAGS_MASK) | newSize;\n right = GETRIGHT(block);\n rightInfo = right.mmInfo;\n // 'back' is set below\n }\n }\n\n // merge with left block if also free\n if (blockInfo & LEFTFREE) {\n let left = GETFREELEFT(block);\n let leftInfo = left.mmInfo;\n if (DEBUG) assert(leftInfo & FREE); // must be free according to right tags\n let newSize = (leftInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (blockInfo & ~TAGS_MASK);\n if (newSize < BLOCK_MAXSIZE) {\n removeBlock(root, left);\n left.mmInfo = blockInfo = (leftInfo & TAGS_MASK) | newSize;\n block = left;\n // 'back' is set below\n }\n }\n\n right.mmInfo = rightInfo | LEFTFREE;\n // right is no longer used now, hence rightInfo is not synced\n\n // we now know the size of the block\n var size = blockInfo & ~TAGS_MASK;\n if (DEBUG) assert(size >= BLOCK_MINSIZE && size < BLOCK_MAXSIZE); // must be a valid size\n if (DEBUG) assert(changetype(block) + BLOCK_OVERHEAD + size == changetype(right)); // must match\n\n // set 'back' to itself at the end of block\n store(changetype(right) - sizeof(), block);\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const inv: usize = sizeof() * 8 - 1;\n fl = inv - clz(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // perform insertion\n var head = GETHEAD(root, fl, sl);\n block.prev = null;\n block.next = head;\n if (head) head.prev = block;\n SETHEAD(root, fl, sl, block);\n\n // update first and second level maps\n root.flMap |= (1 << fl);\n SETSL(root, fl, GETSL(root, fl) | (1 << sl));\n}\n\n/** Removes a free block from internal lists. */\nfunction removeBlock(root: Root, block: Block): void {\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(blockInfo & FREE); // must be free\n var size = blockInfo & ~TAGS_MASK;\n if (DEBUG) assert(size >= BLOCK_MINSIZE && size < BLOCK_MAXSIZE); // must be valid\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const inv: usize = sizeof() * 8 - 1;\n fl = inv - clz(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // link previous and next free block\n var prev = block.prev;\n var next = block.next;\n if (prev) prev.next = next;\n if (next) next.prev = prev;\n\n // update head if we are removing it\n if (block == GETHEAD(root, fl, sl)) {\n SETHEAD(root, fl, sl, next);\n\n // clear second level map if head is empty now\n if (!next) {\n let slMap = GETSL(root, fl);\n SETSL(root, fl, slMap &= ~(1 << sl));\n\n // clear first level map if second level is empty now\n if (!slMap) root.flMap &= ~(1 << fl);\n }\n }\n // note: does not alter left/back because it is likely that splitting\n // is performed afterwards, invalidating those changes. so, the caller\n // must perform those updates.\n}\n\n/** Searches for a free block of at least the specified size. */\nfunction searchBlock(root: Root, size: usize): Block | null {\n // size was already asserted by caller\n\n // mapping_search\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size >> AL_BITS);\n } else {\n const halfMaxSize = BLOCK_MAXSIZE >> 1; // don't round last fl\n const inv: usize = sizeof() * 8 - 1;\n const invRound = inv - SL_BITS;\n let requestSize = size < halfMaxSize\n ? size + (1 << (invRound - clz(size))) - 1\n : size;\n fl = inv - clz(requestSize);\n sl = ((requestSize >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n if (DEBUG) assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range\n\n // search second level\n var slMap = GETSL(root, fl) & (~0 << sl);\n var head: Block | null = null;\n if (!slMap) {\n // search next larger first level\n let flMap = root.flMap & (~0 << (fl + 1));\n if (!flMap) {\n head = null;\n } else {\n fl = ctz(flMap);\n slMap = GETSL(root, fl);\n if (DEBUG) assert(slMap); // can't be zero if fl points here\n head = GETHEAD(root, fl, ctz(slMap));\n }\n } else {\n head = GETHEAD(root, fl, ctz(slMap));\n }\n return head;\n}\n\n/** Prepares the specified block before (re-)use, possibly splitting it. */\nfunction prepareBlock(root: Root, block: Block, size: usize): void {\n // size was already asserted by caller\n\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(!(size & AL_MASK)); // size must be aligned so the new block is\n\n // split if the block can hold another MINSIZE block incl. overhead\n var remaining = (blockInfo & ~TAGS_MASK) - size;\n if (remaining >= BLOCK_OVERHEAD + BLOCK_MINSIZE) {\n block.mmInfo = size | (blockInfo & LEFTFREE); // also discards FREE\n\n let spare = changetype(changetype(block) + BLOCK_OVERHEAD + size);\n spare.mmInfo = (remaining - BLOCK_OVERHEAD) | FREE; // not LEFTFREE\n insertBlock(root, spare); // also sets 'back'\n\n // otherwise tag block as no longer FREE and right as no longer LEFTFREE\n } else {\n block.mmInfo = blockInfo & ~FREE;\n GETRIGHT(block).mmInfo &= ~LEFTFREE;\n }\n}\n\n/** Adds more memory to the pool. */\nfunction addMemory(root: Root, start: usize, end: usize): bool {\n if (DEBUG) {\n assert(\n start <= end && // must be valid\n !(start & AL_MASK) && // must be aligned\n !(end & AL_MASK) // must be aligned\n );\n }\n\n var tail = GETTAIL(root);\n var tailInfo: usize = 0;\n if (tail) { // more memory\n if (DEBUG) assert(start >= changetype(tail) + BLOCK_OVERHEAD);\n\n // merge with current tail if adjacent\n if (start - BLOCK_OVERHEAD == changetype(tail)) {\n start -= BLOCK_OVERHEAD;\n tailInfo = tail.mmInfo;\n } else {\n // We don't do this, but a user might `memory.grow` manually\n // leading to non-adjacent pages managed by TLSF.\n }\n\n } else if (DEBUG) { // first memory\n assert(start >= changetype(root) + ROOT_SIZE); // starts after root\n }\n\n // check if size is large enough for a free block and the tail block\n var size = end - start;\n if (size < BLOCK_OVERHEAD + BLOCK_MINSIZE + BLOCK_OVERHEAD) {\n return false;\n }\n\n // left size is total minus its own and the zero-length tail's header\n var leftSize = size - 2 * BLOCK_OVERHEAD;\n var left = changetype(start);\n left.mmInfo = leftSize | FREE | (tailInfo & LEFTFREE);\n left.prev = null;\n left.next = null;\n\n // tail is a zero-length used block\n tail = changetype(start + size - BLOCK_OVERHEAD);\n tail.mmInfo = 0 | LEFTFREE;\n SETTAIL(root, tail);\n\n insertBlock(root, left); // also merges with free left before tail / sets 'back'\n\n return true;\n}\n\n/** Grows memory to fit at least another block of the specified size. */\nfunction growMemory(root: Root, size: usize): void {\n var pagesBefore = memory.size();\n var pagesNeeded = (((size + 0xffff) & ~0xffff) >>> 16);\n var pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) unreachable();\n }\n var pagesAfter = memory.size();\n addMemory(root, pagesBefore << 16, pagesAfter << 16);\n}\n\n/** Prepares and checks an allocation size. */\nfunction prepareSize(size: usize): usize {\n if (size >= BLOCK_MAXSIZE) throw new Error(\"allocation too large\");\n return max((size + AL_MASK) & ~AL_MASK, BLOCK_MINSIZE); // align and ensure min size\n}\n\n/** Initilizes the root structure. */\nexport function initializeRoot(): void {\n var rootOffset = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n var pagesNeeded = ((((rootOffset + ROOT_SIZE) + 0xffff) & ~0xffff) >>> 16);\n if (pagesNeeded > pagesBefore && memory.grow(pagesNeeded - pagesBefore) < 0) unreachable();\n var root = changetype(rootOffset);\n root.flMap = 0;\n SETTAIL(root, changetype(0));\n for (let fl: usize = 0; fl < FL_BITS; ++fl) {\n SETSL(root, fl, 0);\n for (let sl: u32 = 0; sl < SL_SIZE; ++sl) {\n SETHEAD(root, fl, sl, null);\n }\n }\n addMemory(root, (rootOffset + ROOT_SIZE + AL_MASK) & ~AL_MASK, memory.size() << 16);\n ROOT = root;\n}\n\n/** Allocates a block of the specified size. */\nexport function allocateBlock(root: Root, size: usize): Block {\n var payloadSize = prepareSize(size);\n var block = searchBlock(root, payloadSize);\n if (!block) {\n growMemory(root, payloadSize);\n block = searchBlock(root, payloadSize);\n if (DEBUG) assert(block); // must be found now\n }\n if (DEBUG) assert((block.mmInfo & ~TAGS_MASK) >= payloadSize); // must fit\n block.gcInfo = 0; // RC=0\n // block.rtId = 0; // set by the caller (__alloc)\n block.rtSize = size;\n removeBlock(root, block);\n prepareBlock(root, block, payloadSize);\n if (isDefined(ASC_RTRACE)) onalloc(block);\n return block;\n}\n\n/** Reallocates a block to the specified size. */\nexport function reallocateBlock(root: Root, block: Block, size: usize): Block {\n var payloadSize = prepareSize(size);\n var blockInfo = block.mmInfo;\n if (DEBUG) assert(!(blockInfo & FREE)); // must be used\n\n // possibly split and update runtime size if it still fits\n if (payloadSize <= (blockInfo & ~TAGS_MASK)) {\n prepareBlock(root, block, payloadSize);\n block.rtSize = size;\n return block;\n }\n\n // merge with right free block if merger is large enough\n var right = GETRIGHT(block);\n var rightInfo = right.mmInfo;\n if (rightInfo & FREE) {\n let mergeSize = (blockInfo & ~TAGS_MASK) + BLOCK_OVERHEAD + (rightInfo & ~TAGS_MASK);\n if (mergeSize >= payloadSize) {\n removeBlock(root, right);\n // TODO: this can yield an intermediate block larger than BLOCK_MAXSIZE, which\n // is immediately split though. does this trigger any assertions / issues?\n block.mmInfo = (blockInfo & TAGS_MASK) | mergeSize;\n block.rtSize = size;\n prepareBlock(root, block, payloadSize);\n return block;\n }\n }\n\n // otherwise move the block\n var newBlock = allocateBlock(root, size);\n newBlock.gcInfo = block.gcInfo;\n newBlock.rtId = block.rtId;\n memory.copy(changetype(newBlock) + BLOCK_OVERHEAD, changetype(block) + BLOCK_OVERHEAD, size);\n block.mmInfo = blockInfo | FREE;\n insertBlock(root, block);\n return newBlock;\n}\n\n/** Frees a block. */\nexport function freeBlock(root: Root, block: Block): void {\n var blockInfo = block.mmInfo;\n assert(!(blockInfo & FREE)); // must be used (user might call through to this)\n block.mmInfo = blockInfo | FREE;\n insertBlock(root, block);\n if (isDefined(ASC_RTRACE)) onfree(block);\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __alloc(size: usize, id: u32): usize {\n var root = ROOT;\n if (!root) {\n initializeRoot();\n root = ROOT;\n }\n var block = allocateBlock(root, size);\n block.rtId = id;\n return changetype(block) + BLOCK_OVERHEAD;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __realloc(ref: usize, size: usize): usize {\n if (DEBUG) assert(ROOT); // must be initialized\n assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned\n return changetype(reallocateBlock(ROOT, changetype(ref - BLOCK_OVERHEAD), size)) + BLOCK_OVERHEAD;\n}\n\n// @ts-ignore: decorator\n@global @unsafe\nexport function __free(ref: usize): void {\n if (DEBUG) assert(ROOT); // must be initialized\n assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned\n freeBlock(ROOT, changetype(ref - BLOCK_OVERHEAD));\n}\n",set:'/// \n\nimport { HASH } from "./util/hash";\n\n// A deterministic hash set based on CloseTable from https://github.com/jorendorff/dht\n\n// @ts-ignore: decorator\n@inline\nconst INITIAL_CAPACITY = 4;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR: f64 = 8 / 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR: f64 = 3 / 4;\n\n/** Structure of a set entry. */\n@unmanaged class SetEntry {\n key: K;\n taggedNext: usize; // LSB=1 indicates EMPTY\n}\n\n/** Empty bit. */\n// @ts-ignore: decorator\n@inline\nconst EMPTY: usize = 1 << 0;\n\n/** Size of a bucket. */\n// @ts-ignore: decorator\n@inline\nconst BUCKET_SIZE = sizeof();\n\n/** Computes the alignment of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_ALIGN(): usize {\n // can align to 4 instead of 8 if 32-bit and K is <= 32-bits\n const align = (sizeof() > sizeof() ? sizeof() : sizeof()) - 1;\n return align;\n}\n\n/** Computes the aligned size of an entry. */\n// @ts-ignore: decorator\n@inline\nfunction ENTRY_SIZE(): usize {\n const align = ENTRY_ALIGN();\n const size = (offsetof>() + align) & ~align;\n return size;\n}\n\nexport class Set {\n\n // buckets holding references to the respective first entry within\n private buckets: ArrayBuffer; // usize[bucketsMask + 1]\n private bucketsMask: u32;\n\n // entries in insertion order\n private entries: ArrayBuffer; // SetEntry[entriesCapacity]\n private entriesCapacity: i32;\n private entriesOffset: i32;\n private entriesCount: i32;\n\n get size(): i32 { return this.entriesCount; }\n\n constructor() { this.clear(); }\n\n clear(): void {\n const bucketsSize = INITIAL_CAPACITY * BUCKET_SIZE;\n this.buckets = new ArrayBuffer(bucketsSize);\n this.bucketsMask = INITIAL_CAPACITY - 1;\n const entriesSize = INITIAL_CAPACITY * ENTRY_SIZE();\n this.entries = new ArrayBuffer(entriesSize);\n this.entriesCapacity = INITIAL_CAPACITY;\n this.entriesOffset = 0;\n this.entriesCount = 0;\n }\n\n private find(key: K, hashCode: u32): SetEntry | null {\n var entry = load>( // unmanaged!\n changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE\n );\n while (entry) {\n if (!(entry.taggedNext & EMPTY) && entry.key == key) return entry;\n entry = changetype>(entry.taggedNext & ~EMPTY);\n }\n return null;\n }\n\n has(key: K): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n add(key: K): void {\n var hashCode = HASH(key);\n var entry = this.find(key, hashCode); // unmanaged!\n if (!entry) {\n // check if rehashing is necessary\n if (this.entriesOffset == this.entriesCapacity) {\n this.rehash(\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ? this.bucketsMask // just rehash if 1/4+ entries are empty\n : (this.bucketsMask << 1) | 1 // grow capacity to next 2^N\n );\n }\n // append new entry\n entry = changetype>(changetype(this.entries) + this.entriesOffset++ * ENTRY_SIZE());\n entry.key = isManaged()\n ? changetype(__retain(changetype(key)))\n : key;\n ++this.entriesCount;\n // link with previous entry in bucket\n let bucketPtrBase = changetype(this.buckets) + (hashCode & this.bucketsMask) * BUCKET_SIZE;\n entry.taggedNext = load(bucketPtrBase);\n store(bucketPtrBase, changetype(entry));\n }\n }\n\n delete(key: K): bool {\n var entry = this.find(key, HASH(key)); // unmanaged!\n if (!entry) return false;\n if (isManaged()) __release(changetype(entry.key)); // exact \'key\'\n entry.taggedNext |= EMPTY;\n --this.entriesCount;\n // check if rehashing is appropriate\n var halfBucketsMask = this.bucketsMask >> 1;\n if (\n halfBucketsMask + 1 >= max(INITIAL_CAPACITY, this.entriesCount) &&\n this.entriesCount < (this.entriesCapacity * FREE_FACTOR)\n ) this.rehash(halfBucketsMask);\n return true;\n }\n\n private rehash(newBucketsMask: u32): void {\n var newBucketsCapacity = (newBucketsMask + 1);\n var newBuckets = new ArrayBuffer(newBucketsCapacity * BUCKET_SIZE);\n var newEntriesCapacity = (newBucketsCapacity * FILL_FACTOR);\n var newEntries = new ArrayBuffer(newEntriesCapacity * ENTRY_SIZE());\n\n // copy old entries to new entries\n var oldPtr = changetype(this.entries);\n var oldEnd = oldPtr + this.entriesOffset * ENTRY_SIZE();\n var newPtr = changetype(newEntries);\n while (oldPtr != oldEnd) {\n let oldEntry = changetype>(oldPtr); // unmanaged!\n if (!(oldEntry.taggedNext & EMPTY)) {\n let newEntry = changetype>(newPtr); // unmanaged!\n newEntry.key = oldEntry.key;\n let newBucketIndex = HASH(oldEntry.key) & newBucketsMask;\n let newBucketPtrBase = changetype(newBuckets) + newBucketIndex * BUCKET_SIZE;\n newEntry.taggedNext = load(newBucketPtrBase);\n store(newBucketPtrBase, newPtr);\n newPtr += ENTRY_SIZE();\n }\n oldPtr += ENTRY_SIZE();\n }\n\n this.buckets = newBuckets;\n this.bucketsMask = newBucketsMask;\n this.entries = newEntries;\n this.entriesCapacity = newEntriesCapacity;\n this.entriesOffset = this.entriesCount;\n }\n\n toString(): string {\n return "[object Set]";\n }\n\n // RT integration\n\n @unsafe private __visit_impl(cookie: u32): void {\n __visit(changetype(this.buckets), cookie);\n var entries = changetype(this.entries);\n if (isManaged()) {\n let cur = entries;\n let end = cur + this.entriesOffset * ENTRY_SIZE();\n while (cur < end) {\n let entry = changetype>(cur);\n if (!(entry.taggedNext & EMPTY)) {\n let val = changetype(entry.key);\n if (isNullable()) {\n if (val) __visit(val, cookie);\n } else __visit(val, cookie);\n }\n cur += ENTRY_SIZE();\n }\n }\n __visit(entries, cookie);\n }\n}\n',"shared/feature":"// This file is shared with the compiler and must remain portable\n\n/** Indicates specific features to activate. */\nexport const enum Feature {\n /** No additional features. */\n NONE = 0,\n /** Sign extension operations. */\n SIGN_EXTENSION = 1 << 0, // see: https://github.com/WebAssembly/sign-extension-ops\n /** Mutable global imports and exports. */\n MUTABLE_GLOBAL = 1 << 1, // see: https://github.com/WebAssembly/mutable-global\n /** Bulk memory operations. */\n BULK_MEMORY = 1 << 2, // see: https://github.com/WebAssembly/bulk-memory-operations\n /** SIMD types and operations. */\n SIMD = 1 << 3, // see: https://github.com/WebAssembly/simd\n /** Threading and atomic operations. */\n THREADS = 1 << 4 // see: https://github.com/WebAssembly/threads\n}\n","shared/target":"// This file is shared with the compiler and must remain portable\n\n/** Compilation target. */\nexport enum Target {\n /** WebAssembly with 32-bit pointers. */\n WASM32,\n /** WebAssembly with 64-bit pointers. Experimental and not supported by any runtime yet. */\n WASM64,\n /** Portable. */\n JS\n}\n","shared/typeinfo":"// This file is shared with the compiler and must remain portable\n\n// ╒═══════════════════ Typeinfo interpretation ═══════════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ◄─ RTTI_BASE\n// │ count │\n// ╞═══════════════════════════════════════════════════════════════╡ ┐\n// │ Typeinfo#flags [id=0] │ id < count\n// ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤\n// │ Typeinfo#base [id=0] │\n// ├───────────────────────────────────────────────────────────────┤\n// │ ... │\n\n/** Runtime type information data structure. */\n@unmanaged\nexport class Typeinfo {\n /** Flags describing the shape of this class type. */\n flags: TypeinfoFlags;\n /** Base class id or `0` if none. */\n base: u32;\n}\n\n/** Runtime type information flags. */\nexport const enum TypeinfoFlags {\n /** No specific flags. */\n NONE = 0,\n /** Type is an `ArrayBufferView`. */\n ARRAYBUFFERVIEW = 1 << 0,\n /** Type is an `Array`. */\n ARRAY = 1 << 1,\n /** Type is a `Set`. */\n SET = 1 << 2,\n /** Type is a `Map`. */\n MAP = 1 << 3,\n /** Type is inherently acyclic. */\n ACYCLIC = 1 << 4,\n /** Value alignment of 1 byte. */\n VALUE_ALIGN_0 = 1 << 5,\n /** Value alignment of 2 bytes. */\n VALUE_ALIGN_1 = 1 << 6,\n /** Value alignment of 4 bytes. */\n VALUE_ALIGN_2 = 1 << 7,\n /** Value alignment of 8 bytes. */\n VALUE_ALIGN_3 = 1 << 8,\n /** Value alignment of 16 bytes. */\n VALUE_ALIGN_4 = 1 << 9,\n /** Value is a signed type. */\n VALUE_SIGNED = 1 << 10,\n /** Value is a float type. */\n VALUE_FLOAT = 1 << 11,\n /** Value type is nullable. */\n VALUE_NULLABLE = 1 << 12,\n /** Value type is managed. */\n VALUE_MANAGED = 1 << 13,\n /** Key alignment of 1 byte. */\n KEY_ALIGN_0 = 1 << 14,\n /** Key alignment of 2 bytes. */\n KEY_ALIGN_1 = 1 << 15,\n /** Key alignment of 4 bytes. */\n KEY_ALIGN_2 = 1 << 16,\n /** Key alignment of 8 bytes. */\n KEY_ALIGN_3 = 1 << 17,\n /** Key alignment of 16 bytes. */\n KEY_ALIGN_4 = 1 << 18,\n /** Value is a signed type. */\n KEY_SIGNED = 1 << 19,\n /** Value is a float type. */\n KEY_FLOAT = 1 << 20,\n /** Key type is nullable. */\n KEY_NULLABLE = 1 << 21,\n /** Key type is managed. */\n KEY_MANAGED = 1 << 22\n}\n",string:'/// \n\nimport { BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "./rt/common";\nimport { compareImpl, parse, CharCode, isWhiteSpaceOrLineTerminator } from "./util/string";\nimport { E_INVALIDLENGTH } from "./util/error";\nimport { ArrayBufferView } from "./arraybuffer";\nimport { idof } from "./builtins";\n\n@sealed export abstract class String {\n\n @lazy static readonly MAX_LENGTH: i32 = BLOCK_MAXSIZE >>> alignof();\n\n // TODO Add and handle second argument\n static fromCharCode(code: i32): string {\n var out = __alloc(2, idof());\n store(out, code);\n return changetype(out); // retains\n }\n\n static fromCodePoint(code: i32): string {\n assert(code <= 0x10FFFF);\n var sur = code > 0xFFFF;\n var out = __alloc((i32(sur) + 1) << 1, idof());\n if (!sur) {\n store(out, code);\n } else {\n code -= 0x10000;\n let hi: u32 = (code >>> 10) + 0xD800;\n let lo: u32 = (code & 0x3FF) + 0xDC00;\n store(out, (hi << 16) | lo);\n }\n return changetype(out); // retains\n }\n\n get length(): i32 {\n return changetype(changetype(this) - BLOCK_OVERHEAD).rtSize >> 1;\n }\n\n @operator("[]") charAt(pos: i32): String {\n assert(this !== null);\n if (pos >= this.length) return changetype("");\n var out = __alloc(2, idof());\n store(out, load(changetype(this) + (pos << 1)));\n return changetype(out); // retains\n }\n\n charCodeAt(pos: i32): i32 {\n if (pos >= this.length) return -1; // (NaN)\n return load(changetype(this) + (pos << 1));\n }\n\n codePointAt(pos: i32): i32 {\n if (pos >= this.length) return -1; // (undefined)\n var first = load(changetype(this) + (pos << 1));\n if (first < 0xD800 || first > 0xDBFF || pos + 1 == this.length) return first;\n var second = load(changetype(this) + ((pos + 1) << 1));\n if (second < 0xDC00 || second > 0xDFFF) return first;\n return ((first - 0xD800) << 10) + (second - 0xDC00) + 0x10000;\n }\n\n @operator("+") private static __concat(left: String, right: String): String {\n return select(left, changetype("null"), left !== null).concat(right);\n }\n\n concat(other: String): String {\n if (other === null) other = changetype("null");\n var thisSize: isize = this.length << 1;\n var otherSize: isize = other.length << 1;\n var outSize: usize = thisSize + otherSize;\n if (outSize == 0) return changetype("");\n var out = changetype(__alloc(outSize, idof())); // retains\n memory.copy(changetype(out), changetype(this), thisSize);\n memory.copy(changetype(out) + thisSize, changetype(other), otherSize);\n return out;\n }\n\n endsWith(searchString: String, endPosition: i32 = String.MAX_LENGTH): bool {\n assert(this !== null);\n if (searchString === null) return false;\n var end = min(max(endPosition, 0), this.length);\n var searchLength: isize = searchString.length;\n var start: isize = end - searchLength;\n if (start < 0) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, start, searchString, 0, searchLength);\n }\n\n @operator("==") private static __eq(left: String | null, right: String | null): bool {\n if (left === right) return true;\n if (left === null || right === null) return false;\n var leftLength = left.length;\n if (leftLength != right.length) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(left, 0, right, 0, leftLength);\n }\n\n @operator.prefix("!")\n private static __not(str: String | null): bool {\n return str === null || !str.length;\n }\n\n @operator("!=")\n private static __ne(left: String | null, right: String | null): bool {\n return !this.__eq(left, right);\n }\n\n @operator(">") private static __gt(left: String | null, right: String | null): bool {\n if (left === right || left === null || right === null) return false;\n var leftLength = left.length;\n var rightLength = right.length;\n if (!leftLength) return false;\n if (!rightLength) return true;\n // @ts-ignore: string <-> String\n return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) > 0;\n }\n\n @operator(">=") private static __gte(left: String, right: String): bool {\n return !this.__lt(left, right);\n }\n\n @operator("<") private static __lt(left: String, right: String): bool {\n if (left === right || left === null || right === null) return false;\n var leftLength = left.length;\n var rightLength = right.length;\n if (!rightLength) return false;\n if (!leftLength) return true;\n // @ts-ignore: string <-> String\n return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) < 0;\n }\n\n @operator("<=") private static __lte(left: String, right: String): bool {\n return !this.__gt(left, right);\n }\n\n @inline includes(searchString: String, position: i32 = 0): bool {\n return this.indexOf(searchString, position) != -1;\n }\n\n indexOf(searchString: String, fromIndex: i32 = 0): i32 {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var searchLen: isize = searchString.length;\n if (!searchLen) return 0;\n var len: isize = this.length;\n if (!len) return -1;\n var start = min(max(fromIndex, 0), len);\n len -= searchLen;\n for (let k: isize = start; k <= len; ++k) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, k, searchString, 0, searchLen)) return k;\n }\n return -1;\n }\n\n lastIndexOf(searchString: String, fromIndex: i32 = i32.MAX_VALUE): i32 {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var len: isize = this.length;\n var searchLen: isize = searchString.length;\n if (!searchLen) return len;\n if (!len) return -1;\n var start = min(max(fromIndex, 0), len - searchLen);\n for (let k = start; k >= 0; --k) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, k, searchString, 0, searchLen)) return k;\n }\n return -1;\n }\n\n startsWith(searchString: String, position: i32 = 0): bool {\n assert(this !== null);\n if (searchString === null) searchString = changetype("null");\n var pos: isize = position;\n var len: isize = this.length;\n var start = min(max(pos, 0), len);\n var searchLength: isize = searchString.length;\n if (searchLength + start > len) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, start, searchString, 0, searchLength);\n }\n\n substr(start: i32, length: i32 = i32.MAX_VALUE): String {\n assert(this !== null);\n var intStart: isize = start;\n var end: isize = length;\n var size: isize = this.length;\n if (intStart < 0) intStart = max(size + intStart, 0);\n var resultLength = min(max(end, 0), size - intStart);\n if (resultLength <= 0) return changetype("");\n var out = __alloc(resultLength << 1, idof());\n memory.copy(out, changetype(this) + intStart, resultLength);\n return changetype(out); // retains\n }\n\n substring(start: i32, end: i32 = i32.MAX_VALUE): String {\n assert(this !== null);\n var len: isize = this.length;\n var finalStart = min(max(start, 0), len);\n var finalEnd = min(max(end, 0), len);\n var fromPos = min(finalStart, finalEnd) << 1;\n var toPos = max(finalStart, finalEnd) << 1;\n len = toPos - fromPos;\n if (!len) return changetype("");\n if (!fromPos && toPos == this.length << 1) return this;\n var out = __alloc(len, idof());\n memory.copy(out, changetype(this) + fromPos, len);\n return changetype(out); // retains\n }\n\n trim(): String {\n assert(this !== null);\n var length = this.length;\n var size: usize = length << 1;\n while (\n size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + size)\n )\n ) {\n size -= 2;\n }\n var offset: usize = 0;\n while (\n offset < size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + offset)\n )\n ) {\n offset += 2; size -= 2;\n }\n if (!size) return changetype("");\n if (!start && size == length << 1) return this;\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this) + offset, size);\n return changetype(out); // retains\n }\n\n @inline\n trimLeft(): String {\n return this.trimStart();\n }\n\n @inline\n trimRight(): String {\n return this.trimEnd();\n }\n\n trimStart(): String {\n assert(this !== null);\n var size = this.length << 1;\n var offset: usize = 0;\n while (\n offset < size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + offset)\n )\n ) {\n offset += 2;\n }\n if (!offset) return this;\n size -= offset;\n if (!size) return changetype("");\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this) + offset, size);\n return changetype(out); // retains\n }\n\n trimEnd(): String {\n assert(this !== null);\n var originalSize = this.length << 1;\n var size = originalSize;\n while (\n size &&\n isWhiteSpaceOrLineTerminator(\n load(changetype(this) + size)\n )\n ) {\n size -= 2;\n }\n if (!size) return changetype("");\n if (size == originalSize) return this;\n var out = __alloc(size, idof());\n memory.copy(out, changetype(this), size);\n return changetype(out); // retains\n }\n\n padStart(targetLength: i32, padString: string = " "): String {\n assert(this !== null);\n var thisSize = this.length << 1;\n var targetSize = targetLength << 1;\n var padSize = padString.length << 1;\n if (targetSize < thisSize || !padSize) return this;\n var prependSize = targetSize - thisSize;\n var out = __alloc(targetSize, idof());\n if (prependSize > padSize) {\n let repeatCount = (prependSize - 2) / padSize;\n let restBase = repeatCount * padSize;\n let restSize = prependSize - restBase;\n memory.repeat(out, changetype(padString), padSize, repeatCount);\n memory.copy(out + restBase, changetype(padString), restSize);\n } else {\n memory.copy(out, changetype(padString), prependSize);\n }\n memory.copy(out + prependSize, changetype(this), thisSize);\n return changetype(out); // retains\n }\n\n padEnd(targetLength: i32, padString: string = " "): String {\n assert(this !== null);\n var thisSize = this.length << 1;\n var targetSize = targetLength << 1;\n var padSize = padString.length << 1;\n if (targetSize < thisSize || !padSize) return this;\n var appendSize = targetSize - thisSize;\n var out = __alloc(targetSize, idof());\n memory.copy(out, changetype(this), thisSize);\n if (appendSize > padSize) {\n let repeatCount = (appendSize - 2) / padSize;\n let restBase = repeatCount * padSize;\n let restSize = appendSize - restBase;\n memory.repeat(out + thisSize, changetype(padString), padSize, repeatCount);\n memory.copy(out + thisSize + restBase, changetype(padString), restSize);\n } else {\n memory.copy(out + thisSize, changetype(padString), appendSize);\n }\n return changetype(out); // retains\n }\n\n repeat(count: i32 = 0): String {\n assert(this !== null);\n var length = this.length;\n\n // Most browsers can\'t handle strings 1 << 28 chars or longer\n if (count < 0 || length * count > (1 << 28)) {\n throw new RangeError(E_INVALIDLENGTH);\n }\n\n if (count == 0 || !length) return changetype("");\n if (count == 1) return this;\n var out = __alloc((length * count) << 1, idof());\n memory.repeat(out, changetype(this), length << 1, count);\n return changetype(out); // retains\n }\n\n slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String {\n var len = this.length;\n var begin = beginIndex < 0 ? max(beginIndex + len, 0) : min(beginIndex, len);\n var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len);\n len = end - begin;\n if (len <= 0) return changetype("");\n var out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (begin << 1), len << 1);\n return changetype(out); // retains\n }\n\n split(separator: String | null = null, limit: i32 = i32.MAX_VALUE): String[] {\n assert(this !== null);\n if (!limit) return changetype>(__allocArray(0, alignof(), idof>())); // retains\n if (separator === null) return [this];\n var length: isize = this.length;\n var sepLen: isize = separator.length;\n if (limit < 0) limit = i32.MAX_VALUE;\n if (!sepLen) {\n if (!length) return changetype>(__allocArray(0, alignof(), idof>())); // retains\n // split by chars\n length = min(length, limit);\n let result = __allocArray(length, alignof(), idof>());\n let resultStart = changetype(result).dataStart;\n for (let i: isize = 0; i < length; ++i) {\n let charStr = __alloc(2, idof());\n store(charStr, load(changetype(this) + (i << 1)));\n store(resultStart + (i << alignof()), charStr); // result[i] = charStr\n if (isManaged()) __retain(charStr);\n }\n return changetype>(result); // retains\n } else if (!length) {\n let result = __allocArray(1, alignof(), idof>());\n store(changetype(result).dataStart, changetype("")); // static ""\n return changetype>(result); // retains\n }\n var result = changetype>(__allocArray(0, alignof(), idof>())); // retains\n var end = 0, start = 0, i = 0;\n while ((end = this.indexOf(separator, start)) != -1) {\n let len = end - start;\n if (len > 0) {\n let out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n result.push(changetype(out));\n } else {\n result.push(changetype(""));\n }\n if (++i == limit) return changetype>(result); // retains\n start = end + sepLen;\n }\n if (!start) { // also means: loop above didn\'t do anything\n result.push(this);\n return changetype>(result); // retains\n }\n var len = length - start;\n if (len > 0) {\n let out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n result.push(changetype(out)); // retains\n } else {\n result.push(changetype("")); // static ""\n }\n return changetype>(result); // retains\n // releases result\n }\n\n toString(): String {\n return this;\n }\n\n get lengthUTF8(): i32 {\n var len = 1; // null terminated\n var pos: usize = 0;\n var end = this.length;\n while (pos < end) {\n let c = load(changetype(this) + (pos << 1));\n if (c < 128) {\n len += 1; ++pos;\n } else if (c < 2048) {\n len += 2; ++pos;\n } else {\n if (\n (c & 0xFC00) == 0xD800 && pos + 1 < end &&\n (load(changetype(this) + ((pos + 1) << 1)) & 0xFC00) == 0xDC00\n ) {\n len += 4; pos += 2;\n } else {\n len += 3; ++pos;\n }\n }\n }\n return len;\n }\n\n static fromUTF8(ptr: usize, len: usize): String {\n if (len < 1) return changetype("");\n var ptrPos = 0;\n var buf = __alloc(len << 1, 0);\n var bufPos = 0;\n while (ptrPos < len) {\n let cp = load(ptr + ptrPos++);\n if (cp < 128) {\n store(buf + bufPos, cp);\n bufPos += 2;\n } else if (cp > 191 && cp < 224) {\n assert(ptrPos + 1 <= len);\n store(buf + bufPos, (cp & 31) << 6 | load(ptr + ptrPos++) & 63);\n bufPos += 2;\n } else if (cp > 239 && cp < 365) {\n assert(ptrPos + 3 <= len);\n cp = (\n (cp & 7) << 18 |\n (load(ptr + ptrPos++) & 63) << 12 |\n (load(ptr + ptrPos++) & 63) << 6 |\n load(ptr + ptrPos++) & 63\n ) - 0x10000;\n store(buf + bufPos, 0xD800 + (cp >> 10));\n bufPos += 2;\n store(buf + bufPos, 0xDC00 + (cp & 1023));\n bufPos += 2;\n } else {\n assert(ptrPos + 2 <= len);\n store(buf + bufPos,\n (cp & 15) << 12 |\n (load(ptr + ptrPos++) & 63) << 6 |\n load(ptr + ptrPos++) & 63\n );\n bufPos += 2;\n }\n }\n assert(ptrPos == len);\n var out = __alloc(bufPos, idof());\n memory.copy(out, buf, bufPos);\n __free(buf);\n return changetype(out); // retains\n }\n\n toUTF8(): usize {\n var buf = __alloc(this.lengthUTF8, 0);\n var pos: usize = 0;\n var end = this.length;\n var off: usize = 0;\n while (pos < end) {\n let c1 = load(changetype(this) + (pos << 1));\n if (c1 < 128) {\n store(buf + off, c1);\n ++off; ++pos;\n } else if (c1 < 2048) {\n let ptr = buf + off;\n store(ptr, c1 >> 6 | 192);\n store(ptr, c1 & 63 | 128, 1);\n off += 2; ++pos;\n } else {\n let ptr = buf + off;\n if ((c1 & 0xFC00) == 0xD800 && pos + 1 < end) {\n let c2 = load(changetype(this) + ((pos + 1) << 1));\n if ((c2 & 0xFC00) == 0xDC00) {\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\n store(ptr, c1 >> 18 | 240);\n store(ptr, c1 >> 12 & 63 | 128, 1);\n store(ptr, c1 >> 6 & 63 | 128, 2);\n store(ptr, c1 & 63 | 128, 3);\n off += 4; pos += 2;\n continue;\n }\n }\n store(ptr, c1 >> 12 | 224);\n store(ptr, c1 >> 6 & 63 | 128, 1);\n store(ptr, c1 & 63 | 128, 2);\n off += 3; ++pos;\n }\n }\n store(buf + off, 0);\n return buf;\n }\n}\n\n// @ts-ignore: nolib\nexport type string = String;\n\nexport function parseInt(str: String, radix: i32 = 0): f64 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\nexport function parseI32(str: String, radix: i32 = 0): i32 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\nexport function parseI64(str: String, radix: i32 = 0): i64 {\n // @ts-ignore: string <-> String\n return parse(str, radix);\n}\n\n// FIXME: naive implementation\nexport function parseFloat(str: String): f64 {\n var len: i32 = str.length;\n if (!len) return NaN;\n\n var ptr = changetype(str);\n var code = load(ptr);\n\n // determine sign\n var sign: f64;\n if (code == CharCode.MINUS) {\n if (!--len) return NaN;\n code = load(ptr += 2);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len) return NaN;\n code = load(ptr += 2);\n sign = 1;\n } else {\n sign = 1;\n }\n\n // calculate value\n var num: f64 = 0;\n while (len--) {\n code = load(ptr);\n if (code == CharCode.DOT) {\n ptr += 2;\n let fac: f64 = 0.1; // precision :(\n while (len--) {\n code = load(ptr);\n if (code == CharCode.E || code == CharCode.e) {\n assert(false); // TODO\n }\n code -= CharCode._0;\n if (code > 9) break;\n num += code * fac;\n fac *= 0.1;\n ptr += 2;\n }\n break;\n }\n code -= CharCode._0;\n if (code >= 10) break;\n num = (num * 10) + code;\n ptr += 2;\n }\n return sign * num;\n}\n',symbol:'import { Map } from "./map";\n\n// @ts-ignore: decorator\n@lazy\nvar stringToId: Map;\n\n// @ts-ignore: decorator\n@lazy\nvar idToString: Map;\n\n// @ts-ignore: decorator\n@lazy\nvar nextId: usize = 12; // Symbol.unscopables + 1\n\n@unmanaged @sealed abstract class _Symbol {\n\n // TODO: all of the following default symbols are unused currently yet add to\n // binary size if #toString becomes compiled. Ultimately we\'ll most likely want\n // to remove the unsupported ones and only keep what\'s actually supported.\n\n // @ts-ignore: decorator\n @lazy\n static readonly hasInstance: symbol = changetype(1);\n\n // @ts-ignore: decorator\n @lazy\n static readonly isConcatSpreadable: symbol = changetype(2);\n\n // @ts-ignore: decorator\n @lazy\n static readonly isRegExp: symbol = changetype(3);\n\n // @ts-ignore: decorator\n @lazy\n static readonly iterator: symbol = changetype(3);\n\n // @ts-ignore: decorator\n @lazy\n static readonly match: symbol = changetype(4);\n\n // @ts-ignore: decorator\n @lazy\n static readonly replace: symbol = changetype(5);\n\n // @ts-ignore: decorator\n @lazy\n static readonly search: symbol = changetype(6);\n\n // @ts-ignore: decorator\n @lazy\n static readonly species: symbol = changetype(7);\n\n // @ts-ignore: decorator\n @lazy\n static readonly split: symbol = changetype(8);\n\n // @ts-ignore: decorator\n @lazy\n static readonly toPrimitive: symbol = changetype(9);\n\n // @ts-ignore: decorator\n @lazy\n static readonly toStringTag: symbol = changetype(10);\n\n // @ts-ignore: decorator\n @lazy\n static readonly unscopables: symbol = changetype(11);\n\n static for(key: string): symbol {\n if (!stringToId) { stringToId = new Map(); idToString = new Map(); }\n else if (stringToId.has(key)) return changetype(stringToId.get(key));\n var id = nextId++;\n if (!id) unreachable(); // out of ids\n stringToId.set(key, id);\n idToString.set(id, key);\n return changetype(id);\n }\n\n static keyFor(sym: symbol): string | null {\n return idToString !== null && idToString.has(changetype(sym))\n ? idToString.get(changetype(sym))\n : null;\n }\n\n toString(): string {\n var id = changetype(this);\n var str = "";\n switch (id) {\n case 1: { str = "hasInstance"; break; }\n case 2: { str = "isConcatSpreadable"; break; }\n case 3: { str = "isRegExp"; break; }\n case 4: { str = "match"; break; }\n case 5: { str = "replace"; break; }\n case 6: { str = "search"; break; }\n case 7: { str = "species"; break; }\n case 8: { str = "split"; break; }\n case 9: { str = "toPrimitive"; break; }\n case 10: { str = "toStringTag"; break; }\n case 11: { str = "unscopables"; break; }\n default: {\n if (idToString !== null && idToString.has(id)) str = idToString.get(id);\n break;\n }\n }\n return "Symbol(" + str + ")";\n }\n}\n\nexport function Symbol(description: string | null = null): symbol {\n var id = nextId++;\n if (!id) unreachable(); // out of ids\n return changetype(id);\n}\n\nexport type Symbol = _Symbol;\n\n// @ts-ignore: nolib\nexport type symbol = _Symbol;\n',table:'import { E_NOTIMPLEMENTED } from "./util/error";\n\nexport namespace table {\n\n export function copy(dst: u32, src: u32, n: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n\n export function drop(elementIndex: u32): void {\n throw new Error(E_NOTIMPLEMENTED);\n }\n}\n',typedarray:'import { COMPARATOR, SORT as SORT_IMPL } from "./util/sort";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\nimport { idof } from "./builtins";\nimport { ArrayBufferView } from "./arraybuffer";\n\nexport class Int8Array extends ArrayBufferView {\n [key: number]: i8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i8, b: i8) => i32 = COMPARATOR()): Int8Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int8Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i8, index: i32, self: Int8Array) => i8): Int8Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i8, index: i32, self: Int8Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint8Array extends ArrayBufferView {\n [key: number]: u8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u8, index: i32, self: Uint8Array) => u8): Uint8Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u8, index: i32, self: Uint8Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint8ClampedArray extends ArrayBufferView {\n [key: number]: u8;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u8 {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, ~(value >> 31) & (((255 - value) >> 31) | value));\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8ClampedArray {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint8ClampedArray {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => u8): Uint8ClampedArray {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u8, index: i32, self: Uint8ClampedArray) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int16Array extends ArrayBufferView {\n [key: number]: i16;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i16 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i16, b: i16) => i32 = COMPARATOR()): Int16Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int16Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i16, index: i32, self: Int16Array) => i16): Int16Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i16, index: i32, self: Int16Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint16Array extends ArrayBufferView {\n [key: number]: u16;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u16 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: native): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u16, b: u16) => i32 = COMPARATOR()): Uint16Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint16Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u16, index: i32, self: Uint16Array) => u16): Uint16Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u16, index: i32, self: Uint16Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int32Array extends ArrayBufferView {\n [key: number]: i32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: i32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i32, b: i32) => i32 = COMPARATOR()): Int32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i32, index: i32, self: Int32Array) => i32): Int32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i32, index: i32, self: Int32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint32Array extends ArrayBufferView {\n [key: number]: u32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: u32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u32, b: u32) => i32 = COMPARATOR()): Uint32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u32, index: i32, self: Uint32Array) => u32): Uint32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u32, index: i32, self: Uint32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Int64Array extends ArrayBufferView {\n [key: number]: i64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): i64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: i64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: i64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: i64, b: i64) => i32 = COMPARATOR()): Int64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Int64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: i64, index: i32, self: Int64Array) => i64): Int64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: i64, index: i32, self: Int64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Uint64Array extends ArrayBufferView {\n [key: number]: u64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): u64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: u64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: u64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: u64, b: u64) => i32 = COMPARATOR()): Uint64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Uint64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: u64, index: i32, self: Uint64Array) => u64): Uint64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: u64, index: i32, self: Uint64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Float32Array extends ArrayBufferView {\n [key: number]: f32;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): f32 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: f32): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: f32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: f32, b: f32) => i32 = COMPARATOR()): Float32Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float32Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: f32, index: i32, self: Float32Array) => f32): Float32Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: f32, index: i32, self: Float32Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\nexport class Float64Array extends ArrayBufferView {\n [key: number]: f64;\n\n // @ts-ignore: decorator\n @lazy\n static readonly BYTES_PER_ELEMENT: usize = sizeof();\n\n constructor(length: i32) {\n super(length, alignof());\n }\n\n get buffer(): ArrayBuffer {\n return this.data;\n }\n\n get length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]") // unchecked is built-in\n private __get(index: i32): f64 {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=") // unchecked is built-in\n private __set(index: i32, value: f64): void {\n if (index >= this.dataLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n fill(value: f64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {\n return FILL(this, value, start, end);\n }\n\n sort(comparator: (a: f64, b: f64) => i32 = COMPARATOR()): Float64Array {\n return SORT(this, comparator);\n }\n\n subarray(begin: i32 = 0, end: i32 = 0x7fffffff): Float64Array {\n return SUBARRAY(this, begin, end);\n }\n\n reduce(\n callbackfn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, callbackfn, initialValue);\n }\n\n reduceRight(\n callbackfn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, callbackfn, initialValue);\n }\n\n map(callbackfn: (value: f64, index: i32, self: Float64Array) => f64): Float64Array {\n return MAP(this, callbackfn);\n }\n\n findIndex(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): i32 {\n return FIND_INDEX(this, callbackfn);\n }\n\n some(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return SOME(this, callbackfn);\n }\n\n every(callbackfn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return EVERY(this, callbackfn);\n }\n\n forEach(callbackfn: (value: f64, index: i32, self: Float64Array) => void): void {\n FOREACH(this, callbackfn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FILL(\n array: TArray,\n value: native,\n start: i32,\n end: i32\n): TArray {\n var dataStart = array.dataStart;\n var length = array.length;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n end = end < 0 ? max(length + end, 0) : min(end, length);\n if (sizeof() == 1) {\n if (start < end) memory.fill(dataStart + start, value, (end - start));\n } else {\n for (; start < end; ++start) {\n store(dataStart + (start << alignof()), value);\n }\n }\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SORT(\n array: TArray,\n comparator: (a: T, b: T) => i32\n): TArray {\n var length = array.length;\n if (length <= 1) return array;\n var base = array.dataStart;\n if (length == 2) {\n let a: T = load(base, sizeof()); // a = arr[1]\n let b: T = load(base); // b = arr[0]\n if (comparator(a, b) < 0) {\n store(base, b, sizeof()); // arr[1] = b\n store(base, a); // arr[0] = a\n }\n return array;\n }\n SORT_IMPL(base, length, comparator);\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SUBARRAY(\n array: TArray,\n begin: i32,\n end: i32\n): TArray {\n var len = array.length;\n begin = begin < 0 ? max(len + begin, 0) : min(begin, len);\n end = end < 0 ? max(len + end, 0) : min(end, len);\n end = max(end, begin);\n var out = changetype(__alloc(offsetof(), idof())); // retains\n out.data = array.data; // retains\n out.dataStart = array.dataStart + (begin << alignof());\n out.dataLength = (end - begin) << alignof();\n return out;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE(\n array: TArray,\n callbackfn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,\n initialValue: TRet\n): TRet {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n initialValue = callbackfn(initialValue, load(dataStart + (i << alignof())), i, array);\n }\n return initialValue;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE_RIGHT(\n array: TArray,\n callbackfn: (accumulator: TRet, value: T, index: i32, array: TArray) => TRet,\n initialValue: TRet\n): TRet {\n var dataStart = array.dataStart;\n for (let i = array.length - 1; i >= 0; i--) {\n initialValue = callbackfn(initialValue, load(dataStart + (i << alignof())), i, array);\n }\n return initialValue;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction MAP(\n array: TArray,\n callbackfn: (value: T, index: i32, self: TArray) => T,\n): TArray {\n var length = array.length;\n var dataStart = array.dataStart;\n var out = instantiate(length);\n var outDataStart = out.dataStart;\n for (let i = 0; i < length; i++) {\n store(\n outDataStart + (i << alignof()),\n callbackfn(load(dataStart + (i << alignof())), i, array)\n );\n }\n return out;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FIND_INDEX(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): i32 {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) return i;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SOME(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): bool {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) return true;\n }\n return false;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction EVERY(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => bool,\n): bool {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n if (callbackfn(load(dataStart + (i << alignof())), i, array)) continue;\n return false;\n }\n return true;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FOREACH(\n array: TArray,\n callbackfn: (value: T, index: i32, array: TArray) => void,\n): void {\n var dataStart = array.dataStart;\n for (let i = 0, k = array.length; i < k; i++) {\n callbackfn(load(dataStart + (i << alignof())), i, array);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function REVERSE(array: TArray): TArray {\n var dataStart = array.dataStart;\n for (let front = 0, back = array.length - 1; front < back; ++front, --back) {\n let frontPtr = dataStart + (front << alignof());\n let backPtr = dataStart + (back << alignof());\n let temp = load(frontPtr);\n store(frontPtr, load(backPtr));\n store(backPtr, temp);\n }\n return array;\n}\n',"util/error":'// Common error messages for use accross the standard library. Keeping error messages compact\n// and reusing them where possible ensures minimal static data in binaries.\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_INDEXOUTOFRANGE: string = "Index out of range";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_INVALIDLENGTH: string = "Invalid length";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_EMPTYARRAY: string = "Array is empty";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_HOLEYARRAY: string = "Element type must be nullable if array is holey";\n\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_NOTIMPLEMENTED: string = "Not implemented";\n',"util/hash":"// @ts-ignore: decorator\n@inline\nexport function HASH(key: T): u32 {\n if (isString()) {\n return hashStr(changetype(key));\n } else if (isReference()) {\n if (sizeof() == 4) return hash32(changetype(key));\n if (sizeof() == 8) return hash64(changetype(key));\n } else if (isFloat()) {\n if (sizeof() == 4) return hash32(reinterpret(f32(key)));\n if (sizeof() == 8) return hash64(reinterpret(f64(key)));\n } else {\n if (sizeof() == 1) return hash8 (u32(key));\n if (sizeof() == 2) return hash16(u32(key));\n if (sizeof() == 4) return hash32(u32(key));\n if (sizeof() == 8) return hash64(u64(key));\n }\n return unreachable();\n}\n\n// FNV-1a 32-bit as a starting point, see: http://isthe.com/chongo/tech/comp/fnv/\n\n// @ts-ignore: decorator\n@inline\nconst FNV_OFFSET: u32 = 2166136261;\n\n// @ts-ignore: decorator\n@inline\nconst FNV_PRIME: u32 = 16777619;\n\nfunction hash8(key: u32): u32 {\n return (FNV_OFFSET ^ key) * FNV_PRIME;\n}\n\nfunction hash16(key: u32): u32 {\n var v = FNV_OFFSET;\n v = (v ^ ( key & 0xff)) * FNV_PRIME;\n v = (v ^ ( key >> 8 )) * FNV_PRIME;\n return v;\n}\n\nfunction hash32(key: u32): u32 {\n var v = FNV_OFFSET;\n v = (v ^ ( key & 0xff)) * FNV_PRIME;\n v = (v ^ ((key >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((key >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( key >> 24 )) * FNV_PRIME;\n return v;\n}\n\nfunction hash64(key: u64): u32 {\n var l = key;\n var h = (key >>> 32);\n var v = FNV_OFFSET;\n v = (v ^ ( l & 0xff)) * FNV_PRIME;\n v = (v ^ ((l >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((l >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( l >> 24 )) * FNV_PRIME;\n v = (v ^ ( h & 0xff)) * FNV_PRIME;\n v = (v ^ ((h >> 8) & 0xff)) * FNV_PRIME;\n v = (v ^ ((h >> 16) & 0xff)) * FNV_PRIME;\n v = (v ^ ( h >> 24 )) * FNV_PRIME;\n return v;\n}\n\nfunction hashStr(key: string): u32 {\n var v = FNV_OFFSET;\n if (key !== null) {\n for (let i: usize = 0, k: usize = key.length << 1; i < k; ++i) {\n v = (v ^ load(changetype(key) + i)) * FNV_PRIME;\n }\n }\n return v;\n}\n","util/memory":"export function memcpy(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memcpy.c\n if (ASC_SHRINK_LEVEL > 1) {\n while (n) {\n store(dest++, load(src++));\n --n;\n }\n } else {\n let w: u32, x: u32;\n\n // copy 1 byte each until src is aligned to 4 bytes\n while (n && (src & 3)) {\n store(dest++, load(src++));\n n--;\n }\n\n // if dst is aligned to 4 bytes as well, copy 4 bytes each\n if ((dest & 3) == 0) {\n while (n >= 16) {\n store(dest , load(src ));\n store(dest + 4, load(src + 4));\n store(dest + 8, load(src + 8));\n store(dest + 12, load(src + 12));\n src += 16; dest += 16; n -= 16;\n }\n if (n & 8) {\n store(dest , load(src ));\n store(dest + 4, load(src + 4));\n dest += 8; src += 8;\n }\n if (n & 4) {\n store(dest, load(src));\n dest += 4; src += 4;\n }\n if (n & 2) { // drop to 2 bytes each\n store(dest, load(src));\n dest += 2; src += 2;\n }\n if (n & 1) { // drop to 1 byte\n store(dest++, load(src++));\n }\n return;\n }\n\n // if dst is not aligned to 4 bytes, use alternating shifts to copy 4 bytes each\n // doing shifts if faster when copying enough bytes (here: 32 or more)\n if (n >= 32) {\n switch (dest & 3) {\n // known to be != 0\n case 1: {\n w = load(src);\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n n -= 3;\n while (n >= 17) {\n x = load(src + 1);\n store(dest, w >> 24 | x << 8);\n w = load(src + 5);\n store(dest + 4, x >> 24 | w << 8);\n x = load(src + 9);\n store(dest + 8, w >> 24 | x << 8);\n w = load(src + 13);\n store(dest + 12, x >> 24 | w << 8);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n case 2: {\n w = load(src);\n store(dest++, load(src++));\n store(dest++, load(src++));\n n -= 2;\n while (n >= 18) {\n x = load(src + 2);\n store(dest, w >> 16 | x << 16);\n w = load(src + 6);\n store(dest + 4, x >> 16 | w << 16);\n x = load(src + 10);\n store(dest + 8, w >> 16 | x << 16);\n w = load(src + 14);\n store(dest + 12, x >> 16 | w << 16);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n case 3: {\n w = load(src);\n store(dest++, load(src++));\n n -= 1;\n while (n >= 19) {\n x = load(src + 3);\n store(dest, w >> 8 | x << 24);\n w = load(src + 7);\n store(dest + 4, x >> 8 | w << 24);\n x = load(src + 11);\n store(dest + 8, w >> 8 | x << 24);\n w = load(src + 15);\n store(dest + 12, x >> 8 | w << 24);\n src += 16; dest += 16; n -= 16;\n }\n break;\n }\n }\n }\n\n // copy remaining bytes one by one\n if (n & 16) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 8) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 4) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 2) {\n store(dest++, load(src++));\n store(dest++, load(src++));\n }\n if (n & 1) {\n store(dest++, load(src++));\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memmove(dest: usize, src: usize, n: usize): void { // see: musl/src/string/memmove.c\n if (dest === src) return;\n if (ASC_SHRINK_LEVEL < 1) {\n if (src + n <= dest || dest + n <= src) {\n memcpy(dest, src, n);\n return;\n }\n }\n if (dest < src) {\n if ((src & 7) == (dest & 7)) {\n while (dest & 7) {\n if (!n) return;\n --n;\n store(dest++, load(src++));\n }\n while (n >= 8) {\n store(dest, load(src));\n n -= 8;\n dest += 8;\n src += 8;\n }\n }\n while (n) {\n store(dest++, load(src++));\n --n;\n }\n } else {\n if ((src & 7) == (dest & 7)) {\n while ((dest + n) & 7) {\n if (!n) return;\n store(dest + --n, load(src + n));\n }\n while (n >= 8) {\n n -= 8;\n store(dest + n, load(src + n));\n }\n }\n while (n) {\n store(dest + --n, load(src + n));\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memset(dest: usize, c: u8, n: usize): void { // see: musl/src/string/memset\n if (ASC_SHRINK_LEVEL > 1) {\n while (n) {\n store(dest++, c);\n --n;\n }\n } else {\n // fill head and tail with minimal branching\n if (!n) return;\n store(dest, c);\n store(dest + n - 1, c);\n if (n <= 2) return;\n\n store(dest + 1, c);\n store(dest + 2, c);\n store(dest + n - 2, c);\n store(dest + n - 3, c);\n if (n <= 6) return;\n store(dest + 3, c);\n store(dest + n - 4, c);\n if (n <= 8) return;\n\n // advance pointer to align it at 4-byte boundary\n let k: usize = -dest & 3;\n dest += k;\n n -= k;\n n &= -4;\n\n let c32: u32 = -1 / 255 * c;\n\n // fill head/tail up to 28 bytes each in preparation\n store(dest, c32);\n store(dest + n - 4, c32);\n if (n <= 8) return;\n store(dest + 4, c32);\n store(dest + 8, c32);\n store(dest + n - 12, c32);\n store(dest + n - 8, c32);\n if (n <= 24) return;\n store(dest + 12, c32);\n store(dest + 16, c32);\n store(dest + 20, c32);\n store(dest + 24, c32);\n store(dest + n - 28, c32);\n store(dest + n - 24, c32);\n store(dest + n - 20, c32);\n store(dest + n - 16, c32);\n\n // align to a multiple of 8\n k = 24 + (dest & 4);\n dest += k;\n n -= k;\n\n // copy 32 bytes each\n let c64: u64 = c32 | (c32 << 32);\n while (n >= 32) {\n store(dest, c64);\n store(dest + 8, c64);\n store(dest + 16, c64);\n store(dest + 24, c64);\n n -= 32;\n dest += 32;\n }\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function memcmp(vl: usize, vr: usize, n: usize): i32 { // see: musl/src/string/memcmp.c\n if (vl == vr) return 0;\n while (n != 0 && load(vl) == load(vr)) {\n n--; vl++; vr++;\n }\n return n ? load(vl) - load(vr) : 0;\n}\n","util/number":'/// \n\nimport { idof } from "../builtins";\nimport { CharCode } from "./string";\nimport { ArrayBufferView } from "../arraybuffer";\n\n// @ts-ignore: decorator\n@inline\nexport const MAX_DOUBLE_LENGTH = 28;\n\n// @ts-ignore: decorator\n@lazy @inline\nconst POWERS10: u32[] = [\n 1,\n 10,\n 100,\n 1000,\n 10000,\n 100000,\n 1000000,\n 10000000,\n 100000000,\n 1000000000\n];\n\n/*\n Lookup table for pairwise char codes in range [0-99]\n\n "00", "01", "02", "03", "04", "05", "06", "07", "08", "09",\n "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",\n "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",\n "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",\n "40", "41", "42", "43", "44", "45", "46", "47", "48", "49",\n "50", "51", "52", "53", "54", "55", "56", "57", "58", "59",\n "60", "61", "62", "63", "64", "65", "66", "67", "68", "69",\n "70", "71", "72", "73", "74", "75", "76", "77", "78", "79",\n "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",\n "90", "91", "92", "93", "94", "95", "96", "97", "98", "99"\n*/\n// @ts-ignore: decorator\n@lazy @inline\nconst DIGITS: u32[] = [\n 0x00300030, 0x00310030, 0x00320030, 0x00330030, 0x00340030,\n 0x00350030, 0x00360030, 0x00370030, 0x00380030, 0x00390030,\n 0x00300031, 0x00310031, 0x00320031, 0x00330031, 0x00340031,\n 0x00350031, 0x00360031, 0x00370031, 0x00380031, 0x00390031,\n 0x00300032, 0x00310032, 0x00320032, 0x00330032, 0x00340032,\n 0x00350032, 0x00360032, 0x00370032, 0x00380032, 0x00390032,\n 0x00300033, 0x00310033, 0x00320033, 0x00330033, 0x00340033,\n 0x00350033, 0x00360033, 0x00370033, 0x00380033, 0x00390033,\n 0x00300034, 0x00310034, 0x00320034, 0x00330034, 0x00340034,\n 0x00350034, 0x00360034, 0x00370034, 0x00380034, 0x00390034,\n 0x00300035, 0x00310035, 0x00320035, 0x00330035, 0x00340035,\n 0x00350035, 0x00360035, 0x00370035, 0x00380035, 0x00390035,\n 0x00300036, 0x00310036, 0x00320036, 0x00330036, 0x00340036,\n 0x00350036, 0x00360036, 0x00370036, 0x00380036, 0x00390036,\n 0x00300037, 0x00310037, 0x00320037, 0x00330037, 0x00340037,\n 0x00350037, 0x00360037, 0x00370037, 0x00380037, 0x00390037,\n 0x00300038, 0x00310038, 0x00320038, 0x00330038, 0x00340038,\n 0x00350038, 0x00360038, 0x00370038, 0x00380038, 0x00390038,\n 0x00300039, 0x00310039, 0x00320039, 0x00330039, 0x00340039,\n 0x00350039, 0x00360039, 0x00370039, 0x00380039, 0x00390039\n];\n\n// @ts-ignore: decorator\n@lazy @inline\nconst EXP_POWERS: i16[] = [\n -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980,\n -954, -927, -901, -874, -847, -821, -794, -768, -741, -715,\n -688, -661, -635, -608, -582, -555, -529, -502, -475, -449,\n -422, -396, -369, -343, -316, -289, -263, -236, -210, -183,\n -157, -130, -103, -77, -50, -24, 3, 30, 56, 83,\n 109, 136, 162, 189, 216, 242, 269, 295, 322, 348,\n 375, 402, 428, 455, 481, 508, 534, 561, 588, 614,\n 641, 667, 694, 720, 747, 774, 800, 827, 853, 880,\n 907, 933, 960, 986, 1013, 1039, 1066\n];\n\n// 1e-348, 1e-340, ..., 1e340\n// @ts-ignore: decorator\n@lazy @inline\nconst FRC_POWERS: u64[] = [\n 0xFA8FD5A0081C0288, 0xBAAEE17FA23EBF76, 0x8B16FB203055AC76, 0xCF42894A5DCE35EA,\n 0x9A6BB0AA55653B2D, 0xE61ACF033D1A45DF, 0xAB70FE17C79AC6CA, 0xFF77B1FCBEBCDC4F,\n 0xBE5691EF416BD60C, 0x8DD01FAD907FFC3C, 0xD3515C2831559A83, 0x9D71AC8FADA6C9B5,\n 0xEA9C227723EE8BCB, 0xAECC49914078536D, 0x823C12795DB6CE57, 0xC21094364DFB5637,\n 0x9096EA6F3848984F, 0xD77485CB25823AC7, 0xA086CFCD97BF97F4, 0xEF340A98172AACE5,\n 0xB23867FB2A35B28E, 0x84C8D4DFD2C63F3B, 0xC5DD44271AD3CDBA, 0x936B9FCEBB25C996,\n 0xDBAC6C247D62A584, 0xA3AB66580D5FDAF6, 0xF3E2F893DEC3F126, 0xB5B5ADA8AAFF80B8,\n 0x87625F056C7C4A8B, 0xC9BCFF6034C13053, 0x964E858C91BA2655, 0xDFF9772470297EBD,\n 0xA6DFBD9FB8E5B88F, 0xF8A95FCF88747D94, 0xB94470938FA89BCF, 0x8A08F0F8BF0F156B,\n 0xCDB02555653131B6, 0x993FE2C6D07B7FAC, 0xE45C10C42A2B3B06, 0xAA242499697392D3,\n 0xFD87B5F28300CA0E, 0xBCE5086492111AEB, 0x8CBCCC096F5088CC, 0xD1B71758E219652C,\n 0x9C40000000000000, 0xE8D4A51000000000, 0xAD78EBC5AC620000, 0x813F3978F8940984,\n 0xC097CE7BC90715B3, 0x8F7E32CE7BEA5C70, 0xD5D238A4ABE98068, 0x9F4F2726179A2245,\n 0xED63A231D4C4FB27, 0xB0DE65388CC8ADA8, 0x83C7088E1AAB65DB, 0xC45D1DF942711D9A,\n 0x924D692CA61BE758, 0xDA01EE641A708DEA, 0xA26DA3999AEF774A, 0xF209787BB47D6B85,\n 0xB454E4A179DD1877, 0x865B86925B9BC5C2, 0xC83553C5C8965D3D, 0x952AB45CFA97A0B3,\n 0xDE469FBD99A05FE3, 0xA59BC234DB398C25, 0xF6C69A72A3989F5C, 0xB7DCBF5354E9BECE,\n 0x88FCF317F22241E2, 0xCC20CE9BD35C78A5, 0x98165AF37B2153DF, 0xE2A0B5DC971F303A,\n 0xA8D9D1535CE3B396, 0xFB9B7CD9A4A7443C, 0xBB764C4CA7A44410, 0x8BAB8EEFB6409C1A,\n 0xD01FEF10A657842C, 0x9B10A4E5E9913129, 0xE7109BFBA19C0C9D, 0xAC2820D9623BF429,\n 0x80444B5E7AA7CF85, 0xBF21E44003ACDD2D, 0x8E679C2F5E44FF8F, 0xD433179D9C8CB841,\n 0x9E19DB92B4E31BA9, 0xEB96BF6EBADF77D9, 0xAF87023B9BF0EE6B\n];\n\n// Count number of decimals for u32 values\n// In our case input value always non-zero so we can simplify some parts\nexport function decimalCount32(value: u32): u32 {\n if (value < 100000) {\n if (value < 100) {\n return select(1, 2, value < 10);\n } else {\n let m = select(4, 5, value < 10000);\n return select(3, m, value < 1000);\n }\n } else {\n if (value < 10000000) {\n return select(6, 7, value < 1000000);\n } else {\n let m = select(9, 10, value < 1000000000);\n return select(8, m, value < 100000000);\n }\n }\n}\n\n// Count number of decimals for u64 values\n// In our case input value always greater than 2^32-1 so we can skip some parts\nexport function decimalCount64(value: u64): u32 {\n if (value < 1000000000000000) {\n if (value < 1000000000000) {\n return select(11, 12, value < 100000000000);\n } else {\n let m = select(14, 15, value < 100000000000000);\n return select(13, m, value < 10000000000000);\n }\n } else {\n if (value < 100000000000000000) {\n return select(16, 17, value < 10000000000000000);\n } else {\n let m = select(19, 20, value < 10000000000000000000);\n return select(18, m, value < 1000000000000000000);\n }\n }\n}\n\nfunction utoa32_lut(buffer: usize, num: u32, offset: usize): void {\n var lut = changetype(DIGITS).dataStart;\n while (num >= 10000) {\n // in most VMs i32/u32 div and modulo by constant can be shared and simplificate\n let t = num / 10000;\n let r = num % 10000;\n num = t;\n\n let d1 = r / 100;\n let d2 = r % 100;\n\n let digits1 = load(lut + (d1 << alignof()));\n let digits2 = load(lut + (d2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n }\n\n if (num >= 100) {\n let t = num / 100;\n let d1 = num % 100;\n num = t;\n offset -= 2;\n let digits = load(lut + (d1 << alignof()));\n store(buffer + (offset << 1), digits);\n }\n\n if (num >= 10) {\n offset -= 2;\n let digits = load(lut + (num << alignof()));\n store(buffer + (offset << 1), digits);\n } else {\n offset -= 1;\n let digit = CharCode._0 + num;\n store(buffer + (offset << 1), digit);\n }\n}\n\nfunction utoa64_lut(buffer: usize, num: u64, offset: usize): void {\n var lut = changetype(DIGITS).dataStart;\n while (num >= 100000000) {\n let t = num / 100000000;\n let r = (num - t * 100000000);\n num = t;\n\n let b = r / 10000;\n let c = r % 10000;\n\n let b1 = b / 100;\n let b2 = b % 100;\n let c1 = c / 100;\n let c2 = c % 100;\n\n let digits1 = load(lut + (c1 << alignof()));\n let digits2 = load(lut + (c2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n\n digits1 = load(lut + (b1 << alignof()));\n digits2 = load(lut + (b2 << alignof()));\n\n offset -= 4;\n store(buffer + (offset << 1), digits1 | (digits2 << 32));\n }\n\n utoa32_lut(buffer, num, offset);\n}\n\nfunction utoa_simple(buffer: usize, num: T, offset: usize): void {\n do {\n let t = num / 10;\n let r = (num % 10);\n num = changetype(t);\n offset -= 1;\n store(buffer + (offset << 1), CharCode._0 + r);\n } while (num);\n}\n\n// @ts-ignore: decorator\n@inline\nexport function utoa32_core(buffer: usize, num: u32, offset: u32): void {\n if (ASC_SHRINK_LEVEL >= 1) {\n utoa_simple(buffer, num, offset);\n } else {\n utoa32_lut(buffer, num, offset);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function utoa64_core(buffer: usize, num: u64, offset: u32): void {\n if (ASC_SHRINK_LEVEL >= 1) {\n utoa_simple(buffer, num, offset);\n } else {\n utoa64_lut(buffer, num, offset);\n }\n}\n\nexport function utoa32(value: u32): String {\n if (!value) return "0";\n\n var decimals = decimalCount32(value);\n var out = __alloc(decimals << 1, idof());\n\n utoa32_core(out, value, decimals);\n return changetype(out); // retains\n}\n\nexport function itoa32(value: i32): String {\n if (!value) return "0";\n\n var sign = value < 0;\n if (sign) value = -value;\n\n var decimals = decimalCount32(value) + u32(sign);\n var out = __alloc(decimals << 1, idof());\n\n utoa32_core(out, value, decimals);\n if (sign) store(out, CharCode.MINUS);\n return changetype(out); // retains\n}\n\nexport function utoa64(value: u64): String {\n if (!value) return "0";\n\n var out: usize;\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n let decimals = decimalCount32(val32);\n out = __alloc(decimals << 1, idof());\n utoa32_core(out, val32, decimals);\n } else {\n let decimals = decimalCount64(value);\n out = __alloc(decimals << 1, idof());\n utoa64_core(out, value, decimals);\n }\n return changetype(out); // retains\n}\n\nexport function itoa64(value: i64): String {\n if (!value) return "0";\n\n var sign = value < 0;\n if (sign) value = -value;\n\n var out: usize;\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n let decimals = decimalCount32(val32) + u32(sign);\n out = __alloc(decimals << 1, idof());\n utoa32_core(out, val32, decimals);\n } else {\n let decimals = decimalCount64(value) + u32(sign);\n out = __alloc(decimals << 1, idof());\n utoa64_core(out, value, decimals);\n }\n if (sign) store(out, CharCode.MINUS);\n\n return changetype(out); // retains\n}\n\nexport function itoa(value: T): String {\n if (!isInteger()) ERROR("integer type expected");\n if (isSigned()) {\n if (sizeof() <= 4) {\n return itoa32(value);\n } else {\n return itoa64(value);\n }\n } else {\n if (sizeof() <= 4) {\n return utoa32(value);\n } else {\n return utoa64(value);\n }\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar _K: i32 = 0;\n\n// // @ts-ignore: decorator\n// @lazy\n// var _frc: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _exp: i32 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_minus: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_plus: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _frc_pow: u64 = 0;\n\n// @ts-ignore: decorator\n@lazy\nvar _exp_pow: i32 = 0;\n\n// @ts-ignore: decorator\n@inline\nfunction umul64f(u: u64, v: u64): u64 {\n var u0 = u & 0xFFFFFFFF;\n var v0 = v & 0xFFFFFFFF;\n\n var u1 = u >> 32;\n var v1 = v >> 32;\n\n var l = u0 * v0;\n var t = u1 * v0 + (l >> 32);\n var w = u0 * v1 + (t & 0xFFFFFFFF);\n\n w += 0x7FFFFFFF; // rounding\n\n t >>= 32;\n w >>= 32;\n\n return u1 * v1 + t + w;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction umul64e(e1: i32, e2: i32): i32 {\n return e1 + e2 + 64; // where 64 is significand size\n}\n\n// @ts-ignore: decorator\n@inline\nfunction normalizedBoundaries(f: u64, e: i32): void {\n var frc = (f << 1) + 1;\n var exp = e - 1;\n var off = clz(frc);\n frc <<= off;\n exp -= off;\n\n var m = 1 + i32(f == 0x0010000000000000);\n\n _frc_plus = frc;\n _frc_minus = ((f << m) - 1) << e - m - exp;\n _exp = exp;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction grisuRound(buffer: usize, len: i32, delta: u64, rest: u64, ten_kappa: u64, wp_w: u64): void {\n var lastp = buffer + ((len - 1) << 1);\n var digit = load(lastp);\n while (\n rest < wp_w &&\n delta - rest >= ten_kappa && (\n rest + ten_kappa < wp_w ||\n wp_w - rest > rest + ten_kappa - wp_w\n )\n ) {\n --digit;\n rest += ten_kappa;\n }\n store(lastp, digit);\n}\n\n// @ts-ignore: decorator\n@inline\nfunction getCachedPower(minExp: i32): void {\n const c = reinterpret(0x3FD34413509F79FE); // 1 / lg(10) = 0.30102999566398114\n var dk = (-61 - minExp) * c + 347;\t // dk must be positive, so can do ceiling in positive\n var k = dk;\n k += i32(k != dk); // conversion with ceil\n\n var index = (k >> 3) + 1;\n _K = 348 - (index << 3);\t// decimal exponent no need lookup table\n _frc_pow = unchecked(FRC_POWERS[index]);\n _exp_pow = unchecked(EXP_POWERS[index]);\n}\n\n// @ts-ignore: decorator\n@inline\nfunction grisu2(value: f64, buffer: usize, sign: i32): i32 {\n\n // frexp routine\n var uv = reinterpret(value);\n var exp = ((uv & 0x7FF0000000000000) >>> 52);\n var sid = uv & 0x000FFFFFFFFFFFFF;\n var frc = (u64(exp != 0) << 52) + sid;\n exp = select(exp, 1, exp != 0) - (0x3FF + 52);\n\n normalizedBoundaries(frc, exp);\n getCachedPower(_exp);\n\n // normalize\n var off = clz(frc);\n frc <<= off;\n exp -= off;\n\n var frc_pow = _frc_pow;\n var exp_pow = _exp_pow;\n\n var w_frc = umul64f(frc, frc_pow);\n var w_exp = umul64e(exp, exp_pow);\n\n var wp_frc = umul64f(_frc_plus, frc_pow) - 1;\n var wp_exp = umul64e(_exp, exp_pow);\n\n var wm_frc = umul64f(_frc_minus, frc_pow) + 1;\n var delta = wp_frc - wm_frc;\n\n return genDigits(buffer, w_frc, w_exp, wp_frc, wp_exp, delta, sign);\n}\n\nfunction genDigits(buffer: usize, w_frc: u64, w_exp: i32, mp_frc: u64, mp_exp: i32, delta: u64, sign: i32): i32 {\n var one_exp = -mp_exp;\n var one_frc = (1) << one_exp;\n var mask = one_frc - 1;\n\n var wp_w_frc = mp_frc - w_frc;\n var wp_w_exp = mp_exp;\n\n var p1 = (mp_frc >> one_exp);\n var p2 = mp_frc & mask;\n\n var kappa = decimalCount32(p1);\n var len = sign;\n\n var lut = changetype(POWERS10).dataStart;\n\n while (kappa > 0) {\n let d: u32;\n switch (kappa) {\n case 10: { d = p1 / 1000000000; p1 %= 1000000000; break; }\n case 9: { d = p1 / 100000000; p1 %= 100000000; break; }\n case 8: { d = p1 / 10000000; p1 %= 10000000; break; }\n case 7: { d = p1 / 1000000; p1 %= 1000000; break; }\n case 6: { d = p1 / 100000; p1 %= 100000; break; }\n case 5: { d = p1 / 10000; p1 %= 10000; break; }\n case 4: { d = p1 / 1000; p1 %= 1000; break; }\n case 3: { d = p1 / 100; p1 %= 100; break; }\n case 2: { d = p1 / 10; p1 %= 10; break; }\n case 1: { d = p1; p1 = 0; break; }\n default: { d = 0; break; }\n }\n\n if (d | len) store(buffer + (len++ << 1), CharCode._0 + d);\n\n --kappa;\n let tmp = ((p1) << one_exp) + p2;\n if (tmp <= delta) {\n _K += kappa;\n grisuRound(buffer, len, delta, tmp, load(lut + (kappa << alignof())) << one_exp, wp_w_frc);\n return len;\n }\n }\n\n while (1) {\n p2 *= 10;\n delta *= 10;\n\n let d = p2 >> one_exp;\n if (d | len) store(buffer + (len++ << 1), CharCode._0 + d);\n\n p2 &= mask;\n --kappa;\n if (p2 < delta) {\n _K += kappa;\n wp_w_frc *= load(lut + (-kappa << alignof()));\n grisuRound(buffer, len, delta, p2, one_frc, wp_w_frc);\n return len;\n }\n }\n\n return len;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction genExponent(buffer: usize, k: i32): i32 {\n var sign = k < 0;\n if (sign) k = -k;\n var decimals = decimalCount32(k) + 1;\n utoa32_core(buffer, k, decimals);\n store(buffer, select(CharCode.MINUS, CharCode.PLUS, sign));\n return decimals;\n}\n\nfunction prettify(buffer: usize, length: i32, k: i32): i32 {\n if (!k) {\n store(buffer + (length << 1), CharCode.DOT | (CharCode._0 << 16));\n return length + 2;\n }\n\n var kk = length + k;\n if (length <= kk && kk <= 21) {\n // 1234e7 -> 12340000000\n for (let i = length; i < kk; ++i) {\n store(buffer + (i << 1), CharCode._0);\n }\n store(buffer + (kk << 1), CharCode.DOT | (CharCode._0 << 16));\n return kk + 2;\n } else if (kk > 0 && kk <= 21) {\n // 1234e-2 -> 12.34\n let ptr = buffer + (kk << 1);\n memory.copy(\n ptr + 2,\n ptr,\n -k << 1\n );\n store(buffer + (kk << 1), CharCode.DOT);\n return length + 1;\n } else if (-6 < kk && kk <= 0) {\n // 1234e-6 -> 0.001234\n let offset = 2 - kk;\n memory.copy(\n buffer + (offset << 1),\n buffer,\n length << 1\n );\n store(buffer, CharCode._0 | (CharCode.DOT << 16));\n for (let i = 2; i < offset; ++i) {\n store(buffer + (i << 1), CharCode._0);\n }\n return length + offset;\n } else if (length == 1) {\n // 1e30\n store(buffer, CharCode.e, 2);\n length = genExponent(buffer + 4, kk - 1);\n return length + 2;\n } else {\n let len = length << 1;\n memory.copy(\n buffer + 4,\n buffer + 2,\n len - 2\n );\n store(buffer, CharCode.DOT, 2);\n store(buffer + len, CharCode.e, 2);\n length += genExponent(buffer + len + 4, kk - 1);\n return length + 2;\n }\n}\n\nexport function dtoa_core(buffer: usize, value: f64): i32 {\n var sign = i32(value < 0);\n if (sign) {\n value = -value;\n store(buffer, CharCode.MINUS);\n }\n // assert(value > 0 && value <= 1.7976931348623157e308);\n var len = grisu2(value, buffer, sign);\n len = prettify(buffer + (sign << 1), len - sign, _K);\n return len + sign;\n}\n\nexport function dtoa(value: f64): String {\n if (value == 0) return "0.0";\n if (!isFinite(value)) {\n if (isNaN(value)) return "NaN";\n return select("-Infinity", "Infinity", value < 0);\n }\n var buffer = __alloc(MAX_DOUBLE_LENGTH << 1, idof());\n var length = dtoa_core(buffer, value);\n if (length == MAX_DOUBLE_LENGTH) return changetype(buffer);\n var result = changetype(buffer).substring(0, length);\n __free(buffer);\n return result;\n}\n\nexport function itoa_stream(buffer: usize, offset: usize, value: T): u32 {\n buffer += (offset << 1);\n if (!value) {\n store(buffer, CharCode._0);\n return 1;\n }\n var decimals: u32 = 0;\n if (isSigned()) {\n let sign = i32(value < 0);\n if (sign) value = changetype(-value);\n if (sizeof() <= 4) {\n decimals = decimalCount32(value) + sign;\n utoa32_core(buffer, value, decimals);\n } else {\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n decimals = decimalCount32(val32) + sign;\n utoa32_core(buffer, val32, decimals);\n } else {\n decimals = decimalCount64(value) + sign;\n utoa64_core(buffer, value, decimals);\n }\n }\n if (sign) store(buffer, CharCode.MINUS);\n } else {\n if (sizeof() <= 4) {\n decimals = decimalCount32(value);\n utoa32_core(buffer, value, decimals);\n } else {\n if (value <= u32.MAX_VALUE) {\n let val32 = value;\n decimals = decimalCount32(val32);\n utoa32_core(buffer, val32, decimals);\n } else {\n decimals = decimalCount64(value);\n utoa64_core(buffer, value, decimals);\n }\n }\n }\n return decimals;\n}\n\nexport function dtoa_stream(buffer: usize, offset: usize, value: f64): u32 {\n buffer += (offset << 1);\n if (value == 0.0) {\n store(buffer, CharCode._0);\n store(buffer, CharCode.DOT, 2);\n store(buffer, CharCode._0, 4);\n return 3;\n }\n if (!isFinite(value)) {\n if (isNaN(value)) {\n store(buffer, CharCode.N);\n store(buffer, CharCode.a, 2);\n store(buffer, CharCode.N, 4);\n return 3;\n } else {\n let sign = i32(value < 0);\n let len = 8 + sign;\n memory.copy(buffer, changetype(select("-Infinity", "Infinity", sign)), len << 1);\n return len;\n }\n }\n return dtoa_core(buffer, value);\n}\n',"util/sort":'import { compareImpl } from "./string";\n\n// @ts-ignore: decorator\n@inline\nexport function COMPARATOR(): (a: T, b: T) => i32 {\n if (isInteger()) {\n if (isSigned() && sizeof() <= 4) {\n return (a: T, b: T): i32 => (i32(a) - i32(b));\n } else {\n return (a: T, b: T): i32 => (i32(a > b) - i32(a < b));\n }\n } else if (isFloat()) {\n if (sizeof() == 4) {\n return (a: T, b: T): i32 => {\n var ia = reinterpret(f32(a));\n var ib = reinterpret(f32(b));\n ia ^= (ia >> 31) >>> 1;\n ib ^= (ib >> 31) >>> 1;\n return i32(ia > ib) - i32(ia < ib);\n };\n } else {\n return (a: T, b: T): i32 => {\n var ia = reinterpret(f64(a));\n var ib = reinterpret(f64(b));\n ia ^= (ia >> 63) >>> 1;\n ib ^= (ib >> 63) >>> 1;\n return i32(ia > ib) - i32(ia < ib);\n };\n }\n } else if (isString()) {\n return (a: T, b: T): i32 => {\n if (a === b || a === null || b === null) return 0;\n var alen = changetype(a).length;\n var blen = changetype(b).length;\n if (!alen && !blen) return 0;\n if (!alen) return -1;\n if (!blen) return 1;\n return compareImpl(changetype(a), 0, changetype(b), 0, min(alen, blen));\n };\n } else {\n return (a: T, b: T): i32 => (i32(a > b) - i32(a < b));\n }\n}\n\n// @ts-ignore: decorator\n@inline\nexport function SORT(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n if (isReference()) {\n // TODO replace this to faster stable sort (TimSort) when it implemented\n insertionSort(dataStart, length, comparator);\n } else {\n if (length < 256) {\n insertionSort(dataStart, length, comparator);\n } else {\n weakHeapSort(dataStart, length, comparator);\n }\n }\n}\n\nfunction insertionSort(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n for (let i = 0; i < length; i++) {\n let a: T = load(dataStart + (i << alignof())); // a = arr[i]\n let j = i - 1;\n while (j >= 0) {\n let b: T = load(dataStart + (j << alignof())); // b = arr[j]\n if (comparator(a, b) < 0) {\n store(dataStart + ((j-- + 1) << alignof()), b); // arr[j + 1] = b\n } else break;\n }\n store(dataStart + ((j + 1) << alignof()), a); // arr[j + 1] = a\n }\n}\n\nfunction weakHeapSort(\n dataStart: usize,\n length: i32,\n comparator: (a: T, b: T) => i32\n): void {\n const shift32 = alignof();\n\n var bitsetSize = (length + 31) >> 5 << shift32;\n var bitset = __alloc(bitsetSize, 0); // indexed in 32-bit chunks below\n memory.fill(bitset, 0, bitsetSize);\n\n // see: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf\n\n for (let i = length - 1; i > 0; i--) {\n let j = i;\n while ((j & 1) == (load(bitset + (j >> 6 << shift32)) >> (j >> 1 & 31) & 1)) j >>= 1;\n\n let p = j >> 1;\n let a: T = load(dataStart + (p << alignof())); // a = arr[p]\n let b: T = load(dataStart + (i << alignof())); // b = arr[i]\n if (comparator(a, b) < 0) {\n store(\n bitset + (i >> 5 << shift32),\n load(bitset + (i >> 5 << shift32)) ^ (1 << (i & 31))\n );\n store(dataStart + (i << alignof()), a); // arr[i] = a\n store(dataStart + (p << alignof()), b); // arr[p] = b\n }\n }\n\n for (let i = length - 1; i >= 2; i--) {\n let a: T = load(dataStart); // a = arr[0]\n store(dataStart, load(dataStart + (i << alignof()))); // arr[0] = arr[i]\n store(dataStart + (i << alignof()), a); // arr[i] = a\n\n let x = 1, y: i32;\n while ((y = (x << 1) + ((load(bitset + (x >> 5 << shift32)) >> (x & 31)) & 1)) < i) x = y;\n\n while (x > 0) {\n a = load(dataStart); // a = arr[0]\n let b: T = load(dataStart + (x << alignof())); // b = arr[x]\n\n if (comparator(a, b) < 0) {\n store(\n bitset + (x >> 5 << shift32),\n load(bitset + (x >> 5 << shift32)) ^ (1 << (x & 31))\n );\n store(dataStart + (x << alignof()), a); // arr[x] = a\n store(dataStart, b); // arr[0] = b\n }\n x >>= 1;\n }\n }\n\n __free(bitset);\n\n var t: T = load(dataStart, sizeof()); // t = arr[1]\n store(dataStart, load(dataStart), sizeof()); // arr[1] = arr[0]\n store(dataStart, t); // arr[0] = t\n}\n',"util/string":"export function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 {\n var result: i32 = 0;\n var ptr1 = changetype(str1) + (index1 << 1);\n var ptr2 = changetype(str2) + (index2 << 1);\n while (len && !(result = load(ptr1) - load(ptr2))) {\n --len, ptr1 += 2, ptr2 += 2;\n }\n return result;\n}\n\n// @ts-ignore: decorator\n@inline\nexport const enum CharCode {\n PLUS = 0x2B,\n MINUS = 0x2D,\n DOT = 0x2E,\n _0 = 0x30,\n _1 = 0x31,\n _2 = 0x32,\n _3 = 0x33,\n _4 = 0x34,\n _5 = 0x35,\n _6 = 0x36,\n _7 = 0x37,\n _8 = 0x38,\n _9 = 0x39,\n A = 0x41,\n B = 0x42,\n E = 0x45,\n N = 0x4E,\n O = 0x4F,\n X = 0x58,\n Z = 0x5a,\n a = 0x61,\n b = 0x62,\n e = 0x65,\n n = 0x6E,\n o = 0x6F,\n x = 0x78,\n z = 0x7A\n}\n\nexport function isWhiteSpaceOrLineTerminator(c: u16): bool {\n switch (c) {\n case 9: // \n case 10: // \n case 13: // \n case 11: // \n case 12: // \n case 32: // \n case 160: // \n case 8232: // \n case 8233: // \n case 65279: return true; // \n default: return false;\n }\n}\n\n/** Parses a string to an integer (usually), using the specified radix. */\nexport function parse(str: string, radix: i32 = 0): T {\n var len: i32 = str.length;\n // @ts-ignore: cast\n if (!len) return NaN;\n\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr);\n\n // determine sign\n var sign: T;\n if (code == CharCode.MINUS) {\n // @ts-ignore: cast\n if (!--len) return NaN;\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = -1;\n } else if (code == CharCode.PLUS) {\n // @ts-ignore: cast\n if (!--len) return NaN;\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = 1;\n } else {\n // @ts-ignore: type\n sign = 1;\n }\n\n // determine radix\n if (!radix) {\n if (code == CharCode._0 && len > 2) {\n switch (load(ptr + 2)) {\n case CharCode.B:\n case CharCode.b: {\n ptr += 4; len -= 2;\n radix = 2;\n break;\n }\n case CharCode.O:\n case CharCode.o: {\n ptr += 4; len -= 2;\n radix = 8;\n break;\n }\n case CharCode.X:\n case CharCode.x: {\n ptr += 4; len -= 2;\n radix = 16;\n break;\n }\n default: radix = 10;\n }\n } else radix = 10;\n } else if (radix < 2 || radix > 36) {\n // @ts-ignore: cast\n return NaN;\n }\n\n // calculate value\n // @ts-ignore: type\n var num: T = 0;\n while (len--) {\n code = load(ptr);\n if (code >= CharCode._0 && code <= CharCode._9) {\n code -= CharCode._0;\n } else if (code >= CharCode.A && code <= CharCode.Z) {\n code -= CharCode.A - 10;\n } else if (code >= CharCode.a && code <= CharCode.z) {\n code -= CharCode.a - 10;\n } else break;\n if (code >= radix) break;\n // @ts-ignore: type\n num = (num * radix) + code;\n ptr += 2;\n }\n // @ts-ignore: type\n return sign * num;\n}\n",vector:"/** Vector abstraction. */\n@sealed export class V128 {\n}\n"}):(()=>{const n=path.join(".","..","std","assembly"),e=__webpack_require__(!function(){var n=new Error("Cannot find module 'glob'");throw n.code="MODULE_NOT_FOUND",n}()).sync("**/!(*.d).ts",{cwd:n}),t={};return e.forEach(e=>t[e.replace(/\.ts$/,"")]=fs.readFileSync(path.join(n,e),"utf8")),t})(),exports.definitionFiles=exports.isBundle?Object({assembly:'/**\n * Environment definitions for compiling AssemblyScript to WebAssembly using asc.\n * @module std/assembly\n *//***/\n\n/// \n\n// Types\n\n/** An 8-bit signed integer. */\ndeclare type i8 = number;\n/** A 16-bit signed integer. */\ndeclare type i16 = number;\n/** A 32-bit signed integer. */\ndeclare type i32 = number;\n/** A 64-bit signed integer. */\ndeclare type i64 = number;\n/** A 32-bit signed integer when targeting 32-bit WebAssembly or a 64-bit signed integer when targeting 64-bit WebAssembly. */\ndeclare type isize = number;\n/** An 8-bit unsigned integer. */\ndeclare type u8 = number;\n/** A 16-bit unsigned integer. */\ndeclare type u16 = number;\n/** A 32-bit unsigned integer. */\ndeclare type u32 = number;\n/** A 64-bit unsigned integer. */\ndeclare type u64 = number;\n/** A 32-bit unsigned integer when targeting 32-bit WebAssembly or a 64-bit unsigned integer when targeting 64-bit WebAssembly. */\ndeclare type usize = number;\n/** A 1-bit unsigned integer. */\ndeclare type bool = boolean | number;\n/** A 32-bit float. */\ndeclare type f32 = number;\n/** A 64-bit float. */\ndeclare type f64 = number;\n/** A 128-bit vector. */\ndeclare type v128 = object;\n\n// Compiler hints\n\n/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */\ndeclare const ASC_TARGET: i32;\n/** Provided noAssert option. */\ndeclare const ASC_NO_ASSERT: bool;\n/** Provided memoryBase option. */\ndeclare const ASC_MEMORY_BASE: i32;\n/** Provided optimizeLevel option. */\ndeclare const ASC_OPTIMIZE_LEVEL: i32;\n/** Provided shrinkLevel option. */\ndeclare const ASC_SHRINK_LEVEL: i32;\n/** Whether the mutable global feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBAL: bool;\n/** Whether the sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n/** Whether the bulk memory feature is enabled. */\ndeclare const ASC_FEATURE_BULK_MEMORY: bool;\n/** Whether the SIMD feature is enabled. */\ndeclare const ASC_FEATURE_SIMD: bool;\n/** Whether the threads feature is enabled. */\ndeclare const ASC_FEATURE_THREADS: bool;\n\n// Builtins\n\n/** Performs the sign-agnostic count leading zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered leading if the value is zero. */\ndeclare function clz(value: T): T;\n/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit or 64-bit integer. All zero bits are considered trailing if the value is zero. */\ndeclare function ctz(value: T): T;\n/** Performs the sign-agnostic count number of one bits operation on a 32-bit or 64-bit integer. */\ndeclare function popcnt(value: T): T;\n/** Performs the sign-agnostic rotate left operation on a 32-bit or 64-bit integer. */\ndeclare function rotl(value: T, shift: T): T;\n/** Performs the sign-agnostic rotate right operation on a 32-bit or 64-bit integer. */\ndeclare function rotr(value: T, shift: T): T;\n/** Computes the absolute value of an integer or float. */\ndeclare function abs(value: T): T;\n/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function max(left: T, right: T): T;\n/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function min(left: T, right: T): T;\n/** Performs the ceiling operation on a 32-bit or 64-bit float. */\ndeclare function ceil(value: T): T;\n/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */\ndeclare function copysign(x: T, y: T): T;\n/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(value: T): T;\n/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */\ndeclare function nearest(value: T): T;\n/** Reinterprets the bits of the specified value as type `T`. Valid reinterpretations are u32/i32 to/from f32 and u64/i64 to/from f64. */\ndeclare function reinterpret(value: number): T;\n/** Selects one of two pre-evaluated values depending on the condition. */\ndeclare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n/** Calculates the square root of a 32-bit or 64-bit float. */\ndeclare function sqrt(value: T): T;\n/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */\ndeclare function trunc(value: T): T;\n/** Loads a value of the specified type from memory. Equivalent to dereferncing a pointer in other languages. */\ndeclare function load(ptr: usize, immOffset?: usize, immAlign?: usize): T;\n/** Stores a value of the specified type to memory. Equivalent to dereferencing a pointer in other languages when assigning a value. */\ndeclare function store(ptr: usize, value: any, immOffset?: usize, immAlign?: usize): void;\n/** Emits an unreachable operation that results in a runtime error when executed. Both a statement and an expression of any type. */\ndeclare function unreachable(): any; // sic\n\n/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */\ndeclare const NaN: f32 | f64;\n/** Positive infinity as a 32-bit or 64-bit float depending on context. */\ndeclare const Infinity: f32 | f64;\n/** Heap base offset. */\ndeclare const HEAP_BASE: usize;\n/** Determines the byte size of the specified underlying core type. Compiles to a constant. */\ndeclare function sizeof(): usize;\n/** Determines the alignment (log2) of the specified underlying core type. Compiles to a constant. */\ndeclare function alignof(): usize;\n/** Determines the offset of the specified field within the given class type. Returns the class type\'s end offset if field name has been omitted. Compiles to a constant. */\ndeclare function offsetof(fieldName?: string): usize;\n/** Determines the unique runtime id of a class type. Compiles to a constant. */\ndeclare function idof(): u32;\n/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/\ndeclare function changetype(value: any): T;\n/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */\ndeclare function unchecked(value: T): T;\n/** Emits a `call_indirect` instruction, calling the specified function in the function table by index with the specified arguments. Does result in a runtime error if the arguments do not match the called function. */\ndeclare function call_indirect(target: Function | u32, ...args: any[]): T;\n/** Emits a `call` instruction, calling the specified function in the function table directly with the specified arguments. Function index must be a compile-time constant. */\ndeclare function call_direct(target: Function | u32, ...args: any[]): T;\n/** Instantiates a new instance of `T` using the specified constructor arguments. */\ndeclare function instantiate(...args: any[]): T;\n/** Tests if a 32-bit or 64-bit float is `NaN`. */\ndeclare function isNaN(value: T): bool;\n/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */\ndeclare function isFinite(value: T): bool;\n/** Tests if the specified type *or* expression is of an integer type and not a reference. Compiles to a constant. */\ndeclare function isInteger(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a float type. Compiles to a constant. */\ndeclare function isFloat(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a boolean type. */\ndeclare function isBoolean(value?: any): value is number;\n/** Tests if the specified type *or* expression can represent negative numbers. Compiles to a constant. */\ndeclare function isSigned(value?: any): value is number;\n/** Tests if the specified type *or* expression is of a reference type. Compiles to a constant. */\ndeclare function isReference(value?: any): value is object | string;\n/** Tests if the specified type *or* expression can be used as a string. Compiles to a constant. */\ndeclare function isString(value?: any): value is string | String;\n/** Tests if the specified type *or* expression can be used as an array. Compiles to a constant. */\ndeclare function isArray(value?: any): value is Array;\n/** Tests if the specified type *or* expression can be used as an array like object. Compiles to a constant. */\ndeclare function isArrayLike(value?: any): value is ArrayLike;\n/** Tests if the specified type *or* expression is of a function type. Compiles to a constant. */\ndeclare function isFunction(value?: any): value is (...args: any) => any;\n/** Tests if the specified type *or* expression is of a nullable reference type. Compiles to a constant. */\ndeclare function isNullable(value?: any): bool;\n/** Tests if the specified expression resolves to a defined element. Compiles to a constant. */\ndeclare function isDefined(expression: any): bool;\n/** Tests if the specified expression evaluates to a constant value. Compiles to a constant. */\ndeclare function isConstant(expression: any): bool;\n/** Tests if the specified type *or* expression is of a managed type. Compiles to a constant. */\ndeclare function isManaged(value?: any): bool;\n/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */\ndeclare function assert(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses an integer string to a 64-bit integer. */\ndeclare function parseI64(str: string, radix?: i32): i64;\n/** Parses a string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n/** Returns the 64-bit floating-point remainder of `x/y`. */\ndeclare function fmod(x: f64, y: f64): f64;\n/** Returns the 32-bit floating-point remainder of `x/y`. */\ndeclare function fmodf(x: f32, y: f32): f32;\n\n/** Atomic operations. */\ndeclare namespace atomic {\n /** Atomically loads an integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): T;\n /** Atomically stores an integer value to memory. */\n export function store(offset: usize, value: T, immOffset?: usize): void;\n /** Atomically adds an integer value in memory. */\n export function add(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically subtracts an integer value in memory. */\n export function sub(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise AND operation on an integer value in memory. */\n export function and(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise OR operation on an integer value in memory. */\n export function or(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically performs a bitwise XOR operation on an integer value in memory. */\n export function xor(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically exchanges an integer value in memory. */\n export function xchg(ptr: usize, value: T, immOffset?: usize): T;\n /** Atomically compares and exchanges an integer value in memory if the condition is met. */\n export function cmpxchg(ptr: usize, expected: T, replacement: T, immOffset?: usize): T;\n /** Performs a wait operation on an address in memory suspending this agent if the integer condition is met. */\n export function wait(ptr: usize, expected: T, timeout: i64): AtomicWaitResult;\n /** Performs a notify operation on an address in memory waking up suspended agents. */\n export function notify(ptr: usize, count: i32): i32;\n}\n\n/** Describes the result of an atomic wait operation. */\ndeclare enum AtomicWaitResult {\n /** Woken by another agent. */\n OK,\n /** Loaded value did not match the expected value. */\n NOT_EQUAL,\n /** Not woken before the timeout expired. */\n TIMED_OUT\n}\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: any): i8;\ndeclare namespace i8 {\n /** Smallest representable value. */\n export const MIN_VALUE: i8;\n /** Largest representable value. */\n export const MAX_VALUE: i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: any): i8;\ndeclare namespace i16 {\n /** Smallest representable value. */\n export const MIN_VALUE: i16;\n /** Largest representable value. */\n export const MAX_VALUE: i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: any): i32;\ndeclare namespace i32 {\n /** Smallest representable value. */\n export const MIN_VALUE: i32;\n /** Largest representable value. */\n export const MAX_VALUE: i32;\n /** Loads an 8-bit signed integer value from memory and returns it as a 32-bit integer. */\n export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 16-bit signed integer value from memory and returns it as a 32-bit integer. */\n export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 32-bit integer value from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory. */\n export function store(offset: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Atomic 32-bit integer operations. */\n export namespace atomic {\n /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize): i32;\n /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 32-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize): i32;\n /** Atomically loads a 32-bit integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): i32;\n /** Atomically stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory. */\n export function store(offset: usize, value: i32, immOffset?: usize): void;\n /** Performs a wait operation on a 32-bit integer value in memory suspending this agent if the condition is met. */\n export function wait(ptr: usize, expected: i32, timeout: i64): AtomicWaitResult;\n /** Atomic 32-bit integer read-modify-write operations on 8-bit values. */\n export namespace rmw8 {\n /** Atomically adds an 8-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation an 8-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation an 8-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation an 8-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n /** Atomic 32-bit integer read-modify-write operations on 16-bit values. */\n export namespace rmw16 {\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 16-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 16-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 16-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n /** Atomic 32-bit integer read-modify-write operations. */\n export namespace rmw {\n /** Atomically adds a 32-bit integer value in memory. */\n export function add(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts a 32-bit integer value in memory. */\n export function sub(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 32-bit integer value in memory. */\n export function and(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 32-bit integer value in memory. */\n export function or(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 32-bit integer value in memory. */\n export function xor(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 32-bit integer value in memory. */\n export function xchg(offset: usize, value: i32, immOffset?: usize): i32;\n /** Atomically compares and exchanges a 32-bit integer value in memory if the condition is met. */\n export function cmpxchg(offset: usize, expected: i32, replacement: i32, immOffset?: usize): i32;\n }\n }\n}\n/** Converts any other numeric value to a 64-bit signed integer. */\ndeclare function i64(value: any): i64;\ndeclare namespace i64 {\n /** Smallest representable value. */\n export const MIN_VALUE: i64;\n /** Largest representable value. */\n export const MAX_VALUE: i64;\n /** Loads an 8-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load8_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 16-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load16_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 32-bit signed integer value from memory and returns it as a 64-bit integer. */\n export function load32_s(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load32_u(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 64-bit unsigned integer value from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory as a 32-bit integer. */\n export function store32(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory. */\n export function store(offset: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Atomic 64-bit integer operations. */\n export namespace atomic {\n /** Atomically loads an 8-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load8_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 16-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load16_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 32-bit unsigned integer value from memory and returns it as a 64-bit integer. */\n export function load32_u(offset: usize, immOffset?: usize): i64;\n /** Atomically loads a 64-bit integer value from memory and returns it. */\n export function load(offset: usize, immOffset?: usize): i64;\n /** Atomically stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory as a 16-bit integer. */\n export function store16(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory as a 32-bit integer. */\n export function store32(offset: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory. */\n export function store(offset: usize, value: i64, immOffset?: usize): void;\n /** Performs a wait operation on a 64-bit integer value in memory suspending this agent if the condition is met. */\n export function wait(ptr: usize, expected: i64, timeout: i64): AtomicWaitResult;\n /** Atomic 64-bit integer read-modify-write operations on 8-bit values. */\n export namespace rmw8 {\n /** Atomically adds an 8-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on an 8-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on an 8-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on an 8-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges an 8-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations on 16-bit values. */\n export namespace rmw16 {\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 16-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 16-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 16-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 16-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 16-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations on 32-bit values. */\n export namespace rmw32 {\n /** Atomically adds a 32-bit unsigned integer value in memory. */\n export function add_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 32-bit unsigned integer value in memory. */\n export function sub_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 32-bit unsigned integer value in memory. */\n export function and_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 32-bit unsigned integer value in memory. */\n export function or_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 32-bit unsigned integer value in memory. */\n export function xor_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 32-bit unsigned integer value in memory. */\n export function xchg_u(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 32-bit unsigned integer value in memory if the condition is met. */\n export function cmpxchg_u(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n /** Atomic 64-bit integer read-modify-write operations. */\n export namespace rmw {\n /** Atomically adds a 64-bit integer value in memory. */\n export function add(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 64-bit integer value in memory. */\n export function sub(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise AND operation on a 64-bit integer value in memory. */\n export function and(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise OR operation on a 64-bit integer value in memory. */\n export function or(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically performs a bitwise XOR operation on a 64-bit integer value in memory. */\n export function xor(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 64-bit integer value in memory. */\n export function xchg(offset: usize, value: i64, immOffset?: usize): i64;\n /** Atomically compares and exchanges a 64-bit integer value in memory if the condition is met. */\n export function cmpxchg(offset: usize, expected: i64, replacement: i64, immOffset?: usize): i64;\n }\n }\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare var isize: typeof i32 | typeof i64;\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: any): i8;\ndeclare namespace u8 {\n /** Smallest representable value. */\n export const MIN_VALUE: u8;\n /** Largest representable value. */\n export const MAX_VALUE: u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: any): i8;\ndeclare namespace u16 {\n /** Smallest representable value. */\n export const MIN_VALUE: u16;\n /** Largest representable value. */\n export const MAX_VALUE: u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: any): i32;\ndeclare namespace u32 {\n /** Smallest representable value. */\n export const MIN_VALUE: u32;\n /** Largest representable value. */\n export const MAX_VALUE: u32;\n}\n/** Converts any other numeric value to a 64-bit unsigned integer. */\ndeclare function u64(value: any): i64;\ndeclare namespace u64 {\n /** Smallest representable value. */\n export const MIN_VALUE: u64;\n /** Largest representable value. */\n export const MAX_VALUE: u64;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */\ndeclare var usize: typeof u32 | typeof u64;\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: any): bool;\ndeclare namespace bool {\n /** Smallest representable value. */\n export const MIN_VALUE: bool;\n /** Largest representable value. */\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: any): f32;\ndeclare namespace f32 {\n /** Smallest representable value. */\n export const MIN_VALUE: f32;\n /** Largest representable value. */\n export const MAX_VALUE: f32;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f32;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f32;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f32;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f32;\n /** Loads a 32-bit float from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): f32;\n /** Stores a 32-bit float to memory. */\n export function store(offset: usize, value: f32, immOffset?: usize, immAlign?: usize): void;\n}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: any): f64;\ndeclare namespace f64 {\n /** Smallest representable value. */\n export const MIN_VALUE: f64;\n /** Largest representable value. */\n export const MAX_VALUE: f64;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f64;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f64;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f64;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f64;\n /** Loads a 64-bit float from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): f64;\n /** Stores a 64-bit float to memory. */\n export function store(offset: usize, value: f64, immOffset?: usize, immAlign?: usize): void;\n}\n/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */\ndeclare function v128(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;\ndeclare namespace v128 {\n /** Creates a 128-bit vector with identical lanes. */\n export function splat(x: T): v128;\n /** Extracts one lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): T;\n /** Replaces one lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: T): v128;\n /** Selects lanes from either 128-bit vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n /** Loads a 128-bit vector from memory. */\n export function load(offset: usize, immOffset?: usize, immAlign?: usize): v128;\n /** Stores a 128-bit vector to memory. */\n export function store(offset: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n /** Adds each lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128; // except i64\n /** Divides each lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each lane of a 128-bit vector */\n export function neg(a: v128): v128;\n /** Adds each lane of two 128-bit vectors using saturation. */\n export function add_saturate(a: v128, b: v128): v128;\n /** Subtracts each lane of two 128-bit vectors using saturation. */\n export function sub_saturate(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise right shift on each lane of a 128-bit vector by a scalar. */\n export function shr(a: v128, b: i32): v128;\n /** Performs the bitwise AND operation on each lane of two 128-bit vectors. */\n export function and(a: v128, b: v128): v128;\n /** Performs the bitwise OR operation on each lane of two 128-bit vectors. */\n export function or(a: v128, b: v128): v128;\n /** Performs the bitwise XOR operation on each lane of two 128-bit vectors. */\n export function xor(a: v128, b: v128): v128;\n /** Performs the bitwise NOT operation on each lane of a 128-bit vector. */\n export function not(a: v128): v128;\n /** Selects bits of either 128-bit vector according to the specified mask. */\n export function bitselect(v1: v128, v2: v128, mask: v128): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes the minimum of each lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each lane of a 128-bit vector from integer to floating point. */\n export function convert(a: v128): v128;\n /** Truncates each lane of a 128-bit vector from floating point to integer with saturation. */\n export function trunc(a: v128): v128;\n}\n/** Initializes a 128-bit vector from sixteen 8-bit integer values. Arguments must be compile-time constants. */\ndeclare function i8x16(a: i8, b: i8, c: i8, d: i8, e: i8, f: i8, g: i8, h: i8, i: i8, j: i8, k: i8, l: i8, m: i8, n: i8, o: i8, p: i8): v128;\ndeclare namespace i8x16 {\n /** Creates a vector with sixteen identical 8-bit integer lanes. */\n export function splat(x: i8): v128;\n /** Extracts one 8-bit integer lane from a 128-bit vector as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i8;\n /** Extracts one 8-bit integer lane from a 128-bit vector as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u8;\n /** Replaces one 8-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i8): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 8-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 8-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function sub_saturate_u(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 8-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 8-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 8-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 8-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 8-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 8-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n}\n/** Initializes a 128-bit vector from eight 16-bit integer values. Arguments must be compile-time constants. */\ndeclare function i16x8(a: i16, b: i16, c: i16, d: i16, e: i16, f: i16, g: i16, h: i16): v128;\ndeclare namespace i16x8 {\n /** Creates a vector with eight identical 16-bit integer lanes. */\n export function splat(x: i16): v128;\n /** Extracts one 16-bit integer lane from a 128-bit vector as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i16;\n /** Extracts one 16-bit integer lane from a 128-bit vector as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u16;\n /** Replaces one 16-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i16): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 16-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 16-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane of two 128-bit vectors using unsigned saturation. */\n export function sub_saturate_u(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 16-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 16-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 16-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 16-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 16-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 16-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n}\n/** Initializes a 128-bit vector from four 32-bit integer values. Arguments must be compile-time constants. */\ndeclare function i32x4(a: i32, b: i32, c: i32, d: i32): v128;\ndeclare namespace i32x4 {\n /** Creates a 128-bit vector with four identical 32-bit integer lanes. */\n export function splat(x: i32): v128;\n /** Extracts one 32-bit integer lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): i32;\n /** Replaces one 32-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i32): v128;\n /** Adds each 32-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 32-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 32-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 32-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 32-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Computes which 32-bit integer lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit integer lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than those of the second. */\n export function lt_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than those of the second. */\n export function gt_u(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_s(a: v128, b: v128): v128;\n /** Computes which 32-bit unsigned integer lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n /** Truncates each 32-bit float lane of a 128-bit vector to a signed integer with saturation. */\n export function trunc_s_f32x4_sat(a: v128): v128;\n /** Truncates each 32-bit float lane of a 128-bit vector to an unsigned integer with saturation. */\n export function trunc_u_f32x4_sat(a: v128): v128;\n}\n/** Initializes a 128-bit vector from two 64-bit integer values. Arguments must be compile-time constants. */\ndeclare function i64x2(a: i64, b: i64): v128;\ndeclare namespace i64x2 {\n /** Creates a 128-bit vector with two identical 64-bit integer lanes. */\n export function splat(x: i64): v128;\n /** Extracts one 64-bit integer lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): i64;\n /** Replaces one 64-bit integer lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: i64): v128;\n /** Adds each 64-bit integer lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit integer lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit integer lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 64-bit integer lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_s(a: v128, b: i32): v128;\n /** Performs a bitwise logical right shift on each 64-bit integer lane of a 128-bit vector by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 128-bit vector to a scalar indicating whether any 64-bit integer lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 128-bit vector to a scalar indicating whether all 64-bit integer lanes are considered `true`. */\n export function all_true(a: v128): bool;\n /** Truncates each 64-bit float lane of a 128-bit vector to a signed integer with saturation. */\n export function trunc_s_f64x2_sat(a: v128): v128;\n /** Truncates each 64-bit float lane of a 128-bit vector to an unsigned integer with saturation. */\n export function trunc_u_f64x2_sat(a: v128): v128;\n}\n/** Initializes a 128-bit vector from four 32-bit float values. Arguments must be compile-time constants. */\ndeclare function f32x4(a: f32, b: f32, c: f32, d: f32): v128;\ndeclare namespace f32x4 {\n /** Creates a 128-bit vector with four identical 32-bit float lanes. */\n export function splat(x: f32): v128;\n /** Extracts one 32-bit float lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): f32;\n /** Replaces one 32-bit float lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: f32): v128;\n /** Adds each 32-bit float lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit float lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit float lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 32-bit float lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 32-bit float lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 32-bit float lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 32-bit float lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 32-bit float lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 32-bit float lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which 32-bit float lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each 32-bit signed integer lane of a 128-bit vector to floating point. */\n export function convert_s_i32x4(a: v128): v128;\n /** Converts each 32-bit unsigned integer lane of a 128-bit vector to floating point. */\n export function convert_u_i32x4(a: v128): v128;\n}\n/** Initializes a 128-bit vector from two 64-bit float values. Arguments must be compile-time constants. */\ndeclare function f64x2(a: f64, b: f64): v128;\ndeclare namespace f64x2 {\n /** Creates a 128-bit vector with two identical 64-bit float lanes. */\n export function splat(x: f64): v128;\n /** Extracts one 64-bit float lane from a 128-bit vector as a scalar. */\n export function extract_lane(x: v128, idx: u8): f64;\n /** Replaces one 64-bit float lane in a 128-bit vector. */\n export function replace_lane(x: v128, idx: u8, value: f64): v128;\n /** Adds each 64-bit float lane of two 128-bit vectors. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit float lane of two 128-bit vectors. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit float lane of two 128-bit vectors. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 64-bit float lane of two 128-bit vectors. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 64-bit float lane of a 128-bit vector. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 64-bit float lane of two 128-bit vectors. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 64-bit float lane of two 128-bit vectors. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 64-bit float lane of a 128-bit vector. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 64-bit float lane of a 128-bit vector. */\n export function sqrt(a: v128): v128;\n /** Computes which 64-bit float lanes of two 128-bit vectors are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of two 128-bit vectors are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are less than or equal those of the second. */\n export function le(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 128-bit vector are greater than or equal those of the second. */\n export function ge(a: v128, b: v128): v128;\n /** Converts each 64-bit signed integer lane of a 128-bit vector to floating point. */\n export function convert_s_i64x2(a: v128): v128;\n /** Converts each 64-bit unsigned integer lane of a 128-bit vector to floating point. */\n export function convert_u_i64x2(a: v128): v128;\n}\ndeclare namespace v8x16 {\n /** Selects 8-bit lanes from either 128-bit vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, l0: u8, l1: u8, l2: u8, l3: u8, l4: u8, l5: u8, l6: u8, l7: u8, l8: u8, l9: u8, l10: u8, l11: u8, l12: u8, l13: u8, l14: u8, l15: u8): v128;\n}\n/** Macro type evaluating to the underlying native WebAssembly type. */\ndeclare type native = T;\n\n/** Pseudo-class representing the backing class of integer types. */\ndeclare class _Integer {\n /** Smallest representable value. */\n static readonly MIN_VALUE: number;\n /** Largest representable value. */\n static readonly MAX_VALUE: number;\n /** Converts a string to an integer of this type. */\n static parseInt(value: string, radix?: number): number;\n /** Converts this integer to a string. */\n toString(): string;\n}\n\n/** Pseudo-class representing the backing class of floating-point types. */\ndeclare class _Float {\n /** Difference between 1 and the smallest representable value greater than 1. */\n static readonly EPSILON: f32 | f64;\n /** Smallest representable value. */\n static readonly MIN_VALUE: f32 | f64;\n /** Largest representable value. */\n static readonly MAX_VALUE: f32 | f64;\n /** Smallest safely representable integer value. */\n static readonly MIN_SAFE_INTEGER: f32 | f64;\n /** Largest safely representable integer value. */\n static readonly MAX_SAFE_INTEGER: f32 | f64;\n /** Value representing positive infinity. */\n static readonly POSITIVE_INFINITY: f32 | f64;\n /** Value representing negative infinity. */\n static readonly NEGATIVE_INFINITY: f32 | f64;\n /** Value representing \'not a number\'. */\n static readonly NaN: f32 | f64;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n static isNaN(value: f32 | f64): bool;\n /** Returns true if passed value is finite. */\n static isFinite(value: f32 | f64): bool;\n /** Returns true if the value passed is a safe integer. */\n static isSafeInteger(value: f32 | f64): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n static isInteger(value: f32 | f64): bool;\n /** Converts a string to an integer. */\n static parseInt(value: string, radix?: i32): f32 | f64;\n /** Converts a string to a floating-point number. */\n static parseFloat(value: string): f32 | f64;\n /** Converts this floating-point number to a string. */\n toString(this: f64): string;\n}\n\n/** Backing class of signed 8-bit integers. */\ndeclare const I8: typeof _Integer;\n/** Backing class of signed 16-bit integers. */\ndeclare const I16: typeof _Integer;\n/** Backing class of signed 32-bit integers. */\ndeclare const I32: typeof _Integer;\n/** Backing class of signed 64-bit integers. */\ndeclare const I64: typeof _Integer;\n/** Backing class of signed size integers. */\ndeclare const Isize: typeof _Integer;\n/** Backing class of unsigned 8-bit integers. */\ndeclare const U8: typeof _Integer;\n/** Backing class of unsigned 16-bit integers. */\ndeclare const U16: typeof _Integer;\n/** Backing class of unsigned 32-bit integers. */\ndeclare const U32: typeof _Integer;\n/** Backing class of unsigned 64-bit integers. */\ndeclare const U64: typeof _Integer;\n/** Backing class of unsigned size integers. */\ndeclare const Usize: typeof _Integer;\n/** Backing class of 32-bit floating-point values. */\ndeclare const F32: typeof _Float;\n/** Backing class of 64-bit floating-point values. */\ndeclare const F64: typeof _Float;\n\n// User-defined diagnostic macros\n\n/** Emits a user-defined diagnostic error when encountered. */\ndeclare function ERROR(message?: any): void;\n/** Emits a user-defined diagnostic warning when encountered. */\ndeclare function WARNING(message?: any): void;\n/** Emits a user-defined diagnostic info when encountered. */\ndeclare function INFO(message?: any): void;\n\n// Polyfills\n\n/** Performs the sign-agnostic reverse bytes **/\ndeclare function bswap(value: T): T;\n/** Performs the sign-agnostic reverse bytes only for last 16-bit **/\ndeclare function bswap16(value: T): T;\n\n// Standard library\n\n/** Memory operations. */\ndeclare namespace memory {\n /** Whether the memory managed interface is implemented. */\n export const implemented: bool;\n /** Returns the current memory size in units of pages. One page is 64kb. */\n export function size(): i32;\n /** Grows linear memory by a given unsigned delta of pages. One page is 64kb. Returns the previous memory size in units of pages or `-1` on failure. */\n export function grow(value: i32): i32;\n /** Sets n bytes beginning at the specified destination in memory to the specified byte value. */\n export function fill(dst: usize, value: u8, count: usize): void;\n /** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\n export function copy(dst: usize, src: usize, n: usize): void;\n /** Repeats `src` of length `srcLength` `count` times at `dst`. */\n export function repeat(dst: usize, src: usize, srcLength: usize, count: usize): void;\n /** Copies elements from a passive element segment to a table. */\n export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void;\n /** Prevents further use of a passive element segment. */\n export function drop(segmentIndex: u32): void;\n /** Compares two chunks of memory. Returns `0` if equal, otherwise the difference of the first differing bytes. */\n export function compare(vl: usize, vr: usize, n: usize): i32;\n}\n\n/** Garbage collector operations. */\ndeclare namespace gc {\n /** Whether the garbage collector interface is implemented. */\n export const implemented: bool;\n /** Performs a full garbage collection cycle. */\n export function collect(): void;\n /** Retains a reference, making sure that it doesn\'t become collected. */\n export function retain(ref: usize): void;\n /** Releases a reference, allowing it to become collected. */\n export function release(ref: usize): void;\n}\n\n/** Table operations. */\ndeclare namespace table {\n /** Copies elements from a passive element segment to a table. */\n export function init(elementIndex: u32, srcOffset: u32, dstOffset: u32, n: u32): void;\n /** Prevents further use of a passive element segment. */\n export function drop(elementIndex: u32): void;\n /** Copies elements from one region of a table to another region. */\n export function copy(dest: u32, src: u32, n: u32): void;\n}\n\n/** Class representing a generic, fixed-length raw binary data buffer. */\ndeclare class ArrayBuffer {\n /** The size, in bytes, of the array. */\n readonly byteLength: i32;\n /** Returns true if value is one of the ArrayBuffer views, such as typed array or a DataView **/\n static isView(value: T): bool;\n /** Constructs a new array buffer of the given length in bytes. */\n constructor(length: i32);\n /** Returns a copy of this array buffer\'s bytes from begin, inclusive, up to end, exclusive. */\n slice(begin?: i32, end?: i32): ArrayBuffer;\n /** Returns a string representation of ArrayBuffer. */\n toString(): string;\n}\n\n/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform\'s endianness. */\ndeclare class DataView {\n /** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */\n readonly buffer: ArrayBuffer;\n /** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteLength: i32;\n /** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteOffset: i32;\n /** Constructs a new `DataView` with the given properties */\n constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);\n /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */\n getFloat32(byteOffset: i32, littleEndian?: boolean): f32;\n /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */\n getFloat64(byteOffset: i32, littleEndian?: boolean): f64;\n /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */\n getInt8(byteOffset: i32): i8;\n /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */\n getInt16(byteOffset: i32, littleEndian?: boolean): i16;\n /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */\n getInt32(byteOffset: i32, littleEndian?: boolean): i32;\n /** The `getInt64()` method gets a signed 64-bit integer (long long) at the specified byte offset from the start of the `DataView`. */\n getInt64(byteOffset: i32, littleEndian?: boolean): i64;\n /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */\n getUint8(byteOffset: i32): u8;\n /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */\n getUint16(byteOffset: i32, littleEndian?: boolean): u16;\n /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */\n getUint32(byteOffset: i32, littleEndian?: boolean): u32;\n /** The `getUint64()` method gets an unsigned 64-bit integer (unsigned long long) at the specified byte offset from the start of the `DataView`. */\n getUint64(byteOffset: i32, littleEndian?: boolean): u64;\n /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */\n setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;\n /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */\n setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;\n /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setInt8(byteOffset: i32, value: i8): void;\n /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */\n setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;\n /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */\n setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;\n /** The `setInt64()` method stores a signed 64-bit integer (long long) value at the specified byte offset from the start of the `DataView`. */\n setInt64(byteOffset: i32, value: i64, littleEndian?: boolean): void;\n /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setUint8(byteOffset: i32, value: u8): void;\n /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */\n setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;\n /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */\n setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;\n /** The `setUint64()` method stores an unsigned 64-bit integer (unsigned long long) value at the specified byte offset from the start of the `DataView`. */\n setUint64(byteOffset: i32, value: u64, littleEndian?: boolean): void;\n /** Returns a string representation of DataView. */\n toString(): string;\n}\n\ninterface ArrayLike {\n length: i32;\n // [key: number]: T;\n}\n\n/** Interface for a typed view on an array buffer. */\ninterface ArrayBufferView {\n [key: number]: T;\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n}\n\n/* @internal */\ndeclare abstract class TypedArray implements ArrayBufferView {\n [key: number]: T;\n /** Number of bytes per element. */\n static readonly BYTES_PER_ELEMENT: usize;\n /** Constructs a new typed array. */\n constructor(length: i32);\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n /** The length (in elements). */\n readonly length: i32;\n /** Returns a new TypedArray of this type on the same ArrayBuffer from begin inclusive to end exclusive. */\n subarray(begin?: i32, end?: i32): this;\n /** The reduce() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value. This method has the same algorithm as Array.prototype.reduce(). */\n reduce(\n callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,\n initialValue: W,\n ): W;\n /** The reduceRight() method applies a function against an accumulator and each value of the typed array (from left-to-right) has to reduce it to a single value, starting from the end of the array. This method has the same algorithm as Array.prototype.reduceRight(). */\n reduceRight(\n callbackfn: (accumulator: W, value: T, index: i32, self: this) => W,\n initialValue: W,\n ): W;\n /** The some() method tests whether some element in the typed array passes the test implemented by the provided function. This method has the same algorithm as Array.prototype.some().*/\n some(callbackfn: (value: T, index: i32, self: this) => bool): bool;\n /** The map() method creates a new typed array with the results of calling a provided function on every element in this typed array. This method has the same algorithm as Array.prototype.map().*/\n map(callbackfn: (value: T, index: i32, self: this) => T): this;\n /** The sort() method sorts the elements of a typed array numerically in place and returns the typed array. This method has the same algorithm as Array.prototype.sort(), except that sorts the values numerically instead of as strings. TypedArray is one of the typed array types here. */\n sort(callback?: (a: T, b: T) => i32): this;\n /** The fill() method fills all the elements of a typed array from a start index to an end index with a static value. This method has the same algorithm as Array.prototype.fill(). */\n fill(value: T, start?: i32, end?: i32): this;\n /** The findIndex() method returns an index in the typed array, if an element in the typed array satisfies the provided testing function. Otherwise -1 is returned. See also the find() [not implemented] method, which returns the value of a found element in the typed array instead of its index. */\n findIndex(callbackfn: (value: T, index: i32, self: this) => bool): i32;\n /** The every() method tests whether all elements in the typed array pass the test implemented by the provided function. This method has the same algorithm as Array.prototype.every(). */\n every(callbackfn: (value: T, index: i32, self: this) => bool): bool;\n /** The forEach() method executes a provided function once per array element. This method has the same algorithm as Array.prototype.forEach().*/\n forEach(callbackfn: (value: T, index: i32, self: this) => void): void;\n /** The reverse() method reverses a typed array in place. The first typed array element becomes the last and the last becomes the first. This method has the same algorithm as Array.prototype.reverse(). */\n reverse(): this;\n}\n\n/** An array of twos-complement 8-bit signed integers. */\ndeclare class Int8Array extends TypedArray {}\n/** An array of 8-bit unsigned integers. */\ndeclare class Uint8Array extends TypedArray {}\n/** A clamped array of 8-bit unsigned integers. */\ndeclare class Uint8ClampedArray extends TypedArray {}\n/** An array of twos-complement 16-bit signed integers. */\ndeclare class Int16Array extends TypedArray {}\n/** An array of 16-bit unsigned integers. */\ndeclare class Uint16Array extends TypedArray {}\n/** An array of twos-complement 32-bit signed integers. */\ndeclare class Int32Array extends TypedArray {}\n/** An array of 32-bit unsigned integers. */\ndeclare class Uint32Array extends TypedArray {}\n/** An array of twos-complement 64-bit signed integers. */\ndeclare class Int64Array extends TypedArray {}\n/** An array of 64-bit unsigned integers. */\ndeclare class Uint64Array extends TypedArray {}\n/** An array of 32-bit floating point numbers. */\ndeclare class Float32Array extends TypedArray {}\n/** An array of 64-bit floating point numbers. */\ndeclare class Float64Array extends TypedArray {}\n\n/** Class representing a sequence of values of type `T`. */\ndeclare class Array {\n\n /** Tests if a value is an array. */\n static isArray(value: any): value is Array;\n /** Creates a new array with at least the specified capacity and length zero. */\n static create(capacity?: i32): Array;\n\n [key: number]: T;\n /** Current length of the array. */\n length: i32;\n /** Constructs a new array. If length is greater than zero and T is a non-nullable reference, use `Array.create` instead.*/\n constructor(capacity?: i32);\n\n fill(value: T, start?: i32, end?: i32): this;\n every(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n findIndex(predicate: (element: T, index: i32, array?: Array) => bool): i32;\n includes(searchElement: T, fromIndex?: i32): bool;\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): i32;\n concat(items: T[]): T[];\n copyWithin(target: i32, start: i32, end?: i32): this;\n pop(): T;\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void;\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array;\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array;\n reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n shift(): T;\n some(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n unshift(element: T): i32;\n slice(from: i32, to?: i32): Array;\n splice(start: i32, deleteCount?: i32): Array;\n sort(comparator?: (a: T, b: T) => i32): this;\n join(separator?: string): string;\n reverse(): T[];\n toString(): string;\n}\n\n/** Class representing a fixed sequence of values of type `T`. */\ndeclare class FixedArray {\n [key: number]: T;\n readonly length: i32;\n constructor(capacity?: i32);\n}\n\n/** Class representing a sequence of characters. */\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(code: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: i32;\n readonly lengthUTF8: i32;\n\n charAt(index: u32): string;\n charCodeAt(index: u32): u16;\n concat(other: string): string;\n endsWith(other: string): bool;\n indexOf(other: string, fromIndex?: i32): u32;\n lastIndexOf(other: string, fromIndex?: i32): i32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(start: u32, end?: u32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n trimStart(): string;\n trimEnd(): string;\n padStart(targetLength: i32, padString?: string): string;\n padEnd(targetLength: i32, padString?: string): string;\n repeat(count?: i32): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n static fromUTF8(ptr: usize, len: usize): string;\n toUTF8(): usize;\n}\n\n/** Class for representing a runtime error. Base class of all errors. */\ndeclare class Error {\n\n /** Error name. */\n name: string;\n\n /** Message provided on construction. */\n message: string;\n\n /** Stack trace. */\n stack?: string;\n\n /** Constructs a new error, optionally with a message. */\n constructor(message?: string);\n\n /** Method returns a string representing the specified Error class. */\n toString(): string;\n}\n\n/** Class for indicating an error when a value is not in the set or range of allowed values. */\ndeclare class RangeError extends Error { }\n\n/** Class for indicating an error when a value is not of the expected type. */\ndeclare class TypeError extends Error { }\n\n/** Class for indicating an error when trying to interpret syntactically invalid code. */\ndeclare class SyntaxError extends Error { }\n\ninterface Boolean {}\ninterface Function {}\ninterface IArguments {}\ninterface Number {}\ninterface Object {}\ninterface RegExp {}\n\ndeclare class Map {\n readonly size: i32;\n has(key: K): bool;\n set(key: K, value: V): void;\n get(key: K): V;\n delete(key: K): bool;\n clear(): void;\n toString(): string;\n}\n\ndeclare class Set {\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n toString(): string;\n}\n\ninterface SymbolConstructor {\n readonly hasInstance: symbol;\n readonly isConcatSpreadable: symbol;\n readonly isRegExp: symbol;\n readonly iterator: symbol;\n readonly match: symbol;\n readonly replace: symbol;\n readonly search: symbol;\n readonly species: symbol;\n readonly split: symbol;\n readonly toPrimitive: symbol;\n readonly toStringTag: symbol;\n readonly unscopables: symbol;\n (description?: string | null): symbol;\n for(key: string): symbol;\n keyFor(sym: symbol): string | null;\n}\n\ndeclare const Symbol: SymbolConstructor;\n\ninterface IMath {\n /** The base of natural logarithms, e, approximately 2.718. */\n readonly E: T;\n /** The natural logarithm of 2, approximately 0.693. */\n readonly LN2: T;\n /** The natural logarithm of 10, approximately 2.302. */\n readonly LN10: T;\n /** The base 2 logarithm of e, approximately 1.442. */\n readonly LOG2E: T;\n /** The base 10 logarithm of e, approximately 0.434. */\n readonly LOG10E: T;\n /** The ratio of the circumference of a circle to its diameter, approximately 3.14159. */\n readonly PI: T;\n /** The square root of 1/2, approximately 0.707. */\n readonly SQRT1_2: T;\n /** The square root of 2, approximately 1.414. */\n readonly SQRT2: T;\n /** Returns the absolute value of `x`. */\n abs(x: T): T;\n /** Returns the arccosine (in radians) of `x`. */\n acos(x: T): T;\n /** Returns the hyperbolic arc-cosine of `x`. */\n acosh(x: T): T;\n /** Returns the arcsine (in radians) of `x` */\n asin(x: T): T;\n /** Returns the hyperbolic arcsine of `x`. */\n asinh(x: T): T;\n /** Returns the arctangent (in radians) of `x`. */\n atan(x: T): T;\n /** Returns the arctangent of the quotient of its arguments. */\n atan2(y: T, x: T): T;\n /** Returns the hyperbolic arctangent of `x`. */\n atanh(x: T): T;\n /** Returns the cube root of `x`. */\n cbrt(x: T): T;\n /** Returns the smallest integer greater than or equal to `x`. */\n ceil(x: T): T;\n /** Returns the number of leading zero bits in the 32-bit binary representation of `x`. */\n clz32(x: T): T;\n /** Returns the cosine (in radians) of `x`. */\n cos(x: T): T;\n /** Returns the hyperbolic cosine of `x`. */\n cosh(x: T): T;\n /** Returns e to the power of `x`. */\n exp(x: T): T;\n /** Returns e to the power of `x`, minus 1. */\n expm1(x: T): T;\n /** Returns the largest integer less than or equal to `x`. */\n floor(x: T): T;\n /** Returns the nearest 32-bit single precision float representation of `x`. */\n fround(x: T): f32;\n /** Returns the square root of the sum of squares of its arguments. */\n hypot(value1: T, value2: T): T; // TODO: rest\n /** Returns the result of the C-like 32-bit multiplication of `a` and `b`. */\n imul(a: T, b: T): T;\n /** Returns the natural logarithm (base e) of `x`. */\n log(x: T): T;\n /** Returns the base 10 logarithm of `x`. */\n log10(x: T): T;\n /** Returns the natural logarithm (base e) of 1 + `x`. */\n log1p(x: T): T;\n /** Returns the base 2 logarithm of `x`. */\n log2(x: T): T;\n /** Returns the largest-valued number of its arguments. */\n max(value1: T, value2: T): T; // TODO: rest\n /** Returns the lowest-valued number of its arguments. */\n min(value1: T, value2: T): T; // TODO: rest\n /** Returns `base` to the power of `exponent`. */\n pow(base: T, exponent: T): T;\n /** Returns a pseudo-random number in the range from 0.0 inclusive up to but not including 1.0. */\n random(): T;\n /** Returns the value of `x` rounded to the nearest integer. */\n round(x: T): T;\n /** Returns the sign of `x`, indicating whether the number is positive, negative or zero. */\n sign(x: T): T;\n /** Returns whether the sign bit of `x` is set */\n signbit(x: T): bool;\n /** Returns the sine of `x`. */\n sin(x: T): T;\n /** Returns the hyperbolic sine of `x`. */\n sinh(x: T): T;\n /** Returns the square root of `x`. */\n sqrt(x: T): T;\n /** Returns the tangent of `x`. */\n tan(x: T): T;\n /** Returns the hyperbolic tangent of `x`. */\n tanh(x: T): T;\n /** Returns the integer part of `x` by removing any fractional digits. */\n trunc(x: T): T;\n}\n\ninterface INativeMath extends IMath {\n /** Contains sin value produced after Math/Mathf.sincos */\n sincos_sin: T;\n /** Contains cos value produced after Math/Mathf.sincos */\n sincos_cos: T;\n /** Seeds the random number generator. */\n seedRandom(value: i64): void;\n /** Returns the floating-point remainder of `x / y` (rounded towards zero). */\n mod(x: T, y: T): T;\n /** Returns the floating-point remainder of `x / y` (rounded to nearest). */\n rem(x: T, y: T): T;\n /** Returns sin and cos simultaneously for same angle. Results stored to `sincos_s32/64` and `sincos_c32/64` globals */\n sincos(x: T): void;\n}\n\n/** Double precision math imported from JavaScript. */\ndeclare const JSMath: IMath;\n/** Double precision math implemented natively. */\ndeclare const NativeMath: INativeMath;\n/** Single precision math implemented natively. */\ndeclare const NativeMathf: INativeMath;\n/** Alias of {@link NativeMath} or {@link JSMath} respectively. Defaults to `NativeMath`. */\ndeclare const Math: IMath;\n/** Alias of {@link NativeMathf} or {@link JSMath} respectively. Defaults to `NativeMathf`. */\ndeclare const Mathf: IMath;\n\ndeclare class Date {\n /** Returns the UTC timestamp in milliseconds of the specified date. */\n static UTC(\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: i32\n ): i64;\n /** Returns the current UTC timestamp in milliseconds. */\n static now(): i64;\n /** Constructs a new date object from an UTC timestamp in milliseconds. */\n constructor(value: i64);\n /** Returns the UTC timestamp of this date in milliseconds. */\n getTime(): i64;\n /** Sets the UTC timestamp of this date in milliseconds. */\n setTime(value: i64): i64;\n}\n\n/** Environmental tracing function for debugging purposes. */\ndeclare function trace(msg: string, n?: i32, a0?: f64, a1?: f64, a2?: f64, a3?: f64, a4?: f64): void;\n\n// Decorators\n\ninterface TypedPropertyDescriptor {\n configurable?: boolean;\n enumerable?: boolean;\n writable?: boolean;\n value?: T;\n get?(): T;\n set?(value: T): void;\n}\n\n/** Annotates a method as a binary operator overload for the specified `token`. */\ndeclare function operator(token:\n "[]" | "[]=" | "{}" | "{}=" | "==" | "!=" | ">" | "<" | "<=" | ">=" |\n ">>" | ">>>" | "<<" | "&" | "|" | "^" | "+" | "-" | "*" | "**" | "/" | "%"\n): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n) => TypedPropertyDescriptor | void;\n\ndeclare namespace operator {\n /** Annotates a method as a binary operator overload for the specified `token`. */\n export function binary(token:\n "[]" | "[]=" | "{}" | "{}=" | "==" | "!=" | ">" | "<" | "<=" | ">=" |\n ">>" | ">>>" | "<<" | "&" | "|" | "^" | "+" | "-" | "*" | "**" | "/" | "%"\n ): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n /** Annotates a method as an unary prefix operator overload for the specified `token`. */\n export function prefix(token: "!" | "~" | "+" | "-" | "++" | "--"): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n /** Annotates a method as an unary postfix operator overload for the specified `token`. */\n export function postfix(token: "++" | "--"): (\n target: any,\n propertyKey: string,\n descriptor: TypedPropertyDescriptor\n ) => TypedPropertyDescriptor | void;\n}\n\n/** Annotates an element as a program global. */\ndeclare function global(...args: any[]): any;\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(constructor: Function): void;\n\n/** Annotates a class as being sealed / non-derivable. */\ndeclare function sealed(constructor: Function): void;\n\n/** Annotates a method, function or constant global as always inlined. */\ndeclare function inline(...args: any[]): any;\n\n/** Annotates a method, function or constant global as unsafe. */\ndeclare function unsafe(...args: any[]): any;\n\n/** Annotates an explicit external name of a function or global. */\ndeclare function external(...args: any[]): any;\n\n/** Annotates a global for lazy compilation. */\ndeclare function lazy(...args: any[]): any;\n\n/** Annotates a function as the explicit start function. */\ndeclare function start(...args: any[]): any;\n',portable:"/**\n * Environment definitions for compiling AssemblyScript to JavaScript using tsc.\n *\n * Note that semantic differences require additional explicit conversions for full compatibility.\n * For example, when casting an i32 to an u8, doing `(someI32 & 0xff)` will yield the same\n * result when compiling to WebAssembly or JS while `someI32` alone does nothing in JS.\n *\n * Note that i64's are not portable (JS numbers are IEEE754 doubles with a maximum safe integer\n * value of 2^53-1) and instead require a compatibility layer to work in JS as well, as for example\n * {@link glue/js/i64} respectively {@link glue/wasm/i64}.\n *\n * @module std/portable\n *//***/\n\n/// \n\n// Types\n\ndeclare type bool = boolean;\ndeclare type i8 = number;\ndeclare type i16 = number;\ndeclare type i32 = number;\ndeclare type isize = number;\ndeclare type u8 = number;\ndeclare type u16 = number;\ndeclare type u32 = number;\ndeclare type usize = number;\ndeclare type f32 = number;\ndeclare type f64 = number;\n\n// Compiler hints\n\n/** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */\ndeclare const ASC_TARGET: i32;\n/** Provided noAssert option. */\ndeclare const ASC_NO_ASSERT: bool;\n/** Provided memoryBase option. */\ndeclare const ASC_MEMORY_BASE: i32;\n/** Provided optimizeLevel option. */\ndeclare const ASC_OPTIMIZE_LEVEL: i32;\n/** Provided shrinkLevel option. */\ndeclare const ASC_SHRINK_LEVEL: i32;\n/** Whether the mutable global feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBAL: bool;\n/** Whether the sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n\n// Builtins\n\n/** Performs the sign-agnostic count leading zero bits operation on a 32-bit integer. All zero bits are considered leading if the value is zero. */\ndeclare function clz(value: T): T;\n/** Performs the sign-agnostic count tailing zero bits operation on a 32-bit integer. All zero bits are considered trailing if the value is zero. */\ndeclare function ctz(value: T): T;\n/** Performs the sign-agnostic count number of one bits operation on a 32-bit integer. */\ndeclare function popcnt(value: T): T;\n/** Performs the sign-agnostic rotate left operation on a 32-bit integer. */\ndeclare function rotl(value: T, shift: T): T;\n/** Performs the sign-agnostic rotate right operation on a 32-bit integer. */\ndeclare function rotr(value: T, shift: T): T;\n/** Computes the absolute value of an integer or float. */\ndeclare function abs(value: T): T;\n/** Determines the maximum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function max(left: T, right: T): T;\n/** Determines the minimum of two integers or floats. If either operand is `NaN`, returns `NaN`. */\ndeclare function min(left: T, right: T): T;\n/** Composes a 32-bit or 64-bit float from the magnitude of `x` and the sign of `y`. */\ndeclare function copysign(x: T, y: T): T;\n/** Performs the ceiling operation on a 32-bit or 64-bit float. */\ndeclare function ceil(value: T): T;\n/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(value: T): T;\n/** Rounds to the nearest integer tied to even of a 32-bit or 64-bit float. */\ndeclare function nearest(value: T): T;\n/** Selects one of two pre-evaluated values depending on the condition. */\ndeclare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n/** Calculates the square root of a 32-bit or 64-bit float. */\ndeclare function sqrt(value: T): T;\n/** Rounds to the nearest integer towards zero of a 32-bit or 64-bit float. */\ndeclare function trunc(value: T): T;\n/** Loads a value of the specified type from memory. Type must be `u8`. */\ndeclare function load(ptr: usize, constantOffset?: usize): T;\n/** Stores a value of the specified type to memory. Type must be `u8`. */\ndeclare function store(ptr: usize, value: T, constantOffset?: usize): void;\n/** Emits an unreachable operation that results in a runtime error when executed. */\ndeclare function unreachable(): any; // sic\n\n/** NaN (not a number) as a 32-bit or 64-bit float depending on context. */\ndeclare const NaN: f32 | f64;\n/** Positive infinity as a 32-bit or 64-bit float depending on context. */\ndeclare const Infinity: f32 | f64;\n/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/\ndeclare function changetype(value: any): T;\n/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */\ndeclare function unchecked(value: T): T;\n/** Tests if a 32-bit or 64-bit float is `NaN`. */\ndeclare function isNaN(value: T): bool;\n/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */\ndeclare function isFinite(value: T): bool;\n/** Tests if the specified value is a valid integer. Can't distinguish an integer from an integral float. */\ndeclare function isInteger(value: any): value is number;\n/** Tests if the specified value is a valid float. Can't distinguish a float from an integer. */\ndeclare function isFloat(value: any): value is number;\n/** Tests if the specified value is of a nullable reference type. */\ndeclare function isNullable(value: any): bool;\n/** Tests if the specified value is of a reference type. */\ndeclare function isReference(value: any): value is object | string;\n/** Tests if the specified value is of a function type */\ndeclare function isFunction(value: any): value is Function;\n/** Tests if the specified value can be used as a string. */\ndeclare function isString(value: any): value is string | String;\n/** Tests if the specified value can be used as an array. */\ndeclare function isArray(value: any): value is Array;\n/** Tests if the specified type *or* expression can be used as an array like object. */\ndeclare function isArrayLike(value: any): value is ArrayLike;\n/** Tests if the specified expression resolves to a defined element. */\ndeclare function isDefined(expression: any): bool;\n/** Tests if the specified expression evaluates to a constant value. */\ndeclare function isConstant(expression: any): bool;\n/** Traps if the specified value is not true-ish, otherwise returns the value. */\ndeclare function assert(isTrueish: T | null, message?: string): T;\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses a floating point string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n/** Returns the 64-bit floating-point remainder of `x/y`. */\ndeclare function fmod(x: f64, y: f64): f64;\n/** Returns the 32-bit floating-point remainder of `x/y`. */\ndeclare function fmodf(x: f32, y: f32): f32;\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: any): i8;\ndeclare namespace i8 {\n /** Smallest representable value. */\n export const MIN_VALUE: i8;\n /** Largest representable value. */\n export const MAX_VALUE: i8;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i8;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: any): i16;\ndeclare namespace i16 {\n /** Smallest representable value. */\n export const MIN_VALUE: i16;\n /** Largest representable value. */\n export const MAX_VALUE: i16;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i16;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: any): i32;\ndeclare namespace i32 {\n /** Smallest representable value. */\n export const MIN_VALUE: i32;\n /** Largest representable value. */\n export const MAX_VALUE: i32;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): i32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): i32;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare function isize(value: any): isize;\ndeclare namespace isize {\n /** Smallest representable value. */\n export const MIN_VALUE: isize;\n /** Largest representable value. */\n export const MAX_VALUE: isize;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): isize;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): isize;\n}\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: any): u8;\ndeclare namespace u8 {\n /** Smallest representable value. */\n export const MIN_VALUE: u8;\n /** Largest representable value. */\n export const MAX_VALUE: u8;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u8;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: any): u16;\ndeclare namespace u16 {\n /** Smallest representable value. */\n export const MIN_VALUE: u16;\n /** Largest representable value. */\n export const MAX_VALUE: u16;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u16;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: any): u32;\ndeclare namespace u32 {\n /** Smallest representable value. */\n export const MIN_VALUE: u32;\n /** Largest representable value. */\n export const MAX_VALUE: u32;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): u32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): u32;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) unsigned integer. */\ndeclare function usize(value: any): isize;\ndeclare namespace usize {\n /** Smallest representable value. */\n export const MIN_VALUE: usize;\n /** Largest representable value. */\n export const MAX_VALUE: usize;\n /** Converts a string to a floating-point number and cast to target integer after. */\n export function parseFloat(string: string): usize;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): usize;\n}\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: any): bool;\ndeclare namespace bool {\n /** Smallest representable value. */\n export const MIN_VALUE: bool;\n /** Largest representable value. */\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: any): f32;\ndeclare namespace f32 {\n /** Smallest representable value. */\n export const MIN_VALUE: f32;\n /** Largest representable value. */\n export const MAX_VALUE: f32;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f32;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f32;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f32;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f32;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n export function isNaN(value: f32): bool;\n /** Returns true if passed value is finite. */\n export function isFinite(value: f32): bool;\n /** Returns true if the value passed is a safe integer. */\n export function isSafeInteger(value: f32): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n export function isInteger(value: f32): bool;\n /** Converts a string to a floating-point number. */\n export function parseFloat(string: string): f32;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): f32;\n}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: any): f64;\ndeclare namespace f64 {\n /** Smallest representable value. */\n export const MIN_VALUE: f64;\n /** Largest representable value. */\n export const MAX_VALUE: f64;\n /** Smallest normalized positive value. */\n export const MIN_POSITIVE_VALUE: f64;\n /** Smallest safely representable integer value. */\n export const MIN_SAFE_INTEGER: f64;\n /** Largest safely representable integer value. */\n export const MAX_SAFE_INTEGER: f64;\n /** Difference between 1 and the smallest representable value greater than 1. */\n export const EPSILON: f64;\n /** Returns a boolean value that indicates whether a value is the reserved value NaN (not a number). */\n export function isNaN(value: f32): bool;\n /** Returns true if passed value is finite. */\n export function isFinite(value: f32): bool;\n /** Returns true if the value passed is a safe integer. */\n export function isSafeInteger(value: f64): bool;\n /** Returns true if the value passed is an integer, false otherwise. */\n export function isInteger(value: f64): bool;\n /** Converts a string to a floating-point number. */\n export function parseFloat(string: string): f64;\n /** Converts A string to an integer. */\n export function parseInt(string: string, radix?: i32): f64;\n}\n\n// Polyfills\n\n/** [Polyfill] Performs the sign-agnostic reverse bytes **/\ndeclare function bswap(value: T): T;\n/** [Polyfill] Performs the sign-agnostic reverse bytes only for last 16-bit **/\ndeclare function bswap16(value: T): T;\n\n// Standard library\n\n/** Memory operations. */\ndeclare namespace memory {\n /** Allocates a chunk of memory of the specified size and returns a pointer to it. */\n function allocate(size: usize): usize;\n /** Disposes a chunk of memory by its pointer. */\n function free(ptr: usize): void;\n /** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\n function copy(dst: usize, src: usize, n: usize): void;\n /** Fills size bytes from from the specified destination by same value in memory. */\n function fill(dst: usize, value: u8, size: usize): void;\n /** Resets the allocator to its initial state, if supported. */\n function reset(): void;\n}\n\n/** Class representing a generic, fixed-length raw binary data buffer. */\ndeclare class ArrayBuffer {\n /** The size, in bytes, of the array. */\n readonly byteLength: i32;\n /** Returns true if value is one of the ArrayBuffer views, such as typed array or a DataView **/\n static isView(value: T): bool;\n /** Constructs a new array buffer of the given length in bytes. */\n constructor(length: i32);\n /** Returns a copy of this array buffer's bytes from begin, inclusive, up to end, exclusive. */\n slice(begin?: i32, end?: i32): ArrayBuffer;\n /** Returns a string representation of ArrayBuffer. */\n toString(): string;\n}\n\n/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform's endianness. */\ndeclare class DataView {\n /** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */\n readonly buffer: ArrayBuffer;\n /** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteLength: i32;\n /** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */\n readonly byteOffset: i32;\n /** Constructs a new `DataView` with the given properties */\n constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);\n /** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */\n getFloat32(byteOffset: i32, littleEndian?: boolean): f32;\n /** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */\n getFloat64(byteOffset: i32, littleEndian?: boolean): f64;\n /** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */\n getInt8(byteOffset: i32): i8;\n /** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */\n getInt16(byteOffset: i32, littleEndian?: boolean): i16;\n /** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */\n getInt32(byteOffset: i32, littleEndian?: boolean): i32;\n /** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */\n getUint8(byteOffset: i32): u8;\n /** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */\n getUint16(byteOffset: i32, littleEndian?: boolean): u16;\n /** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */\n getUint32(byteOffset: i32, littleEndian?: boolean): u32;\n /** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */\n setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void;\n /** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */\n setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void;\n /** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setInt8(byteOffset: i32, value: i8): void;\n /** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */\n setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void;\n /** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */\n setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void;\n /** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */\n setUint8(byteOffset: i32, value: u8): void;\n /** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */\n setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void;\n /** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */\n setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void;\n /** Returns a string representation of DataView. */\n toString(): string;\n}\n\ndeclare class Array {\n\n static isArray(value: any): value is Array;\n static create(capacity?: i32): Array;\n\n [key: number]: T;\n length: i32;\n constructor(capacity?: i32);\n\n fill(value: T, start?: i32, end?: i32): this;\n every(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n findIndex(predicate: (element: T, index: i32, array?: Array) => bool): i32;\n includes(searchElement: T, fromIndex?: i32): bool;\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): i32;\n concat(items: T[]): T[];\n copyWithin(target: i32, start: i32, end?: i32): this;\n pop(): T;\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void;\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array;\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array;\n reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U, initialValue: U): U;\n shift(): T;\n some(callbackfn: (element: T, index: i32, array?: Array) => bool): bool;\n unshift(element: T): i32;\n slice(from?: i32, to?: i32): Array;\n splice(start: i32, deleteCount?: i32): Array;\n sort(comparator?: (a: T, b: T) => i32): this;\n join(separator?: string): string;\n reverse(): T[];\n toString(): string;\n}\n\ndeclare class Uint8Array extends Array {}\ndeclare class Uint8ClampedArray extends Array {}\ndeclare class Uint16Array extends Array {}\ndeclare class Uint32Array extends Array {}\ndeclare class Int8Array extends Array {}\ndeclare class Int16Array extends Array {}\ndeclare class Int32Array extends Array {}\ndeclare class Float32Array extends Array {}\ndeclare class Float64Array extends Array {}\n\ninterface ArrayLike {\n length: i32;\n [key: number]: T;\n}\n\n/** Interface for a typed view on an array buffer. */\ninterface ArrayBufferView {\n [key: number]: T;\n /** The {@link ArrayBuffer} referenced by this view. */\n readonly buffer: ArrayBuffer;\n /** The offset in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteOffset: i32;\n /** The length in bytes from the start of the referenced {@link ArrayBuffer}. */\n readonly byteLength: i32;\n}\n\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(code: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: i32;\n\n private constructor();\n\n charAt(index: i32): string;\n charCodeAt(index: i32): i32;\n concat(other: string): string;\n indexOf(other: string, fromIndex?: i32): i32;\n lastIndexOf(other: string, fromIndex?: i32): i32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n endsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(from: i32, to?: i32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n trimStart(): string;\n trimEnd(): string;\n padStart(targetLength: i32, padString?: string): string;\n padEnd(targetLength: i32, padString?: string): string;\n replace(search: string, replacement: string): string;\n repeat(count?: i32): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n}\n\ninterface Boolean {}\n\ndeclare class Number {\n private constructor();\n toString(radix?: i32): string;\n}\n\ninterface Object {}\n\ninterface Function {}\n\ninterface RegExp {}\n\ninterface IArguments {}\n\n/** Class for representing a runtime error. Base class of all errors. */\ndeclare class Error {\n\n /** Error name. */\n name: string;\n\n /** Message provided on construction. */\n message: string;\n\n /** Stack trace. */\n stack?: string;\n\n /** Constructs a new error, optionally with a message. */\n constructor(message?: string);\n\n /** Method returns a string representing the specified Error class. */\n toString(): string;\n}\n\n/** Class for indicating an error when a value is not in the set or range of allowed values. */\ndeclare class RangeError extends Error { }\n\n/** Class for indicating an error when a value is not of the expected type. */\ndeclare class TypeError extends Error { }\n\n/** Class for indicating an error when trying to interpret syntactically invalid code. */\ndeclare class SyntaxError extends Error { }\n\ndeclare class Set {\n constructor(entries?: T[]);\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n toString(): string;\n [Symbol.iterator](): Iterator;\n}\n\ndeclare class Map {\n constructor(entries?: [K, V][]);\n readonly size: i32;\n set(key: K, value: V): void;\n has(key: K): bool;\n get(key: K): V | null;\n clear(): void;\n entries(): Iterable<[K, V]>;\n keys(): Iterable;\n values(): Iterable;\n delete(key: K): bool;\n toString(): string;\n [Symbol.iterator](): Iterator<[K,V]>;\n}\n\ninterface SymbolConstructor {\n readonly hasInstance: symbol;\n readonly isConcatSpreadable: symbol;\n readonly isRegExp: symbol;\n readonly iterator: symbol;\n readonly match: symbol;\n readonly replace: symbol;\n readonly search: symbol;\n readonly species: symbol;\n readonly split: symbol;\n readonly toPrimitive: symbol;\n readonly toStringTag: symbol;\n readonly unscopables: symbol;\n (description?: string | null): symbol;\n for(key: string): symbol;\n keyFor(sym: symbol): string | null;\n}\ndeclare const Symbol: SymbolConstructor;\n\ninterface Iterable {\n [Symbol.iterator](): Iterator;\n}\n\ninterface Iterator {}\n\ninterface IMath {\n readonly E: f64;\n readonly LN2: f64;\n readonly LN10: f64;\n readonly LOG2E: f64;\n readonly LOG10E: f64;\n readonly PI: f64;\n readonly SQRT1_2: f64;\n readonly SQRT2: f64;\n\n sincos_sin: f64;\n sincos_cos: f64;\n\n abs(x: f64): f64;\n acos(x: f64): f64;\n acosh(x: f64): f64;\n asin(x: f64): f64;\n asinh(x: f64): f64;\n atan(x: f64): f64;\n atan2(y: f64, x: f64): f64;\n atanh(x: f64): f64;\n cbrt(x: f64): f64;\n ceil(x: f64): f64;\n clz32(x: f64): i32;\n cos(x: f64): f64;\n cosh(x: f64): f64;\n exp(x: f64): f64;\n expm1(x: f64): f64;\n floor(x: f64): f64;\n fround(x: f64): f32;\n hypot(value1: f64, value2: f64): f64; // TODO: see std/math\n imul(a: f64, b: f64): i32;\n log(x: f64): f64;\n log10(x: f64): f64;\n log1p(x: f64): f64;\n log2(x: f64): f64;\n max(value1: f64, value2: f64): f64; // TODO: see std/math\n min(value1: f64, value2: f64): f64; // TODO: see std/math\n pow(base: f64, exponent: f64): f64;\n random(): f64;\n round(x: f64): f64;\n sign(x: f64): f64;\n signbit(x: f64): bool;\n sin(x: f64): f64;\n sincos(x: f64): f64;\n sinh(x: f64): f64;\n sqrt(x: f64): f64;\n tan(x: f64): f64;\n tanh(x: f64): f64;\n trunc(x: f64): f64;\n}\n\ndeclare const Math: IMath;\ndeclare const Mathf: IMath;\ndeclare const JSMath: IMath;\n\ndeclare class Date {\n /** Returns the UTC timestamp in milliseconds of the specified date. */\n static UTC(\n year: i32,\n month: i32,\n day: i32,\n hour: i32,\n minute: i32,\n second: i32,\n millisecond: i32\n ): number;\n /** Returns the current UTC timestamp in milliseconds. */\n static now(): number;\n /** Constructs a new date object from an UTC timestamp in milliseconds. */\n constructor(value: number);\n /** Returns the UTC timestamp of this date in milliseconds. */\n getTime(): number;\n /** Sets the UTC timestamp of this date in milliseconds. */\n setTime(value: number): number;\n}\n\ndeclare namespace console {\n /** @deprecated */\n function log(message: string): void;\n}\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(constructor: Function): void;\n"}):(()=>{const n=path.join(".","..","std");return{assembly:fs.readFileSync(path.join(n,"assembly","index.d.ts"),"utf8"),portable:fs.readFileSync(path.join(n,"portable","index.d.ts"),"utf8")}})(),exports.compileString=((n,e)=>{"string"==typeof n&&(n={"input.ts":n});const t=Object.create({stdout:createMemoryStream(),stderr:createMemoryStream()});var r=["--binaryFile","binary","--textFile","text"];return Object.keys(e||{}).forEach(n=>{var t=e[n];Array.isArray(t)?t.forEach(e=>r.push("--"+n,String(e))):r.push("--"+n,String(t))}),exports.main(r.concat(Object.keys(n)),{stdout:t.stdout,stderr:t.stderr,readFile:e=>n.hasOwnProperty(e)?n[e]:null,writeFile:(n,e)=>t[n]=e,listFiles:()=>[]}),t}),exports.main=function(n,e,t){"function"==typeof e?(t=e,e={}):e||(e={});const r=e.stdout||process.stdout,i=e.stderr||process.stderr,o=e.readFile||F,a=e.writeFile||z,s=e.listFiles||S,l=e.stats||createStats();if(!r)throw Error("'options.stdout' must be specified");if(!i)throw Error("'options.stderr' must be specified");const u=optionsUtil.parse(n,exports.options),f=u.options;if(n=u.arguments,f.noColors?colorsUtil.stdout.supported=colorsUtil.stderr.supported=!1:(colorsUtil.stdout=colorsUtil.from(r),colorsUtil.stderr=colorsUtil.from(i)),u.unknown.length&&u.unknown.forEach(n=>{i.write(colorsUtil.stderr.yellow("WARN: ")+"Unknown option '"+n+"'"+EOL)}),u.trailing.length&&i.write(colorsUtil.stderr.yellow("WARN: ")+"Unsupported trailing arguments: "+u.trailing.join(" ")+EOL),t||(t=function(n){var e=0;return n&&(i.write(colorsUtil.stderr.red("ERROR: ")+n.stack.replace(/^ERROR: /i,"")+EOL),e=1),e}),f.version)return r.write("Version "+exports.version+(isDev?"-dev":"")+EOL),t(null);if(f.help||!n.length){var c=f.help?r:i,d=f.help?colorsUtil.stdout:colorsUtil.stderr;return c.write([d.white("SYNTAX")," "+d.cyan("asc")+" [entryFile ...] [options]","",d.white("EXAMPLES")," "+d.cyan("asc")+" hello.ts"," "+d.cyan("asc")+" hello.ts -b hello.wasm -t hello.wat"," "+d.cyan("asc")+" hello1.ts hello2.ts -b -O > hello.wasm","",d.white("OPTIONS")].concat(optionsUtil.help(exports.options,24,EOL)).join(EOL)+EOL),t(null)}if(!fs.readFileSync){if(o===F)throw Error("'options.readFile' must be specified");if(a===z)throw Error("'options.writeFile' must be specified");if(s===S)throw Error("'options.listFiles' must be specified")}const p=f.baseDir?path.resolve(f.baseDir):".",h=[];f.transform&&f.transform.forEach(n=>h.push(__webpack_require__(12)(path.isAbsolute(n=n.trim())?n:path.join(process.cwd(),n))));var g=null;Object.keys(exports.libraryFiles).forEach(n=>{n.indexOf("/")>=0||(l.parseCount++,l.parseTime+=measure(()=>{g=assemblyscript.parseFile(exports.libraryFiles[n],exports.libraryPrefix+n+".ts",!1,g)}))});const x=[];if(f.lib){let n=f.lib;"string"==typeof n&&(n=n.split(",")),Array.prototype.push.apply(x,n.map(n=>n.trim()));for(let n=0,e=x.length;n{g=assemblyscript.parseFile(a,exports.libraryPrefix+i,!1,g)})}}}function v(){for(var n,e;null!=(n=g.nextFile());){if(n.startsWith(exports.libraryPrefix)){const t=n.substring(exports.libraryPrefix.length),r=n.substring(exports.libraryPrefix.length)+"/index";if(exports.libraryFiles.hasOwnProperty(t))e=exports.libraryFiles[t],n=exports.libraryPrefix+t+".ts";else if(exports.libraryFiles.hasOwnProperty(r))e=exports.libraryFiles[r],n=exports.libraryPrefix+r+".ts";else for(let i=0,a=x.length;i{assemblyscript.parseFile(e,n,!1,g)})}if(checkDiagnostics(g,i))return t(Error("Parse error"))}{let n=String(f.runtime),e=exports.libraryFiles["rt/index-"+n];if(null==e&&null==(e=o(n+".ts",p)))return t(Error("Runtime template '"+n+"' not found."));l.parseCount++,l.parseTime+=measure(()=>{g=assemblyscript.parseFile(e,n,!0,g)})}for(let e=0,r=n.length;e{g=assemblyscript.parseFile(a,i,!0,g)})}{let n=v();if(n)return n}!function(n,...e){h.forEach(t=>{"function"==typeof t[n]&&t[n](...e)})}("afterParse",g);{let n=v();if(n)return n}const m=assemblyscript.finishParsing(g);var b=0,y=0;f.optimize&&(b=exports.defaultOptimizeLevel,y=exports.defaultShrinkLevel),"number"==typeof f.optimizeLevel&&(b=f.optimizeLevel),"number"==typeof f.shrinkLevel&&(y=f.shrinkLevel),b=Math.min(Math.max(b,0),3),y=Math.min(Math.max(y,0),2);const _=assemblyscript.createOptions();if(assemblyscript.setTarget(_,0),assemblyscript.setNoAssert(_,f.noAssert),assemblyscript.setImportMemory(_,f.importMemory),assemblyscript.setSharedMemory(_,f.sharedMemory),assemblyscript.setImportTable(_,f.importTable),assemblyscript.setMemoryBase(_,f.memoryBase>>>0),assemblyscript.setSourceMap(_,null!=f.sourceMap),assemblyscript.setOptimizeLevelHints(_,b,y),assemblyscript.setGlobalAlias(_,"Math","NativeMath"),assemblyscript.setGlobalAlias(_,"Mathf","NativeMathf"),assemblyscript.setGlobalAlias(_,"abort","~lib/builtins/abort"),assemblyscript.setGlobalAlias(_,"trace","~lib/builtins/trace"),f.use){let n=f.use;for(let e=0,r=n.length;e{T=assemblyscript.compileProgram(m,_)})}catch(n){return t(n)}if(checkDiagnostics(g,i))return T&&T.dispose(),t(Error("Compile error"));if(f.validate&&(l.validateCount++,l.validateTime+=measure(()=>{if(!T.validate())return T.dispose(),t(Error("Validate error"))})),"clamp"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(["trap-mode-clamp"])});else if("js"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(["trap-mode-js"])});else if("allow"!==f.trapMode)return T.dispose(),t(Error("Unsupported trap mode"));(b>=3||y>=2)&&(b=4),T.setOptimizeLevel(b),T.setShrinkLevel(y),T.setDebugInfo(f.debug);var A=[];if(f.runPasses&&("string"==typeof f.runPasses&&(f.runPasses=f.runPasses.split(",")),f.runPasses.length&&f.runPasses.forEach(n=>{A.indexOf(n)<0&&A.push(n)})),(b>0||y>0)&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{T.optimize()})),A.length&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{T.runPasses(A.map(n=>n.trim()))})),!f.noEmit){let n=!1,e=!1;if(null!=f.outFile&&(/\.was?t$/.test(f.outFile)&&null==f.textFile?f.textFile=f.outFile:/\.js$/.test(f.outFile)&&null==f.asmjsFile?f.asmjsFile=f.outFile:null==f.binaryFile&&(f.binaryFile=f.outFile)),null!=f.binaryFile){let r,s=null!=f.sourceMap?f.sourceMap.length?f.sourceMap:path.basename(f.binaryFile)+".map":null;if(l.emitCount++,l.emitTime+=measure(()=>{r=T.toBinary(s)}),f.binaryFile.length?a(f.binaryFile,r.output,p):(I(r.output),n=!0),e=!0,null!=r.sourceMap)if(f.binaryFile.length){let n=JSON.parse(r.sourceMap);n.sourceRoot=exports.sourceMapRoot,n.sources.forEach((e,r)=>{let i=null;if(e.startsWith(exports.libraryPrefix)){let n=e.substring(exports.libraryPrefix.length).replace(/\.ts$/,"");if(exports.libraryFiles.hasOwnProperty(n))i=exports.libraryFiles[n];else for(let n=0,t=x.length;n{t=T.toAsmjs()}),a(f.asmjsFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=T.toAsmjs()}),I(t),n=!0),e=!0}if(null!=f.idlFile){let t;f.idlFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(m)}),a(f.idlFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(m)}),I(t),n=!0),e=!0}if(null!=f.tsdFile){let t;f.tsdFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(m)}),a(f.tsdFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(m)}),I(t),n=!0),e=!0}if(null!=f.textFile||!e){let e;f.textFile&&f.textFile.length?(l.emitCount++,l.emitTime+=measure(()=>{e=T.toText()}),a(f.textFile,e,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{e=T.toText()}),I(e))}}return T.dispose(),f.measure&&printStats(l,i),t(null);function F(n,e){try{let t;return l.readCount++,l.readTime+=measure(()=>{t=fs.readFileSync(path.join(e,n),{encoding:"utf8"})}),t}catch(n){return null}}function z(n,e,t){try{return l.writeCount++,l.writeTime+=measure(()=>{mkdirp(path.join(t,path.dirname(n))),"string"==typeof e?fs.writeFileSync(path.join(t,n),e,{encoding:"utf8"}):fs.writeFileSync(path.join(t,n),e)}),!0}catch(n){return!1}}function S(n,e){var t;try{return l.readTime+=measure(()=>{t=fs.readdirSync(path.join(e,n)).filter(n=>/^(?!.*\.d\.ts$).*\.ts$/.test(n))}),t}catch(n){return[]}}function I(n){I.used||(l.writeCount++,I.used=!0),l.writeTime+=measure(()=>{"string"==typeof n?r.write(n,{encoding:"utf8"}):r.write(n)})}},exports.checkDiagnostics=checkDiagnostics,exports.createStats=createStats,process.hrtime||(process.hrtime=__webpack_require__(13)),exports.measure=measure,exports.formatTime=formatTime,exports.printStats=printStats;var allocBuffer=void 0!==global&&global.Buffer?global.Buffer.allocUnsafe||function(n){return new global.Buffer(n)}:function(n){return new Uint8Array(n)};function createMemoryStream(n){var e=[];return e.write=function(e){if(n&&n(e),"string"==typeof e){let n=allocBuffer(utf8.length(e));utf8.write(e,n,0),e=n}this.push(e)},e.reset=function(){e.length=0},e.toBuffer=function(){for(var n=0,e=0,t=this.length;e191&&r<224?o[a++]=(31&r)<<6|63&n[e++]:r>239&&r<365?(r=((7&r)<<18|(63&n[e++])<<12|(63&n[e++])<<6|63&n[e++])-65536,o[a++]=55296+(r>>10),o[a++]=56320+(1023&r)):o[a++]=(15&r)<<12|(63&n[e++])<<6|63&n[e++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))},r.write=function(n,e,t){for(var r,i,o=t,a=0;a>6|192,e[t++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=n.charCodeAt(a+1)))?(r=65536+((1023&r)<<10)+(1023&i),++a,e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=63&r|128):(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=63&r|128);return t-o}},function(n,e,t){(function(n){var t=void 0!==n&&n||{},r=t.env&&"CI"in t.env;function i(n,t){var i=t||{};return i.supported=n&&!!n.isTTY||r,i.gray=(n=>i.supported?e.GRAY+n+e.RESET:n),i.red=(n=>i.supported?e.RED+n+e.RESET:n),i.green=(n=>i.supported?e.GREEN+n+e.RESET:n),i.yellow=(n=>i.supported?e.YELLOW+n+e.RESET:n),i.blue=(n=>i.supported?e.BLUE+n+e.RESET:n),i.magenta=(n=>i.supported?e.MAGENTA+n+e.RESET:n),i.cyan=(n=>i.supported?e.CYAN+n+e.RESET:n),i.white=(n=>i.supported?e.WHITE+n+e.RESET:n),i}e.stdout=i(t.stdout,e),e.stderr=i(t.stderr),e.from=i,e.GRAY="",e.RED="",e.GREEN="",e.YELLOW="",e.BLUE="",e.MAGENTA="",e.CYAN="",e.WHITE="",e.RESET=""}).call(this,t(0))},function(n,e){e.parse=function(n,e){var t={},r=[],arguments=[],i=[],o={};Object.keys(e).forEach(n=>{if(!n.startsWith(" ")){var r=e[n];null!=r.alias&&("string"==typeof r.alias?o[r.alias]=n:Array.isArray(r.alias)&&r.alias.forEach(e=>o[e]=n)),null!=r.default&&(t[n]=r.default)}});for(var a=0,s=(n=n.slice()).length;at[n]=s.value[n])}else r.push(i)}for(;a{var a=n[e];if(null!=a.description){for(var s="";s.length{for(let e=0;e 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nvar splitPathRe =\n /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\nvar splitPath = function(filename) {\n return splitPathRe.exec(filename).slice(1);\n};\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function(path) {\n var result = splitPath(path),\n root = result[0],\n dir = result[1];\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.';\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1);\n }\n\n return root + dir;\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPath(path)[2];\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPath(path)[3];\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/**\r\n * Compiler frontend for node.js\r\n *\r\n * Uses the low-level API exported from src/index.ts so it works with the compiler compiled to\r\n * JavaScript as well as the compiler compiled to WebAssembly (eventually). Runs the sources\r\n * directly through ts-node if distribution files are not present (indicated by a `-dev` version).\r\n *\r\n * Can also be packaged as a bundle suitable for in-browser use with the standard library injected\r\n * in the build step. See dist/asc.js for the bundle and webpack.config.js for building details.\r\n *\r\n * @module cli/asc\r\n */\r\n\r\n// Use \".\" instead of \"/\" as cwd in browsers\r\nif (process.browser) process.cwd = function() { return \".\"; };\r\n\r\nconst fs = require(\"fs\");\r\nconst path = require(\"path\");\r\nconst utf8 = require(\"@protobufjs/utf8\");\r\nconst colorsUtil = require(\"./util/colors\");\r\nconst optionsUtil = require(\"./util/options\");\r\nconst mkdirp = require(\"./util/mkdirp\");\r\nconst EOL = process.platform === \"win32\" ? \"\\r\\n\" : \"\\n\";\r\n\r\n// global.Binaryen = require(\"../lib/binaryen\");\r\n\r\n// Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional\r\n// useless code fragment on top of an actual error. suppress this:\r\nif (process.removeAllListeners) process.removeAllListeners(\"uncaughtException\");\r\n\r\n// Use distribution files if present, otherwise run the sources directly\r\nvar assemblyscript, isDev = false;\r\n(() => {\r\n try { // `asc` on the command line\r\n assemblyscript = require(\"../dist/assemblyscript.js\");\r\n } catch (e) {\r\n try { // `asc` on the command line without dist files\r\n require(\"ts-node\").register({ project: path.join(__dirname, \"..\", \"src\", \"tsconfig.json\") });\r\n require(\"../src/glue/js\");\r\n assemblyscript = require(\"../src\");\r\n isDev = true;\r\n } catch (e_ts) {\r\n try { // `require(\"dist/asc.js\")` in explicit browser tests\r\n assemblyscript = eval(\"require('./assemblyscript')\");\r\n } catch (e) {\r\n // combine both errors that lead us here\r\n e.stack = e_ts.stack + \"\\n---\\n\" + e.stack;\r\n throw e;\r\n }\r\n }\r\n }\r\n})();\r\n\r\n/** Whether this is a webpack bundle or not. */\r\nexports.isBundle = typeof BUNDLE_VERSION === \"string\";\r\n\r\n/** Whether asc runs the sources directly or not. */\r\nexports.isDev = isDev;\r\n\r\n/** AssemblyScript version. */\r\nexports.version = exports.isBundle ? BUNDLE_VERSION : require(\"../package.json\").version;\r\n\r\n/** Available CLI options. */\r\nexports.options = require(\"./asc.json\");\r\n\r\n/** Common root used in source maps. */\r\nexports.sourceMapRoot = \"assemblyscript:///\";\r\n\r\n/** Prefix used for library files. */\r\nexports.libraryPrefix = assemblyscript.LIBRARY_PREFIX;\r\n\r\n/** Default Binaryen optimization level. */\r\nexports.defaultOptimizeLevel = 3;\r\n\r\n/** Default Binaryen shrink level. */\r\nexports.defaultShrinkLevel = 1;\r\n\r\n/** Bundled library files. */\r\nexports.libraryFiles = exports.isBundle ? BUNDLE_LIBRARY : (() => { // set up if not a bundle\r\n const libDir = path.join(__dirname, \"..\", \"std\", \"assembly\");\r\n const libFiles = require(\"glob\").sync(\"**/!(*.d).ts\", { cwd: libDir });\r\n const bundled = {};\r\n libFiles.forEach(file => bundled[file.replace(/\\.ts$/, \"\")] = fs.readFileSync(path.join(libDir, file), \"utf8\" ));\r\n return bundled;\r\n})();\r\n\r\n/** Bundled definition files. */\r\nexports.definitionFiles = exports.isBundle ? BUNDLE_DEFINITIONS : (() => { // set up if not a bundle\r\n const stdDir = path.join(__dirname, \"..\", \"std\");\r\n return {\r\n \"assembly\": fs.readFileSync(path.join(stdDir, \"assembly\", \"index.d.ts\"), \"utf8\"),\r\n \"portable\": fs.readFileSync(path.join(stdDir, \"portable\", \"index.d.ts\"), \"utf8\")\r\n };\r\n})();\r\n\r\n/** Convenience function that parses and compiles source strings directly. */\r\nexports.compileString = (sources, options) => {\r\n if (typeof sources === \"string\") sources = { \"input.ts\": sources };\r\n const output = Object.create({\r\n stdout: createMemoryStream(),\r\n stderr: createMemoryStream()\r\n });\r\n var argv = [\r\n \"--binaryFile\", \"binary\",\r\n \"--textFile\", \"text\",\r\n ];\r\n Object.keys(options || {}).forEach(key => {\r\n var val = options[key];\r\n if (Array.isArray(val)) val.forEach(val => argv.push(\"--\" + key, String(val)));\r\n else argv.push(\"--\" + key, String(val));\r\n });\r\n exports.main(argv.concat(Object.keys(sources)), {\r\n stdout: output.stdout,\r\n stderr: output.stderr,\r\n readFile: name => sources.hasOwnProperty(name) ? sources[name] : null,\r\n writeFile: (name, contents) => output[name] = contents,\r\n listFiles: () => []\r\n });\r\n return output;\r\n}\r\n\r\n/** Runs the command line utility using the specified arguments array. */\r\nexports.main = function main(argv, options, callback) {\r\n if (typeof options === \"function\") {\r\n callback = options;\r\n options = {};\r\n } else if (!options) {\r\n options = {};\r\n }\r\n\r\n const stdout = options.stdout || process.stdout;\r\n const stderr = options.stderr || process.stderr;\r\n const readFile = options.readFile || readFileNode;\r\n const writeFile = options.writeFile || writeFileNode;\r\n const listFiles = options.listFiles || listFilesNode;\r\n const stats = options.stats || createStats();\r\n\r\n // Output must be specified if not present in the environment\r\n if (!stdout) throw Error(\"'options.stdout' must be specified\");\r\n if (!stderr) throw Error(\"'options.stderr' must be specified\");\r\n\r\n const opts = optionsUtil.parse(argv, exports.options);\r\n const args = opts.options;\r\n argv = opts.arguments;\r\n if (args.noColors) {\r\n colorsUtil.stdout.supported =\r\n colorsUtil.stderr.supported = false;\r\n } else {\r\n colorsUtil.stdout = colorsUtil.from(stdout);\r\n colorsUtil.stderr = colorsUtil.from(stderr);\r\n }\r\n\r\n // Check for unknown arguments\r\n if (opts.unknown.length) {\r\n opts.unknown.forEach(arg => {\r\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unknown option '\" + arg + \"'\" + EOL);\r\n });\r\n }\r\n\r\n // Check for trailing arguments\r\n if (opts.trailing.length) {\r\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unsupported trailing arguments: \" + opts.trailing.join(\" \") + EOL);\r\n }\r\n\r\n // Use default callback if none is provided\r\n if (!callback) callback = function defaultCallback(err) {\r\n var code = 0;\r\n if (err) {\r\n stderr.write(colorsUtil.stderr.red(\"ERROR: \") + err.stack.replace(/^ERROR: /i, \"\") + EOL);\r\n code = 1;\r\n }\r\n return code;\r\n };\r\n\r\n // Just print the version if requested\r\n if (args.version) {\r\n stdout.write(\"Version \" + exports.version + (isDev ? \"-dev\" : \"\") + EOL);\r\n return callback(null);\r\n }\r\n // Print the help message if requested or no source files are provided\r\n if (args.help || !argv.length) {\r\n var out = args.help ? stdout : stderr;\r\n var color = args.help ? colorsUtil.stdout : colorsUtil.stderr;\r\n out.write([\r\n color.white(\"SYNTAX\"),\r\n \" \" + color.cyan(\"asc\") + \" [entryFile ...] [options]\",\r\n \"\",\r\n color.white(\"EXAMPLES\"),\r\n \" \" + color.cyan(\"asc\") + \" hello.ts\",\r\n \" \" + color.cyan(\"asc\") + \" hello.ts -b hello.wasm -t hello.wat\",\r\n \" \" + color.cyan(\"asc\") + \" hello1.ts hello2.ts -b -O > hello.wasm\",\r\n \"\",\r\n color.white(\"OPTIONS\"),\r\n ].concat(\r\n optionsUtil.help(exports.options, 24, EOL)\r\n ).join(EOL) + EOL);\r\n return callback(null);\r\n }\r\n\r\n // I/O must be specified if not present in the environment\r\n if (!fs.readFileSync) {\r\n if (readFile === readFileNode) throw Error(\"'options.readFile' must be specified\");\r\n if (writeFile === writeFileNode) throw Error(\"'options.writeFile' must be specified\");\r\n if (listFiles === listFilesNode) throw Error(\"'options.listFiles' must be specified\");\r\n }\r\n\r\n // Set up base directory\r\n const baseDir = args.baseDir ? path.resolve(args.baseDir) : \".\";\r\n\r\n // Set up transforms\r\n const transforms = [];\r\n if (args.transform) {\r\n args.transform.forEach(transform =>\r\n transforms.push(\r\n require(\r\n path.isAbsolute(transform = transform.trim())\r\n ? transform\r\n : path.join(process.cwd(), transform)\r\n )\r\n )\r\n );\r\n }\r\n function applyTransform(name, ...args) {\r\n transforms.forEach(transform => {\r\n if (typeof transform[name] === \"function\") transform[name](...args);\r\n });\r\n }\r\n\r\n // Begin parsing\r\n var parser = null;\r\n\r\n // Include library files\r\n Object.keys(exports.libraryFiles).forEach(libPath => {\r\n if (libPath.indexOf(\"/\") >= 0) return; // in sub-directory: imported on demand\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(\r\n exports.libraryFiles[libPath],\r\n exports.libraryPrefix + libPath + \".ts\",\r\n false,\r\n parser\r\n );\r\n });\r\n });\r\n const customLibDirs = [];\r\n if (args.lib) {\r\n let lib = args.lib;\r\n if (typeof lib === \"string\") lib = lib.split(\",\");\r\n Array.prototype.push.apply(customLibDirs, lib.map(lib => lib.trim()));\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) { // custom\r\n let libDir = customLibDirs[i];\r\n let libFiles;\r\n if (libDir.endsWith(\".ts\")) {\r\n libFiles = [ path.basename(libDir) ];\r\n libDir = path.dirname(libDir);\r\n } else {\r\n libFiles = listFiles(libDir);\r\n }\r\n for (let j = 0, l = libFiles.length; j < l; ++j) {\r\n let libPath = libFiles[j];\r\n let libText = readFile(libPath, libDir);\r\n if (libText === null) return callback(Error(\"Library file '\" + libPath + \"' not found.\"));\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(\r\n libText,\r\n exports.libraryPrefix + libPath,\r\n false,\r\n parser\r\n );\r\n });\r\n }\r\n }\r\n }\r\n\r\n // Parses the backlog of imported files after including entry files\r\n function parseBacklog() {\r\n var sourcePath, sourceText;\r\n while ((sourcePath = parser.nextFile()) != null) {\r\n\r\n // Load library file if explicitly requested\r\n if (sourcePath.startsWith(exports.libraryPrefix)) {\r\n const plainName = sourcePath.substring(exports.libraryPrefix.length);\r\n const indexName = sourcePath.substring(exports.libraryPrefix.length) + \"/index\";\r\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\r\n sourceText = exports.libraryFiles[plainName];\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\r\n sourceText = exports.libraryFiles[indexName];\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n sourceText = readFile(plainName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n break;\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Otherwise try nextFile.ts, nextFile/index.ts, ~lib/nextFile.ts, ~lib/nextFile/index.ts\r\n } else {\r\n const plainName = sourcePath;\r\n const indexName = sourcePath + \"/index\";\r\n sourceText = readFile(plainName + \".ts\", baseDir);\r\n if (sourceText !== null) {\r\n sourcePath = plainName + \".ts\";\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", baseDir);\r\n if (sourceText !== null) {\r\n sourcePath = indexName + \".ts\";\r\n } else if (!plainName.startsWith(\".\")) {\r\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\r\n sourceText = exports.libraryFiles[plainName];\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\r\n sourceText = exports.libraryFiles[indexName];\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n const dir = customLibDirs[i];\r\n sourceText = readFile(plainName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n break;\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n if (sourceText == null) {\r\n return callback(Error(\"Import file '\" + sourcePath + \".ts' not found.\"));\r\n }\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n assemblyscript.parseFile(sourceText, sourcePath, false, parser);\r\n });\r\n }\r\n if (checkDiagnostics(parser, stderr)) {\r\n return callback(Error(\"Parse error\"));\r\n }\r\n }\r\n\r\n // Include runtime template before entry files so its setup runs first\r\n {\r\n let templateName = String(args.runtime);\r\n let templateText = exports.libraryFiles[\"rt/index-\" + templateName];\r\n if (templateText == null) {\r\n templateText = readFile(templateName + \".ts\", baseDir);\r\n if (templateText == null) {\r\n return callback(Error(\"Runtime template '\" + templateName + \"' not found.\"));\r\n }\r\n }\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(templateText, templateName, true, parser);\r\n });\r\n }\r\n\r\n // Include entry files\r\n for (let i = 0, k = argv.length; i < k; ++i) {\r\n const filename = argv[i];\r\n\r\n let sourcePath = String(filename).replace(/\\\\/g, \"/\").replace(/(\\.ts|\\/)$/, \"\");\r\n\r\n // Try entryPath.ts, then entryPath/index.ts\r\n let sourceText = readFile(sourcePath + \".ts\", baseDir);\r\n if (sourceText === null) {\r\n sourceText = readFile(sourcePath + \"/index.ts\", baseDir);\r\n if (sourceText === null) {\r\n return callback(Error(\"Entry file '\" + sourcePath + \".ts' not found.\"));\r\n } else {\r\n sourcePath += \"/index.ts\";\r\n }\r\n } else {\r\n sourcePath += \".ts\";\r\n }\r\n\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);\r\n });\r\n }\r\n\r\n // Parse entry files\r\n {\r\n let code = parseBacklog();\r\n if (code) return code;\r\n }\r\n\r\n // Call afterParse transform hook\r\n applyTransform(\"afterParse\", parser);\r\n\r\n // Parse additional files, if any\r\n {\r\n let code = parseBacklog();\r\n if (code) return code;\r\n }\r\n\r\n // Finish parsing\r\n const program = assemblyscript.finishParsing(parser);\r\n\r\n // Set up optimization levels\r\n var optimizeLevel = 0;\r\n var shrinkLevel = 0;\r\n if (args.optimize) {\r\n optimizeLevel = exports.defaultOptimizeLevel;\r\n shrinkLevel = exports.defaultShrinkLevel;\r\n }\r\n if (typeof args.optimizeLevel === \"number\") {\r\n optimizeLevel = args.optimizeLevel;\r\n }\r\n if (typeof args.shrinkLevel === \"number\") {\r\n shrinkLevel = args.shrinkLevel;\r\n }\r\n optimizeLevel = Math.min(Math.max(optimizeLevel, 0), 3);\r\n shrinkLevel = Math.min(Math.max(shrinkLevel, 0), 2);\r\n\r\n // Begin compilation\r\n const compilerOptions = assemblyscript.createOptions();\r\n assemblyscript.setTarget(compilerOptions, 0);\r\n assemblyscript.setNoAssert(compilerOptions, args.noAssert);\r\n assemblyscript.setImportMemory(compilerOptions, args.importMemory);\r\n assemblyscript.setSharedMemory(compilerOptions, args.sharedMemory);\r\n assemblyscript.setImportTable(compilerOptions, args.importTable);\r\n assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);\r\n assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);\r\n assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel);\r\n\r\n // Initialize default aliases\r\n assemblyscript.setGlobalAlias(compilerOptions, \"Math\", \"NativeMath\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"Mathf\", \"NativeMathf\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"abort\", \"~lib/builtins/abort\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"trace\", \"~lib/builtins/trace\");\r\n\r\n // Add or override aliases if specified\r\n if (args.use) {\r\n let aliases = args.use;\r\n for (let i = 0, k = aliases.length; i < k; ++i) {\r\n let part = aliases[i];\r\n let p = part.indexOf(\"=\");\r\n if (p < 0) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\r\n let name = part.substring(0, p).trim();\r\n let alias = part.substring(p + 1).trim();\r\n if (!name.length) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\r\n assemblyscript.setGlobalAlias(compilerOptions, name, alias);\r\n }\r\n }\r\n\r\n // Enable additional features if specified\r\n var features = args.enable;\r\n if (features != null) {\r\n if (typeof features === \"string\") features = features.split(\",\");\r\n for (let i = 0, k = features.length; i < k; ++i) {\r\n let name = features[i].trim();\r\n let flag = assemblyscript[\"FEATURE_\" + name.replace(/\\-/g, \"_\").toUpperCase()];\r\n if (!flag) return callback(Error(\"Feature '\" + name + \"' is unknown.\"));\r\n assemblyscript.enableFeature(compilerOptions, flag);\r\n }\r\n }\r\n\r\n var module;\r\n stats.compileCount++;\r\n try {\r\n stats.compileTime += measure(() => {\r\n module = assemblyscript.compileProgram(program, compilerOptions);\r\n });\r\n } catch (e) {\r\n return callback(e);\r\n }\r\n if (checkDiagnostics(parser, stderr)) {\r\n if (module) module.dispose();\r\n return callback(Error(\"Compile error\"));\r\n }\r\n\r\n // Validate the module if requested\r\n if (args.validate) {\r\n stats.validateCount++;\r\n stats.validateTime += measure(() => {\r\n if (!module.validate()) {\r\n module.dispose();\r\n return callback(Error(\"Validate error\"));\r\n }\r\n });\r\n }\r\n\r\n // Set Binaryen-specific options\r\n if (args.trapMode === \"clamp\") {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses([ \"trap-mode-clamp\" ]);\r\n });\r\n } else if (args.trapMode === \"js\") {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses([ \"trap-mode-js\" ]);\r\n });\r\n } else if (args.trapMode !== \"allow\") {\r\n module.dispose();\r\n return callback(Error(\"Unsupported trap mode\"));\r\n }\r\n\r\n // Implicitly run costly non-LLVM optimizations on -O3 or -Oz\r\n // see: https://github.com/WebAssembly/binaryen/pull/1596\r\n if (optimizeLevel >= 3 || shrinkLevel >= 2) optimizeLevel = 4;\r\n\r\n module.setOptimizeLevel(optimizeLevel);\r\n module.setShrinkLevel(shrinkLevel);\r\n module.setDebugInfo(args.debug);\r\n\r\n var runPasses = [];\r\n if (args.runPasses) {\r\n if (typeof args.runPasses === \"string\") {\r\n args.runPasses = args.runPasses.split(\",\");\r\n }\r\n if (args.runPasses.length) {\r\n args.runPasses.forEach(pass => {\r\n if (runPasses.indexOf(pass) < 0)\r\n runPasses.push(pass);\r\n });\r\n }\r\n }\r\n\r\n // Optimize the module if requested\r\n if (optimizeLevel > 0 || shrinkLevel > 0) {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.optimize();\r\n });\r\n }\r\n\r\n // Run additional passes if requested\r\n if (runPasses.length) {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses(runPasses.map(pass => pass.trim()));\r\n });\r\n }\r\n\r\n // Prepare output\r\n if (!args.noEmit) {\r\n let hasStdout = false;\r\n let hasOutput = false;\r\n\r\n if (args.outFile != null) {\r\n if (/\\.was?t$/.test(args.outFile) && args.textFile == null) {\r\n args.textFile = args.outFile;\r\n } else if (/\\.js$/.test(args.outFile) && args.asmjsFile == null) {\r\n args.asmjsFile = args.outFile;\r\n } else if (args.binaryFile == null) {\r\n args.binaryFile = args.outFile;\r\n }\r\n }\r\n\r\n // Write binary\r\n if (args.binaryFile != null) {\r\n let sourceMapURL = args.sourceMap != null\r\n ? args.sourceMap.length\r\n ? args.sourceMap\r\n : path.basename(args.binaryFile) + \".map\"\r\n : null;\r\n\r\n let wasm;\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wasm = module.toBinary(sourceMapURL)\r\n });\r\n\r\n if (args.binaryFile.length) {\r\n writeFile(args.binaryFile, wasm.output, baseDir);\r\n } else {\r\n writeStdout(wasm.output);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n\r\n // Post-process source map\r\n if (wasm.sourceMap != null) {\r\n if (args.binaryFile.length) {\r\n let sourceMap = JSON.parse(wasm.sourceMap);\r\n sourceMap.sourceRoot = exports.sourceMapRoot;\r\n sourceMap.sources.forEach((name, index) => {\r\n let text = null;\r\n if (name.startsWith(exports.libraryPrefix)) {\r\n let stdName = name.substring(exports.libraryPrefix.length).replace(/\\.ts$/, \"\");\r\n if (exports.libraryFiles.hasOwnProperty(stdName)) {\r\n text = exports.libraryFiles[stdName];\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n text = readFile(name.substring(exports.libraryPrefix.length), customLibDirs[i]);\r\n if (text !== null) break;\r\n }\r\n }\r\n } else {\r\n text = readFile(name, baseDir);\r\n }\r\n if (text === null) {\r\n return callback(Error(\"Source file '\" + name + \"' not found.\"));\r\n }\r\n if (!sourceMap.sourceContents) sourceMap.sourceContents = [];\r\n sourceMap.sourceContents[index] = text;\r\n });\r\n writeFile(path.join(\r\n path.dirname(args.binaryFile),\r\n path.basename(sourceMapURL)\r\n ).replace(/^\\.\\//, \"\"), JSON.stringify(sourceMap), baseDir);\r\n } else {\r\n stderr.write(\"Skipped source map (stdout already occupied)\" + EOL);\r\n }\r\n }\r\n }\r\n\r\n // Write asm.js\r\n if (args.asmjsFile != null) {\r\n let asm;\r\n if (args.asmjsFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n asm = module.toAsmjs();\r\n });\r\n writeFile(args.asmjsFile, asm, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n asm = module.toAsmjs();\r\n });\r\n writeStdout(asm);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write WebIDL\r\n if (args.idlFile != null) {\r\n let idl;\r\n if (args.idlFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n idl = assemblyscript.buildIDL(program);\r\n });\r\n writeFile(args.idlFile, idl, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n idl = assemblyscript.buildIDL(program);\r\n });\r\n writeStdout(idl);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write TypeScript definition\r\n if (args.tsdFile != null) {\r\n let tsd;\r\n if (args.tsdFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n tsd = assemblyscript.buildTSD(program);\r\n });\r\n writeFile(args.tsdFile, tsd, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n tsd = assemblyscript.buildTSD(program);\r\n });\r\n writeStdout(tsd);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write text (must be last)\r\n if (args.textFile != null || !hasOutput) {\r\n let wat;\r\n if (args.textFile && args.textFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wat = module.toText();\r\n });\r\n writeFile(args.textFile, wat, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wat = module.toText()\r\n });\r\n writeStdout(wat);\r\n }\r\n }\r\n }\r\n\r\n module.dispose();\r\n if (args.measure) {\r\n printStats(stats, stderr);\r\n }\r\n return callback(null);\r\n\r\n function readFileNode(filename, baseDir) {\r\n try {\r\n let text;\r\n stats.readCount++;\r\n stats.readTime += measure(() => {\r\n text = fs.readFileSync(path.join(baseDir, filename), { encoding: \"utf8\" });\r\n });\r\n return text;\r\n } catch (e) {\r\n return null;\r\n }\r\n }\r\n\r\n function writeFileNode(filename, contents, baseDir) {\r\n try {\r\n stats.writeCount++;\r\n stats.writeTime += measure(() => {\r\n mkdirp(path.join(baseDir, path.dirname(filename)));\r\n if (typeof contents === \"string\") {\r\n fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: \"utf8\" } );\r\n } else {\r\n fs.writeFileSync(path.join(baseDir, filename), contents);\r\n }\r\n });\r\n return true;\r\n } catch (e) {\r\n return false;\r\n }\r\n }\r\n\r\n function listFilesNode(dirname, baseDir) {\r\n var files;\r\n try {\r\n stats.readTime += measure(() => {\r\n files = fs.readdirSync(path.join(baseDir, dirname)).filter(file => /^(?!.*\\.d\\.ts$).*\\.ts$/.test(file));\r\n });\r\n return files;\r\n } catch (e) {\r\n return [];\r\n }\r\n }\r\n\r\n function writeStdout(contents) {\r\n if (!writeStdout.used) {\r\n stats.writeCount++;\r\n writeStdout.used = true;\r\n }\r\n stats.writeTime += measure(() => {\r\n if (typeof contents === \"string\") {\r\n stdout.write(contents, { encoding: \"utf8\" });\r\n } else {\r\n stdout.write(contents);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/** Checks diagnostics emitted so far for errors. */\r\nfunction checkDiagnostics(emitter, stderr) {\r\n var diagnostic;\r\n var hasErrors = false;\r\n while ((diagnostic = assemblyscript.nextDiagnostic(emitter)) != null) {\r\n if (stderr) {\r\n stderr.write(\r\n assemblyscript.formatDiagnostic(diagnostic, stderr.isTTY, true) +\r\n EOL + EOL\r\n );\r\n }\r\n if (assemblyscript.isError(diagnostic)) hasErrors = true;\r\n }\r\n return hasErrors;\r\n}\r\n\r\nexports.checkDiagnostics = checkDiagnostics;\r\n\r\n/** Creates an empty set of stats. */\r\nfunction createStats() {\r\n return {\r\n readTime: 0,\r\n readCount: 0,\r\n writeTime: 0,\r\n writeCount: 0,\r\n parseTime: 0,\r\n parseCount: 0,\r\n compileTime: 0,\r\n compileCount: 0,\r\n emitTime: 0,\r\n emitCount: 0,\r\n validateTime: 0,\r\n validateCount: 0,\r\n optimizeTime: 0,\r\n optimizeCount: 0\r\n };\r\n}\r\n\r\nexports.createStats = createStats;\r\n\r\nif (!process.hrtime) process.hrtime = require(\"browser-process-hrtime\");\r\n\r\n/** Measures the execution time of the specified function. */\r\nfunction measure(fn) {\r\n const start = process.hrtime();\r\n fn();\r\n const times = process.hrtime(start);\r\n return times[0] * 1e9 + times[1];\r\n}\r\n\r\nexports.measure = measure;\r\n\r\n/** Formats a high resolution time to a human readable string. */\r\nfunction formatTime(time) {\r\n return time ? (time / 1e6).toFixed(3) + \" ms\" : \"N/A\";\r\n}\r\n\r\nexports.formatTime = formatTime;\r\n\r\n/** Formats and prints out the contents of a set of stats. */\r\nfunction printStats(stats, output) {\r\n function format(time, count) {\r\n return formatTime(time);\r\n }\r\n (output || process.stdout).write([\r\n \"I/O Read : \" + format(stats.readTime, stats.readCount),\r\n \"I/O Write : \" + format(stats.writeTime, stats.writeCount),\r\n \"Parse : \" + format(stats.parseTime, stats.parseCount),\r\n \"Compile : \" + format(stats.compileTime, stats.compileCount),\r\n \"Emit : \" + format(stats.emitTime, stats.emitCount),\r\n \"Validate : \" + format(stats.validateTime, stats.validateCount),\r\n \"Optimize : \" + format(stats.optimizeTime, stats.optimizeCount)\r\n ].join(EOL) + EOL);\r\n}\r\n\r\nexports.printStats = printStats;\r\n\r\nvar allocBuffer = typeof global !== \"undefined\" && global.Buffer\r\n ? global.Buffer.allocUnsafe || function(len) { return new global.Buffer(len); }\r\n : function(len) { return new Uint8Array(len) };\r\n\r\n/** Creates a memory stream that can be used in place of stdout/stderr. */\r\nfunction createMemoryStream(fn) {\r\n var stream = [];\r\n stream.write = function(chunk) {\r\n if (fn) fn(chunk);\r\n if (typeof chunk === \"string\") {\r\n let buffer = allocBuffer(utf8.length(chunk));\r\n utf8.write(chunk, buffer, 0);\r\n chunk = buffer;\r\n }\r\n this.push(chunk);\r\n };\r\n stream.reset = function() {\r\n stream.length = 0;\r\n };\r\n stream.toBuffer = function() {\r\n var offset = 0, i = 0, k = this.length;\r\n while (i < k) offset += this[i++].length;\r\n var buffer = allocBuffer(offset);\r\n offset = i = 0;\r\n while (i < k) {\r\n buffer.set(this[i], offset);\r\n offset += this[i].length;\r\n ++i;\r\n }\r\n return buffer;\r\n };\r\n stream.toString = function() {\r\n var buffer = this.toBuffer();\r\n return utf8.read(buffer, 0, buffer.length);\r\n };\r\n return stream;\r\n}\r\n\r\nexports.createMemoryStream = createMemoryStream;\r\n\r\n/** Compatible TypeScript compiler options for syntax highlighting etc. */\r\nexports.tscOptions = {\r\n alwaysStrict: true,\r\n noImplicitAny: true,\r\n noImplicitReturns: true,\r\n noImplicitThis: true,\r\n noEmitOnError: true,\r\n strictNullChecks: true,\r\n experimentalDecorators: true,\r\n target: \"esnext\",\r\n module: \"commonjs\",\r\n noLib: true,\r\n types: [],\r\n allowJs: false\r\n};\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal UTF8 implementation for number arrays.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar utf8 = exports;\r\n\r\n/**\r\n * Calculates the UTF8 byte length of a string.\r\n * @param {string} string String\r\n * @returns {number} Byte length\r\n */\r\nutf8.length = function utf8_length(string) {\r\n var len = 0,\r\n c = 0;\r\n for (var i = 0; i < string.length; ++i) {\r\n c = string.charCodeAt(i);\r\n if (c < 128)\r\n len += 1;\r\n else if (c < 2048)\r\n len += 2;\r\n else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {\r\n ++i;\r\n len += 4;\r\n } else\r\n len += 3;\r\n }\r\n return len;\r\n};\r\n\r\n/**\r\n * Reads UTF8 bytes as a string.\r\n * @param {Uint8Array} buffer Source buffer\r\n * @param {number} start Source start\r\n * @param {number} end Source end\r\n * @returns {string} String read\r\n */\r\nutf8.read = function utf8_read(buffer, start, end) {\r\n var len = end - start;\r\n if (len < 1)\r\n return \"\";\r\n var parts = null,\r\n chunk = [],\r\n i = 0, // char offset\r\n t; // temporary\r\n while (start < end) {\r\n t = buffer[start++];\r\n if (t < 128)\r\n chunk[i++] = t;\r\n else if (t > 191 && t < 224)\r\n chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;\r\n else if (t > 239 && t < 365) {\r\n t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;\r\n chunk[i++] = 0xD800 + (t >> 10);\r\n chunk[i++] = 0xDC00 + (t & 1023);\r\n } else\r\n chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;\r\n if (i > 8191) {\r\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\r\n i = 0;\r\n }\r\n }\r\n if (parts) {\r\n if (i)\r\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\r\n return parts.join(\"\");\r\n }\r\n return String.fromCharCode.apply(String, chunk.slice(0, i));\r\n};\r\n\r\n/**\r\n * Writes a string as UTF8 bytes.\r\n * @param {string} string Source string\r\n * @param {Uint8Array} buffer Destination buffer\r\n * @param {number} offset Destination offset\r\n * @returns {number} Bytes written\r\n */\r\nutf8.write = function utf8_write(string, buffer, offset) {\r\n var start = offset,\r\n c1, // character 1\r\n c2; // character 2\r\n for (var i = 0; i < string.length; ++i) {\r\n c1 = string.charCodeAt(i);\r\n if (c1 < 128) {\r\n buffer[offset++] = c1;\r\n } else if (c1 < 2048) {\r\n buffer[offset++] = c1 >> 6 | 192;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {\r\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\r\n ++i;\r\n buffer[offset++] = c1 >> 18 | 240;\r\n buffer[offset++] = c1 >> 12 & 63 | 128;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else {\r\n buffer[offset++] = c1 >> 12 | 224;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n }\r\n }\r\n return offset - start;\r\n};\r\n","var proc = typeof process !== \"undefined\" && process || {};\r\nvar isCI = proc.env && \"CI\" in proc.env; // doesn't work when bundled because 'process' is a mock\r\n\r\nfunction from(stream, base) {\r\n var colors = base || {};\r\n colors.supported = (stream && !!stream.isTTY) || isCI;\r\n colors.gray = text => colors.supported ? exports.GRAY + text + exports.RESET : text;\r\n colors.red = text => colors.supported ? exports.RED + text + exports.RESET : text;\r\n colors.green = text => colors.supported ? exports.GREEN + text + exports.RESET : text;\r\n colors.yellow = text => colors.supported ? exports.YELLOW + text + exports.RESET : text;\r\n colors.blue = text => colors.supported ? exports.BLUE + text + exports.RESET : text;\r\n colors.magenta = text => colors.supported ? exports.MAGENTA + text + exports.RESET : text;\r\n colors.cyan = text => colors.supported ? exports.CYAN + text + exports.RESET : text;\r\n colors.white = text => colors.supported ? exports.WHITE + text + exports.RESET : text;\r\n return colors;\r\n}\r\n\r\nexports.stdout = from(proc.stdout, exports);\r\nexports.stderr = from(proc.stderr);\r\nexports.from = from;\r\n\r\nexports.GRAY = \"\\u001b[90m\";\r\nexports.RED = \"\\u001b[91m\";\r\nexports.GREEN = \"\\u001b[92m\";\r\nexports.YELLOW = \"\\u001b[93m\";\r\nexports.BLUE = \"\\u001b[94m\";\r\nexports.MAGENTA = \"\\u001b[95m\";\r\nexports.CYAN = \"\\u001b[96m\";\r\nexports.WHITE = \"\\u001b[97m\";\r\nexports.RESET = \"\\u001b[0m\";\r\n","// type | meaning\r\n// -----|---------------\r\n// b | boolean\r\n// i | integer\r\n// f | float\r\n// s | string\r\n// I | integer array\r\n// F | float array\r\n// S | string array\r\n\r\n/** Parses the specified command line arguments according to the given configuration. */\r\nfunction parse(argv, config) {\r\n var options = {};\r\n var unknown = [];\r\n var arguments = [];\r\n var trailing = [];\r\n\r\n // make an alias map and initialize defaults\r\n var aliases = {};\r\n Object.keys(config).forEach(key => {\r\n if (key.startsWith(\" \")) return;\r\n var option = config[key];\r\n if (option.alias != null) {\r\n if (typeof option.alias === \"string\") aliases[option.alias] = key;\r\n else if (Array.isArray(option.alias)) option.alias.forEach(alias => aliases[alias] = key);\r\n }\r\n if (option.default != null) options[key] = option.default;\r\n });\r\n\r\n // iterate over argv\r\n for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {\r\n let arg = argv[i];\r\n if (arg == \"--\") { ++i; break; }\r\n let match = /^(?:(\\-\\w)(?:=(.*))?|(\\-\\-\\w{2,})(?:=(.*))?)$/.exec(arg), option, key;\r\n if (match) {\r\n if (config[arg]) option = config[key = arg]; // exact\r\n else if (match[1] != null) { // alias\r\n option = config[key = aliases[match[1].substring(1)]];\r\n if (option && match[2] != null) argv[i--] = match[2];\r\n } else if (match[3] != null) { // full\r\n option = config[key = match[3].substring(2)];\r\n if (option && match[4] != null) argv[i--] = match[4];\r\n }\r\n } else {\r\n if (arg.charCodeAt(0) == 45) option = config[key = arg]; // exact\r\n else { arguments.push(arg); continue; } // argument\r\n }\r\n if (option) {\r\n if (option.type == null || option.type === \"b\") options[key] = true; // flag\r\n else {\r\n if (i + 1 < argv.length && argv[i + 1].charCodeAt(0) != 45) { // present\r\n switch (option.type) {\r\n case \"i\": options[key] = parseInt(argv[++i], 10); break;\r\n case \"I\": options[key] = (options[key] || []).concat(parseInt(argv[++i], 10)); break;\r\n case \"f\": options[key] = parseFloat(argv[++i]); break;\r\n case \"F\": options[key] = (options[key] || []).concat(parseFloat(argv[++i])); break;\r\n case \"s\": options[key] = String(argv[++i]); break;\r\n case \"S\": options[key] = (options[key] || []).concat(argv[++i].split(\",\")); break;\r\n default: unknown.push(arg); --i;\r\n }\r\n } else { // omitted\r\n switch (option.type) {\r\n case \"i\":\r\n case \"f\": options[key] = option.default || 0; break;\r\n case \"s\": options[key] = option.default || \"\"; break;\r\n case \"I\":\r\n case \"F\":\r\n case \"S\": options[key] = options.default || []; break;\r\n default: unknown.push(arg);\r\n }\r\n }\r\n }\r\n if (option.value) Object.keys(option.value).forEach(k => options[k] = option.value[k]);\r\n } else unknown.push(arg);\r\n }\r\n while (i < k) trailing.push(argv[i++]); // trailing\r\n\r\n return { options, unknown, arguments, trailing };\r\n}\r\n\r\nexports.parse = parse;\r\n\r\n/** Generates the help text for the specified configuration. */\r\nfunction help(config, options) {\r\n if (!options) options = {};\r\n var indent = options.indent || 2;\r\n var padding = options.padding || 24;\r\n var eol = options.eol || \"\\n\";\r\n var sb = [];\r\n Object.keys(config).forEach(key => {\r\n var option = config[key];\r\n if (option.description == null) return;\r\n var text = \"\";\r\n while (text.length < indent) text += \" \";\r\n text += \"--\" + key;\r\n if (option.alias) text += \", -\" + option.alias;\r\n while (text.length < padding) text += \" \";\r\n if (Array.isArray(option.description)) {\r\n sb.push(text + option.description[0] + option.description.slice(1).map(line => {\r\n for (let i = 0; i < padding; ++i) line = \" \" + line;\r\n return eol + line;\r\n }).join(\"\"));\r\n } else sb.push(text + option.description);\r\n });\r\n return sb.join(eol);\r\n}\r\n\r\nexports.help = help;\r\n","/*\r\nCopyright 2010 James Halliday (mail@substack.net)\r\n\r\nThis project is free software released under the MIT/X11 license:\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n*/\r\n\r\nvar path = require(\"path\");\r\nvar fs = require(\"fs\");\r\nvar _0777 = parseInt(\"0777\", 8);\r\n\r\nmodule.exports = function mkdirp(p, opts, made) {\r\n if (!opts || typeof opts !== \"object\") {\r\n opts = { mode: opts };\r\n }\r\n var mode = opts.mode;\r\n if (mode === undefined) {\r\n mode = _0777 & (~process.umask());\r\n }\r\n if (!made) made = null;\r\n p = path.resolve(p);\r\n try {\r\n fs.mkdirSync(p, mode);\r\n made = made || p;\r\n } catch (err0) {\r\n switch (err0.code) {\r\n case \"ENOENT\":\r\n made = mkdirp(path.dirname(p), opts, made);\r\n mkdirp(p, opts, made);\r\n break;\r\n default:\r\n var stat;\r\n try {\r\n stat = fs.statSync(p);\r\n } catch (err1) {\r\n throw err0;\r\n }\r\n if (!stat.isDirectory()) throw err0;\r\n break;\r\n }\r\n }\r\n return made;\r\n};\r\n","if(typeof __WEBPACK_EXTERNAL_MODULE__10__ === 'undefined') {var e = new Error(\"Cannot find module 'assemblyscript'\"); e.code = 'MODULE_NOT_FOUND'; throw e;}\nmodule.exports = __WEBPACK_EXTERNAL_MODULE__10__;","function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = 12;","module.exports = process.hrtime || hrtime\n\n// polyfil for window.performance.now\nvar performance = global.performance || {}\nvar performanceNow =\n performance.now ||\n performance.mozNow ||\n performance.msNow ||\n performance.oNow ||\n performance.webkitNow ||\n function(){ return (new Date()).getTime() }\n\n// generate timestamp or delta\n// see http://nodejs.org/api/process.html#process_process_hrtime\nfunction hrtime(previousTimestamp){\n var clocktime = performanceNow.call(performance)*1e-3\n var seconds = Math.floor(clocktime)\n var nanoseconds = Math.floor((clocktime%1)*1e9)\n if (previousTimestamp) {\n seconds = seconds - previousTimestamp[0]\n nanoseconds = nanoseconds - previousTimestamp[1]\n if (nanoseconds<0) {\n seconds--\n nanoseconds += 1e9\n }\n }\n return [seconds,nanoseconds]\n}"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://asc/webpack/universalModuleDefinition","webpack://asc/webpack/bootstrap","webpack://asc/../node_modules/node-libs-browser/mock/process.js","webpack://asc/../node_modules/path-browserify/index.js","webpack://asc/../node_modules/webpack/buildin/global.js","webpack://asc/./asc.js","webpack://asc/../node_modules/@protobufjs/utf8/index.js","webpack://asc/./util/colors.js","webpack://asc/./util/options.js","webpack://asc/./util/mkdirp.js","webpack://asc/external \"assemblyscript\"","webpack://asc/. sync","webpack://asc/../node_modules/browser-process-hrtime/index.js"],"names":["root","factory","exports","module","require","e","define","amd","self","this","__WEBPACK_EXTERNAL_MODULE__10__","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","path","cwd","nextTick","fn","setTimeout","platform","arch","execPath","title","pid","browser","env","argv","binding","Error","chdir","dir","resolve","exit","kill","umask","dlopen","uptime","memoryUsage","uvCounters","features","process","normalizeArray","parts","allowAboveRoot","up","length","last","splice","unshift","splitPathRe","splitPath","filename","exec","slice","filter","xs","f","res","push","resolvedPath","resolvedAbsolute","arguments","TypeError","charAt","split","join","normalize","isAbsolute","trailingSlash","substr","paths","Array","index","relative","from","to","trim","arr","start","end","fromParts","toParts","Math","min","samePartsLength","outputParts","concat","sep","delimiter","dirname","result","basename","ext","extname","str","len","g","Function","window","global","fs","utf8","colorsUtil","optionsUtil","mkdirp","EOL","removeAllListeners","assemblyscript","isDev","checkDiagnostics","emitter","stderr","diagnostic","hasErrors","nextDiagnostic","write","formatDiagnostic","isTTY","isError","createStats","readTime","readCount","writeTime","writeCount","parseTime","parseCount","compileTime","compileCount","emitTime","emitCount","validateTime","validateCount","optimizeTime","optimizeCount","measure","hrtime","times","formatTime","time","toFixed","printStats","stats","output","format","count","stdout","code","register","project","e_ts","eval","stack","isBundle","version","options","sourceMapRoot","libraryPrefix","LIBRARY_PREFIX","defaultOptimizeLevel","defaultShrinkLevel","libraryFiles","array","arraybuffer","bindings/Date","bindings/Math","bindings/wasi_unstable","bindings/wasi","builtins","dataview","date","diagnostics","error","fixedarray","heap","iterator","map","math","memory","number","polyfills","regexp","rt","rt/common","rt/index-full","rt/index-half","rt/index-none","rt/index-stub","rt/pure","rt/rtrace","rt/stub","rt/tlsf","set","shared/feature","shared/target","shared/typeinfo","string","symbol","table","typedarray","util/error","util/hash","util/memory","util/number","util/sort","util/string","vector","libDir","libFiles","sync","bundled","forEach","file","replace","readFileSync","definitionFiles","assembly","portable","stdDir","compileString","sources","input.ts","createMemoryStream","keys","val","isArray","String","main","readFile","writeFile","contents","listFiles","callback","readFileNode","writeFileNode","listFilesNode","opts","parse","args","noColors","supported","unknown","arg","yellow","trailing","err","red","help","out","color","white","cyan","baseDir","transforms","transform","parser","libPath","indexOf","parseFile","customLibDirs","lib","apply","k","endsWith","j","libText","parseBacklog","sourcePath","sourceText","nextFile","startsWith","plainName","substring","indexName","templateName","runtime","templateText","applyTransform","program","finishParsing","optimizeLevel","shrinkLevel","optimize","max","compilerOptions","createOptions","setTarget","setNoAssert","noAssert","setImportMemory","importMemory","setSharedMemory","sharedMemory","setImportTable","importTable","setMemoryBase","memoryBase","setSourceMap","sourceMap","setOptimizeLevelHints","setGlobalAlias","use","aliases","part","alias","enable","flag","toUpperCase","enableFeature","compileProgram","dispose","validate","trapMode","runPasses","setOptimizeLevel","setShrinkLevel","setDebugInfo","debug","pass","noEmit","hasStdout","hasOutput","outFile","test","textFile","asmjsFile","binaryFile","wasm","sourceMapURL","toBinary","writeStdout","JSON","sourceRoot","text","stdName","sourceContents","stringify","asm","toAsmjs","idlFile","idl","buildIDL","tsdFile","tsd","buildTSD","wat","toText","encoding","writeFileSync","files","readdirSync","used","allocBuffer","Buffer","allocUnsafe","Uint8Array","stream","chunk","buffer","reset","toBuffer","offset","toString","read","tscOptions","alwaysStrict","noImplicitAny","noImplicitReturns","noImplicitThis","noEmitOnError","strictNullChecks","experimentalDecorators","target","noLib","types","allowJs","charCodeAt","fromCharCode","c1","c2","proc","isCI","base","colors","gray","GRAY","RESET","RED","green","GREEN","YELLOW","blue","BLUE","magenta","MAGENTA","CYAN","WHITE","config","option","default","match","type","parseInt","parseFloat","indent","padding","eol","sb","description","line","_0777","made","undefined","mkdirSync","err0","stat","statSync","err1","isDirectory","webpackEmptyContext","req","id","previousTimestamp","clocktime","performanceNow","performance","seconds","floor","nanoseconds","now","mozNow","msNow","oNow","webkitNow","Date","getTime"],"mappings":"CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,EAAA,WAA0E,IAAM,OAAAG,QAAA,kBAAoC,MAAAC,KAApH,IACA,mBAAAC,eAAAC,IACAD,OAAA,mBAAAL,GACA,iBAAAC,QACAA,QAAA,IAAAD,EAAA,WAA0E,IAAM,OAAAG,QAAA,kBAAoC,MAAAC,KAApH,IAEAL,EAAA,IAAAC,EAAAD,EAAA,gBARA,CASC,oBAAAQ,UAAAC,KAAA,SAAAC,iCACD,mBCTA,IAAAC,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAX,QAGA,IAAAC,EAAAQ,EAAAE,GAAA,CACAC,EAAAD,EACAE,GAAA,EACAb,QAAA,IAUA,OANAc,EAAAH,GAAAI,KAAAd,EAAAD,QAAAC,IAAAD,QAAAU,GAGAT,EAAAY,GAAA,EAGAZ,EAAAD,QA0DA,OArDAU,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAlB,EAAAmB,EAAAC,GACAV,EAAAW,EAAArB,EAAAmB,IACAG,OAAAC,eAAAvB,EAAAmB,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CV,EAAAgB,EAAA,SAAA1B,GACA,oBAAA2B,eAAAC,aACAN,OAAAC,eAAAvB,EAAA2B,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAvB,EAAA,cAAiD6B,OAAA,KAQjDnB,EAAAoB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAAnB,EAAAmB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,iBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAX,OAAAY,OAAA,MAGA,GAFAxB,EAAAgB,EAAAO,GACAX,OAAAC,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAAAN,EAAAnB,EAAAQ,EAAAe,EAAAE,EAAA,SAAAA,GAAgH,OAAAN,EAAAM,IAAqBC,KAAA,KAAAD,IACrI,OAAAF,GAIAvB,EAAA2B,EAAA,SAAApC,GACA,IAAAmB,EAAAnB,KAAA+B,WACA,WAA2B,OAAA/B,EAAA,SAC3B,WAAiC,OAAAA,GAEjC,OADAS,EAAAQ,EAAAE,EAAA,IAAAA,GACAA,GAIAV,EAAAW,EAAA,SAAAiB,EAAAC,GAAsD,OAAAjB,OAAAkB,UAAAC,eAAA1B,KAAAuB,EAAAC,IAGtD7B,EAAAgC,EAAA,GAIAhC,IAAAiC,EAAA,qBCnEA,IAEAC,EADAC,EAhBA7C,EAAA8C,SAAA,SAAAC,GACAC,WAAAD,EAAA,IAGA/C,EAAAiD,SAAAjD,EAAAkD,KACAlD,EAAAmD,SAAAnD,EAAAoD,MAAA,UACApD,EAAAqD,IAAA,EACArD,EAAAsD,SAAA,EACAtD,EAAAuD,IAAA,GACAvD,EAAAwD,KAAA,GAEAxD,EAAAyD,QAAA,SAAAtC,GACA,UAAAuC,MAAA,8CAIAb,EAAA,IAEA7C,EAAA6C,IAAA,WAA+B,OAAAA,GAC/B7C,EAAA2D,MAAA,SAAAC,GACAhB,MAA0BlC,EAAQ,IAClCmC,EAAAD,EAAAiB,QAAAD,EAAAf,IAIA7C,EAAA8D,KAAA9D,EAAA+D,KACA/D,EAAAgE,MAAAhE,EAAAiE,OACAjE,EAAAkE,OAAAlE,EAAAmE,YACAnE,EAAAoE,WAAA,aACApE,EAAAqE,SAAA,qBC7BA,SAAAC,GAyBA,SAAAC,EAAAC,EAAAC,GAGA,IADA,IAAAC,EAAA,EACA9D,EAAA4D,EAAAG,OAAA,EAAgC/D,GAAA,EAAQA,IAAA,CACxC,IAAAgE,EAAAJ,EAAA5D,GACA,MAAAgE,EACAJ,EAAAK,OAAAjE,EAAA,GACK,OAAAgE,GACLJ,EAAAK,OAAAjE,EAAA,GACA8D,KACKA,IACLF,EAAAK,OAAAjE,EAAA,GACA8D,KAKA,GAAAD,EACA,KAAUC,IAAMA,EAChBF,EAAAM,QAAA,MAIA,OAAAN,EAKA,IAAAO,EACA,gEACAC,EAAA,SAAAC,GACA,OAAAF,EAAAG,KAAAD,GAAAE,MAAA,IAuJA,SAAAC,EAAAC,EAAAC,GACA,GAAAD,EAAAD,OAAA,OAAAC,EAAAD,OAAAE,GAEA,IADA,IAAAC,EAAA,GACA3E,EAAA,EAAmBA,EAAAyE,EAAAV,OAAe/D,IAClC0E,EAAAD,EAAAzE,KAAAyE,IAAAE,EAAAC,KAAAH,EAAAzE,IAEA,OAAA2E,EAxJAvF,EAAA6D,QAAA,WAIA,IAHA,IAAA4B,EAAA,GACAC,GAAA,EAEA9E,EAAA+E,UAAAhB,OAAA,EAAoC/D,IAAA,IAAA8E,EAA8B9E,IAAA,CAClE,IAAAgC,EAAAhC,GAAA,EAAA+E,UAAA/E,GAAA0D,EAAAzB,MAGA,oBAAAD,EACA,UAAAgD,UAAA,6CACKhD,IAIL6C,EAAA7C,EAAA,IAAA6C,EACAC,EAAA,MAAA9C,EAAAiD,OAAA,IAWA,OAAAH,EAAA,SAJAD,EAAAlB,EAAAa,EAAAK,EAAAK,MAAA,cAAApD,GACA,QAAAA,KACGgD,GAAAK,KAAA,OAEH,KAKA/F,EAAAgG,UAAA,SAAApD,GACA,IAAAqD,EAAAjG,EAAAiG,WAAArD,GACAsD,EAAA,MAAAC,EAAAvD,GAAA,GAcA,OAXAA,EAAA2B,EAAAa,EAAAxC,EAAAkD,MAAA,cAAApD,GACA,QAAAA,KACGuD,GAAAF,KAAA,OAEHE,IACArD,EAAA,KAEAA,GAAAsD,IACAtD,GAAA,MAGAqD,EAAA,QAAArD,GAIA5C,EAAAiG,WAAA,SAAArD,GACA,YAAAA,EAAAiD,OAAA,IAIA7F,EAAA+F,KAAA,WACA,IAAAK,EAAAC,MAAA7D,UAAA2C,MAAApE,KAAA4E,UAAA,GACA,OAAA3F,EAAAgG,UAAAZ,EAAAgB,EAAA,SAAA1D,EAAA4D,GACA,oBAAA5D,EACA,UAAAkD,UAAA,0CAEA,OAAAlD,IACGqD,KAAA,OAMH/F,EAAAuG,SAAA,SAAAC,EAAAC,GAIA,SAAAC,EAAAC,GAEA,IADA,IAAAC,EAAA,EACUA,EAAAD,EAAAhC,QACV,KAAAgC,EAAAC,GAD8BA,KAK9B,IADA,IAAAC,EAAAF,EAAAhC,OAAA,EACUkC,GAAA,GACV,KAAAF,EAAAE,GADoBA,KAIpB,OAAAD,EAAAC,EAAA,GACAF,EAAAxB,MAAAyB,EAAAC,EAAAD,EAAA,GAfAJ,EAAAxG,EAAA6D,QAAA2C,GAAAL,OAAA,GACAM,EAAAzG,EAAA6D,QAAA4C,GAAAN,OAAA,GAsBA,IALA,IAAAW,EAAAJ,EAAAF,EAAAV,MAAA,MACAiB,EAAAL,EAAAD,EAAAX,MAAA,MAEAnB,EAAAqC,KAAAC,IAAAH,EAAAnC,OAAAoC,EAAApC,QACAuC,EAAAvC,EACA/D,EAAA,EAAiBA,EAAA+D,EAAY/D,IAC7B,GAAAkG,EAAAlG,KAAAmG,EAAAnG,GAAA,CACAsG,EAAAtG,EACA,MAIA,IAAAuG,EAAA,GACA,IAAAvG,EAAAsG,EAA+BtG,EAAAkG,EAAAnC,OAAsB/D,IACrDuG,EAAA3B,KAAA,MAKA,OAFA2B,IAAAC,OAAAL,EAAA5B,MAAA+B,KAEAnB,KAAA,MAGA/F,EAAAqH,IAAA,IACArH,EAAAsH,UAAA,IAEAtH,EAAAuH,QAAA,SAAA3E,GACA,IAAA4E,EAAAxC,EAAApC,GACA9C,EAAA0H,EAAA,GACA5D,EAAA4D,EAAA,GAEA,OAAA1H,GAAA8D,GAKAA,IAEAA,IAAAuC,OAAA,EAAAvC,EAAAe,OAAA,IAGA7E,EAAA8D,GARA,KAYA5D,EAAAyH,SAAA,SAAA7E,EAAA8E,GACA,IAAApC,EAAAN,EAAApC,GAAA,GAKA,OAHA8E,GAAApC,EAAAa,QAAA,EAAAuB,EAAA/C,UAAA+C,IACApC,IAAAa,OAAA,EAAAb,EAAAX,OAAA+C,EAAA/C,SAEAW,GAIAtF,EAAA2H,QAAA,SAAA/E,GACA,OAAAoC,EAAApC,GAAA,IAaA,IAAAuD,EAAA,WAAAA,QAAA,GACA,SAAAyB,EAAAhB,EAAAiB,GAAkC,OAAAD,EAAAzB,OAAAS,EAAAiB,IAClC,SAAAD,EAAAhB,EAAAiB,GAEA,OADAjB,EAAA,IAAAA,EAAAgB,EAAAjD,OAAAiC,GACAgB,EAAAzB,OAAAS,EAAAiB,qCC7NA,IAAAC,EAGAA,EAAA,WACA,OAAAvH,KADA,GAIA,IAEAuH,KAAA,IAAAC,SAAA,iBACC,MAAA5H,GAED,iBAAA6H,SAAAF,EAAAE,QAOA/H,EAAAD,QAAA8H,iGCnBA,SAAAxD,QAAA2D,QAcA3D,QAAAhB,UAAAgB,QAAAzB,IAAA,WAA+C,YAE/C,MAAAqF,GAAWxH,oBAAQ,GACnBkC,KAAalC,oBAAQ,GACrByH,KAAazH,oBAAQ,GACrB0H,WAAmB1H,oBAAQ,GAC3B2H,YAAoB3H,oBAAQ,GAC5B4H,OAAe5H,oBAAQ,GACvB6H,IAAA,UAAAjE,QAAArB,SAAA,YAMAqB,QAAAkE,oBAAAlE,QAAAkE,mBAAA,qBAGA,IAAAC,eAAAC,OAAA,EAiuBA,SAAAC,iBAAAC,EAAAC,GAGA,IAFA,IAAAC,EACAC,GAAA,EACA,OAAAD,EAAAL,eAAAO,eAAAJ,KACAC,GACAA,EAAAI,MACAR,eAAAS,iBAAAJ,EAAAD,EAAAM,OAAA,GACAZ,SAGAE,eAAAW,QAAAN,KAAAC,GAAA,GAEA,OAAAA,EAMA,SAAAM,cACA,OACAC,SAAA,EACAC,UAAA,EACAC,UAAA,EACAC,WAAA,EACAC,UAAA,EACAC,WAAA,EACAC,YAAA,EACAC,aAAA,EACAC,SAAA,EACAC,UAAA,EACAC,aAAA,EACAC,cAAA,EACAC,aAAA,EACAC,cAAA,GASA,SAAAC,QAAArH,GACA,MAAA6D,EAAAtC,QAAA+F,SACAtH,IACA,MAAAuH,EAAAhG,QAAA+F,OAAAzD,GACA,WAAA0D,EAAA,GAAAA,EAAA,GAMA,SAAAC,WAAAC,GACA,OAAAA,KAAA,KAAAC,QAAA,eAMA,SAAAC,WAAAC,EAAAC,GACA,SAAAC,EAAAL,EAAAM,GACA,OAAAP,WAAAC,IAEAI,GAAAtG,QAAAyG,QAAA9B,MAAA,CACA,eAAA4B,EAAAF,EAAArB,SAAAqB,EAAApB,WACA,eAAAsB,EAAAF,EAAAnB,UAAAmB,EAAAlB,YACA,eAAAoB,EAAAF,EAAAjB,UAAAiB,EAAAhB,YACA,eAAAkB,EAAAF,EAAAf,YAAAe,EAAAd,cACA,eAAAgB,EAAAF,EAAAb,SAAAa,EAAAZ,WACA,eAAAc,EAAAF,EAAAX,aAAAW,EAAAV,eACA,eAAAY,EAAAF,EAAAT,aAAAS,EAAAR,gBACApE,KAAAwC,UAvyBA,MACA,IACAE,eAAqB/H,oBAAQ,IAC1B,MAAAP,GACH,IACMO,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,sCAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IAAS8K,SAAA,CAAYC,QAAAtI,KAAAmD,KAAoB,IAAS,8BAC1DrF,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,6CAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IACdsI,eAAuB/H,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,qCAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IAC/BuI,OAAA,EACK,MAAAyC,MACL,IACA1C,eAAA2C,KAAA,+BACO,MAAAjL,GAGP,MADAA,EAAAkL,MAAAF,KAAAE,MAAA,UAAAlL,EAAAkL,MACAlL,MAfA,GAsBAH,QAAAsL,UAAmB,EAGnBtL,QAAA0I,YAGA1I,QAAAuL,QAAAvL,QAAAsL,SAAqC,QAAiB5K,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,8CAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IAAiBoL,QAG/EvL,QAAAwL,QAAkB9K,oBAAQ,IAG1BV,QAAAyL,cAAA,qBAGAzL,QAAA0L,cAAAjD,eAAAkD,eAGA3L,QAAA4L,qBAAA,EAGA5L,QAAA6L,mBAAA,EAGA7L,QAAA8L,aAAA9L,QAAAsL,SAA0ChK,OAAA,CAAAyK,MAAA,0qxBAAAC,YAAA,6pFAAAC,gBAAA,iVAAAC,gBAAA,q5DAAAC,yBAAA,ko+CAAAC,gBAAA,qCAAAC,SAAA,wk4CAAAC,SAAA,k2OAAAC,KAAA,upBAAAC,YAAA,4RAAAC,MAAA,itBAAAC,WAAA,88EAAAC,KAAA,+EAAAC,SAAA,ukCAAAC,IAAA,yxOAAAC,KAAA,mn6FAAAC,OAAA,q7DAAAC,OAAA,yiPAAAC,UAAA,ilCAAAC,OAAA,2YAAAC,GAAA,umFAAAC,YAAA,qtDAAAC,gBAAA,6IAAAC,gBAAA,4BAAAC,gBAAA,4BAAAC,gBAAA,kHAAAC,UAAA,krRAAAC,YAAA,uPAAAC,UAAA,46DAAAC,UAAA,knpBAAAC,IAAA,0sMAAAC,iBAAA,6wBAAAC,gBAAA,wTAAAC,kBAAA,ghFAAAC,OAAA,46oBAAAC,OAAA,yyGAAAC,MAAA,2aAAAC,WAAA,i1hCAAAC,aAAA,2sBAAAC,YAAA,0qEAAAC,cAAA,y5PAAAC,cAAA,mrpBAAAC,YAAA,8iJAAAC,cAAA,goGAAAC,OAAA,iEAAc,MACxD,MAAAC,EAAAhM,KAAAmD,KAA2B,IAAS,uBACpC8I,EAAmBnO,qBAAQ,eAAAP,EAAA,IAAAuD,MAAA,mCAAAvD,EAAA6K,KAAA,mBAAA7K,EAAA,IAAM2O,KAAA,gBAAwBjM,IAAA+L,IACzDG,EAAA,GAEA,OADAF,EAAAG,QAAAC,GAAAF,EAAAE,EAAAC,QAAA,aAAAhH,GAAAiH,aAAAvM,KAAAmD,KAAA6I,EAAAK,GAAA,SACAF,GALwD,GASxD/O,QAAAoP,gBAAApP,QAAAsL,SAA6ChK,OAAA,CAAA+N,SAAA,sssFAAAC,SAAA,0z3BAAkB,MAC/D,MAAAC,EAAA3M,KAAAmD,KAA2B,IAAS,YACpC,OACAsJ,SAAAnH,GAAAiH,aAAAvM,KAAAmD,KAAAwJ,EAAA,iCACAD,SAAApH,GAAAiH,aAAAvM,KAAAmD,KAAAwJ,EAAA,mCAJ+D,GAS/DvP,QAAAwP,cAAA,EAAAC,EAAAjE,KACA,iBAAAiE,MAAA,CAA8CC,WAAAD,IAC9C,MAAA7E,EAAAtJ,OAAAY,OAAA,CACA6I,OAAA4E,qBACA9G,OAAA8G,uBAEA,IAAAnM,EAAA,CACA,wBACA,qBAcA,OAZAlC,OAAAsO,KAAApE,GAAA,IAA2BwD,QAAA7M,IAC3B,IAAA0N,EAAArE,EAAArJ,GACAkE,MAAAyJ,QAAAD,KAAAb,QAAAa,GAAArM,EAAAgC,KAAA,KAAArD,EAAA4N,OAAAF,KACArM,EAAAgC,KAAA,KAAArD,EAAA4N,OAAAF,MAEA7P,QAAAgQ,KAAAxM,EAAA4D,OAAA9F,OAAAsO,KAAAH,IAAA,CACA1E,OAAAH,EAAAG,OACAlC,OAAA+B,EAAA/B,OACAoH,SAAA9O,GAAAsO,EAAAhN,eAAAtB,GAAAsO,EAAAtO,GAAA,KACA+O,UAAA,CAAA/O,EAAAgP,IAAAvF,EAAAzJ,GAAAgP,EACAC,UAAA,SAEAxF,IAIA5K,QAAAgQ,KAAA,SAAAxM,EAAAgI,EAAA6E,GACA,mBAAA7E,GACA6E,EAAA7E,EACAA,EAAA,IACGA,IACHA,EAAA,IAGA,MAAAT,EAAAS,EAAAT,QAAAzG,QAAAyG,OACAlC,EAAA2C,EAAA3C,QAAAvE,QAAAuE,OACAoH,EAAAzE,EAAAyE,UAAAK,EACAJ,EAAA1E,EAAA0E,WAAAK,EACAH,EAAA5E,EAAA4E,WAAAI,EACA7F,EAAAa,EAAAb,OAAAtB,cAGA,IAAA0B,EAAA,MAAArH,MAAA,sCACA,IAAAmF,EAAA,MAAAnF,MAAA,sCAEA,MAAA+M,EAAApI,YAAAqI,MAAAlN,EAAAxD,QAAAwL,SACAmF,EAAAF,EAAAjF,QAiCA,GAhCAhI,EAAAiN,EAAA9K,UACAgL,EAAAC,SACAxI,WAAA2C,OAAA8F,UACAzI,WAAAS,OAAAgI,WAAA,GAEAzI,WAAA2C,OAAA3C,WAAA5B,KAAAuE,GACA3C,WAAAS,OAAAT,WAAA5B,KAAAqC,IAIA4H,EAAAK,QAAAnM,QACA8L,EAAAK,QAAA9B,QAAA+B,IACAlI,EAAAI,MAAAb,WAAAS,OAAAmI,OAAA,6BAAAD,EAAA,IAAAxI,OAKAkI,EAAAQ,SAAAtM,QACAkE,EAAAI,MAAAb,WAAAS,OAAAmI,OAAA,6CAAAP,EAAAQ,SAAAlL,KAAA,KAAAwC,KAIA8H,MAAA,SAAAa,GACA,IAAAlG,EAAA,EAKA,OAJAkG,IACArI,EAAAI,MAAAb,WAAAS,OAAAsI,IAAA,WAAAD,EAAA7F,MAAA6D,QAAA,gBAAA3G,KACAyC,EAAA,GAEAA,IAIA2F,EAAApF,QAEA,OADAR,EAAA9B,MAAA,WAAAjJ,QAAAuL,SAAA7C,MAAA,WAAAH,KACA8H,EAAA,MAGA,GAAAM,EAAAS,OAAA5N,EAAAmB,OAAA,CACA,IAAA0M,EAAAV,EAAAS,KAAArG,EAAAlC,EACAyI,EAAAX,EAAAS,KAAAhJ,WAAA2C,OAAA3C,WAAAS,OAcA,OAbAwI,EAAApI,MAAA,CACAqI,EAAAC,MAAA,UACA,KAAAD,EAAAE,KAAA,oCACA,GACAF,EAAAC,MAAA,YACA,KAAAD,EAAAE,KAAA,mBACA,KAAAF,EAAAE,KAAA,8CACA,KAAAF,EAAAE,KAAA,iDACA,GACAF,EAAAC,MAAA,YACAnK,OACAiB,YAAA+I,KAAApR,QAAAwL,QAAA,GAAAjD,MACAxC,KAAAwC,UACA8H,EAAA,MAIA,IAAAnI,GAAAiH,aAAA,CACA,GAAAc,IAAAK,EAAA,MAAA5M,MAAA,wCACA,GAAAwM,IAAAK,EAAA,MAAA7M,MAAA,yCACA,GAAA0M,IAAAI,EAAA,MAAA9M,MAAA,yCAIA,MAAA+N,EAAAd,EAAAc,QAAA7O,KAAAiB,QAAA8M,EAAAc,SAAA,IAGAC,EAAA,GACAf,EAAAgB,WACAhB,EAAAgB,UAAA3C,QAAA2C,GACAD,EAAAlM,KACQ9E,oBAAA,GAAAA,CACEkC,KAAAqD,WAAA0L,IAAAjL,QACViL,EACA/O,KAAAmD,KAAAzB,QAAAzB,MAAA8O,MAYA,IAAAC,EAAA,KAGAtQ,OAAAsO,KAAA5P,QAAA8L,cAAAkD,QAAA6C,IACAA,EAAAC,QAAA,UACAnH,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACAwH,EAAAnJ,eAAAsJ,UACA/R,QAAA8L,aAAA+F,GACA7R,QAAA0L,cAAAmG,EAAA,OACA,EACAD,QAIA,MAAAI,EAAA,GACA,GAAArB,EAAAsB,IAAA,CACA,IAAAA,EAAAtB,EAAAsB,IACA,iBAAAA,QAAAnM,MAAA,MACAO,MAAA7D,UAAAgD,KAAA0M,MAAAF,EAAAC,EAAApF,IAAAoF,KAAAvL,SACA,QAAA9F,EAAA,EAAAuR,EAAAH,EAAArN,OAA6C/D,EAAAuR,IAAOvR,EAAA,CACpD,IACAiO,EADAD,EAAAoD,EAAApR,GAEAgO,EAAAwD,SAAA,QACAvD,EAAA,CAAAjM,KAAA6E,SAAAmH,IACAA,EAAAhM,KAAA2E,QAAAqH,IAEAC,EAAAuB,EAAAxB,GAEA,QAAAyD,EAAA,EAAAxR,EAAAgO,EAAAlK,OAA0C0N,EAAAxR,IAAOwR,EAAA,CACjD,IAAAR,EAAAhD,EAAAwD,GACAC,EAAArC,EAAA4B,EAAAjD,GACA,UAAA0D,EAAA,OAAAjC,EAAA3M,MAAA,iBAAAmO,EAAA,iBACAlH,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACAwH,EAAAnJ,eAAAsJ,UACAO,EACAtS,QAAA0L,cAAAmG,GACA,EACAD,OAQA,SAAAW,IAEA,IADA,IAAAC,EAAAC,EACA,OAAAD,EAAAZ,EAAAc,aAAA,CAGA,GAAAF,EAAAG,WAAA3S,QAAA0L,eAAA,CACA,MAAAkH,EAAAJ,EAAAK,UAAA7S,QAAA0L,cAAA/G,QACAmO,EAAAN,EAAAK,UAAA7S,QAAA0L,cAAA/G,QAAA,SACA,GAAA3E,QAAA8L,aAAArJ,eAAAmQ,GACAH,EAAAzS,QAAA8L,aAAA8G,GACAJ,EAAAxS,QAAA0L,cAAAkH,EAAA,WACS,GAAA5S,QAAA8L,aAAArJ,eAAAqQ,GACTL,EAAAzS,QAAA8L,aAAAgH,GACAN,EAAAxS,QAAA0L,cAAAoH,EAAA,WAEA,QAAAlS,EAAA,EAAAuR,EAAAH,EAAArN,OAAmD/D,EAAAuR,IAAOvR,EAAA,CAE1D,WADA6R,EAAAxC,EAAA2C,EAAA,MAAAZ,EAAApR,KACA,CACA4R,EAAAxS,QAAA0L,cAAAkH,EAAA,MACA,MAGA,WADAH,EAAAxC,EAAA6C,EAAA,MAAAd,EAAApR,KACA,CACA4R,EAAAxS,QAAA0L,cAAAoH,EAAA,MACA,YAOO,CACP,MAAAF,EAAAJ,EACAM,EAAAN,EAAA,SAEA,WADAC,EAAAxC,EAAA2C,EAAA,MAAAnB,IAEAe,EAAAI,EAAA,WAGA,WADAH,EAAAxC,EAAA6C,EAAA,MAAArB,IAEAe,EAAAM,EAAA,WACW,IAAAF,EAAAD,WAAA,KACX,GAAA3S,QAAA8L,aAAArJ,eAAAmQ,GACAH,EAAAzS,QAAA8L,aAAA8G,GACAJ,EAAAxS,QAAA0L,cAAAkH,EAAA,WACa,GAAA5S,QAAA8L,aAAArJ,eAAAqQ,GACbL,EAAAzS,QAAA8L,aAAAgH,GACAN,EAAAxS,QAAA0L,cAAAoH,EAAA,WAEA,QAAAlS,EAAA,EAAAuR,EAAAH,EAAArN,OAAuD/D,EAAAuR,IAAOvR,EAAA,CAC9DoR,EAAApR,GAEA,WADA6R,EAAAxC,EAAA2C,EAAA,MAAAZ,EAAApR,KACA,CACA4R,EAAAxS,QAAA0L,cAAAkH,EAAA,MACA,MAGA,WADAH,EAAAxC,EAAA6C,EAAA,MAAAd,EAAApR,KACA,CACA4R,EAAAxS,QAAA0L,cAAAoH,EAAA,MACA,QAQA,SAAAL,EACA,OAAApC,EAAA3M,MAAA,gBAAA8O,EAAA,oBAEA7H,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACA3B,eAAAsJ,UAAAU,EAAAD,GAAA,EAAAZ,KAGA,GAAAjJ,iBAAAiJ,EAAA/I,GACA,OAAAwH,EAAA3M,MAAA,gBAKA,CACA,IAAAqP,EAAAhD,OAAAY,EAAAqC,SACAC,EAAAjT,QAAA8L,aAAA,YAAAiH,GACA,SAAAE,GAEA,OADAA,EAAAhD,EAAA8C,EAAA,MAAAtB,IAEA,OAAApB,EAAA3M,MAAA,qBAAAqP,EAAA,iBAGApI,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACAwH,EAAAnJ,eAAAsJ,UAAAkB,EAAAF,GAAA,EAAAnB,KAKA,QAAAhR,EAAA,EAAAuR,EAAA3O,EAAAmB,OAAkC/D,EAAAuR,IAAOvR,EAAA,CACzC,MAAAqE,EAAAzB,EAAA5C,GAEA,IAAA4R,EAAAzC,OAAA9K,GAAAiK,QAAA,WAAAA,QAAA,iBAGAuD,EAAAxC,EAAAuC,EAAA,MAAAf,GACA,UAAAgB,EAAA,CAEA,WADAA,EAAAxC,EAAAuC,EAAA,YAAAf,IAEA,OAAApB,EAAA3M,MAAA,eAAA8O,EAAA,oBAEAA,GAAA,iBAGAA,GAAA,MAGA7H,EAAAhB,aACAgB,EAAAjB,WAAAU,QAAA,KACAwH,EAAAnJ,eAAAsJ,UAAAU,EAAAD,GAAA,EAAAZ,KAKA,CACA,IAAA5G,EAAAuH,IACA,GAAAvH,EAAA,OAAAA,GAlLA,SAAA7J,KAAAwP,GACAe,EAAA1C,QAAA2C,IACA,mBAAAA,EAAAxQ,IAAAwQ,EAAAxQ,MAAAwP,KAoLAuC,CAAA,aAAAtB,GAGA,CACA,IAAA5G,EAAAuH,IACA,GAAAvH,EAAA,OAAAA,EAIA,MAAAmI,EAAA1K,eAAA2K,cAAAxB,GAGA,IAAAyB,EAAA,EACAC,EAAA,EACA3C,EAAA4C,WACAF,EAAArT,QAAA4L,qBACA0H,EAAAtT,QAAA6L,oBAEA,iBAAA8E,EAAA0C,gBACAA,EAAA1C,EAAA0C,eAEA,iBAAA1C,EAAA2C,cACAA,EAAA3C,EAAA2C,aAEAD,EAAArM,KAAAC,IAAAD,KAAAwM,IAAAH,EAAA,MACAC,EAAAtM,KAAAC,IAAAD,KAAAwM,IAAAF,EAAA,MAGA,MAAAG,EAAAhL,eAAAiL,gBAiBA,GAhBAjL,eAAAkL,UAAAF,EAAA,GACAhL,eAAAmL,YAAAH,EAAA9C,EAAAkD,UACApL,eAAAqL,gBAAAL,EAAA9C,EAAAoD,cACAtL,eAAAuL,gBAAAP,EAAA9C,EAAAsD,cACAxL,eAAAyL,eAAAT,EAAA9C,EAAAwD,aACA1L,eAAA2L,cAAAX,EAAA9C,EAAA0D,aAAA,GACA5L,eAAA6L,aAAAb,EAAA,MAAA9C,EAAA4D,WACA9L,eAAA+L,sBAAAf,EAAAJ,EAAAC,GAGA7K,eAAAgM,eAAAhB,EAAA,qBACAhL,eAAAgM,eAAAhB,EAAA,uBACAhL,eAAAgM,eAAAhB,EAAA,+BACAhL,eAAAgM,eAAAhB,EAAA,+BAGA9C,EAAA+D,IAAA,CACA,IAAAC,EAAAhE,EAAA+D,IACA,QAAA9T,EAAA,EAAAuR,EAAAwC,EAAAhQ,OAAuC/D,EAAAuR,IAAOvR,EAAA,CAC9C,IAAAgU,EAAAD,EAAA/T,GACA8B,EAAAkS,EAAA9C,QAAA,KACA,GAAApP,EAAA,SAAA2N,EAAA3M,MAAA,iBAAAkR,EAAA,kBACA,IAAAzT,EAAAyT,EAAA/B,UAAA,EAAAnQ,GAAAgE,OACAmO,EAAAD,EAAA/B,UAAAnQ,EAAA,GAAAgE,OACA,IAAAvF,EAAAwD,OAAA,OAAA0L,EAAA3M,MAAA,iBAAAkR,EAAA,kBACAnM,eAAAgM,eAAAhB,EAAAtS,EAAA0T,IAKA,IAWA5U,EAXAoE,EAAAsM,EAAAmE,OACA,SAAAzQ,EAAA,CACA,iBAAAA,QAAAyB,MAAA,MACA,QAAAlF,EAAA,EAAAuR,EAAA9N,EAAAM,OAAwC/D,EAAAuR,IAAOvR,EAAA,CAC/C,IAAAO,EAAAkD,EAAAzD,GAAA8F,OACAqO,EAAAtM,eAAA,WAAAtH,EAAA+N,QAAA,WAAA8F,eACA,IAAAD,EAAA,OAAA1E,EAAA3M,MAAA,YAAAvC,EAAA,kBACAsH,eAAAwM,cAAAxB,EAAAsB,IAKApK,EAAAd,eACA,IACAc,EAAAf,aAAAQ,QAAA,KACAnK,EAAAwI,eAAAyM,eAAA/B,EAAAM,KAEG,MAAAtT,GACH,OAAAkQ,EAAAlQ,GAEA,GAAAwI,iBAAAiJ,EAAA/I,GAEA,OADA5I,KAAAkV,UACA9E,EAAA3M,MAAA,kBAeA,GAXAiN,EAAAyE,WACAzK,EAAAV,gBACAU,EAAAX,cAAAI,QAAA,KACA,IAAAnK,EAAAmV,WAEA,OADAnV,EAAAkV,UACA9E,EAAA3M,MAAA,sBAMA,UAAAiN,EAAA0E,SACA1K,EAAAR,gBACAQ,EAAAT,cAAAE,QAAA,KACAnK,EAAAqV,UAAA,4BAEG,UAAA3E,EAAA0E,SACH1K,EAAAR,gBACAQ,EAAAT,cAAAE,QAAA,KACAnK,EAAAqV,UAAA,yBAEG,aAAA3E,EAAA0E,SAEH,OADApV,EAAAkV,UACA9E,EAAA3M,MAAA,2BAKA2P,GAAA,GAAAC,GAAA,KAAAD,EAAA,GAEApT,EAAAsV,iBAAAlC,GACApT,EAAAuV,eAAAlC,GACArT,EAAAwV,aAAA9E,EAAA+E,OAEA,IAAAJ,EAAA,GA8BA,GA7BA3E,EAAA2E,YACA,iBAAA3E,EAAA2E,YACA3E,EAAA2E,UAAA3E,EAAA2E,UAAAxP,MAAA,MAEA6K,EAAA2E,UAAA3Q,QACAgM,EAAA2E,UAAAtG,QAAA2G,IACAL,EAAAxD,QAAA6D,GAAA,GACAL,EAAA9P,KAAAmQ,OAMAtC,EAAA,GAAAC,EAAA,KACA3I,EAAAR,gBACAQ,EAAAT,cAAAE,QAAA,KACAnK,EAAAsT,cAKA+B,EAAA3Q,SACAgG,EAAAR,gBACAQ,EAAAT,cAAAE,QAAA,KACAnK,EAAAqV,YAAAzI,IAAA8I,KAAAjP,aAKAiK,EAAAiF,OAAA,CACA,IAAAC,GAAA,EACAC,GAAA,EAaA,GAXA,MAAAnF,EAAAoF,UACA,WAAAC,KAAArF,EAAAoF,UAAA,MAAApF,EAAAsF,SACAtF,EAAAsF,SAAAtF,EAAAoF,QACO,QAAAC,KAAArF,EAAAoF,UAAA,MAAApF,EAAAuF,UACPvF,EAAAuF,UAAAvF,EAAAoF,QACO,MAAApF,EAAAwF,aACPxF,EAAAwF,WAAAxF,EAAAoF,UAKA,MAAApF,EAAAwF,WAAA,CACA,IAMAC,EANAC,EAAA,MAAA1F,EAAA4D,UACA5D,EAAA4D,UAAA5P,OACAgM,EAAA4D,UACA3R,KAAA6E,SAAAkJ,EAAAwF,YAAA,OACA,KAiBA,GAdAxL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAgM,EAAAnW,EAAAqW,SAAAD,KAGA1F,EAAAwF,WAAAxR,OACAuL,EAAAS,EAAAwF,WAAAC,EAAAxL,OAAA6G,IAEA8E,EAAAH,EAAAxL,QACAiL,GAAA,GAEAC,GAAA,EAGA,MAAAM,EAAA7B,UACA,GAAA5D,EAAAwF,WAAAxR,OAAA,CACA,IAAA4P,EAAAiC,KAAA9F,MAAA0F,EAAA7B,WACAA,EAAAkC,WAAAzW,QAAAyL,cACA8I,EAAA9E,QAAAT,QAAA,CAAA7N,EAAAmF,KACA,IAAAoQ,EAAA,KACA,GAAAvV,EAAAwR,WAAA3S,QAAA0L,eAAA,CACA,IAAAiL,EAAAxV,EAAA0R,UAAA7S,QAAA0L,cAAA/G,QAAAuK,QAAA,YACA,GAAAlP,QAAA8L,aAAArJ,eAAAkU,GACAD,EAAA1W,QAAA8L,aAAA6K,QAEA,QAAA/V,EAAA,EAAAuR,EAAAH,EAAArN,OAAyD/D,EAAAuR,GAEzD,QADAuE,EAAAzG,EAAA9O,EAAA0R,UAAA7S,QAAA0L,cAAA/G,QAAAqN,EAAApR,OADgEA,SAMhE8V,EAAAzG,EAAA9O,EAAAsQ,GAEA,UAAAiF,EACA,OAAArG,EAAA3M,MAAA,gBAAAvC,EAAA,iBAEAoT,EAAAqC,iBAAArC,EAAAqC,eAAA,IACArC,EAAAqC,eAAAtQ,GAAAoQ,IAEAxG,EAAAtN,KAAAmD,KACAnD,KAAA2E,QAAAoJ,EAAAwF,YACAvT,KAAA6E,SAAA4O,IACAnH,QAAA,YAAAsH,KAAAK,UAAAtC,GAAA9C,QAEA5I,EAAAI,MAAA,+CAAAV,KAMA,SAAAoI,EAAAuF,UAAA,CACA,IAAAY,EACAnG,EAAAuF,UAAAvR,QACAgG,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACA0M,EAAA7W,EAAA8W,YAEA7G,EAAAS,EAAAuF,UAAAY,EAAArF,IACOoE,IACPlL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACA0M,EAAA7W,EAAA8W,YAEAR,EAAAO,GACAjB,GAAA,GAEAC,GAAA,EAIA,SAAAnF,EAAAqG,QAAA,CACA,IAAAC,EACAtG,EAAAqG,QAAArS,QACAgG,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACA6M,EAAAxO,eAAAyO,SAAA/D,KAEAjD,EAAAS,EAAAqG,QAAAC,EAAAxF,IACOoE,IACPlL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACA6M,EAAAxO,eAAAyO,SAAA/D,KAEAoD,EAAAU,GACApB,GAAA,GAEAC,GAAA,EAIA,SAAAnF,EAAAwG,QAAA,CACA,IAAAC,EACAzG,EAAAwG,QAAAxS,QACAgG,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAgN,EAAA3O,eAAA4O,SAAAlE,KAEAjD,EAAAS,EAAAwG,QAAAC,EAAA3F,IACOoE,IACPlL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAgN,EAAA3O,eAAA4O,SAAAlE,KAEAoD,EAAAa,GACAvB,GAAA,GAEAC,GAAA,EAIA,SAAAnF,EAAAsF,WAAAH,EAAA,CACA,IAAAwB,EACA3G,EAAAsF,UAAAtF,EAAAsF,SAAAtR,QACAgG,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAkN,EAAArX,EAAAsX,WAEArH,EAAAS,EAAAsF,SAAAqB,EAAA7F,IACOoE,IACPlL,EAAAZ,YACAY,EAAAb,UAAAM,QAAA,KACAkN,EAAArX,EAAAsX,WAEAhB,EAAAe,KASA,OAJArX,EAAAkV,UACAxE,EAAAvG,SACAM,WAAAC,EAAA9B,GAEAwH,EAAA,MAEA,SAAAC,EAAArL,EAAAwM,GACA,IACA,IAAAiF,EAKA,OAJA/L,EAAApB,YACAoB,EAAArB,UAAAc,QAAA,KACAsM,EAAAxO,GAAAiH,aAAAvM,KAAAmD,KAAA0L,EAAAxM,GAAA,CAA8DuS,SAAA,WAE9Dd,EACK,MAAAvW,GACL,aAIA,SAAAoQ,EAAAtL,EAAAkL,EAAAsB,GACA,IAUA,OATA9G,EAAAlB,aACAkB,EAAAnB,WAAAY,QAAA,KACA9B,OAAA1F,KAAAmD,KAAA0L,EAAA7O,KAAA2E,QAAAtC,KACA,iBAAAkL,EACAjI,GAAAuP,cAAA7U,KAAAmD,KAAA0L,EAAAxM,GAAAkL,EAAA,CAAoEqH,SAAA,SAEpEtP,GAAAuP,cAAA7U,KAAAmD,KAAA0L,EAAAxM,GAAAkL,MAGA,EACK,MAAAhQ,GACL,UAIA,SAAAqQ,EAAAjJ,EAAAkK,GACA,IAAAiG,EACA,IAIA,OAHA/M,EAAArB,UAAAc,QAAA,KACAsN,EAAAxP,GAAAyP,YAAA/U,KAAAmD,KAAA0L,EAAAlK,IAAAnC,OAAA6J,GAAA,yBAAA+G,KAAA/G,MAEAyI,EACK,MAAAvX,GACL,UAIA,SAAAoW,EAAApG,GACAoG,EAAAqB,OACAjN,EAAAlB,aACA8M,EAAAqB,MAAA,GAEAjN,EAAAnB,WAAAY,QAAA,KACA,iBAAA+F,EACApF,EAAA9B,MAAAkH,EAAA,CAAgCqH,SAAA,SAEhCzM,EAAA9B,MAAAkH,OAsBAnQ,QAAA2I,kCAsBA3I,QAAAqJ,wBAEA/E,QAAA+F,SAAA/F,QAAA+F,OAAsC3J,oBAAQ,KAU9CV,QAAAoK,gBAOApK,QAAAuK,sBAkBAvK,QAAA0K,sBAEA,IAAAmN,iBAAA,IAAA5P,eAAA6P,OACA7P,OAAA6P,OAAAC,aAAA,SAAAlQ,GAAgD,WAAAI,OAAA6P,OAAAjQ,IAChD,SAAAA,GAAmB,WAAAmQ,WAAAnQ,IAGnB,SAAA8H,mBAAA5M,GACA,IAAAkV,EAAA,GA6BA,OA5BAA,EAAAhP,MAAA,SAAAiP,GAEA,GADAnV,KAAAmV,GACA,iBAAAA,EAAA,CACA,IAAAC,EAAAN,YAAA1P,KAAAxD,OAAAuT,IACA/P,KAAAc,MAAAiP,EAAAC,EAAA,GACAD,EAAAC,EAEA5X,KAAAiF,KAAA0S,IAEAD,EAAAG,MAAA,WACAH,EAAAtT,OAAA,GAEAsT,EAAAI,SAAA,WAEA,IADA,IAAAC,EAAA,EAAA1X,EAAA,EAAAuR,EAAA5R,KAAAoE,OACA/D,EAAAuR,GAAAmG,GAAA/X,KAAAK,KAAA+D,OACA,IAAAwT,EAAAN,YAAAS,GAEA,IADAA,EAAA1X,EAAA,EACAA,EAAAuR,GACAgG,EAAAtK,IAAAtN,KAAAK,GAAA0X,GACAA,GAAA/X,KAAAK,GAAA+D,SACA/D,EAEA,OAAAuX,GAEAF,EAAAM,SAAA,WACA,IAAAJ,EAAA5X,KAAA8X,WACA,OAAAlQ,KAAAqQ,KAAAL,EAAA,EAAAA,EAAAxT,SAEAsT,EAGAjY,QAAA2P,sCAGA3P,QAAAyY,WAAA,CACAC,cAAA,EACAC,eAAA,EACAC,mBAAA,EACAC,gBAAA,EACAC,eAAA,EACAC,kBAAA,EACAC,wBAAA,EACAC,OAAA,SACAhZ,OAAA,WACAiZ,OAAA,EACAC,MAAA,GACAC,SAAA,4FC13BA,IAAAjR,EAAAnI,EAOAmI,EAAAxD,OAAA,SAAAsJ,GAGA,IAFA,IAAApG,EAAA,EACA5G,EAAA,EACAL,EAAA,EAAmBA,EAAAqN,EAAAtJ,SAAmB/D,GACtCK,EAAAgN,EAAAoL,WAAAzY,IACA,IACAiH,GAAA,EACA5G,EAAA,KACA4G,GAAA,EACA,cAAA5G,IAAA,cAAAgN,EAAAoL,WAAAzY,EAAA,OACAA,EACAiH,GAAA,GAEAA,GAAA,EAEA,OAAAA,GAUAM,EAAAqQ,KAAA,SAAAL,EAAAvR,EAAAC,GAEA,GADAA,EAAAD,EACA,EACA,SAKA,IAJA,IAGA9E,EAHA0C,EAAA,KACA0T,EAAA,GACAtX,EAAA,EAEAgG,EAAAC,IACA/E,EAAAqW,EAAAvR,MACA,IACAsR,EAAAtX,KAAAkB,EACAA,EAAA,KAAAA,EAAA,IACAoW,EAAAtX,MAAA,GAAAkB,IAAA,KAAAqW,EAAAvR,KACA9E,EAAA,KAAAA,EAAA,KACAA,IAAA,EAAAA,IAAA,OAAAqW,EAAAvR,OAAA,OAAAuR,EAAAvR,OAAA,KAAAuR,EAAAvR,MAAA,MACAsR,EAAAtX,KAAA,OAAAkB,GAAA,IACAoW,EAAAtX,KAAA,YAAAkB,IAEAoW,EAAAtX,MAAA,GAAAkB,IAAA,OAAAqW,EAAAvR,OAAA,KAAAuR,EAAAvR,KACAhG,EAAA,QACA4D,MAAA,KAAAgB,KAAAuK,OAAAuJ,aAAApH,MAAAnC,OAAAmI,IACAtX,EAAA,GAGA,OAAA4D,GACA5D,GACA4D,EAAAgB,KAAAuK,OAAAuJ,aAAApH,MAAAnC,OAAAmI,EAAA/S,MAAA,EAAAvE,KACA4D,EAAAuB,KAAA,KAEAgK,OAAAuJ,aAAApH,MAAAnC,OAAAmI,EAAA/S,MAAA,EAAAvE,KAUAuH,EAAAc,MAAA,SAAAgF,EAAAkK,EAAAG,GAIA,IAHA,IACAiB,EACAC,EAFA5S,EAAA0R,EAGA1X,EAAA,EAAmBA,EAAAqN,EAAAtJ,SAAmB/D,GACtC2Y,EAAAtL,EAAAoL,WAAAzY,IACA,IACAuX,EAAAG,KAAAiB,EACSA,EAAA,MACTpB,EAAAG,KAAAiB,GAAA,MACApB,EAAAG,KAAA,GAAAiB,EAAA,KACS,cAAAA,IAAA,eAAAC,EAAAvL,EAAAoL,WAAAzY,EAAA,MACT2Y,EAAA,aAAAA,IAAA,UAAAC,KACA5Y,EACAuX,EAAAG,KAAAiB,GAAA,OACApB,EAAAG,KAAAiB,GAAA,UACApB,EAAAG,KAAAiB,GAAA,SACApB,EAAAG,KAAA,GAAAiB,EAAA,MAEApB,EAAAG,KAAAiB,GAAA,OACApB,EAAAG,KAAAiB,GAAA,SACApB,EAAAG,KAAA,GAAAiB,EAAA,KAGA,OAAAjB,EAAA1R,qBCvGA,SAAAtC,GAAA,IAAAmV,OAAA,IAAAnV,MAAA,GACAoV,EAAAD,EAAAlW,KAAA,OAAAkW,EAAAlW,IAEA,SAAAiD,EAAAyR,EAAA0B,GACA,IAAAC,EAAAD,GAAA,GAUA,OATAC,EAAA/I,UAAAoH,OAAA9O,OAAAuQ,EACAE,EAAAC,KAAAnD,IAAAkD,EAAA/I,UAAA7Q,EAAA8Z,KAAApD,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAAzI,IAAAuF,IAAAkD,EAAA/I,UAAA7Q,EAAAga,IAAAtD,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAAK,MAAAvD,IAAAkD,EAAA/I,UAAA7Q,EAAAka,MAAAxD,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAA5I,OAAA0F,IAAAkD,EAAA/I,UAAA7Q,EAAAma,OAAAzD,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAAQ,KAAA1D,IAAAkD,EAAA/I,UAAA7Q,EAAAqa,KAAA3D,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAAU,QAAA5D,IAAAkD,EAAA/I,UAAA7Q,EAAAua,QAAA7D,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAApI,KAAAkF,IAAAkD,EAAA/I,UAAA7Q,EAAAwa,KAAA9D,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAAArI,MAAAmF,IAAAkD,EAAA/I,UAAA7Q,EAAAya,MAAA/D,EAAA1W,EAAA+Z,MAAArD,GACAkD,EAGA5Z,EAAA+K,OAAAvE,EAAAiT,EAAA1O,OAAA/K,GACAA,EAAA6I,OAAArC,EAAAiT,EAAA5Q,QACA7I,EAAAwG,OAEAxG,EAAA8Z,KAAA,QACA9Z,EAAAga,IAAA,QACAha,EAAAka,MAAA,QACAla,EAAAma,OAAA,QACAna,EAAAqa,KAAA,QACAra,EAAAua,QAAA,QACAva,EAAAwa,KAAA,QACAxa,EAAAya,MAAA,QACAza,EAAA+Z,MAAA,wCCmDA/Z,EAAA0Q,MArEA,SAAAlN,EAAAkX,GACA,IAAAlP,EAAA,GACAsF,EAAA,GACAnL,UAAA,GACAsL,EAAA,GAGA0D,EAAA,GACArT,OAAAsO,KAAA8K,GAAA1L,QAAA7M,IACA,IAAAA,EAAAwQ,WAAA,MACA,IAAAgI,EAAAD,EAAAvY,GACA,MAAAwY,EAAA9F,QACA,iBAAA8F,EAAA9F,MAAAF,EAAAgG,EAAA9F,OAAA1S,EACAkE,MAAAyJ,QAAA6K,EAAA9F,QAAA8F,EAAA9F,MAAA7F,QAAA6F,GAAAF,EAAAE,GAAA1S,IAEA,MAAAwY,EAAAC,UAAApP,EAAArJ,GAAAwY,EAAAC,YAIA,QAAAha,EAAA,EAAAuR,GAAA3O,IAAA2B,SAAAR,OAAmD/D,EAAAuR,IAAOvR,EAAA,CAC1D,IAAAmQ,EAAAvN,EAAA5C,GACA,SAAAmQ,EAAA,GAAsBnQ,EAAK,MAC3B,IAAiD+Z,EAAAxY,EAAjD0Y,EAAA,gDAAiD3V,KAAA6L,GACjD,GAAA8J,EACAH,EAAA3J,GAAA4J,EAAAD,EAAAvY,EAAA4O,GACA,MAAA8J,EAAA,IACAF,EAAAD,EAAAvY,EAAAwS,EAAAkG,EAAA,GAAAhI,UAAA,OACA,MAAAgI,EAAA,KAAArX,EAAA5C,KAAAia,EAAA,IACO,MAAAA,EAAA,KACPF,EAAAD,EAAAvY,EAAA0Y,EAAA,GAAAhI,UAAA,MACA,MAAAgI,EAAA,KAAArX,EAAA5C,KAAAia,EAAA,QAEK,CACL,OAAA9J,EAAAsI,WAAA,GACA,CAAY1T,UAAAH,KAAAuL,GAAqB,SADjC4J,EAAAD,EAAAvY,EAAA4O,GAGA,GAAA4J,EAAA,CACA,SAAAA,EAAAG,MAAA,MAAAH,EAAAG,KAAAtP,EAAArJ,IAAA,OAEA,GAAAvB,EAAA,EAAA4C,EAAAmB,QAAA,IAAAnB,EAAA5C,EAAA,GAAAyY,WAAA,GACA,OAAAsB,EAAAG,MACA,QAAAtP,EAAArJ,GAAA4Y,SAAAvX,IAAA5C,GAAA,IAA6D,MAC7D,QAAA4K,EAAArJ,IAAAqJ,EAAArJ,IAAA,IAAAiF,OAAA2T,SAAAvX,IAAA5C,GAAA,KAA0F,MAC1F,QAAA4K,EAAArJ,GAAA6Y,WAAAxX,IAAA5C,IAA2D,MAC3D,QAAA4K,EAAArJ,IAAAqJ,EAAArJ,IAAA,IAAAiF,OAAA4T,WAAAxX,IAAA5C,KAAwF,MACxF,QAAA4K,EAAArJ,GAAA4N,OAAAvM,IAAA5C,IAAuD,MACvD,QAAA4K,EAAArJ,IAAAqJ,EAAArJ,IAAA,IAAAiF,OAAA5D,IAAA5C,GAAAkF,MAAA,MAAuF,MACvF,QAAAgL,EAAAtL,KAAAuL,KAAuCnQ,OAGvC,OAAA+Z,EAAAG,MACA,QACA,QAAAtP,EAAArJ,GAAAwY,EAAAC,SAAA,EAAyD,MACzD,QAAApP,EAAArJ,GAAAwY,EAAAC,SAAA,GAA0D,MAC1D,QACA,QACA,QAAApP,EAAArJ,GAAAqJ,EAAAoP,SAAA,GAA2D,MAC3D,QAAA9J,EAAAtL,KAAAuL,GAIA4J,EAAA9Y,OAAAP,OAAAsO,KAAA+K,EAAA9Y,OAAAmN,QAAAmD,GAAA3G,EAAA2G,GAAAwI,EAAA9Y,MAAAsQ,SACKrB,EAAAtL,KAAAuL,GAEL,KAAAnQ,EAAAuR,GAAAlB,EAAAzL,KAAAhC,EAAA5C,MAEA,OAAU4K,UAAAsF,UAAAnL,oBAAAsL,aA8BVjR,EAAAoR,KAxBA,SAAAsJ,EAAAlP,GACAA,MAAA,IACA,IAAAyP,EAAAzP,EAAAyP,QAAA,EACAC,EAAA1P,EAAA0P,SAAA,GACAC,EAAA3P,EAAA2P,KAAA,KACAC,EAAA,GAgBA,OAfA9Z,OAAAsO,KAAA8K,GAAA1L,QAAA7M,IACA,IAAAwY,EAAAD,EAAAvY,GACA,SAAAwY,EAAAU,YAAA,CAEA,IADA,IAAA3E,EAAA,GACAA,EAAA/R,OAAAsW,GAAAvE,GAAA,IAGA,IAFAA,GAAA,KAAAvU,EACAwY,EAAA9F,QAAA6B,GAAA,MAAAiE,EAAA9F,OACA6B,EAAA/R,OAAAuW,GAAAxE,GAAA,IACArQ,MAAAyJ,QAAA6K,EAAAU,aACAD,EAAA5V,KAAAkR,EAAAiE,EAAAU,YAAA,GAAAV,EAAAU,YAAAlW,MAAA,GAAA0H,IAAAyO,IACA,QAAA1a,EAAA,EAAuBA,EAAAsa,IAAata,EAAA0a,EAAA,IAAAA,EACpC,OAAAH,EAAAG,IACOvV,KAAA,KACFqV,EAAA5V,KAAAkR,EAAAiE,EAAAU,gBAELD,EAAArV,KAAAoV,sBCxGA,SAAA7W,GAwBA,IAAA1B,EAAWlC,EAAQ,GACnBwH,EAASxH,EAAQ,GACjB6a,EAAAR,SAAA,UAEA9a,EAAAD,QAAA,SAAAsI,EAAA5F,EAAA+N,EAAA+K,GACA/K,GAAA,iBAAAA,IACAA,EAAA,CAAY1O,KAAA0O,IAEZ,IAAA1O,EAAA0O,EAAA1O,UACA0Z,IAAA1Z,IACAA,EAAAwZ,GAAAjX,EAAAN,SAEAwX,MAAA,MACA9Y,EAAAE,EAAAiB,QAAAnB,GACA,IACAwF,EAAAwT,UAAAhZ,EAAAX,GACAyZ,KAAA9Y,EACG,MAAAiZ,GACH,OAAAA,EAAA3Q,MACA,aACAwQ,EAAAlT,EAAA1F,EAAA2E,QAAA7E,GAAA+N,EAAA+K,GACAlT,EAAA5F,EAAA+N,EAAA+K,GACA,MACA,QACA,IAAAI,EACA,IACAA,EAAA1T,EAAA2T,SAAAnZ,GACS,MAAAoZ,GACT,MAAAH,EAEA,IAAAC,EAAAG,cAAA,MAAAJ,GAIA,OAAAH,oCC1DA,YAAAhb,gCAAA,CAA4D,IAAAL,EAAA,IAAAuD,MAAA,uCAAsF,MAA7BvD,EAAA6K,KAAA,mBAA6B7K,EAClJF,EAAAD,QAAAQ,myJCDA,SAAAwb,EAAAC,GACA,IAAA9b,EAAA,IAAAuD,MAAA,uBAAAuY,EAAA,KAEA,MADA9b,EAAA6K,KAAA,mBACA7K,EAEA6b,EAAApM,KAAA,WAAuC,UACvCoM,EAAAnY,QAAAmY,EACA/b,EAAAD,QAAAgc,EACAA,EAAAE,GAAA,qBCRA,SAAA5X,EAAA2D,GAAAhI,EAAAD,QAAAsE,EAAA+F,QAcA,SAAA8R,GACA,IAAAC,EAAA,KAAAC,EAAAtb,KAAAub,GACAC,EAAAvV,KAAAwV,MAAAJ,GACAK,EAAAzV,KAAAwV,MAAAJ,EAAA,OACAD,IACAI,GAAAJ,EAAA,IACAM,GAAAN,EAAA,IACA,IACAI,IACAE,GAAA,MAGA,OAAAF,EAAAE,IAvBA,IAAAH,EAAArU,EAAAqU,aAAA,GACAD,EACAC,EAAAI,KACAJ,EAAAK,QACAL,EAAAM,OACAN,EAAAO,MACAP,EAAAQ,WACA,WAAa,WAAAC,MAAAC","file":"asc.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory((function webpackLoadOptionalExternalModule() { try { return require(\"assemblyscript\"); } catch(e) {} }()));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"assemblyscript\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"asc\"] = factory((function webpackLoadOptionalExternalModule() { try { return require(\"assemblyscript\"); } catch(e) {} }()));\n\telse\n\t\troot[\"asc\"] = factory(root[\"assemblyscript\"]);\n})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE__10__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","exports.nextTick = function nextTick(fn) {\n\tsetTimeout(fn, 0);\n};\n\nexports.platform = exports.arch = \nexports.execPath = exports.title = 'browser';\nexports.pid = 1;\nexports.browser = true;\nexports.env = {};\nexports.argv = [];\n\nexports.binding = function (name) {\n\tthrow new Error('No such module. (Possibly not yet loaded)')\n};\n\n(function () {\n var cwd = '/';\n var path;\n exports.cwd = function () { return cwd };\n exports.chdir = function (dir) {\n if (!path) path = require('path');\n cwd = path.resolve(dir, cwd);\n };\n})();\n\nexports.exit = exports.kill = \nexports.umask = exports.dlopen = \nexports.uptime = exports.memoryUsage = \nexports.uvCounters = function() {};\nexports.features = {};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nvar splitPathRe =\n /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\nvar splitPath = function(filename) {\n return splitPathRe.exec(filename).slice(1);\n};\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function(path) {\n var result = splitPath(path),\n root = result[0],\n dir = result[1];\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.';\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1);\n }\n\n return root + dir;\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPath(path)[2];\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPath(path)[3];\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/**\r\n * Compiler frontend for node.js\r\n *\r\n * Uses the low-level API exported from src/index.ts so it works with the compiler compiled to\r\n * JavaScript as well as the compiler compiled to WebAssembly (eventually). Runs the sources\r\n * directly through ts-node if distribution files are not present (indicated by a `-dev` version).\r\n *\r\n * Can also be packaged as a bundle suitable for in-browser use with the standard library injected\r\n * in the build step. See dist/asc.js for the bundle and webpack.config.js for building details.\r\n *\r\n * @module cli/asc\r\n */\r\n\r\n// Use \".\" instead of \"/\" as cwd in browsers\r\nif (process.browser) process.cwd = function() { return \".\"; };\r\n\r\nconst fs = require(\"fs\");\r\nconst path = require(\"path\");\r\nconst utf8 = require(\"@protobufjs/utf8\");\r\nconst colorsUtil = require(\"./util/colors\");\r\nconst optionsUtil = require(\"./util/options\");\r\nconst mkdirp = require(\"./util/mkdirp\");\r\nconst EOL = process.platform === \"win32\" ? \"\\r\\n\" : \"\\n\";\r\n\r\n// global.Binaryen = require(\"../lib/binaryen\");\r\n\r\n// Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional\r\n// useless code fragment on top of an actual error. suppress this:\r\nif (process.removeAllListeners) process.removeAllListeners(\"uncaughtException\");\r\n\r\n// Use distribution files if present, otherwise run the sources directly\r\nvar assemblyscript, isDev = false;\r\n(() => {\r\n try { // `asc` on the command line\r\n assemblyscript = require(\"../dist/assemblyscript.js\");\r\n } catch (e) {\r\n try { // `asc` on the command line without dist files\r\n require(\"ts-node\").register({ project: path.join(__dirname, \"..\", \"src\", \"tsconfig.json\") });\r\n require(\"../src/glue/js\");\r\n assemblyscript = require(\"../src\");\r\n isDev = true;\r\n } catch (e_ts) {\r\n try { // `require(\"dist/asc.js\")` in explicit browser tests\r\n assemblyscript = eval(\"require('./assemblyscript')\");\r\n } catch (e) {\r\n // combine both errors that lead us here\r\n e.stack = e_ts.stack + \"\\n---\\n\" + e.stack;\r\n throw e;\r\n }\r\n }\r\n }\r\n})();\r\n\r\n/** Whether this is a webpack bundle or not. */\r\nexports.isBundle = typeof BUNDLE_VERSION === \"string\";\r\n\r\n/** Whether asc runs the sources directly or not. */\r\nexports.isDev = isDev;\r\n\r\n/** AssemblyScript version. */\r\nexports.version = exports.isBundle ? BUNDLE_VERSION : require(\"../package.json\").version;\r\n\r\n/** Available CLI options. */\r\nexports.options = require(\"./asc.json\");\r\n\r\n/** Common root used in source maps. */\r\nexports.sourceMapRoot = \"assemblyscript:///\";\r\n\r\n/** Prefix used for library files. */\r\nexports.libraryPrefix = assemblyscript.LIBRARY_PREFIX;\r\n\r\n/** Default Binaryen optimization level. */\r\nexports.defaultOptimizeLevel = 3;\r\n\r\n/** Default Binaryen shrink level. */\r\nexports.defaultShrinkLevel = 1;\r\n\r\n/** Bundled library files. */\r\nexports.libraryFiles = exports.isBundle ? BUNDLE_LIBRARY : (() => { // set up if not a bundle\r\n const libDir = path.join(__dirname, \"..\", \"std\", \"assembly\");\r\n const libFiles = require(\"glob\").sync(\"**/!(*.d).ts\", { cwd: libDir });\r\n const bundled = {};\r\n libFiles.forEach(file => bundled[file.replace(/\\.ts$/, \"\")] = fs.readFileSync(path.join(libDir, file), \"utf8\" ));\r\n return bundled;\r\n})();\r\n\r\n/** Bundled definition files. */\r\nexports.definitionFiles = exports.isBundle ? BUNDLE_DEFINITIONS : (() => { // set up if not a bundle\r\n const stdDir = path.join(__dirname, \"..\", \"std\");\r\n return {\r\n \"assembly\": fs.readFileSync(path.join(stdDir, \"assembly\", \"index.d.ts\"), \"utf8\"),\r\n \"portable\": fs.readFileSync(path.join(stdDir, \"portable\", \"index.d.ts\"), \"utf8\")\r\n };\r\n})();\r\n\r\n/** Convenience function that parses and compiles source strings directly. */\r\nexports.compileString = (sources, options) => {\r\n if (typeof sources === \"string\") sources = { \"input.ts\": sources };\r\n const output = Object.create({\r\n stdout: createMemoryStream(),\r\n stderr: createMemoryStream()\r\n });\r\n var argv = [\r\n \"--binaryFile\", \"binary\",\r\n \"--textFile\", \"text\",\r\n ];\r\n Object.keys(options || {}).forEach(key => {\r\n var val = options[key];\r\n if (Array.isArray(val)) val.forEach(val => argv.push(\"--\" + key, String(val)));\r\n else argv.push(\"--\" + key, String(val));\r\n });\r\n exports.main(argv.concat(Object.keys(sources)), {\r\n stdout: output.stdout,\r\n stderr: output.stderr,\r\n readFile: name => sources.hasOwnProperty(name) ? sources[name] : null,\r\n writeFile: (name, contents) => output[name] = contents,\r\n listFiles: () => []\r\n });\r\n return output;\r\n}\r\n\r\n/** Runs the command line utility using the specified arguments array. */\r\nexports.main = function main(argv, options, callback) {\r\n if (typeof options === \"function\") {\r\n callback = options;\r\n options = {};\r\n } else if (!options) {\r\n options = {};\r\n }\r\n\r\n const stdout = options.stdout || process.stdout;\r\n const stderr = options.stderr || process.stderr;\r\n const readFile = options.readFile || readFileNode;\r\n const writeFile = options.writeFile || writeFileNode;\r\n const listFiles = options.listFiles || listFilesNode;\r\n const stats = options.stats || createStats();\r\n\r\n // Output must be specified if not present in the environment\r\n if (!stdout) throw Error(\"'options.stdout' must be specified\");\r\n if (!stderr) throw Error(\"'options.stderr' must be specified\");\r\n\r\n const opts = optionsUtil.parse(argv, exports.options);\r\n const args = opts.options;\r\n argv = opts.arguments;\r\n if (args.noColors) {\r\n colorsUtil.stdout.supported =\r\n colorsUtil.stderr.supported = false;\r\n } else {\r\n colorsUtil.stdout = colorsUtil.from(stdout);\r\n colorsUtil.stderr = colorsUtil.from(stderr);\r\n }\r\n\r\n // Check for unknown arguments\r\n if (opts.unknown.length) {\r\n opts.unknown.forEach(arg => {\r\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unknown option '\" + arg + \"'\" + EOL);\r\n });\r\n }\r\n\r\n // Check for trailing arguments\r\n if (opts.trailing.length) {\r\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unsupported trailing arguments: \" + opts.trailing.join(\" \") + EOL);\r\n }\r\n\r\n // Use default callback if none is provided\r\n if (!callback) callback = function defaultCallback(err) {\r\n var code = 0;\r\n if (err) {\r\n stderr.write(colorsUtil.stderr.red(\"ERROR: \") + err.stack.replace(/^ERROR: /i, \"\") + EOL);\r\n code = 1;\r\n }\r\n return code;\r\n };\r\n\r\n // Just print the version if requested\r\n if (args.version) {\r\n stdout.write(\"Version \" + exports.version + (isDev ? \"-dev\" : \"\") + EOL);\r\n return callback(null);\r\n }\r\n // Print the help message if requested or no source files are provided\r\n if (args.help || !argv.length) {\r\n var out = args.help ? stdout : stderr;\r\n var color = args.help ? colorsUtil.stdout : colorsUtil.stderr;\r\n out.write([\r\n color.white(\"SYNTAX\"),\r\n \" \" + color.cyan(\"asc\") + \" [entryFile ...] [options]\",\r\n \"\",\r\n color.white(\"EXAMPLES\"),\r\n \" \" + color.cyan(\"asc\") + \" hello.ts\",\r\n \" \" + color.cyan(\"asc\") + \" hello.ts -b hello.wasm -t hello.wat\",\r\n \" \" + color.cyan(\"asc\") + \" hello1.ts hello2.ts -b -O > hello.wasm\",\r\n \"\",\r\n color.white(\"OPTIONS\"),\r\n ].concat(\r\n optionsUtil.help(exports.options, 24, EOL)\r\n ).join(EOL) + EOL);\r\n return callback(null);\r\n }\r\n\r\n // I/O must be specified if not present in the environment\r\n if (!fs.readFileSync) {\r\n if (readFile === readFileNode) throw Error(\"'options.readFile' must be specified\");\r\n if (writeFile === writeFileNode) throw Error(\"'options.writeFile' must be specified\");\r\n if (listFiles === listFilesNode) throw Error(\"'options.listFiles' must be specified\");\r\n }\r\n\r\n // Set up base directory\r\n const baseDir = args.baseDir ? path.resolve(args.baseDir) : \".\";\r\n\r\n // Set up transforms\r\n const transforms = [];\r\n if (args.transform) {\r\n args.transform.forEach(transform =>\r\n transforms.push(\r\n require(\r\n path.isAbsolute(transform = transform.trim())\r\n ? transform\r\n : path.join(process.cwd(), transform)\r\n )\r\n )\r\n );\r\n }\r\n function applyTransform(name, ...args) {\r\n transforms.forEach(transform => {\r\n if (typeof transform[name] === \"function\") transform[name](...args);\r\n });\r\n }\r\n\r\n // Begin parsing\r\n var parser = null;\r\n\r\n // Include library files\r\n Object.keys(exports.libraryFiles).forEach(libPath => {\r\n if (libPath.indexOf(\"/\") >= 0) return; // in sub-directory: imported on demand\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(\r\n exports.libraryFiles[libPath],\r\n exports.libraryPrefix + libPath + \".ts\",\r\n false,\r\n parser\r\n );\r\n });\r\n });\r\n const customLibDirs = [];\r\n if (args.lib) {\r\n let lib = args.lib;\r\n if (typeof lib === \"string\") lib = lib.split(\",\");\r\n Array.prototype.push.apply(customLibDirs, lib.map(lib => lib.trim()));\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) { // custom\r\n let libDir = customLibDirs[i];\r\n let libFiles;\r\n if (libDir.endsWith(\".ts\")) {\r\n libFiles = [ path.basename(libDir) ];\r\n libDir = path.dirname(libDir);\r\n } else {\r\n libFiles = listFiles(libDir);\r\n }\r\n for (let j = 0, l = libFiles.length; j < l; ++j) {\r\n let libPath = libFiles[j];\r\n let libText = readFile(libPath, libDir);\r\n if (libText === null) return callback(Error(\"Library file '\" + libPath + \"' not found.\"));\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(\r\n libText,\r\n exports.libraryPrefix + libPath,\r\n false,\r\n parser\r\n );\r\n });\r\n }\r\n }\r\n }\r\n\r\n // Parses the backlog of imported files after including entry files\r\n function parseBacklog() {\r\n var sourcePath, sourceText;\r\n while ((sourcePath = parser.nextFile()) != null) {\r\n\r\n // Load library file if explicitly requested\r\n if (sourcePath.startsWith(exports.libraryPrefix)) {\r\n const plainName = sourcePath.substring(exports.libraryPrefix.length);\r\n const indexName = sourcePath.substring(exports.libraryPrefix.length) + \"/index\";\r\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\r\n sourceText = exports.libraryFiles[plainName];\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\r\n sourceText = exports.libraryFiles[indexName];\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n sourceText = readFile(plainName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n break;\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Otherwise try nextFile.ts, nextFile/index.ts, ~lib/nextFile.ts, ~lib/nextFile/index.ts\r\n } else {\r\n const plainName = sourcePath;\r\n const indexName = sourcePath + \"/index\";\r\n sourceText = readFile(plainName + \".ts\", baseDir);\r\n if (sourceText !== null) {\r\n sourcePath = plainName + \".ts\";\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", baseDir);\r\n if (sourceText !== null) {\r\n sourcePath = indexName + \".ts\";\r\n } else if (!plainName.startsWith(\".\")) {\r\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\r\n sourceText = exports.libraryFiles[plainName];\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\r\n sourceText = exports.libraryFiles[indexName];\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n const dir = customLibDirs[i];\r\n sourceText = readFile(plainName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\r\n break;\r\n } else {\r\n sourceText = readFile(indexName + \".ts\", customLibDirs[i]);\r\n if (sourceText !== null) {\r\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n if (sourceText == null) {\r\n return callback(Error(\"Import file '\" + sourcePath + \".ts' not found.\"));\r\n }\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n assemblyscript.parseFile(sourceText, sourcePath, false, parser);\r\n });\r\n }\r\n if (checkDiagnostics(parser, stderr)) {\r\n return callback(Error(\"Parse error\"));\r\n }\r\n }\r\n\r\n // Include runtime template before entry files so its setup runs first\r\n {\r\n let templateName = String(args.runtime);\r\n let templateText = exports.libraryFiles[\"rt/index-\" + templateName];\r\n if (templateText == null) {\r\n templateText = readFile(templateName + \".ts\", baseDir);\r\n if (templateText == null) {\r\n return callback(Error(\"Runtime template '\" + templateName + \"' not found.\"));\r\n }\r\n }\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(templateText, templateName, true, parser);\r\n });\r\n }\r\n\r\n // Include entry files\r\n for (let i = 0, k = argv.length; i < k; ++i) {\r\n const filename = argv[i];\r\n\r\n let sourcePath = String(filename).replace(/\\\\/g, \"/\").replace(/(\\.ts|\\/)$/, \"\");\r\n\r\n // Try entryPath.ts, then entryPath/index.ts\r\n let sourceText = readFile(sourcePath + \".ts\", baseDir);\r\n if (sourceText === null) {\r\n sourceText = readFile(sourcePath + \"/index.ts\", baseDir);\r\n if (sourceText === null) {\r\n return callback(Error(\"Entry file '\" + sourcePath + \".ts' not found.\"));\r\n } else {\r\n sourcePath += \"/index.ts\";\r\n }\r\n } else {\r\n sourcePath += \".ts\";\r\n }\r\n\r\n stats.parseCount++;\r\n stats.parseTime += measure(() => {\r\n parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);\r\n });\r\n }\r\n\r\n // Parse entry files\r\n {\r\n let code = parseBacklog();\r\n if (code) return code;\r\n }\r\n\r\n // Call afterParse transform hook\r\n applyTransform(\"afterParse\", parser);\r\n\r\n // Parse additional files, if any\r\n {\r\n let code = parseBacklog();\r\n if (code) return code;\r\n }\r\n\r\n // Finish parsing\r\n const program = assemblyscript.finishParsing(parser);\r\n\r\n // Set up optimization levels\r\n var optimizeLevel = 0;\r\n var shrinkLevel = 0;\r\n if (args.optimize) {\r\n optimizeLevel = exports.defaultOptimizeLevel;\r\n shrinkLevel = exports.defaultShrinkLevel;\r\n }\r\n if (typeof args.optimizeLevel === \"number\") {\r\n optimizeLevel = args.optimizeLevel;\r\n }\r\n if (typeof args.shrinkLevel === \"number\") {\r\n shrinkLevel = args.shrinkLevel;\r\n }\r\n optimizeLevel = Math.min(Math.max(optimizeLevel, 0), 3);\r\n shrinkLevel = Math.min(Math.max(shrinkLevel, 0), 2);\r\n\r\n // Begin compilation\r\n const compilerOptions = assemblyscript.createOptions();\r\n assemblyscript.setTarget(compilerOptions, 0);\r\n assemblyscript.setNoAssert(compilerOptions, args.noAssert);\r\n assemblyscript.setImportMemory(compilerOptions, args.importMemory);\r\n assemblyscript.setSharedMemory(compilerOptions, args.sharedMemory);\r\n assemblyscript.setImportTable(compilerOptions, args.importTable);\r\n assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);\r\n assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);\r\n assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel);\r\n\r\n // Initialize default aliases\r\n assemblyscript.setGlobalAlias(compilerOptions, \"Math\", \"NativeMath\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"Mathf\", \"NativeMathf\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"abort\", \"~lib/builtins/abort\");\r\n assemblyscript.setGlobalAlias(compilerOptions, \"trace\", \"~lib/builtins/trace\");\r\n\r\n // Add or override aliases if specified\r\n if (args.use) {\r\n let aliases = args.use;\r\n for (let i = 0, k = aliases.length; i < k; ++i) {\r\n let part = aliases[i];\r\n let p = part.indexOf(\"=\");\r\n if (p < 0) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\r\n let name = part.substring(0, p).trim();\r\n let alias = part.substring(p + 1).trim();\r\n if (!name.length) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\r\n assemblyscript.setGlobalAlias(compilerOptions, name, alias);\r\n }\r\n }\r\n\r\n // Enable additional features if specified\r\n var features = args.enable;\r\n if (features != null) {\r\n if (typeof features === \"string\") features = features.split(\",\");\r\n for (let i = 0, k = features.length; i < k; ++i) {\r\n let name = features[i].trim();\r\n let flag = assemblyscript[\"FEATURE_\" + name.replace(/\\-/g, \"_\").toUpperCase()];\r\n if (!flag) return callback(Error(\"Feature '\" + name + \"' is unknown.\"));\r\n assemblyscript.enableFeature(compilerOptions, flag);\r\n }\r\n }\r\n\r\n var module;\r\n stats.compileCount++;\r\n try {\r\n stats.compileTime += measure(() => {\r\n module = assemblyscript.compileProgram(program, compilerOptions);\r\n });\r\n } catch (e) {\r\n return callback(e);\r\n }\r\n if (checkDiagnostics(parser, stderr)) {\r\n if (module) module.dispose();\r\n return callback(Error(\"Compile error\"));\r\n }\r\n\r\n // Validate the module if requested\r\n if (args.validate) {\r\n stats.validateCount++;\r\n stats.validateTime += measure(() => {\r\n if (!module.validate()) {\r\n module.dispose();\r\n return callback(Error(\"Validate error\"));\r\n }\r\n });\r\n }\r\n\r\n // Set Binaryen-specific options\r\n if (args.trapMode === \"clamp\") {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses([ \"trap-mode-clamp\" ]);\r\n });\r\n } else if (args.trapMode === \"js\") {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses([ \"trap-mode-js\" ]);\r\n });\r\n } else if (args.trapMode !== \"allow\") {\r\n module.dispose();\r\n return callback(Error(\"Unsupported trap mode\"));\r\n }\r\n\r\n // Implicitly run costly non-LLVM optimizations on -O3 or -Oz\r\n // see: https://github.com/WebAssembly/binaryen/pull/1596\r\n if (optimizeLevel >= 3 || shrinkLevel >= 2) optimizeLevel = 4;\r\n\r\n module.setOptimizeLevel(optimizeLevel);\r\n module.setShrinkLevel(shrinkLevel);\r\n module.setDebugInfo(args.debug);\r\n\r\n var runPasses = [];\r\n if (args.runPasses) {\r\n if (typeof args.runPasses === \"string\") {\r\n args.runPasses = args.runPasses.split(\",\");\r\n }\r\n if (args.runPasses.length) {\r\n args.runPasses.forEach(pass => {\r\n if (runPasses.indexOf(pass) < 0)\r\n runPasses.push(pass);\r\n });\r\n }\r\n }\r\n\r\n // Optimize the module if requested\r\n if (optimizeLevel > 0 || shrinkLevel > 0) {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.optimize();\r\n });\r\n }\r\n\r\n // Run additional passes if requested\r\n if (runPasses.length) {\r\n stats.optimizeCount++;\r\n stats.optimizeTime += measure(() => {\r\n module.runPasses(runPasses.map(pass => pass.trim()));\r\n });\r\n }\r\n\r\n // Prepare output\r\n if (!args.noEmit) {\r\n let hasStdout = false;\r\n let hasOutput = false;\r\n\r\n if (args.outFile != null) {\r\n if (/\\.was?t$/.test(args.outFile) && args.textFile == null) {\r\n args.textFile = args.outFile;\r\n } else if (/\\.js$/.test(args.outFile) && args.asmjsFile == null) {\r\n args.asmjsFile = args.outFile;\r\n } else if (args.binaryFile == null) {\r\n args.binaryFile = args.outFile;\r\n }\r\n }\r\n\r\n // Write binary\r\n if (args.binaryFile != null) {\r\n let sourceMapURL = args.sourceMap != null\r\n ? args.sourceMap.length\r\n ? args.sourceMap\r\n : path.basename(args.binaryFile) + \".map\"\r\n : null;\r\n\r\n let wasm;\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wasm = module.toBinary(sourceMapURL)\r\n });\r\n\r\n if (args.binaryFile.length) {\r\n writeFile(args.binaryFile, wasm.output, baseDir);\r\n } else {\r\n writeStdout(wasm.output);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n\r\n // Post-process source map\r\n if (wasm.sourceMap != null) {\r\n if (args.binaryFile.length) {\r\n let sourceMap = JSON.parse(wasm.sourceMap);\r\n sourceMap.sourceRoot = exports.sourceMapRoot;\r\n sourceMap.sources.forEach((name, index) => {\r\n let text = null;\r\n if (name.startsWith(exports.libraryPrefix)) {\r\n let stdName = name.substring(exports.libraryPrefix.length).replace(/\\.ts$/, \"\");\r\n if (exports.libraryFiles.hasOwnProperty(stdName)) {\r\n text = exports.libraryFiles[stdName];\r\n } else {\r\n for (let i = 0, k = customLibDirs.length; i < k; ++i) {\r\n text = readFile(name.substring(exports.libraryPrefix.length), customLibDirs[i]);\r\n if (text !== null) break;\r\n }\r\n }\r\n } else {\r\n text = readFile(name, baseDir);\r\n }\r\n if (text === null) {\r\n return callback(Error(\"Source file '\" + name + \"' not found.\"));\r\n }\r\n if (!sourceMap.sourceContents) sourceMap.sourceContents = [];\r\n sourceMap.sourceContents[index] = text;\r\n });\r\n writeFile(path.join(\r\n path.dirname(args.binaryFile),\r\n path.basename(sourceMapURL)\r\n ).replace(/^\\.\\//, \"\"), JSON.stringify(sourceMap), baseDir);\r\n } else {\r\n stderr.write(\"Skipped source map (stdout already occupied)\" + EOL);\r\n }\r\n }\r\n }\r\n\r\n // Write asm.js\r\n if (args.asmjsFile != null) {\r\n let asm;\r\n if (args.asmjsFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n asm = module.toAsmjs();\r\n });\r\n writeFile(args.asmjsFile, asm, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n asm = module.toAsmjs();\r\n });\r\n writeStdout(asm);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write WebIDL\r\n if (args.idlFile != null) {\r\n let idl;\r\n if (args.idlFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n idl = assemblyscript.buildIDL(program);\r\n });\r\n writeFile(args.idlFile, idl, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n idl = assemblyscript.buildIDL(program);\r\n });\r\n writeStdout(idl);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write TypeScript definition\r\n if (args.tsdFile != null) {\r\n let tsd;\r\n if (args.tsdFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n tsd = assemblyscript.buildTSD(program);\r\n });\r\n writeFile(args.tsdFile, tsd, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n tsd = assemblyscript.buildTSD(program);\r\n });\r\n writeStdout(tsd);\r\n hasStdout = true;\r\n }\r\n hasOutput = true;\r\n }\r\n\r\n // Write text (must be last)\r\n if (args.textFile != null || !hasOutput) {\r\n let wat;\r\n if (args.textFile && args.textFile.length) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wat = module.toText();\r\n });\r\n writeFile(args.textFile, wat, baseDir);\r\n } else if (!hasStdout) {\r\n stats.emitCount++;\r\n stats.emitTime += measure(() => {\r\n wat = module.toText()\r\n });\r\n writeStdout(wat);\r\n }\r\n }\r\n }\r\n\r\n module.dispose();\r\n if (args.measure) {\r\n printStats(stats, stderr);\r\n }\r\n return callback(null);\r\n\r\n function readFileNode(filename, baseDir) {\r\n try {\r\n let text;\r\n stats.readCount++;\r\n stats.readTime += measure(() => {\r\n text = fs.readFileSync(path.join(baseDir, filename), { encoding: \"utf8\" });\r\n });\r\n return text;\r\n } catch (e) {\r\n return null;\r\n }\r\n }\r\n\r\n function writeFileNode(filename, contents, baseDir) {\r\n try {\r\n stats.writeCount++;\r\n stats.writeTime += measure(() => {\r\n mkdirp(path.join(baseDir, path.dirname(filename)));\r\n if (typeof contents === \"string\") {\r\n fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: \"utf8\" } );\r\n } else {\r\n fs.writeFileSync(path.join(baseDir, filename), contents);\r\n }\r\n });\r\n return true;\r\n } catch (e) {\r\n return false;\r\n }\r\n }\r\n\r\n function listFilesNode(dirname, baseDir) {\r\n var files;\r\n try {\r\n stats.readTime += measure(() => {\r\n files = fs.readdirSync(path.join(baseDir, dirname)).filter(file => /^(?!.*\\.d\\.ts$).*\\.ts$/.test(file));\r\n });\r\n return files;\r\n } catch (e) {\r\n return [];\r\n }\r\n }\r\n\r\n function writeStdout(contents) {\r\n if (!writeStdout.used) {\r\n stats.writeCount++;\r\n writeStdout.used = true;\r\n }\r\n stats.writeTime += measure(() => {\r\n if (typeof contents === \"string\") {\r\n stdout.write(contents, { encoding: \"utf8\" });\r\n } else {\r\n stdout.write(contents);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/** Checks diagnostics emitted so far for errors. */\r\nfunction checkDiagnostics(emitter, stderr) {\r\n var diagnostic;\r\n var hasErrors = false;\r\n while ((diagnostic = assemblyscript.nextDiagnostic(emitter)) != null) {\r\n if (stderr) {\r\n stderr.write(\r\n assemblyscript.formatDiagnostic(diagnostic, stderr.isTTY, true) +\r\n EOL + EOL\r\n );\r\n }\r\n if (assemblyscript.isError(diagnostic)) hasErrors = true;\r\n }\r\n return hasErrors;\r\n}\r\n\r\nexports.checkDiagnostics = checkDiagnostics;\r\n\r\n/** Creates an empty set of stats. */\r\nfunction createStats() {\r\n return {\r\n readTime: 0,\r\n readCount: 0,\r\n writeTime: 0,\r\n writeCount: 0,\r\n parseTime: 0,\r\n parseCount: 0,\r\n compileTime: 0,\r\n compileCount: 0,\r\n emitTime: 0,\r\n emitCount: 0,\r\n validateTime: 0,\r\n validateCount: 0,\r\n optimizeTime: 0,\r\n optimizeCount: 0\r\n };\r\n}\r\n\r\nexports.createStats = createStats;\r\n\r\nif (!process.hrtime) process.hrtime = require(\"browser-process-hrtime\");\r\n\r\n/** Measures the execution time of the specified function. */\r\nfunction measure(fn) {\r\n const start = process.hrtime();\r\n fn();\r\n const times = process.hrtime(start);\r\n return times[0] * 1e9 + times[1];\r\n}\r\n\r\nexports.measure = measure;\r\n\r\n/** Formats a high resolution time to a human readable string. */\r\nfunction formatTime(time) {\r\n return time ? (time / 1e6).toFixed(3) + \" ms\" : \"N/A\";\r\n}\r\n\r\nexports.formatTime = formatTime;\r\n\r\n/** Formats and prints out the contents of a set of stats. */\r\nfunction printStats(stats, output) {\r\n function format(time, count) {\r\n return formatTime(time);\r\n }\r\n (output || process.stdout).write([\r\n \"I/O Read : \" + format(stats.readTime, stats.readCount),\r\n \"I/O Write : \" + format(stats.writeTime, stats.writeCount),\r\n \"Parse : \" + format(stats.parseTime, stats.parseCount),\r\n \"Compile : \" + format(stats.compileTime, stats.compileCount),\r\n \"Emit : \" + format(stats.emitTime, stats.emitCount),\r\n \"Validate : \" + format(stats.validateTime, stats.validateCount),\r\n \"Optimize : \" + format(stats.optimizeTime, stats.optimizeCount)\r\n ].join(EOL) + EOL);\r\n}\r\n\r\nexports.printStats = printStats;\r\n\r\nvar allocBuffer = typeof global !== \"undefined\" && global.Buffer\r\n ? global.Buffer.allocUnsafe || function(len) { return new global.Buffer(len); }\r\n : function(len) { return new Uint8Array(len) };\r\n\r\n/** Creates a memory stream that can be used in place of stdout/stderr. */\r\nfunction createMemoryStream(fn) {\r\n var stream = [];\r\n stream.write = function(chunk) {\r\n if (fn) fn(chunk);\r\n if (typeof chunk === \"string\") {\r\n let buffer = allocBuffer(utf8.length(chunk));\r\n utf8.write(chunk, buffer, 0);\r\n chunk = buffer;\r\n }\r\n this.push(chunk);\r\n };\r\n stream.reset = function() {\r\n stream.length = 0;\r\n };\r\n stream.toBuffer = function() {\r\n var offset = 0, i = 0, k = this.length;\r\n while (i < k) offset += this[i++].length;\r\n var buffer = allocBuffer(offset);\r\n offset = i = 0;\r\n while (i < k) {\r\n buffer.set(this[i], offset);\r\n offset += this[i].length;\r\n ++i;\r\n }\r\n return buffer;\r\n };\r\n stream.toString = function() {\r\n var buffer = this.toBuffer();\r\n return utf8.read(buffer, 0, buffer.length);\r\n };\r\n return stream;\r\n}\r\n\r\nexports.createMemoryStream = createMemoryStream;\r\n\r\n/** Compatible TypeScript compiler options for syntax highlighting etc. */\r\nexports.tscOptions = {\r\n alwaysStrict: true,\r\n noImplicitAny: true,\r\n noImplicitReturns: true,\r\n noImplicitThis: true,\r\n noEmitOnError: true,\r\n strictNullChecks: true,\r\n experimentalDecorators: true,\r\n target: \"esnext\",\r\n module: \"commonjs\",\r\n noLib: true,\r\n types: [],\r\n allowJs: false\r\n};\r\n","\"use strict\";\r\n\r\n/**\r\n * A minimal UTF8 implementation for number arrays.\r\n * @memberof util\r\n * @namespace\r\n */\r\nvar utf8 = exports;\r\n\r\n/**\r\n * Calculates the UTF8 byte length of a string.\r\n * @param {string} string String\r\n * @returns {number} Byte length\r\n */\r\nutf8.length = function utf8_length(string) {\r\n var len = 0,\r\n c = 0;\r\n for (var i = 0; i < string.length; ++i) {\r\n c = string.charCodeAt(i);\r\n if (c < 128)\r\n len += 1;\r\n else if (c < 2048)\r\n len += 2;\r\n else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {\r\n ++i;\r\n len += 4;\r\n } else\r\n len += 3;\r\n }\r\n return len;\r\n};\r\n\r\n/**\r\n * Reads UTF8 bytes as a string.\r\n * @param {Uint8Array} buffer Source buffer\r\n * @param {number} start Source start\r\n * @param {number} end Source end\r\n * @returns {string} String read\r\n */\r\nutf8.read = function utf8_read(buffer, start, end) {\r\n var len = end - start;\r\n if (len < 1)\r\n return \"\";\r\n var parts = null,\r\n chunk = [],\r\n i = 0, // char offset\r\n t; // temporary\r\n while (start < end) {\r\n t = buffer[start++];\r\n if (t < 128)\r\n chunk[i++] = t;\r\n else if (t > 191 && t < 224)\r\n chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;\r\n else if (t > 239 && t < 365) {\r\n t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;\r\n chunk[i++] = 0xD800 + (t >> 10);\r\n chunk[i++] = 0xDC00 + (t & 1023);\r\n } else\r\n chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;\r\n if (i > 8191) {\r\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\r\n i = 0;\r\n }\r\n }\r\n if (parts) {\r\n if (i)\r\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\r\n return parts.join(\"\");\r\n }\r\n return String.fromCharCode.apply(String, chunk.slice(0, i));\r\n};\r\n\r\n/**\r\n * Writes a string as UTF8 bytes.\r\n * @param {string} string Source string\r\n * @param {Uint8Array} buffer Destination buffer\r\n * @param {number} offset Destination offset\r\n * @returns {number} Bytes written\r\n */\r\nutf8.write = function utf8_write(string, buffer, offset) {\r\n var start = offset,\r\n c1, // character 1\r\n c2; // character 2\r\n for (var i = 0; i < string.length; ++i) {\r\n c1 = string.charCodeAt(i);\r\n if (c1 < 128) {\r\n buffer[offset++] = c1;\r\n } else if (c1 < 2048) {\r\n buffer[offset++] = c1 >> 6 | 192;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {\r\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\r\n ++i;\r\n buffer[offset++] = c1 >> 18 | 240;\r\n buffer[offset++] = c1 >> 12 & 63 | 128;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n } else {\r\n buffer[offset++] = c1 >> 12 | 224;\r\n buffer[offset++] = c1 >> 6 & 63 | 128;\r\n buffer[offset++] = c1 & 63 | 128;\r\n }\r\n }\r\n return offset - start;\r\n};\r\n","var proc = typeof process !== \"undefined\" && process || {};\r\nvar isCI = proc.env && \"CI\" in proc.env; // doesn't work when bundled because 'process' is a mock\r\n\r\nfunction from(stream, base) {\r\n var colors = base || {};\r\n colors.supported = (stream && !!stream.isTTY) || isCI;\r\n colors.gray = text => colors.supported ? exports.GRAY + text + exports.RESET : text;\r\n colors.red = text => colors.supported ? exports.RED + text + exports.RESET : text;\r\n colors.green = text => colors.supported ? exports.GREEN + text + exports.RESET : text;\r\n colors.yellow = text => colors.supported ? exports.YELLOW + text + exports.RESET : text;\r\n colors.blue = text => colors.supported ? exports.BLUE + text + exports.RESET : text;\r\n colors.magenta = text => colors.supported ? exports.MAGENTA + text + exports.RESET : text;\r\n colors.cyan = text => colors.supported ? exports.CYAN + text + exports.RESET : text;\r\n colors.white = text => colors.supported ? exports.WHITE + text + exports.RESET : text;\r\n return colors;\r\n}\r\n\r\nexports.stdout = from(proc.stdout, exports);\r\nexports.stderr = from(proc.stderr);\r\nexports.from = from;\r\n\r\nexports.GRAY = \"\\u001b[90m\";\r\nexports.RED = \"\\u001b[91m\";\r\nexports.GREEN = \"\\u001b[92m\";\r\nexports.YELLOW = \"\\u001b[93m\";\r\nexports.BLUE = \"\\u001b[94m\";\r\nexports.MAGENTA = \"\\u001b[95m\";\r\nexports.CYAN = \"\\u001b[96m\";\r\nexports.WHITE = \"\\u001b[97m\";\r\nexports.RESET = \"\\u001b[0m\";\r\n","// type | meaning\r\n// -----|---------------\r\n// b | boolean\r\n// i | integer\r\n// f | float\r\n// s | string\r\n// I | integer array\r\n// F | float array\r\n// S | string array\r\n\r\n/** Parses the specified command line arguments according to the given configuration. */\r\nfunction parse(argv, config) {\r\n var options = {};\r\n var unknown = [];\r\n var arguments = [];\r\n var trailing = [];\r\n\r\n // make an alias map and initialize defaults\r\n var aliases = {};\r\n Object.keys(config).forEach(key => {\r\n if (key.startsWith(\" \")) return;\r\n var option = config[key];\r\n if (option.alias != null) {\r\n if (typeof option.alias === \"string\") aliases[option.alias] = key;\r\n else if (Array.isArray(option.alias)) option.alias.forEach(alias => aliases[alias] = key);\r\n }\r\n if (option.default != null) options[key] = option.default;\r\n });\r\n\r\n // iterate over argv\r\n for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {\r\n let arg = argv[i];\r\n if (arg == \"--\") { ++i; break; }\r\n let match = /^(?:(\\-\\w)(?:=(.*))?|(\\-\\-\\w{2,})(?:=(.*))?)$/.exec(arg), option, key;\r\n if (match) {\r\n if (config[arg]) option = config[key = arg]; // exact\r\n else if (match[1] != null) { // alias\r\n option = config[key = aliases[match[1].substring(1)]];\r\n if (option && match[2] != null) argv[i--] = match[2];\r\n } else if (match[3] != null) { // full\r\n option = config[key = match[3].substring(2)];\r\n if (option && match[4] != null) argv[i--] = match[4];\r\n }\r\n } else {\r\n if (arg.charCodeAt(0) == 45) option = config[key = arg]; // exact\r\n else { arguments.push(arg); continue; } // argument\r\n }\r\n if (option) {\r\n if (option.type == null || option.type === \"b\") options[key] = true; // flag\r\n else {\r\n if (i + 1 < argv.length && argv[i + 1].charCodeAt(0) != 45) { // present\r\n switch (option.type) {\r\n case \"i\": options[key] = parseInt(argv[++i], 10); break;\r\n case \"I\": options[key] = (options[key] || []).concat(parseInt(argv[++i], 10)); break;\r\n case \"f\": options[key] = parseFloat(argv[++i]); break;\r\n case \"F\": options[key] = (options[key] || []).concat(parseFloat(argv[++i])); break;\r\n case \"s\": options[key] = String(argv[++i]); break;\r\n case \"S\": options[key] = (options[key] || []).concat(argv[++i].split(\",\")); break;\r\n default: unknown.push(arg); --i;\r\n }\r\n } else { // omitted\r\n switch (option.type) {\r\n case \"i\":\r\n case \"f\": options[key] = option.default || 0; break;\r\n case \"s\": options[key] = option.default || \"\"; break;\r\n case \"I\":\r\n case \"F\":\r\n case \"S\": options[key] = options.default || []; break;\r\n default: unknown.push(arg);\r\n }\r\n }\r\n }\r\n if (option.value) Object.keys(option.value).forEach(k => options[k] = option.value[k]);\r\n } else unknown.push(arg);\r\n }\r\n while (i < k) trailing.push(argv[i++]); // trailing\r\n\r\n return { options, unknown, arguments, trailing };\r\n}\r\n\r\nexports.parse = parse;\r\n\r\n/** Generates the help text for the specified configuration. */\r\nfunction help(config, options) {\r\n if (!options) options = {};\r\n var indent = options.indent || 2;\r\n var padding = options.padding || 24;\r\n var eol = options.eol || \"\\n\";\r\n var sb = [];\r\n Object.keys(config).forEach(key => {\r\n var option = config[key];\r\n if (option.description == null) return;\r\n var text = \"\";\r\n while (text.length < indent) text += \" \";\r\n text += \"--\" + key;\r\n if (option.alias) text += \", -\" + option.alias;\r\n while (text.length < padding) text += \" \";\r\n if (Array.isArray(option.description)) {\r\n sb.push(text + option.description[0] + option.description.slice(1).map(line => {\r\n for (let i = 0; i < padding; ++i) line = \" \" + line;\r\n return eol + line;\r\n }).join(\"\"));\r\n } else sb.push(text + option.description);\r\n });\r\n return sb.join(eol);\r\n}\r\n\r\nexports.help = help;\r\n","/*\r\nCopyright 2010 James Halliday (mail@substack.net)\r\n\r\nThis project is free software released under the MIT/X11 license:\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n*/\r\n\r\nvar path = require(\"path\");\r\nvar fs = require(\"fs\");\r\nvar _0777 = parseInt(\"0777\", 8);\r\n\r\nmodule.exports = function mkdirp(p, opts, made) {\r\n if (!opts || typeof opts !== \"object\") {\r\n opts = { mode: opts };\r\n }\r\n var mode = opts.mode;\r\n if (mode === undefined) {\r\n mode = _0777 & (~process.umask());\r\n }\r\n if (!made) made = null;\r\n p = path.resolve(p);\r\n try {\r\n fs.mkdirSync(p, mode);\r\n made = made || p;\r\n } catch (err0) {\r\n switch (err0.code) {\r\n case \"ENOENT\":\r\n made = mkdirp(path.dirname(p), opts, made);\r\n mkdirp(p, opts, made);\r\n break;\r\n default:\r\n var stat;\r\n try {\r\n stat = fs.statSync(p);\r\n } catch (err1) {\r\n throw err0;\r\n }\r\n if (!stat.isDirectory()) throw err0;\r\n break;\r\n }\r\n }\r\n return made;\r\n};\r\n","if(typeof __WEBPACK_EXTERNAL_MODULE__10__ === 'undefined') {var e = new Error(\"Cannot find module 'assemblyscript'\"); e.code = 'MODULE_NOT_FOUND'; throw e;}\nmodule.exports = __WEBPACK_EXTERNAL_MODULE__10__;","function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = 12;","module.exports = process.hrtime || hrtime\n\n// polyfil for window.performance.now\nvar performance = global.performance || {}\nvar performanceNow =\n performance.now ||\n performance.mozNow ||\n performance.msNow ||\n performance.oNow ||\n performance.webkitNow ||\n function(){ return (new Date()).getTime() }\n\n// generate timestamp or delta\n// see http://nodejs.org/api/process.html#process_process_hrtime\nfunction hrtime(previousTimestamp){\n var clocktime = performanceNow.call(performance)*1e-3\n var seconds = Math.floor(clocktime)\n var nanoseconds = Math.floor((clocktime%1)*1e9)\n if (previousTimestamp) {\n seconds = seconds - previousTimestamp[0]\n nanoseconds = nanoseconds - previousTimestamp[1]\n if (nanoseconds<0) {\n seconds--\n nanoseconds += 1e9\n }\n }\n return [seconds,nanoseconds]\n}"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/assemblyscript.d.ts b/dist/assemblyscript.d.ts new file mode 100644 index 00000000..2833142d --- /dev/null +++ b/dist/assemblyscript.d.ts @@ -0,0 +1,5591 @@ +declare type bool = boolean; +declare type i8 = number; +declare type i16 = number; +declare type i32 = number; +declare type isize = number; +declare type u8 = number; +declare type u16 = number; +declare type u32 = number; +declare type usize = number; +declare type f32 = number; +declare type f64 = number; +declare module 'assemblyscript' { + export * from 'assemblyscript/src/index'; +} +declare module 'assemblyscript/src/common' { + /** + * Common constants. + * @module common + */ /***/ + /** Indicates traits of a {@link Node} or {@link Element}. */ + export enum CommonFlags { + /** No flags set. */ + NONE = 0, + /** Has an `import` modifier. */ + IMPORT = 1, + /** Has an `export` modifier. */ + EXPORT = 2, + /** Has a `declare` modifier. */ + DECLARE = 4, + /** Has a `const` modifier. */ + CONST = 8, + /** Has a `let` modifier. */ + LET = 16, + /** Has a `static` modifier. */ + STATIC = 32, + /** Has a `readonly` modifier. */ + READONLY = 64, + /** Has an `abstract` modifier. */ + ABSTRACT = 128, + /** Has a `public` modifier. */ + PUBLIC = 256, + /** Has a `private` modifier. */ + PRIVATE = 512, + /** Has a `protected` modifier. */ + PROTECTED = 1024, + /** Has a `get` modifier. */ + GET = 2048, + /** Has a `set` modifier. */ + SET = 4096, + /** Has a definite assignment assertion `!` as in `x!: i32;`. */ + DEFINITE_ASSIGNMENT = 8192, + /** Is ambient, that is either declared or nested in a declared element. */ + AMBIENT = 16384, + /** Is generic. */ + GENERIC = 32768, + /** Is part of a generic context. */ + GENERIC_CONTEXT = 65536, + /** Is an instance member. */ + INSTANCE = 131072, + /** Is a constructor. */ + CONSTRUCTOR = 262144, + /** Is a module export. */ + MODULE_EXPORT = 524288, + /** Is a module import. */ + MODULE_IMPORT = 1048576, + /** Is resolved. */ + RESOLVED = 2097152, + /** Is compiled. */ + COMPILED = 4194304, + /** Has a constant value and is therefore inlined. */ + INLINED = 8388608, + /** Is scoped. */ + SCOPED = 16777216, + /** Is a trampoline. */ + TRAMPOLINE = 33554432, + /** Is a virtual method. */ + VIRTUAL = 67108864, + /** Is the main function. */ + MAIN = 134217728, + /** Is quoted. */ + QUOTED = 268435456 + } + /** Path delimiter inserted between file system levels. */ + export const PATH_DELIMITER = "/"; + /** Substitution used to indicate the parent directory. */ + export const PARENT_SUBST = ".."; + /** Function name prefix used for getters. */ + export const GETTER_PREFIX = "get:"; + /** Function name prefix used for setters. */ + export const SETTER_PREFIX = "set:"; + /** Delimiter used between class names and instance members. */ + export const INSTANCE_DELIMITER = "#"; + /** Delimiter used between class and namespace names and static members. */ + export const STATIC_DELIMITER = "."; + /** Delimiter used between a function and its inner elements. */ + export const INNER_DELIMITER = "~"; + /** Substitution used to indicate a library directory. */ + export const LIBRARY_SUBST = "~lib"; + /** Library directory prefix. */ + export const LIBRARY_PREFIX: string; + /** Path index suffix. */ + export const INDEX_SUFFIX: string; + /** Common compiler symbols. */ + export namespace CommonSymbols { + const EMPTY = ""; + const i8 = "i8"; + const i16 = "i16"; + const i32 = "i32"; + const i64 = "i64"; + const isize = "isize"; + const u8 = "u8"; + const u16 = "u16"; + const u32 = "u32"; + const u64 = "u64"; + const usize = "usize"; + const bool = "bool"; + const f32 = "f32"; + const f64 = "f64"; + const v128 = "v128"; + const i8x16 = "i8x16"; + const u8x16 = "u8x16"; + const i16x8 = "i16x8"; + const u16x8 = "u16x8"; + const i32x4 = "i32x4"; + const u32x4 = "u32x4"; + const i64x2 = "i64x2"; + const u64x2 = "u64x2"; + const f32x4 = "f32x4"; + const f64x2 = "f64x2"; + const void_ = "void"; + const number = "number"; + const boolean = "boolean"; + const string = "string"; + const native = "native"; + const null_ = "null"; + const true_ = "true"; + const false_ = "false"; + const this_ = "this"; + const super_ = "super"; + const constructor = "constructor"; + const ASC_TARGET = "ASC_TARGET"; + const ASC_NO_TREESHAKING = "ASC_NO_TREESHAKING"; + const ASC_NO_ASSERT = "ASC_NO_ASSERT"; + const ASC_MEMORY_BASE = "ASC_MEMORY_BASE"; + const ASC_OPTIMIZE_LEVEL = "ASC_OPTIMIZE_LEVEL"; + const ASC_SHRINK_LEVEL = "ASC_SHRINK_LEVEL"; + const ASC_FEATURE_MUTABLE_GLOBAL = "ASC_FEATURE_MUTABLE_GLOBAL"; + const ASC_FEATURE_SIGN_EXTENSION = "ASC_FEATURE_SIGN_EXTENSION"; + const ASC_FEATURE_BULK_MEMORY = "ASC_FEATURE_BULK_MEMORY"; + const ASC_FEATURE_SIMD = "ASC_FEATURE_SIMD"; + const ASC_FEATURE_THREADS = "ASC_FEATURE_THREADS"; + const I8 = "I8"; + const I16 = "I16"; + const I32 = "I32"; + const I64 = "I64"; + const Isize = "Isize"; + const U8 = "U8"; + const U16 = "U16"; + const U32 = "U32"; + const U64 = "U64"; + const Usize = "Usize"; + const Bool = "Bool"; + const F32 = "F32"; + const F64 = "F64"; + const V128 = "V128"; + const String = "String"; + const Array = "Array"; + const FixedArray = "FixedArray"; + const Set = "Set"; + const Map = "Map"; + const ArrayBufferView = "ArrayBufferView"; + const ArrayBuffer = "ArrayBuffer"; + const Math = "Math"; + const Mathf = "Mathf"; + const Int8Array = "Int8Array"; + const Int16Array = "Int16Array"; + const Int32Array = "Int32Array"; + const Int64Array = "Int64Array"; + const Uint8Array = "Uint8Array"; + const Uint8ClampedArray = "Uint8ClampedArray"; + const Uint16Array = "Uint16Array"; + const Uint32Array = "Uint32Array"; + const Uint64Array = "Uint64Array"; + const Float32Array = "Float32Array"; + const Float64Array = "Float64Array"; + const abort = "abort"; + const pow = "pow"; + const mod = "mod"; + const alloc = "__alloc"; + const realloc = "__realloc"; + const free = "__free"; + const retain = "__retain"; + const release = "__release"; + const collect = "__collect"; + const typeinfo = "__typeinfo"; + const instanceof_ = "__instanceof"; + const visit = "__visit"; + const allocArray = "__allocArray"; + } + export { Feature } from 'assemblyscript/std/assembly/shared/feature'; + export { Target } from 'assemblyscript/std/assembly/shared/target'; + export { Typeinfo, TypeinfoFlags } from 'assemblyscript/std/assembly/shared/typeinfo'; + +} +declare module 'assemblyscript/src/diagnosticMessages.generated' { + /** + * Generated from diagnosticsMessages.json. Do not edit. + * @module diagnostics + */ /***/ + /** Enum of available diagnostic codes. */ + export enum DiagnosticCode { + Operation_not_supported = 100, + Operation_is_unsafe = 101, + User_defined_0 = 102, + Conversion_from_type_0_to_1_requires_an_explicit_cast = 200, + Conversion_from_type_0_to_1_will_require_an_explicit_cast_when_switching_between_32_64_bit = 201, + Type_0_cannot_be_changed_to_type_1 = 202, + Type_0_cannot_be_reinterpreted_as_type_1 = 203, + Basic_type_0_cannot_be_nullable = 204, + Cannot_export_a_mutable_global = 205, + Compiling_constant_with_non_constant_initializer_as_mutable = 206, + Unmanaged_classes_cannot_extend_managed_classes_and_vice_versa = 207, + Unmanaged_classes_cannot_implement_interfaces = 208, + Invalid_regular_expression_flags = 209, + Implementation_0_must_match_the_signature_1 = 210, + Class_0_is_sealed_and_cannot_be_extended = 211, + Decorator_0_is_not_valid_here = 212, + Duplicate_decorator = 213, + An_allocator_must_be_present_to_use_0 = 214, + Optional_parameter_must_have_an_initializer = 215, + Constructor_of_class_0_must_not_require_any_arguments = 216, + Function_0_cannot_be_inlined_into_itself = 217, + Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set = 218, + Optional_properties_are_not_supported = 219, + Expression_must_be_a_compile_time_constant = 220, + Module_cannot_have_multiple_start_functions = 221, + _0_must_be_a_value_between_1_and_2_inclusive = 222, + _0_must_be_a_power_of_two = 223, + TODO_Cannot_inline_inferred_calls_and_specific_internals_yet = 224, + Expression_is_never_null = 225, + Unterminated_string_literal = 1002, + Identifier_expected = 1003, + _0_expected = 1005, + A_file_cannot_have_a_reference_to_itself = 1006, + Trailing_comma_not_allowed = 1009, + Unexpected_token = 1012, + A_rest_parameter_must_be_last_in_a_parameter_list = 1014, + Parameter_cannot_have_question_mark_and_initializer = 1015, + A_required_parameter_cannot_follow_an_optional_parameter = 1016, + Statements_are_not_allowed_in_ambient_contexts = 1036, + Initializers_are_not_allowed_in_ambient_contexts = 1039, + _0_modifier_cannot_be_used_here = 1042, + A_rest_parameter_cannot_be_optional = 1047, + A_rest_parameter_cannot_have_an_initializer = 1048, + A_set_accessor_must_have_exactly_one_parameter = 1049, + A_set_accessor_parameter_cannot_have_an_initializer = 1052, + A_get_accessor_cannot_have_parameters = 1054, + Enum_member_must_have_initializer = 1061, + Type_parameters_cannot_appear_on_a_constructor_declaration = 1092, + Type_annotation_cannot_appear_on_a_constructor_declaration = 1093, + An_accessor_cannot_have_type_parameters = 1094, + A_set_accessor_cannot_have_a_return_type_annotation = 1095, + Type_parameter_list_cannot_be_empty = 1098, + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement = 1104, + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement = 1105, + A_return_statement_can_only_be_used_within_a_function_body = 1108, + Expression_expected = 1109, + Type_expected = 1110, + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement = 1113, + Duplicate_label_0 = 1114, + Octal_literals_are_not_allowed_in_strict_mode = 1121, + Digit_expected = 1124, + Hexadecimal_digit_expected = 1125, + Unexpected_end_of_text = 1126, + Invalid_character = 1127, + _case_or_default_expected = 1130, + _super_must_be_followed_by_an_argument_list_or_member_access = 1034, + A_declare_modifier_cannot_be_used_in_an_already_ambient_context = 1038, + Type_argument_expected = 1140, + String_literal_expected = 1141, + Line_break_not_permitted_here = 1142, + Declaration_expected = 1146, + _const_declarations_must_be_initialized = 1155, + Unterminated_regular_expression_literal = 1161, + Interface_declaration_cannot_have_implements_clause = 1176, + Binary_digit_expected = 1177, + Octal_digit_expected = 1178, + An_implementation_cannot_be_declared_in_ambient_contexts = 1183, + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive = 1198, + Unterminated_Unicode_escape_sequence = 1199, + Decorators_are_not_valid_here = 1206, + _abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration = 1242, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract = 1245, + A_definite_assignment_assertion_is_not_permitted_in_this_context = 1255, + A_class_may_only_extend_another_class = 1311, + A_parameter_property_cannot_be_declared_using_a_rest_parameter = 1317, + Duplicate_identifier_0 = 2300, + Cannot_find_name_0 = 2304, + Module_0_has_no_exported_member_1 = 2305, + Generic_type_0_requires_1_type_argument_s = 2314, + Type_0_is_not_generic = 2315, + Type_0_is_not_assignable_to_type_1 = 2322, + Index_signature_is_missing_in_type_0 = 2329, + _this_cannot_be_referenced_in_current_location = 2332, + _super_can_only_be_referenced_in_a_derived_class = 2335, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors = 2337, + Property_0_does_not_exist_on_type_1 = 2339, + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures = 2349, + Cannot_use_new_with_an_expression_whose_type_lacks_a_construct_signature = 2351, + A_function_whose_declared_type_is_not_void_must_return_a_value = 2355, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access = 2357, + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access = 2364, + Operator_0_cannot_be_applied_to_types_1_and_2 = 2365, + A_super_call_must_be_the_first_statement_in_the_constructor = 2376, + Constructors_for_derived_classes_must_contain_a_super_call = 2377, + _get_and_set_accessor_must_have_the_same_type = 2380, + Constructor_implementation_is_missing = 2390, + Function_implementation_is_missing_or_not_immediately_following_the_declaration = 2391, + Multiple_constructor_implementations_are_not_allowed = 2392, + Duplicate_function_implementation = 2393, + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local = 2395, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged = 2434, + Type_0_has_no_property_1 = 2460, + The_0_operator_cannot_be_applied_to_type_1 = 2469, + In_const_enum_declarations_member_initializer_must_be_constant_expression = 2474, + Export_declaration_conflicts_with_exported_declaration_of_0 = 2484, + Object_is_possibly_null = 2531, + Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property = 2540, + The_target_of_an_assignment_must_be_a_variable_or_a_property_access = 2541, + Index_signature_in_type_0_only_permits_reading = 2542, + Expected_0_arguments_but_got_1 = 2554, + Expected_at_least_0_arguments_but_got_1 = 2555, + Expected_0_type_arguments_but_got_1 = 2558, + A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums = 2651, + Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration = 2673, + Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration = 2674, + Namespace_0_has_no_exported_member_1 = 2694, + Required_type_parameters_may_not_follow_optional_type_parameters = 2706, + Duplicate_property_0 = 2718, + File_0_not_found = 6054, + Numeric_separators_are_not_allowed_here = 6188, + Multiple_consecutive_numeric_separators_are_not_permitted = 6189, + _super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class = 17009, + _super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class = 17011 + } + /** Translates a diagnostic code to its respective string. */ + export function diagnosticCodeToString(code: DiagnosticCode): string; + +} +declare module 'assemblyscript/src/util/bitset' { + /** @module util */ /***/ + /** Tests if the bit at the specified index is set within a 64-bit map. */ + export function bitsetIs(map: I64, index: i32): bool; + /** Sets or unsets the bit at the specified index within a 64-bit map and returns the new map. */ + export function bitsetSet(map: I64, index: i32, isSet: bool): I64; + +} +declare module 'assemblyscript/src/util/charcode' { + /** @module util */ /***/ + /** An enum of named character codes. */ + export const enum CharCode { + NULL = 0, + LINEFEED = 10, + CARRIAGERETURN = 13, + LINESEPARATOR = 8232, + PARAGRAPHSEPARATOR = 8233, + NEXTLINE = 133, + SPACE = 32, + NONBREAKINGSPACE = 160, + ENQUAD = 8192, + EMQUAD = 8193, + ENSPACE = 8194, + EMSPACE = 8195, + THREEPEREMSPACE = 8196, + FOURPEREMSPACE = 8197, + SIXPEREMSPACE = 8198, + FIGURESPACE = 8199, + PUNCTUATIONSPACE = 8200, + THINSPACE = 8201, + HAIRSPACE = 8202, + ZEROWIDTHSPACE = 8203, + NARROWNOBREAKSPACE = 8239, + IDEOGRAPHICSPACE = 12288, + MATHEMATICALSPACE = 8287, + OGHAM = 5760, + _ = 95, + _0 = 48, + _1 = 49, + _2 = 50, + _3 = 51, + _4 = 52, + _5 = 53, + _6 = 54, + _7 = 55, + _8 = 56, + _9 = 57, + a = 97, + b = 98, + c = 99, + d = 100, + e = 101, + f = 102, + g = 103, + h = 104, + i = 105, + j = 106, + k = 107, + l = 108, + m = 109, + n = 110, + o = 111, + p = 112, + q = 113, + r = 114, + s = 115, + t = 116, + u = 117, + v = 118, + w = 119, + x = 120, + y = 121, + z = 122, + A = 65, + B = 66, + C = 67, + D = 68, + E = 69, + F = 70, + G = 71, + H = 72, + I = 73, + J = 74, + K = 75, + L = 76, + M = 77, + N = 78, + O = 79, + P = 80, + Q = 81, + R = 82, + S = 83, + T = 84, + U = 85, + V = 86, + W = 87, + X = 88, + Y = 89, + Z = 90, + AMPERSAND = 38, + ASTERISK = 42, + AT = 64, + BACKSLASH = 92, + BACKTICK = 96, + BAR = 124, + CARET = 94, + CLOSEBRACE = 125, + CLOSEBRACKET = 93, + CLOSEPAREN = 41, + COLON = 58, + COMMA = 44, + DOLLAR = 36, + DOT = 46, + DOUBLEQUOTE = 34, + EQUALS = 61, + EXCLAMATION = 33, + GREATERTHAN = 62, + HASH = 35, + LESSTHAN = 60, + MINUS = 45, + OPENBRACE = 123, + OPENBRACKET = 91, + OPENPAREN = 40, + PERCENT = 37, + PLUS = 43, + QUESTION = 63, + SEMICOLON = 59, + SINGLEQUOTE = 39, + SLASH = 47, + TILDE = 126, + BACKSPACE = 8, + FORMFEED = 12, + BYTEORDERMARK = 65279, + TAB = 9, + VERTICALTAB = 11 + } + /** Tests if the specified character code is some sort of line break. */ + export function isLineBreak(c: CharCode): bool; + /** Tests if the specified character code is some sort of white space. */ + export function isWhiteSpace(c: i32): bool; + /** Tests if the specified character code is a valid decimal digit. */ + export function isDecimalDigit(c: i32): bool; + /** Tests if the specified character code is a valid octal digit. */ + export function isOctalDigit(c: i32): bool; + /** Tests if the specified character code is a valid start of an identifier. */ + export function isIdentifierStart(c: i32): bool; + /** Tests if the specified character code is a valid keyword character. */ + export function isKeywordCharacter(c: i32): bool; + /** Tests if the specified character code is a valid part of an identifier. */ + export function isIdentifierPart(c: i32): bool; + +} +declare module 'assemblyscript/src/util/collections' { + export function makeArray(original?: Array | null): Array; + export function makeSet(original?: Set | null): Set; + export function makeMap(original?: Map | null, overrides?: Map | null): Map; + +} +declare module 'assemblyscript/src/util/path' { + /** @module util */ /***/ + /** + * Normalizes the specified path, removing interior placeholders. + * Expects a posix-compatible relative path (not Windows compatible). + */ + export function normalizePath(path: string): string; + /** Resolves the specified path relative to the specified origin. */ + export function resolvePath(normalizedPath: string, origin: string): string; + /** Obtains the directory portion of a normalized path. */ + export function dirname(normalizedPath: string): string; + +} +declare module 'assemblyscript/src/util/text' { + /** @module util */ /***/ + /** Creates an indentation matching the number of specified levels. */ + export function indent(sb: string[], level: i32): void; + +} +declare module 'assemblyscript/src/util/binary' { + /** @module util */ /***/ + /** Reads an 8-bit integer from the specified buffer. */ + export function readI8(buffer: Uint8Array, offset: i32): i32; + /** Writes an 8-bit integer to the specified buffer. */ + export function writeI8(value: i32, buffer: Uint8Array, offset: i32): void; + /** Reads a 16-bit integer from the specified buffer. */ + export function readI16(buffer: Uint8Array, offset: i32): i32; + /** Writes a 16-bit integer to the specified buffer. */ + export function writeI16(value: i32, buffer: Uint8Array, offset: i32): void; + /** Reads a 32-bit integer from the specified buffer. */ + export function readI32(buffer: Uint8Array, offset: i32): i32; + /** Writes a 32-bit integer to the specified buffer. */ + export function writeI32(value: i32, buffer: Uint8Array, offset: i32): void; + /** Reads a 64-bit integer from the specified buffer. */ + export function readI64(buffer: Uint8Array, offset: i32): I64; + /** Writes a 64-bit integer to the specified buffer. */ + export function writeI64(value: I64, buffer: Uint8Array, offset: i32): void; + /** Reads a 32-bit float from the specified buffer. */ + export function readF32(buffer: Uint8Array, offset: i32): f32; + /** Writes a 32-bit float to the specified buffer. */ + export function writeF32(value: f32, buffer: Uint8Array, offset: i32): void; + /** Reads a 64-bit float from the specified buffer. */ + export function readF64(buffer: Uint8Array, offset: i32): f64; + /** Writes a 64-bit float to the specified buffer. */ + export function writeF64(value: f64, buffer: Uint8Array, offset: i32): void; + +} +declare module 'assemblyscript/src/util/index' { + /** + * Various compiler utilities. + * @module util + * @preferred + */ /***/ + export * from 'assemblyscript/src/util/bitset'; + export * from 'assemblyscript/src/util/charcode'; + export * from 'assemblyscript/src/util/collections'; + export * from 'assemblyscript/src/util/path'; + export * from 'assemblyscript/src/util/text'; + export * from 'assemblyscript/src/util/binary'; + /** Tests if `x` is a power of two. */ + export function isPowerOf2(x: i32): bool; + +} +declare module 'assemblyscript/src/diagnostics' { + /** + * Shared diagnostic handling inherited by the parser and the compiler. + * @module diagnostics + * @preferred + */ /***/ + import { Range } from 'assemblyscript/src/ast'; + import { DiagnosticCode } from 'assemblyscript/src/diagnosticMessages.generated'; + export { DiagnosticCode, diagnosticCodeToString } from 'assemblyscript/src/diagnosticMessages.generated'; + /** Indicates the category of a {@link DiagnosticMessage}. */ + export enum DiagnosticCategory { + /** Informatory message. */ + INFO = 0, + /** Warning message. */ + WARNING = 1, + /** Error message. */ + ERROR = 2 + } + /** Returns the string representation of the specified diagnostic category. */ + export function diagnosticCategoryToString(category: DiagnosticCategory): string; + /** ANSI escape sequence for blue foreground. */ + export const COLOR_BLUE: string; + /** ANSI escape sequence for yellow foreground. */ + export const COLOR_YELLOW: string; + /** ANSI escape sequence for red foreground. */ + export const COLOR_RED: string; + /** ANSI escape sequence to reset the foreground color. */ + export const COLOR_RESET: string; + /** Returns the ANSI escape sequence for the specified category. */ + export function diagnosticCategoryToColor(category: DiagnosticCategory): string; + /** Represents a diagnostic message. */ + export class DiagnosticMessage { + /** Message code. */ + code: i32; + /** Message category. */ + category: DiagnosticCategory; + /** Message text. */ + message: string; + /** Respective source range, if any. */ + range: Range | null; + /** Related range, if any. */ + relatedRange: Range | null; + /** Constructs a new diagnostic message. */ + private constructor(); + /** Creates a new diagnostic message of the specified category. */ + static create(code: DiagnosticCode, category: DiagnosticCategory, arg0?: string | null, arg1?: string | null, arg2?: string | null): DiagnosticMessage; + /** Creates a new informatory diagnostic message. */ + static createInfo(code: DiagnosticCode, arg0?: string | null, arg1?: string | null): DiagnosticMessage; + /** Creates a new warning diagnostic message. */ + static createWarning(code: DiagnosticCode, arg0?: string | null, arg1?: string | null): DiagnosticMessage; + /** Creates a new error diagnostic message. */ + static createError(code: DiagnosticCode, arg0?: string | null, arg1?: string | null): DiagnosticMessage; + /** Adds a source range to this message. */ + withRange(range: Range): this; + /** Adds a related source range to this message. */ + withRelatedRange(range: Range): this; + /** Converts this message to a string. */ + toString(): string; + } + /** Formats a diagnostic message, optionally with terminal colors and source context. */ + export function formatDiagnosticMessage(message: DiagnosticMessage, useColors?: bool, showContext?: bool): string; + /** Formats the diagnostic context for the specified range, optionally with terminal colors. */ + export function formatDiagnosticContext(range: Range, useColors?: bool): string; + /** Base class of all diagnostic emitters. */ + export abstract class DiagnosticEmitter { + /** Diagnostic messages emitted so far. */ + diagnostics: DiagnosticMessage[]; + /** Initializes this diagnostic emitter. */ + protected constructor(diagnostics?: DiagnosticMessage[] | null); + /** Emits a diagnostic message of the specified category. */ + emitDiagnostic(code: DiagnosticCode, category: DiagnosticCategory, range: Range, relatedRange: Range | null, arg0?: string | null, arg1?: string | null, arg2?: string | null): void; + /** Emits an informatory diagnostic message. */ + info(code: DiagnosticCode, range: Range, arg0?: string | null, arg1?: string | null, arg2?: string | null): void; + /** Emits an informatory diagnostic message with a related range. */ + infoRelated(code: DiagnosticCode, range: Range, relatedRange: Range, arg0?: string | null, arg1?: string | null, arg2?: string | null): void; + /** Emits a warning diagnostic message. */ + warning(code: DiagnosticCode, range: Range, arg0?: string | null, arg1?: string | null, arg2?: string | null): void; + /** Emits a warning diagnostic message with a related range. */ + warningRelated(code: DiagnosticCode, range: Range, relatedRange: Range, arg0?: string | null, arg1?: string | null, arg2?: string | null): void; + /** Emits an error diagnostic message. */ + error(code: DiagnosticCode, range: Range, arg0?: string | null, arg1?: string | null, arg2?: string | null): void; + /** Emits an error diagnostic message with a related range. */ + errorRelated(code: DiagnosticCode, range: Range, relatedRange: Range, arg0?: string | null, arg1?: string | null, arg2?: string | null): void; + } + +} +declare module 'assemblyscript/src/tokenizer' { + /** + * A TypeScript tokenizer modified for AssemblyScript. + * + * Skips over trivia and provides a general mark/reset mechanism for the parser to utilize on + * ambiguous tokens. + * + * @module tokenizer + */ /***/ + import { DiagnosticMessage, DiagnosticEmitter } from 'assemblyscript/src/diagnostics'; + import { Source, CommentKind } from 'assemblyscript/src/ast'; + /** Named token types. */ + export enum Token { + ABSTRACT = 0, + AS = 1, + ASYNC = 2, + AWAIT = 3, + BREAK = 4, + CASE = 5, + CATCH = 6, + CLASS = 7, + CONST = 8, + CONTINUE = 9, + CONSTRUCTOR = 10, + DEBUGGER = 11, + DECLARE = 12, + DEFAULT = 13, + DELETE = 14, + DO = 15, + ELSE = 16, + ENUM = 17, + EXPORT = 18, + EXTENDS = 19, + FALSE = 20, + FINALLY = 21, + FOR = 22, + FROM = 23, + FUNCTION = 24, + GET = 25, + IF = 26, + IMPLEMENTS = 27, + IMPORT = 28, + IN = 29, + INSTANCEOF = 30, + INTERFACE = 31, + IS = 32, + KEYOF = 33, + LET = 34, + MODULE = 35, + NAMESPACE = 36, + NEW = 37, + NULL = 38, + OF = 39, + PACKAGE = 40, + PRIVATE = 41, + PROTECTED = 42, + PUBLIC = 43, + READONLY = 44, + RETURN = 45, + SET = 46, + STATIC = 47, + SUPER = 48, + SWITCH = 49, + THIS = 50, + THROW = 51, + TRUE = 52, + TRY = 53, + TYPE = 54, + TYPEOF = 55, + VAR = 56, + VOID = 57, + WHILE = 58, + WITH = 59, + YIELD = 60, + OPENBRACE = 61, + CLOSEBRACE = 62, + OPENPAREN = 63, + CLOSEPAREN = 64, + OPENBRACKET = 65, + CLOSEBRACKET = 66, + DOT = 67, + DOT_DOT_DOT = 68, + SEMICOLON = 69, + COMMA = 70, + LESSTHAN = 71, + GREATERTHAN = 72, + LESSTHAN_EQUALS = 73, + GREATERTHAN_EQUALS = 74, + EQUALS_EQUALS = 75, + EXCLAMATION_EQUALS = 76, + EQUALS_EQUALS_EQUALS = 77, + EXCLAMATION_EQUALS_EQUALS = 78, + EQUALS_GREATERTHAN = 79, + PLUS = 80, + MINUS = 81, + ASTERISK_ASTERISK = 82, + ASTERISK = 83, + SLASH = 84, + PERCENT = 85, + PLUS_PLUS = 86, + MINUS_MINUS = 87, + LESSTHAN_LESSTHAN = 88, + GREATERTHAN_GREATERTHAN = 89, + GREATERTHAN_GREATERTHAN_GREATERTHAN = 90, + AMPERSAND = 91, + BAR = 92, + CARET = 93, + EXCLAMATION = 94, + TILDE = 95, + AMPERSAND_AMPERSAND = 96, + BAR_BAR = 97, + QUESTION = 98, + COLON = 99, + EQUALS = 100, + PLUS_EQUALS = 101, + MINUS_EQUALS = 102, + ASTERISK_EQUALS = 103, + ASTERISK_ASTERISK_EQUALS = 104, + SLASH_EQUALS = 105, + PERCENT_EQUALS = 106, + LESSTHAN_LESSTHAN_EQUALS = 107, + GREATERTHAN_GREATERTHAN_EQUALS = 108, + GREATERTHAN_GREATERTHAN_GREATERTHAN_EQUALS = 109, + AMPERSAND_EQUALS = 110, + BAR_EQUALS = 111, + CARET_EQUALS = 112, + AT = 113, + IDENTIFIER = 114, + STRINGLITERAL = 115, + INTEGERLITERAL = 116, + FLOATLITERAL = 117, + INVALID = 118, + ENDOFFILE = 119 + } + export enum IdentifierHandling { + DEFAULT = 0, + PREFER = 1, + ALWAYS = 2 + } + export function tokenFromKeyword(text: string): Token; + export function tokenIsAlsoIdentifier(token: Token): bool; + export function operatorTokenToString(token: Token): string; + export class Range { + source: Source; + start: i32; + end: i32; + constructor(source: Source, start: i32, end: i32); + static join(a: Range, b: Range): Range; + readonly atStart: Range; + readonly atEnd: Range; + readonly line: i32; + readonly column: i32; + toString(): string; + debugInfoRef: usize; + } + /** Handler for intercepting comments while tokenizing. */ + export type CommentHandler = (kind: CommentKind, text: string, range: Range) => void; + /** Tokenizes a source to individual {@link Token}s. */ + export class Tokenizer extends DiagnosticEmitter { + source: Source; + end: i32; + pos: i32; + token: Token; + tokenPos: i32; + nextToken: Token; + nextTokenPos: i32; + nextTokenOnNewLine: bool; + onComment: CommentHandler | null; + /** Constructs a new tokenizer. */ + constructor(source: Source, diagnostics?: DiagnosticMessage[] | null); + next(identifierHandling?: IdentifierHandling): Token; + private unsafeNext; + peek(checkOnNewLine?: bool, identifierHandling?: IdentifierHandling, maxCompoundLength?: i32): Token; + skipIdentifier(identifierHandling?: IdentifierHandling): bool; + skip(token: Token, identifierHandling?: IdentifierHandling): bool; + mark(): State; + discard(state: State): void; + reset(state: State): void; + range(start?: i32, end?: i32): Range; + readIdentifier(): string; + readString(): string; + readEscapeSequence(): string; + readRegexpPattern(): string; + readRegexpFlags(): string; + testInteger(): bool; + readInteger(): I64; + readHexInteger(): I64; + readDecimalInteger(): I64; + readOctalInteger(): I64; + readBinaryInteger(): I64; + readFloat(): f64; + readDecimalFloat(): f64; + readHexFloat(): f64; + readUnicodeEscape(): string; + private readExtendedUnicodeEscape; + finish(): void; + } + /** Tokenizer state as returned by {@link Tokenizer#mark} and consumed by {@link Tokenizer#reset}. */ + export class State { + /** Current position. */ + pos: i32; + /** Current token. */ + token: Token; + /** Current token's position. */ + tokenPos: i32; + } + +} +declare module 'assemblyscript/src/ast' { + /** + * Abstract syntax tree representing a source file once parsed. + * @module ast + */ /***/ + import { CommonFlags } from 'assemblyscript/src/common'; + import { Token, Tokenizer, Range } from 'assemblyscript/src/tokenizer'; + export { Token, Range }; + /** Indicates the kind of a node. */ + export enum NodeKind { + SOURCE = 0, + TYPE = 1, + TYPENAME = 2, + TYPEPARAMETER = 3, + PARAMETER = 4, + SIGNATURE = 5, + IDENTIFIER = 6, + ASSERTION = 7, + BINARY = 8, + CALL = 9, + CLASS = 10, + COMMA = 11, + ELEMENTACCESS = 12, + FALSE = 13, + FUNCTION = 14, + INSTANCEOF = 15, + LITERAL = 16, + NEW = 17, + NULL = 18, + PARENTHESIZED = 19, + PROPERTYACCESS = 20, + TERNARY = 21, + SUPER = 22, + THIS = 23, + TRUE = 24, + CONSTRUCTOR = 25, + UNARYPOSTFIX = 26, + UNARYPREFIX = 27, + BLOCK = 28, + BREAK = 29, + CONTINUE = 30, + DO = 31, + EMPTY = 32, + EXPORT = 33, + EXPORTIMPORT = 34, + EXPRESSION = 35, + FOR = 36, + IF = 37, + IMPORT = 38, + RETURN = 39, + SWITCH = 40, + THROW = 41, + TRY = 42, + VARIABLE = 43, + VOID = 44, + WHILE = 45, + CLASSDECLARATION = 46, + ENUMDECLARATION = 47, + ENUMVALUEDECLARATION = 48, + FIELDDECLARATION = 49, + FUNCTIONDECLARATION = 50, + IMPORTDECLARATION = 51, + INDEXSIGNATUREDECLARATION = 52, + INTERFACEDECLARATION = 53, + METHODDECLARATION = 54, + NAMESPACEDECLARATION = 55, + TYPEDECLARATION = 56, + VARIABLEDECLARATION = 57, + DECORATOR = 58, + EXPORTMEMBER = 59, + SWITCHCASE = 60, + COMMENT = 61 + } + /** Checks if a node represents a constant value. */ + export function nodeIsConstantValue(kind: NodeKind): bool; + /** Checks if a node might be callable. */ + export function nodeIsCallable(kind: NodeKind): bool; + /** Checks if a node might be callable with generic arguments. */ + export function nodeIsGenericCallable(kind: NodeKind): bool; + /** Base class of all nodes. */ + export abstract class Node { + /** Node kind indicator. */ + kind: NodeKind; + /** Source range. */ + range: Range; + static createTypeName(name: IdentifierExpression, range: Range): TypeName; + static createSimpleTypeName(name: string, range: Range): TypeName; + static createType(name: TypeName, typeArguments: CommonTypeNode[] | null, isNullable: bool, range: Range): TypeNode; + static createOmittedType(range: Range): TypeNode; + static createTypeParameter(name: IdentifierExpression, extendsType: TypeNode | null, defaultType: TypeNode | null, range: Range): TypeParameterNode; + static createParameter(name: IdentifierExpression, type: CommonTypeNode, initializer: Expression | null, kind: ParameterKind, range: Range): ParameterNode; + static createSignature(parameters: ParameterNode[], returnType: CommonTypeNode, explicitThisType: TypeNode | null, isNullable: bool, range: Range): SignatureNode; + static createDecorator(name: Expression, args: Expression[] | null, range: Range): DecoratorNode; + static createComment(text: string, kind: CommentKind, range: Range): CommentNode; + static createIdentifierExpression(name: string, range: Range, isQuoted?: bool): IdentifierExpression; + static createEmptyIdentifierExpression(range: Range): IdentifierExpression; + static createArrayLiteralExpression(elements: (Expression | null)[], range: Range): ArrayLiteralExpression; + static createAssertionExpression(assertionKind: AssertionKind, expression: Expression, toType: CommonTypeNode | null, range: Range): AssertionExpression; + static createBinaryExpression(operator: Token, left: Expression, right: Expression, range: Range): BinaryExpression; + static createCallExpression(expression: Expression, typeArgs: CommonTypeNode[] | null, args: Expression[], range: Range): CallExpression; + static createClassExpression(declaration: ClassDeclaration): ClassExpression; + static createCommaExpression(expressions: Expression[], range: Range): CommaExpression; + static createConstructorExpression(range: Range): ConstructorExpression; + static createElementAccessExpression(expression: Expression, element: Expression, range: Range): ElementAccessExpression; + static createFalseExpression(range: Range): FalseExpression; + static createFloatLiteralExpression(value: f64, range: Range): FloatLiteralExpression; + static createFunctionExpression(declaration: FunctionDeclaration): FunctionExpression; + static createInstanceOfExpression(expression: Expression, isType: CommonTypeNode, range: Range): InstanceOfExpression; + static createIntegerLiteralExpression(value: I64, range: Range): IntegerLiteralExpression; + static createNewExpression(expression: Expression, typeArgs: CommonTypeNode[] | null, args: Expression[], range: Range): NewExpression; + static createNullExpression(range: Range): NullExpression; + static createObjectLiteralExpression(names: IdentifierExpression[], values: Expression[], range: Range): ObjectLiteralExpression; + static createParenthesizedExpression(expression: Expression, range: Range): ParenthesizedExpression; + static createPropertyAccessExpression(expression: Expression, property: IdentifierExpression, range: Range): PropertyAccessExpression; + static createRegexpLiteralExpression(pattern: string, flags: string, range: Range): RegexpLiteralExpression; + static createTernaryExpression(condition: Expression, ifThen: Expression, ifElse: Expression, range: Range): TernaryExpression; + static createStringLiteralExpression(value: string, range: Range): StringLiteralExpression; + static createSuperExpression(range: Range): SuperExpression; + static createThisExpression(range: Range): ThisExpression; + static createTrueExpression(range: Range): TrueExpression; + static createUnaryPostfixExpression(operator: Token, operand: Expression, range: Range): UnaryPostfixExpression; + static createUnaryPrefixExpression(operator: Token, operand: Expression, range: Range): UnaryPrefixExpression; + static createBlockStatement(statements: Statement[], range: Range): BlockStatement; + static createBreakStatement(label: IdentifierExpression | null, range: Range): BreakStatement; + static createClassDeclaration(identifier: IdentifierExpression, typeParameters: TypeParameterNode[] | null, extendsType: TypeNode | null, // can't be a function + implementsTypes: TypeNode[] | null, // can't be functions + members: DeclarationStatement[], decorators: DecoratorNode[] | null, flags: CommonFlags, range: Range): ClassDeclaration; + static createContinueStatement(label: IdentifierExpression | null, range: Range): ContinueStatement; + static createDoStatement(statement: Statement, condition: Expression, range: Range): DoStatement; + static createEmptyStatement(range: Range): EmptyStatement; + static createEnumDeclaration(name: IdentifierExpression, members: EnumValueDeclaration[], decorators: DecoratorNode[] | null, flags: CommonFlags, range: Range): EnumDeclaration; + static createEnumValueDeclaration(name: IdentifierExpression, value: Expression | null, flags: CommonFlags, range: Range): EnumValueDeclaration; + static createExportStatement(members: ExportMember[] | null, path: StringLiteralExpression | null, isDeclare: bool, range: Range): ExportStatement; + static createExportImportStatement(name: IdentifierExpression, externalName: IdentifierExpression, range: Range): ExportImportStatement; + static createExportMember(name: IdentifierExpression, externalName: IdentifierExpression | null, range: Range): ExportMember; + static createExpressionStatement(expression: Expression): ExpressionStatement; + static createIfStatement(condition: Expression, ifTrue: Statement, ifFalse: Statement | null, range: Range): IfStatement; + static createImportStatement(decls: ImportDeclaration[] | null, path: StringLiteralExpression, range: Range): ImportStatement; + static createImportStatementWithWildcard(identifier: IdentifierExpression, path: StringLiteralExpression, range: Range): ImportStatement; + static createImportDeclaration(foreignName: IdentifierExpression, name: IdentifierExpression | null, range: Range): ImportDeclaration; + static createInterfaceDeclaration(name: IdentifierExpression, typeParameters: TypeParameterNode[] | null, extendsType: TypeNode | null, // can't be a function + members: DeclarationStatement[], decorators: DecoratorNode[] | null, flags: CommonFlags, range: Range): InterfaceDeclaration; + static createFieldDeclaration(name: IdentifierExpression, type: CommonTypeNode | null, initializer: Expression | null, decorators: DecoratorNode[] | null, flags: CommonFlags, range: Range): FieldDeclaration; + static createForStatement(initializer: Statement | null, condition: Expression | null, incrementor: Expression | null, statement: Statement, range: Range): ForStatement; + static createFunctionDeclaration(name: IdentifierExpression, typeParameters: TypeParameterNode[] | null, signature: SignatureNode, body: Statement | null, decorators: DecoratorNode[] | null, flags: CommonFlags, arrowKind: ArrowKind, range: Range): FunctionDeclaration; + static createIndexSignatureDeclaration(keyType: TypeNode, valueType: CommonTypeNode, range: Range): IndexSignatureDeclaration; + static createMethodDeclaration(name: IdentifierExpression, typeParameters: TypeParameterNode[] | null, signature: SignatureNode, body: Statement | null, decorators: DecoratorNode[] | null, flags: CommonFlags, range: Range): MethodDeclaration; + static createNamespaceDeclaration(name: IdentifierExpression, members: Statement[], decorators: DecoratorNode[] | null, flags: CommonFlags, range: Range): NamespaceDeclaration; + static createReturnStatement(value: Expression | null, range: Range): ReturnStatement; + static createSwitchStatement(condition: Expression, cases: SwitchCase[], range: Range): SwitchStatement; + static createSwitchCase(label: Expression | null, statements: Statement[], range: Range): SwitchCase; + static createThrowStatement(value: Expression, range: Range): ThrowStatement; + static createTryStatement(statements: Statement[], catchVariable: IdentifierExpression | null, catchStatements: Statement[] | null, finallyStatements: Statement[] | null, range: Range): TryStatement; + static createTypeDeclaration(name: IdentifierExpression, typeParameters: TypeParameterNode[] | null, alias: CommonTypeNode, decorators: DecoratorNode[] | null, flags: CommonFlags, range: Range): TypeDeclaration; + static createVariableStatement(declarations: VariableDeclaration[], decorators: DecoratorNode[] | null, range: Range): VariableStatement; + static createVariableDeclaration(name: IdentifierExpression, type: CommonTypeNode | null, initializer: Expression | null, decorators: DecoratorNode[] | null, flags: CommonFlags, range: Range): VariableDeclaration; + static createVoidStatement(expression: Expression, range: Range): VoidStatement; + static createWhileStatement(condition: Expression, statement: Statement, range: Range): WhileStatement; + } + export abstract class CommonTypeNode extends Node { + /** Whether nullable or not. */ + isNullable: bool; + } + /** Represents a type name. */ + export class TypeName extends Node { + kind: NodeKind; + /** Identifier of this part. */ + identifier: IdentifierExpression; + /** Next part of the type name or `null` if this is the last part. */ + next: TypeName | null; + } + /** Represents a type annotation. */ + export class TypeNode extends CommonTypeNode { + kind: NodeKind; + /** Type name. */ + name: TypeName; + /** Type argument references. */ + typeArguments: CommonTypeNode[] | null; + } + /** Represents a type parameter. */ + export class TypeParameterNode extends Node { + kind: NodeKind; + /** Identifier reference. */ + name: IdentifierExpression; + /** Extended type reference, if any. */ + extendsType: TypeNode | null; + /** Default type if omitted, if any. */ + defaultType: TypeNode | null; + } + /** Represents the kind of a parameter. */ + export enum ParameterKind { + /** No specific flags. */ + DEFAULT = 0, + /** Is an optional parameter. */ + OPTIONAL = 1, + /** Is a rest parameter. */ + REST = 2 + } + /** Represents a function parameter. */ + export class ParameterNode extends Node { + kind: NodeKind; + /** Parameter kind. */ + parameterKind: ParameterKind; + /** Parameter name. */ + name: IdentifierExpression; + /** Parameter type. */ + type: CommonTypeNode; + /** Initializer expression, if present. */ + initializer: Expression | null; + /** Implicit field declaration, if applicable. */ + implicitFieldDeclaration: FieldDeclaration | null; + /** Common flags indicating specific traits. */ + flags: CommonFlags; + /** Tests if this node has the specified flag or flags. */ + is(flag: CommonFlags): bool; + /** Tests if this node has one of the specified flags. */ + isAny(flag: CommonFlags): bool; + /** Sets a specific flag or flags. */ + set(flag: CommonFlags): void; + } + /** Represents a function signature. */ + export class SignatureNode extends CommonTypeNode { + kind: NodeKind; + /** Accepted parameters. */ + parameters: ParameterNode[]; + /** Return type. */ + returnType: CommonTypeNode; + /** Explicitly provided this type, if any. */ + explicitThisType: TypeNode | null; + } + /** Built-in decorator kinds. */ + export enum DecoratorKind { + CUSTOM = 0, + GLOBAL = 1, + OPERATOR = 2, + OPERATOR_BINARY = 3, + OPERATOR_PREFIX = 4, + OPERATOR_POSTFIX = 5, + UNMANAGED = 6, + SEALED = 7, + INLINE = 8, + EXTERNAL = 9, + BUILTIN = 10, + LAZY = 11, + START = 12, + UNSAFE = 13 + } + /** Returns the kind of the specified decorator. Defaults to {@link DecoratorKind.CUSTOM}. */ + export function decoratorNameToKind(name: Expression): DecoratorKind; + /** Represents a decorator. */ + export class DecoratorNode extends Node { + kind: NodeKind; + /** Built-in kind, if applicable. */ + decoratorKind: DecoratorKind; + /** Name expression. */ + name: Expression; + /** Argument expressions. */ + arguments: Expression[] | null; + } + /** Comment kinds. */ + export enum CommentKind { + /** Line comment. */ + LINE = 0, + /** Triple-slash comment. */ + TRIPLE = 1, + /** Block comment. */ + BLOCK = 2 + } + /** Represents a comment. */ + export class CommentNode extends Node { + kind: NodeKind; + /** Comment kind. */ + commentKind: CommentKind; + /** Comment text. */ + text: string; + } + /** Base class of all expression nodes. */ + export abstract class Expression extends Node { + } + /** Represents an identifier expression. */ + export class IdentifierExpression extends Expression { + kind: NodeKind; + /** Textual name. */ + text: string; + /** Symbol. */ + symbol: string; + /** Whether quoted or not. */ + isQuoted: bool; + } + /** Indicates the kind of a literal. */ + export enum LiteralKind { + FLOAT = 0, + INTEGER = 1, + STRING = 2, + REGEXP = 3, + ARRAY = 4, + OBJECT = 5 + } + /** Base class of all literal expressions. */ + export abstract class LiteralExpression extends Expression { + kind: NodeKind; + /** Specific literal kind. */ + literalKind: LiteralKind; + } + /** Represents an `[]` literal expression. */ + export class ArrayLiteralExpression extends LiteralExpression { + literalKind: LiteralKind; + /** Nested element expressions. */ + elementExpressions: (Expression | null)[]; + } + /** Indicates the kind of an assertion. */ + export enum AssertionKind { + PREFIX = 0, + AS = 1, + NONNULL = 2 + } + /** Represents an assertion expression. */ + export class AssertionExpression extends Expression { + kind: NodeKind; + /** Specific kind of this assertion. */ + assertionKind: AssertionKind; + /** Expression being asserted. */ + expression: Expression; + /** Target type. */ + toType: CommonTypeNode | null; + } + /** Represents a binary expression. */ + export class BinaryExpression extends Expression { + kind: NodeKind; + /** Operator token. */ + operator: Token; + /** Left-hand side expression */ + left: Expression; + /** Right-hand side expression. */ + right: Expression; + } + /** Represents a call expression. */ + export class CallExpression extends Expression { + kind: NodeKind; + /** Called expression. Usually an identifier or property access expression. */ + expression: Expression; + /** Provided type arguments. */ + typeArguments: CommonTypeNode[] | null; + /** Provided arguments. */ + arguments: Expression[]; + /** Gets the type arguments range for reporting. */ + readonly typeArgumentsRange: Range; + /** Gets the arguments range for reporting. */ + readonly argumentsRange: Range; + } + /** Represents a class expression using the 'class' keyword. */ + export class ClassExpression extends Expression { + kind: NodeKind; + /** Inline class declaration. */ + declaration: ClassDeclaration; + } + /** Represents a comma expression composed of multiple expressions. */ + export class CommaExpression extends Expression { + kind: NodeKind; + /** Sequential expressions. */ + expressions: Expression[]; + } + /** Represents a `constructor` expression. */ + export class ConstructorExpression extends IdentifierExpression { + kind: NodeKind; + text: string; + symbol: string; + } + /** Represents an element access expression, e.g., array access. */ + export class ElementAccessExpression extends Expression { + kind: NodeKind; + /** Expression being accessed. */ + expression: Expression; + /** Element of the expression being accessed. */ + elementExpression: Expression; + } + /** Represents a float literal expression. */ + export class FloatLiteralExpression extends LiteralExpression { + literalKind: LiteralKind; + /** Float value. */ + value: f64; + } + /** Represents a function expression using the 'function' keyword. */ + export class FunctionExpression extends Expression { + kind: NodeKind; + /** Inline function declaration. */ + declaration: FunctionDeclaration; + } + /** Represents an `instanceof` expression. */ + export class InstanceOfExpression extends Expression { + kind: NodeKind; + /** Expression being asserted. */ + expression: Expression; + /** Type to test for. */ + isType: CommonTypeNode; + } + /** Represents an integer literal expression. */ + export class IntegerLiteralExpression extends LiteralExpression { + literalKind: LiteralKind; + /** Integer value. */ + value: I64; + } + /** Represents a `new` expression. Like a call but with its own kind. */ + export class NewExpression extends CallExpression { + kind: NodeKind; + } + /** Represents a `null` expression. */ + export class NullExpression extends IdentifierExpression { + kind: NodeKind; + text: string; + symbol: string; + } + /** Represents an object literal expression. */ + export class ObjectLiteralExpression extends LiteralExpression { + literalKind: LiteralKind; + /** Field names. */ + names: IdentifierExpression[]; + /** Field values. */ + values: Expression[]; + } + /** Represents a parenthesized expression. */ + export class ParenthesizedExpression extends Expression { + kind: NodeKind; + /** Expression in parenthesis. */ + expression: Expression; + } + /** Represents a property access expression. */ + export class PropertyAccessExpression extends Expression { + kind: NodeKind; + /** Expression being accessed. */ + expression: Expression; + /** Property of the expression being accessed. */ + property: IdentifierExpression; + } + /** Represents a regular expression literal expression. */ + export class RegexpLiteralExpression extends LiteralExpression { + literalKind: LiteralKind; + /** Regular expression pattern. */ + pattern: string; + /** Regular expression flags. */ + patternFlags: string; + } + /** Represents a ternary expression, i.e., short if notation. */ + export class TernaryExpression extends Expression { + kind: NodeKind; + /** Condition expression. */ + condition: Expression; + /** Expression executed when condition is `true`. */ + ifThen: Expression; + /** Expression executed when condition is `false`. */ + ifElse: Expression; + } + /** Represents a string literal expression. */ + export class StringLiteralExpression extends LiteralExpression { + literalKind: LiteralKind; + /** String value without quotes. */ + value: string; + } + /** Represents a `super` expression. */ + export class SuperExpression extends IdentifierExpression { + kind: NodeKind; + text: string; + symbol: string; + } + /** Represents a `this` expression. */ + export class ThisExpression extends IdentifierExpression { + kind: NodeKind; + text: string; + symbol: string; + } + /** Represents a `true` expression. */ + export class TrueExpression extends IdentifierExpression { + kind: NodeKind; + text: string; + symbol: string; + } + /** Represents a `false` expression. */ + export class FalseExpression extends IdentifierExpression { + kind: NodeKind; + text: string; + symbol: string; + } + /** Base class of all unary expressions. */ + export abstract class UnaryExpression extends Expression { + /** Operator token. */ + operator: Token; + /** Operand expression. */ + operand: Expression; + } + /** Represents a unary postfix expression, e.g. a postfix increment. */ + export class UnaryPostfixExpression extends UnaryExpression { + kind: NodeKind; + } + /** Represents a unary prefix expression, e.g. a negation. */ + export class UnaryPrefixExpression extends UnaryExpression { + kind: NodeKind; + } + /** Base class of all statement nodes. */ + export abstract class Statement extends Node { + } + /** Indicates the specific kind of a source. */ + export enum SourceKind { + /** Default source. Usually imported from an entry file. */ + DEFAULT = 0, + /** Entry file. */ + ENTRY = 1, + /** Library file. */ + LIBRARY = 2 + } + /** A top-level source node. */ + export class Source extends Node { + kind: NodeKind; + parent: null; + /** Source kind. */ + sourceKind: SourceKind; + /** Normalized path. */ + normalizedPath: string; + /** Path used internally. */ + internalPath: string; + /** Simple path (last part without extension). */ + simplePath: string; + /** Contained statements. */ + statements: Statement[]; + /** Full source text. */ + text: string; + /** Tokenizer reference. */ + tokenizer: Tokenizer | null; + /** Source map index. */ + debugInfoIndex: i32; + /** Re-exported sources. */ + exportPaths: Set | null; + /** Constructs a new source node. */ + constructor(normalizedPath: string, text: string, kind: SourceKind); + /** Tests if this source is an entry file. */ + readonly isEntry: bool; + /** Tests if this source is a stdlib file. */ + readonly isLibrary: bool; + } + /** Base class of all declaration statements. */ + export abstract class DeclarationStatement extends Statement { + /** Simple name being declared. */ + name: IdentifierExpression; + /** Array of decorators. */ + decorators: DecoratorNode[] | null; + /** Common flags indicating specific traits. */ + flags: CommonFlags; + /** Tests if this node has the specified flag or flags. */ + is(flag: CommonFlags): bool; + /** Tests if this node has one of the specified flags. */ + isAny(flag: CommonFlags): bool; + /** Sets a specific flag or flags. */ + set(flag: CommonFlags): void; + } + /** Represents an index signature declaration. */ + export class IndexSignatureDeclaration extends DeclarationStatement { + kind: NodeKind; + /** Key type. */ + keyType: TypeNode; + /** Value type. */ + valueType: CommonTypeNode; + } + /** Base class of all variable-like declaration statements. */ + export abstract class VariableLikeDeclarationStatement extends DeclarationStatement { + /** Variable type. */ + type: CommonTypeNode | null; + /** Variable initializer. */ + initializer: Expression | null; + } + /** Represents a block statement. */ + export class BlockStatement extends Statement { + kind: NodeKind; + /** Contained statements. */ + statements: Statement[]; + } + /** Represents a `break` statement. */ + export class BreakStatement extends Statement { + kind: NodeKind; + /** Target label, if applicable. */ + label: IdentifierExpression | null; + } + /** Represents a `class` declaration. */ + export class ClassDeclaration extends DeclarationStatement { + kind: NodeKind; + /** Accepted type parameters. */ + typeParameters: TypeParameterNode[] | null; + /** Base class type being extended, if any. */ + extendsType: TypeNode | null; + /** Interface types being implemented, if any. */ + implementsTypes: TypeNode[] | null; + /** Class member declarations. */ + members: DeclarationStatement[]; + readonly isGeneric: bool; + } + /** Represents a `continue` statement. */ + export class ContinueStatement extends Statement { + kind: NodeKind; + /** Target label, if applicable. */ + label: IdentifierExpression | null; + } + /** Represents a `do` statement. */ + export class DoStatement extends Statement { + kind: NodeKind; + /** Statement being looped over. */ + statement: Statement; + /** Condition when to repeat. */ + condition: Expression; + } + /** Represents an empty statement, i.e., a semicolon terminating nothing. */ + export class EmptyStatement extends Statement { + kind: NodeKind; + } + /** Represents an `enum` declaration. */ + export class EnumDeclaration extends DeclarationStatement { + kind: NodeKind; + /** Enum value declarations. */ + values: EnumValueDeclaration[]; + } + /** Represents a value of an `enum` declaration. */ + export class EnumValueDeclaration extends VariableLikeDeclarationStatement { + kind: NodeKind; + /** Value expression. */ + value: Expression | null; + } + /** Represents an `export import` statement of an interface. */ + export class ExportImportStatement extends Node { + kind: NodeKind; + /** Identifier being imported. */ + name: IdentifierExpression; + /** Identifier being exported. */ + externalName: IdentifierExpression; + } + /** Represents a member of an `export` statement. */ + export class ExportMember extends Node { + kind: NodeKind; + /** Local identifier. */ + localName: IdentifierExpression; + /** Exported identifier. */ + exportedName: IdentifierExpression; + } + /** Represents an `export` statement. */ + export class ExportStatement extends Statement { + kind: NodeKind; + /** Array of members if a set of named exports, or `null` if a file export. */ + members: ExportMember[] | null; + /** Path being exported from, if applicable. */ + path: StringLiteralExpression | null; + /** Normalized path, if `path` is set. */ + normalizedPath: string | null; + /** Mangled internal path being referenced, if `path` is set. */ + internalPath: string | null; + /** Whether this is a declared export. */ + isDeclare: bool; + } + /** Represents an expression that is used as a statement. */ + export class ExpressionStatement extends Statement { + kind: NodeKind; + /** Expression being used as a statement.*/ + expression: Expression; + } + /** Represents a field declaration within a `class`. */ + export class FieldDeclaration extends VariableLikeDeclarationStatement { + kind: NodeKind; + /** Parameter index if declared as a constructor parameter, otherwise `-1`. */ + parameterIndex: i32; + } + /** Represents a `for` statement. */ + export class ForStatement extends Statement { + kind: NodeKind; + /** + * Initializer statement, if present. + * Either a {@link VariableStatement} or {@link ExpressionStatement}. + */ + initializer: Statement | null; + /** Condition expression, if present. */ + condition: Expression | null; + /** Incrementor expression, if present. */ + incrementor: Expression | null; + /** Statement being looped over. */ + statement: Statement; + } + /** Indicates the kind of an array function. */ + export const enum ArrowKind { + /** Not an arrow function. */ + NONE = 0, + /** Parenthesized parameter list. */ + ARROW_PARENTHESIZED = 1, + /** Single parameter without parenthesis. */ + ARROW_SINGLE = 2 + } + /** Represents a `function` declaration. */ + export class FunctionDeclaration extends DeclarationStatement { + kind: NodeKind; + /** Type parameters, if any. */ + typeParameters: TypeParameterNode[] | null; + /** Function signature. */ + signature: SignatureNode; + /** Body statement. Usually a block. */ + body: Statement | null; + /** Arrow function kind, if applicable. */ + arrowKind: ArrowKind; + readonly isGeneric: bool; + /** Clones this function declaration. */ + clone(): FunctionDeclaration; + } + /** Represents an `if` statement. */ + export class IfStatement extends Statement { + kind: NodeKind; + /** Condition. */ + condition: Expression; + /** Statement executed when condition is `true`. */ + ifTrue: Statement; + /** Statement executed when condition is `false`. */ + ifFalse: Statement | null; + } + /** Represents an `import` declaration part of an {@link ImportStatement}. */ + export class ImportDeclaration extends DeclarationStatement { + kind: NodeKind; + /** Identifier being imported. */ + foreignName: IdentifierExpression; + } + /** Represents an `import` statement. */ + export class ImportStatement extends Statement { + kind: NodeKind; + /** Array of member declarations or `null` if an asterisk import. */ + declarations: ImportDeclaration[] | null; + /** Name of the local namespace, if an asterisk import. */ + namespaceName: IdentifierExpression | null; + /** Path being imported from. */ + path: StringLiteralExpression; + /** Normalized path. */ + normalizedPath: string; + /** Mangled internal path being referenced. */ + internalPath: string; + } + /** Represents an `interfarce` declaration. */ + export class InterfaceDeclaration extends ClassDeclaration { + kind: NodeKind; + } + /** Represents a method declaration within a `class`. */ + export class MethodDeclaration extends FunctionDeclaration { + kind: NodeKind; + } + /** Represents a `namespace` declaration. */ + export class NamespaceDeclaration extends DeclarationStatement { + kind: NodeKind; + /** Array of namespace members. */ + members: Statement[]; + } + /** Represents a `return` statement. */ + export class ReturnStatement extends Statement { + kind: NodeKind; + /** Value expression being returned, if present. */ + value: Expression | null; + } + /** Represents a single `case` within a `switch` statement. */ + export class SwitchCase extends Node { + kind: NodeKind; + /** Label expression. `null` indicates the default case. */ + label: Expression | null; + /** Contained statements. */ + statements: Statement[]; + } + /** Represents a `switch` statement. */ + export class SwitchStatement extends Statement { + kind: NodeKind; + /** Condition expression. */ + condition: Expression; + /** Contained cases. */ + cases: SwitchCase[]; + } + /** Represents a `throw` statement. */ + export class ThrowStatement extends Statement { + kind: NodeKind; + /** Value expression being thrown. */ + value: Expression; + } + /** Represents a `try` statement. */ + export class TryStatement extends Statement { + kind: NodeKind; + /** Contained statements. */ + statements: Statement[]; + /** Exception variable name, if a `catch` clause is present. */ + catchVariable: IdentifierExpression | null; + /** Statements being executed on catch, if a `catch` clause is present. */ + catchStatements: Statement[] | null; + /** Statements being executed afterwards, if a `finally` clause is present. */ + finallyStatements: Statement[] | null; + } + /** Represents a `type` declaration. */ + export class TypeDeclaration extends DeclarationStatement { + kind: NodeKind; + /** Type parameters, if any. */ + typeParameters: TypeParameterNode[] | null; + /** Type being aliased. */ + type: CommonTypeNode; + } + /** Represents a variable declaration part of a {@link VariableStatement}. */ + export class VariableDeclaration extends VariableLikeDeclarationStatement { + kind: NodeKind; + } + /** Represents a variable statement wrapping {@link VariableDeclaration}s. */ + export class VariableStatement extends Statement { + kind: NodeKind; + /** Array of decorators. */ + decorators: DecoratorNode[] | null; + /** Array of member declarations. */ + declarations: VariableDeclaration[]; + } + /** Represents a void statement dropping an expression's value. */ + export class VoidStatement extends Statement { + kind: NodeKind; + /** Expression being dropped. */ + expression: Expression; + } + /** Represents a `while` statement. */ + export class WhileStatement extends Statement { + kind: NodeKind; + /** Condition expression. */ + condition: Expression; + /** Statement being looped over. */ + statement: Statement; + } + /** Finds the first decorator matching the specified kind. */ + export function findDecorator(kind: DecoratorKind, decorators: DecoratorNode[] | null): DecoratorNode | null; + /** Mangles an external to an internal path. */ + export function mangleInternalPath(path: string): string; + /** Tests if the specified type node represents an omitted type. */ + export function isTypeOmitted(type: CommonTypeNode): bool; + +} +declare module 'assemblyscript/src/module' { + /** + * A thin wrapper around Binaryen's C-API. + * @module module + */ /***/ + import { Target } from 'assemblyscript/src/common'; + export type ModuleRef = usize; + export type FunctionTypeRef = usize; + export type FunctionRef = usize; + export type ExpressionRef = usize; + export type GlobalRef = usize; + export type ImportRef = usize; + export type ExportRef = usize; + export type RelooperRef = usize; + export type RelooperBlockRef = usize; + export type Index = u32; + export enum NativeType { + None, + I32, + I64, + F32, + F64, + V128, + Unreachable, + Auto + } + export enum FeatureFlags { + Atomics, + MutableGloabls, + NontrappingFPToInt, + SIMD128, + BulkMemory, + SignExt, + ExceptionHandling + } + export enum ExpressionId { + 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, + SIMDExtract, + SIMDReplace, + SIMDShuffle, + SIMDBitselect, + SIMDShift, + MemoryInit, + DataDrop, + MemoryCopy, + MemoryFill + } + export enum UnaryOp { + ClzI32, + CtzI32, + PopcntI32, + NegF32, + AbsF32, + CeilF32, + FloorF32, + TruncF32, + NearestF32, + SqrtF32, + EqzI32, + ClzI64, + CtzI64, + PopcntI64, + NegF64, + AbsF64, + CeilF64, + FloorF64, + TruncF64, + NearestF64, + SqrtF64, + EqzI64, + ExtendI32, + ExtendU32, + WrapI64, + TruncF32ToI32, + TruncF32ToI64, + TruncF32ToU32, + TruncF32ToU64, + TruncF64ToI32, + TruncF64ToI64, + TruncF64ToU32, + TruncF64ToU64, + ReinterpretF32, + ReinterpretF64, + ConvertI32ToF32, + ConvertI32ToF64, + ConvertU32ToF32, + ConvertU32ToF64, + ConvertI64ToF32, + ConvertI64ToF64, + ConvertU64ToF32, + ConvertU64ToF64, + PromoteF32, + DemoteF64, + ReinterpretI32, + ReinterpretI64, + ExtendI8ToI32, + ExtendI16ToI32, + ExtendI8ToI64, + ExtendI16ToI64, + ExtendI32ToI64, + SplatVecI8x16, + SplatVecI16x8, + SplatVecI32x4, + SplatVecI64x2, + SplatVecF32x4, + SplatVecF64x2, + NotVec128, + NegVecI8x16, + AnyTrueVecI8x16, + AllTrueVecI8x16, + NegVecI16x8, + AnyTrueVecI16x8, + AllTrueVecI16x8, + NegVecI32x4, + AnyTrueVecI32x4, + AllTrueVecI32x4, + NegVecI64x2, + AnyTrueVecI64x2, + AllTrueVecI64x2, + AbsVecF32x4, + NegVecF32x4, + SqrtVecF32x4, + AbsVecF64x2, + NegVecF64x2, + SqrtVecF64x2, + TruncSatSVecF32x4ToVecI32x4, + TruncSatUVecF32x4ToVecI32x4, + TruncSatSVecF64x2ToVecI64x2, + TruncSatUVecF64x2ToVecI64x2, + ConvertSVecI32x4ToVecF32x4, + ConvertUVecI32x4ToVecF32x4, + ConvertSVecI64x2ToVecF64x2, + ConvertUVecI64x2ToVecF64x2 + } + export enum BinaryOp { + AddI32, + SubI32, + MulI32, + DivI32, + DivU32, + RemI32, + RemU32, + AndI32, + OrI32, + XorI32, + ShlI32, + ShrU32, + ShrI32, + RotlI32, + RotrI32, + EqI32, + NeI32, + LtI32, + LtU32, + LeI32, + LeU32, + GtI32, + GtU32, + GeI32, + GeU32, + AddI64, + SubI64, + MulI64, + DivI64, + DivU64, + RemI64, + RemU64, + AndI64, + OrI64, + XorI64, + ShlI64, + ShrU64, + ShrI64, + RotlI64, + RotrI64, + EqI64, + NeI64, + LtI64, + LtU64, + LeI64, + LeU64, + GtI64, + GtU64, + GeI64, + GeU64, + AddF32, + SubF32, + MulF32, + DivF32, + CopysignF32, + MinF32, + MaxF32, + EqF32, + NeF32, + LtF32, + LeF32, + GtF32, + GeF32, + AddF64, + SubF64, + MulF64, + DivF64, + CopysignF64, + MinF64, + MaxF64, + EqF64, + NeF64, + LtF64, + LeF64, + GtF64, + GeF64, + EqVecI8x16, + NeVecI8x16, + LtSVecI8x16, + LtUVecI8x16, + LeSVecI8x16, + LeUVecI8x16, + GtSVecI8x16, + GtUVecI8x16, + GeSVecI8x16, + GeUVecI8x16, + EqVecI16x8, + NeVecI16x8, + LtSVecI16x8, + LtUVecI16x8, + LeSVecI16x8, + LeUVecI16x8, + GtSVecI16x8, + GtUVecI16x8, + GeSVecI16x8, + GeUVecI16x8, + EqVecI32x4, + NeVecI32x4, + LtSVecI32x4, + LtUVecI32x4, + LeSVecI32x4, + LeUVecI32x4, + GtSVecI32x4, + GtUVecI32x4, + GeSVecI32x4, + GeUVecI32x4, + EqVecF32x4, + NeVecF32x4, + LtVecF32x4, + LeVecF32x4, + GtVecF32x4, + GeVecF32x4, + EqVecF64x2, + NeVecF64x2, + LtVecF64x2, + LeVecF64x2, + GtVecF64x2, + GeVecF64x2, + AndVec128, + OrVec128, + XorVec128, + AddVecI8x16, + AddSatSVecI8x16, + AddSatUVecI8x16, + SubVecI8x16, + SubSatSVecI8x16, + SubSatUVecI8x16, + MulVecI8x16, + AddVecI16x8, + AddSatSVecI16x8, + AddSatUVecI16x8, + SubVecI16x8, + SubSatSVecI16x8, + SubSatUVecI16x8, + MulVecI16x8, + AddVecI32x4, + SubVecI32x4, + MulVecI32x4, + AddVecI64x2, + SubVecI64x2, + AddVecF32x4, + SubVecF32x4, + MulVecF32x4, + DivVecF32x4, + MinVecF32x4, + MaxVecF32x4, + AddVecF64x2, + SubVecF64x2, + MulVecF64x2, + DivVecF64x2, + MinVecF64x2, + MaxVecF64x2 + } + export enum HostOp { + MemorySize, + MemoryGrow + } + export enum AtomicRMWOp { + Add, + Sub, + And, + Or, + Xor, + Xchg + } + export enum SIMDExtractOp { + ExtractLaneSVecI8x16, + ExtractLaneUVecI8x16, + ExtractLaneSVecI16x8, + ExtractLaneUVecI16x8, + ExtractLaneVecI32x4, + ExtractLaneVecI64x2, + ExtractLaneVecF32x4, + ExtractLaneVecF64x2 + } + export enum SIMDReplaceOp { + ReplaceLaneVecI8x16, + ReplaceLaneVecI16x8, + ReplaceLaneVecI32x4, + ReplaceLaneVecI64x2, + ReplaceLaneVecF32x4, + ReplaceLaneVecF64x2 + } + export enum SIMDShiftOp { + ShlVecI8x16, + ShrSVecI8x16, + ShrUVecI8x16, + ShlVecI16x8, + ShrSVecI16x8, + ShrUVecI16x8, + ShlVecI32x4, + ShrSVecI32x4, + ShrUVecI32x4, + ShlVecI64x2, + ShrSVecI64x2, + ShrUVecI64x2 + } + export class MemorySegment { + buffer: Uint8Array; + offset: I64; + static create(buffer: Uint8Array, offset: I64): MemorySegment; + } + export class Module { + ref: ModuleRef; + private lit; + static create(): Module; + static createFrom(buffer: Uint8Array): Module; + private constructor(); + addFunctionType(name: string, result: NativeType, paramTypes: NativeType[] | null): FunctionRef; + getFunctionTypeBySignature(result: NativeType, paramTypes: NativeType[] | null): FunctionTypeRef; + removeFunctionType(name: string): void; + i32(value: i32): ExpressionRef; + i64(valueLow: i32, valueHigh?: i32): ExpressionRef; + f32(value: f32): ExpressionRef; + f64(value: f64): ExpressionRef; + v128(bytes: Uint8Array): ExpressionRef; + unary(op: UnaryOp, expr: ExpressionRef): ExpressionRef; + binary(op: BinaryOp, left: ExpressionRef, right: ExpressionRef): ExpressionRef; + host(op: HostOp, name?: string | null, operands?: ExpressionRef[] | null): ExpressionRef; + local_get(index: i32, type: NativeType): ExpressionRef; + local_tee(index: i32, value: ExpressionRef): ExpressionRef; + global_get(name: string, type: NativeType): ExpressionRef; + load(bytes: Index, signed: bool, ptr: ExpressionRef, type: NativeType, offset?: Index, align?: Index): ExpressionRef; + store(bytes: Index, ptr: ExpressionRef, value: ExpressionRef, type: NativeType, offset?: Index, align?: Index): ExpressionRef; + atomic_load(bytes: Index, ptr: ExpressionRef, type: NativeType, offset?: Index): ExpressionRef; + atomic_store(bytes: Index, ptr: ExpressionRef, value: ExpressionRef, type: NativeType, offset?: Index): ExpressionRef; + atomic_rmw(op: AtomicRMWOp, bytes: Index, offset: Index, ptr: ExpressionRef, value: ExpressionRef, type: NativeType): ExpressionRef; + atomic_cmpxchg(bytes: Index, offset: Index, ptr: ExpressionRef, expected: ExpressionRef, replacement: ExpressionRef, type: NativeType): ExpressionRef; + atomic_wait(ptr: ExpressionRef, expected: ExpressionRef, timeout: ExpressionRef, expectedType: NativeType): ExpressionRef; + atomic_notify(ptr: ExpressionRef, notifyCount: ExpressionRef): ExpressionRef; + local_set(index: Index, value: ExpressionRef): ExpressionRef; + global_set(name: string, value: ExpressionRef): ExpressionRef; + block(label: string | null, children: ExpressionRef[], type?: NativeType): ExpressionRef; + br(label: string | null, condition?: ExpressionRef, value?: ExpressionRef): ExpressionRef; + drop(expression: ExpressionRef): ExpressionRef; + loop(label: string | null, body: ExpressionRef): ExpressionRef; + if(condition: ExpressionRef, ifTrue: ExpressionRef, ifFalse?: ExpressionRef): ExpressionRef; + nop(): ExpressionRef; + return(expression?: ExpressionRef): ExpressionRef; + select(ifTrue: ExpressionRef, ifFalse: ExpressionRef, condition: ExpressionRef): ExpressionRef; + switch(names: string[], defaultName: string | null, condition: ExpressionRef, value?: ExpressionRef): ExpressionRef; + call(target: string, operands: ExpressionRef[] | null, returnType: NativeType): ExpressionRef; + call_indirect(index: ExpressionRef, operands: ExpressionRef[] | null, typeName: string): ExpressionRef; + unreachable(): ExpressionRef; + memory_copy(dest: ExpressionRef, source: ExpressionRef, size: ExpressionRef): ExpressionRef; + memory_fill(dest: ExpressionRef, value: ExpressionRef, size: ExpressionRef): ExpressionRef; + simd_extract(op: SIMDExtractOp, vec: ExpressionRef, idx: u8): ExpressionRef; + simd_replace(op: SIMDReplaceOp, vec: ExpressionRef, idx: u8, value: ExpressionRef): ExpressionRef; + simd_shuffle(vec1: ExpressionRef, vec2: ExpressionRef, mask: Uint8Array): ExpressionRef; + simd_bitselect(vec1: ExpressionRef, vec2: ExpressionRef, cond: ExpressionRef): ExpressionRef; + simd_shift(op: SIMDShiftOp, vec: ExpressionRef, shift: ExpressionRef): ExpressionRef; + addGlobal(name: string, type: NativeType, mutable: bool, initializer: ExpressionRef): GlobalRef; + removeGlobal(name: string): void; + addFunction(name: string, type: FunctionTypeRef, varTypes: NativeType[] | null, body: ExpressionRef): FunctionRef; + removeFunction(name: string): void; + private hasTemporaryFunction; + addTemporaryFunction(result: NativeType, paramTypes: NativeType[] | null, body: ExpressionRef): FunctionRef; + removeTemporaryFunction(): 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; + addFunctionImport(internalName: string, externalModuleName: string, externalBaseName: string, functionType: FunctionTypeRef): ImportRef; + addTableImport(internalName: string, externalModuleName: string, externalBaseName: string): ImportRef; + addMemoryImport(internalName: string, externalModuleName: string, externalBaseName: string, shared?: bool): ImportRef; + addGlobalImport(internalName: string, externalModuleName: string, externalBaseName: string, globalType: NativeType): ImportRef; + /** Unlimited memory constant. */ + static readonly UNLIMITED_MEMORY: Index; + setMemory(initial: Index, maximum: Index, segments: MemorySegment[], target: Target, exportName?: string | null, shared?: bool): void; + setFunctionTable(initial: Index, maximum: Index, funcs: string[]): void; + setStart(func: FunctionRef): void; + getOptimizeLevel(): i32; + setOptimizeLevel(level?: i32): void; + getShrinkLevel(): i32; + setShrinkLevel(level?: i32): void; + setDebugInfo(on?: bool): void; + getFeatures(): BinaryenFeatureFlags; + setFeatures(featureFlags: BinaryenFeatureFlags): void; + optimize(func?: FunctionRef): void; + runPasses(passes: string[], func?: FunctionRef): void; + private cachedPrecomputeNames; + precomputeExpression(expr: ExpressionRef): ExpressionRef; + validate(): bool; + interpret(): void; + toBinary(sourceMapUrl: string | null): BinaryModule; + toText(): string; + toAsmjs(): string; + private cachedStrings; + private allocStringCached; + dispose(): void; + createRelooper(): Relooper; + cloneExpression(expr: ExpressionRef, noSideEffects?: bool, maxDepth?: i32): ExpressionRef; + addDebugInfoFile(name: string): Index; + getDebugInfoFile(index: Index): string | null; + setDebugLocation(func: FunctionRef, expr: ExpressionRef, fileIndex: Index, lineNumber: Index, columnNumber: Index): void; + } + export function getExpressionId(expr: ExpressionRef): ExpressionId; + export function getExpressionType(expr: ExpressionRef): NativeType; + export function getConstValueI32(expr: ExpressionRef): i32; + export function getConstValueI64Low(expr: ExpressionRef): i32; + export function getConstValueI64High(expr: ExpressionRef): i32; + export function getConstValueF32(expr: ExpressionRef): f32; + export function getConstValueF64(expr: ExpressionRef): f32; + export function getLocalGetIndex(expr: ExpressionRef): Index; + export function getLocalSetIndex(expr: ExpressionRef): Index; + export function getLocalSetValue(expr: ExpressionRef): ExpressionRef; + export function isLocalTee(expr: ExpressionRef): bool; + export function getGlobalGetName(expr: ExpressionRef): string | null; + export function getBinaryOp(expr: ExpressionRef): BinaryOp; + export function getBinaryLeft(expr: ExpressionRef): ExpressionRef; + export function getBinaryRight(expr: ExpressionRef): ExpressionRef; + export function getUnaryOp(expr: ExpressionRef): UnaryOp; + export function getUnaryValue(expr: ExpressionRef): ExpressionRef; + export function getLoadBytes(expr: ExpressionRef): u32; + export function getLoadOffset(expr: ExpressionRef): u32; + export function getLoadPtr(expr: ExpressionRef): ExpressionRef; + export function isLoadSigned(expr: ExpressionRef): bool; + export function getStoreBytes(expr: ExpressionRef): u32; + export function getStoreOffset(expr: ExpressionRef): u32; + export function getStorePtr(expr: ExpressionRef): ExpressionRef; + export function getStoreValue(expr: ExpressionRef): ExpressionRef; + export function getBlockName(expr: ExpressionRef): string | null; + export function getBlockChildCount(expr: ExpressionRef): Index; + export function getBlockChild(expr: ExpressionRef, index: Index): ExpressionRef; + export function getIfCondition(expr: ExpressionRef): ExpressionRef; + export function getIfTrue(expr: ExpressionRef): ExpressionRef; + export function getIfFalse(expr: ExpressionRef): ExpressionRef; + export function getLoopName(expr: ExpressionRef): string | null; + export function getLoopBody(expr: ExpressionRef): ExpressionRef; + export function getBreakName(expr: ExpressionRef): string | null; + export function getBreakCondition(expr: ExpressionRef): ExpressionRef; + export function getSelectThen(expr: ExpressionRef): ExpressionRef; + export function getSelectElse(expr: ExpressionRef): ExpressionRef; + export function getSelectCondition(expr: ExpressionRef): ExpressionRef; + export function getDropValue(expr: ExpressionRef): ExpressionRef; + export function getReturnValue(expr: ExpressionRef): ExpressionRef; + export function getCallTarget(expr: ExpressionRef): string | null; + export function getCallOperandCount(expr: ExpressionRef): i32; + export function getCallOperand(expr: ExpressionRef, index: Index): ExpressionRef; + export function getHostOp(expr: ExpressionRef): ExpressionRef; + export function getHostOperandCount(expr: ExpressionRef): Index; + export function getHostOperand(expr: ExpressionRef, index: Index): ExpressionRef; + export function getHostName(expr: ExpressionRef): string | null; + export function getFunctionBody(func: FunctionRef): ExpressionRef; + export function getFunctionName(func: FunctionRef): string | null; + export function getFunctionParamCount(func: FunctionRef): Index; + export function getFunctionParamType(func: FunctionRef, index: Index): NativeType; + export function getFunctionResultType(func: FunctionRef): NativeType; + export class Relooper { + module: Module; + ref: RelooperRef; + static create(module: Module): Relooper; + private constructor(); + addBlock(code: ExpressionRef): RelooperBlockRef; + addBranch(from: RelooperBlockRef, to: RelooperBlockRef, condition?: ExpressionRef, code?: ExpressionRef): void; + addBlockWithSwitch(code: ExpressionRef, condition: ExpressionRef): RelooperBlockRef; + addBranchForSwitch(from: RelooperBlockRef, to: RelooperBlockRef, indexes: i32[], code?: ExpressionRef): void; + renderAndDispose(entry: RelooperBlockRef, labelHelper: Index): ExpressionRef; + } + export function readString(ptr: usize): string | null; + /** Result structure of {@link Module#toBinary}. */ + export class BinaryModule { + /** WebAssembly binary. */ + output: Uint8Array; + /** Source map, if generated. */ + sourceMap: string | null; + } + /** Tests if an expression needs an explicit 'unreachable' when it is the terminating statement. */ + export function needsExplicitUnreachable(expr: ExpressionRef): bool; + /** Traverses all expression members of an expression, calling the given visitor. */ + export function traverse(expr: ExpressionRef, data: T, visit: (expr: ExpressionRef, data: T) => void): bool; + +} +declare module 'assemblyscript/src/types' { + /** + * Mappings from AssemblyScript types to WebAssembly types. + * @module types + */ /***/ + import { Class, FunctionTarget, Program } from 'assemblyscript/src/program'; + import { NativeType, ExpressionRef, Module } from 'assemblyscript/src/module'; + /** Indicates the kind of a type. */ + export const enum TypeKind { + /** An 8-bit signed integer. */ + I8 = 0, + /** A 16-bit signed integer. */ + I16 = 1, + /** A 32-bit signed integer. */ + I32 = 2, + /** A 64-bit signed integer. */ + I64 = 3, + /** A 32-bit/64-bit signed integer, depending on the target. */ + ISIZE = 4, + /** An 8-bit unsigned integer. */ + U8 = 5, + /** A 16-bit unsigned integer. */ + U16 = 6, + /** A 32-bit unsigned integer. Also the base of function types. */ + U32 = 7, + /** A 64-bit unsigned integer. */ + U64 = 8, + /** A 32-bit/64-bit unsigned integer, depending on the target. Also the base of class types. */ + USIZE = 9, + /** A 1-bit unsigned integer. */ + BOOL = 10, + /** A 32-bit float. */ + F32 = 11, + /** A 64-bit double. */ + F64 = 12, + /** A 128-bit vector. */ + V128 = 13, + /** No return type. */ + VOID = 14 + } + /** Indicates capabilities of a type. */ + export const enum TypeFlags { + NONE = 0, + /** Is a signed type that can represent negative values. */ + SIGNED = 1, + /** Is an unsigned type that cannot represent negative values. */ + UNSIGNED = 2, + /** Is an integer type. */ + INTEGER = 4, + /** Is a floating point type. */ + FLOAT = 8, + /** Is a pointer type. */ + POINTER = 16, + /** Is smaller than 32-bits. */ + SHORT = 32, + /** Is larger than 32-bits. */ + LONG = 64, + /** Is a value type. */ + VALUE = 128, + /** Is a reference type. */ + REFERENCE = 256, + /** Is a nullable type. */ + NULLABLE = 512, + /** Is a vector type. */ + VECTOR = 1024 + } + /** Represents a resolved type. */ + export class Type { + /** Type kind. */ + kind: TypeKind; + /** Type flags. */ + flags: TypeFlags; + /** Size in bits. */ + size: u32; + /** Size in bytes. */ + byteSize: i32; + /** Underlying class reference, if a class type. */ + classReference: Class | null; + /** Underlying signature reference, if a function type. */ + signatureReference: Signature | null; + /** Respective non-nullable type, if nullable. */ + nonNullableType: Type; + /** Cached nullable type, if non-nullable. */ + private cachedNullableType; + /** Constructs a new resolved type. */ + constructor(kind: TypeKind, flags: TypeFlags, size: u32); + /** Returns the closest int type representing this type. */ + readonly intType: Type; + /** Gets this type's logarithmic alignment in memory. */ + readonly alignLog2: i32; + /** Tests if this is a managed type that needs GC hooks. */ + readonly isManaged: bool; + /** Tests if this is a class type explicitly annotated as unmanaged. */ + readonly isUnmanaged: bool; + /** Computes the sign-extending shift in the target type. */ + computeSmallIntegerShift(targetType: Type): u32; + /** Computes the truncating mask in the target type. */ + computeSmallIntegerMask(targetType: Type): u32; + /** Tests if this type has (all of) the specified flags. */ + is(flags: TypeFlags): bool; + /** Tests if this type has any of the specified flags. */ + isAny(flags: TypeFlags): bool; + /** Composes a class type from this type and a class. */ + asClass(classType: Class): Type; + /** Composes a function type from this type and a function. */ + asFunction(signature: Signature): Type; + /** Composes the respective nullable type of this type. */ + asNullable(): Type; + /** Tests if a value of this type is assignable to the target type incl. implicit conversion. */ + isAssignableTo(target: Type, signednessIsRelevant?: bool): bool; + /** Tests if a value of this type is assignable to the target type excl. implicit conversion. */ + isStrictlyAssignableTo(target: Type, signednessIsRelevant?: bool): bool; + /** Determines the common denominator type of two types, if there is any. */ + static commonDenominator(left: Type, right: Type, signednessIsImportant: bool): Type | null; + /** Converts this type to a string. */ + toString(): string; + /** Converts this type to its respective native type. */ + toNativeType(): NativeType; + /** Converts this type to its native `0` value. */ + toNativeZero(module: Module): ExpressionRef; + /** Converts this type to its native `1` value. */ + toNativeOne(module: Module): ExpressionRef; + /** Converts this type to its native `-1` value. */ + toNativeNegOne(module: Module): ExpressionRef; + /** Converts this type to its signature string. */ + toSignatureString(): string; + /** An 8-bit signed integer. */ + static readonly i8: Type; + /** A 16-bit signed integer. */ + static readonly i16: Type; + /** A 32-bit signed integer. */ + static readonly i32: Type; + /** A 64-bit signed integer. */ + static readonly i64: Type; + /** A 32-bit signed size. WASM32 only. */ + static readonly isize32: Type; + /** A 64-bit signed size. WASM64 only. */ + static readonly isize64: Type; + /** An 8-bit unsigned integer. */ + static readonly u8: Type; + /** A 16-bit unsigned integer. */ + static readonly u16: Type; + /** A 32-bit unsigned integer. */ + static readonly u32: Type; + /** A 64-bit unsigned integer. */ + static readonly u64: Type; + /** A 32-bit unsigned size. WASM32 only. */ + static readonly usize32: Type; + /** A 64-bit unsigned size. WASM64 only. */ + static readonly usize64: Type; + /** A 1-bit unsigned integer. */ + static readonly bool: Type; + /** A 32-bit float. */ + static readonly f32: Type; + /** A 64-bit float. */ + static readonly f64: Type; + /** A 128-bit vector. */ + static readonly v128: Type; + /** No return type. */ + static readonly void: Type; + } + /** Converts an array of types to an array of native types. */ + export function typesToNativeTypes(types: Type[]): NativeType[]; + /** Converts an array of types to its combined string representation. */ + export function typesToString(types: Type[]): string; + /** Represents a fully resolved function signature. */ + export class Signature { + /** Parameter types, if any, excluding `this`. */ + parameterTypes: Type[]; + /** Parameter names, if known, excluding `this`. */ + parameterNames: string[] | null; + /** Number of required parameters excluding `this`. Other parameters are considered optional. */ + requiredParameters: i32; + /** Return type. */ + returnType: Type; + /** This type, if an instance signature. */ + thisType: Type | null; + /** Whether the last parameter is a rest parameter. */ + hasRest: bool; + /** Cached {@link FunctionTarget}. */ + cachedFunctionTarget: FunctionTarget | null; + /** Respective function type. */ + type: Type; + /** Constructs a new signature. */ + constructor(parameterTypes?: Type[] | null, returnType?: Type | null, thisType?: Type | null); + asFunctionTarget(program: Program): FunctionTarget; + /** Gets the known or, alternatively, generic parameter name at the specified index. */ + getParameterName(index: i32): string; + /** Tests if a value of this function type is assignable to a target of the specified function type. */ + isAssignableTo(target: Signature): bool; + /** Converts a signature to a function type string. */ + static makeSignatureString(parameterTypes: Type[] | null, returnType: Type, thisType?: Type | null): string; + /** Converts this signature to a function type string. */ + toSignatureString(): string; + /** Converts this signature to a string. */ + toString(): string; + } + /** Gets the cached default parameter name for the specified index. */ + export function getDefaultParameterName(index: i32): string; + +} +declare module 'assemblyscript/src/flow' { + /** + * A control flow analyzer. + * @module flow + */ /***/ + import { Type } from 'assemblyscript/src/types'; + import { Local, Function, Element } from 'assemblyscript/src/program'; + import { ExpressionRef } from 'assemblyscript/src/module'; + import { Node } from 'assemblyscript/src/ast'; + /** Control flow flags indicating specific conditions. */ + export const enum FlowFlags { + /** No specific conditions. */ + NONE = 0, + /** This flow returns. */ + RETURNS = 1, + /** This flow returns a wrapped value. */ + RETURNS_WRAPPED = 2, + /** This flow returns a non-null value. */ + RETURNS_NONNULL = 4, + /** This flow throws. */ + THROWS = 8, + /** This flow breaks. */ + BREAKS = 16, + /** This flow continues. */ + CONTINUES = 32, + /** This flow allocates. Constructors only. */ + ALLOCATES = 64, + /** This flow calls super. Constructors only. */ + CALLS_SUPER = 128, + /** This flow conditionally returns in a child flow. */ + CONDITIONALLY_RETURNS = 256, + /** This flow conditionally throws in a child flow. */ + CONDITIONALLY_THROWS = 512, + /** This flow conditionally breaks in a child flow. */ + CONDITIONALLY_BREAKS = 1024, + /** This flow conditionally continues in a child flow. */ + CONDITIONALLY_CONTINUES = 2048, + /** This flow conditionally allocates in a child flow. Constructors only. */ + CONDITIONALLY_ALLOCATES = 4096, + /** This is an inlining flow. */ + INLINE_CONTEXT = 8192, + /** This is a flow with explicitly disabled bounds checking. */ + UNCHECKED_CONTEXT = 16384, + /** Any terminating flag. */ + ANY_TERMINATING = 57, + /** Any categorical flag. */ + ANY_CATEGORICAL = 255, + /** Any conditional flag. */ + ANY_CONDITIONAL = 7936 + } + /** Flags indicating the current state of a local. */ + export enum LocalFlags { + /** No specific conditions. */ + NONE = 0, + /** Local is properly wrapped. Relevant for small integers. */ + WRAPPED = 1, + /** Local is non-null. */ + NONNULL = 2, + /** Local is read from. */ + READFROM = 4, + /** Local is written to. */ + WRITTENTO = 8, + /** Local is retained. */ + RETAINED = 16, + /** Local is conditionally read from. */ + CONDITIONALLY_READFROM = 32, + /** Local is conditionally written to. */ + CONDITIONALLY_WRITTENTO = 64, + /** Local must be conditionally retained. */ + CONDITIONALLY_RETAINED = 128, + /** Any categorical flag. */ + ANY_CATEGORICAL = 31, + /** Any conditional flag. */ + ANY_CONDITIONAL = 240, + /** Any retained flag. */ + ANY_RETAINED = 144 + } + export namespace LocalFlags { + function join(left: LocalFlags, right: LocalFlags): LocalFlags; + } + /** Flags indicating the current state of a field. */ + export enum FieldFlags { + /** No specific conditions. */ + NONE = 0, + /** Field is initialized. Relevant in constructors. */ + INITIALIZED = 1, + /** Field is conditionally initialized. Relevant in constructors. */ + CONDITIONALLY_INITIALIZED = 2, + /** Any categorical flag. */ + ANY_CATEGORICAL = 1, + /** Any conditional flag. */ + ANY_CONDITIONAL = 2 + } + export namespace FieldFlags { + function join(left: FieldFlags, right: FieldFlags): FieldFlags; + } + /** A control flow evaluator. */ + export class Flow { + /** Parent flow. */ + parent: Flow | null; + /** Flow flags indicating specific conditions. */ + flags: FlowFlags; + /** Function this flow belongs to. */ + parentFunction: Function; + /** The label we break to when encountering a continue statement. */ + continueLabel: string | null; + /** The label we break to when encountering a break statement. */ + breakLabel: string | null; + /** The current return type. */ + returnType: Type; + /** The current contextual type arguments. */ + contextualTypeArguments: Map | null; + /** Scoped local variables. */ + scopedLocals: Map | null; + /** Local flags. */ + localFlags: LocalFlags[]; + /** Field flags. Relevant in constructors. */ + fieldFlags: Map | null; + /** Function being inlined, when inlining. */ + inlineFunction: Function | null; + /** The label we break to when encountering a return statement, when inlining. */ + inlineReturnLabel: string | null; + /** Creates the parent flow of the specified function. */ + static create(parentFunction: Function): Flow; + /** Creates an inline flow within `parentFunction`. */ + static createInline(parentFunction: Function, inlineFunction: Function): Flow; + private constructor(); + /** Gets the actual function being compiled, The inlined function when inlining, otherwise the parent function. */ + readonly actualFunction: Function; + /** Tests if this flow has the specified flag or flags. */ + is(flag: FlowFlags): bool; + /** Tests if this flow has one of the specified flags. */ + isAny(flag: FlowFlags): bool; + /** Sets the specified flag or flags. */ + set(flag: FlowFlags): void; + /** Unsets the specified flag or flags. */ + unset(flag: FlowFlags): void; + /** Forks this flow to a child flow. */ + fork(): Flow; + /** Gets a free temporary local of the specified type. */ + getTempLocal(type: Type, except?: ExpressionRef): Local; + /** Gets a local that sticks around until this flow is exited, and then released. */ + getAutoreleaseLocal(type: Type, except?: ExpressionRef): Local; + /** Frees the temporary local for reuse. */ + freeTempLocal(local: Local): void; + /** Gets and immediately frees a temporary local of the specified type. */ + getAndFreeTempLocal(type: Type, except?: ExpressionRef): Local; + /** Adds a new scoped local of the specified name. */ + addScopedLocal(name: string, type: Type, reportNode?: Node | null): Local; + /** Adds a new scoped alias for the specified local. For example `super` aliased to the `this` local. */ + addScopedAlias(name: string, type: Type, index: i32, reportNode?: Node | null): Local; + /** Blocks any locals that might be used in an inlining operation. */ + blockLocalsBeforeInlining(instance: Function): Local[]; + /** Unblocks the specified locals. */ + unblockLocals(temps: Local[]): void; + /** Frees this flow's scoped variables and returns its parent flow. */ + freeScopedLocals(): void; + /** Looks up the local of the specified name in the current scope. */ + lookupLocal(name: string): Local | null; + /** Looks up the element with the specified name relative to the scope of this flow. */ + lookup(name: string): Element | null; + /** Tests if the local at the specified index has the specified flag or flags. */ + isLocalFlag(index: i32, flag: LocalFlags, defaultIfInlined?: bool): bool; + /** Tests if the local at the specified index has any of the specified flags. */ + isAnyLocalFlag(index: i32, flag: LocalFlags, defaultIfInlined?: bool): bool; + /** Sets the specified flag or flags on the local at the specified index. */ + setLocalFlag(index: i32, flag: LocalFlags): void; + /** Unsets the specified flag or flags on the local at the specified index. */ + unsetLocalFlag(index: i32, flag: LocalFlags): void; + /** Pushes a new break label to the stack, for example when entering a loop that one can `break` from. */ + pushBreakLabel(): string; + /** Pops the most recent break label from the stack. */ + popBreakLabel(): void; + /** Inherits flags and local wrap states from the specified flow (e.g. blocks). */ + inherit(other: Flow): void; + /** Inherits categorical flags as conditional flags from the specified flow (e.g. then without else). */ + inheritConditional(other: Flow): void; + /** Inherits mutual flags and local wrap states from the specified flows (e.g. then with else). */ + inheritMutual(left: Flow, right: Flow): void; + /** Checks if an expression of the specified type is known to be non-null, even if the type might be nullable. */ + isNonnull(expr: ExpressionRef, type: Type): bool; + /** Updates local states to reflect that this branch is only taken when `expr` is true-ish. */ + inheritNonnullIfTrue(expr: ExpressionRef): void; + /** Updates local states to reflect that this branch is only taken when `expr` is false-ish. */ + inheritNonnullIfFalse(expr: ExpressionRef): void; + /** + * Tests if an expression can possibly overflow in the context of this flow. Assumes that the + * expression might already have overflown and returns `false` only if the operation neglects + * any possible combination of garbage bits being present. + */ + canOverflow(expr: ExpressionRef, type: Type): bool; + toString(): string; + } + +} +declare module 'assemblyscript/src/resolver' { + /** + * Resolve infrastructure to obtain types and elements. + * @module resolver + */ /***/ + import { DiagnosticEmitter } from 'assemblyscript/src/diagnostics'; + import { Program, Element, Class, ClassPrototype, Function, FunctionPrototype, Global } from 'assemblyscript/src/program'; + import { Flow } from 'assemblyscript/src/flow'; + import { CommonTypeNode, TypeName, TypeParameterNode, Node, IdentifierExpression, CallExpression, ElementAccessExpression, PropertyAccessExpression, LiteralExpression, AssertionExpression, Expression, UnaryPrefixExpression, UnaryPostfixExpression, BinaryExpression, ThisExpression, SuperExpression } from 'assemblyscript/src/ast'; + import { Type } from 'assemblyscript/src/types'; + /** Indicates whether errors are reported or not. */ + export enum ReportMode { + /** Report errors. */ + REPORT = 0, + /** Swallow errors. */ + SWALLOW = 1 + } + /** Provides tools to resolve types and expressions. */ + export class Resolver extends DiagnosticEmitter { + /** The program this resolver belongs to. */ + program: Program; + /** Target expression of the previously resolved property or element access. */ + currentThisExpression: Expression | null; + /** Element expression of the previously resolved element access. */ + currentElementExpression: Expression | null; + /** Constructs the resolver for the specified program. */ + constructor( + /** The program to construct a resolver for. */ + program: Program); + /** Resolves a {@link CommonTypeNode} to a concrete {@link Type}. */ + resolveType( + /** The type to resolve. */ + node: CommonTypeNode, + /** Relative context. */ + context: Element, + /** Type arguments inherited through context, i.e. `T`. */ + contextualTypeArguments?: Map | null, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Type | null; + /** Resolves a type name to the program element it refers to. */ + resolveTypeName( + /** The type name to resolve. */ + typeName: TypeName, + /** Relative context. */ + context: Element, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves an array of type arguments to concrete types. */ + resolveTypeArguments( + /** Actual type parameter nodes. */ + typeParameters: TypeParameterNode[], + /** Type arguments provided. */ + typeArgumentNodes: CommonTypeNode[] | null, + /** Relative context. */ + context: Element, + /** Type arguments inherited through context, i.e. `T`. */ + contextualTypeArguments?: Map, + /** Alternative report node in case of empty type arguments. */ + alternativeReportNode?: Node | null, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Type[] | null; + /** Resolves an identifier to the program element it refers to. */ + resolveIdentifier( + /** The expression to resolve. */ + identifier: IdentifierExpression, + /** Optional flow to search for scoped locals. */ + flow: Flow | null, + /** Optional context to search. */ + context: Element | null, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves a lazily compiled global, i.e. a static class field. */ + ensureResolvedLazyGlobal(global: Global, reportMode?: ReportMode): bool; + /** Resolves a property access expression to the program element it refers to. */ + resolvePropertyAccessExpression( + /** The expression to resolve. */ + propertyAccess: PropertyAccessExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves an element access expression to the program element it refers to. */ + resolveElementAccessExpression( + /** The expression to resolve. */ + elementAccess: ElementAccessExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Determines the final type of an integer literal given the specified contextual type. */ + determineIntegerLiteralType( + /** Integer literal value. */ + intValue: I64, + /** Current contextual type. */ + contextualType: Type): Type; + /** Resolves any expression to the program element it refers to. */ + resolveExpression( + /** The expression to resolve. */ + expression: Expression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves an assertion expression to the program element it refers to. */ + resolveAssertionExpression( + /** The expression to resolve. */ + expression: AssertionExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves an unary prefix expression to the program element it refers to. */ + resolveUnaryPrefixExpression( + /** The expression to resolve. */ + expression: UnaryPrefixExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves an unary postfix expression to the program element it refers to. */ + resolveUnaryPostfixExpression( + /** The expression to resolve. */ + expression: UnaryPostfixExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves a binary expression to the program element it refers to. */ + resolveBinaryExpression( + /** The expression to resolve. */ + expression: BinaryExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves a this expression to the program element it refers to. */ + resolveThisExpression( + /** The expression to resolve. */ + expression: ThisExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves a super expression to the program element it refers to. */ + resolveSuperExpression( + /** The expression to resolve. */ + expression: SuperExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves a literal expression to the program element it refers to. */ + resolveLiteralExpression( + /** The expression to resolve. */ + expression: LiteralExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves a call expression to the program element it refers to. */ + resolveCallExpression( + /** The expression to resolve. */ + expression: CallExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType?: Type, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Element | null; + /** Resolves a function prototype using the specified concrete type arguments. */ + resolveFunction( + /** The prototype of the function. */ + prototype: FunctionPrototype, + /** Concrete type arguments. */ + typeArguments: Type[] | null, + /** Type arguments inherited through context, i.e. `T`. */ + contextualTypeArguments?: Map, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Function | null; + /** Resolves a function prototypeby first resolving the specified type arguments. */ + resolveFunctionInclTypeArguments( + /** The prototype of the function. */ + prototype: FunctionPrototype, + /** Type arguments provided. */ + typeArgumentNodes: CommonTypeNode[] | null, + /** Relative context. Type arguments are resolved from here. */ + context: Element, + /** Type arguments inherited through context, i.e. `T`. */ + contextualTypeArguments: Map, + /** The node to use when reporting intermediate errors. */ + reportNode: Node, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Function | null; + /** Resolves a class prototype using the specified concrete type arguments. */ + resolveClass( + /** The prototype of the class. */ + prototype: ClassPrototype, + /** Concrete type arguments. */ + typeArguments: Type[] | null, + /** Type arguments inherited through context, i.e. `T`. */ + contextualTypeArguments?: Map, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Class | null; + /** Resolves a class prototype by first resolving the specified type arguments. */ + resolveClassInclTypeArguments( + /** The prototype of the class. */ + prototype: ClassPrototype, + /** Type argument nodes provided. */ + typeArgumentNodes: CommonTypeNode[] | null, + /** Relative context. Type arguments are resolved from here. */ + context: Element, + /** Type arguments inherited through context, i.e. `T`. */ + contextualTypeArguments: Map, + /** The node to use when reporting intermediate errors. */ + reportNode: Node, + /** How to proceed with eventualy diagnostics. */ + reportMode?: ReportMode): Class | null; + } + +} +declare module 'assemblyscript/src/program' { + /** + * AssemblyScript's intermediate representation describing a program's elements. + * @module program + */ /***/ + import { CommonFlags } from 'assemblyscript/src/common'; + import { Options } from 'assemblyscript/src/compiler'; + import { DiagnosticMessage, DiagnosticEmitter } from 'assemblyscript/src/diagnostics'; + import { Type, TypeKind, Signature } from 'assemblyscript/src/types'; + import { Source, Range, DecoratorNode, DecoratorKind, SignatureNode, TypeParameterNode, CommonTypeNode, TypeNode, ArrowKind, Expression, IdentifierExpression, Statement, ClassDeclaration, DeclarationStatement, EnumDeclaration, EnumValueDeclaration, FieldDeclaration, FunctionDeclaration, InterfaceDeclaration, NamespaceDeclaration, TypeDeclaration, VariableDeclaration, VariableLikeDeclarationStatement } from 'assemblyscript/src/ast'; + import { Module, FunctionRef } from 'assemblyscript/src/module'; + import { Resolver } from 'assemblyscript/src/resolver'; + import { Flow } from 'assemblyscript/src/flow'; + /** Represents the kind of an operator overload. */ + export enum OperatorKind { + INVALID = 0, + INDEXED_GET = 1, + INDEXED_SET = 2, + UNCHECKED_INDEXED_GET = 3, + UNCHECKED_INDEXED_SET = 4, + ADD = 5, + SUB = 6, + MUL = 7, + DIV = 8, + REM = 9, + POW = 10, + BITWISE_AND = 11, + BITWISE_OR = 12, + BITWISE_XOR = 13, + BITWISE_SHL = 14, + BITWISE_SHR = 15, + BITWISE_SHR_U = 16, + EQ = 17, + NE = 18, + GT = 19, + GE = 20, + LT = 21, + LE = 22, + PLUS = 23, + MINUS = 24, + NOT = 25, + BITWISE_NOT = 26, + PREFIX_INC = 27, + PREFIX_DEC = 28, + POSTFIX_INC = 29, + POSTFIX_DEC = 30 + } + /** Represents an AssemblyScript program. */ + export class Program extends DiagnosticEmitter { + /** Resolver instance. */ + resolver: Resolver; + /** Array of sources. */ + sources: Source[]; + /** Diagnostic offset used where successively obtaining the next diagnostic. */ + diagnosticsOffset: i32; + /** Compiler options. */ + options: Options; + /** Special native code source. */ + nativeSource: Source; + /** Special native code file. */ + nativeFile: File; + /** Explicitly annotated start function. */ + explicitStartFunction: FunctionPrototype | null; + /** Files by unique internal name. */ + filesByName: Map; + /** Elements by unique internal name in element space. */ + elementsByName: Map; + /** Elements by declaration. */ + elementsByDeclaration: Map; + /** Element instances by unique internal name. */ + instancesByName: Map; + /** Classes backing basic types like `i32`. */ + typeClasses: Map; + /** Managed classes contained in the program, by id. */ + managedClasses: Map; + /** ArrayBufferView reference. */ + arrayBufferViewInstance: Class; + /** ArrayBuffer instance reference. */ + arrayBufferInstance: Class; + /** Array prototype reference. */ + arrayPrototype: ClassPrototype; + /** Set prototype reference. */ + setPrototype: ClassPrototype; + /** Map prototype reference. */ + mapPrototype: ClassPrototype; + /** Fixed array prototype reference. */ + fixedArrayPrototype: ClassPrototype; + /** Int8Array prototype. */ + i8ArrayPrototype: ClassPrototype; + /** Int16Array prototype. */ + i16ArrayPrototype: ClassPrototype; + /** Int32Array prototype. */ + i32ArrayPrototype: ClassPrototype; + /** Int64Array prototype. */ + i64ArrayPrototype: ClassPrototype; + /** Uint8Array prototype. */ + u8ArrayPrototype: ClassPrototype; + /** Uint8ClampedArray prototype. */ + u8ClampedArrayPrototype: ClassPrototype; + /** Uint16Array prototype. */ + u16ArrayPrototype: ClassPrototype; + /** Uint32Array prototype. */ + u32ArrayPrototype: ClassPrototype; + /** Uint64Array prototype. */ + u64ArrayPrototype: ClassPrototype; + /** Float32Array prototype. */ + f32ArrayPrototype: ClassPrototype; + /** Float64Array prototype. */ + f64ArrayPrototype: ClassPrototype; + /** String instance reference. */ + stringInstance: Class; + /** Abort function reference, if present. */ + abortInstance: Function; + /** RT `__alloc(size: usize, id: u32): usize` */ + allocInstance: Function; + /** RT `__realloc(ref: usize, newSize: usize): usize` */ + reallocInstance: Function; + /** RT `__free(ref: usize): void` */ + freeInstance: Function; + /** RT `__retain(ref: usize): usize` */ + retainInstance: Function; + /** RT `__release(ref: usize): void` */ + releaseInstance: Function; + /** RT `__collect(): void` */ + collectInstance: Function; + /** RT `__visit(ref: usize, cookie: u32): void` */ + visitInstance: Function; + /** RT `__typeinfo(id: u32): RTTIFlags` */ + typeinfoInstance: Function; + /** RT `__instanceof(ref: usize, superId: u32): bool` */ + instanceofInstance: Function; + /** RT `__allocArray(length: i32, alignLog2: usize, id: u32, data: usize = 0): usize` */ + allocArrayInstance: Function; + /** Next class id. */ + nextClassId: u32; + /** Constructs a new program, optionally inheriting parser diagnostics. */ + constructor( + /** Shared array of diagnostic messages (emitted so far). */ + diagnostics?: DiagnosticMessage[] | null); + /** Writes a common runtime header to the specified buffer. */ + writeRuntimeHeader(buffer: Uint8Array, offset: i32, classInstance: Class, payloadSize: u32): void; + /** Gets the size of a runtime header. */ + readonly runtimeHeaderSize: i32; + /** Creates a native variable declaration. */ + makeNativeVariableDeclaration( + /** The simple name of the variable */ + name: string, + /** Flags indicating specific traits, e.g. `CONST`. */ + flags?: CommonFlags): VariableDeclaration; + /** Creates a native type declaration. */ + makeNativeTypeDeclaration( + /** The simple name of the type. */ + name: string, + /** Flags indicating specific traits, e.g. `GENERIC`. */ + flags?: CommonFlags): TypeDeclaration; + private nativeDummySignature; + /** Creates a native function declaration. */ + makeNativeFunctionDeclaration( + /** The simple name of the function. */ + name: string, + /** Flags indicating specific traits, e.g. `DECLARE`. */ + flags?: CommonFlags): FunctionDeclaration; + /** Creates a native namespace declaration. */ + makeNativeNamespaceDeclaration( + /** The simple name of the namespace. */ + name: string, + /** Flags indicating specific traits, e.g. `EXPORT`. */ + flags?: CommonFlags): NamespaceDeclaration; + /** Creates a native function. */ + makeNativeFunction( + /** The simple name of the function. */ + name: string, + /** Concrete function signature. */ + signature: Signature, + /** Parent element, usually a file, class or namespace. */ + parent?: Element, + /** Flags indicating specific traits, e.g. `GENERIC`. */ + flags?: CommonFlags, + /** Decorator flags representing built-in decorators. */ + decoratorFlags?: DecoratorFlags): Function; + /** Gets the (possibly merged) program element linked to the specified declaration. */ + getElementByDeclaration(declaration: DeclarationStatement): DeclaredElement; + /** Initializes the program and its elements prior to compilation. */ + initialize(options: Options): void; + /** Requires that a global library element of the specified kind is present and returns it. */ + private require; + /** Requires that a non-generic global class is present and returns it. */ + private requireClass; + /** Requires that a non-generic global function is present and returns it. */ + private requireFunction; + /** Marks an element and its children as a module export. */ + private markModuleExport; + /** Registers a native type with the program. */ + private registerNativeType; + /** Registers the backing class of a native type. */ + private registerNativeTypeClass; + /** Registers a constant integer value within the global scope. */ + private registerConstantInteger; + /** Registers a constant float value within the global scope. */ + private registerConstantFloat; + /** Ensures that the given global element exists. Attempts to merge duplicates. */ + ensureGlobal(name: string, element: DeclaredElement): DeclaredElement; + /** Looks up the element of the specified name in the global scope. */ + lookupGlobal(name: string): Element | null; + /** Looks up the element of the specified name in the global scope. Errors if not present. */ + requireGlobal(name: string): Element; + /** Tries to locate a foreign file given its normalized path. */ + private lookupForeignFile; + /** Tries to locate a foreign element by traversing exports and queued exports. */ + private lookupForeign; + /** Validates that only supported decorators are present. */ + private checkDecorators; + /** Initializes a class declaration. */ + private initializeClass; + /** Initializes a field of a class or interface. */ + private initializeField; + /** Initializes a method of a class or interface. */ + private initializeMethod; + /** Checks that operator overloads are generally valid, if present. */ + private checkOperatorOverloads; + /** Ensures that the property introduced by the specified getter or setter exists.*/ + private ensureProperty; + /** Initializes a property of a class. */ + private initializeProperty; + /** Initializes an enum. */ + private initializeEnum; + /** Initializes an enum value. */ + private initializeEnumValue; + /** Initializes an `export` statement. */ + private initializeExports; + /** Initializes a single `export` member. Does not handle `export *`. */ + private initializeExport; + /** Initializes an `import` statement. */ + private initializeImports; + /** Initializes a single `import` declaration. Does not handle `import *`. */ + private initializeImport; + /** Initializes a function. Does not handle methods. */ + private initializeFunction; + /** Initializes an interface. */ + private initializeInterface; + /** Initializes a namespace. */ + private initializeNamespace; + /** Initializes a `type` definition. */ + private initializeTypeDefinition; + /** Initializes a variable statement. */ + private initializeVariables; + } + /** Indicates the specific kind of an {@link Element}. */ + export enum ElementKind { + /** A {@link Global}. */ + GLOBAL = 0, + /** A {@link Local}. */ + LOCAL = 1, + /** An {@link Enum}. */ + ENUM = 2, + /** An {@link EnumValue}. */ + ENUMVALUE = 3, + /** A {@link FunctionPrototype}. */ + FUNCTION_PROTOTYPE = 4, + /** A {@link Function}. */ + FUNCTION = 5, + /** A {@link FunctionTarget}. */ + FUNCTION_TARGET = 6, + /** A {@link ClassPrototype}. */ + CLASS_PROTOTYPE = 7, + /** A {@link Class}. */ + CLASS = 8, + /** An {@link InterfacePrototype}. */ + INTERFACE_PROTOTYPE = 9, + /** An {@link Interface}. */ + INTERFACE = 10, + /** A {@link FieldPrototype}. */ + FIELD_PROTOTYPE = 11, + /** A {@link Field}. */ + FIELD = 12, + /** A {@link PropertyPrototype}. */ + PROPERTY_PROTOTYPE = 13, + /** A {@link Property}. */ + PROPERTY = 14, + /** A {@link Namespace}. */ + NAMESPACE = 15, + /** A {@link File}. */ + FILE = 16, + /** A {@link TypeDefinition}. */ + TYPEDEFINITION = 17 + } + /** Indicates built-in decorators that are present. */ + export enum DecoratorFlags { + /** No flags set. */ + NONE = 0, + /** Is a program global. */ + GLOBAL = 1, + /** Is a binary operator overload. */ + OPERATOR_BINARY = 2, + /** Is a unary prefix operator overload. */ + OPERATOR_PREFIX = 4, + /** Is a unary postfix operator overload. */ + OPERATOR_POSTFIX = 8, + /** Is an unmanaged class. */ + UNMANAGED = 16, + /** Is a sealed class. */ + SEALED = 32, + /** Is always inlined. */ + INLINE = 64, + /** Is using a different external name. */ + EXTERNAL = 128, + /** Is a builtin. */ + BUILTIN = 256, + /** Is compiled lazily. */ + LAZY = 512, + /** Is the explicit start function. */ + START = 1024, + /** Is considered unsafe code. */ + UNSAFE = 2048 + } + /** Translates a decorator kind to the respective decorator flag. */ + export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags; + /** Base class of all program elements. */ + export abstract class Element { + /** Specific element kind. */ + kind: ElementKind; + /** Simple name. */ + name: string; + /** Internal name referring to this element. */ + internalName: string; + /** Containing {@link Program}. */ + program: Program; + /** Parent element. */ + parent: Element; + /** Common flags indicating specific traits. */ + flags: CommonFlags; + /** Decorator flags indicating annotated traits. */ + decoratorFlags: DecoratorFlags; + /** Member elements. */ + members: Map | null; + /** Shadowing type in type space, if any. */ + shadowType: TypeDefinition | null; + /** Constructs a new program element. */ + protected constructor( + /** Specific element kind. */ + kind: ElementKind, + /** Simple name. */ + name: string, + /** Internal name referring to this element. */ + internalName: string, + /** Containing {@link Program}. */ + program: Program, + /** Parent element. */ + parent: Element | null); + /** Gets the enclosing file. */ + readonly file: File; + /** Tests if this element has a specific flag or flags. */ + is(flag: CommonFlags): bool; + /** Tests if this element has any of the specified flags. */ + isAny(flags: CommonFlags): bool; + /** Sets a specific flag or flags. */ + set(flag: CommonFlags): void; + /** Unsets the specific flag or flags. */ + unset(flag: CommonFlags): void; + /** Tests if this element has a specific decorator flag or flags. */ + hasDecorator(flag: DecoratorFlags): bool; + /** Looks up the element with the specified name within this element. */ + lookupInSelf(name: string): DeclaredElement | null; + /** Looks up the element with the specified name relative to this element, like in JS. */ + abstract lookup(name: string): Element | null; + /** Adds an element as a member of this one. Reports and returns `false` if a duplicate. */ + add(name: string, element: DeclaredElement): bool; + /** Returns a string representation of this element. */ + toString(): string; + } + /** Base class of elements with an associated declaration statement. */ + export abstract class DeclaredElement extends Element { + /** Declaration reference. */ + declaration: DeclarationStatement; + /** Constructs a new declared program element. */ + protected constructor( + /** Specific element kind. */ + kind: ElementKind, + /** Simple name. */ + name: string, + /** Internal name referring to this element. */ + internalName: string, + /** Containing {@link Program}. */ + program: Program, + /** Parent element. */ + parent: Element | null, + /** Declaration reference. */ + declaration: DeclarationStatement); + /** Tests if this element is a library element. */ + readonly isDeclaredInLibrary: bool; + /** Gets the associated identifier node. */ + readonly identifierNode: IdentifierExpression; + /** Gets the assiciated decorator nodes. */ + readonly decoratorNodes: DecoratorNode[] | null; + } + /** Base class of elements that can be resolved to a concrete type. */ + export abstract class TypedElement extends DeclaredElement { + /** Resolved type. Set once `is(RESOLVED)`, otherwise void. */ + type: Type; + /** Sets the resolved type of this element. */ + setType(type: Type): void; + } + /** A file representing the implicit top-level namespace of a source. */ + export class File extends Element { + /** Source of this file. */ + source: Source; + /** File exports. */ + exports: Map | null; + /** File re-exports. */ + exportsStar: File[] | null; + /** Top-level start function of this file. */ + startFunction: Function; + /** Constructs a new file. */ + constructor( + /** Program this file belongs to. */ + program: Program, + /** Source of this file. */ + source: Source); + add(name: string, element: DeclaredElement, isImport?: bool): bool; + lookupInSelf(name: string): DeclaredElement | null; + lookup(name: string): Element | null; + /** Ensures that an element is an export of this file. */ + ensureExport(name: string, element: DeclaredElement): void; + /** Ensures that another file is a re-export of this file. */ + ensureExportStar(file: File): void; + /** Looks up the export of the specified name. */ + lookupExport(name: string): DeclaredElement | null; + /** Creates an imported namespace from this file. */ + asImportedNamespace(name: string, parent: Element): Namespace; + } + /** A type definition. */ + export class TypeDefinition extends TypedElement { + /** Constructs a new type definition. */ + constructor( + /** Simple name. */ + name: string, + /** Parent element, usually a file or namespace. */ + parent: Element, + /** Declaration reference. */ + declaration: TypeDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags?: DecoratorFlags); + /** Gets the associated type parameter nodes. */ + readonly typeParameterNodes: TypeParameterNode[] | null; + /** Gets the associated type node. */ + readonly typeNode: CommonTypeNode; + lookup(name: string): Element | null; + } + /** A namespace that differs from a file in being user-declared with a name. */ + export class Namespace extends DeclaredElement { + /** Constructs a new namespace. */ + constructor( + /** Simple name. */ + name: string, + /** Parent element, usually a file or another namespace. */ + parent: Element, + /** Declaration reference. */ + declaration: NamespaceDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags?: DecoratorFlags); + lookup(name: string): Element | null; + } + /** An enum. */ + export class Enum extends TypedElement { + /** Constructs a new enum. */ + constructor( + /** Simple name. */ + name: string, + /** Parent element, usually a file or namespace. */ + parent: Element, + /** Declaration reference. */ + declaration: EnumDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags?: DecoratorFlags); + lookup(name: string): Element | null; + } + /** Indicates the kind of an inlined constant value. */ + export const enum ConstantValueKind { + /** No constant value. */ + NONE = 0, + /** Constant integer value. */ + INTEGER = 1, + /** Constant float value. */ + FLOAT = 2 + } + /** Base class of all variable-like program elements. */ + export abstract class VariableLikeElement extends TypedElement { + /** Constant value kind. */ + constantValueKind: ConstantValueKind; + /** Constant integer value, if applicable. */ + constantIntegerValue: I64; + /** Constant float value, if applicable. */ + constantFloatValue: f64; + /** Constructs a new variable-like element. */ + protected constructor( + /** Specific element kind. */ + kind: ElementKind, + /** Simple name. */ + name: string, + /** Parent element, usually a file, namespace or class. */ + parent: Element, + /** Declaration reference. Creates a native declaration if omitted. */ + declaration?: VariableLikeDeclarationStatement); + /** Gets the associated type node.s */ + readonly typeNode: CommonTypeNode | null; + /** Gets the associated initializer node. */ + readonly initializerNode: Expression | null; + /** Applies a constant integer value to this element. */ + setConstantIntegerValue(value: I64, type: Type): void; + /** Applies a constant float value to this element. */ + setConstantFloatValue(value: f64, type: Type): void; + /** @override */ + lookup(name: string): Element | null; + } + /** An enum value. */ + export class EnumValue extends VariableLikeElement { + /** Constructs a new enum value. */ + constructor( + /** Simple name. */ + name: string, + /** Parent enum. */ + parent: Enum, + /** Declaration reference. */ + declaration: EnumValueDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags?: DecoratorFlags); + /** Whether this enum value is immutable. */ + isImmutable: bool; + /** Gets the associated value node. */ + readonly valueNode: Expression | null; + lookup(name: string): Element | null; + } + /** A global variable. */ + export class Global extends VariableLikeElement { + /** Constructs a new global variable. */ + constructor( + /** Simple name. */ + name: string, + /** Parent element, usually a file, namespace or static class. */ + parent: Element, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags: DecoratorFlags, + /** Declaration reference. Creates a native declaration if omitted. */ + declaration?: VariableLikeDeclarationStatement); + } + /** A function parameter. */ + export class Parameter { + /** Parameter name. */ + name: string; + /** Parameter type. */ + type: Type; + /** Parameter initializer, if present. */ + initializer: Expression | null; + /** Constructs a new function parameter. */ + constructor( + /** Parameter name. */ + name: string, + /** Parameter type. */ + type: Type, + /** Parameter initializer, if present. */ + initializer?: Expression | null); + } + /** A local variable. */ + export class Local extends VariableLikeElement { + /** Zero-based index within the enclosing function. `-1` indicates a virtual local. */ + index: i32; + /** Constructs a new local variable. */ + constructor( + /** Simple name. */ + name: string, + /** Zero-based index within the enclosing function. `-1` indicates a virtual local. */ + index: i32, + /** Resolved type. */ + type: Type, + /** Parent function. */ + parent: Function, + /** Declaration reference. */ + declaration?: VariableLikeDeclarationStatement); + } + /** A yet unresolved function prototype. */ + export class FunctionPrototype extends DeclaredElement { + /** Operator kind, if an overload. */ + operatorKind: OperatorKind; + /** Already resolved instances. */ + instances: Map | null; + /** Clones of this prototype that are bounds to specific classes. */ + private boundPrototypes; + /** Constructs a new function prototype. */ + constructor( + /** Simple name */ + name: string, + /** Parent element, usually a file, namespace or class (if a method). */ + parent: Element, + /** Declaration reference. */ + declaration: FunctionDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags?: DecoratorFlags); + /** Gets the associated type parameter nodes. */ + readonly typeParameterNodes: TypeParameterNode[] | null; + /** Gets the associated signature node. */ + readonly signatureNode: SignatureNode; + /** Gets the associated body node. */ + readonly bodyNode: Statement | null; + /** Gets the arrow function kind. */ + readonly arrowKind: ArrowKind; + /** Tests if this prototype is bound to a class. */ + readonly isBound: bool; + /** Creates a clone of this prototype that is bound to a concrete class instead. */ + toBound(classInstance: Class): FunctionPrototype; + /** Gets the resolved instance for the specified instance key, if already resolved. */ + getResolvedInstance(instanceKey: string): Function | null; + /** Sets the resolved instance for the specified instance key. */ + setResolvedInstance(instanceKey: string, instance: Function): void; + lookup(name: string): Element | null; + } + /** A resolved function. */ + export class Function extends TypedElement { + /** Function prototype. */ + prototype: FunctionPrototype; + /** Function signature. */ + signature: Signature; + /** Map of locals by name. */ + localsByName: Map; + /** Array of locals by index. */ + localsByIndex: Local[]; + /** List of additional non-parameter locals. */ + additionalLocals: Type[]; + /** Contextual type arguments. */ + contextualTypeArguments: Map | null; + /** Default control flow. */ + flow: Flow; + /** Remembered debug locations. */ + debugLocations: Range[]; + /** Function reference, if compiled. */ + ref: FunctionRef; + /** Function table index, if any. */ + functionTableIndex: i32; + /** Trampoline function for calling with omitted arguments. */ + trampoline: Function | null; + /** Counting id of inline operations involving this function. */ + nextInlineId: i32; + /** Counting id of anonymous inner functions. */ + nextAnonymousId: i32; + /** Counting id of autorelease variables. */ + nextAutoreleaseId: i32; + /** Constructs a new concrete function. */ + constructor( + /** Name incl. type parameters, i.e. `foo`. */ + nameInclTypeParameters: string, + /** Respective function prototype. */ + prototype: FunctionPrototype, + /** Concrete signature. */ + signature: Signature, // pre-resolved + /** Contextual type arguments inherited from its parent class, if any. */ + contextualTypeArguments?: Map | null); + /** Adds a local of the specified type, with an optional name. */ + addLocal(type: Type, name?: string | null, declaration?: VariableDeclaration | null): Local; + lookup(name: string): Element | null; + tempI32s: Local[] | null; + tempI64s: Local[] | null; + tempF32s: Local[] | null; + tempF64s: Local[] | null; + tempV128s: Local[] | null; + nextBreakId: i32; + breakStack: i32[] | null; + breakLabel: string | null; + /** Finalizes the function once compiled, releasing no longer needed resources. */ + finalize(module: Module, ref: FunctionRef): void; + } + /** A resolved function target, that is a function called indirectly by an index and signature. */ + export class FunctionTarget extends Element { + /** Underlying signature. */ + signature: Signature; + /** Function type. */ + type: Type; + /** Constructs a new function target. */ + constructor( + /** Concrete signature. */ + signature: Signature, + /** Program reference. */ + program: Program, __s?: string); + lookup(name: string): Element | null; + } + /** A yet unresolved instance field prototype. */ + export class FieldPrototype extends DeclaredElement { + /** Constructs a new field prototype. */ + constructor( + /** Simple name. */ + name: string, + /** Parent class. */ + parent: ClassPrototype, + /** Declaration reference. */ + declaration: FieldDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags?: DecoratorFlags); + /** Gets the associated type node. */ + readonly typeNode: CommonTypeNode | null; + /** Gets the associated initializer node. */ + readonly initializerNode: Expression | null; + /** Gets the associated parameter index. Set if declared as a constructor parameter, otherwise `-1`. */ + readonly parameterIndex: i32; + lookup(name: string): Element | null; + } + /** A resolved instance field. */ + export class Field extends VariableLikeElement { + /** Field prototype reference. */ + prototype: FieldPrototype; + /** Field memory offset, if an instance field. */ + memoryOffset: i32; + /** Constructs a new field. */ + constructor( + /** Respective field prototype. */ + prototype: FieldPrototype, + /** Parent class. */ + parent: Class, + /** Concrete type. */ + type: Type); + } + /** A property comprised of a getter and a setter function. */ + export class PropertyPrototype extends DeclaredElement { + /** Getter prototype. */ + getterPrototype: FunctionPrototype | null; + /** Setter prototype. */ + setterPrototype: FunctionPrototype | null; + /** Constructs a new property prototype. */ + constructor( + /** Simple name. */ + name: string, + /** Parent class. */ + parent: ClassPrototype, + /** Declaration of the getter or setter introducing the property. */ + firstDeclaration: FunctionDeclaration); + lookup(name: string): Element | null; + } + /** A resolved property. */ + export class Property extends VariableLikeElement { + /** Prototype reference. */ + prototype: PropertyPrototype; + /** Getter instance. */ + getterInstance: Function | null; + /** Setter instance. */ + setterInstance: Function | null; + /** Constructs a new property prototype. */ + constructor( + /** Respective property prototype. */ + prototype: PropertyPrototype, + /** Parent element, usually a static class prototype or class instance. */ + parent: Element); + lookup(name: string): Element | null; + } + /** A yet unresolved class prototype. */ + export class ClassPrototype extends DeclaredElement { + /** Instance member prototypes. */ + instanceMembers: Map | null; + /** Base class prototype, if applicable. */ + basePrototype: ClassPrototype | null; + /** Constructor prototype. */ + constructorPrototype: FunctionPrototype | null; + /** Operator overload prototypes. */ + overloadPrototypes: Map; + /** Already resolved instances. */ + instances: Map | null; + constructor( + /** Simple name. */ + name: string, + /** Parent element, usually a file or namespace. */ + parent: Element, + /** Declaration reference. */ + declaration: ClassDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags?: DecoratorFlags, _isInterface?: bool); + /** Gets the associated type parameter nodes. */ + readonly typeParameterNodes: TypeParameterNode[] | null; + /** Gets the associated extends node. */ + readonly extendsNode: TypeNode | null; + /** Gets the associated implements nodes. */ + readonly implementsNodes: TypeNode[] | null; + /** Tests if this prototype is of a builtin array type (Array/TypedArray). */ + readonly isBuiltinArray: bool; + /** Tests if this prototype extends the specified. */ + extends(basePtototype: ClassPrototype | null): bool; + /** Adds an element as an instance member of this one. Returns the previous element if a duplicate. */ + addInstance(name: string, element: DeclaredElement): bool; + /** Gets the resolved instance for the specified instance key, if already resolved. */ + getResolvedInstance(instanceKey: string): Class | null; + /** Sets the resolved instance for the specified instance key. */ + setResolvedInstance(instanceKey: string, instance: Class): void; + lookup(name: string): Element | null; + } + /** A resolved class. */ + export class Class extends TypedElement { + /** Class prototype. */ + prototype: ClassPrototype; + /** Resolved type arguments. */ + typeArguments: Type[] | null; + /** Base class, if applicable. */ + base: Class | null; + /** Contextual type arguments for fields and methods. */ + contextualTypeArguments: Map | null; + /** Current member memory offset. */ + currentMemoryOffset: u32; + /** Constructor instance. */ + constructorInstance: Function | null; + /** Operator overloads. */ + overloads: Map | null; + /** Unique class id. */ + private _id; + /** Remembers acyclic state. */ + private _acyclic; + /** Gets the unique runtime id of this class. */ + readonly id: u32; + /** Tests if this class is of a builtin array type (Array/TypedArray). */ + readonly isBuiltinArray: bool; + /** Tests if this class is array-like. */ + readonly isArrayLike: bool; + /** Constructs a new class. */ + constructor( + /** Name incl. type parameters, i.e. `Foo`. */ + nameInclTypeParameters: string, + /** The respective class prototype. */ + prototype: ClassPrototype, + /** Concrete type arguments, if any. */ + typeArguments?: Type[] | null, + /** Base class, if derived. */ + base?: Class | null, _isInterface?: bool); + /** Tests if a value of this class type is assignable to a target of the specified class type. */ + isAssignableTo(target: Class): bool; + /** Looks up the operator overload of the specified kind. */ + lookupOverload(kind: OperatorKind, unchecked?: bool): Function | null; + lookup(name: string): Element | null; + /** Calculates the memory offset of the specified field. */ + offsetof(fieldName: string): u32; + /** Writes a field value to a buffer and returns the number of bytes written. */ + writeField(name: string, value: T, buffer: Uint8Array, baseOffset: i32): i32; + /** Tests if this class extends the specified prototype. */ + extends(prototype: ClassPrototype): bool; + /** Gets the concrete type arguments to the specified extendend prototype. */ + getTypeArgumentsTo(extendedPrototype: ClassPrototype): Type[] | null; + /** Gets the value type of an array. Must be an array. */ + getArrayValueType(): Type; + /** Tests if this class is inherently acyclic. */ + readonly isAcyclic: bool; + /** Tests if this class potentially forms a reference cycle to another one. */ + private cyclesTo; + } + /** A yet unresolved interface. */ + export class InterfacePrototype extends ClassPrototype { + /** Constructs a new interface prototype. */ + constructor(name: string, parent: Element, declaration: InterfaceDeclaration, decoratorFlags: DecoratorFlags); + } + /** A resolved interface. */ + export class Interface extends Class { + /** Constructs a new interface. */ + constructor(nameInclTypeParameters: string, prototype: InterfacePrototype, typeArguments?: Type[], base?: Interface | null); + } + /** Mangles the internal name of an element with the specified name that is a child of the given parent. */ + export function mangleInternalName(name: string, parent: Element, isInstance: bool, asGlobal?: bool): string; + +} +declare module 'assemblyscript/src/compiler' { + /** + * The AssemblyScript compiler. + * @module compiler + */ /***/ + import { DiagnosticEmitter } from 'assemblyscript/src/diagnostics'; + import { Module, MemorySegment, ExpressionRef, NativeType, FunctionRef, FunctionTypeRef, GlobalRef } from 'assemblyscript/src/module'; + import { Feature, Target } from 'assemblyscript/src/common'; + import { Program, ClassPrototype, Class, Element, Enum, Field, FunctionPrototype, Function, Global, VariableLikeElement, File } from 'assemblyscript/src/program'; + import { Flow } from 'assemblyscript/src/flow'; + import { Resolver } from 'assemblyscript/src/resolver'; + import { Node, TypeNode, Range, Statement, BlockStatement, BreakStatement, ContinueStatement, DoStatement, EmptyStatement, ExpressionStatement, ForStatement, IfStatement, InstanceOfExpression, InterfaceDeclaration, ReturnStatement, SwitchStatement, ThrowStatement, TryStatement, VariableStatement, VoidStatement, WhileStatement, Expression, AssertionExpression, BinaryExpression, CallExpression, CommaExpression, ElementAccessExpression, FunctionExpression, IdentifierExpression, LiteralExpression, NewExpression, ObjectLiteralExpression, PropertyAccessExpression, TernaryExpression, StringLiteralExpression, UnaryPostfixExpression, UnaryPrefixExpression } from 'assemblyscript/src/ast'; + import { Type, Signature } from 'assemblyscript/src/types'; + /** Compiler options. */ + export class Options { + /** WebAssembly target. Defaults to {@link Target.WASM32}. */ + target: Target; + /** If true, replaces assertions with nops. */ + noAssert: bool; + /** If true, imports the memory provided by the embedder. */ + importMemory: bool; + /** If greater than zero, declare memory as shared by setting max memory to sharedMemory. */ + sharedMemory: i32; + /** If true, imports the function table provided by the embedder. */ + importTable: bool; + /** If true, generates information necessary for source maps. */ + sourceMap: bool; + /** Static memory start offset. */ + memoryBase: i32; + /** Global aliases. */ + globalAliases: Map | null; + /** Additional features to activate. */ + features: Feature; + /** Hinted optimize level. Not applied by the compiler itself. */ + optimizeLevelHint: i32; + /** Hinted shrink level. Not applied by the compiler itself. */ + shrinkLevelHint: i32; + /** Tests if the target is WASM64 or, otherwise, WASM32. */ + readonly isWasm64: bool; + /** Gets the unsigned size type matching the target. */ + readonly usizeType: Type; + /** Gets the signed size type matching the target. */ + readonly isizeType: Type; + /** Gets the native size type matching the target. */ + readonly nativeSizeType: NativeType; + /** Tests if a specific feature is activated. */ + hasFeature(feature: Feature): bool; + } + /** Requests or indicates compilation conditions of statements and expressions. */ + export const enum ContextualFlags { + NONE = 0, + /** Implicit conversion required. */ + IMPLICIT = 1, + /** Explicit conversion required. */ + EXPLICIT = 2, + /** Small integer wrap required. */ + WRAP = 4, + /** Value is known to be immediately dropped. */ + WILL_DROP = 8, + /** Value is known to be immediately assigned to a retaining target. */ + SKIP_AUTORELEASE = 16, + /** Is the last statement in a function body. */ + LAST_IN_BODY = 32, + /** Data can be compiled statically. */ + STATIC_CAPABLE = 64 + } + /** Runtime features to be activated by the compiler. */ + export const enum RuntimeFeatures { + NONE = 0, + /** Requires HEAP_BASE and heap setup. */ + HEAP = 1, + /** Requires RTTI_BASE and RTTI setup. */ + RTTI = 2, + /** Requires the built-in globals visitor. */ + visitGlobals = 4, + /** Requires the built-in members visitor. */ + visitMembers = 8 + } + /** Compiler interface. */ + export class Compiler extends DiagnosticEmitter { + /** Program reference. */ + program: Program; + /** Resolver reference. */ + resolver: Resolver; + /** Provided options. */ + options: Options; + /** Module instance being compiled. */ + module: Module; + /** Current control flow. */ + currentFlow: Flow; + /** Current inline functions stack. */ + currentInlineFunctions: Function[]; + /** Current enum in compilation. */ + currentEnum: Enum | null; + /** Current type in compilation. */ + currentType: Type; + /** Start function statements. */ + currentBody: ExpressionRef[]; + /** Counting memory offset. */ + memoryOffset: I64; + /** Memory segments being compiled. */ + memorySegments: MemorySegment[]; + /** Map of already compiled static string segments. */ + stringSegments: Map; + /** Function table being compiled. */ + functionTable: string[]; + /** Argument count helper global. */ + argcVar: GlobalRef; + /** Argument count helper setter. */ + argcSet: FunctionRef; + /** Requires runtime features. */ + runtimeFeatures: RuntimeFeatures; + /** Expressions known to have skipped an autorelease. Usually function returns. */ + skippedAutoreleases: Set; + /** Compiles a {@link Program} to a {@link Module} using the specified options. */ + static compile(program: Program, options?: Options | null): Module; + /** Constructs a new compiler for a {@link Program} using the specified options. */ + constructor(program: Program, options?: Options | null); + /** Performs compilation of the underlying {@link Program} to a {@link Module}. */ + compile(): Module; + /** Applies the respective module exports for the specified file. */ + private ensureModuleExports; + /** Applies the respective module export(s) for the specified element. */ + private ensureModuleExport; + /** Makes a function to get the value of a field of an exported class. */ + private ensureModuleFieldGetter; + /** Makes a function to set the value of a field of an exported class. */ + private ensureModuleFieldSetter; + /** Compiles any element. */ + compileElement(element: Element, compileMembers?: bool): void; + /** Compiles an element's members. */ + compileMembers(element: Element): void; + /** Compiles a file's exports. */ + compileExports(file: File): void; + /** Compiles the file matching the specified path. */ + compileFileByPath(normalizedPathWithoutExtension: string, reportNode: Node): void; + /** Compiles the specified file. */ + compileFile(file: File): void; + compileGlobal(global: Global): bool; + compileEnum(element: Enum): bool; + /** Resolves the specified type arguments prior to compiling the resulting function instance. */ + compileFunctionUsingTypeArguments(prototype: FunctionPrototype, typeArguments: TypeNode[], contextualTypeArguments?: Map, alternativeReportNode?: Node | null): Function | null; + /** Either reuses or creates the function type matching the specified signature. */ + ensureFunctionType(parameterTypes: Type[] | null, returnType: Type, thisType?: Type | null): FunctionTypeRef; + /** Compiles the body of a function within the specified flow. */ + compileFunctionBody( + /** Function to compile. */ + instance: Function, + /** Target array of statements. */ + stmts?: ExpressionRef[] | null): ExpressionRef[]; + /** Compiles a readily resolved function instance. */ + compileFunction(instance: Function): bool; + compileClassUsingTypeArguments(prototype: ClassPrototype, typeArguments: TypeNode[], contextualTypeArguments?: Map, alternativeReportNode?: Node | null): void; + compileClass(instance: Class): bool; + compileInterfaceDeclaration(declaration: InterfaceDeclaration, typeArguments: TypeNode[], contextualTypeArguments?: Map | null, alternativeReportNode?: Node | null): void; + /** Adds a static memory segment with the specified data. */ + addMemorySegment(buffer: Uint8Array, alignment?: i32): MemorySegment; + /** Ensures that the specified string exists in static memory and returns a pointer to it. */ + ensureStaticString(stringValue: string): ExpressionRef; + ensureStaticArrayBuffer(elementType: Type, values: ExpressionRef[]): MemorySegment; + ensureStaticArrayHeader(elementType: Type, bufferSegment: MemorySegment): MemorySegment; + /** Ensures that a table entry exists for the specified function and returns its index. */ + ensureFunctionTableEntry(func: Function): i32; + compileTopLevelStatement(statement: Statement, body: ExpressionRef[]): void; + compileStatement(statement: Statement, contextualFlags?: ContextualFlags): ExpressionRef; + compileStatements(statements: Statement[], isBody?: bool, stmts?: ExpressionRef[] | null): ExpressionRef[]; + compileBlockStatement(statement: BlockStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileBreakStatement(statement: BreakStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileContinueStatement(statement: ContinueStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileDoStatement(statement: DoStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileEmptyStatement(statement: EmptyStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileExpressionStatement(statement: ExpressionStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileForStatement(statement: ForStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileIfStatement(statement: IfStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileReturnStatement(statement: ReturnStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileSwitchStatement(statement: SwitchStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileThrowStatement(statement: ThrowStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileTryStatement(statement: TryStatement, contextualFlags: ContextualFlags): ExpressionRef; + /** Compiles a variable statement. Returns `0` if an initializer is not necessary. */ + compileVariableStatement(statement: VariableStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileVoidStatement(statement: VoidStatement, contextualFlags: ContextualFlags): ExpressionRef; + compileWhileStatement(statement: WhileStatement, contextualFlags: ContextualFlags): ExpressionRef; + /** + * Compiles the value of an inlined constant element. + * @param retainType If true, the annotated type of the constant is retained. Otherwise, the value + * is precomputed according to context. + */ + compileInlineConstant(element: VariableLikeElement, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileExpression(expression: Expression, contextualType: Type, contextualFlags?: ContextualFlags): ExpressionRef; + /** Compiles an expression while retaining the type, that is not void, it ultimately compiles to. */ + compileExpressionRetainType(expression: Expression, contextualType: Type, contextualFlags?: ContextualFlags): ExpressionRef; + /** Compiles and precomputes an expression, possibly yielding a costant value. */ + precomputeExpression(expression: Expression, contextualType: Type, contextualFlags?: ContextualFlags): ExpressionRef; + convertExpression(expr: ExpressionRef, + /** Original type. */ + fromType: Type, + /** New type. */ + toType: Type, + /** Whether the conversion is explicit.*/ + explicit: bool, + /** Whether the result should be wrapped, if a small integer. */ + wrap: bool, reportNode: Node): ExpressionRef; + compileAssertionExpression(expression: AssertionExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + private f32ModInstance; + private f64ModInstance; + private f32PowInstance; + private f64PowInstance; + compileBinaryExpression(expression: BinaryExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileUnaryOverload(operatorInstance: Function, value: Expression, valueExpr: ExpressionRef, reportNode: Node): ExpressionRef; + compileBinaryOverload(operatorInstance: Function, left: Expression, leftExpr: ExpressionRef, right: Expression, reportNode: Node): ExpressionRef; + compileAssignment(expression: Expression, valueExpression: Expression, contextualType: Type): ExpressionRef; + /** Makes an assignment expression or block, assigning a value to a target. */ + makeAssignment( + /** Target element, e.g. a Local. */ + target: Element, + /** Value expression that has been compiled in a previous step already. */ + valueExpr: ExpressionRef, + /** Expression reference. Has already been compiled to `valueExpr`. */ + valueExpression: Expression, + /** `this` expression reference if a field or property set. */ + thisExpression: Expression | null, + /** Index expression reference if an indexed set. */ + indexExpression: Expression | null, + /** Whether to tee the value. */ + tee: bool): ExpressionRef; + /** Makes an assignment to a local, possibly retaining and releasing affected references and keeping track of wrap and null states. */ + private makeLocalAssignment; + /** Makes an assignment to a global, possibly retaining and releasing affected references. */ + private makeGlobalAssignment; + /** Makes an assignment to a field, possibly retaining and releasing affected references. */ + makeFieldAssignment( + /** The field to assign to. */ + field: Field, + /** The value to assign. */ + valueExpr: ExpressionRef, + /** The value of `this`. */ + thisExpr: ExpressionRef, + /** Whether to tee the value. */ + tee: bool): ExpressionRef; + /** Compiles a call expression according to the specified context. */ + compileCallExpression( + /** Call expression to compile. */ + expression: CallExpression, + /** Contextual type indicating the return type the caller expects, if any. */ + contextualType: Type, + /** Contextual flags indicating contextual conditions. */ + contextualFlags: ContextualFlags): ExpressionRef; + private compileCallExpressionBuiltin; + /** + * Checks that a call with the given number as arguments can be performed according to the + * specified signature. + */ + checkCallSignature(signature: Signature, numArguments: i32, hasThis: bool, reportNode: Node): bool; + /** Compiles a direct call to a concrete function. */ + compileCallDirect(instance: Function, argumentExpressions: Expression[], reportNode: Node, thisArg?: ExpressionRef, inlineCanAlias?: bool, contextualFlags?: ContextualFlags): ExpressionRef; + compileCallInline(instance: Function, argumentExpressions: Expression[], thisArg: ExpressionRef, reportNode: Node, canAlias?: bool): ExpressionRef; + private compileCallInlinePrechecked; + makeCallInlinePrechecked(instance: Function, args: ExpressionRef[], thisArg?: ExpressionRef, canAlias?: bool, immediatelyDropped?: bool): ExpressionRef; + /** Gets the trampoline for the specified function. */ + ensureTrampoline(original: Function): Function; + /** Makes sure that the argument count helper global is present and returns its name. */ + private ensureArgcVar; + /** Makes sure that the argument count helper setter is present and returns its name. */ + private ensureArgcSet; + /** Makes retain call, retaining the expression's value. */ + makeRetain(expr: ExpressionRef): ExpressionRef; + /** Makes a retainRelease call, retaining the new expression's value and releasing the old expression's value, in this order. */ + makeRetainRelease(oldExpr: ExpressionRef, newExpr: ExpressionRef): ExpressionRef; + /** Makes a skippedRelease call, ignoring the new expression's value and releasing the old expression's value, in this order. */ + makeSkippedRelease(oldExpr: ExpressionRef, newExpr: ExpressionRef): ExpressionRef; + /** Makes a release call, releasing the expression's value. Changes the current type to void.*/ + makeRelease(expr: ExpressionRef): ExpressionRef; + /** Makes an automatic release call at the end of the current flow. */ + makeAutorelease(expr: ExpressionRef, flow?: Flow): ExpressionRef; + /** Attempts to undo a final autorelease, returning the index of the previously retaining variable or -1 if not possible. */ + undoAutorelease(expr: ExpressionRef, flow: Flow): i32; + /** + * Attemps to move a final autorelease from one flow to a parent. + * It is crucial that from flow hasn't processed autoreleases yet because otherwise the final + * retain would have been written already. + */ + moveAutorelease(expr: ExpressionRef, fromInnerFlow: Flow, toOuterFlow: Flow): ExpressionRef; + /** Performs any queued autoreleases in the specified flow. */ + performAutoreleases(flow: Flow, stmts: ExpressionRef[], clearFlags?: bool): void; + /** Performs any queued autoreleases in the specified flow and returns the value. */ + performAutoreleasesWithValue(flow: Flow, valueExpr: ExpressionRef, valueType: Type, stmts?: ExpressionRef[] | null, clearFlags?: bool): ExpressionRef; + /** Finishes any queued top-level autoreleases in the actual function of the specified flow. */ + finishAutoreleases(flow: Flow, stmts: ExpressionRef[]): void; + /** Creates a direct call to the specified function. */ + makeCallDirect(instance: Function, operands: ExpressionRef[] | null, reportNode: Node, immediatelyDropped?: bool, + /** Skip the usual autorelease and manage this at the callsite instead. */ + skipAutorelease?: bool): ExpressionRef; + /** Compiles an indirect call using an index argument and a signature. */ + compileCallIndirect(signature: Signature, indexArg: ExpressionRef, argumentExpressions: Expression[], reportNode: Node, thisArg?: ExpressionRef, immediatelyDropped?: bool): ExpressionRef; + /** Creates an indirect call to the function at `indexArg` in the function table. */ + makeCallIndirect(signature: Signature, indexArg: ExpressionRef, operands?: ExpressionRef[] | null, immediatelyDropped?: bool): ExpressionRef; + compileCommaExpression(expression: CommaExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileElementAccessExpression(expression: ElementAccessExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileFunctionExpression(expression: FunctionExpression, contextualSignature: Signature | null, contextualFlags: ContextualFlags): ExpressionRef; + /** Makes sure the enclosing source file of the specified expression has been compiled. */ + private maybeCompileEnclosingSource; + /** + * Compiles an identifier in the specified context. + * @param retainConstantType Retains the type of inlined constants if `true`, otherwise + * precomputes them according to context. + */ + compileIdentifierExpression(expression: IdentifierExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileInstanceOfExpression(expression: InstanceOfExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileLiteralExpression(expression: LiteralExpression, contextualType: Type, contextualFlags: ContextualFlags, implicitlyNegate?: bool): ExpressionRef; + compileStringLiteral(expression: StringLiteralExpression): ExpressionRef; + compileArrayLiteral(elementType: Type, expressions: (Expression | null)[], isConst: bool, contextualFlags: ContextualFlags, reportNode: Node): ExpressionRef; + compileObjectLiteral(expression: ObjectLiteralExpression, contextualType: Type): ExpressionRef; + compileNewExpression(expression: NewExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + /** Gets the compiled constructor of the specified class or generates one if none is present. */ + ensureConstructor(classInstance: Class, reportNode: Node): Function; + compileInstantiate( + /** Class to instantiate. */ + classInstance: Class, + /** Constructor arguments. */ + argumentExpressions: Expression[], + /** Contextual flags. */ + contextualFlags: ContextualFlags, + /** Node to report on. */ + reportNode: Node): ExpressionRef; + /** + * Compiles a property access in the specified context. + * @param retainConstantType Retains the type of inlined constants if `true`, otherwise + * precomputes them according to context. + */ + compilePropertyAccessExpression(propertyAccess: PropertyAccessExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileTernaryExpression(expression: TernaryExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileUnaryPostfixExpression(expression: UnaryPostfixExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + compileUnaryPrefixExpression(expression: UnaryPrefixExpression, contextualType: Type, contextualFlags: ContextualFlags): ExpressionRef; + /** Makes sure that a 32-bit integer value is wrapped to a valid value of the specified type. */ + ensureSmallIntegerWrap(expr: ExpressionRef, type: Type): ExpressionRef; + /** Adds the debug location of the specified expression at the specified range to the source map. */ + addDebugLocation(expr: ExpressionRef, range: Range): void; + /** Creates a comparison whether an expression is 'false' in a broader sense. */ + makeIsFalseish(expr: ExpressionRef, type: Type): ExpressionRef; + /** Creates a comparison whether an expression is 'true' in a broader sense. */ + makeIsTrueish(expr: ExpressionRef, type: Type): ExpressionRef; + /** Makes an allocation suitable to hold the data of an instance of the given class. */ + makeAllocation(classInstance: Class): ExpressionRef; + /** Makes the initializers for a class's fields. */ + makeFieldInitialization(classInstance: Class, stmts?: ExpressionRef[]): ExpressionRef[]; + makeInstanceOfClass(expr: ExpressionRef, classInstance: Class): ExpressionRef; + } + /** Flattens a series of expressions to a nop, a single statement or a block depending on statement count. */ + export function flatten(module: Module, stmts: ExpressionRef[], type: NativeType): ExpressionRef; + +} +declare module 'assemblyscript/src/builtins' { + /** + * Built-in elements providing WebAssembly core functionality. + * @module builtins + */ /***/ + import { Compiler } from 'assemblyscript/src/compiler'; + import { Node, Expression, CallExpression } from 'assemblyscript/src/ast'; + import { Type } from 'assemblyscript/src/types'; + import { ExpressionRef } from 'assemblyscript/src/module'; + import { FunctionPrototype } from 'assemblyscript/src/program'; + /** Symbols of various compiler built-ins. */ + export namespace BuiltinSymbols { + const isInteger = "~lib/builtins/isInteger"; + const isFloat = "~lib/builtins/isFloat"; + const isBoolean = "~lib/builtins/isBoolean"; + const isSigned = "~lib/builtins/isSigned"; + const isReference = "~lib/builtins/isReference"; + const isString = "~lib/builtins/isString"; + const isArray = "~lib/builtins/isArray"; + const isArrayLike = "~lib/builtins/isArrayLike"; + const isFunction = "~lib/builtins/isFunction"; + const isNullable = "~lib/builtins/isNullable"; + const isDefined = "~lib/builtins/isDefined"; + const isConstant = "~lib/builtins/isConstant"; + const isManaged = "~lib/builtins/isManaged"; + const clz = "~lib/builtins/clz"; + const ctz = "~lib/builtins/ctz"; + const popcnt = "~lib/builtins/popcnt"; + const rotl = "~lib/builtins/rotl"; + const rotr = "~lib/builtins/rotr"; + const abs = "~lib/builtins/abs"; + const max = "~lib/builtins/max"; + const min = "~lib/builtins/min"; + const ceil = "~lib/builtins/ceil"; + const floor = "~lib/builtins/floor"; + const copysign = "~lib/builtins/copysign"; + const nearest = "~lib/builtins/nearest"; + const reinterpret = "~lib/builtins/reinterpret"; + const sqrt = "~lib/builtins/sqrt"; + const trunc = "~lib/builtins/trunc"; + const load = "~lib/builtins/load"; + const store = "~lib/builtins/store"; + const atomic_load = "~lib/builtins/atomic.load"; + const atomic_store = "~lib/builtins/atomic.store"; + const atomic_add = "~lib/builtins/atomic.add"; + const atomic_sub = "~lib/builtins/atomic.sub"; + const atomic_and = "~lib/builtins/atomic.and"; + const atomic_or = "~lib/builtins/atomic.or"; + const atomic_xor = "~lib/builtins/atomic.xor"; + const atomic_xchg = "~lib/builtins/atomic.xchg"; + const atomic_cmpxchg = "~lib/builtins/atomic.cmpxchg"; + const atomic_wait = "~lib/builtins/atomic.wait"; + const atomic_notify = "~lib/builtins/atomic.notify"; + const sizeof = "~lib/builtins/sizeof"; + const alignof = "~lib/builtins/alignof"; + const offsetof = "~lib/builtins/offsetof"; + const select = "~lib/builtins/select"; + const unreachable = "~lib/builtins/unreachable"; + const changetype = "~lib/builtins/changetype"; + const assert = "~lib/builtins/assert"; + const unchecked = "~lib/builtins/unchecked"; + const call_direct = "~lib/builtins/call_direct"; + const call_indirect = "~lib/builtins/call_indirect"; + const instantiate = "~lib/builtins/instantiate"; + const idof = "~lib/builtins/idof"; + const i8 = "~lib/builtins/i8"; + const i16 = "~lib/builtins/i16"; + const i32 = "~lib/builtins/i32"; + const i64 = "~lib/builtins/i64"; + const isize = "~lib/builtins/isize"; + const u8 = "~lib/builtins/u8"; + const u16 = "~lib/builtins/u16"; + const u32 = "~lib/builtins/u32"; + const u64 = "~lib/builtins/u64"; + const usize = "~lib/builtins/usize"; + const bool = "~lib/builtins/bool"; + const f32 = "~lib/builtins/f32"; + const f64 = "~lib/builtins/f64"; + const v128 = "~lib/builtins/v128"; + const void_ = "~lib/builtins/void"; + const i32_clz = "~lib/builtins/i32.clz"; + const i64_clz = "~lib/builtins/i64.clz"; + const i32_ctz = "~lib/builtins/i32.ctz"; + const i64_ctz = "~lib/builtins/i64.ctz"; + const i32_popcnt = "~lib/builtins/i32.popcnt"; + const i64_popcnt = "~lib/builtins/i64.popcnt"; + const i32_rotl = "~lib/builtins/i32.rotl"; + const i64_rotl = "~lib/builtins/i64.rotl"; + const i32_rotr = "~lib/builtins/i32.rotr"; + const i64_rotr = "~lib/builtins/i64.rotr"; + const f32_abs = "~lib/builtins/f32.abs"; + const f64_abs = "~lib/builtins/f64.abs"; + const f32_max = "~lib/builtins/f32.max"; + const f64_max = "~lib/builtins/f64.max"; + const f32_min = "~lib/builtins/f32.min"; + const f64_min = "~lib/builtins/f64.min"; + const f32_ceil = "~lib/builtins/f32.ceil"; + const f64_ceil = "~lib/builtins/f64.ceil"; + const f32_floor = "~lib/builtins/f32.floor"; + const f64_floor = "~lib/builtins/f64.floor"; + const f32_copysign = "~lib/builtins/f32.copysign"; + const f64_copysign = "~lib/builtins/f64.copysign"; + const f32_nearest = "~lib/builtins/f32.nearest"; + const f64_nearest = "~lib/builtins/f64.nearest"; + const i32_reinterpret_f32 = "~lib/builtins/i32.reinterpret_f32"; + const i64_reinterpret_f64 = "~lib/builtins/i64.reinterpret_f64"; + const f32_reinterpret_i32 = "~lib/builtins/f32.reinterpret_i32"; + const f64_reinterpret_i64 = "~lib/builtins/f64.reinterpret_i64"; + const f32_sqrt = "~lib/builtins/f32.sqrt"; + const f64_sqrt = "~lib/builtins/f64.sqrt"; + const f32_trunc = "~lib/builtins/f32.trunc"; + const f64_trunc = "~lib/builtins/f64.trunc"; + const i32_load8_s = "~lib/builtins/i32.load8_s"; + const i32_load8_u = "~lib/builtins/i32.load8_u"; + const i32_load16_s = "~lib/builtins/i32.load16_s"; + const i32_load16_u = "~lib/builtins/i32.load16_u"; + const i32_load = "~lib/builtins/i32.load"; + const i64_load8_s = "~lib/builtins/i64.load8_s"; + const i64_load8_u = "~lib/builtins/i64.load8_u"; + const i64_load16_s = "~lib/builtins/i64.load16_s"; + const i64_load16_u = "~lib/builtins/i64.load16_u"; + const i64_load32_s = "~lib/builtins/i64.load32_s"; + const i64_load32_u = "~lib/builtins/i64.load32_u"; + const i64_load = "~lib/builtins/i64.load"; + const f32_load = "~lib/builtins/f32.load"; + const f64_load = "~lib/builtins/f64.load"; + const i32_store8 = "~lib/builtins/i32.store8"; + const i32_store16 = "~lib/builtins/i32.store16"; + const i32_store = "~lib/builtins/i32.store"; + const i64_store8 = "~lib/builtins/i64.store8"; + const i64_store16 = "~lib/builtins/i64.store16"; + const i64_store32 = "~lib/builtins/i64.store32"; + const i64_store = "~lib/builtins/i64.store"; + const f32_store = "~lib/builtins/f32.store"; + const f64_store = "~lib/builtins/f64.store"; + const i32_atomic_load8_u = "~lib/builtins/i32.atomic.load8_u"; + const i32_atomic_load16_u = "~lib/builtins/i32.atomic.load16_u"; + const i32_atomic_load = "~lib/builtins/i32.atomic.load"; + const i64_atomic_load8_u = "~lib/builtins/i64.atomic.load8_u"; + const i64_atomic_load16_u = "~lib/builtins/i64.atomic.load16_u"; + const i64_atomic_load32_u = "~lib/builtins/i64.atomic.load32_u"; + const i64_atomic_load = "~lib/builtins/i64.atomic.load"; + const i32_atomic_store8 = "~lib/builtins/i32.atomic.store8"; + const i32_atomic_store16 = "~lib/builtins/i32.atomic.store16"; + const i32_atomic_store = "~lib/builtins/i32.atomic.store"; + const i64_atomic_store8 = "~lib/builtins/i64.atomic.store8"; + const i64_atomic_store16 = "~lib/builtins/i64.atomic.store16"; + const i64_atomic_store32 = "~lib/builtins/i64.atomic.store32"; + const i64_atomic_store = "~lib/builtins/i64.atomic.store"; + const i32_atomic_rmw8_add_u = "~lib/builtins/i32.atomic.rmw8.add_u"; + const i32_atomic_rmw16_add_u = "~lib/builtins/i32.atomic.rmw16.add_u"; + const i32_atomic_rmw_add = "~lib/builtins/i32.atomic.rmw.add"; + const i64_atomic_rmw8_add_u = "~lib/builtins/i64.atomic.rmw8.add_u"; + const i64_atomic_rmw16_add_u = "~lib/builtins/i64.atomic.rmw16.add_u"; + const i64_atomic_rmw32_add_u = "~lib/builtins/i64.atomic.rmw32.add_u"; + const i64_atomic_rmw_add = "~lib/builtins/i64.atomic.rmw.add"; + const i32_atomic_rmw8_sub_u = "~lib/builtins/i32.atomic.rmw8.sub_u"; + const i32_atomic_rmw16_sub_u = "~lib/builtins/i32.atomic.rmw16.sub_u"; + const i32_atomic_rmw_sub = "~lib/builtins/i32.atomic.rmw.sub"; + const i64_atomic_rmw8_sub_u = "~lib/builtins/i64.atomic.rmw8.sub_u"; + const i64_atomic_rmw16_sub_u = "~lib/builtins/i64.atomic.rmw16.sub_u"; + const i64_atomic_rmw32_sub_u = "~lib/builtins/i64.atomic.rmw32.sub_u"; + const i64_atomic_rmw_sub = "~lib/builtins/i64.atomic.rmw.sub"; + const i32_atomic_rmw8_and_u = "~lib/builtins/i32.atomic.rmw8.and_u"; + const i32_atomic_rmw16_and_u = "~lib/builtins/i32.atomic.rmw16.and_u"; + const i32_atomic_rmw_and = "~lib/builtins/i32.atomic.rmw.and"; + const i64_atomic_rmw8_and_u = "~lib/builtins/i64.atomic.rmw8.and_u"; + const i64_atomic_rmw16_and_u = "~lib/builtins/i64.atomic.rmw16.and_u"; + const i64_atomic_rmw32_and_u = "~lib/builtins/i64.atomic.rmw32.and_u"; + const i64_atomic_rmw_and = "~lib/builtins/i64.atomic.rmw.and"; + const i32_atomic_rmw8_or_u = "~lib/builtins/i32.atomic.rmw8.or_u"; + const i32_atomic_rmw16_or_u = "~lib/builtins/i32.atomic.rmw16.or_u"; + const i32_atomic_rmw_or = "~lib/builtins/i32.atomic.rmw.or"; + const i64_atomic_rmw8_or_u = "~lib/builtins/i64.atomic.rmw8.or_u"; + const i64_atomic_rmw16_or_u = "~lib/builtins/i64.atomic.rmw16.or_u"; + const i64_atomic_rmw32_or_u = "~lib/builtins/i64.atomic.rmw32.or_u"; + const i64_atomic_rmw_or = "~lib/builtins/i64.atomic.rmw.or"; + const i32_atomic_rmw8_u_xor = "~lib/builtins/i32.atomic.rmw8.xor_u"; + const i32_atomic_rmw16_u_xor = "~lib/builtins/i32.atomic.rmw16.xor_u"; + const i32_atomic_rmw_xor = "~lib/builtins/i32.atomic.rmw.xor"; + const i64_atomic_rmw8_xor_u = "~lib/builtins/i64.atomic.rmw8.xor_u"; + const i64_atomic_rmw16_xor_u = "~lib/builtins/i64.atomic.rmw16.xor_u"; + const i64_atomic_rmw32_xor_u = "~lib/builtins/i64.atomic.rmw32.xor_u"; + const i64_atomic_rmw_xor = "~lib/builtins/i64.atomic.rmw.xor"; + const i32_atomic_rmw8_xchg_u = "~lib/builtins/i32.atomic.rmw8.xchg_u"; + const i32_atomic_rmw16_xchg_u = "~lib/builtins/i32.atomic.rmw16.xchg_u"; + const i32_atomic_rmw_xchg = "~lib/builtins/i32.atomic.rmw.xchg"; + const i64_atomic_rmw8_xchg_u = "~lib/builtins/i64.atomic.rmw8.xchg_u"; + const i64_atomic_rmw16_xchg_u = "~lib/builtins/i64.atomic.rmw16.xchg_u"; + const i64_atomic_rmw32_xchg_u = "~lib/builtins/i64.atomic.rmw32.xchg_u"; + const i64_atomic_rmw_xchg = "~lib/builtins/i64.atomic.rmw.xchg"; + const i32_atomic_rmw8_cmpxchg_u = "~lib/builtins/i32.atomic.rmw8.cmpxchg_u"; + const i32_atomic_rmw16_cmpxchg_u = "~lib/builtins/i32.atomic.rmw16.cmpxchg_u"; + const i32_atomic_rmw_cmpxchg = "~lib/builtins/i32.atomic.rmw.cmpxchg"; + const i64_atomic_rmw8_cmpxchg_u = "~lib/builtins/i64.atomic.rmw8.cmpxchg_u"; + const i64_atomic_rmw16_cmpxchg_u = "~lib/builtins/i64.atomic.rmw16.cmpxchg_u"; + const i64_atomic_rmw32_cmpxchg_u = "~lib/builtins/i64.atomic.rmw32.cmpxchg_u"; + const i64_atomic_rmw_cmpxchg = "~lib/builtins/i64.atomic.rmw.cmpxchg"; + const i32_wait = "~lib/builtins/i32.wait"; + const i64_wait = "~lib/builtins/i64.wait"; + const v128_splat = "~lib/builtins/v128.splat"; + const v128_extract_lane = "~lib/builtins/v128.extract_lane"; + const v128_replace_lane = "~lib/builtins/v128.replace_lane"; + const v128_shuffle = "~lib/builtins/v128.shuffle"; + const v128_load = "~lib/builtins/v128.load"; + const v128_store = "~lib/builtins/v128.store"; + const v128_add = "~lib/builtins/v128.add"; + const v128_sub = "~lib/builtins/v128.sub"; + const v128_mul = "~lib/builtins/v128.mul"; + const v128_div = "~lib/builtins/v128.div"; + const v128_neg = "~lib/builtins/v128.neg"; + const v128_add_saturate = "~lib/builtins/v128.add_saturate"; + const v128_sub_saturate = "~lib/builtins/v128.sub_saturate"; + const v128_shl = "~lib/builtins/v128.shl"; + const v128_shr = "~lib/builtins/v128.shr"; + const v128_and = "~lib/builtins/v128.and"; + const v128_or = "~lib/builtins/v128.or"; + const v128_xor = "~lib/builtins/v128.xor"; + const v128_not = "~lib/builtins/v128.not"; + const v128_bitselect = "~lib/builtins/v128.bitselect"; + const v128_any_true = "~lib/builtins/v128.any_true"; + const v128_all_true = "~lib/builtins/v128.all_true"; + const v128_min = "~lib/builtins/v128.min"; + const v128_max = "~lib/builtins/v128.max"; + const v128_abs = "~lib/builtins/v128.abs"; + const v128_sqrt = "~lib/builtins/v128.sqrt"; + const v128_eq = "~lib/builtins/v128.eq"; + const v128_ne = "~lib/builtins/v128.ne"; + const v128_lt = "~lib/builtins/v128.lt"; + const v128_le = "~lib/builtins/v128.le"; + const v128_gt = "~lib/builtins/v128.gt"; + const v128_ge = "~lib/builtins/v128.ge"; + const v128_convert = "~lib/builtins/v128.convert"; + const v128_trunc = "~lib/builtins/v128.trunc"; + const i8x16 = "~lib/builtins/i8x16"; + const i16x8 = "~lib/builtins/i16x8"; + const i32x4 = "~lib/builtins/i32x4"; + const i64x2 = "~lib/builtins/i64x2"; + const f32x4 = "~lib/builtins/f32x4"; + const f64x2 = "~lib/builtins/f64x2"; + const i8x16_splat = "~lib/builtins/i8x16.splat"; + const i8x16_extract_lane_s = "~lib/builtins/i8x16.extract_lane_s"; + const i8x16_extract_lane_u = "~lib/builtins/i8x16.extract_lane_u"; + const i8x16_replace_lane = "~lib/builtins/i8x16.replace_lane"; + const i8x16_add = "~lib/builtins/i8x16.add"; + const i8x16_sub = "~lib/builtins/i8x16.sub"; + const i8x16_mul = "~lib/builtins/i8x16.mul"; + const i8x16_neg = "~lib/builtins/i8x16.neg"; + const i8x16_add_saturate_s = "~lib/builtins/i8x16.add_saturate_s"; + const i8x16_add_saturate_u = "~lib/builtins/i8x16.add_saturate_u"; + const i8x16_sub_saturate_s = "~lib/builtins/i8x16.sub_saturate_s"; + const i8x16_sub_saturate_u = "~lib/builtins/i8x16.sub_saturate_u"; + const i8x16_shl = "~lib/builtins/i8x16.shl"; + const i8x16_shr_s = "~lib/builtins/i8x16.shr_s"; + const i8x16_shr_u = "~lib/builtins/i8x16.shr_u"; + const i8x16_any_true = "~lib/builtins/i8x16.any_true"; + const i8x16_all_true = "~lib/builtins/i8x16.all_true"; + const i8x16_eq = "~lib/builtins/i8x16.eq"; + const i8x16_ne = "~lib/builtins/i8x16.ne"; + const i8x16_lt_s = "~lib/builtins/i8x16.lt_s"; + const i8x16_lt_u = "~lib/builtins/i8x16.lt_u"; + const i8x16_le_s = "~lib/builtins/i8x16.le_s"; + const i8x16_le_u = "~lib/builtins/i8x16.le_u"; + const i8x16_gt_s = "~lib/builtins/i8x16.gt_s"; + const i8x16_gt_u = "~lib/builtins/i8x16.gt_u"; + const i8x16_ge_s = "~lib/builtins/i8x16.ge_s"; + const i8x16_ge_u = "~lib/builtins/i8x16.ge_u"; + const i16x8_splat = "~lib/builtins/i16x8.splat"; + const i16x8_extract_lane_s = "~lib/builtins/i16x8.extract_lane_s"; + const i16x8_extract_lane_u = "~lib/builtins/i16x8.extract_lane_u"; + const i16x8_replace_lane = "~lib/builtins/i16x8.replace_lane"; + const i16x8_add = "~lib/builtins/i16x8.add"; + const i16x8_sub = "~lib/builtins/i16x8.sub"; + const i16x8_mul = "~lib/builtins/i16x8.mul"; + const i16x8_neg = "~lib/builtins/i16x8.neg"; + const i16x8_add_saturate_s = "~lib/builtins/i16x8.add_saturate_s"; + const i16x8_add_saturate_u = "~lib/builtins/i16x8.add_saturate_u"; + const i16x8_sub_saturate_s = "~lib/builtins/i16x8.sub_saturate_s"; + const i16x8_sub_saturate_u = "~lib/builtins/i16x8.sub_saturate_u"; + const i16x8_shl = "~lib/builtins/i16x8.shl"; + const i16x8_shr_s = "~lib/builtins/i16x8.shr_s"; + const i16x8_shr_u = "~lib/builtins/i16x8.shr_u"; + const i16x8_any_true = "~lib/builtins/i16x8.any_true"; + const i16x8_all_true = "~lib/builtins/i16x8.all_true"; + const i16x8_eq = "~lib/builtins/i16x8.eq"; + const i16x8_ne = "~lib/builtins/i16x8.ne"; + const i16x8_lt_s = "~lib/builtins/i16x8.lt_s"; + const i16x8_lt_u = "~lib/builtins/i16x8.lt_u"; + const i16x8_le_s = "~lib/builtins/i16x8.le_s"; + const i16x8_le_u = "~lib/builtins/i16x8.le_u"; + const i16x8_gt_s = "~lib/builtins/i16x8.gt_s"; + const i16x8_gt_u = "~lib/builtins/i16x8.gt_u"; + const i16x8_ge_s = "~lib/builtins/i16x8.ge_s"; + const i16x8_ge_u = "~lib/builtins/i16x8.ge_u"; + const i32x4_splat = "~lib/builtins/i32x4.splat"; + const i32x4_extract_lane = "~lib/builtins/i32x4.extract_lane"; + const i32x4_replace_lane = "~lib/builtins/i32x4.replace_lane"; + const i32x4_add = "~lib/builtins/i32x4.add"; + const i32x4_sub = "~lib/builtins/i32x4.sub"; + const i32x4_mul = "~lib/builtins/i32x4.mul"; + const i32x4_neg = "~lib/builtins/i32x4.neg"; + const i32x4_shl = "~lib/builtins/i32x4.shl"; + const i32x4_shr_s = "~lib/builtins/i32x4.shr_s"; + const i32x4_shr_u = "~lib/builtins/i32x4.shr_u"; + const i32x4_any_true = "~lib/builtins/i32x4.any_true"; + const i32x4_all_true = "~lib/builtins/i32x4.all_true"; + const i32x4_eq = "~lib/builtins/i32x4.eq"; + const i32x4_ne = "~lib/builtins/i32x4.ne"; + const i32x4_lt_s = "~lib/builtins/i32x4.lt_s"; + const i32x4_lt_u = "~lib/builtins/i32x4.lt_u"; + const i32x4_le_s = "~lib/builtins/i32x4.le_s"; + const i32x4_le_u = "~lib/builtins/i32x4.le_u"; + const i32x4_gt_s = "~lib/builtins/i32x4.gt_s"; + const i32x4_gt_u = "~lib/builtins/i32x4.gt_u"; + const i32x4_ge_s = "~lib/builtins/i32x4.ge_s"; + const i32x4_ge_u = "~lib/builtins/i32x4.ge_u"; + const i32x4_trunc_s_f32x4_sat = "~lib/builtins/i32x4.trunc_s_f32x4_sat"; + const i32x4_trunc_u_f32x4_sat = "~lib/builtins/i32x4.trunc_u_f32x4_sat"; + const i64x2_splat = "~lib/builtins/i64x2.splat"; + const i64x2_extract_lane = "~lib/builtins/i64x2.extract_lane"; + const i64x2_replace_lane = "~lib/builtins/i64x2.replace_lane"; + const i64x2_add = "~lib/builtins/i64x2.add"; + const i64x2_sub = "~lib/builtins/i64x2.sub"; + const i64x2_neg = "~lib/builtins/i64x2.neg"; + const i64x2_shl = "~lib/builtins/i64x2.shl"; + const i64x2_shr_s = "~lib/builtins/i64x2.shr_s"; + const i64x2_shr_u = "~lib/builtins/i64x2.shr_u"; + const i64x2_any_true = "~lib/builtins/i64x2.any_true"; + const i64x2_all_true = "~lib/builtins/i64x2.all_true"; + const i64x2_trunc_s_f64x2_sat = "~lib/builtins/i64x2.trunc_s_f64x2_sat"; + const i64x2_trunc_u_f64x2_sat = "~lib/builtins/i64x2.trunc_u_f64x2_sat"; + const f32x4_splat = "~lib/builtins/f32x4.splat"; + const f32x4_extract_lane = "~lib/builtins/f32x4.extract_lane"; + const f32x4_replace_lane = "~lib/builtins/f32x4.replace_lane"; + const f32x4_add = "~lib/builtins/f32x4.add"; + const f32x4_sub = "~lib/builtins/f32x4.sub"; + const f32x4_mul = "~lib/builtins/f32x4.mul"; + const f32x4_div = "~lib/builtins/f32x4.div"; + const f32x4_neg = "~lib/builtins/f32x4.neg"; + const f32x4_min = "~lib/builtins/f32x4.min"; + const f32x4_max = "~lib/builtins/f32x4.max"; + const f32x4_abs = "~lib/builtins/f32x4.abs"; + const f32x4_sqrt = "~lib/builtins/f32x4.sqrt"; + const f32x4_eq = "~lib/builtins/f32x4.eq"; + const f32x4_ne = "~lib/builtins/f32x4.ne"; + const f32x4_lt = "~lib/builtins/f32x4.lt"; + const f32x4_le = "~lib/builtins/f32x4.le"; + const f32x4_gt = "~lib/builtins/f32x4.gt"; + const f32x4_ge = "~lib/builtins/f32x4.ge"; + const f32x4_convert_s_i32x4 = "~lib/builtins/f32x4.convert_s_i32x4"; + const f32x4_convert_u_i32x4 = "~lib/builtins/f32x4.convert_u_i32x4"; + const f64x2_splat = "~lib/builtins/f64x2.splat"; + const f64x2_extract_lane = "~lib/builtins/f64x2.extract_lane"; + const f64x2_replace_lane = "~lib/builtins/f64x2.replace_lane"; + const f64x2_add = "~lib/builtins/f64x2.add"; + const f64x2_sub = "~lib/builtins/f64x2.sub"; + const f64x2_mul = "~lib/builtins/f64x2.mul"; + const f64x2_div = "~lib/builtins/f64x2.div"; + const f64x2_neg = "~lib/builtins/f64x2.neg"; + const f64x2_min = "~lib/builtins/f64x2.min"; + const f64x2_max = "~lib/builtins/f64x2.max"; + const f64x2_abs = "~lib/builtins/f64x2.abs"; + const f64x2_sqrt = "~lib/builtins/f64x2.sqrt"; + const f64x2_eq = "~lib/builtins/f64x2.eq"; + const f64x2_ne = "~lib/builtins/f64x2.ne"; + const f64x2_lt = "~lib/builtins/f64x2.lt"; + const f64x2_le = "~lib/builtins/f64x2.le"; + const f64x2_gt = "~lib/builtins/f64x2.gt"; + const f64x2_ge = "~lib/builtins/f64x2.ge"; + const f64x2_convert_s_i64x2 = "~lib/builtins/f64x2.convert_s_i64x2"; + const f64x2_convert_u_i64x2 = "~lib/builtins/f64x2.convert_u_i64x2"; + const v8x16_shuffle = "~lib/builtins/v8x16.shuffle"; + const HEAP_BASE = "~lib/heap/HEAP_BASE"; + const RTTI_BASE = "~lib/rt/RTTI_BASE"; + const visit_globals = "~lib/rt/__visit_globals"; + const visit_members = "~lib/rt/__visit_members"; + const ERROR = "~lib/diagnostics/ERROR"; + const WARNING = "~lib/diagnostics/WARNING"; + const INFO = "~lib/diagnostics/INFO"; + const memory_size = "~lib/memory/memory.size"; + const memory_grow = "~lib/memory/memory.grow"; + const memory_copy = "~lib/memory/memory.copy"; + const memory_fill = "~lib/memory/memory.fill"; + const memory_allocate = "~lib/memory/memory.allocate"; + const memory_free = "~lib/memory/memory.free"; + const memory_reset = "~lib/memory/memory.reset"; + const runtime_instanceof = "~lib/runtime/runtime.instanceof"; + const runtime_flags = "~lib/runtime/runtime.flags"; + const runtime_allocate = "~lib/util/runtime/allocate"; + const runtime_reallocate = "~lib/util/runtime/reallocate"; + const runtime_register = "~lib/util/runtime/register"; + const runtime_discard = "~lib/util/runtime/discard"; + const runtime_makeArray = "~lib/util/runtime/makeArray"; + const Int8Array = "~lib/typedarray/Int8Array"; + const Uint8Array = "~lib/typedarray/Uint8Array"; + const Int16Array = "~lib/typedarray/Int16Array"; + const Uint16Array = "~lib/typedarray/Uint16Array"; + const Int32Array = "~lib/typedarray/Int32Array"; + const Uint32Array = "~lib/typedarray/Uint32Array"; + const Int64Array = "~lib/typedarray/Int64Array"; + const Uint64Array = "~lib/typedarray/Uint64Array"; + const Uint8ClampedArray = "~lib/typedarray/Uint8ClampedArray"; + const Float32Array = "~lib/typedarray/Float32Array"; + const Float64Array = "~lib/typedarray/Float64Array"; + const started = "~lib/started"; + const argc = "~lib/argc"; + const setargc = "~lib/setargc"; + const capabilities = "~lib/capabilities"; + } + /** Compiles a call to a built-in function. */ + export function compileCall(compiler: Compiler, + /** Respective function prototype. */ + prototype: FunctionPrototype, + /** Pre-resolved type arguments. */ + typeArguments: Type[] | null, + /** Operand expressions. */ + operands: Expression[], + /** Contextual type. */ + contextualType: Type, + /** Respective call expression. */ + reportNode: CallExpression, + /** Indicates that contextual type is ASM type. */ + isAsm?: bool): ExpressionRef; + /** Compiles an abort wired to the conditionally imported 'abort' function. */ + export function compileAbort(compiler: Compiler, message: Expression | null, reportNode: Node): ExpressionRef; + /** Compiles the `visit_globals` function. */ + export function compileVisitGlobals(compiler: Compiler): void; + /** Compiles the `visit_members` function. */ + export function compileVisitMembers(compiler: Compiler): void; + /** Compiles runtime type information for use by stdlib. */ + export function compileRTTI(compiler: Compiler): void; + +} +declare module 'assemblyscript/src/decompiler' { + /** + * A decompiler that generates low-level AssemblyScript from WebAssembly binaries. + * @module decompiler + */ /***/ + import { Module, FunctionRef, ExpressionRef } from 'assemblyscript/src/module'; + export class Decompiler { + static decompile(module: Module): string; + text: string[]; + functionId: i32; + constructor(); + /** Decompiles a module to an AST that can then be serialized. */ + decompile(module: Module): void; + decompileFunction(func: FunctionRef): void; + decompileExpression(expr: ExpressionRef): void; + private push; + finish(): string; + } + +} +declare module 'assemblyscript/src/definitions' { + /** + * Definition builders for WebIDL and TypeScript. + * @module definitions + */ /***/ + import { Program, Element, Global, Enum, Field, Function, Class, Namespace, Interface } from 'assemblyscript/src/program'; + import { Type } from 'assemblyscript/src/types'; abstract class ExportsWalker { + /** Program reference. */ + program: Program; + /** Whether to include private members */ + includePrivate: bool; + /** Elements still to do. */ + todo: Element[]; + /** Already seen elements. */ + seen: Set; + /** Constructs a new Element walker. */ + constructor(program: Program, includePrivate?: bool); + /** Walks all elements and calls the respective handlers. */ + walk(): void; + /** Visits an element.*/ + visitElement(element: Element): void; + private visitFunctionInstances; + private visitClassInstances; + private visitPropertyInstances; + abstract visitGlobal(element: Global): void; + abstract visitEnum(element: Enum): void; + abstract visitFunction(element: Function): void; + abstract visitClass(element: Class): void; + abstract visitInterface(element: Interface): void; + abstract visitField(element: Field): void; + abstract visitNamespace(element: Element): void; + } + /** A WebIDL definitions builder. */ + export class IDLBuilder extends ExportsWalker { + /** Builds WebIDL definitions for the specified program. */ + static build(program: Program): string; + private sb; + private indentLevel; + /** Constructs a new WebIDL builder. */ + constructor(program: Program, includePrivate?: bool); + visitGlobal(element: Global): void; + visitEnum(element: Enum): void; + visitFunction(element: Function): void; + visitClass(element: Class): void; + visitInterface(element: Interface): void; + visitField(element: Field): void; + visitNamespace(element: Namespace): void; + typeToString(type: Type): string; + build(): string; + } + /** A TypeScript definitions builder. */ + export class TSDBuilder extends ExportsWalker { + /** Builds TypeScript definitions for the specified program. */ + static build(program: Program): string; + private sb; + private indentLevel; + /** Constructs a new WebIDL builder. */ + constructor(program: Program, includePrivate?: bool); + visitGlobal(element: Global): void; + visitEnum(element: Enum): void; + visitFunction(element: Function): void; + visitClass(element: Class): void; + visitInterface(element: Interface): void; + visitField(element: Field): void; + visitNamespace(element: Element): void; + typeToString(type: Type): string; + build(): string; + } + export {}; + +} +declare module 'assemblyscript/src/parser' { + /** + * A TypeScript parser for the AssemblyScript subset. + * @module parser + */ /***/ + import { CommonFlags } from 'assemblyscript/src/common'; + import { Program } from 'assemblyscript/src/program'; + import { Tokenizer, CommentHandler } from 'assemblyscript/src/tokenizer'; + import { DiagnosticEmitter } from 'assemblyscript/src/diagnostics'; + import { CommonTypeNode, SignatureNode, Expression, ClassExpression, FunctionExpression, Statement, BlockStatement, BreakStatement, ClassDeclaration, ContinueStatement, DeclarationStatement, DecoratorNode, DoStatement, EnumDeclaration, EnumValueDeclaration, ExportImportStatement, ExportMember, ExportStatement, ExpressionStatement, ForStatement, FunctionDeclaration, IfStatement, ImportDeclaration, ImportStatement, IndexSignatureDeclaration, NamespaceDeclaration, ParameterNode, ReturnStatement, SwitchCase, SwitchStatement, ThrowStatement, TryStatement, TypeDeclaration, TypeParameterNode, VariableStatement, VariableDeclaration, VoidStatement, WhileStatement } from 'assemblyscript/src/ast'; + /** Parser interface. */ + export class Parser extends DiagnosticEmitter { + /** Program being created. */ + program: Program; + /** Source file names to be requested next. */ + backlog: string[]; + /** Source file names already seen, that is processed or backlogged. */ + seenlog: Set; + /** Source file names already completely processed. */ + donelog: Set; + /** Optional handler to intercept comments while tokenizing. */ + onComment: CommentHandler | null; + /** Constructs a new parser. */ + constructor(); + /** Parses a file and adds its definitions to the program. */ + parseFile(text: string, path: string, isEntry: bool): void; + /** Parses a top-level statement. */ + parseTopLevelStatement(tn: Tokenizer, namespace?: NamespaceDeclaration | null): Statement | null; + /** Obtains the next file to parse. */ + nextFile(): string | null; + /** Finishes parsing and returns the program. */ + finish(): Program; + /** Parses a type. */ + parseType(tn: Tokenizer, acceptParenthesized?: bool, suppressErrors?: bool): CommonTypeNode | null; + private tryParseSignatureIsSignature; + /** Parses a function signature, as used in type declarations. */ + tryParseSignature(tn: Tokenizer): SignatureNode | null; + parseDecorator(tn: Tokenizer): DecoratorNode | null; + parseVariable(tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, startPos: i32): VariableStatement | null; + parseVariableDeclaration(tn: Tokenizer, parentFlags: CommonFlags, parentDecorators: DecoratorNode[] | null): VariableDeclaration | null; + parseEnum(tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, startPos: i32): EnumDeclaration | null; + parseEnumValue(tn: Tokenizer, parentFlags: CommonFlags): EnumValueDeclaration | null; + parseReturn(tn: Tokenizer): ReturnStatement | null; + parseTypeParameters(tn: Tokenizer): TypeParameterNode[] | null; + parseTypeParameter(tn: Tokenizer): TypeParameterNode | null; + private parseParametersThis; + parseParameters(tn: Tokenizer, isConstructor?: bool): ParameterNode[] | null; + parseParameter(tn: Tokenizer, isConstructor?: bool): ParameterNode | null; + parseFunction(tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, startPos: i32): FunctionDeclaration | null; + parseFunctionExpression(tn: Tokenizer): FunctionExpression | null; + private parseFunctionExpressionCommon; + parseClassOrInterface(tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, startPos: i32): ClassDeclaration | null; + parseClassExpression(tn: Tokenizer): ClassExpression | null; + parseClassMember(tn: Tokenizer, parent: ClassDeclaration): DeclarationStatement | null; + parseIndexSignatureDeclaration(tn: Tokenizer, decorators: DecoratorNode[] | null): IndexSignatureDeclaration | null; + parseNamespace(tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, startPos: i32): NamespaceDeclaration | null; + parseExport(tn: Tokenizer, startPos: i32, isDeclare: bool): ExportStatement | null; + parseExportMember(tn: Tokenizer): ExportMember | null; + parseImport(tn: Tokenizer): ImportStatement | null; + parseImportDeclaration(tn: Tokenizer): ImportDeclaration | null; + parseExportImport(tn: Tokenizer, startPos: i32): ExportImportStatement | null; + parseStatement(tn: Tokenizer, topLevel?: bool): Statement | null; + parseBlockStatement(tn: Tokenizer, topLevel: bool): BlockStatement | null; + parseBreak(tn: Tokenizer): BreakStatement | null; + parseContinue(tn: Tokenizer): ContinueStatement | null; + parseDoStatement(tn: Tokenizer): DoStatement | null; + parseExpressionStatement(tn: Tokenizer): ExpressionStatement | null; + parseForStatement(tn: Tokenizer): ForStatement | null; + parseIfStatement(tn: Tokenizer): IfStatement | null; + parseSwitchStatement(tn: Tokenizer): SwitchStatement | null; + parseSwitchCase(tn: Tokenizer): SwitchCase | null; + parseThrowStatement(tn: Tokenizer): ThrowStatement | null; + parseTryStatement(tn: Tokenizer): TryStatement | null; + parseTypeDeclaration(tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, startPos: i32): TypeDeclaration | null; + parseVoidStatement(tn: Tokenizer): VoidStatement | null; + parseWhileStatement(tn: Tokenizer): WhileStatement | null; + parseExpressionStart(tn: Tokenizer): Expression | null; + tryParseTypeArgumentsBeforeArguments(tn: Tokenizer): CommonTypeNode[] | null; + parseArguments(tn: Tokenizer): Expression[] | null; + parseExpression(tn: Tokenizer, precedence?: Precedence): Expression | null; + private joinPropertyCall; + private maybeParseCallExpression; + /** Skips over a statement on errors in an attempt to reduce unnecessary diagnostic noise. */ + skipStatement(tn: Tokenizer): void; + /** Skips over a block on errors in an attempt to reduce unnecessary diagnostic noise. */ + skipBlock(tn: Tokenizer): void; + } + /** Operator precedence from least to largest. */ + export const enum Precedence { + NONE = 0, + COMMA = 1, + SPREAD = 2, + YIELD = 3, + ASSIGNMENT = 4, + CONDITIONAL = 5, + LOGICAL_OR = 6, + LOGICAL_AND = 7, + BITWISE_OR = 8, + BITWISE_XOR = 9, + BITWISE_AND = 10, + EQUALITY = 11, + RELATIONAL = 12, + SHIFT = 13, + ADDITIVE = 14, + MULTIPLICATIVE = 15, + EXPONENTIATED = 16, + UNARY_PREFIX = 17, + UNARY_POSTFIX = 18, + CALL = 19, + MEMBERACCESS = 20, + GROUPING = 21 + } + +} +declare module 'assemblyscript/src/index' { + /** + * Low-level C-like compiler API. + * @module index + */ /***/ + import { Target, Feature } from 'assemblyscript/src/common'; + import { Options } from 'assemblyscript/src/compiler'; + import { DiagnosticMessage, formatDiagnosticMessage } from 'assemblyscript/src/diagnostics'; + import { Module } from 'assemblyscript/src/module'; + import { Parser } from 'assemblyscript/src/parser'; + import { Program } from 'assemblyscript/src/program'; + /** Parses a source file. If `parser` has been omitted a new one is created. */ + export function parseFile(text: string, path: string, isEntry?: bool, parser?: Parser | null): Parser; + /** Obtains the next required file's path. Returns `null` once complete. */ + export function nextFile(parser: Parser): string | null; + /** Obtains the next diagnostic message. Returns `null` once complete. */ + export function nextDiagnostic(parser: Parser): DiagnosticMessage | null; + /** Formats a diagnostic message to a string. */ + export { formatDiagnosticMessage as formatDiagnostic }; + /** Tests whether a diagnostic is informatory. */ + export function isInfo(message: DiagnosticMessage): bool; + /** Tests whether a diagnostic is a warning. */ + export function isWarning(message: DiagnosticMessage): bool; + /** Tests whether a diagnostic is an error. */ + export function isError(message: DiagnosticMessage): bool; + /** Creates a new set of compiler options. */ + export function createOptions(): Options; + /** Sets the `target` option. */ + export function setTarget(options: Options, target: Target): void; + /** Sets the `noAssert` option. */ + export function setNoAssert(options: Options, noAssert: bool): void; + /** Sets the `importMemory` option. */ + export function setImportMemory(options: Options, importMemory: bool): void; + /** Sets the `sharedMemory` option. */ + export function setSharedMemory(options: Options, sharedMemory: i32): void; + /** Sets the `importTable` option. */ + export function setImportTable(options: Options, importTable: bool): void; + /** Sets the `sourceMap` option. */ + export function setSourceMap(options: Options, sourceMap: bool): void; + /** Sets the `memoryBase` option. */ + export function setMemoryBase(options: Options, memoryBase: u32): void; + /** Sets a 'globalAliases' value. */ + export function setGlobalAlias(options: Options, name: string, alias: string): void; + /** Sign extension operations. */ + export const FEATURE_SIGN_EXTENSION: Feature; + /** Mutable global imports and exports. */ + export const FEATURE_MUTABLE_GLOBAL: Feature; + /** Bulk memory operations. */ + export const FEATURE_BULK_MEMORY: Feature; + /** SIMD types and operations. */ + export const FEATURE_SIMD: Feature; + /** Threading and atomic operations. */ + export const FEATURE_THREADS: Feature; + /** Enables a specific feature. */ + export function enableFeature(options: Options, feature: Feature): void; + /** Gives the compiler a hint at the optimize levels that will be used later on. */ + export function setOptimizeLevelHints(options: Options, optimizeLevel: i32, shrinkLevel: i32): void; + /** Finishes parsing. */ + export function finishParsing(parser: Parser): Program; + /** Compiles the sources computed by the parser to a module. */ + export function compileProgram(program: Program, options?: Options | null): Module; + /** Decompiles a module to its (low level) source. */ + export function decompileModule(module: Module): string; + /** Builds WebIDL definitions for the specified program. */ + export function buildIDL(program: Program): string; + /** Builds TypeScript definitions for the specified program. */ + export function buildTSD(program: Program): string; + /** Prefix indicating a library file. */ + export { LIBRARY_PREFIX } from 'assemblyscript/src/common'; + export * from 'assemblyscript/src/ast'; + export * from 'assemblyscript/src/common'; + export * from 'assemblyscript/src/compiler'; + export * from 'assemblyscript/src/decompiler'; + export * from 'assemblyscript/src/definitions'; + export * from 'assemblyscript/src/diagnosticMessages.generated'; + export * from 'assemblyscript/src/diagnostics'; + export * from 'assemblyscript/src/flow'; + export * from 'assemblyscript/src/module'; + export * from 'assemblyscript/src/parser'; + export * from 'assemblyscript/src/program'; + export * from 'assemblyscript/src/resolver'; + export * from 'assemblyscript/src/tokenizer'; + export * from 'assemblyscript/src/types'; + export * from 'assemblyscript/src/util'; + +} +declare module 'assemblyscript/src/extra/ast' { + /** + * Abstract Syntax Tree extras. + * + * Not needed in a standalone compiler but useful for testing the parser. + * + * @module extra/ast + */ /***/ + import { Node, Source, CommonTypeNode, TypeName, TypeParameterNode, SignatureNode, IdentifierExpression, LiteralExpression, FloatLiteralExpression, IntegerLiteralExpression, StringLiteralExpression, RegexpLiteralExpression, ArrayLiteralExpression, AssertionExpression, BinaryExpression, CallExpression, CommaExpression, ElementAccessExpression, FunctionExpression, NewExpression, ParenthesizedExpression, PropertyAccessExpression, TernaryExpression, UnaryPostfixExpression, UnaryExpression, UnaryPrefixExpression, ClassExpression, ObjectLiteralExpression, Statement, BlockStatement, BreakStatement, ContinueStatement, DoStatement, EmptyStatement, ExportImportStatement, ExportStatement, ExpressionStatement, ForStatement, IfStatement, ImportStatement, InstanceOfExpression, ReturnStatement, SwitchStatement, ThrowStatement, TryStatement, VariableStatement, WhileStatement, ClassDeclaration, EnumDeclaration, EnumValueDeclaration, FieldDeclaration, FunctionDeclaration, ImportDeclaration, IndexSignatureDeclaration, InterfaceDeclaration, MethodDeclaration, NamespaceDeclaration, TypeDeclaration, VariableDeclaration, DecoratorNode, ParameterNode, ExportMember, SwitchCase, DeclarationStatement } from 'assemblyscript/src/ast'; + /** An AST builder. */ + export class ASTBuilder { + /** Rebuilds the textual source from the specified AST, as far as possible. */ + static build(node: Node): string; + private sb; + private indentLevel; + visitNode(node: Node): void; + visitSource(source: Source): void; + visitTypeNode(node: CommonTypeNode): void; + visitTypeName(node: TypeName): void; + visitTypeParameter(node: TypeParameterNode): void; + visitSignatureNode(node: SignatureNode): void; + visitIdentifierExpression(node: IdentifierExpression): void; + visitArrayLiteralExpression(node: ArrayLiteralExpression): void; + visitObjectLiteralExpression(node: ObjectLiteralExpression): void; + visitAssertionExpression(node: AssertionExpression): void; + visitBinaryExpression(node: BinaryExpression): void; + visitCallExpression(node: CallExpression): void; + visitClassExpression(node: ClassExpression): void; + visitCommaExpression(node: CommaExpression): void; + visitElementAccessExpression(node: ElementAccessExpression): void; + visitFunctionExpression(node: FunctionExpression): void; + visitLiteralExpression(node: LiteralExpression): void; + visitFloatLiteralExpression(node: FloatLiteralExpression): void; + visitInstanceOfExpression(node: InstanceOfExpression): void; + visitIntegerLiteralExpression(node: IntegerLiteralExpression): void; + visitStringLiteral(str: string, singleQuoted?: bool): void; + visitStringLiteralExpression(node: StringLiteralExpression): void; + visitRegexpLiteralExpression(node: RegexpLiteralExpression): void; + visitNewExpression(node: NewExpression): void; + visitParenthesizedExpression(node: ParenthesizedExpression): void; + visitPropertyAccessExpression(node: PropertyAccessExpression): void; + visitTernaryExpression(node: TernaryExpression): void; + visitUnaryExpression(node: UnaryExpression): void; + visitUnaryPostfixExpression(node: UnaryPostfixExpression): void; + visitUnaryPrefixExpression(node: UnaryPrefixExpression): void; + visitNodeAndTerminate(statement: Statement): void; + visitBlockStatement(node: BlockStatement): void; + visitBreakStatement(node: BreakStatement): void; + visitContinueStatement(node: ContinueStatement): void; + visitClassDeclaration(node: ClassDeclaration): void; + visitDoStatement(node: DoStatement): void; + visitEmptyStatement(node: EmptyStatement): void; + visitEnumDeclaration(node: EnumDeclaration): void; + visitEnumValueDeclaration(node: EnumValueDeclaration): void; + visitExportImportStatement(node: ExportImportStatement): void; + visitExportMember(node: ExportMember): void; + visitExportStatement(node: ExportStatement): void; + visitExpressionStatement(node: ExpressionStatement): void; + visitFieldDeclaration(node: FieldDeclaration): void; + visitForStatement(node: ForStatement): void; + visitFunctionDeclaration(node: FunctionDeclaration): void; + visitFunctionCommon(node: FunctionDeclaration): void; + visitIfStatement(node: IfStatement): void; + visitImportDeclaration(node: ImportDeclaration): void; + visitImportStatement(node: ImportStatement): void; + visitIndexSignatureDeclaration(node: IndexSignatureDeclaration): void; + visitInterfaceDeclaration(node: InterfaceDeclaration): void; + visitMethodDeclaration(node: MethodDeclaration): void; + visitNamespaceDeclaration(node: NamespaceDeclaration): void; + visitReturnStatement(node: ReturnStatement): void; + visitSwitchCase(node: SwitchCase): void; + visitSwitchStatement(node: SwitchStatement): void; + visitThrowStatement(node: ThrowStatement): void; + visitTryStatement(node: TryStatement): void; + visitTypeDeclaration(node: TypeDeclaration): void; + visitVariableDeclaration(node: VariableDeclaration): void; + visitVariableStatement(node: VariableStatement): void; + visitWhileStatement(node: WhileStatement): void; + serializeDecorator(node: DecoratorNode): void; + serializeParameter(node: ParameterNode): void; + serializeExternalModifiers(node: DeclarationStatement): void; + serializeAccessModifiers(node: DeclarationStatement): void; + finish(): string; + } + +} +/** + * TypeScript definitions for Binaryen's C-API. + * + * See: https://github.com/WebAssembly/binaryen/blob/master/src/binaryen-c.h + * + * @module glue/binaryen + *//***/ + +declare function _malloc(size: usize): usize; +declare function _free(ptr: usize): void; + +declare type BinaryenIndex = u32; + +declare type BinaryenType = i32; + +declare function _BinaryenTypeNone(): BinaryenType; +declare function _BinaryenTypeInt32(): BinaryenType; +declare function _BinaryenTypeInt64(): BinaryenType; +declare function _BinaryenTypeFloat32(): BinaryenType; +declare function _BinaryenTypeFloat64(): BinaryenType; +declare function _BinaryenTypeVec128(): BinaryenType; +declare function _BinaryenTypeUnreachable(): BinaryenType; +declare function _BinaryenTypeAuto(): BinaryenType; + +declare type BinaryenFeatureFlags = u32; + +declare function _BinaryenFeatureAtomics(): BinaryenFeatureFlags; +declare function _BinaryenFeatureMutableGlobals(): BinaryenFeatureFlags; +declare function _BinaryenFeatureNontrappingFPToInt(): BinaryenFeatureFlags; +declare function _BinaryenFeatureSIMD128(): BinaryenFeatureFlags; +declare function _BinaryenFeatureBulkMemory(): BinaryenFeatureFlags; +declare function _BinaryenFeatureSignExt(): BinaryenFeatureFlags; +declare function _BinaryenFeatureExceptionHandling(): BinaryenFeatureFlags; + +declare type BinaryenExpressionId = i32; + +declare function _BinaryenInvalidId(): BinaryenExpressionId; +declare function _BinaryenBlockId(): BinaryenExpressionId; +declare function _BinaryenIfId(): BinaryenExpressionId; +declare function _BinaryenLoopId(): BinaryenExpressionId; +declare function _BinaryenBreakId(): BinaryenExpressionId; +declare function _BinaryenSwitchId(): BinaryenExpressionId; +declare function _BinaryenCallId(): BinaryenExpressionId; +declare function _BinaryenCallIndirectId(): BinaryenExpressionId; +declare function _BinaryenLocalGetId(): BinaryenExpressionId; +declare function _BinaryenLocalSetId(): BinaryenExpressionId; +declare function _BinaryenGlobalGetId(): BinaryenExpressionId; +declare function _BinaryenGlobalSetId(): BinaryenExpressionId; +declare function _BinaryenLoadId(): BinaryenExpressionId; +declare function _BinaryenStoreId(): BinaryenExpressionId; +declare function _BinaryenConstId(): BinaryenExpressionId; +declare function _BinaryenUnaryId(): BinaryenExpressionId; +declare function _BinaryenBinaryId(): BinaryenExpressionId; +declare function _BinaryenSelectId(): BinaryenExpressionId; +declare function _BinaryenDropId(): BinaryenExpressionId; +declare function _BinaryenReturnId(): BinaryenExpressionId; +declare function _BinaryenHostId(): BinaryenExpressionId; +declare function _BinaryenNopId(): BinaryenExpressionId; +declare function _BinaryenUnreachableId(): BinaryenExpressionId; +declare function _BinaryenAtomicCmpxchgId(): BinaryenExpressionId; +declare function _BinaryenAtomicRMWId(): BinaryenExpressionId; +declare function _BinaryenAtomicWaitId(): BinaryenExpressionId; +declare function _BinaryenAtomicNotifyId(): BinaryenExpressionId; +declare function _BinaryenSIMDExtractId(): BinaryenExpressionId; +declare function _BinaryenSIMDReplaceId(): BinaryenExpressionId; +declare function _BinaryenSIMDShuffleId(): BinaryenExpressionId; +declare function _BinaryenSIMDBitselectId(): BinaryenExpressionId; +declare function _BinaryenSIMDShiftId(): BinaryenExpressionId; +declare function _BinaryenMemoryInitId(): BinaryenExpressionId; +declare function _BinaryenDataDropId(): BinaryenExpressionId; +declare function _BinaryenMemoryCopyId(): BinaryenExpressionId; +declare function _BinaryenMemoryFillId(): BinaryenExpressionId; + +declare type BinaryenModuleRef = usize; +declare type v128ptr = usize; // TODO: LLVM C-abi for const uint8_t[16]? + +declare function _BinaryenModuleCreate(): BinaryenModuleRef; +declare function _BinaryenModuleDispose(module: BinaryenModuleRef): void; + +// LLVM C ABI with `out` being a large enough buffer receiving the +// BinaryenLiteral struct of size `_BinaryenSizeofLiteral()`. +declare function _BinaryenSizeofLiteral(): usize; +declare function _BinaryenLiteralInt32(out: usize, x: i32): void; +declare function _BinaryenLiteralInt64(out: usize, x: i32, y: i32): void; +declare function _BinaryenLiteralFloat32(out: usize, x: f32): void; +declare function _BinaryenLiteralFloat64(out: usize, x: f64): void; +declare function _BinaryenLiteralVec128(out: usize, x: v128ptr): void; +declare function _BinaryenLiteralFloat32Bits(out: usize, x: i32): void; +declare function _BinaryenLiteralFloat64Bits(out: usize, x: i32, y: i32): void; + +declare type BinaryenOp = i32; + +declare function _BinaryenClzInt32(): BinaryenOp; +declare function _BinaryenCtzInt32(): BinaryenOp; +declare function _BinaryenPopcntInt32(): BinaryenOp; +declare function _BinaryenNegFloat32(): BinaryenOp; +declare function _BinaryenAbsFloat32(): BinaryenOp; +declare function _BinaryenCeilFloat32(): BinaryenOp; +declare function _BinaryenFloorFloat32(): BinaryenOp; +declare function _BinaryenTruncFloat32(): BinaryenOp; +declare function _BinaryenNearestFloat32(): BinaryenOp; +declare function _BinaryenSqrtFloat32(): BinaryenOp; +declare function _BinaryenEqZInt32(): BinaryenOp; +declare function _BinaryenClzInt64(): BinaryenOp; +declare function _BinaryenCtzInt64(): BinaryenOp; +declare function _BinaryenPopcntInt64(): BinaryenOp; +declare function _BinaryenNegFloat64(): BinaryenOp; +declare function _BinaryenAbsFloat64(): BinaryenOp; +declare function _BinaryenCeilFloat64(): BinaryenOp; +declare function _BinaryenFloorFloat64(): BinaryenOp; +declare function _BinaryenTruncFloat64(): BinaryenOp; +declare function _BinaryenNearestFloat64(): BinaryenOp; +declare function _BinaryenSqrtFloat64(): BinaryenOp; +declare function _BinaryenEqZInt64(): BinaryenOp; +declare function _BinaryenExtendSInt32(): BinaryenOp; +declare function _BinaryenExtendUInt32(): BinaryenOp; +declare function _BinaryenWrapInt64(): BinaryenOp; +declare function _BinaryenTruncSFloat32ToInt32(): BinaryenOp; +declare function _BinaryenTruncSFloat32ToInt64(): BinaryenOp; +declare function _BinaryenTruncUFloat32ToInt32(): BinaryenOp; +declare function _BinaryenTruncUFloat32ToInt64(): BinaryenOp; +declare function _BinaryenTruncSFloat64ToInt32(): BinaryenOp; +declare function _BinaryenTruncSFloat64ToInt64(): BinaryenOp; +declare function _BinaryenTruncUFloat64ToInt32(): BinaryenOp; +declare function _BinaryenTruncUFloat64ToInt64(): BinaryenOp; +declare function _BinaryenReinterpretFloat32(): BinaryenOp; +declare function _BinaryenReinterpretFloat64(): BinaryenOp; +declare function _BinaryenConvertSInt32ToFloat32(): BinaryenOp; +declare function _BinaryenConvertSInt32ToFloat64(): BinaryenOp; +declare function _BinaryenConvertUInt32ToFloat32(): BinaryenOp; +declare function _BinaryenConvertUInt32ToFloat64(): BinaryenOp; +declare function _BinaryenConvertSInt64ToFloat32(): BinaryenOp; +declare function _BinaryenConvertSInt64ToFloat64(): BinaryenOp; +declare function _BinaryenConvertUInt64ToFloat32(): BinaryenOp; +declare function _BinaryenConvertUInt64ToFloat64(): BinaryenOp; +declare function _BinaryenPromoteFloat32(): BinaryenOp; +declare function _BinaryenDemoteFloat64(): BinaryenOp; +declare function _BinaryenReinterpretInt32(): BinaryenOp; +declare function _BinaryenReinterpretInt64(): BinaryenOp; +declare function _BinaryenExtendS8Int32(): BinaryenOp; +declare function _BinaryenExtendS16Int32(): BinaryenOp; +declare function _BinaryenExtendS8Int64(): BinaryenOp; +declare function _BinaryenExtendS16Int64(): BinaryenOp; +declare function _BinaryenExtendS32Int64(): BinaryenOp; +declare function _BinaryenAddInt32(): BinaryenOp; +declare function _BinaryenSubInt32(): BinaryenOp; +declare function _BinaryenMulInt32(): BinaryenOp; +declare function _BinaryenDivSInt32(): BinaryenOp; +declare function _BinaryenDivUInt32(): BinaryenOp; +declare function _BinaryenRemSInt32(): BinaryenOp; +declare function _BinaryenRemUInt32(): BinaryenOp; +declare function _BinaryenAndInt32(): BinaryenOp; +declare function _BinaryenOrInt32(): BinaryenOp; +declare function _BinaryenXorInt32(): BinaryenOp; +declare function _BinaryenShlInt32(): BinaryenOp; +declare function _BinaryenShrUInt32(): BinaryenOp; +declare function _BinaryenShrSInt32(): BinaryenOp; +declare function _BinaryenRotLInt32(): BinaryenOp; +declare function _BinaryenRotRInt32(): BinaryenOp; +declare function _BinaryenEqInt32(): BinaryenOp; +declare function _BinaryenNeInt32(): BinaryenOp; +declare function _BinaryenLtSInt32(): BinaryenOp; +declare function _BinaryenLtUInt32(): BinaryenOp; +declare function _BinaryenLeSInt32(): BinaryenOp; +declare function _BinaryenLeUInt32(): BinaryenOp; +declare function _BinaryenGtSInt32(): BinaryenOp; +declare function _BinaryenGtUInt32(): BinaryenOp; +declare function _BinaryenGeSInt32(): BinaryenOp; +declare function _BinaryenGeUInt32(): BinaryenOp; +declare function _BinaryenAddInt64(): BinaryenOp; +declare function _BinaryenSubInt64(): BinaryenOp; +declare function _BinaryenMulInt64(): BinaryenOp; +declare function _BinaryenDivSInt64(): BinaryenOp; +declare function _BinaryenDivUInt64(): BinaryenOp; +declare function _BinaryenRemSInt64(): BinaryenOp; +declare function _BinaryenRemUInt64(): BinaryenOp; +declare function _BinaryenAndInt64(): BinaryenOp; +declare function _BinaryenOrInt64(): BinaryenOp; +declare function _BinaryenXorInt64(): BinaryenOp; +declare function _BinaryenShlInt64(): BinaryenOp; +declare function _BinaryenShrUInt64(): BinaryenOp; +declare function _BinaryenShrSInt64(): BinaryenOp; +declare function _BinaryenRotLInt64(): BinaryenOp; +declare function _BinaryenRotRInt64(): BinaryenOp; +declare function _BinaryenEqInt64(): BinaryenOp; +declare function _BinaryenNeInt64(): BinaryenOp; +declare function _BinaryenLtSInt64(): BinaryenOp; +declare function _BinaryenLtUInt64(): BinaryenOp; +declare function _BinaryenLeSInt64(): BinaryenOp; +declare function _BinaryenLeUInt64(): BinaryenOp; +declare function _BinaryenGtSInt64(): BinaryenOp; +declare function _BinaryenGtUInt64(): BinaryenOp; +declare function _BinaryenGeSInt64(): BinaryenOp; +declare function _BinaryenGeUInt64(): BinaryenOp; +declare function _BinaryenAddFloat32(): BinaryenOp; +declare function _BinaryenSubFloat32(): BinaryenOp; +declare function _BinaryenMulFloat32(): BinaryenOp; +declare function _BinaryenDivFloat32(): BinaryenOp; +declare function _BinaryenCopySignFloat32(): BinaryenOp; +declare function _BinaryenMinFloat32(): BinaryenOp; +declare function _BinaryenMaxFloat32(): BinaryenOp; +declare function _BinaryenEqFloat32(): BinaryenOp; +declare function _BinaryenNeFloat32(): BinaryenOp; +declare function _BinaryenLtFloat32(): BinaryenOp; +declare function _BinaryenLeFloat32(): BinaryenOp; +declare function _BinaryenGtFloat32(): BinaryenOp; +declare function _BinaryenGeFloat32(): BinaryenOp; +declare function _BinaryenAddFloat64(): BinaryenOp; +declare function _BinaryenSubFloat64(): BinaryenOp; +declare function _BinaryenMulFloat64(): BinaryenOp; +declare function _BinaryenDivFloat64(): BinaryenOp; +declare function _BinaryenCopySignFloat64(): BinaryenOp; +declare function _BinaryenMinFloat64(): BinaryenOp; +declare function _BinaryenMaxFloat64(): BinaryenOp; +declare function _BinaryenEqFloat64(): BinaryenOp; +declare function _BinaryenNeFloat64(): BinaryenOp; +declare function _BinaryenLtFloat64(): BinaryenOp; +declare function _BinaryenLeFloat64(): BinaryenOp; +declare function _BinaryenGtFloat64(): BinaryenOp; +declare function _BinaryenGeFloat64(): BinaryenOp; + +declare type BinaryenHostOp = BinaryenOp; + +declare function _BinaryenMemorySize(): BinaryenHostOp; +declare function _BinaryenMemoryGrow(): BinaryenHostOp; + +declare type BinaryenAtomicRMWOp = BinaryenOp; + +declare function _BinaryenAtomicRMWAdd(): BinaryenAtomicRMWOp; +declare function _BinaryenAtomicRMWSub(): BinaryenAtomicRMWOp; +declare function _BinaryenAtomicRMWAnd(): BinaryenAtomicRMWOp; +declare function _BinaryenAtomicRMWOr(): BinaryenAtomicRMWOp; +declare function _BinaryenAtomicRMWXor(): BinaryenAtomicRMWOp; +declare function _BinaryenAtomicRMWXchg(): BinaryenAtomicRMWOp; + +declare type BinaryenSIMDOp = BinaryenOp; + +declare function _BinaryenSplatVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenExtractLaneSVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenExtractLaneUVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenReplaceLaneVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenSplatVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenExtractLaneSVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenExtractLaneUVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenReplaceLaneVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenSplatVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenExtractLaneVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenReplaceLaneVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenSplatVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenExtractLaneVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenReplaceLaneVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenSplatVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenExtractLaneVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenReplaceLaneVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenSplatVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenExtractLaneVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenReplaceLaneVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenEqVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenNeVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenLtSVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenLtUVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenGtSVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenGtUVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenLeSVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenLeUVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenGeSVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenGeUVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenEqVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenNeVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenLtSVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenLtUVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenGtSVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenGtUVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenLeSVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenLeUVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenGeSVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenGeUVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenEqVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenNeVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenLtSVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenLtUVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenGtSVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenGtUVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenLeSVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenLeUVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenGeSVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenGeUVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenEqVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenNeVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenLtVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenGtVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenLeVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenGeVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenEqVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenNeVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenLtVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenGtVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenLeVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenGeVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenNotVec128(): BinaryenSIMDOp; +declare function _BinaryenAndVec128(): BinaryenSIMDOp; +declare function _BinaryenOrVec128(): BinaryenSIMDOp; +declare function _BinaryenXorVec128(): BinaryenSIMDOp; +declare function _BinaryenNegVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenAnyTrueVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenAllTrueVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenShlVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenShrSVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenShrUVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenAddVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenAddSatSVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenAddSatUVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenSubVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenSubSatSVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenSubSatUVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenMulVecI8x16(): BinaryenSIMDOp; +declare function _BinaryenNegVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenAnyTrueVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenAllTrueVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenShlVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenShrSVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenShrUVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenAddVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenAddSatSVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenAddSatUVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenSubVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenSubSatSVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenSubSatUVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenMulVecI16x8(): BinaryenSIMDOp; +declare function _BinaryenNegVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenAnyTrueVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenAllTrueVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenShlVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenShrSVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenShrUVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenAddVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenSubVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenMulVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenNegVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenAnyTrueVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenAllTrueVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenShlVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenShrSVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenShrUVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenAddVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenSubVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenAbsVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenNegVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenSqrtVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenAddVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenSubVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenMulVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenDivVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenMinVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenMaxVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenAbsVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenNegVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenSqrtVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenAddVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenSubVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenMulVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenDivVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenMinVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenMaxVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenTruncSatSVecF32x4ToVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenTruncSatUVecF32x4ToVecI32x4(): BinaryenSIMDOp; +declare function _BinaryenTruncSatSVecF64x2ToVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenTruncSatUVecF64x2ToVecI64x2(): BinaryenSIMDOp; +declare function _BinaryenConvertSVecI32x4ToVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenConvertUVecI32x4ToVecF32x4(): BinaryenSIMDOp; +declare function _BinaryenConvertSVecI64x2ToVecF64x2(): BinaryenSIMDOp; +declare function _BinaryenConvertUVecI64x2ToVecF64x2(): BinaryenSIMDOp; + +declare type BinaryenExpressionRef = usize; + +declare function _BinaryenBlock(module: BinaryenModuleRef, name: usize, children: usize, numChildren: BinaryenIndex, type: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenIf(module: BinaryenModuleRef, condition: BinaryenExpressionRef, ifTrue: BinaryenExpressionRef, ifFalse: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenLoop(module: BinaryenModuleRef, name: usize, body: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenBreak(module: BinaryenModuleRef, name: usize, condition: BinaryenExpressionRef, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSwitch(module: BinaryenModuleRef, names: usize, numNames: BinaryenIndex, defaultName: usize, condition: BinaryenExpressionRef, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenCall(module: BinaryenModuleRef, target: usize, operands: usize, numOperands: BinaryenIndex, returnType: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenCallIndirect(module: BinaryenModuleRef, target: BinaryenExpressionRef, operands: usize, numOperands: BinaryenIndex, type: usize): BinaryenExpressionRef; +declare function _BinaryenLocalGet(module: BinaryenModuleRef, index: BinaryenIndex, type: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenLocalSet(module: BinaryenModuleRef, index: BinaryenIndex, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenLocalTee(module: BinaryenModuleRef, index: BinaryenIndex, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenGlobalGet(module: BinaryenModuleRef, name: usize, type: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenGlobalSet(module: BinaryenModuleRef, name: usize, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenLoad(module: BinaryenModuleRef, bytes: u32, signed: i8, offset: u32, align: u32, type: BinaryenType, ptr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenStore(module: BinaryenModuleRef, bytes: u32, offset: u32, align: u32, ptr: BinaryenExpressionRef, value: BinaryenExpressionRef, type: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenConst(module: BinaryenModuleRef, value: usize): BinaryenExpressionRef; +declare function _BinaryenUnary(module: BinaryenModuleRef, op: BinaryenOp, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenBinary(module: BinaryenModuleRef, op: BinaryenOp, left: BinaryenExpressionRef, right: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSelect(module: BinaryenModuleRef, condition: BinaryenExpressionRef, ifTrue: BinaryenExpressionRef, ifFalse: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenDrop(module: BinaryenModuleRef, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenReturn(module: BinaryenModuleRef, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenHost(module: BinaryenModuleRef, op: BinaryenOp, name: usize | 0, operands: usize, numOperands: BinaryenIndex): BinaryenExpressionRef; +declare function _BinaryenNop(module: BinaryenModuleRef): BinaryenExpressionRef; +declare function _BinaryenUnreachable(module: BinaryenModuleRef): BinaryenExpressionRef; + +declare function _BinaryenAtomicLoad(module: BinaryenModuleRef, bytes: BinaryenIndex, offset: BinaryenIndex, type: BinaryenType, ptr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenAtomicStore(module: BinaryenModuleRef, bytes: BinaryenIndex, offset: BinaryenIndex, ptr: BinaryenExpressionRef, value: BinaryenExpressionRef, type: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenAtomicRMW(module: BinaryenModuleRef, op: BinaryenAtomicRMWOp, bytes: i32, offset: i32, ptr: BinaryenExpressionRef, value: BinaryenExpressionRef, type: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenAtomicCmpxchg(module: BinaryenModuleRef, bytes: i32, offset: i32, ptr: BinaryenExpressionRef, expected: BinaryenExpressionRef, replacement: BinaryenExpressionRef, type: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenAtomicWait(module: BinaryenModuleRef, ptr: BinaryenExpressionRef, expected: BinaryenExpressionRef, timeout: BinaryenExpressionRef, expectedType: BinaryenType): BinaryenExpressionRef; +declare function _BinaryenAtomicNotify(module: BinaryenModuleRef, ptr: BinaryenExpressionRef, notifyCount: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenSIMDExtract(module: BinaryenModuleRef, op: BinaryenSIMDOp, vec: BinaryenExpressionRef, idx: u8): BinaryenExpressionRef; +declare function _BinaryenSIMDReplace(module: BinaryenModuleRef, op: BinaryenSIMDOp, vec: BinaryenExpressionRef, idx: u8, value: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDShuffle(module: BinaryenModuleRef, left: BinaryenExpressionRef, right: BinaryenExpressionRef, mask: v128ptr): BinaryenExpressionRef; +declare function _BinaryenSIMDBitselect(module: BinaryenModuleRef, left: BinaryenExpressionRef, right: BinaryenExpressionRef, cond: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDShift(module: BinaryenModuleRef, op: BinaryenSIMDOp, vec: BinaryenExpressionRef, shift: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenMemoryInit(module: BinaryenModuleRef, segment: u32, dest: BinaryenExpressionRef, offset: BinaryenExpressionRef, size: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenDataDrop(module: BinaryenModuleRef, segment: u32): BinaryenExpressionRef; +declare function _BinaryenMemoryCopy(module: BinaryenModuleRef, dest: BinaryenExpressionRef, source: BinaryenExpressionRef, size: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenMemoryFill(module: BinaryenModuleRef, dest: BinaryenExpressionRef, value: BinaryenExpressionRef, size: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenExpressionGetId(expr: BinaryenExpressionRef): BinaryenExpressionId; +declare function _BinaryenExpressionGetType(expr: BinaryenExpressionRef): BinaryenType; +declare function _BinaryenExpressionPrint(expr: BinaryenExpressionRef): void; + +declare function _BinaryenBlockGetName(expr: BinaryenExpressionRef): usize; +declare function _BinaryenBlockGetNumChildren(expr: BinaryenExpressionRef): BinaryenIndex; +declare function _BinaryenBlockGetChild(expr: BinaryenExpressionRef, index: BinaryenIndex): BinaryenExpressionRef; + +declare function _BinaryenIfGetCondition(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenIfGetIfTrue(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenIfGetIfFalse(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenLoopGetName(expr: BinaryenExpressionRef): usize; +declare function _BinaryenLoopGetBody(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenBreakGetName(expr: BinaryenExpressionRef): usize; +declare function _BinaryenBreakGetCondition(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenBreakGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenSwitchGetNumNames(expr: BinaryenExpressionRef): BinaryenIndex; +declare function _BinaryenSwitchGetName(expr: BinaryenExpressionRef, index: BinaryenIndex): usize; +declare function _BinaryenSwitchGetDefaultName(expr: BinaryenExpressionRef): usize; +declare function _BinaryenSwitchGetCondition(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSwitchGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenCallGetTarget(expr: BinaryenExpressionRef): usize; +declare function _BinaryenCallGetNumOperands(expr: BinaryenExpressionRef): BinaryenIndex; +declare function _BinaryenCallGetOperand(expr: BinaryenExpressionRef, index: BinaryenIndex): BinaryenExpressionRef; + +declare function _BinaryenCallIndirectGetTarget(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenCallIndirectGetNumOperands(expr: BinaryenExpressionRef): BinaryenIndex; +declare function _BinaryenCallIndirectGetOperand(expr: BinaryenExpressionRef, index: BinaryenIndex): BinaryenExpressionRef; + +declare function _BinaryenLocalGetGetIndex(expr: BinaryenExpressionRef): BinaryenIndex; + +declare function _BinaryenLocalSetIsTee(expr: BinaryenExpressionRef): bool; +declare function _BinaryenLocalSetGetIndex(expr: BinaryenExpressionRef): BinaryenIndex; +declare function _BinaryenLocalSetGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenGlobalGetGetName(expr: BinaryenExpressionRef): usize; + +declare function _BinaryenGlobalSetGetName(expr: BinaryenExpressionRef): usize; +declare function _BinaryenGlobalSetGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenHostGetOp(expr: BinaryenExpressionRef): BinaryenOp; +declare function _BinaryenHostGetNameOperand(expr: BinaryenExpressionRef): usize; +declare function _BinaryenHostGetNumOperands(expr: BinaryenExpressionRef): BinaryenIndex; +declare function _BinaryenHostGetOperand(expr: BinaryenExpressionRef, index: BinaryenIndex): BinaryenExpressionRef; + +declare function _BinaryenLoadIsAtomic(expr: BinaryenExpressionRef): bool; +declare function _BinaryenLoadIsSigned(expr: BinaryenExpressionRef): bool; +declare function _BinaryenLoadGetBytes(expr: BinaryenExpressionRef): u32; +declare function _BinaryenLoadGetOffset(expr: BinaryenExpressionRef): u32; +declare function _BinaryenLoadGetAlign(expr: BinaryenExpressionRef): u32; +declare function _BinaryenLoadGetPtr(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenStoreIsAtomic(expr: BinaryenExpressionRef): bool; +declare function _BinaryenStoreGetBytes(expr: BinaryenExpressionRef): u32; +declare function _BinaryenStoreGetOffset(expr: BinaryenExpressionRef): u32; +declare function _BinaryenStoreGetAlign(expr: BinaryenExpressionRef): u32; +declare function _BinaryenStoreGetPtr(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenStoreGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenConstGetValueI32(expr: BinaryenExpressionRef): i32; +declare function _BinaryenConstGetValueI64Low(expr: BinaryenExpressionRef): i32; +declare function _BinaryenConstGetValueI64High(expr: BinaryenExpressionRef): i32; +declare function _BinaryenConstGetValueF32(expr: BinaryenExpressionRef): f32; +declare function _BinaryenConstGetValueF64(expr: BinaryenExpressionRef): f64; + +declare function _BinaryenUnaryGetOp(expr: BinaryenExpressionRef): BinaryenOp; +declare function _BinaryenUnaryGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenBinaryGetOp(expr: BinaryenExpressionRef): BinaryenOp; +declare function _BinaryenBinaryGetLeft(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenBinaryGetRight(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenSelectGetIfTrue(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSelectGetIfFalse(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSelectGetCondition(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenDropGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenReturnGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenAtomicRMWGetOp(expr: BinaryenExpressionRef): BinaryenOp; +declare function _BinaryenAtomicRMWGetBytes(expr: BinaryenExpressionRef): u32; +declare function _BinaryenAtomicRMWGetOffset(expr: BinaryenExpressionRef): u32; +declare function _BinaryenAtomicRMWGetPtr(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenAtomicRMWGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenAtomicCmpxchgGetBytes(expr: BinaryenExpressionRef): u32; +declare function _BinaryenAtomicCmpxchgGetOffset(expr: BinaryenExpressionRef): u32; +declare function _BinaryenAtomicCmpxchgGetPtr(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenAtomicCmpxchgGetExpected(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenAtomicCmpxchgGetReplacement(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenAtomicWaitGetPtr(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenAtomicWaitGetExpected(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenAtomicWaitGetTimeout(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenAtomicWaitGetExpectedType(expr: BinaryenExpressionRef): BinaryenType; + +declare function _BinaryenAtomicNotifyGetPtr(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenAtomicNotifyGetNotifyCount(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenSIMDExtractGetOp(expr: BinaryenExpressionRef): BinaryenSIMDOp; +declare function _BinaryenSIMDExtractGetVec(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDExtractGetIdx(expr: BinaryenExpressionRef): u8; + +declare function _BinaryenSIMDReplaceGetOp(expr: BinaryenExpressionRef): BinaryenSIMDOp; +declare function _BinaryenSIMDReplaceGetVec(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDReplaceGetIdx(expr: BinaryenExpressionRef): u8; +declare function _BinaryenSIMDReplaceGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenSIMDShuffleGetLeft(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDShuffleGetRight(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDShuffleGetMask(expr: BinaryenExpressionRef, out: v128ptr): void; + +declare function _BinaryenSIMDBitselectGetLeft(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDBitselectGetRight(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDBitselectGetCond(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenSIMDShiftGetOp(expr: BinaryenExpressionRef): BinaryenSIMDOp; +declare function _BinaryenSIMDShiftGetVec(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenSIMDShiftGetShift(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenMemoryInitGetSegment(expr: BinaryenExpressionRef): u32; +declare function _BinaryenMemoryInitGetDest(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenMemoryInitGetOffset(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenMemoryInitGetSize(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenDataDropGetSegment(expr: BinaryenExpressionRef): u32; + +declare function _BinaryenMemoryCopyGetDest(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenMemoryCopyGetSource(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenMemoryCopyGetSize(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare function _BinaryenMemoryFillGetDest(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenMemoryFillGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; +declare function _BinaryenMemoryFillGetSize(expr: BinaryenExpressionRef): BinaryenExpressionRef; + +declare type BinaryenFunctionTypeRef = usize; + +declare function _BinaryenAddFunctionType(module: BinaryenModuleRef, name: usize, result: BinaryenType, paramTypes: usize, numParams: BinaryenIndex): BinaryenFunctionTypeRef; +declare function _BinaryenGetFunctionTypeBySignature(module: BinaryenModuleRef, result: BinaryenType, paramTypes: usize, numParams: BinaryenIndex): BinaryenFunctionTypeRef; +declare function _BinaryenRemoveFunctionType(module: BinaryenModuleRef, name: usize): void; + +declare function _BinaryenFunctionTypeGetName(ftype: BinaryenFunctionTypeRef): usize; +declare function _BinaryenFunctionTypeGetNumParams(ftype: BinaryenFunctionTypeRef): BinaryenIndex; +declare function _BinaryenFunctionTypeGetParam(ftype: BinaryenFunctionTypeRef, index: BinaryenIndex): BinaryenType; +declare function _BinaryenFunctionTypeGetResult(ftype: BinaryenFunctionTypeRef): BinaryenType; + +declare type BinaryenFunctionRef = usize; + +declare function _BinaryenAddFunction(module: BinaryenModuleRef, name: usize, type: BinaryenFunctionTypeRef, varTypes: usize, numVarTypes: BinaryenIndex, body: BinaryenExpressionRef): BinaryenFunctionRef; +declare function _BinaryenGetFunction(module: BinaryenModuleRef, name: usize): BinaryenFunctionRef; +declare function _BinaryenRemoveFunction(module: BinaryenModuleRef, name: usize): void; + +declare function _BinaryenFunctionGetName(func: BinaryenFunctionRef): usize; +declare function _BinaryenFunctionGetType(func: BinaryenFunctionRef): BinaryenFunctionTypeRef; +declare function _BinaryenFunctionGetNumParams(func: BinaryenFunctionRef): BinaryenIndex; +declare function _BinaryenFunctionGetParam(func: BinaryenFunctionRef, index: BinaryenIndex): BinaryenType; +declare function _BinaryenFunctionGetResult(func: BinaryenFunctionRef): BinaryenType; +declare function _BinaryenFunctionGetNumVars(func: BinaryenFunctionRef): BinaryenIndex; +declare function _BinaryenFunctionGetVar(func: BinaryenFunctionRef, index: BinaryenIndex): BinaryenType; +declare function _BinaryenFunctionGetBody(func: BinaryenFunctionRef): BinaryenExpressionRef; +declare function _BinaryenFunctionOptimize(func: BinaryenFunctionRef, module: BinaryenModuleRef): void; +declare function _BinaryenFunctionRunPasses(func: BinaryenFunctionRef, module: BinaryenModuleRef, passes: usize, numPasses: BinaryenIndex): void; +declare function _BinaryenFunctionSetDebugLocation(func: BinaryenFunctionRef, expr: BinaryenExpressionRef, fileIndex: BinaryenIndex, lineNumber: BinaryenIndex, columnNumber: BinaryenIndex): void; + +declare type BinaryenImportRef = usize; + +declare function _BinaryenAddFunctionImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, functionType: BinaryenFunctionTypeRef): BinaryenImportRef; +declare function _BinaryenAddTableImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize): BinaryenImportRef; +declare function _BinaryenAddMemoryImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, shared:bool): BinaryenImportRef; +declare function _BinaryenAddGlobalImport(module: BinaryenModuleRef, internalName: usize, externalModuleName: usize, externalBaseName: usize, globalType: BinaryenType): BinaryenImportRef; + +declare type BinaryenExportRef = usize; + +declare function _BinaryenAddFunctionExport(module: BinaryenModuleRef, internalName: usize, externalName: usize): BinaryenExportRef; +declare function _BinaryenAddTableExport(module: BinaryenModuleRef, internalName: usize, externalName: usize): BinaryenExportRef; +declare function _BinaryenAddMemoryExport(module: BinaryenModuleRef, internalName: usize, externalName: usize): BinaryenExportRef; +declare function _BinaryenAddGlobalExport(module: BinaryenModuleRef, internalName: usize, externalName: usize): BinaryenExportRef; +declare function _BinaryenRemoveExport(module: BinaryenModuleRef, externalName: usize): void; + +declare type BinaryenGlobalRef = usize; + +declare function _BinaryenAddGlobal(module: BinaryenModuleRef, name: usize, type: BinaryenType, mutable: i8, init: BinaryenExpressionRef): BinaryenGlobalRef; +declare function _BinaryenRemoveGlobal(module: BinaryenModuleRef, name: usize): void; + +declare function _BinaryenSetFunctionTable(module: BinaryenModuleRef, initial: BinaryenIndex, maximum: BinaryenIndex, funcs: usize, numFuncs: BinaryenIndex): void; + +declare function _BinaryenSetMemory(module: BinaryenModuleRef, initial: BinaryenIndex, maximum: BinaryenIndex, exportName: usize, segments: usize, segmentPassive: usize, segmentOffsets: usize, segmentSizes: usize, numSegments: BinaryenIndex, shared: bool): void; + +declare function _BinaryenSetStart(module: BinaryenModuleRef, start: BinaryenFunctionRef): void; + +declare function _BinaryenModuleParse(text: usize): BinaryenModuleRef; +declare function _BinaryenModulePrint(module: BinaryenModuleRef): void; +declare function _BinaryenModulePrintAsmjs(module: BinaryenModuleRef): void; +declare function _BinaryenModuleValidate(module: BinaryenModuleRef): i32; +declare function _BinaryenModuleOptimize(module: BinaryenModuleRef): void; +declare function _BinaryenModuleRunPasses(module: BinaryenModuleRef, passes: usize, numPasses: BinaryenIndex): void; +declare function _BinaryenModuleAutoDrop(module: BinaryenModuleRef): void; +declare function _BinaryenModuleAllocateAndWrite(out: usize, module: BinaryenModuleRef, sourceMapUrl: usize): void; +declare function _BinaryenModuleRead(input: usize, inputSize: usize): BinaryenModuleRef; +declare function _BinaryenModuleInterpret(module: BinaryenModuleRef): void; +declare function _BinaryenModuleAddDebugInfoFileName(module: BinaryenModuleRef, filename: usize): BinaryenIndex; +declare function _BinaryenModuleGetDebugInfoFileName(module: BinaryenModuleRef, index: BinaryenIndex): usize; +declare function _BinaryenModuleGetFeatures(module: BinaryenModuleRef): BinaryenFeatureFlags; +declare function _BinaryenModuleSetFeatures(module: BinaryenModuleRef, featureFlags: BinaryenFeatureFlags): void; + +declare type BinaryenRelooperRef = usize; +declare type BinaryenRelooperBlockRef = usize; + +declare function _RelooperCreate(module: BinaryenModuleRef): BinaryenRelooperRef; +declare function _RelooperAddBlock(relooper: BinaryenRelooperRef, code: BinaryenExpressionRef): BinaryenRelooperBlockRef; +declare function _RelooperAddBranch(from: BinaryenRelooperBlockRef, to: BinaryenRelooperBlockRef, condition: BinaryenExpressionRef, code: BinaryenExpressionRef): void; +declare function _RelooperAddBlockWithSwitch(relooper: BinaryenRelooperRef, code: BinaryenExpressionRef, condition: BinaryenExpressionRef): BinaryenRelooperBlockRef; +declare function _RelooperAddBranchForSwitch(from: BinaryenRelooperBlockRef, to: BinaryenRelooperBlockRef, indexes: usize, numIndexes: BinaryenIndex, code: BinaryenExpressionRef): void; +declare function _RelooperRenderAndDispose(relooper: BinaryenRelooperRef, entry: BinaryenRelooperBlockRef, labelHelper: BinaryenIndex): BinaryenExpressionRef; + +declare function _BinaryenGetOptimizeLevel(): i32; +declare function _BinaryenSetOptimizeLevel(level: i32): void; +declare function _BinaryenGetShrinkLevel(): i32; +declare function _BinaryenSetShrinkLevel(level: i32): void; +declare function _BinaryenGetDebugInfo(): bool; +declare function _BinaryenSetDebugInfo(on: bool): void; + +declare function _BinaryenSetAPITracing(on: i32): void; +/** @module glue/js *//***/ + + +declare namespace binaryen { + class Module { + constructor(); + emitStackIR(optimize?: boolean): string; + emitAsmjs(): string; + } + function wrapModule(ptr: number): Module; +} +/** @module glue/js *//***/ + +declare function f32_as_i32(value: f32): i32; +declare function i32_as_f32(value: i32): f32; +declare function f64_as_i64(value: f64): I64; +declare function i64_as_f64(value: I64): f64; +/** @module glue/js *//***/ + +declare type I64 = { __Long__: true }; // opaque + +declare const i64_zero: I64; +declare const i64_one: I64; + +declare function i64_new(lo: i32, hi?: i32): I64; +declare function i64_low(value: I64): i32; +declare function i64_high(value: I64): i32; + +declare function i64_add(left: I64, right: I64): I64; +declare function i64_sub(left: I64, right: I64): I64; +declare function i64_mul(left: I64, right: I64): I64; +declare function i64_div(left: I64, right: I64): I64; +declare function i64_div_u(left: I64, right: I64): I64; +declare function i64_rem(left: I64, right: I64): I64; +declare function i64_rem_u(left: I64, right: I64): I64; +declare function i64_and(left: I64, right: I64): I64; +declare function i64_or(left: I64, right: I64): I64; +declare function i64_xor(left: I64, right: I64): I64; +declare function i64_shl(left: I64, right: I64): I64; +declare function i64_shr(left: I64, right: I64): I64; +declare function i64_shr_u(left: I64, right: I64): I64; +declare function i64_not(value: I64): I64; + +declare function i64_eq(left: I64, right: I64): bool; +declare function i64_ne(left: I64, right: I64): bool; + +declare function i64_align(value: I64, alignment: i32): I64; + +declare function i64_is_i8(value: I64): bool; +declare function i64_is_i16(value: I64): bool; +declare function i64_is_i32(value: I64): bool; +declare function i64_is_u8(value: I64): bool; +declare function i64_is_u16(value: I64): bool; +declare function i64_is_u32(value: I64): bool; +declare function i64_is_bool(value: I64): bool; +declare function i64_is_f32(value: I64): bool; +declare function i64_is_f64(value: I64): bool; + +declare function i64_to_f32(value: I64): f64; +declare function i64_to_f64(value: I64): f64; +declare function i64_to_string(value: I64, unsigned?: bool): string; diff --git a/index.d.ts b/index.d.ts index 3bd16e17..388aca20 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1 +1,2 @@ -export * from "./src"; +/// +export * from "assemblyscript"; diff --git a/lib/rtrace/README.md b/lib/rtrace/README.md index df526092..72411f26 100644 --- a/lib/rtrace/README.md +++ b/lib/rtrace/README.md @@ -16,7 +16,7 @@ WebAssembly.instantiate(..., { rtrace: rtr, ... }); ... if (rtr.active) { - let leakCount = rtr.leakCount; + let leakCount = rtr.check(); if (leakCount) { // handle error } diff --git a/lib/rtrace/index.js b/lib/rtrace/index.js index 622177ee..af0d66c7 100644 --- a/lib/rtrace/index.js +++ b/lib/rtrace/index.js @@ -56,10 +56,10 @@ function rtrace(onerror, oninfo) { }, get active() { - return Boolean(rtrace.allocCount + rtrace.freeCount + rtrace.incrementCount + rtrace.decrementCount); + return Boolean(rtrace.allocCount || rtrace.freeCount || rtrace.incrementCount || rtrace.decrementCount); }, - get leakCount() { + check() { if (oninfo) { for (let [block, rc ] of blocks) { oninfo("LEAKING " + block + " @ " + rc); diff --git a/package-lock.json b/package-lock.json index d7208215..4dfa5741 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "assemblyscript", - "version": "0.6.0", + "version": "0.7.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index cfbe3615..a2d44b50 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,9 @@ "node": ">=8" }, "scripts": { - "build": "webpack --mode production --display-modules", + "build": "npm run build:bundle && npm run build:dts", + "build:bundle": "webpack --mode production --display-modules", + "build:dts": "node scripts/build-dts", "clean": "node scripts/clean", "check": "npm run check:config && npm run check:compiler", "check:config": "tsc --noEmit -p src --diagnostics --listFiles", @@ -68,7 +70,6 @@ "package.json", "package-lock.json", "README.md", - "src/", "std/", "tsconfig-base.json" ], diff --git a/scripts/build-dts.js b/scripts/build-dts.js new file mode 100644 index 00000000..d3012451 --- /dev/null +++ b/scripts/build-dts.js @@ -0,0 +1,450 @@ +// © 2015-2019 SitePen, Inc. New BSD License. +// see: https://github.com/SitePen/dts-generator +(function (factory) { + var v = factory(require, exports); + if (v !== undefined) module.exports = v; +})(function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + const fs = require("fs"); + const glob = require("glob"); + const mkdirp = require("mkdirp"); + const os = require("os"); + const pathUtil = require("path"); + const ts = require("typescript"); + // declare some constants so we don't have magic integers without explanation + const DTSLEN = '.d.ts'.length; + const filenameToMid = (function () { + if (pathUtil.sep === '/') { + return function (filename) { + return filename; + }; + } + else { + const separatorExpression = new RegExp(pathUtil.sep.replace('\\', '\\\\'), 'g'); + return function (filename) { + return filename.replace(separatorExpression, '/'); + }; + } + })(); + /** + * A helper function that takes TypeScript diagnostic errors and returns an error + * object. + * @param diagnostics The array of TypeScript Diagnostic objects + */ + function getError(diagnostics) { + let message = 'Declaration generation failed'; + diagnostics.forEach(function (diagnostic) { + // not all errors have an associated file: in particular, problems with a + // the tsconfig.json don't; the messageText is enough to diagnose in those + // cases. + if (diagnostic.file) { + const position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); + message += + `\n${diagnostic.file.fileName}(${position.line + 1},${position.character + 1}): ` + + `error TS${diagnostic.code}: ${diagnostic.messageText}`; + } + else { + message += `\nerror TS${diagnostic.code}: ${diagnostic.messageText}`; + } + }); + const error = new Error(message); + error.name = 'EmitterError'; + return error; + } + function getFilenames(baseDir, files) { + return files.map(function (filename) { + const resolvedFilename = pathUtil.resolve(filename); + if (resolvedFilename.indexOf(baseDir) === 0) { + return resolvedFilename; + } + return pathUtil.resolve(baseDir, filename); + }); + } + function processTree(sourceFile, replacer) { + let code = ''; + let cursorPosition = 0; + function skip(node) { + cursorPosition = node.end; + } + function readThrough(node) { + code += sourceFile.text.slice(cursorPosition, node.pos); + cursorPosition = node.pos; + } + function visit(node) { + readThrough(node); + const replacement = replacer(node); + if (replacement != null) { + code += replacement; + skip(node); + } + else { + ts.forEachChild(node, visit); + } + } + visit(sourceFile); + code += sourceFile.text.slice(cursorPosition); + return code; + } + /** + * Load and parse a TSConfig File + * @param options The dts-generator options to load config into + * @param fileName The path to the file + */ + function getTSConfig(fileName) { + // TODO this needs a better design than merging stuff into options. + // the trouble is what to do when no tsconfig is specified... + const configText = fs.readFileSync(fileName, { encoding: 'utf8' }); + const result = ts.parseConfigFileTextToJson(fileName, configText); + if (result.error) { + throw getError([result.error]); + } + const configObject = result.config; + const configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, pathUtil.dirname(fileName)); + if (configParseResult.errors && configParseResult.errors.length) { + throw getError(configParseResult.errors); + } + return [ + configParseResult.fileNames, + configParseResult.options + ]; + } + function isNodeKindImportDeclaration(value) { + return value && value.kind === ts.SyntaxKind.ImportDeclaration; + } + function isNodeKindExternalModuleReference(value) { + return value && value.kind === ts.SyntaxKind.ExternalModuleReference; + } + function isNodeKindStringLiteral(value) { + return value && value.kind === ts.SyntaxKind.StringLiteral; + } + function isNodeKindExportDeclaration(value) { + return value && value.kind === ts.SyntaxKind.ExportDeclaration; + } + function isNodeKindExportAssignment(value) { + return value && value.kind === ts.SyntaxKind.ExportAssignment; + } + function isNodeKindModuleDeclaration(value) { + return value && value.kind === ts.SyntaxKind.ModuleDeclaration; + } + function generate(options) { + if (Boolean(options.main) !== Boolean(options.name)) { + if (Boolean(options.name)) { + // since options.name used to do double duty as the prefix, let's be + // considerate and point out that name should be replaced with prefix. + // TODO update this error message when we finalize which version this change + // will be released in. + throw new Error(`name and main must be used together. Perhaps you want prefix instead of + name? In dts-generator version 2.1, name did double duty as the option to + use to prefix module names with, but in >=2.2 the name option was split + into two; prefix is what is now used to prefix imports and module names + in the output.`); + } + else { + throw new Error('name and main must be used together.'); + } + } + const noop = function () { }; + const sendMessage = options.sendMessage || noop; + const verboseMessage = options.verbose ? sendMessage : noop; + let compilerOptions = {}; + let files = options.files; + /* following tsc behaviour, if a project is specified, or if no files are specified then + * attempt to load tsconfig.json */ + if (options.project || !options.files || options.files.length === 0) { + verboseMessage(`project = "${options.project || options.baseDir}"`); + // if project isn't specified, use baseDir. If it is and it's a directory, + // assume we want tsconfig.json in that directory. If it is a file, though + // use that as our tsconfig.json. This allows for projects that have more + // than one tsconfig.json file. + let tsconfigFilename; + if (Boolean(options.project)) { + if (fs.lstatSync(options.project).isDirectory()) { + tsconfigFilename = pathUtil.join(options.project, 'tsconfig.json'); + } + else { + // project isn't a diretory, it's a file + tsconfigFilename = options.project; + } + } + else { + tsconfigFilename = pathUtil.join(options.baseDir, 'tsconfig.json'); + } + if (fs.existsSync(tsconfigFilename)) { + verboseMessage(` parsing "${tsconfigFilename}"`); + [files, compilerOptions] = getTSConfig(tsconfigFilename); + } + else { + sendMessage(`No "tsconfig.json" found at "${tsconfigFilename}"!`); + return new Promise(function ({}, reject) { + reject(new SyntaxError('Unable to resolve configuration.')); + }); + } + } + const eol = options.eol || os.EOL; + const nonEmptyLineStart = new RegExp(eol + '(?!' + eol + '|$)', 'g'); + const indent = options.indent === undefined ? '\t' : options.indent; + // use input values if tsconfig leaves any of these undefined. + // this is for backwards compatibility + compilerOptions.declaration = true; + compilerOptions.target = compilerOptions.target || ts.ScriptTarget.Latest; // is this necessary? + compilerOptions.moduleResolution = compilerOptions.moduleResolution || options.moduleResolution; + compilerOptions.outDir = compilerOptions.outDir || options.outDir; + // TODO should compilerOptions.baseDir come into play? + const baseDir = pathUtil.resolve(compilerOptions.rootDir || options.project || options.baseDir); + const outDir = compilerOptions.outDir; + verboseMessage(`baseDir = "${baseDir}"`); + verboseMessage(`target = ${compilerOptions.target}`); + verboseMessage(`outDir = ${compilerOptions.outDir}`); + verboseMessage(`rootDir = ${compilerOptions.rootDir}`); + verboseMessage(`moduleResolution = ${compilerOptions.moduleResolution}`); + const filenames = getFilenames(baseDir, files); + verboseMessage('filenames:'); + filenames.forEach(name => { verboseMessage(' ' + name); }); + const excludesMap = {}; + options.exclude = options.exclude || ['node_modules/**/*.d.ts']; + options.exclude && options.exclude.forEach(function (filename) { + glob.sync(filename, { cwd: baseDir }).forEach(function (globFileName) { + excludesMap[filenameToMid(pathUtil.resolve(baseDir, globFileName))] = true; + }); + }); + if (options.exclude) { + verboseMessage('exclude:'); + options.exclude.forEach(name => { verboseMessage(' ' + name); }); + } + if (!options.stdout) mkdirp.sync(pathUtil.dirname(options.out)); + /* node.js typings are missing the optional mode in createWriteStream options and therefore + * in TS 1.6 the strict object literal checking is throwing, therefore a hammer to the nut */ + const output = options.stdout || fs.createWriteStream(options.out, { mode: parseInt('644', 8) }); + const host = ts.createCompilerHost(compilerOptions); + const program = ts.createProgram(filenames, compilerOptions, host); + function writeFile(filename, data) { + // Compiler is emitting the non-declaration file, which we do not care about + if (filename.slice(-DTSLEN) !== '.d.ts') { + return; + } + writeDeclaration(ts.createSourceFile(filename, data, compilerOptions.target, true), true); + } + let declaredExternalModules = []; + return new Promise(function (resolve, reject) { + output.on('close', () => { resolve(undefined); }); + output.on('error', reject); + if (options.externs) { + options.externs.forEach(function (path) { + sendMessage(`Writing external dependency ${path}`); + output.write(`/// ` + eol); + }); + } + if (options.types) { + options.types.forEach(function (type) { + sendMessage(`Writing external @types package dependency ${type}`); + output.write(`/// ` + eol); + }); + } + sendMessage('processing:'); + let mainExportDeclaration = false; + let mainExportAssignment = false; + let foundMain = false; + program.getSourceFiles().forEach(function (sourceFile) { + processTree(sourceFile, function (node) { + if (isNodeKindModuleDeclaration(node)) { + const name = node.name; + if (isNodeKindStringLiteral(name)) { + declaredExternalModules.push(name.text); + } + } + return null; + }); + }); + program.getSourceFiles().some(function (sourceFile) { + // Source file is a default library, or other dependency from another project, that should not be included in + // our bundled output + if (pathUtil.normalize(sourceFile.fileName).indexOf(baseDir + pathUtil.sep) !== 0) { + return; + } + if (excludesMap[filenameToMid(pathUtil.normalize(sourceFile.fileName))]) { + return; + } + sendMessage(` ${sourceFile.fileName}`); + // Source file is already a declaration file so should does not need to be pre-processed by the emitter + if (sourceFile.fileName.slice(-DTSLEN) === '.d.ts') { + writeDeclaration(sourceFile, false); + return; + } + // We can optionally output the main module if there's something to export. + if (options.main && options.main === (options.prefix + filenameToMid(sourceFile.fileName.slice(baseDir.length, -3)))) { + foundMain = true; + ts.forEachChild(sourceFile, function (node) { + mainExportDeclaration = mainExportDeclaration || isNodeKindExportDeclaration(node); + mainExportAssignment = mainExportAssignment || isNodeKindExportAssignment(node); + }); + } + const emitOutput = program.emit(sourceFile, writeFile); + if (emitOutput.emitSkipped || emitOutput.diagnostics.length > 0) { + reject(getError(emitOutput.diagnostics + .concat(program.getSemanticDiagnostics(sourceFile)) + .concat(program.getSyntacticDiagnostics(sourceFile)) + .concat(program.getDeclarationDiagnostics(sourceFile)))); + return true; + } + }); + if (options.main && !foundMain) { + throw new Error(`main module ${options.main} was not found`); + } + if (options.main) { + output.write(`declare module '${options.name}' {` + eol + indent); + if (compilerOptions.target >= ts.ScriptTarget.ES2015) { + if (mainExportAssignment) { + output.write(`export {default} from '${options.main}';` + eol + indent); + } + if (mainExportDeclaration) { + output.write(`export * from '${options.main}';` + eol); + } + } + else { + output.write(`import main = require('${options.main}');` + eol + indent); + output.write('export = main;' + eol); + } + output.write('}' + eol); + sendMessage(`Aliased main module ${options.name} to ${options.main}`); + } + if (!options.stdout) { + sendMessage(`output to "${options.out}"`); + output.end(); + } + }); + function writeDeclaration(declarationFile, isOutput) { + // resolving is important for dealting with relative outDirs + const filename = pathUtil.resolve(declarationFile.fileName); + // use the outDir here, not the baseDir, because the declarationFiles are + // outputs of the build process; baseDir points instead to the inputs. + // However we have to account for .d.ts files in our inputs that this code + // is also used for. Also if no outDir is used, the compiled code ends up + // alongside the source, so use baseDir in that case too. + const outputDir = (isOutput && Boolean(outDir)) ? pathUtil.resolve(outDir) : baseDir; + const sourceModuleId = filenameToMid(filename.slice(outputDir.length + 1, -DTSLEN)); + const currentModuleId = filenameToMid(filename.slice(outputDir.length + 1, -DTSLEN)); + function resolveModuleImport(moduleId) { + const isDeclaredExternalModule = declaredExternalModules.indexOf(moduleId) !== -1; + let resolved; + if (options.resolveModuleImport) { + resolved = options.resolveModuleImport({ + importedModuleId: moduleId, + currentModuleId: currentModuleId, + isDeclaredExternalModule: isDeclaredExternalModule + }); + } + if (!resolved) { + // resolve relative imports relative to the current module id. + if (moduleId.charAt(0) === '.') { + resolved = filenameToMid(pathUtil.join(pathUtil.dirname(sourceModuleId), moduleId)); + } + else { + resolved = moduleId; + } + // prefix the import with options.prefix, so that both non-relative imports + // and relative imports end up prefixed with options.prefix. We only + // do this when no resolveModuleImport function is given so that that + // function has complete control of the imports that get outputed. + // NOTE: we may want to revisit the isDeclaredExternalModule behavior. + // discussion is on https://github.com/SitePen/dts-generator/pull/94 + // but currently there's no strong argument against this behavior. + if (Boolean(options.prefix) && !isDeclaredExternalModule) { + resolved = `${options.prefix}/${resolved}`; + } + } + return resolved; + } + /* For some reason, SourceFile.externalModuleIndicator is missing from 1.6+, so having + * to use a sledgehammer on the nut */ + if (declarationFile.externalModuleIndicator) { + let resolvedModuleId = sourceModuleId; + if (options.resolveModuleId) { + const resolveModuleIdResult = options.resolveModuleId({ + currentModuleId: currentModuleId + }); + if (resolveModuleIdResult) { + resolvedModuleId = resolveModuleIdResult; + } + else if (options.prefix) { + resolvedModuleId = `${options.prefix}/${resolvedModuleId}`; + } + } + else if (options.prefix) { + resolvedModuleId = `${options.prefix}/${resolvedModuleId}`; + } + output.write('declare module \'' + resolvedModuleId + '\' {' + eol + indent); + const content = processTree(declarationFile, function (node) { + if (isNodeKindExternalModuleReference(node)) { + // TODO figure out if this branch is possible, and if so, write a test + // that covers it. + const expression = node.expression; + // convert both relative and non-relative module names in import = require(...) + // statements. + const resolved = resolveModuleImport(expression.text); + return ` require('${resolved}')`; + } + else if (node.kind === ts.SyntaxKind.DeclareKeyword) { + return ''; + } + else if (isNodeKindStringLiteral(node) && node.parent && + (isNodeKindExportDeclaration(node.parent) || isNodeKindImportDeclaration(node.parent))) { + // This block of code is modifying the names of imported modules + const text = node.text; + const resolved = resolveModuleImport(text); + if (resolved) { + return ` '${resolved}'`; + } + } + }); + output.write(content.replace(nonEmptyLineStart, '$&' + indent)); + output.write(eol + '}' + eol); + } + else { + output.write(declarationFile.text); + } + } + } + exports.default = generate; +}); + +const prelude = `declare type bool = boolean; +declare type i8 = number; +declare type i16 = number; +declare type i32 = number; +declare type isize = number; +declare type u8 = number; +declare type u16 = number; +declare type u32 = number; +declare type usize = number; +declare type f32 = number; +declare type f64 = number; +declare module 'assemblyscript' { + export * from 'assemblyscript/src/index'; +} +`; + +var path = require("path"); +var fs = require("fs"); +var stdout = fs.createWriteStream(path.resolve(__dirname, "..", "dist", "assemblyscript.d.ts")); +stdout.write(prelude); +stdout.write = (function(_write) { + return function(...args) { + if (typeof args[0] === "string") { + args[0] = args[0].replace(/\/\/\/ ]*>\r?\n/g, ""); + } + return _write.apply(stdout, args); + }; +})(stdout.write); + +module.exports.default({ + project: path.resolve(__dirname, "..", "src"), + prefix: "assemblyscript", + exclude: [ + "glue/js/index.ts", + "glue/js/node.d.ts" + ], + verbose: true, + sendMessage: console.log, + stdout: stdout +}); diff --git a/src/tsconfig.json b/src/tsconfig.json index 1917198b..1dc9d5da 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../std/portable.json", "compilerOptions": { "outDir": "../out", + "allowJs": false, "sourceMap": true }, "include": [ diff --git a/tests/compiler.js b/tests/compiler.js index bbfebc59..e0ca9bb6 100644 --- a/tests/compiler.js +++ b/tests/compiler.js @@ -357,7 +357,7 @@ function testInstantiate(basename, binaryBuffer, name) { console.log(colorsUtil.white(" [exit " + code + "]\n")); } }); - let leakCount = rtr.leakCount; + let leakCount = rtr.check(); if (leakCount) { let msg = "memory leak detected: " + leakCount + " leaking"; console.log("- " + colorsUtil.red("rtrace " + name + " ERROR: ") + msg);