From 9b8ef4e193956e1963abcfb4bcc5e3f026c163ee Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 18 Nov 2019 00:24:45 +0000 Subject: [PATCH] Release v0.8.1 --- dist/asc.js | 2 +- dist/asc.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/asc.js b/dist/asc.js index ff1ae758be..c4467aacc4 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__12__){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=5)}([function(n,e,t){var r,i;e.nextTick=function(n){var e=Array.prototype.slice.call(arguments);e.shift(),setTimeout((function(){n.apply(null,e)}),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}function r(n,e){if(n.filter)return n.filter(e);for(var t=[],r=0;r=-1&&!i;a--){var o=a>=0?arguments[a]:n.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(e=o+"/"+e,i="/"===o.charAt(0))}return(i?"/":"")+(e=t(r(e.split("/"),(function(n){return!!n})),!i).join("/"))||"."},e.normalize=function(n){var a=e.isAbsolute(n),o="/"===i(n,-1);return(n=t(r(n.split("/"),(function(n){return!!n})),!a).join("/"))||a||(n="."),n&&o&&(n+="/"),(a?"/":"")+n},e.isAbsolute=function(n){return"/"===n.charAt(0)},e.join=function(){var n=Array.prototype.slice.call(arguments,0);return e.normalize(r(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("/")),a=r(t.split("/")),o=Math.min(i.length,a.length),s=o,l=0;l=1;--a)if(47===(e=n.charCodeAt(a))){if(!i){r=a;break}}else i=!1;return-1===r?t?"/":".":t&&1===r?"/":n.slice(0,r)},e.basename=function(n,e){var t=function(n){"string"!=typeof n&&(n+="");var e,t=0,r=-1,i=!0;for(e=n.length-1;e>=0;--e)if(47===n.charCodeAt(e)){if(!i){t=e+1;break}}else-1===r&&(i=!1,r=e+1);return-1===r?"":n.slice(t,r)}(n);return e&&t.substr(-1*e.length)===e&&(t=t.substr(0,t.length-e.length)),t},e.extname=function(n){"string"!=typeof n&&(n+="");for(var e=-1,t=0,r=-1,i=!0,a=0,o=n.length-1;o>=0;--o){var s=n.charCodeAt(o);if(47!==s)-1===r&&(i=!1,r=o+1),46===s?-1===e?e=o:1!==a&&(a=1):-1!==e&&(a=-1);else if(!i){t=o+1;break}}return-1===e||-1===r||0===a||1===a&&e===r-1&&e===t+1?"":n.slice(e,r)};var i="b"==="ab".substr(-1)?function(n,e,t){return n.substr(e,t)}:function(n,e,t){return e<0&&(e=n.length+e),n.substr(e,t)}}).call(this,t(0))},function(n,e){},function(n,e){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(n){"object"==typeof window&&(t=window)}n.exports=t},function(n,e){function t(n){var e=new Error("Cannot find module '"+n+"'");throw e.code="MODULE_NOT_FOUND",e}t.keys=function(){return[]},t.resolve=t,n.exports=t,t.id=4},function(n,e,t){n.exports=t(6)},function(module,exports,__webpack_require__){"use strict";(function(process,global){process.browser&&(process.cwd=function(){return"."});const fs=__webpack_require__(2),path=__webpack_require__(1),utf8=__webpack_require__(7),colorsUtil=__webpack_require__(8),optionsUtil=__webpack_require__(9),mkdirp=__webpack_require__(10),find=__webpack_require__(11),EOL="win32"===process.platform?"\r\n":"\n",SEP="win32"===process.platform?"\\":"/";process.removeAllListeners&&process.removeAllListeners("uncaughtException");var assemblyscript,isDev=!1;function checkDiagnostics(n,e){for(var t,r=!1;null!=(t=assemblyscript.nextDiagnostic(n));)e&&e.write(assemblyscript.formatDiagnostic(t,e.isTTY,!0)+EOL+EOL),assemblyscript.isError(t)&&(r=!0);return r}function createStats(){return{readTime:0,readCount:0,writeTime:0,writeCount:0,parseTime:0,parseCount:0,compileTime:0,compileCount:0,emitTime:0,emitCount:0,validateTime:0,validateCount:0,optimizeTime:0,optimizeCount:0}}function measure(n){const e=process.hrtime();n();const t=process.hrtime(e);return 1e9*t[0]+t[1]}function formatTime(n){return n?(n/1e6).toFixed(3)+" ms":"N/A"}function printStats(n,e){function t(n,e){return formatTime(n)}(e||process.stdout).write(["I/O Read : "+t(n.readTime,n.readCount),"I/O Write : "+t(n.writeTime,n.writeCount),"Parse : "+t(n.parseTime,n.parseCount),"Compile : "+t(n.compileTime,n.compileCount),"Emit : "+t(n.emitTime,n.emitCount),"Validate : "+t(n.validateTime,n.validateCount),"Optimize : "+t(n.optimizeTime,n.optimizeCount)].join(EOL)+EOL)}function printRTTI(n,e){e||(e=process.stderr),e.write("# Runtime type information (RTTI)\n"),e.write(assemblyscript.buildRTTI(n))}(()=>{try{assemblyscript=__webpack_require__(12)}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"),skipIgnore:!0}),__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.message=e_ts.stack+"\n---\n"+n.stack,n}}}})(),exports.isBundle=!0,exports.isDev=isDev,exports.version=exports.isBundle?"0.8.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__(13),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 { ArrayBufferView } from "./arraybuffer";\nimport { joinBooleanArray, joinIntegerArray, joinFloatArray, joinStringArray, joinReferenceArray } from "./util/string";\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).byteLength;\n if (minSize > oldCapacity >>> alignLog2) {\n if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n let oldData = changetype(changetype(array).buffer);\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(array, __retain(newData), offsetof("buffer"));\n store(array, newData, offsetof("dataStart"));\n }\n store(array, newCapacity, offsetof("byteLength"));\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 uninitialized null values\n // whenever an element is accessed. Otherwise, the compiler wouldn\'t be able to guarantee\n // 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 WARNING("\'Array.create\' is deprecated. Use \'new Array\' instead, making sure initial elements are initialized.");\n var array = new Array(capacity);\n array.length = 0;\n return array;\n }\n\n constructor(length: i32 = 0) {\n super(length, alignof());\n this.length_ = length;\n }\n\n get length(): i32 {\n return this.length_;\n }\n\n set length(newLength: i32) {\n var oldLength = this.length_;\n if (isManaged()) {\n if (oldLength > newLength) { // release no longer used refs\n let dataStart = this.dataStart;\n let cur = dataStart + (newLength << alignof());\n let end = dataStart + (oldLength << alignof());\n do __release(load(cur));\n while ((cur += sizeof()) < end);\n } else {\n ensureSize(changetype(this), newLength, alignof());\n }\n } else {\n ensureSize(changetype(this), newLength, alignof());\n }\n this.length_ = newLength;\n }\n\n every(fn: (value: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (!fn(load(this.dataStart + (index << alignof())), index, this)) return false;\n }\n return true;\n }\n\n findIndex(predicate: (value: 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 (index >= this.length_) throw new RangeError(E_INDEXOUTOFRANGE);\n var value = this.__unchecked_get(index);\n if (isReference()) {\n if (!isNullable()) {\n if (!changetype(value)) throw new Error(E_HOLEYARRAY);\n }\n }\n return value;\n }\n\n @unsafe @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 if (index >= this.length_) {\n if (index < 0) throw new RangeError(E_INDEXOUTOFRANGE);\n ensureSize(changetype(this), index + 1, alignof());\n this.length_ = index + 1;\n }\n this.__unchecked_set(index, value);\n }\n\n @unsafe @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = this.dataStart + (index << alignof());\n let oldRef = 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 (isManaged()) {\n for (; start < end; ++start) {\n let oldRef: usize = load(dataStart + (start << alignof()));\n if (changetype(value) != oldRef) {\n store(dataStart + (start << alignof()), __retain(changetype(value)));\n __release(oldRef);\n }\n }\n } else 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(value: T, fromIndex: i32 = 0): bool {\n if (isFloat()) {\n let length = this.length_;\n if (length == 0 || fromIndex >= length) return false;\n if (fromIndex < 0) fromIndex = max(length + fromIndex, 0);\n let dataStart = this.dataStart;\n while (fromIndex < length) {\n let elem = load(dataStart + (fromIndex << alignof()));\n // @ts-ignore\n if (elem == value || isNaN(elem) & isNaN(value)) return true;\n ++fromIndex;\n }\n return false;\n } else {\n return this.indexOf(value, fromIndex) >= 0;\n }\n }\n\n indexOf(value: 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())) == value) return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(value: 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())) == value) 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 store(this.dataStart + (length << alignof()), __retain(changetype(value)));\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 (isManaged()) {\n if (from < to && to < (from + count)) { // right to left\n from += count - 1;\n to += count - 1;\n while (count) {\n let oldRef: usize = load(dataStart + (to << alignof()));\n let newRef: usize = load(dataStart + (from << alignof()));\n if (newRef != oldRef) {\n store(dataStart + (to << alignof()), __retain(newRef));\n __release(oldRef);\n }\n --from, --to, --count;\n }\n } else { // left to right\n while (count) {\n let oldRef: usize = load(dataStart + (to << alignof()));\n let newRef: usize = load(dataStart + (from << alignof()));\n if (newRef != oldRef) {\n store(dataStart + (to << alignof()), __retain(newRef));\n __release(oldRef);\n }\n ++from, ++to, --count;\n }\n }\n } else {\n memory.copy( // is memmove\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; // no need to retain -> is moved\n }\n\n forEach(fn: (value: T, index: i32, array: Array) => void): void {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n fn(load(this.dataStart + (index << alignof())), index, this);\n }\n }\n\n map(fn: (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 = fn(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(fn: (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 (fn(value, index, this)) result.push(value);\n }\n return result;\n }\n\n reduce(\n fn: (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 = fn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n reduceRight(\n fn: (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 = fn(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; // no need to retain -> is moved\n }\n\n some(fn: (value: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (fn(load(this.dataStart + (index << alignof())), index, this)) return true;\n }\n return false;\n }\n\n unshift(value: 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(value)));\n } else {\n store(dataStart, value);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n slice(start: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n start = start < 0 ? max(start + length, 0) : min(start, length);\n end = end < 0 ? max(end + length, 0) : min(end , length);\n length = max(end - start, 0);\n var slice = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var sliceBase = slice.dataStart;\n var thisBase = this.dataStart + (start << 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 // no need to retain -> is moved\n memory.copy(\n resultStart,\n thisBase,\n deleteCount << alignof()\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 var dataStart = this.dataStart;\n var length = this.length_;\n if (isBoolean()) return joinBooleanArray(dataStart, length, separator);\n if (isInteger()) return joinIntegerArray(dataStart, length, separator);\n if (isFloat()) return joinFloatArray(dataStart, length, separator);\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (isString()) return joinStringArray(dataStart, length, separator);\n }\n // For rest objects and arrays use general join routine\n if (isReference()) return joinReferenceArray(dataStart, length, separator);\n ERROR("unspported element type");\n return unreachable();\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.length_ << alignof());\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n // automatically visits ArrayBufferView (.buffer) 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 readonly buffer: ArrayBuffer;\n @unsafe readonly dataStart: usize;\n readonly byteLength: i32;\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.buffer));\n }\n\n get length(): i32 {\n ERROR("missing implementation: subclasses must implement ArrayBufferView#length");\n return unreachable();\n }\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 memory.fill(buffer, 0, length);\n this.buffer = changetype(buffer); // retains\n this.dataStart = buffer;\n this.byteLength = length;\n }\n}\n\n@sealed export class ArrayBuffer {\n\n static isView(value: T): bool {\n if (isNullable()) {\n if (value === null) return false;\n }\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 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',atomics:'import { ArrayBufferView } from "./arraybuffer";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\n\nexport namespace Atomics {\n\n // @ts-ignore: decorator\n @inline\n export function load(array: T, index: i32): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.load>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function store(array: T, index: i32, value: valueof): void {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n atomic.store>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function add(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.add>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function sub(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.sub>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function and(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.and>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function or(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.or>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function xor(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.xor>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function exchange(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.xchg>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function compareExchange(\n array: T,\n index: i32,\n expectedValue: valueof,\n replacementValue: valueof\n ): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.cmpxchg>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n expectedValue,\n replacementValue\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function wait(array: T, value: valueof, timeout: i64 = -1): AtomicWaitResult {\n return atomic.wait>(changetype(array.buffer) + array.byteOffset, value, timeout);\n }\n\n // @ts-ignore: decorator\n @inline\n export function notify(array: T, index: i32, count: i32 = -1): i32 {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.notify(changetype(array.buffer) + (index << alignof>()) + array.byteOffset, count);\n }\n\n export function isLockFree(size: usize): bool {\n return size == 1 || size == 2 || size == 4;\n }\n}\n',"bindings/console":"export declare function assert(value: anyref): void;\nexport declare function clear(): void;\nexport declare function error(value: anyref): void;\nexport declare function info(value: anyref): void;\nexport declare function log(value: anyref): void;\nexport declare function time(label: anyref): anyref;\nexport declare function timeEnd(label: anyref): void;\nexport declare function timeLog(label: anyref): void;\nexport declare function trace(): void;\nexport declare function warn(value: anyref): void;\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/Reflect":"export declare function get(target: anyref, propertyKey: anyref/*, receiver: anyref*/): anyref;\nexport declare function has(target: anyref, propertyKey: anyref): bool;\nexport declare function set(target: anyref, propertyKey: anyref, value: anyref/*, receiver: anyref*/): anyref;\nexport declare function apply(target: anyref, thisArgument: anyref, argumentsList: anyref): anyref;\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\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\n// @ts-ignore: decorator\n@builtin\nexport declare function isVoid(): boolean;\n\n// @ts-ignore\n@builtin\nexport declare function lengthof(func?: T): i32;\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@unsafe @builtin\nexport declare function load(ptr: usize, immOffset?: usize, immAlign?: usize): T;\n\n// @ts-ignore: decorator\n@unsafe @builtin\nexport declare function store(ptr: 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\n@builtin\nexport declare function nameof(): string;\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@unsafe @builtin\nexport declare function unchecked(expr: T): T;\n\n// @ts-ignore: decorator\n@unsafe @builtin\nexport declare function call_indirect(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@unsafe @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 @unsafe @builtin\n export declare function load(ptr: usize, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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 @unsafe @builtin\n export declare function xchg(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @unsafe @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 // @ts-ignore: decorator\n @builtin\n export declare function fence(): void;\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(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store8(ptr: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store16(ptr: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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(ptr: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(ptr: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(ptr: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store8(ptr: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store16(ptr: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_s(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(ptr: 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 @unsafe @builtin\n export declare function store8(ptr: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store16(ptr: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store32(ptr: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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(ptr: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(ptr: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(ptr: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(ptr: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store8(ptr: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store16(ptr: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store32(ptr: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg(ptr: 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(ptr: 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 @unsafe @builtin\n export declare function store(ptr: 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(ptr: 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 @unsafe @builtin\n export declare function store(ptr: 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 swizzle(a: v128, s: v128): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_ext(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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 andnot(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;\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 dot(a: v128, b: v128): v128; // i16 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_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function narrow(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfma(v1: v128, v2: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfms(v1: v128, v2: v128, c: 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 min_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_u(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 // @ts-ignore: decorator\n @builtin\n export declare function narrow_i16x8_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function narrow_i16x8_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 min_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_u(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 // @ts-ignore: decorator\n @builtin\n export declare function narrow_i32x4_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function narrow_i32x4_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low_i8x16_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low_i8x16_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high_i8x16_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high_i8x16_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8x8_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8x8_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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 min_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function dot_i16x8_s(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_sat_f32x4_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_sat_f32x4_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low_i16x8_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low_i16x8_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high_i16x8_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high_i16x8_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16x4_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16x4_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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_sat_f64x2_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_sat_f64x2_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32x2_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32x2_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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_i32x4_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_i32x4_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfma(a: v128, b: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfms(a: v128, b: v128, c: 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_i64x2_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_i64x2_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfma(a: v128, b: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfms(a: v128, b: v128, c: 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 // @ts-ignore: decorator\n @builtin\n export declare function swizzle(a: v128, s: v128): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n}\n\nexport namespace v16x8 {\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n}\n\nexport namespace v32x4 {\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n}\n\nexport namespace v64x2 {\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: u32, immAlign?: u32): 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',compat:"\nexport type ReturnType = returnof;\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 readonly buffer: ArrayBuffer;\n @unsafe readonly dataStart: usize;\n readonly byteLength: i32;\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.buffer));\n }\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.buffer = buffer; // retains\n var dataStart = changetype(buffer) + byteOffset;\n this.dataStart = dataStart;\n this.byteLength = byteLength;\n }\n\n getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 {\n if (\n (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getInt16(byteOffset: i32, littleEndian: boolean = false): i16 {\n if (\n (byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getUint16(byteOffset: i32, littleEndian: boolean = false): u16 {\n if (\n (byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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.byteLength) 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 (byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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.byteLength) 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 (byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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 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 var value = this.__unchecked_get(index);\n if (isReference()) {\n if (!isNullable()) {\n if (!changetype(value)) throw new Error(E_HOLEYARRAY);\n }\n }\n return value;\n }\n\n @unsafe @operator("{}") private __unchecked_get(index: i32): T {\n return load(changetype(this) + (index << alignof()));\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 @unsafe @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = changetype(this) + (index << alignof());\n let oldRef = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(changetype(oldRef));\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',gc:'/// \n\n/** Garbage collector interface. */\nexport namespace gc {\n\n /** Can be set to `false` to disable automatic collection. Defaults to `true`. */\n export var auto: bool = true;\n\n /** Performs a full garbage collection cycle. */\n export function collect(): void {\n __collect();\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";\nimport { E_KEYNOTFOUND } from "util/error";\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_N = 8;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR_D = 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR_N = 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR_D = 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 @operator("[]")\n get(key: K): V {\n var entry = this.find(key, HASH(key));\n if (!entry) throw new Error(E_KEYNOTFOUND); // cannot represent `undefined`\n return entry.value;\n }\n\n @operator("[]=")\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 / FREE_FACTOR_D\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 / FREE_FACTOR_D\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 / FILL_FACTOR_D;\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 keys(): K[] {\n // FIXME: this is preliminary, needs iterators/closures\n var start = changetype(this.entries);\n var size = this.entriesOffset;\n var keys = new Array(size);\n var length = 0;\n for (let i = 0; i < size; ++i) {\n let entry = changetype>(start + i * ENTRY_SIZE());\n if (!(entry.taggedNext & EMPTY)) {\n keys.push(entry.key);\n ++length;\n }\n }\n keys.length = length;\n return keys;\n }\n\n values(): V[] {\n // FIXME: this is preliminary, needs iterators/closures\n var start = changetype(this.entries);\n var size = this.entriesOffset;\n var values = new Array(size);\n var length = 0;\n for (let i = 0; i < size; ++i) {\n let entry = changetype>(start + i * ENTRY_SIZE());\n if (!(entry.taggedNext & EMPTY)) {\n values.push(entry.value);\n ++length;\n }\n }\n values.length = length;\n return values;\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/** @internal */\n// @ts-ignore: decorator\n@lazy\nvar rempio2_y0: f64,\n rempio2_y1: f64,\n res128_hi: u64;\n\n/** @internal */\n// @ts-ignore: decorator\n@lazy\nconst PIO2_TABLE: u64[] = [\n 0x00000000A2F9836E, 0x4E441529FC2757D1, 0xF534DDC0DB629599, 0x3C439041FE5163AB,\n 0xDEBBC561B7246E3A, 0x424DD2E006492EEA, 0x09D1921CFE1DEB1C, 0xB129A73EE88235F5,\n 0x2EBB4484E99C7026, 0xB45F7E413991D639, 0x835339F49C845F8B, 0xBDF9283B1FF897FF,\n 0xDE05980FEF2F118B, 0x5A0A6D1F6D367ECF, 0x27CB09B74F463F66, 0x9E5FEA2D7527BAC7,\n 0xEBE5F17B3D0739F7, 0x8A5292EA6BFB5FB1, 0x1F8D5D0856033046, 0xFC7B6BABF0CFBC20,\n 0x9AF4361DA9E39161, 0x5EE61B086599855F, 0x14A068408DFFD880, 0x4D73273106061557\n];\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/** @internal */\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/** @internal */\n/* Helper function to eventually get bits of π/2 * |x|\n *\n * y = π/4 * (frac << clz(frac) >> 11)\n * return clz(frac)\n *\n * Right shift 11 bits to make upper half fit in `double`\n */\n// @ts-ignore: decorator\n@inline\nfunction pio2_right(q0: u64, q1: u64): u64 { // see: jdh8/metallic/blob/master/src/math/double/rem_pio2.c\n /* Bits of π/4 */\n const p0: u64 = 0xC4C6628B80DC1CD1;\n const p1: u64 = 0xC90FDAA22168C234;\n\n const Ox1p_64 = reinterpret(0x3BF0000000000000); // 0x1p-64\n const Ox1p_75 = reinterpret(0x3B40000000000000); // 0x1p-75\n\n var shift = clz(q1);\n\n q1 = q1 << shift | q0 >> (64 - shift);\n q0 <<= shift;\n\n var lo = umuldi(p1, q1);\n var hi = res128_hi;\n\n var ahi = hi >> 11;\n var alo = lo >> 11 | hi << 53;\n var blo = (Ox1p_75 * p0 * q1 + Ox1p_75 * p1 * q0);\n\n rempio2_y0 = (ahi + u64(lo < blo));\n rempio2_y1 = Ox1p_64 * (alo + blo);\n\n return shift;\n}\n\n/** @internal */\n// @ts-ignore: decorator\n@inline\nfunction umuldi(u: u64, v: u64): u64 {\n var u1: u64 , v1: u64, w0: u64, w1: u64, t: u64;\n\n u1 = u & 0xFFFFFFFF;\n v1 = v & 0xFFFFFFFF;\n\n u >>= 32;\n v >>= 32;\n\n t = u1 * v1;\n w0 = t & 0xFFFFFFFF;\n t = u * v1 + (t >> 32);\n w1 = t >> 32;\n t = u1 * v + (t & 0xFFFFFFFF);\n\n res128_hi = u * v + w1 + (t >> 32);\n return (t << 32) + w0;\n}\n\n/** @internal */\nfunction pio2_large_quot(x: f64, u: i64): i32 { // see: jdh8/metallic/blob/master/src/math/double/rem_pio2.c\n const bits = PIO2_TABLE.dataStart;\n\n var magnitude = u & 0x7FFFFFFFFFFFFFFF;\n var offset = (magnitude >> 52) - 1045;\n var shift = offset & 63;\n var tblPtr = bits + ((offset >> 6) << 3);\n var s0: u64, s1: u64, s2: u64;\n\n var b0 = load(tblPtr, 0 << 3);\n var b1 = load(tblPtr, 1 << 3);\n var b2 = load(tblPtr, 2 << 3);\n\n /* Get 192 bits of 0x1p-31 / π with `offset` bits skipped */\n if (shift) {\n let rshift = 64 - shift;\n let b3 = load(tblPtr, 3 << 3);\n s0 = b1 >> rshift | b0 << shift;\n s1 = b2 >> rshift | b1 << shift;\n s2 = b3 >> rshift | b2 << shift;\n } else {\n s0 = b0;\n s1 = b1;\n s2 = b2;\n }\n\n var significand = (u & 0x000FFFFFFFFFFFFF) | 0x0010000000000000;\n\n /* First 128 bits of fractional part of x/(2π) */\n var blo = umuldi(s1, significand);\n var bhi = res128_hi;\n\n var ahi = s0 * significand;\n var clo = (s2 >> 32) * (significand >> 32);\n var plo = blo + clo;\n var phi = ahi + bhi + u64(plo < clo);\n\n // r: u128 = p << 2\n var rlo = plo << 2;\n var rhi = phi << 2 | plo >> 62;\n\n // s: i128 = r >> 127\n var slo = rhi >> 63;\n var shi = slo >> 1;\n var q = (phi >> 62) - slo;\n\n var shifter = 0x3CB0000000000000 - (pio2_right(rlo ^ slo, rhi ^ shi) << 52);\n var signbit = (u ^ rhi) & 0x8000000000000000;\n var coeff = reinterpret(shifter | signbit);\n\n rempio2_y0 *= coeff;\n rempio2_y1 *= coeff;\n\n return q;\n}\n\n/** @internal */\n// @ts-ignore: decorator\n@inline\nfunction rempio2(x: f64, u: u64, sign: i32): i32 {\n const pio2_1 = reinterpret(0x3FF921FB54400000); // 1.57079632673412561417e+00\n const pio2_1t = reinterpret(0x3DD0B4611A626331); // 6.07710050650619224932e-11\n const pio2_2 = reinterpret(0x3DD0B4611A600000); // 6.07710050630396597660e-11\n const pio2_2t = reinterpret(0x3BA3198A2E037073); // 2.02226624879595063154e-21\n const pio2_3 = reinterpret(0x3BA3198A2E000000); // 2.02226624871116645580e-21\n const pio2_3t = reinterpret(0x397B839A252049C1); // 8.47842766036889956997e-32\n const invpio2 = reinterpret(0x3FE45F306DC9C883); // 0.63661977236758134308\n\n var ix = (u >> 32) & 0x7FFFFFFF;\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix < 0x4002D97C) { /* |x| < 3pi/4, special case with n=+-1 */\n let q = 1, z: f64, y0: f64, y1: f64;\n if (!sign) {\n z = x - pio2_1;\n if (ix != 0x3FF921FB) { /* 33+53 bit pi is good enough */\n y0 = z - pio2_1t;\n y1 = (z - y0) - pio2_1t;\n } else { /* near pi/2, use 33+33+53 bit pi */\n z -= pio2_2;\n y0 = z - pio2_2t;\n y1 = (z - y0) - pio2_2t;\n }\n } else { /* negative x */\n z = x + pio2_1;\n if (ix != 0x3FF921FB) { /* 33+53 bit pi is good enough */\n y0 = z + pio2_1t;\n y1 = (z - y0) + pio2_1t;\n } else { /* near pi/2, use 33+33+53 bit pi */\n z += pio2_2;\n y0 = z + pio2_2t;\n y1 = (z - y0) + pio2_2t;\n }\n q = -1;\n }\n rempio2_y0 = y0;\n rempio2_y1 = y1;\n return q;\n }\n }\n\n if (ix < 0x413921FB) { // |x| ~< 2^20*pi/2 (1647099)\n // Use precise Cody Waite scheme\n let q = nearest(x * invpio2);\n let r = x - q * pio2_1;\n let w = q * pio2_1t; // 1st round good to 85 bit\n let j = ix >> 20;\n let y0 = r - w;\n let hi = (reinterpret(y0) >> 32);\n let i = j - ((hi >> 20) & 0x7FF);\n\n if (i > 16) { // 2nd iteration needed, good to 118\n let t = r;\n w = q * pio2_2;\n r = t - w;\n w = q * pio2_2t - ((t - r) - w);\n y0 = r - w;\n hi = (reinterpret(y0) >> 32);\n i = j - ((hi >> 20) & 0x7FF);\n if (i > 49) { // 3rd iteration need, 151 bits acc\n let t = r;\n w = q * pio2_3;\n r = t - w;\n w = q * pio2_3t - ((t - r) - w);\n y0 = r - w;\n }\n }\n let y1 = (r - y0) - w;\n rempio2_y0 = y0;\n rempio2_y1 = y1;\n return q;\n }\n var q = pio2_large_quot(x, u);\n return select(-q, q, sign);\n}\n\n/** @internal */\n// @ts-ignore: decorator\n@inline\nfunction sin_kern(x: f64, y: f64, iy: i32): f64 { // see: musl/tree/src/math/__sin.c\n const S1 = reinterpret(0xBFC5555555555549); // -1.66666666666666324348e-01\n const S2 = reinterpret(0x3F8111111110F8A6); // 8.33333333332248946124e-03\n const S3 = reinterpret(0xBF2A01A019C161D5); // -1.98412698298579493134e-04\n const S4 = reinterpret(0x3EC71DE357B1FE7D); // 2.75573137070700676789e-06\n const S5 = reinterpret(0xBE5AE5E68A2B9CEB); // -2.50507602534068634195e-08\n const S6 = reinterpret(0x3DE5D93A5ACFD57C); // 1.58969099521155010221e-10\n\n var z = x * x;\n var w = z * z;\n var r = S2 + z * (S3 + z * S4) + z * w * (S5 + z * S6);\n var v = z * x;\n if (!iy) {\n return x + v * (S1 + z * r);\n } else {\n return x - ((z * (0.5 * y - v * r) - y) - v * S1);\n }\n}\n\n/** @internal */\n// @ts-ignore: decorator\n@inline\nfunction cos_kern(x: f64, y: f64): f64 { // see: musl/tree/src/math/__cos.c\n const C1 = reinterpret(0x3FA555555555554C); // 4.16666666666666019037e-02\n const C2 = reinterpret(0xBF56C16C16C15177); // -1.38888888888741095749e-03\n const C3 = reinterpret(0x3EFA01A019CB1590); // 2.48015872894767294178e-05\n const C4 = reinterpret(0xBE927E4F809C52AD); // -2.75573143513906633035e-07\n const C5 = reinterpret(0x3E21EE9EBDB4B1C4); // 2.08757232129817482790e-09\n const C6 = reinterpret(0xBDA8FAE9BE8838D4); // -1.13596475577881948265e-11\n\n var z = x * x;\n var w = z * z;\n var r = z * (C1 + z * (C2 + z * C3)) + w * w * (C4 + z * (C5 + z * C6));\n var hz = 0.5 * z;\n w = 1.0 - hz;\n return w + (((1.0 - w) - hz) + (z * r - x * y));\n}\n\n/** @internal */\nfunction tan_kern(x: f64, y: f64, iy: i32): f64 { // see: src/lib/msun/src/k_tan.c\n const T0 = reinterpret(0x3FD5555555555563); // 3.33333333333334091986e-01\n const T1 = reinterpret(0x3FC111111110FE7A); // 1.33333333333201242699e-01\n const T2 = reinterpret(0x3FABA1BA1BB341FE); // 5.39682539762260521377e-02\n const T3 = reinterpret(0x3F9664F48406D637); // 2.18694882948595424599e-02\n const T4 = reinterpret(0x3F8226E3E96E8493); // 8.86323982359930005737e-03\n const T5 = reinterpret(0x3F6D6D22C9560328); // 3.59207910759131235356e-03\n const T6 = reinterpret(0x3F57DBC8FEE08315); // 1.45620945432529025516e-03\n const T7 = reinterpret(0x3F4344D8F2F26501); // 5.88041240820264096874e-04\n const T8 = reinterpret(0x3F3026F71A8D1068); // 2.46463134818469906812e-04\n const T9 = reinterpret(0x3F147E88A03792A6); // 7.81794442939557092300e-05\n const T10 = reinterpret(0x3F12B80F32F0A7E9); // 7.14072491382608190305e-05\n const T11 = reinterpret(0xBEF375CBDB605373); // -1.85586374855275456654e-05\n const T12 = reinterpret(0x3EFB2A7074BF7AD4); // 2.59073051863633712884e-05\n\n const one = reinterpret(0x3FF0000000000000); // 1.00000000000000000000e+00\n const pio4 = reinterpret(0x3FE921FB54442D18); // 7.85398163397448278999e-01\n const pio4lo = reinterpret(0x3C81A62633145C07); // 3.06161699786838301793e-17\n\n var z: f64, r: f64, v: f64, w: f64, s: f64;\n var hx = (reinterpret(x) >> 32); /* high word of x */\n var ix = hx & 0x7FFFFFFF; /* high word of |x| */\n var big = ix >= 0x3FE59428;\n if (big) { /* |x| >= 0.6744 */\n if (hx < 0) { x = -x, y = -y; }\n z = pio4 - x;\n w = pio4lo - y;\n x = z + w;\n y = 0.0;\n }\n z = x * x;\n w = z * z;\n r = T1 + w * (T3 + w * (T5 + w * (T7 + w * (T9 + w * T11))));\n v = z * (T2 + w * (T4 + w * (T6 + w * (T8 + w * (T10 + w * T12)))));\n s = z * x;\n r = y + z * (s * (r + v) + y);\n r += T0 * s;\n w = x + r;\n if (big) {\n v = iy;\n return (1 - ((hx >> 30) & 2)) * (v - 2.0 * (x - (w * w / (w + v) - r)));\n }\n if (iy == 1) return w;\n var a: f64, t: f64;\n z = w;\n z = reinterpret(reinterpret(z) & 0xFFFFFFFF00000000);\n v = r - (z - x); /* z + v = r + x */\n t = a = -one / w; /* a = -1.0 / w */\n t = reinterpret(reinterpret(t) & 0xFFFFFFFF00000000);\n s = one + t * z;\n return t + a * (s + t * v);\n}\n\n/** @internal */\nfunction dtoi32(x: f64): i32 {\n if (ASC_SHRINK_LEVEL > 0) {\n const inv32 = 1.0 / 4294967296;\n return (x - 4294967296 * floor(x * inv32));\n } else {\n let result = 0;\n let u = reinterpret(x);\n let e = (u >> 52) & 0x7FF;\n if (e <= 1023 + 30) {\n result = x;\n } else if (e <= 1023 + 30 + 53) {\n let v = (u & ((1 << 52) - 1)) | (1 << 52);\n v = v << e - 1023 - 52 + 32;\n result = (v >> 32);\n result = select(-result, result, u >> 63);\n }\n return result;\n }\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 @lazy\n export var sincos_sin: f64 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_cos: f64 = 0;\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 y = builtin_abs(x);\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 let t = m & 2 ? 3 * PI / 4 : PI / 4;\n return m & 1 ? -t : t;\n } else {\n let t = m & 2 ? PI : 0;\n return m & 1 ? -t : t;\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(dtoi32(x));\n }\n\n export function cos(x: f64): f64 { // see: musl/src/math/cos.c\n var u = reinterpret(x);\n var ix = (u >> 32);\n var sign = ix >> 31;\n\n ix &= 0x7FFFFFFF;\n\n /* |x| ~< pi/4 */\n if (ix <= 0x3FE921FB) {\n if (ix < 0x3E46A09E) { /* |x| < 2**-27 * sqrt(2) */\n return 1.0;\n }\n return cos_kern(x, 0);\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7FF00000) return x - x;\n\n /* argument reduction needed */\n var n = rempio2(x, u, sign);\n var y0 = rempio2_y0;\n var y1 = rempio2_y1;\n\n x = n & 1 ? sin_kern(y0, y1, 1) : cos_kern(y0, y1);\n return (n + 1) & 2 ? -x : x;\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): f64 {\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 return dtoi32(x) * dtoi32(y);\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 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 assert(\n random_state0_64 != 0 && random_state1_64 != 0 &&\n random_state0_32 != 0 && random_state1_32 != 0\n );\n }\n\n export function random(): f64 { // see: v8/src/base/utils/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 >> 12) | 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 { // see: musl/src/math/sin.c\n var u = reinterpret(x);\n var ix = (u >> 32);\n var sign = ix >> 31;\n\n ix &= 0x7FFFFFFF;\n\n /* |x| ~< pi/4 */\n if (ix <= 0x3FE921FB) {\n if (ix < 0x3E500000) { /* |x| < 2**-26 */\n return x;\n }\n return sin_kern(x, 0.0, 0);\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7FF00000) return x - x;\n\n /* argument reduction needed */\n var n = rempio2(x, u, sign);\n var y0 = rempio2_y0;\n var y1 = rempio2_y1;\n\n x = n & 1 ? cos_kern(y0, y1) : sin_kern(y0, y1, 1);\n return n & 2 ? -x : x;\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 { // see: musl/src/math/tan.c\n var u = reinterpret(x);\n var ix = (u >> 32);\n var sign = ix >>> 31;\n\n ix &= 0x7FFFFFFF;\n\n /* |x| ~< pi/4 */\n if (ix <= 0x3FE921FB) {\n if (ix < 0x3E400000) { /* |x| < 2**-27 */\n return x;\n }\n return tan_kern(x, 0.0, 1);\n }\n\n /* tan(Inf or NaN) is NaN */\n if (ix >= 0x7FF00000) return x - x;\n\n var n = rempio2(x, u, sign);\n return tan_kern(rempio2_y0, rempio2_y1, 1 - ((n & 1) << 1));\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 export function sincos(x: f64): void { // see: musl/tree/src/math/sincos.c\n var u = reinterpret(x);\n var ix = (u >> 32);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3FE921FB) { /* |x| ~<= π/4 */\n if (ix < 0x3E46A09E) { /* if |x| < 2**-27 * sqrt(2) */\n sincos_sin = x;\n sincos_cos = 1;\n return;\n }\n sincos_sin = sin_kern(x, 0, 0);\n sincos_cos = cos_kern(x, 0);\n return;\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 /* general argument reduction needed */\n var n = rempio2(x, u, sign);\n var y0 = rempio2_y0;\n var y1 = rempio2_y1;\n var s = sin_kern(y0, y1, 1);\n var c = cos_kern(y0, y1);\n var sin = s, cos = c;\n if (n & 1) {\n sin = c;\n cos = -s;\n }\n if (n & 2) {\n sin = -sin;\n cos = -cos;\n }\n sincos_sin = sin;\n sincos_cos = cos;\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar rempio2f_y: f64;\n\n// @ts-ignore: decorator\n@lazy\nconst PIO2F_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 pio2f_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 = PIO2F_TABLE.dataStart;\n\n var offset = (u >> 23) - 152;\n var shift = (offset & 63);\n var tblPtr = bits + (offset >> 6 << 3);\n\n var b0 = load(tblPtr, 0 << 3);\n var b1 = load(tblPtr, 1 << 3);\n var lo: u64;\n\n if (shift > 32) {\n let b2 = load(tblPtr, 2 << 3);\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 = mantissa * hi + (mantissa * lo >> 32);\n var r: i64 = product << 2;\n var q = ((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 = pio2f_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 var y = builtin_abs(x);\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 let t: f32 = m & 2 ? 3 * pi / 4 : pi / 4;\n return m & 1 ? -t : t;\n } else {\n let t: f32 = m & 2 ? pi : 0.0;\n return m & 1 ? -t : t;\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(dtoi32(x));\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 return (dtoi32(x) * dtoi32(y));\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 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 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 /* 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 /* 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 var sin = s, cos = c;\n if (n & 1) {\n sin = c;\n cos = -s;\n }\n if (n & 2) {\n sin = -sin;\n cos = -cos;\n }\n sincos_sin = sin;\n sincos_cos = cos;\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 { strtol } from "./util/string";\n\n// @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 isNaN(value: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFinite(value: T): bool;\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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 isNaN(value);\n }\n\n static isFinite(value: f64): bool {\n return 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 isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f64 {\n return strtol(value, radix);\n }\n\n static parseFloat(value: string): f64 {\n return parseFloat(value);\n }\n\n toString(this: f64, radix: i32 = 0): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\nexport { F64 as Number };\n',object:"export class Object {\n static is(value1: T, value2: T): bool {\n if (isFloat()) {\n if (value1 == value2) {\n // 0 === -0, but they are not identical\n if (sizeof() == 8) {\n // @ts-ignore: typecast\n return reinterpret(value1) == reinterpret(value2);\n } else {\n // @ts-ignore: typecast\n return reinterpret(value1) == reinterpret(value2);\n }\n }\n // NaN !== NaN, but they are identical.\n // @ts-ignore: typecast\n return bool(i32(isNaN(value1)) & i32(isNaN(value2)));\n }\n // For references, strings, integers and booleans\n return value1 == value2;\n }\n}\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",reference:"/** Host reference abstraction. */\n@sealed @unmanaged\nexport abstract class Anyref {\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("buffer"));\n store(array, buffer, offsetof("dataStart"));\n store(array, bufferSize, offsetof("byteLength"));\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 } 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 } 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 export 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\n// @ts-ignore: decorator\n@global @unsafe\nexport function __reset(): void {\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, AL_SIZE, DEBUG } 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\nfunction maybeGrowMemory(newOffset: usize): void {\n // assumes newOffset is aligned\n var pagesBefore = memory.size();\n var maxOffset = pagesBefore << 16;\n if (newOffset > maxOffset) {\n let pagesNeeded = ((newOffset - maxOffset + 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 = newOffset;\n}\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 actualSize = max((size + AL_MASK) & ~AL_MASK, AL_SIZE);\n maybeGrowMemory(ptr + actualSize);\n var block = changetype(ptr - BLOCK_OVERHEAD);\n block.mmInfo = actualSize;\n if (DEBUG) block.gcInfo = -1;\n block.rtId = id;\n block.rtSize = size;\n return ptr;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __realloc(ptr: usize, size: usize): usize {\n assert(ptr != 0 && !(ptr & AL_MASK)); // must exist and be aligned\n var block = changetype(ptr - BLOCK_OVERHEAD);\n var actualSize = block.mmInfo;\n if (DEBUG) assert(block.gcInfo == -1);\n var isLast = ptr + actualSize == offset;\n var alignedSize = (size + AL_MASK) & ~AL_MASK;\n if (size > actualSize) {\n if (isLast) { // last block: grow\n if (size > BLOCK_MAXSIZE) unreachable();\n maybeGrowMemory(ptr + alignedSize);\n block.mmInfo = alignedSize;\n } else { // copy to new block at least double the size\n let newPtr = __alloc(max(alignedSize, actualSize << 1), block.rtId);\n memory.copy(newPtr, ptr, block.rtSize);\n block = changetype((ptr = newPtr) - BLOCK_OVERHEAD);\n }\n } else if (isLast) { // last block: shrink\n offset = ptr + alignedSize;\n block.mmInfo = alignedSize;\n }\n block.rtSize = size;\n return ptr;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __free(ptr: usize): void {\n assert(ptr != 0 && !(ptr & AL_MASK)); // must exist and be aligned\n var block = changetype(ptr - BLOCK_OVERHEAD);\n if (DEBUG) assert(block.gcInfo == -1);\n if (ptr + block.mmInfo == offset) { // last block: discard\n offset = changetype(block);\n }\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __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\nfunction __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\";\nimport { REFCOUNT_MASK } from \"./pure\";\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 - (BLOCK_OVERHEAD << 1);\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 // Here, both rounding performed in searchBlock ...\n const halfMaxSize = BLOCK_MAXSIZE >> 1;\n if (size < halfMaxSize) { // don't round last fl\n const invRound = (sizeof() * 8 - 1) - SL_BITS;\n size += (1 << (invRound - clz(size))) - 1;\n }\n // and additional BLOCK_OVERHEAD must be taken into account. If we are going\n // to merge with the tail block, that's one time, otherwise it's two times.\n var pagesBefore = memory.size();\n size += BLOCK_OVERHEAD << usize((pagesBefore << 16) - BLOCK_OVERHEAD != changetype(GETTAIL(root)));\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// @ts-ignore: decorator\n@lazy\nvar collectLock: bool = false;\n\n/** Allocates a block of the specified size. */\nexport function allocateBlock(root: Root, size: usize): Block {\n if (DEBUG) assert(!collectLock); // must not allocate while collecting\n var payloadSize = prepareSize(size);\n var block = searchBlock(root, payloadSize);\n if (!block) {\n if (gc.auto) {\n if (DEBUG) collectLock = true;\n __collect();\n if (DEBUG) collectLock = false;\n 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 } else {\n growMemory(root, payloadSize);\n block = searchBlock(root, payloadSize);\n if (DEBUG) assert(block); // must be found now\n }\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) {\n assert(\n !(blockInfo & FREE) && // must be used\n !(block.gcInfo & ~REFCOUNT_MASK) // not buffered or != BLACK\n );\n }\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.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 if (isDefined(ASC_RTRACE)) onfree(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_N = 8;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR_D = 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR_N = 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR_D = 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: T, 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 @operator("[]")\n has(key: T): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n add(key: T): 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 / FREE_FACTOR_D\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 @operator("[]=")\n private __set(key: T, value: bool): void {\n if (value) this.add(key);\n else this.delete(key);\n }\n\n delete(key: T): 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 / FREE_FACTOR_D\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 / FILL_FACTOR_D;\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 values(): T[] {\n // FIXME: this is preliminary, needs iterators/closures\n var start = changetype(this.entries);\n var size = this.entriesOffset;\n var values = new Array(size);\n var length = 0;\n for (let i = 0; i < size; ++i) {\n let entry = changetype>(start + i * ENTRY_SIZE());\n if (!(entry.taggedNext & EMPTY)) {\n values.push(entry.key);\n ++length;\n }\n }\n values.length = length;\n return values;\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_GLOBALS = 1 << 1, // see: https://github.com/WebAssembly/mutable-global\n /** Non-trapping float to integer operations. */\n NONTRAPPING_F2I = 1 << 2, // see: https://github.com/WebAssembly/nontrapping-float-to-int-conversions\n /** Bulk memory operations. */\n BULK_MEMORY = 1 << 3, // see: https://github.com/WebAssembly/bulk-memory-operations\n /** SIMD types and operations. */\n SIMD = 1 << 4, // see: https://github.com/WebAssembly/simd\n /** Threading and atomic operations. */\n THREADS = 1 << 5, // see: https://github.com/WebAssembly/threads\n /** Exception handling operations. */\n EXCEPTION_HANDLING = 1 << 6, // see: https://github.com/WebAssembly/exception-handling\n /** Tail call operations. */\n TAIL_CALLS = 1 << 7, // see: https://github.com/WebAssembly/tail-call\n /** Reference types. */\n REFERENCE_TYPES = 1 << 8 // see: https://github.com/WebAssembly/reference-types\n}\n\n/** Gets the name of the specified feature one would specify on the command line. */\nexport function featureToString(feature: Feature): string {\n switch (feature) {\n case Feature.SIGN_EXTENSION: return "sign-extension";\n case Feature.MUTABLE_GLOBALS: return "mutable-globals";\n case Feature.NONTRAPPING_F2I: return "nontrapping-f2i";\n case Feature.BULK_MEMORY: return "bulk-memory";\n case Feature.SIMD: return "simd";\n case Feature.THREADS: return "threads";\n case Feature.EXCEPTION_HANDLING: return "exception-handling";\n case Feature.TAIL_CALLS: return "tail-calls";\n case Feature.REFERENCE_TYPES: return "reference-types";\n }\n assert(false);\n return "";\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 /** Key is a signed type. */\n KEY_SIGNED = 1 << 19,\n /** Key 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, strtol, strtod, isSpace } 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 static fromCharCode(unit: i32, surr: i32 = -1): string {\n var hasSur = surr > 0;\n var out = __alloc(2 << i32(hasSur), idof());\n store(out, unit);\n if (hasSur) store(out, surr, 2);\n return changetype(out); // retains\n }\n\n static fromCodePoint(code: i32): string {\n assert(code <= 0x10FFFF);\n var hasSur = code > 0xFFFF;\n var out = __alloc(2 << i32(hasSur), idof());\n if (!hasSur) {\n store(out, code);\n } else {\n code -= 0x10000;\n let lo: u32 = (code & 0x3FF) + 0xDC00;\n let hi: u32 = (code >>> 10) + 0xD800;\n store(out, hi | (lo << 16));\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 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(search: String, end: i32 = String.MAX_LENGTH): bool {\n if (search === null) return false;\n end = min(max(end, 0), this.length);\n var searchLength = search.length;\n var searchStart = end - searchLength;\n if (searchStart < 0) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, searchStart, search, 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 includes(search: String, start: i32 = 0): bool {\n return this.indexOf(search, start) != -1;\n }\n\n indexOf(search: String, start: i32 = 0): i32 {\n var searchLen = search.length;\n if (!searchLen) return 0;\n var len = this.length;\n if (!len) return -1;\n var searchStart = min(max(start, 0), len);\n for (len -= searchLen; searchStart <= len; ++searchStart) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, searchStart, search, 0, searchLen)) return searchStart;\n }\n return -1;\n }\n\n lastIndexOf(search: String, start: i32 = i32.MAX_VALUE): i32 {\n var searchLen = search.length;\n if (!searchLen) return this.length;\n var len = this.length;\n if (!len) return -1;\n var searchStart = min(max(start, 0), len - searchLen);\n for (; searchStart >= 0; --searchStart) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, searchStart, search, 0, searchLen)) return searchStart;\n }\n return -1;\n }\n\n startsWith(search: String, start: i32 = 0): bool {\n if (search === null) search = changetype("null");\n var len = this.length;\n var searchStart = min(max(start, 0), len);\n var searchLength = search.length;\n if (searchLength + searchStart > len) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, searchStart, search, 0, searchLength);\n }\n\n substr(start: i32, length: i32 = i32.MAX_VALUE): String { // legacy\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 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 var length = this.length;\n var size: usize = length << 1;\n while (size && isSpace(load(changetype(this) + size - 2))) {\n size -= 2;\n }\n var offset: usize = 0;\n while (offset < size && isSpace(load(changetype(this) + offset))) {\n offset += 2; size -= 2;\n }\n if (!size) return changetype("");\n if (!offset && 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 var size = this.length << 1;\n var offset: usize = 0;\n while (offset < size && isSpace(load(changetype(this) + offset))) {\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 var originalSize = this.length << 1;\n var size = originalSize;\n while (size && isSpace(load(changetype(this) + size - 2))) {\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(length: i32, pad: string = " "): String {\n var thisSize = this.length << 1;\n var targetSize = length << 1;\n var padSize = pad.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(pad), padSize, repeatCount);\n memory.copy(out + restBase, changetype(pad), restSize);\n } else {\n memory.copy(out, changetype(pad), prependSize);\n }\n memory.copy(out + prependSize, changetype(this), thisSize);\n return changetype(out); // retains\n }\n\n padEnd(length: i32, pad: string = " "): String {\n var thisSize = this.length << 1;\n var targetSize = length << 1;\n var padSize = pad.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(pad), padSize, repeatCount);\n memory.copy(out + thisSize + restBase, changetype(pad), restSize);\n } else {\n memory.copy(out + thisSize, changetype(pad), appendSize);\n }\n return changetype(out); // retains\n }\n\n repeat(count: i32 = 0): String {\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 replace(search: String, replacement: String): String {\n var len: usize = this.length;\n var slen: usize = search.length;\n if (len <= slen) {\n return len < slen ? this : select(replacement, this, search == this);\n }\n var index: isize = this.indexOf(search);\n if (~index) {\n let rlen: usize = replacement.length;\n len -= slen;\n let olen = len + rlen;\n if (olen) {\n let out = __alloc(olen << 1, idof());\n memory.copy(out, changetype(this), index << 1);\n memory.copy(\n out + (index << 1),\n changetype(replacement),\n rlen << 1\n );\n memory.copy(\n out + ((index + rlen) << 1),\n changetype(this) + ((index + slen) << 1),\n (len - index) << 1\n );\n return changetype(out);\n }\n }\n return this;\n }\n\n replaceAll(search: String, replacement: String): String {\n var len: usize = this.length;\n var slen: usize = search.length;\n if (len <= slen) {\n return len < slen ? this : select(replacement, this, search == this);\n }\n var rlen: usize = replacement.length;\n if (!slen) {\n if (!rlen) return this;\n // Special case: \'abc\'.replaceAll(\'\', \'-\') -> \'-a-b-c-\'\n let out = __alloc((len + (len + 1) * rlen) << 1, idof());\n memory.copy(out, changetype(replacement), rlen << 1);\n let offset = rlen;\n for (let i: usize = 0; i < len; ++i) {\n store(\n changetype(out) + (offset++ << 1),\n load(changetype(this) + (i << 1))\n );\n memory.copy(\n out + (offset << 1),\n changetype(replacement),\n rlen << 1\n );\n offset += rlen;\n }\n return changetype(out);\n }\n var prev: isize = 0, next: isize = 0;\n if (slen == rlen) {\n // Fast path when search and replacement have same length\n let size = len << 1;\n let out = __alloc(size, idof());\n memory.copy(out, changetype(this), size);\n while (~(next = this.indexOf(search, prev))) {\n memory.copy(out + (next << 1), changetype(replacement), rlen << 1);\n prev = next + slen;\n }\n return changetype(out);\n }\n var out: usize = 0, offset: usize = 0, resLen = len;\n while (~(next = this.indexOf(search, prev))) {\n if (!out) out = __alloc(len << 1, idof());\n if (offset > resLen) {\n let newLength = resLen << 1;\n out = __realloc(out, newLength << 1);\n resLen = newLength;\n }\n let chunk = next - prev;\n memory.copy(\n out + (offset << 1),\n changetype(this) + (prev << 1),\n chunk << 1\n );\n offset += chunk;\n memory.copy(\n out + (offset << 1),\n changetype(replacement),\n rlen << 1\n );\n offset += rlen;\n prev = next + slen;\n }\n if (offset) {\n if (offset > resLen) {\n let newLength = resLen << 1;\n out = __realloc(out, newLength << 1);\n resLen = newLength;\n }\n let rest = len - prev;\n if (rest) {\n memory.copy(\n out + (offset << 1),\n changetype(this) + (prev << 1),\n rest << 1\n );\n }\n rest += offset;\n if (resLen > rest) out = __realloc(out, rest << 1);\n return changetype(out);\n }\n return this;\n }\n\n slice(start: i32, end: i32 = i32.MAX_VALUE): String {\n var len = this.length;\n start = start < 0 ? max(start + len, 0) : min(start, len);\n end = end < 0 ? max(end + len, 0) : min(end, len);\n len = end - start;\n if (len <= 0) return changetype("");\n var out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n return changetype(out); // retains\n }\n\n split(separator: String | null = null, limit: i32 = i32.MAX_VALUE): String[] {\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))) {\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\n// @ts-ignore: nolib\nexport type string = String;\n\nexport function parseInt(str: string, radix: i32 = 0): f64 {\n return strtol(str, radix);\n}\n\nexport function parseFloat(str: string): f64 {\n return strtod(str);\n}\n\n// Encoding helpers\nexport namespace String {\n\n export namespace UTF8 {\n\n export function byteLength(str: string, nullTerminated: bool = false): i32 {\n var strOff = changetype(str);\n var strEnd = strOff + changetype(changetype(str) - BLOCK_OVERHEAD).rtSize;\n var bufLen = nullTerminated ? 1 : 0;\n while (strOff < strEnd) {\n let c1 = load(strOff);\n if (c1 < 128) {\n if (nullTerminated && !c1) break;\n bufLen += 1; strOff += 2;\n } else if (c1 < 2048) {\n bufLen += 2; strOff += 2;\n } else {\n if ((c1 & 0xFC00) == 0xD800 && strOff + 2 < strEnd) {\n if ((load(strOff, 2) & 0xFC00) == 0xDC00) {\n strOff += 4; bufLen += 4;\n continue;\n }\n }\n strOff += 2; bufLen += 3;\n }\n }\n return bufLen;\n }\n\n export function encode(str: string, nullTerminated: bool = false): ArrayBuffer {\n var strOff = changetype(str);\n var strEnd = changetype(str) + changetype(changetype(str) - BLOCK_OVERHEAD).rtSize;\n var buf = __alloc(UTF8.byteLength(str, nullTerminated), idof());\n var bufOff = buf;\n while (strOff < strEnd) {\n let c1 = load(strOff);\n if (c1 < 128) {\n if (nullTerminated && !c1) break;\n store(bufOff, c1);\n bufOff += 1; strOff += 2;\n } else if (c1 < 2048) {\n store(bufOff, c1 >> 6 | 192);\n store(bufOff, c1 & 63 | 128, 1);\n bufOff += 2; strOff += 2;\n } else {\n if ((c1 & 0xFC00) == 0xD800 && strOff + 2 < strEnd) {\n let c2 = load(strOff, 2);\n if ((c2 & 0xFC00) == 0xDC00) {\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\n store(bufOff, c1 >> 18 | 240);\n store(bufOff, c1 >> 12 & 63 | 128, 1);\n store(bufOff, c1 >> 6 & 63 | 128, 2);\n store(bufOff, c1 & 63 | 128, 3);\n strOff += 4; bufOff += 4;\n continue;\n }\n }\n store(bufOff, c1 >> 12 | 224);\n store(bufOff, c1 >> 6 & 63 | 128, 1);\n store(bufOff, c1 & 63 | 128, 2);\n strOff += 2; bufOff += 3;\n }\n }\n if (nullTerminated) {\n assert(strOff <= strEnd);\n buf = __realloc(buf, bufOff - buf + 1);\n store(bufOff, 0);\n } else {\n assert(strOff == strEnd);\n }\n return changetype(buf); // retains\n }\n\n export function decode(buf: ArrayBuffer, nullTerminated: bool = false): string {\n return decodeUnsafe(changetype(buf), buf.byteLength, nullTerminated);\n }\n\n // @ts-ignore: decorator\n @unsafe\n export function decodeUnsafe(buf: usize, len: usize, nullTerminated: bool = false): string {\n var bufOff = buf;\n var bufEnd = buf + len;\n assert(bufEnd >= bufOff); // guard wraparound\n var str = __alloc(len << 1, idof()); // max is one u16 char per u8 byte\n var strOff = str;\n while (bufOff < bufEnd) {\n let cp = load(bufOff++);\n if (cp < 128) {\n if (nullTerminated && !cp) break;\n store(strOff, cp);\n strOff += 2;\n } else if (cp > 191 && cp < 224) {\n if (bufEnd - bufOff < 1) break;\n store(strOff, (cp & 31) << 6 | load(bufOff++) & 63);\n strOff += 2;\n } else if (cp > 239 && cp < 365) {\n if (bufEnd - bufOff < 3) break;\n cp = (\n (cp & 7) << 18 |\n (load(bufOff) & 63) << 12 |\n (load(bufOff, 1) & 63) << 6 |\n load(bufOff, 2) & 63\n ) - 0x10000;\n bufOff += 3;\n store(strOff, 0xD800 + (cp >> 10));\n store(strOff, 0xDC00 + (cp & 1023), 2);\n strOff += 4;\n } else {\n if (bufEnd - bufOff < 2) break;\n store(strOff,\n (cp & 15) << 12 |\n (load(bufOff) & 63) << 6 |\n load(bufOff, 1) & 63\n );\n bufOff += 2; strOff += 2;\n }\n }\n return changetype(__realloc(str, strOff - str)); // retains\n }\n }\n\n export namespace UTF16 {\n\n export function byteLength(str: string): i32 {\n return changetype(changetype(str) - BLOCK_OVERHEAD).rtSize;\n }\n\n export function encode(str: string): ArrayBuffer {\n var size = changetype(changetype(str) - BLOCK_OVERHEAD).rtSize;\n var buf = __alloc(size, idof());\n memory.copy(buf, changetype(str), size);\n return changetype(buf); // retains\n }\n\n export function decode(buf: ArrayBuffer): string {\n return decodeUnsafe(changetype(buf), buf.byteLength);\n }\n\n // @ts-ignore: decorator\n @unsafe\n export function decodeUnsafe(buf: usize, len: usize): string {\n var str = __alloc(len &= ~1, idof());\n memory.copy(str, buf, len);\n return changetype(str); // retains\n }\n }\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, E_INVALIDLENGTH } from "./util/error";\nimport { joinIntegerArray, joinFloatArray } from "./util/string";\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 length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]")\n private __get(index: i32): i8 {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): i8 {\n return load(this.dataStart + index);\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + index, value);\n }\n\n includes(searchElement: i8, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: i8, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: i8, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int8Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: i8, index: i32, self: Int8Array) => i8): Int8Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: i8, index: i32, self: Int8Array) => bool): Int8Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: i8, index: i32, self: Int8Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: i8, index: i32, self: Int8Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int8Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]")\n private __get(index: i32): u8 {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u8 {\n return load(this.dataStart + index);\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + index, value);\n }\n\n includes(searchElement: u8, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u8, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u8, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint8Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u8, index: i32, self: Uint8Array) => u8): Uint8Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u8, index: i32, self: Uint8Array) => bool): Uint8Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u8, index: i32, self: Uint8Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint8Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]")\n private __get(index: i32): u8 {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u8 {\n return load(this.dataStart + index);\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, ~(value >> 31) & (((255 - value) >> 31) | value));\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + index, ~(value >> 31) & (((255 - value) >> 31) | value));\n }\n\n includes(searchElement: u8, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u8, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u8, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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(fn: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8ClampedArray {\n return SORT(this, fn);\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return SLICE(this, begin, end);\n }\n\n subarray(start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return SUBARRAY(this, start, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u8, index: i32, self: Uint8ClampedArray) => u8): Uint8ClampedArray {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): Uint8ClampedArray {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u8, index: i32, self: Uint8ClampedArray) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint8ClampedArray {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): i16 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): i16 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: i16, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: i16, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: i16, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int16Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: i16, index: i32, self: Int16Array) => i16): Int16Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: i16, index: i32, self: Int16Array) => bool): Int16Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: i16, index: i32, self: Int16Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: i16, index: i32, self: Int16Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int16Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): u16 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u16 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: u16, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u16, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u16, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint16Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u16, index: i32, self: Uint16Array) => u16): Uint16Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u16, index: i32, self: Uint16Array) => bool): Uint16Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u16, index: i32, self: Uint16Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint16Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): i32 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): i32 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: i32): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: i32): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: i32, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: i32, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: i32, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int32Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: i32, index: i32, self: Int32Array) => i32): Int32Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: i32, index: i32, self: Int32Array) => bool): Int32Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: i32, index: i32, self: Int32Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: i32, index: i32, self: Int32Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int32Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): u32 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u32 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: u32): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: u32): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: u32, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u32, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u32, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint32Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u32, index: i32, self: Uint32Array) => u32): Uint32Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u32, index: i32, self: Uint32Array) => bool): Uint32Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u32, index: i32, self: Uint32Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint32Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): i64 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): i64 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: i64): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: i64): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: i64, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: i64, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: i64, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int64Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: i64, index: i32, self: Int64Array) => i64): Int64Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: i64, index: i32, self: Int64Array) => bool): Int64Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: i64, index: i32, self: Int64Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: i64, index: i32, self: Int64Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int64Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): u64 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u64 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: u64): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: u64): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: u64, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u64, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u64, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint64Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u64, index: i32, self: Uint64Array) => u64): Uint64Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u64, index: i32, self: Uint64Array) => bool): Uint64Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u64, index: i32, self: Uint64Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint64Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): f32 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): f32 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: f32): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: f32): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: f32, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: f32, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: f32, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Float32Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: f32, index: i32, self: Float32Array) => f32): Float32Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: f32, index: i32, self: Float32Array) => bool): Float32Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: f32, index: i32, self: Float32Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: f32, index: i32, self: Float32Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinFloatArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Float32Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): f64 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): f64 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: f64): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: f64): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: f64, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: f64, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: f64, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Float64Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: f64, index: i32, self: Float64Array) => f64): Float64Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: f64, index: i32, self: Float64Array) => bool): Float64Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: f64, index: i32, self: Float64Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: f64, index: i32, self: Float64Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinFloatArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Float64Array {\n return WRAP(buffer, byteOffset, length);\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 len = array.length;\n start = start < 0 ? max(len + start, 0) : min(start, len);\n end = end < 0 ? max(len + end, 0) : min(end, len);\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 len = array.length;\n if (len <= 1) return array;\n var base = array.dataStart;\n if (len == 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, len, comparator);\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SLICE(\n array: TArray,\n start: i32,\n end: i32\n): TArray {\n var len = array.length;\n start = start < 0 ? max(start + len, 0) : min(start, len);\n end = end < 0 ? max(end + len, 0) : min(end , len);\n len = max(end - start, 0);\n var slice = instantiate(len);\n memory.copy(\n slice.dataStart,\n array.dataStart + (start << alignof()),\n len << alignof()\n );\n return slice;\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\n var out = __alloc(offsetof(), idof());\n store(out, __retain(changetype(array.buffer)), offsetof("buffer"));\n store(out, array.dataStart + (begin << alignof()), offsetof("dataStart"));\n store(out, (end - begin) << alignof(), offsetof("byteLength"));\n return changetype(out); // retains\n}\n\n// @ts-ignore: decorator\n@inline\nfunction COPY_WITHIN(\n array: TArray,\n target: i32,\n start: i32,\n end: i32\n): TArray {\n var len = array.length;\n var dataStart = array.dataStart;\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 memory.copy(\n dataStart + (to << alignof()),\n dataStart + (from << alignof()),\n count << alignof()\n );\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE(\n array: TArray,\n fn: (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 = fn(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 fn: (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 = fn(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 fn: (value: T, index: i32, self: TArray) => T,\n): TArray {\n var len = array.length;\n var dataStart = array.dataStart;\n\n var byteLength = len << alignof();\n var out = __alloc(offsetof(), idof());\n var buffer = __alloc(byteLength, idof());\n for (let i = 0; i < len; i++) {\n store(\n buffer + (i << alignof()),\n fn(load(dataStart + (i << alignof())), i, array)\n );\n }\n store(out, __retain(buffer), offsetof("buffer"));\n store(out, buffer, offsetof("dataStart"));\n store(out, byteLength, offsetof("byteLength"));\n return changetype(out); // retains\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FILTER(\n array: TArray,\n fn: (value: T, index: i32, self: TArray) => bool,\n): TArray {\n var len = array.length;\n var out = __alloc(offsetof(), idof());\n var buffer = __alloc(len << alignof(), idof());\n var dataStart = array.dataStart;\n var j: usize = 0;\n for (let i = 0; i < len; i++) {\n let value = load(dataStart + (i << alignof()));\n if (fn(value, i, array)) {\n store(\n buffer + (j++ << alignof()),\n value\n );\n }\n }\n // shrink output buffer\n var byteLength = j << alignof();\n var data = __realloc(buffer, byteLength);\n store(out, __retain(data), offsetof("buffer"));\n store(out, byteLength, offsetof("byteLength"));\n store(out, data, offsetof("dataStart"));\n return changetype(out); // retains\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FIND_INDEX(\n array: TArray,\n fn: (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 (fn(load(dataStart + (i << alignof())), i, array)) return i;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction INCLUDES(\n array: TArray,\n searchElement: T,\n fromIndex: i32,\n): bool {\n if (isFloat()) {\n let index: isize = fromIndex;\n let length: isize = array.length;\n if (length == 0 || index >= length) return false;\n if (index < 0) index = max(length + index, 0);\n let dataStart = array.dataStart;\n while (index < length) {\n let elem = load(dataStart + (index << alignof()));\n // @ts-ignore\n if (elem == searchElement || isNaN(elem) & isNaN(searchElement)) return true;\n ++index;\n }\n return false;\n } else {\n return INDEX_OF(array, searchElement, fromIndex) >= 0;\n }\n}\n\n// @ts-ignore: decorator\n@inline\nfunction INDEX_OF(\n array: TArray,\n searchElement: T,\n fromIndex: i32,\n): i32 {\n var index: isize = fromIndex;\n var length: isize = array.length;\n if (length == 0 || index >= length) return -1;\n if (index < 0) index = max(length + index, 0);\n var dataStart = array.dataStart;\n while (index < length) {\n if (load(dataStart + (index << alignof())) == searchElement) return index;\n ++index;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction LAST_INDEX_OF(\n array: TArray,\n searchElement: T,\n fromIndex: i32,\n): i32 {\n var index: isize = fromIndex;\n var length: isize = array.length;\n if (length == 0) return -1;\n if (index < 0) index = length + index; // no need to clamp\n else if (index >= length) index = length - 1;\n var dataStart = array.dataStart;\n while (index >= 0) {\n if (load(dataStart + (index << alignof())) == searchElement) return index;\n --index;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SOME(\n array: TArray,\n fn: (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 (fn(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 fn: (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 (fn(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 fn: (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 fn(load(dataStart + (i << alignof())), i, array);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REVERSE(array: TArray): TArray {\n var dataStart = array.dataStart;\n for (let front: usize = 0, back: usize = 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\n// @ts-ignore: decorator\n@inline\nfunction WRAP(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): TArray {\n var bufferByteLength = buffer.byteLength;\n if (byteOffset >= bufferByteLength) {\n throw new RangeError(E_INDEXOUTOFRANGE);\n }\n var byteLength: i32;\n if (length < 0) {\n if (length == -1) {\n const mask = (1 << alignof() - 1);\n if (buffer.byteLength & mask) {\n throw new RangeError(E_INVALIDLENGTH);\n } else {\n byteLength = buffer.byteLength;\n }\n } else {\n throw new RangeError(E_INVALIDLENGTH);\n }\n } else {\n byteLength = length << alignof();\n }\n if (byteOffset + byteLength > buffer.byteLength) {\n throw new RangeError(E_INVALIDLENGTH);\n }\n var out = __alloc(offsetof(), idof());\n store(out, __retain(changetype(buffer)), offsetof("buffer"));\n store(out, byteLength, offsetof("byteLength"));\n store(out, changetype(buffer) + byteOffset, offsetof("dataStart"));\n return changetype(out); // retains\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\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_KEYNOTFOUND: string = "Key does not exist";\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 {\n if (vl == vr) return 0;\n if (ASC_SHRINK_LEVEL < 2) {\n if ((vl & 7) == (vr & 7)) {\n while (vl & 7) {\n if (!n) return 0;\n let a = load(vl);\n let b = load(vr);\n if (a != b) return a - b;\n n--; vl++; vr++;\n }\n while (n >= 8) {\n if (load(vl) != load(vr)) break;\n vl += 8;\n vr += 8;\n n -= 8;\n }\n }\n }\n while (n--) {\n let a = load(vl);\n let b = load(vr);\n if (a != b) return a - b;\n vl++; vr++;\n }\n return 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 let m = select(11, 12, value < 100000000000);\n return select(10, m, value < 10000000000);\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":'import { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./number";\nimport { ipow32 } from "../math";\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 I = 0x49,\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\n// 9 * 8 = 72 bytes\n// @ts-ignore: decorator\n@lazy\nconst Powers10Hi: f64[] = [1, 1e32, 1e64, 1e96, 1e128, 1e160, 1e192, 1e224, 1e256, 1e288];\n// 32 * 8 = 256 bytes\n// @ts-ignore: decorator\n@lazy\nconst Powers10Lo: f64[] = [\n 1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09,\n 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,\n 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29,\n 1e30, 1e31\n];\n\nexport function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 {\n var ptr1 = changetype(str1) + (index1 << 1);\n var ptr2 = changetype(str2) + (index2 << 1);\n if (ASC_SHRINK_LEVEL < 2) {\n if (len >= 4 && !((ptr1 & 7) | (ptr2 & 7))) {\n do {\n if (load(ptr1) != load(ptr2)) break;\n ptr1 += 8;\n ptr2 += 8;\n len -= 4;\n } while (len >= 4);\n }\n }\n while (len--) {\n let a = load(ptr1);\n let b = load(ptr2);\n if (a != b) return a - b;\n ptr1 += 2;\n ptr2 += 2;\n }\n return 0;\n}\n\nexport function isSpace(c: i32): bool {\n if (c <= 0xFF) {\n // , , , , , and \n return c == 0x20 || (c - 0x09) <= 0x0D - 0x09 || c == 0xA0;\n }\n if ((c - 0x2000) <= 0x200A - 0x2000) return true;\n switch (c) {\n case 0x1680: // (1)\n case 0x2028: // (2)\n case 0x2029: // \n case 0x202F: // \n case 0x205F: // \n case 0x3000: // \n case 0xFEFF: return true; // \n }\n return false;\n}\n\n/** Parses a string to an integer (usually), using the specified radix. */\nexport function strtol(str: string, radix: i32 = 0): T {\n var len = str.length;\n if (!len) {\n // @ts-ignore: cast\n if (isFloat()) return NaN;\n // @ts-ignore: cast\n return 0;\n }\n\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr);\n\n // determine sign\n // @ts-ignore: cast\n var sign: T = 1;\n // trim white spaces\n while (isSpace(code)) {\n code = load(ptr += 2);\n --len;\n }\n if (code == CharCode.MINUS) {\n if (!--len) {\n // @ts-ignore: cast\n if (isFloat()) return NaN;\n // @ts-ignore: cast\n return 0;\n }\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len) {\n // @ts-ignore: cast\n if (isFloat()) return NaN;\n // @ts-ignore: cast\n return 0;\n }\n code = load(ptr += 2);\n }\n\n // determine radix\n if (!radix) {\n if (code == CharCode._0 && len > 2) {\n switch (load(ptr + 2) | 32) {\n case CharCode.b: {\n ptr += 4; len -= 2;\n radix = 2;\n break;\n }\n case CharCode.o: {\n ptr += 4; len -= 2;\n radix = 8;\n break;\n }\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 if (isFloat()) return NaN;\n // @ts-ignore: cast\n return 0;\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 < 10) {\n code -= CharCode._0;\n } else if (code - CharCode.A <= (CharCode.Z - CharCode.A)) {\n code -= CharCode.A - 10;\n } else if (code - CharCode.a <= (CharCode.z - CharCode.a)) {\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\nexport function strtod(str: string): f64 {\n var len = str.length;\n if (!len) return NaN;\n\n var ptr = changetype(str);\n var code = load(ptr);\n\n var sign = 1.;\n // skip white spaces\n while (len && isSpace(code)) {\n code = load(ptr += 2);\n --len;\n }\n if (!len) return NaN;\n\n // try parse \'-\' or \'+\'\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 }\n\n // try parse Infinity\n if (len >= 8 && code == CharCode.I) {\n if (\n load(ptr, 0) == 0x690066006E0049 && // ifnI\n load(ptr, 8) == 0x7900740069006E // ytin\n ) {\n return copysign(Infinity, sign);\n }\n return NaN;\n }\n // validate next symbol\n if (code != CharCode.DOT && (code - CharCode._0) >= 10) {\n return NaN;\n }\n var savedPtr = ptr;\n // skip zeros\n while (code == CharCode._0) {\n code = load(ptr += 2);\n --len;\n }\n if (len <= 0) return 0;\n const capacity = 19; // int(64 * 0.3010)\n var pointed = false;\n var consumed = 0;\n var position = 0;\n var x: u64 = 0;\n if (code == CharCode.DOT) {\n let noDigits = !(savedPtr - ptr);\n ptr += 2; --len;\n if (!len && noDigits) return NaN;\n for (pointed = true; (code = load(ptr)) == CharCode._0; --position, ptr += 2) --len;\n if (len <= 0) return 0;\n if (!position && noDigits && code - CharCode._0 >= 10) return NaN;\n }\n for (let digit = code - CharCode._0; digit < 10 || (code == CharCode.DOT && !pointed); digit = code - CharCode._0) {\n if (digit < 10) {\n x = consumed < capacity ? 10 * x + digit : x | u64(!!digit);\n ++consumed;\n } else {\n position = consumed;\n pointed = true;\n }\n if (!--len) break;\n code = load(ptr += 2);\n }\n\n if (!pointed) position = consumed;\n return copysign(scientific(x, position - min(capacity, consumed) + parseExp(ptr, len)), sign);\n}\n\nexport function joinBooleanArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\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\nexport function joinIntegerArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\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\nexport function joinFloatArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\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\nexport function joinStringArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\n if (!lastIndex) {\n // @ts-ignore: type\n return load(dataStart) || "";\n }\n var estLen = 0;\n var value: string;\n for (let i = 0; i < length; ++i) {\n value = load(dataStart + (i << alignof()));\n // @ts-ignore: type\n if (value !== null) estLen += value.length;\n }\n var offset = 0;\n var sepLen = separator.length;\n var result = __alloc((estLen + sepLen * lastIndex) << 1, idof());\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) {\n let valueLen = value.length;\n memory.copy(\n result + (offset << 1),\n changetype(value),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n 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 result + (offset << 1),\n changetype(value),\n value.length << 1\n );\n }\n return changetype(result); // retains\n}\n\nexport function joinReferenceArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\n var value: T;\n if (!lastIndex) {\n value = load(dataStart);\n // @ts-ignore: type\n return value !== null ? value.toString() : "";\n }\n var result = "";\n var sepLen = separator.length;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n // @ts-ignore: type\n if (value !== null) result += value.toString();\n if (sepLen) result += separator;\n }\n value = load(dataStart + (lastIndex << alignof()));\n // @ts-ignore: type\n if (value !== null) result += value.toString();\n return result;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction scientific(significand: u64, exp: i32): f64 {\n if (!significand || exp < -342) return 0;\n if (exp > 308) return Infinity;\n // Try use fast path\n // Use fast path for string-to-double conversion if possible\n // see http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion\n // Simple integer\n var significandf = significand;\n if (!exp) return significandf;\n if (exp > 22 && exp <= 22 + 15) {\n significandf *= pow10(exp - 22);\n exp = 22;\n }\n if (significand <= 9007199254740991 && abs(exp) <= 22) {\n if (exp > 0) return significandf * pow10(exp);\n return significandf / pow10(-exp);\n } else if (exp < 0) {\n return scaledown(significand, exp);\n } else {\n return scaleup(significand, exp);\n }\n}\n\n// Adopted from metallic lib:\n// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h\n// @ts-ignore: decorator\n@inline\nfunction scaledown(significand: u64, exp: i32): f64 {\n const denom: u64 = 6103515625; // 1e14 * 0x1p-14\n const scale = reinterpret(0x3F06849B86A12B9B); // 1e-14 * 0x1p32\n\n var shift = clz(significand);\n significand <<= shift;\n shift = exp - shift;\n\n for (; exp <= -14; exp += 14) {\n let q = significand / denom;\n let r = significand % denom;\n let s = clz(q);\n significand = (q << s) + nearest(scale * (r << (s - 18)));\n shift -= s;\n }\n var b = ipow32(5, -exp);\n var q = significand / b;\n var r = significand % b;\n var s = clz(q);\n significand = (q << s) + (reinterpret(reinterpret(r) + (s << 52)) / b);\n shift -= s;\n\n return NativeMath.scalbn(significand, shift);\n}\n\n// Adopted from metallic lib:\n// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h\n// @ts-ignore: decorator\n@inline\nfunction scaleup(significand: u64, exp: i32): f64 {\n const coeff: u32 = 1220703125; // 1e13 * 0x1p-13;\n var shift = ctz(significand);\n significand >>= shift;\n shift += exp;\n\n __fixmulShift = shift;\n for (; exp >= 13; exp -= 13) {\n significand = fixmul(significand, coeff);\n }\n significand = fixmul(significand, ipow32(5, exp));\n shift = __fixmulShift;\n return NativeMath.scalbn(significand, shift);\n}\n\n// Adopted from metallic lib:\n// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h\n// @ts-ignore: decorator\n@inline\nfunction parseExp(ptr: usize, len: i32): i32 {\n var sign = 1, magnitude = 0;\n var code = load(ptr);\n // check code is \'e\' or \'E\'\n if ((code | 32) != CharCode.e) return 0;\n\n code = load(ptr += 2);\n if (code == CharCode.MINUS) {\n if (!--len) return 0;\n code = load(ptr += 2);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len) return 0;\n code = load(ptr += 2);\n }\n // skip zeros\n while (code == CharCode._0) {\n if (!--len) return 0;\n code = load(ptr += 2);\n }\n for (let digit: u32 = code - CharCode._0; len && digit < 10; digit = code - CharCode._0) {\n if (magnitude >= 3200) return sign * 3200;\n magnitude = 10 * magnitude + digit;\n code = load(ptr += 2);\n --len;\n }\n return sign * magnitude;\n}\n\n// @ts-ignore: decorator\n@lazy\nvar __fixmulShift: u64 = 0;\n\n// Adopted from metallic lib:\n// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h\n// @ts-ignore: decorator\n@inline\nfunction fixmul(a: u64, b: u32): u64 {\n var low = (a & 0xFFFFFFFF) * b;\n var high = (a >> 32) * b + (low >> 32);\n var overflow = (high >> 32);\n var space = clz(overflow);\n var revspace: u64 = 32 - space;\n __fixmulShift += revspace;\n return (high << space | (low & 0xFFFFFFFF) >> revspace) + (low << space >> 31 & 1);\n}\n\n// @ts-ignore: decorator\nfunction pow10(n: i32): f64 {\n // @ts-ignore: type\n const hi = Powers10Hi.dataStart;\n // @ts-ignore: type\n const lo = Powers10Lo.dataStart;\n return (\n load(hi + ((n >> 5) << alignof())) *\n load(lo + ((n & 31) << alignof()))\n );\n}\n',vector:"/** Vector abstraction. */\n@sealed @unmanaged\nexport abstract class V128 {\n}\n"}):(()=>{const n=path.join(".","..","std","assembly"),e={};return find.files(n,find.TS_EXCEPT_DTS).forEach(t=>e[t.replace(/\.ts$/,"")]=fs.readFileSync(path.join(n,t),"utf8")),e})(),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/** A host reference. */\ndeclare type anyref = 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 sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n/** Whether the mutable globals feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBALS: bool;\n/** Whether the non-trapping float-to-int feature is enabled. */\ndeclare const ASC_FEATURE_NONTRAPPING_F2I: 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/** Whether the exception handling feature is enabled. */\ndeclare const ASC_FEATURE_EXCEPTION_HANDLING: bool;\n/** Whether the tail calls feature is enabled. */\ndeclare const ASC_FEATURE_TAIL_CALLS: bool;\n/** Whether the reference types feature is enabled. */\ndeclare const ASC_FEATURE_REFERENCE_TYPES: 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 end offset of the given class type. Compiles to a constant. */\ndeclare function offsetof(): usize;\n/** Determines the offset of the specified field within the given class type. Compiles to a constant. */\ndeclare function offsetof(fieldName: keyof T | string): 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 name of a given type. */\ndeclare function nameof(value?: T): string;\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/** Tests if the specified type is void. Compiles to a constant. */\ndeclare function isVoid(): 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 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/** Returns the number of parameters in the given function signature type. */\ndeclare function lengthof any>(func?: T): i32;\n\n/** Atomic operations. */\ndeclare namespace atomic {\n /** Atomically loads an integer value from memory and returns it. */\n export function load(ptr: usize, immOffset?: usize): T;\n /** Atomically stores an integer value to memory. */\n export function store(ptr: 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 /** Performs a fence operation, preserving synchronization guarantees of higher level languages. */\n export function fence(): void;\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(ptr: 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(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 32-bit integer value from memory. */\n export function load(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(ptr: 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(ptr: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory. */\n export function store(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize): i32;\n /** Atomically loads a 32-bit integer value from memory and returns it. */\n export function load(ptr: usize, immOffset?: usize): i32;\n /** Atomically stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(ptr: 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(ptr: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory. */\n export function store(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts a 32-bit integer value in memory. */\n export function sub(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 32-bit integer value in memory. */\n export function and(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 32-bit integer value in memory. */\n export function or(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 32-bit integer value in memory. */\n export function xor(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 32-bit integer value in memory. */\n export function xchg(ptr: 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(ptr: 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(ptr: 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(ptr: 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(ptr: 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(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 64-bit unsigned integer value from memory. */\n export function load(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory. */\n export function store(ptr: 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(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize): i64;\n /** Atomically loads a 64-bit integer value from memory and returns it. */\n export function load(ptr: usize, immOffset?: usize): i64;\n /** Atomically stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory. */\n export function store(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 16-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 32-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 32-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 64-bit integer value in memory. */\n export function sub(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 64-bit integer value in memory. */\n export function xchg(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): f32;\n /** Stores a 32-bit float to memory. */\n export function store(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): f64;\n /** Stores a 64-bit float to memory. */\n export function store(ptr: 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 vector with identical lanes. */\n export function splat(x: T): v128;\n /** Extracts one lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): T;\n /** Replaces one lane. */\n export function replace_lane(x: v128, idx: u8, value: T): v128;\n /** Selects lanes from either vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n /** Selects 8-bit lanes from the first vector according to the indexes [0-15] specified by the 8-bit lanes of the second vector. */\n export function swizzle(a: v128, s: v128): v128;\n /** Loads a vector from memory. */\n export function load(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n /** Creates a vector with identical lanes by loading the splatted value. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128\n /** Creates a vector by loading the lanes of the specified type and extending each to the next larger type. */\n export function load_ext(ptr: usize, immOffset?: usize, immAlign?: usize): v128\n /** Stores a vector to memory. */\n export function store(ptr: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n /** Adds each lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each lane. */\n export function mul(a: v128, b: v128): v128; // except i64\n /** Divides each lane. */\n export function div(a: v128, b: v128): v128;\n /** Negates each lane of a vector. */\n export function neg(a: v128): v128;\n /** Adds each lane using saturation. */\n export function add_saturate(a: v128, b: v128): v128;\n /** Subtracts each lane using saturation. */\n export function sub_saturate(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each lane of a vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise right shift on each lane of a vector by a scalar. */\n export function shr(a: v128, b: i32): v128;\n /** Performs the bitwise AND operation on two vectors. */\n export function and(a: v128, b: v128): v128;\n /** Performs the bitwise OR operation on two vectors. */\n export function or(a: v128, b: v128): v128;\n /** Performs the bitwise XOR operation on two vectors. */\n export function xor(a: v128, b: v128): v128;\n /** Performs the bitwise ANDNOT operation on two vectors. */\n export function andnot(a: v128, b: v128): v128;\n /** Performs the bitwise NOT operation on a vector. */\n export function not(a: v128): v128;\n /** Selects bits of either vector according to the specified mask. */\n export function bitselect(v1: v128, v2: v128, mask: v128): v128;\n /** Reduces a vector to a scalar indicating whether any lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 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. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each lane. */\n export function max(a: v128, b: v128): v128;\n /** Computes the dot product of two lanes each, yielding lanes one size wider than the input. */\n export function dot(a: v128, b: v128): v128;\n /** Computes the absolute value of each lane. */\n export function abs(a: v128): v128;\n /** Computes the square root of each lane. */\n export function sqrt(a: v128): v128;\n /** Computes which lanes are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which lanes of the first vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 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 vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 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 vector from integer to floating point. */\n export function convert(a: v128): v128;\n /** Truncates each lane of a vector from floating point to integer with saturation. Takes the target type. */\n export function trunc_sat(a: v128): v128;\n /** Narrows each lane to their respective narrower lanes. */\n export function narrow(a: v128, b: v128): v128;\n /** Widens the low lanes of a vector to their respective wider lanes. */\n export function widen_low(a: v128): v128;\n /** Widens the high lanes of a vector to their respective wider lanes. */\n export function widen_high(a: v128): v128;\n /** Computes `(a * b) + c` for each lane. */\n export function qfma(a: v128, b: v128, c: v128): v128;\n /** Computes `(a * b) - c` for each lane. */\n export function qfms(a: v128, b: v128, c: 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 as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i8;\n /** Extracts one 8-bit integer lane as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u8;\n /** Replaces one 8-bit integer lane. */\n export function replace_lane(x: v128, idx: u8, value: i8): v128;\n /** Adds each 8-bit integer lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 8-bit integer lane. */\n export function mul(a: v128, b: v128): v128;\n /** Computes the signed minimum of each 8-bit integer lane. */\n export function min_s(a: v128, b: v128): v128;\n /** Computes the unsigned minimum of each 8-bit integer lane. */\n export function min_u(a: v128, b: v128): v128;\n /** Computes the signed maximum of each 8-bit integer lane. */\n export function max_s(a: v128, b: v128): v128;\n /** Computes the unsigned maximum of each 8-bit integer lane. */\n export function max_u(a: v128, b: v128): v128;\n /** Negates each 8-bit integer lane. */\n export function neg(a: v128): v128;\n /** Adds each 8-bit integer lane using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 8-bit integer lane using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane 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 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 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 by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 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 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 are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 8-bit integer lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 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 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 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 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 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 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 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 vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n /** Narrows each 16-bit signed integer lane to 8-bit signed integer lanes. */\n export function narrow_i16x8_s(a: v128, b: v128): v128;\n /** Narrows each 16-bit signed integer lane to 8-bit unsigned integer lanes. */\n export function narrow_i16x8_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 as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i16;\n /** Extracts one 16-bit integer lane as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u16;\n /** Replaces one 16-bit integer lane. */\n export function replace_lane(x: v128, idx: u8, value: i16): v128;\n /** Adds each 16-bit integer lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 16-bit integer lane. */\n export function mul(a: v128, b: v128): v128;\n /** Computes the signed minimum of each 16-bit integer lane. */\n export function min_s(a: v128, b: v128): v128;\n /** Computes the unsigned minimum of each 16-bit integer lane. */\n export function min_u(a: v128, b: v128): v128;\n /** Computes the signed maximum of each 16-bit integer lane. */\n export function max_s(a: v128, b: v128): v128;\n /** Computes the unsigned maximum of each 16-bit integer lane. */\n export function max_u(a: v128, b: v128): v128;\n /** Negates each 16-bit integer lane. */\n export function neg(a: v128): v128;\n /** Adds each 16-bit integer lane using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 16-bit integer lane using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane 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 by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift each 16-bit integer lane 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 by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 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 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 are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 16-bit integer lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 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 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 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 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 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 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 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 vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n /** Narrows each 32-bit signed integer lane to 16-bit signed integer lanes. */\n export function narrow_i32x4_s(a: v128, b: v128): v128;\n /** Narrows each 32-bit signed integer lane to 16-bit unsigned integer lanes. */\n export function narrow_i32x4_u(a: v128, b: v128): v128;\n /** Widens the low 8-bit signed integer lanes to 16-bit signed integer lanes. */\n export function widen_low_i8x16_s(a: v128): v128;\n /** Widens the low 8-bit unsigned integer lanes to 16-bit unsigned integer lanes. */\n export function widen_low_i8x16_u(a: v128): v128;\n /** Widens the high 8-bit signed integer lanes to 16-bit signed integer lanes. */\n export function widen_high_i8x16_s(a: v128): v128;\n /** Widens the high 8-bit unsigned integer lanes to 16-bit unsigned integer lanes. */\n export function widen_high_i8x16_u(a: v128): v128;\n /** Creates a vector with eight 16-bit integer lanes by loading and sign extending eight 8-bit integers. */\n export function load8x8_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n /** Creates a vector with eight 16-bit integer lanes by loading and zero extending eight 8-bit integers. */\n export function load8x8_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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 vector with four identical 32-bit integer lanes. */\n export function splat(x: i32): v128;\n /** Extracts one 32-bit integer lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): i32;\n /** Replaces one 32-bit integer lane. */\n export function replace_lane(x: v128, idx: u8, value: i32): v128;\n /** Adds each 32-bit integer lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit integer lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit integer lane. */\n export function mul(a: v128, b: v128): v128;\n /** Computes the signed minimum of each 32-bit integer lane. */\n export function min_s(a: v128, b: v128): v128;\n /** Computes the unsigned minimum of each 32-bit integer lane. */\n export function min_u(a: v128, b: v128): v128;\n /** Computes the signed maximum of each 32-bit integer lane. */\n export function max_s(a: v128, b: v128): v128;\n /** Computes the unsigned maximum of each 32-bit integer lane. */\n export function max_u(a: v128, b: v128): v128;\n /** Computes the dot product of two 16-bit integer lanes each, yielding 32-bit integer lanes. */\n export function dot_i16x8_s(a: v128, b: v128): v128;\n /** Negates each 32-bit integer lane. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 32-bit integer lane 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 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 by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 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 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 are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit integer lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 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 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 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 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 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 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 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 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 to a signed integer with saturation. */\n export function trunc_sat_f32x4_s(a: v128): v128;\n /** Truncates each 32-bit float lane to an unsigned integer with saturation. */\n export function trunc_sat_f32x4_u(a: v128): v128;\n /** Widens the low 16-bit signed integer lanes to 32-bit signed integer lanes. */\n export function widen_low_i16x8_s(a: v128): v128;\n /** Widens the low 16-bit unsigned integer lane to 32-bit unsigned integer lanes. */\n export function widen_low_i16x8_u(a: v128): v128;\n /** Widens the high 16-bit signed integer lanes to 32-bit signed integer lanes. */\n export function widen_high_i16x8_s(a: v128): v128;\n /** Widens the high 16-bit unsigned integer lanes to 32-bit unsigned integer lanes. */\n export function widen_high_i16x8_u(a: v128): v128;\n /** Creates a vector with four 32-bit integer lanes by loading and sign extending four 16-bit integers. */\n export function load16x4_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n /** Creates a vector with four 32-bit integer lanes by loading and zero extending four 16-bit integers. */\n export function load16x4_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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 vector with two identical 64-bit integer lanes. */\n export function splat(x: i64): v128;\n /** Extracts one 64-bit integer lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): i64;\n /** Replaces one 64-bit integer lane. */\n export function replace_lane(x: v128, idx: u8, value: i64): v128;\n /** Adds each 64-bit integer lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit integer lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit integer lane. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 64-bit integer lane. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 64-bit integer lane 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 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 by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 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 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 to a signed integer with saturation. */\n export function trunc_sat_f64x2_s(a: v128): v128;\n /** Truncates each 64-bit float lane to an unsigned integer with saturation. */\n export function trunc_sat_f64x2_u(a: v128): v128;\n /** Creates a vector with two 64-bit integer lanes by loading and sign extending two 32-bit integers. */\n export function load32x2_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n /** Creates a vector with two 64-bit integer lanes by loading and zero extending two 32-bit integers. */\n export function load32x2_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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 vector with four identical 32-bit float lanes. */\n export function splat(x: f32): v128;\n /** Extracts one 32-bit float lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): f32;\n /** Replaces one 32-bit float lane. */\n export function replace_lane(x: v128, idx: u8, value: f32): v128;\n /** Adds each 32-bit float lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit float lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit float lane. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 32-bit float lane. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 32-bit float lane. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 32-bit float lane. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 32-bit float lane. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 32-bit float lane. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 32-bit float lane. */\n export function sqrt(a: v128): v128;\n /** Computes which 32-bit float lanes are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 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 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 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 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 vector to floating point. */\n export function convert_i32x4_s(a: v128): v128;\n /** Converts each 32-bit unsigned integer lane of a vector to floating point. */\n export function convert_i32x4_u(a: v128): v128;\n /** Computes `(a * b) + c` for each 32-bit float lane. */\n export function qfma(a: v128, b: v128, c: v128): v128;\n /** Computes `(a * b) - c` for each 32-bit float lane. */\n export function qfms(a: v128, b: v128, c: 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 vector with two identical 64-bit float lanes. */\n export function splat(x: f64): v128;\n /** Extracts one 64-bit float lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): f64;\n /** Replaces one 64-bit float lane. */\n export function replace_lane(x: v128, idx: u8, value: f64): v128;\n /** Adds each 64-bit float lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit float lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit float lane. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 64-bit float lane. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 64-bit float lane. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 64-bit float lane. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 64-bit float lane. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 64-bit float lane. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 64-bit float lane. */\n export function sqrt(a: v128): v128;\n /** Computes which 64-bit float lanes are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 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 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 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 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 vector to floating point. */\n export function convert_i64x2_s(a: v128): v128;\n /** Converts each 64-bit unsigned integer lane of a vector to floating point. */\n export function convert_i64x2_u(a: v128): v128;\n /** Computes `(a * b) + c` for each 64-bit float lane. */\n export function qfma(a: v128, b: v128, c: v128): v128;\n /** Computes `(a * b) - c` for each 64-bit float lane. */\n export function qfms(a: v128, b: v128, c: v128): v128;\n}\ndeclare namespace v8x16 {\n /** Selects 8-bit lanes from either vector according to the specified [0-15] respectively [16-31] 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 /** Selects 8-bit lanes from the first vector according to the indexes [0-15] specified by the 8-bit lanes of the second vector. */\n export function swizzle(a: v128, s: v128): v128;\n /** Loads an 8-bit integer and splats it sixteen times forming a new vector. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n}\ndeclare namespace v16x8 {\n /** Loads a 16-bit integer and splats it eight times forming a new vector. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n}\ndeclare namespace v32x4 {\n /** Loads a 32-bit integer and splats it four times forming a new vector. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n}\ndeclare namespace v64x2 {\n /** Loads a 64-bit integer and splats it two times forming a new vector. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n}\n/** Macro type evaluating to the underlying native WebAssembly type. */\ndeclare type native = T;\n/** Special type evaluating the indexed access index type. */\ndeclare type indexof = keyof T;\n/** Special type evaluating the indexed access value type. */\ndeclare type valueof = T[0];\n/** A special type evaluated to the return type of T if T is a callable function. */\ndeclare type ReturnType any> = T extends (...args: any) => infer R ? R : any;\n/** A special type evaluated to the return type of T if T is a callable function. */\ndeclare type returnof any> = ReturnType;\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 interface. */\ndeclare namespace gc {\n /** Can be set to `false` to disable automatic collection. Defaults to `true`. */\n export var auto: bool;\n /** Performs a full garbage collection cycle. */\n export function collect(): 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\ndeclare namespace Atomics {\n export function load(array: TypedArray, index: i32): T;\n export function store(array: TypedArray, index: i32, value: T): void;\n export function add(array: TypedArray, index: i32, value: T): T;\n export function sub(array: TypedArray, index: i32, value: T): T;\n export function and(array: TypedArray, index: i32, value: T): T;\n export function or(array: TypedArray, index: i32, value: T): T;\n export function xor(array: TypedArray, index: i32, value: T): T;\n export function exchange(array: TypedArray, index: i32, value: T): T;\n export function compareExchange(array: TypedArray, index: i32, expectedValue: T, replacementValue: T): T;\n export function wait(array: TypedArray, value: T, timeout?: i64): AtomicWaitResult;\n export function notify(array: TypedArray, index: i32, count?: i32): i32;\n /** The static Atomics.isLockFree() method is used to determine whether to use locks or atomic operations. It returns true, if the given size is one of the BYTES_PER_ELEMENT */\n export function isLockFree(size: usize): bool;\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 /** 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 /** The includes() method determines whether a typed array includes a certain element, returning true or false as appropriate. */\n includes(searchElement: T, fromIndex?: i32): bool;\n /** The indexOf() method returns the first index at which a given element can be found in the typed array, or -1 if it is not present. */\n indexOf(searchElement: T, fromIndex?: i32): i32;\n /** The lastIndexOf() method returns the last index at which a given element can be found in the typed array, or -1 if it is not present. The typed array is searched backwards, starting at fromIndex. */\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n /** Returns copied section of an TypedArray from begin inclusive to end exclusive */\n slice(begin?: i32, end?: i32): TypedArray;\n /** Returns a new TypedArray of this type on the same ArrayBuffer from begin inclusive to end exclusive. */\n subarray(begin?: i32, end?: i32): TypedArray;\n /** The copyWithin() method copies the sequence of array elements within the array to the position starting at target. The copy is taken from the index positions of the second and third arguments start and end. The end argument is optional and defaults to the length of the array. */\n copyWithin(target: i32, start: 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(callbackfn: (accumulator: U, value: T, index: i32, self: this) => U, initialValue: U): U;\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(callbackfn: (accumulator: U, value: T, index: i32, self: this) => U, initialValue: U): U;\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): TypedArray;\n /** The filter() method creates a new typed array with all elements that pass the test implemented by the provided function. This method has the same algorithm as Array.prototype.filter(). */\n filter(callbackfn: (value: T, index: i32, self: this) => bool): TypedArray;\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 /** The join() method joins all elements of an array into a string. This method has the same algorithm as Array.prototype.join(). */\n join(separator?: string): string;\n /** The toString() method returns a string representing the specified array and its elements. This method has the same algorithm as Array.prototype.toString() */\n toString(): string;\n}\n\n/** An array of twos-complement 8-bit signed integers. */\ndeclare class Int8Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int8Array;\n}\n/** An array of 8-bit unsigned integers. */\ndeclare class Uint8Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8Array;\n}\n/** A clamped array of 8-bit unsigned integers. */\ndeclare class Uint8ClampedArray extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8ClampedArray;\n}\n/** An array of twos-complement 16-bit signed integers. */\ndeclare class Int16Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int16Array;\n}\n/** An array of 16-bit unsigned integers. */\ndeclare class Uint16Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint16Array;\n}\n/** An array of twos-complement 32-bit signed integers. */\ndeclare class Int32Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int32Array;\n}\n/** An array of 32-bit unsigned integers. */\ndeclare class Uint32Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint32Array;\n}\n/** An array of twos-complement 64-bit signed integers. */\ndeclare class Int64Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int64Array;\n}\n/** An array of 64-bit unsigned integers. */\ndeclare class Uint64Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint64Array;\n}\n/** An array of 32-bit floating point numbers. */\ndeclare class Float32Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float32Array;\n}\n/** An array of 64-bit floating point numbers. */\ndeclare class Float64Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float64Array;\n}\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\n [key: number]: T;\n /** Current length of the array. */\n length: i32;\n /** Constructs a new array. */\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 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 readonly length: i32;\n charAt(index: i32): string;\n charCodeAt(index: i32): i32;\n codePointAt(index: i32): i32;\n concat(other: string): string;\n endsWith(other: string): bool;\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 substr(start: i32, length?: i32): string;\n substring(start: i32, end?: 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 repeat(count?: i32): string;\n replace(search: string, replacement: string): string;\n replaceAll(search: string, replacement: string): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n}\n\ndeclare namespace String {\n /** Encoding helpers for UTF-8. */\n export namespace UTF8 {\n /** Calculates the byte length of the specified string when encoded as UTF-8, optionally null terminated. */\n export function byteLength(str: string, nullTerminated?: bool): i32;\n /** Encodes the specified string to UTF-8 bytes, optionally null terminated. */\n export function encode(str: string, nullTerminated?: bool): ArrayBuffer;\n /** Decodes the specified buffer from UTF-8 bytes to a string, optionally null terminated. */\n export function decode(buf: ArrayBuffer, nullTerminated?: bool): string;\n /** Decodes raw UTF-8 bytes to a string, optionally null terminated. */\n export function decodeUnsafe(buf: usize, len: usize, nullTerminated?: bool): string;\n }\n /** Encoding helpers for UTF-16. */\n export namespace UTF16 {\n /** Calculates the byte length of the specified string when encoded as UTF-16. */\n export function byteLength(str: string): i32;\n /** Encodes the specified string to UTF-16 bytes. */\n export function encode(str: string): ArrayBuffer;\n /** Decodes the specified buffer from UTF-16 bytes to a string. */\n export function decode(buf: ArrayBuffer): string;\n /** Decodes raw UTF-16 bytes to a string. */\n export function decodeUnsafe(buf: usize, len: usize): string;\n }\n}\n\ndeclare class Object {\n /** The Object.is() method determines whether two values are the same value. */\n static is(value1: T, value2: T): bool;\n}\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/** 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 {\n toString(): string;\n}\n\ninterface Number {\n toString(radix?: number): string;\n}\n\ninterface Function {}\ninterface IArguments {}\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 keys(): K[]; // preliminary\n values(): V[]; // preliminary\n toString(): string;\n}\n\ndeclare class Set {\n readonly size: i32;\n has(value: K): bool;\n add(value: K): void;\n delete(value: K): bool;\n clear(): void;\n values(): K[]; // preliminary\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): T;\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 /** Multiplies a floating point `x` by 2 raised to power exp `n`. */\n scalbn(x: T, n: i32): T;\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\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// 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/** Special type evaluating the indexed access index type. */\ndeclare type indexof = keyof T;\n/** Special type evaluating the indexed access value type. */\ndeclare type valueof = T[0];\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/** 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 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 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\ndeclare const Mathf: typeof Math;\ndeclare const JSMath: typeof Math;\n\ndeclare interface StringConstructor {\n /** Equivalent to calling `String.fromCharCode` with multiple arguments. */\n fromCharCodes(arr: u16[]): string;\n /** Equivalent to calling `String.fromCodePoint` with multiple arguments. */\n fromCodePoints(arr: i32[]): string;\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,a=e.readFile||O,o=e.writeFile||w,s=e.listFiles||C,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(a===O)throw Error("'options.readFile' must be specified");if(o===w)throw Error("'options.writeFile' must be specified");if(s===C)throw Error("'options.listFiles' must be specified")}const p=f.baseDir?path.resolve(f.baseDir):".",h=[];if(f.transform){let n=f.transform;for(let e=0,l=n.length;e{n.indexOf("/")>=0||(l.parseCount++,l.parseTime+=measure(()=>{x=assemblyscript.parseFile(exports.libraryFiles[n],exports.libraryPrefix+n+".ts",!1,x)}))});const m=[];if(f.lib){let n=f.lib;"string"==typeof n&&(n=n.split(",")),Array.prototype.push.apply(m,n.map(n=>n.trim()));for(let n=0,e=m.length;n{x=assemblyscript.parseFile(o,exports.libraryPrefix+i,!1,x)})}}}f.path=f.path||[];var v=new Map,y=new Map;function b(n,e){var t=null,r=null;if(n.startsWith(exports.libraryPrefix)){const o=n.substring(exports.libraryPrefix.length),s=o+"/index";if(exports.libraryFiles.hasOwnProperty(o))t=exports.libraryFiles[o],r=exports.libraryPrefix+o+".ts";else if(exports.libraryFiles.hasOwnProperty(s))t=exports.libraryFiles[s],r=exports.libraryPrefix+s+".ts";else{for(const n of m){if(null!=(t=a(o+".ts",n))){r=exports.libraryPrefix+o+".ts";break}if(null!=(t=a(s+".ts",n))){r=exports.libraryPrefix+s+".ts";break}}if(null==t){const o=n.match(/^~lib\/((?:@[^\/]+\/)?[^\/]+)(?:\/(.+))?/);if(o){const n=o[1],s=void 0===o[2],l=s?"index":o[2],u=y.has(e)?y.get(e):".";f.traceResolution&&i.write("Looking for package '"+n+"' file '"+l+"' relative to '"+u+"'"+EOL);const c=[];for(let n=(path.isAbsolute(u)?u:path.join(p,u)).split(SEP),e=n.length,t="/"==SEP?0:1;e>=t;--e)"node_modules"!=n[e-1]&&c.push(n.slice(0,e).join(SEP)+SEP+"node_modules");for(const e of c.concat(...f.path).map(n=>path.relative(p,n))){f.traceResolution&&i.write(" in "+path.join(e,n)+EOL);let o="assembly";if(v.has(n))o=v.get(n);else{let t=path.join(e,n,"package.json"),r=a(t,p);if(null!=r)try{let e=JSON.parse(r);"string"==typeof e.ascMain&&(o=e.ascMain.replace(/[\/\\]index\.ts$/,""),v.set(n,o))}catch(n){}}const u=path.join(e,n,o),c=l;if(null!=(t=a(path.join(u,c+".ts"),p))){r=exports.libraryPrefix+n+"/"+c+".ts",y.set(r.replace(/\.ts$/,""),path.join(e,n)),f.traceResolution&&i.write(" -> "+path.join(u,c+".ts")+EOL);break}if(!s){const o=l+"/index";if(null!==(t=a(path.join(u,o+".ts"),p))){r=exports.libraryPrefix+n+"/"+o+".ts",y.set(r.replace(/\.ts$/,""),path.join(e,n)),f.traceResolution&&i.write(" -> "+path.join(u,o+".ts")+EOL);break}}}}}}}else null==(t=a(r=n+".ts",p))&&(t=a(r=n+"/index.ts",p));return null==t?null:{sourceText:t,sourcePath:r}}function _(){for(var n;null!=(n=x.nextFile());){let e=b(n,assemblyscript.getDependee(x,n));if(!e)return t(Error("Import file '"+n+".ts' not found."));l.parseCount++,l.parseTime+=measure(()=>{assemblyscript.parseFile(e.sourceText,e.sourcePath,!1,x)})}if(checkDiagnostics(x,i))return t(Error("Parse error"))}{let n=String(f.runtime),e="rt/index-"+n,r=exports.libraryFiles[e];if(null==r){if(null==(r=a((e=n)+".ts",p)))return t(Error("Runtime '"+n+"' not found."))}else e="~lib/"+e;l.parseCount++,l.parseTime+=measure(()=>{x=assemblyscript.parseFile(r,e,!0,x)})}for(let e=0,r=n.length;e{x=assemblyscript.parseFile(o,i,!0,x)})}{let n=_();if(n)return n}{let n=g("afterParse",x);if(n)return t(n)}{let n=_();if(n)return n}const T=assemblyscript.finishParsing(x);if(f.listFiles)return i.write(T.sources.map(n=>n.normalizedPath).sort().join(EOL)+EOL),t(null);var A=0,E=0;f.optimize&&(A=exports.defaultOptimizeLevel,E=exports.defaultShrinkLevel),"number"==typeof f.optimizeLevel&&(A=f.optimizeLevel),"number"==typeof f.shrinkLevel&&(E=f.shrinkLevel),A=Math.min(Math.max(A,0),3),E=Math.min(Math.max(E,0),2);const F=assemblyscript.createOptions();if(assemblyscript.setTarget(F,0),assemblyscript.setNoAssert(F,f.noAssert),assemblyscript.setImportMemory(F,f.importMemory),assemblyscript.setSharedMemory(F,f.sharedMemory),assemblyscript.setImportTable(F,f.importTable),assemblyscript.setExplicitStart(F,f.explicitStart),assemblyscript.setMemoryBase(F,f.memoryBase>>>0),assemblyscript.setSourceMap(F,null!=f.sourceMap),assemblyscript.setOptimizeLevelHints(F,A,E),assemblyscript.setNoUnsafe(F,f.noUnsafe),assemblyscript.setGlobalAlias(F,"Math","NativeMath"),assemblyscript.setGlobalAlias(F,"Mathf","NativeMathf"),assemblyscript.setGlobalAlias(F,"abort","~lib/builtins/abort"),assemblyscript.setGlobalAlias(F,"trace","~lib/builtins/trace"),f.use){let n=f.use;for(let e=0,r=n.length;e{S=assemblyscript.compileProgram(T,F)})}catch(n){return t(n)}if(checkDiagnostics(x,i))return S&&S.dispose(),t(Error("Compile error"));{let n=g("afterCompile",S);if(n)return t(n)}if(f.validate&&(l.validateCount++,l.validateTime+=measure(()=>{if(!S.validate())return S.dispose(),t(Error("Validate error"))})),"clamp"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{S.runPasses(["trap-mode-clamp"])});else if("js"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{S.runPasses(["trap-mode-js"])});else if("allow"!==f.trapMode)return S.dispose(),t(Error("Unsupported trap mode"));(A>=3||E>=2)&&(A=4),S.setOptimizeLevel(A),S.setShrinkLevel(E),S.setDebugInfo(f.debug);var I=[];if(f.runPasses&&("string"==typeof f.runPasses&&(f.runPasses=f.runPasses.split(",")),f.runPasses.length&&f.runPasses.forEach(n=>{I.indexOf(n)<0&&I.push(n)})),(A>0||E>0)&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{S.optimize()})),I.length&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{S.runPasses(I.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,a=null!=f.sourceMap?f.sourceMap.length?f.sourceMap:path.basename(f.binaryFile)+".map":null;if(l.emitCount++,l.emitTime+=measure(()=>{r=S.toBinary(a)}),f.binaryFile.length?o(f.binaryFile,r.output,p):(L(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=assemblyscript.getSource(T,e.replace(/\.ts$/,""));if(null==i)return t(Error("Source of file '"+e+"' not found."));n.sourceContents||(n.sourceContents=[]),n.sourceContents[r]=i}),o(path.join(path.dirname(f.binaryFile),path.basename(a)).replace(/^\.\//,""),JSON.stringify(n),p)}else i.write("Skipped source map (stdout already occupied)"+EOL)}if(null!=f.asmjsFile){let t;f.asmjsFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=S.toAsmjs()}),o(f.asmjsFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=S.toAsmjs()}),L(t),n=!0),e=!0}if(null!=f.idlFile){let t;f.idlFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(T)}),o(f.idlFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(T)}),L(t),n=!0),e=!0}if(null!=f.tsdFile){let t;f.tsdFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(T)}),o(f.tsdFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(T)}),L(t),n=!0),e=!0}if(null!=f.textFile||!e){let e;f.textFile&&f.textFile.length?(l.emitCount++,l.emitTime+=measure(()=>{e=S.toText()}),o(f.textFile,e,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{e=S.toText()}),L(e))}}return S.dispose(),f.measure&&printStats(l,i),f.printrtti&&printRTTI(T,i),t(null);function O(n,e){let t=path.resolve(e,n);try{let n;return l.readCount++,l.readTime+=measure(()=>{n=fs.readFileSync(t,{encoding:"utf8"})}),n}catch(n){return null}}function w(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 C(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 null}}function L(n){L.used||(l.writeCount++,L.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__(14)),exports.measure=measure,exports.formatTime=formatTime,exports.printStats=printStats,exports.printRTTI=printRTTI;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?a[o++]=(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,a[o++]=55296+(r>>10),a[o++]=56320+(1023&r)):a[o++]=(15&r)<<12|(63&n[e++])<<6|63&n[e++],o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,a)),o=0);return i?(o&&i.push(String.fromCharCode.apply(String,a.slice(0,o))),i.join("")):String.fromCharCode.apply(String,a.slice(0,o))},t.write=function(n,e,t){for(var r,i,a=t,o=0;o>6|192,e[t++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=n.charCodeAt(o+1)))?(r=65536+((1023&r)<<10)+(1023&i),++o,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-a}},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=[],a={};Object.keys(e).forEach(n=>{if(!n.startsWith(" ")){var r=e[n];null!=r.alias&&("string"==typeof r.alias?a[r.alias]=n:Array.isArray(r.alias)&&r.alias.forEach(e=>a[e]=n)),null!=r.default&&(t[n]=r.default)}});for(var o=0,s=(n=n.slice()).length;ot[n]=s.value[n])}else r.push(i)}for(;o{var o=n[e];if(null!=o.description){for(var s="";s.length{for(let e=0;e{r.statSync(i.join(e,o)).isDirectory()?n(i.join(e,o),t).forEach(n=>a.push(o+"/"+n)):(t&&"function"!=typeof t?t.test(o):t(o))&&a.push(o)}),a},e.TS=/\.ts$/,e.TS_EXCEPT_DTS=/[^\.][^\d]\.ts$/},function(n,e){if(void 0===__WEBPACK_EXTERNAL_MODULE__12__){var t=new Error("Cannot find module 'assemblyscript'");throw t.code="MODULE_NOT_FOUND",t}n.exports=__WEBPACK_EXTERNAL_MODULE__12__},function(n){n.exports=JSON.parse('{"version":{"description":"Prints just the compiler\'s version and exits.","type":"b","alias":"v"},"help":{"description":"Prints this message and exits.","type":"b","alias":"h"},"optimize":{"description":["Optimizes the module. Also has the usual shorthands:",""," -O Uses defaults. Equivalent to -O3s"," -O0 Equivalent to --optimizeLevel 0"," -O1 Equivalent to --optimizeLevel 1"," -O2 Equivalent to --optimizeLevel 2"," -O3 Equivalent to --optimizeLevel 3"," -Oz Equivalent to -O but with --shrinkLevel 2"," -O3s Equivalent to -O3 with --shrinkLevel 1 etc.",""],"type":"b","alias":"O"},"optimizeLevel":{"description":"How much to focus on optimizing code. [0-3]","type":"i"},"shrinkLevel":{"description":"How much to focus on shrinking code size. [0-2, s=1, z=2]","type":"i"},"validate":{"description":"Validates the module using Binaryen. Exits if invalid.","type":"b","alias":"c","default":false},"baseDir":{"description":"Specifies the base directory of input and output files.","type":"s","default":"."},"outFile":{"description":"Specifies the output file. File extension indicates format.","type":"s","alias":"o"},"binaryFile":{"description":"Specifies the binary output file (.wasm).","type":"s","alias":"b"},"textFile":{"description":"Specifies the text output file (.wat).","type":"s","alias":"t"},"asmjsFile":{"description":"Specifies the asm.js output file (.js).","type":"s","alias":"a"},"idlFile":{"description":"Specifies the WebIDL output file (.webidl).","type":"s","alias":"i"},"tsdFile":{"description":"Specifies the TypeScript definition output file (.d.ts).","type":"s","alias":"d"},"sourceMap":{"description":["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],"type":"s"},"runtime":{"description":["Specifies the runtime variant to include in the program.",""," full Default runtime based on TLSF and reference counting."," half Same as \'full\', but not exported to the host."," stub Minimal stub implementation without free/GC support."," none Same as \'stub\', but not exported to the host.",""],"type":"s","default":"full"},"noUnsafe":{"description":["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],"type":"b","default":false},"debug":{"description":"Enables debug information in emitted binaries.","type":"b","default":false},"noAssert":{"description":"Replaces assertions with just their value without trapping.","type":"b","default":false},"noEmit":{"description":"Performs compilation as usual but does not emit code.","type":"b","default":false},"importMemory":{"description":"Imports the memory instance provided by the embedder.","type":"b","default":false},"sharedMemory":{"description":"Declare memory as shared by settings the max shared memory.","type":"i","default":0},"memoryBase":{"description":"Sets the start offset of compiler-generated static memory.","type":"i","default":0},"importTable":{"description":"Imports the function table instance provided by the embedder.","type":"b","default":false},"explicitStart":{"description":"Exports an explicit start function to be called manually.","type":"b","default":false},"lib":{"description":["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],"type":"s"},"path":{"description":["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an \'ascMain\' entry in a package\'s","package.json and falls back to an inner \'assembly/\' folder."],"type":"S"},"use":{"description":["Aliases a global object under another name, e.g., to switch","the default \'Math\' implementation used: --use Math=JSMath"],"type":"S","alias":"u"},"trapMode":{"description":["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],"type":"s","default":"allow"},"runPasses":{"description":["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],"type":"s"},"enable":{"description":["Enables WebAssembly features that are disabled by default.",""," sign-extension Sign-extension operations"," bulk-memory Bulk memory operations."," simd SIMD types and operations."," threads Threading and atomic operations."," reference-types Reference types and operations.",""],"TODO_doesNothingYet":[" nontrapping-f2i Non-trapping float to integer ops."," exception-handling Exception handling."," tail-calls Tail call operations."],"type":"s"},"disable":{"description":["Disables WebAssembly features that are enabled by default.",""," mutable-globals Mutable global imports and exports.",""]},"transform":{"description":"Specifies the path to a custom transform to \'require\'.","type":"S"},"traceResolution":{"description":"Enables tracing of package resolution.","type":"b","default":false},"listFiles":{"description":"Lists files to be compiled and exits.","type":"b","default":false},"measure":{"description":"Prints measuring information on I/O and compile times.","type":"b","default":false},"printrtti":{"description":"Prints the module\'s runtime type information to stderr.","type":"b","default":false},"noColors":{"description":"Disables terminal colors.","type":"b","default":false}," ...":{"description":"Specifies node.js options (CLI only). See: node --help"},"-Os":{"value":{"optimize":true,"shrinkLevel":1}},"-Oz":{"value":{"optimize":true,"shrinkLevel":2}},"-O0":{"value":{"optimizeLevel":0,"shrinkLevel":0}},"-O1":{"value":{"optimizeLevel":1,"shrinkLevel":0}},"-O2":{"value":{"optimizeLevel":2,"shrinkLevel":0}},"-O3":{"value":{"optimizeLevel":3,"shrinkLevel":0}},"-O0s":{"value":{"optimizeLevel":0,"shrinkLevel":1}},"-O1s":{"value":{"optimizeLevel":1,"shrinkLevel":1}},"-O2s":{"value":{"optimizeLevel":2,"shrinkLevel":1}},"-O3s":{"value":{"optimizeLevel":3,"shrinkLevel":1}},"-O0z":{"value":{"optimizeLevel":0,"shrinkLevel":2}},"-O1z":{"value":{"optimizeLevel":1,"shrinkLevel":2}},"-O2z":{"value":{"optimizeLevel":2,"shrinkLevel":2}},"-O3z":{"value":{"optimizeLevel":3,"shrinkLevel":2}}}')},function(n,e,t){(function(e,t){n.exports=e.hrtime||function(n){var e=.001*i.call(r),t=Math.floor(e),a=Math.floor(e%1*1e9);n&&(t-=n[0],(a-=n[1])<0&&(t--,a+=1e9));return[t,a]};var r=t.performance||{},i=r.now||r.mozNow||r.msNow||r.oNow||r.webkitNow||function(){return(new Date).getTime()}}).call(this,t(0),t(3))}])})); +!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__12__){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=5)}([function(n,e,t){var r,i;e.nextTick=function(n){var e=Array.prototype.slice.call(arguments);e.shift(),setTimeout((function(){n.apply(null,e)}),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}function r(n,e){if(n.filter)return n.filter(e);for(var t=[],r=0;r=-1&&!i;a--){var o=a>=0?arguments[a]:n.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(e=o+"/"+e,i="/"===o.charAt(0))}return(i?"/":"")+(e=t(r(e.split("/"),(function(n){return!!n})),!i).join("/"))||"."},e.normalize=function(n){var a=e.isAbsolute(n),o="/"===i(n,-1);return(n=t(r(n.split("/"),(function(n){return!!n})),!a).join("/"))||a||(n="."),n&&o&&(n+="/"),(a?"/":"")+n},e.isAbsolute=function(n){return"/"===n.charAt(0)},e.join=function(){var n=Array.prototype.slice.call(arguments,0);return e.normalize(r(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("/")),a=r(t.split("/")),o=Math.min(i.length,a.length),s=o,l=0;l=1;--a)if(47===(e=n.charCodeAt(a))){if(!i){r=a;break}}else i=!1;return-1===r?t?"/":".":t&&1===r?"/":n.slice(0,r)},e.basename=function(n,e){var t=function(n){"string"!=typeof n&&(n+="");var e,t=0,r=-1,i=!0;for(e=n.length-1;e>=0;--e)if(47===n.charCodeAt(e)){if(!i){t=e+1;break}}else-1===r&&(i=!1,r=e+1);return-1===r?"":n.slice(t,r)}(n);return e&&t.substr(-1*e.length)===e&&(t=t.substr(0,t.length-e.length)),t},e.extname=function(n){"string"!=typeof n&&(n+="");for(var e=-1,t=0,r=-1,i=!0,a=0,o=n.length-1;o>=0;--o){var s=n.charCodeAt(o);if(47!==s)-1===r&&(i=!1,r=o+1),46===s?-1===e?e=o:1!==a&&(a=1):-1!==e&&(a=-1);else if(!i){t=o+1;break}}return-1===e||-1===r||0===a||1===a&&e===r-1&&e===t+1?"":n.slice(e,r)};var i="b"==="ab".substr(-1)?function(n,e,t){return n.substr(e,t)}:function(n,e,t){return e<0&&(e=n.length+e),n.substr(e,t)}}).call(this,t(0))},function(n,e){},function(n,e){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(n){"object"==typeof window&&(t=window)}n.exports=t},function(n,e){function t(n){var e=new Error("Cannot find module '"+n+"'");throw e.code="MODULE_NOT_FOUND",e}t.keys=function(){return[]},t.resolve=t,n.exports=t,t.id=4},function(n,e,t){n.exports=t(6)},function(module,exports,__webpack_require__){"use strict";(function(process,global){process.browser&&(process.cwd=function(){return"."});const fs=__webpack_require__(2),path=__webpack_require__(1),utf8=__webpack_require__(7),colorsUtil=__webpack_require__(8),optionsUtil=__webpack_require__(9),mkdirp=__webpack_require__(10),find=__webpack_require__(11),EOL="win32"===process.platform?"\r\n":"\n",SEP="win32"===process.platform?"\\":"/";process.removeAllListeners&&process.removeAllListeners("uncaughtException");var assemblyscript,isDev=!1;function checkDiagnostics(n,e){for(var t,r=!1;null!=(t=assemblyscript.nextDiagnostic(n));)e&&e.write(assemblyscript.formatDiagnostic(t,e.isTTY,!0)+EOL+EOL),assemblyscript.isError(t)&&(r=!0);return r}function createStats(){return{readTime:0,readCount:0,writeTime:0,writeCount:0,parseTime:0,parseCount:0,compileTime:0,compileCount:0,emitTime:0,emitCount:0,validateTime:0,validateCount:0,optimizeTime:0,optimizeCount:0}}function measure(n){const e=process.hrtime();n();const t=process.hrtime(e);return 1e9*t[0]+t[1]}function formatTime(n){return n?(n/1e6).toFixed(3)+" ms":"N/A"}function printStats(n,e){function t(n,e){return formatTime(n)}(e||process.stdout).write(["I/O Read : "+t(n.readTime,n.readCount),"I/O Write : "+t(n.writeTime,n.writeCount),"Parse : "+t(n.parseTime,n.parseCount),"Compile : "+t(n.compileTime,n.compileCount),"Emit : "+t(n.emitTime,n.emitCount),"Validate : "+t(n.validateTime,n.validateCount),"Optimize : "+t(n.optimizeTime,n.optimizeCount)].join(EOL)+EOL)}function printRTTI(n,e){e||(e=process.stderr),e.write("# Runtime type information (RTTI)\n"),e.write(assemblyscript.buildRTTI(n))}(()=>{try{assemblyscript=__webpack_require__(12)}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"),skipIgnore:!0}),__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.message=e_ts.stack+"\n---\n"+n.stack,n}}}})(),exports.isBundle=!0,exports.isDev=isDev,exports.version=exports.isBundle?"0.8.1":__webpack_require__(!function(){var n=new Error("Cannot find module '../package.json'");throw n.code="MODULE_NOT_FOUND",n}()).version,exports.options=__webpack_require__(13),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 { ArrayBufferView } from "./arraybuffer";\nimport { joinBooleanArray, joinIntegerArray, joinFloatArray, joinStringArray, joinReferenceArray } from "./util/string";\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).byteLength;\n if (minSize > oldCapacity >>> alignLog2) {\n if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);\n let oldData = changetype(changetype(array).buffer);\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(array, __retain(newData), offsetof("buffer"));\n store(array, newData, offsetof("dataStart"));\n }\n store(array, newCapacity, offsetof("byteLength"));\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 uninitialized null values\n // whenever an element is accessed. Otherwise, the compiler wouldn\'t be able to guarantee\n // 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 WARNING("\'Array.create\' is deprecated. Use \'new Array\' instead, making sure initial elements are initialized.");\n var array = new Array(capacity);\n array.length = 0;\n return array;\n }\n\n constructor(length: i32 = 0) {\n super(length, alignof());\n this.length_ = length;\n }\n\n get length(): i32 {\n return this.length_;\n }\n\n set length(newLength: i32) {\n var oldLength = this.length_;\n if (isManaged()) {\n if (oldLength > newLength) { // release no longer used refs\n let dataStart = this.dataStart;\n let cur = dataStart + (newLength << alignof());\n let end = dataStart + (oldLength << alignof());\n do __release(load(cur));\n while ((cur += sizeof()) < end);\n } else {\n ensureSize(changetype(this), newLength, alignof());\n }\n } else {\n ensureSize(changetype(this), newLength, alignof());\n }\n this.length_ = newLength;\n }\n\n every(fn: (value: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (!fn(load(this.dataStart + (index << alignof())), index, this)) return false;\n }\n return true;\n }\n\n findIndex(predicate: (value: 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 (index >= this.length_) throw new RangeError(E_INDEXOUTOFRANGE);\n var value = this.__unchecked_get(index);\n if (isReference()) {\n if (!isNullable()) {\n if (!changetype(value)) throw new Error(E_HOLEYARRAY);\n }\n }\n return value;\n }\n\n @unsafe @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 if (index >= this.length_) {\n if (index < 0) throw new RangeError(E_INDEXOUTOFRANGE);\n ensureSize(changetype(this), index + 1, alignof());\n this.length_ = index + 1;\n }\n this.__unchecked_set(index, value);\n }\n\n @unsafe @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = this.dataStart + (index << alignof());\n let oldRef = 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 (isManaged()) {\n for (; start < end; ++start) {\n let oldRef: usize = load(dataStart + (start << alignof()));\n if (changetype(value) != oldRef) {\n store(dataStart + (start << alignof()), __retain(changetype(value)));\n __release(oldRef);\n }\n }\n } else 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(value: T, fromIndex: i32 = 0): bool {\n if (isFloat()) {\n let length = this.length_;\n if (length == 0 || fromIndex >= length) return false;\n if (fromIndex < 0) fromIndex = max(length + fromIndex, 0);\n let dataStart = this.dataStart;\n while (fromIndex < length) {\n let elem = load(dataStart + (fromIndex << alignof()));\n // @ts-ignore\n if (elem == value || isNaN(elem) & isNaN(value)) return true;\n ++fromIndex;\n }\n return false;\n } else {\n return this.indexOf(value, fromIndex) >= 0;\n }\n }\n\n indexOf(value: 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())) == value) return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(value: 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())) == value) 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 store(this.dataStart + (length << alignof()), __retain(changetype(value)));\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 (isManaged()) {\n if (from < to && to < (from + count)) { // right to left\n from += count - 1;\n to += count - 1;\n while (count) {\n let oldRef: usize = load(dataStart + (to << alignof()));\n let newRef: usize = load(dataStart + (from << alignof()));\n if (newRef != oldRef) {\n store(dataStart + (to << alignof()), __retain(newRef));\n __release(oldRef);\n }\n --from, --to, --count;\n }\n } else { // left to right\n while (count) {\n let oldRef: usize = load(dataStart + (to << alignof()));\n let newRef: usize = load(dataStart + (from << alignof()));\n if (newRef != oldRef) {\n store(dataStart + (to << alignof()), __retain(newRef));\n __release(oldRef);\n }\n ++from, ++to, --count;\n }\n }\n } else {\n memory.copy( // is memmove\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; // no need to retain -> is moved\n }\n\n forEach(fn: (value: T, index: i32, array: Array) => void): void {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n fn(load(this.dataStart + (index << alignof())), index, this);\n }\n }\n\n map(fn: (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 = fn(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(fn: (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 (fn(value, index, this)) result.push(value);\n }\n return result;\n }\n\n reduce(\n fn: (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 = fn(accum, load(this.dataStart + (index << alignof())), index, this);\n }\n return accum;\n }\n\n reduceRight(\n fn: (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 = fn(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; // no need to retain -> is moved\n }\n\n some(fn: (value: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (fn(load(this.dataStart + (index << alignof())), index, this)) return true;\n }\n return false;\n }\n\n unshift(value: 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(value)));\n } else {\n store(dataStart, value);\n }\n this.length_ = newLength;\n return newLength;\n }\n\n slice(start: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n start = start < 0 ? max(start + length, 0) : min(start, length);\n end = end < 0 ? max(end + length, 0) : min(end , length);\n length = max(end - start, 0);\n var slice = changetype>(__allocArray(length, alignof(), idof>())); // retains\n var sliceBase = slice.dataStart;\n var thisBase = this.dataStart + (start << 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 // no need to retain -> is moved\n memory.copy(\n resultStart,\n thisBase,\n deleteCount << alignof()\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 var dataStart = this.dataStart;\n var length = this.length_;\n if (isBoolean()) return joinBooleanArray(dataStart, length, separator);\n if (isInteger()) return joinIntegerArray(dataStart, length, separator);\n if (isFloat()) return joinFloatArray(dataStart, length, separator);\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (isString()) return joinStringArray(dataStart, length, separator);\n }\n // For rest objects and arrays use general join routine\n if (isReference()) return joinReferenceArray(dataStart, length, separator);\n ERROR("unspported element type");\n return unreachable();\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.length_ << alignof());\n while (cur < end) {\n let val = load(cur);\n if (val) __visit(val, cookie);\n cur += sizeof();\n }\n }\n // automatically visits ArrayBufferView (.buffer) 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 readonly buffer: ArrayBuffer;\n @unsafe readonly dataStart: usize;\n readonly byteLength: i32;\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.buffer));\n }\n\n get length(): i32 {\n ERROR("missing implementation: subclasses must implement ArrayBufferView#length");\n return unreachable();\n }\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 memory.fill(buffer, 0, length);\n this.buffer = changetype(buffer); // retains\n this.dataStart = buffer;\n this.byteLength = length;\n }\n}\n\n@sealed export class ArrayBuffer {\n\n static isView(value: T): bool {\n if (isNullable()) {\n if (value === null) return false;\n }\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 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',atomics:'import { ArrayBufferView } from "./arraybuffer";\nimport { E_INDEXOUTOFRANGE } from "./util/error";\n\nexport namespace Atomics {\n\n // @ts-ignore: decorator\n @inline\n export function load(array: T, index: i32): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.load>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function store(array: T, index: i32, value: valueof): void {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n atomic.store>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function add(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.add>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function sub(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.sub>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function and(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.and>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function or(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.or>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function xor(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.xor>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function exchange(array: T, index: i32, value: valueof): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.xchg>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n value\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function compareExchange(\n array: T,\n index: i32,\n expectedValue: valueof,\n replacementValue: valueof\n ): valueof {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.cmpxchg>(\n changetype(array.buffer) + (index << alignof>()) + array.byteOffset,\n expectedValue,\n replacementValue\n );\n }\n\n // @ts-ignore: decorator\n @inline\n export function wait(array: T, value: valueof, timeout: i64 = -1): AtomicWaitResult {\n return atomic.wait>(changetype(array.buffer) + array.byteOffset, value, timeout);\n }\n\n // @ts-ignore: decorator\n @inline\n export function notify(array: T, index: i32, count: i32 = -1): i32 {\n if (index < 0 || (index << alignof>()) >= array.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return atomic.notify(changetype(array.buffer) + (index << alignof>()) + array.byteOffset, count);\n }\n\n export function isLockFree(size: usize): bool {\n return size == 1 || size == 2 || size == 4;\n }\n}\n',"bindings/console":"export declare function assert(value: anyref): void;\nexport declare function clear(): void;\nexport declare function error(value: anyref): void;\nexport declare function info(value: anyref): void;\nexport declare function log(value: anyref): void;\nexport declare function time(label: anyref): anyref;\nexport declare function timeEnd(label: anyref): void;\nexport declare function timeLog(label: anyref): void;\nexport declare function trace(): void;\nexport declare function warn(value: anyref): void;\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/Reflect":"export declare function get(target: anyref, propertyKey: anyref/*, receiver: anyref*/): anyref;\nexport declare function has(target: anyref, propertyKey: anyref): bool;\nexport declare function set(target: anyref, propertyKey: anyref, value: anyref/*, receiver: anyref*/): anyref;\nexport declare function apply(target: anyref, thisArgument: anyref, argumentsList: anyref): anyref;\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\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\n// @ts-ignore: decorator\n@builtin\nexport declare function isVoid(): boolean;\n\n// @ts-ignore\n@builtin\nexport declare function lengthof(func?: T): i32;\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@unsafe @builtin\nexport declare function load(ptr: usize, immOffset?: usize, immAlign?: usize): T;\n\n// @ts-ignore: decorator\n@unsafe @builtin\nexport declare function store(ptr: 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\n@builtin\nexport declare function nameof(): string;\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@unsafe @builtin\nexport declare function unchecked(expr: T): T;\n\n// @ts-ignore: decorator\n@unsafe @builtin\nexport declare function call_indirect(target: void, ...args: void[]): T;\n\n// @ts-ignore: decorator\n@unsafe @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 @unsafe @builtin\n export declare function load(ptr: usize, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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 @unsafe @builtin\n export declare function xchg(ptr: usize, value: T, immOffset?: usize): T;\n\n // @ts-ignore: decorator\n @unsafe @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 // @ts-ignore: decorator\n @builtin\n export declare function fence(): void;\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(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store8(ptr: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store16(ptr: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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(ptr: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(ptr: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(ptr: usize, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store8(ptr: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store16(ptr: usize, value: i32, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg(ptr: usize, value: i32, immOffset?: usize): i32;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8_u(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_s(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_s(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(ptr: 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 @unsafe @builtin\n export declare function store8(ptr: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store16(ptr: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store32(ptr: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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(ptr: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16_u(ptr: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32_u(ptr: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load(ptr: usize, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store8(ptr: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store16(ptr: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store32(ptr: usize, value: i64, immOffset?: usize): void;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg_u(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg_u(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function sub(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function and(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function or(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @builtin\n export declare function xor(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function xchg(ptr: usize, value: i64, immOffset?: usize): i64;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function cmpxchg(ptr: 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(ptr: 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 @unsafe @builtin\n export declare function store(ptr: 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(ptr: 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 @unsafe @builtin\n export declare function store(ptr: 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 swizzle(a: v128, s: v128): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_ext(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function store(ptr: 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 andnot(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;\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 dot(a: v128, b: v128): v128; // i16 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_sat(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function narrow(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfma(v1: v128, v2: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfms(v1: v128, v2: v128, c: 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 min_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_u(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 // @ts-ignore: decorator\n @builtin\n export declare function narrow_i16x8_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function narrow_i16x8_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 min_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_u(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 // @ts-ignore: decorator\n @builtin\n export declare function narrow_i32x4_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function narrow_i32x4_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low_i8x16_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low_i8x16_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high_i8x16_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high_i8x16_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8x8_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load8x8_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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 min_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function min_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_s(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function max_u(a: v128, b: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function dot_i16x8_s(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_sat_f32x4_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_sat_f32x4_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low_i16x8_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_low_i16x8_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high_i16x8_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function widen_high_i16x8_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16x4_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load16x4_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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_sat_f64x2_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function trunc_sat_f64x2_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32x2_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function load32x2_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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_i32x4_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_i32x4_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfma(a: v128, b: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfms(a: v128, b: v128, c: 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_i64x2_s(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function convert_i64x2_u(a: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfma(a: v128, b: v128, c: v128): v128;\n\n // @ts-ignore: decorator\n @builtin\n export declare function qfms(a: v128, b: v128, c: 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 // @ts-ignore: decorator\n @builtin\n export declare function swizzle(a: v128, s: v128): v128;\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n}\n\nexport namespace v16x8 {\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n}\n\nexport namespace v32x4 {\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n}\n\nexport namespace v64x2 {\n\n // @ts-ignore: decorator\n @unsafe @builtin\n export declare function load_splat(ptr: usize, immOffset?: u32, immAlign?: u32): 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',compat:"\nexport type ReturnType = returnof;\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 readonly buffer: ArrayBuffer;\n @unsafe readonly dataStart: usize;\n readonly byteLength: i32;\n\n get byteOffset(): i32 {\n return (this.dataStart - changetype(this.buffer));\n }\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.buffer = buffer; // retains\n var dataStart = changetype(buffer) + byteOffset;\n this.dataStart = dataStart;\n this.byteLength = byteLength;\n }\n\n getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 {\n if (\n (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getInt16(byteOffset: i32, littleEndian: boolean = false): i16 {\n if (\n (byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + byteOffset);\n }\n\n getUint16(byteOffset: i32, littleEndian: boolean = false): u16 {\n if (\n (byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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.byteLength) 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 (byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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.byteLength) 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 (byteOffset >>> 31) | i32(byteOffset + 2 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 4 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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 (byteOffset >>> 31) | i32(byteOffset + 8 > this.byteLength)\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 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 var value = this.__unchecked_get(index);\n if (isReference()) {\n if (!isNullable()) {\n if (!changetype(value)) throw new Error(E_HOLEYARRAY);\n }\n }\n return value;\n }\n\n @unsafe @operator("{}") private __unchecked_get(index: i32): T {\n return load(changetype(this) + (index << alignof()));\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 @unsafe @operator("{}=") private __unchecked_set(index: i32, value: T): void {\n if (isManaged()) {\n let offset = changetype(this) + (index << alignof());\n let oldRef = load(offset);\n if (changetype(value) != oldRef) {\n store(offset, __retain(changetype(value)));\n __release(changetype(oldRef));\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',gc:'/// \n\n/** Garbage collector interface. */\nexport namespace gc {\n\n /** Can be set to `false` to disable automatic collection. Defaults to `true`. */\n export var auto: bool = true;\n\n /** Performs a full garbage collection cycle. */\n export function collect(): void {\n __collect();\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";\nimport { E_KEYNOTFOUND } from "util/error";\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_N = 8;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR_D = 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR_N = 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR_D = 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 @operator("[]")\n get(key: K): V {\n var entry = this.find(key, HASH(key));\n if (!entry) throw new Error(E_KEYNOTFOUND); // cannot represent `undefined`\n return entry.value;\n }\n\n @operator("[]=")\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 / FREE_FACTOR_D\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 / FREE_FACTOR_D\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 / FILL_FACTOR_D;\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 keys(): K[] {\n // FIXME: this is preliminary, needs iterators/closures\n var start = changetype(this.entries);\n var size = this.entriesOffset;\n var keys = new Array(size);\n var length = 0;\n for (let i = 0; i < size; ++i) {\n let entry = changetype>(start + i * ENTRY_SIZE());\n if (!(entry.taggedNext & EMPTY)) {\n keys.push(entry.key);\n ++length;\n }\n }\n keys.length = length;\n return keys;\n }\n\n values(): V[] {\n // FIXME: this is preliminary, needs iterators/closures\n var start = changetype(this.entries);\n var size = this.entriesOffset;\n var values = new Array(size);\n var length = 0;\n for (let i = 0; i < size; ++i) {\n let entry = changetype>(start + i * ENTRY_SIZE());\n if (!(entry.taggedNext & EMPTY)) {\n values.push(entry.value);\n ++length;\n }\n }\n values.length = length;\n return values;\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/** @internal */\n// @ts-ignore: decorator\n@lazy\nvar rempio2_y0: f64,\n rempio2_y1: f64,\n res128_hi: u64;\n\n/** @internal */\n// @ts-ignore: decorator\n@lazy\nconst PIO2_TABLE: u64[] = [\n 0x00000000A2F9836E, 0x4E441529FC2757D1, 0xF534DDC0DB629599, 0x3C439041FE5163AB,\n 0xDEBBC561B7246E3A, 0x424DD2E006492EEA, 0x09D1921CFE1DEB1C, 0xB129A73EE88235F5,\n 0x2EBB4484E99C7026, 0xB45F7E413991D639, 0x835339F49C845F8B, 0xBDF9283B1FF897FF,\n 0xDE05980FEF2F118B, 0x5A0A6D1F6D367ECF, 0x27CB09B74F463F66, 0x9E5FEA2D7527BAC7,\n 0xEBE5F17B3D0739F7, 0x8A5292EA6BFB5FB1, 0x1F8D5D0856033046, 0xFC7B6BABF0CFBC20,\n 0x9AF4361DA9E39161, 0x5EE61B086599855F, 0x14A068408DFFD880, 0x4D73273106061557\n];\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/** @internal */\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/** @internal */\n/* Helper function to eventually get bits of π/2 * |x|\n *\n * y = π/4 * (frac << clz(frac) >> 11)\n * return clz(frac)\n *\n * Right shift 11 bits to make upper half fit in `double`\n */\n// @ts-ignore: decorator\n@inline\nfunction pio2_right(q0: u64, q1: u64): u64 { // see: jdh8/metallic/blob/master/src/math/double/rem_pio2.c\n /* Bits of π/4 */\n const p0: u64 = 0xC4C6628B80DC1CD1;\n const p1: u64 = 0xC90FDAA22168C234;\n\n const Ox1p_64 = reinterpret(0x3BF0000000000000); // 0x1p-64\n const Ox1p_75 = reinterpret(0x3B40000000000000); // 0x1p-75\n\n var shift = clz(q1);\n\n q1 = q1 << shift | q0 >> (64 - shift);\n q0 <<= shift;\n\n var lo = umuldi(p1, q1);\n var hi = res128_hi;\n\n var ahi = hi >> 11;\n var alo = lo >> 11 | hi << 53;\n var blo = (Ox1p_75 * p0 * q1 + Ox1p_75 * p1 * q0);\n\n rempio2_y0 = (ahi + u64(lo < blo));\n rempio2_y1 = Ox1p_64 * (alo + blo);\n\n return shift;\n}\n\n/** @internal */\n// @ts-ignore: decorator\n@inline\nfunction umuldi(u: u64, v: u64): u64 {\n var u1: u64 , v1: u64, w0: u64, w1: u64, t: u64;\n\n u1 = u & 0xFFFFFFFF;\n v1 = v & 0xFFFFFFFF;\n\n u >>= 32;\n v >>= 32;\n\n t = u1 * v1;\n w0 = t & 0xFFFFFFFF;\n t = u * v1 + (t >> 32);\n w1 = t >> 32;\n t = u1 * v + (t & 0xFFFFFFFF);\n\n res128_hi = u * v + w1 + (t >> 32);\n return (t << 32) + w0;\n}\n\n/** @internal */\nfunction pio2_large_quot(x: f64, u: i64): i32 { // see: jdh8/metallic/blob/master/src/math/double/rem_pio2.c\n const bits = PIO2_TABLE.dataStart;\n\n var magnitude = u & 0x7FFFFFFFFFFFFFFF;\n var offset = (magnitude >> 52) - 1045;\n var shift = offset & 63;\n var tblPtr = bits + ((offset >> 6) << 3);\n var s0: u64, s1: u64, s2: u64;\n\n var b0 = load(tblPtr, 0 << 3);\n var b1 = load(tblPtr, 1 << 3);\n var b2 = load(tblPtr, 2 << 3);\n\n /* Get 192 bits of 0x1p-31 / π with `offset` bits skipped */\n if (shift) {\n let rshift = 64 - shift;\n let b3 = load(tblPtr, 3 << 3);\n s0 = b1 >> rshift | b0 << shift;\n s1 = b2 >> rshift | b1 << shift;\n s2 = b3 >> rshift | b2 << shift;\n } else {\n s0 = b0;\n s1 = b1;\n s2 = b2;\n }\n\n var significand = (u & 0x000FFFFFFFFFFFFF) | 0x0010000000000000;\n\n /* First 128 bits of fractional part of x/(2π) */\n var blo = umuldi(s1, significand);\n var bhi = res128_hi;\n\n var ahi = s0 * significand;\n var clo = (s2 >> 32) * (significand >> 32);\n var plo = blo + clo;\n var phi = ahi + bhi + u64(plo < clo);\n\n // r: u128 = p << 2\n var rlo = plo << 2;\n var rhi = phi << 2 | plo >> 62;\n\n // s: i128 = r >> 127\n var slo = rhi >> 63;\n var shi = slo >> 1;\n var q = (phi >> 62) - slo;\n\n var shifter = 0x3CB0000000000000 - (pio2_right(rlo ^ slo, rhi ^ shi) << 52);\n var signbit = (u ^ rhi) & 0x8000000000000000;\n var coeff = reinterpret(shifter | signbit);\n\n rempio2_y0 *= coeff;\n rempio2_y1 *= coeff;\n\n return q;\n}\n\n/** @internal */\n// @ts-ignore: decorator\n@inline\nfunction rempio2(x: f64, u: u64, sign: i32): i32 {\n const pio2_1 = reinterpret(0x3FF921FB54400000); // 1.57079632673412561417e+00\n const pio2_1t = reinterpret(0x3DD0B4611A626331); // 6.07710050650619224932e-11\n const pio2_2 = reinterpret(0x3DD0B4611A600000); // 6.07710050630396597660e-11\n const pio2_2t = reinterpret(0x3BA3198A2E037073); // 2.02226624879595063154e-21\n const pio2_3 = reinterpret(0x3BA3198A2E000000); // 2.02226624871116645580e-21\n const pio2_3t = reinterpret(0x397B839A252049C1); // 8.47842766036889956997e-32\n const invpio2 = reinterpret(0x3FE45F306DC9C883); // 0.63661977236758134308\n\n var ix = (u >> 32) & 0x7FFFFFFF;\n\n if (ASC_SHRINK_LEVEL < 1) {\n if (ix < 0x4002D97C) { /* |x| < 3pi/4, special case with n=+-1 */\n let q = 1, z: f64, y0: f64, y1: f64;\n if (!sign) {\n z = x - pio2_1;\n if (ix != 0x3FF921FB) { /* 33+53 bit pi is good enough */\n y0 = z - pio2_1t;\n y1 = (z - y0) - pio2_1t;\n } else { /* near pi/2, use 33+33+53 bit pi */\n z -= pio2_2;\n y0 = z - pio2_2t;\n y1 = (z - y0) - pio2_2t;\n }\n } else { /* negative x */\n z = x + pio2_1;\n if (ix != 0x3FF921FB) { /* 33+53 bit pi is good enough */\n y0 = z + pio2_1t;\n y1 = (z - y0) + pio2_1t;\n } else { /* near pi/2, use 33+33+53 bit pi */\n z += pio2_2;\n y0 = z + pio2_2t;\n y1 = (z - y0) + pio2_2t;\n }\n q = -1;\n }\n rempio2_y0 = y0;\n rempio2_y1 = y1;\n return q;\n }\n }\n\n if (ix < 0x413921FB) { // |x| ~< 2^20*pi/2 (1647099)\n // Use precise Cody Waite scheme\n let q = nearest(x * invpio2);\n let r = x - q * pio2_1;\n let w = q * pio2_1t; // 1st round good to 85 bit\n let j = ix >> 20;\n let y0 = r - w;\n let hi = (reinterpret(y0) >> 32);\n let i = j - ((hi >> 20) & 0x7FF);\n\n if (i > 16) { // 2nd iteration needed, good to 118\n let t = r;\n w = q * pio2_2;\n r = t - w;\n w = q * pio2_2t - ((t - r) - w);\n y0 = r - w;\n hi = (reinterpret(y0) >> 32);\n i = j - ((hi >> 20) & 0x7FF);\n if (i > 49) { // 3rd iteration need, 151 bits acc\n let t = r;\n w = q * pio2_3;\n r = t - w;\n w = q * pio2_3t - ((t - r) - w);\n y0 = r - w;\n }\n }\n let y1 = (r - y0) - w;\n rempio2_y0 = y0;\n rempio2_y1 = y1;\n return q;\n }\n var q = pio2_large_quot(x, u);\n return select(-q, q, sign);\n}\n\n/** @internal */\n// @ts-ignore: decorator\n@inline\nfunction sin_kern(x: f64, y: f64, iy: i32): f64 { // see: musl/tree/src/math/__sin.c\n const S1 = reinterpret(0xBFC5555555555549); // -1.66666666666666324348e-01\n const S2 = reinterpret(0x3F8111111110F8A6); // 8.33333333332248946124e-03\n const S3 = reinterpret(0xBF2A01A019C161D5); // -1.98412698298579493134e-04\n const S4 = reinterpret(0x3EC71DE357B1FE7D); // 2.75573137070700676789e-06\n const S5 = reinterpret(0xBE5AE5E68A2B9CEB); // -2.50507602534068634195e-08\n const S6 = reinterpret(0x3DE5D93A5ACFD57C); // 1.58969099521155010221e-10\n\n var z = x * x;\n var w = z * z;\n var r = S2 + z * (S3 + z * S4) + z * w * (S5 + z * S6);\n var v = z * x;\n if (!iy) {\n return x + v * (S1 + z * r);\n } else {\n return x - ((z * (0.5 * y - v * r) - y) - v * S1);\n }\n}\n\n/** @internal */\n// @ts-ignore: decorator\n@inline\nfunction cos_kern(x: f64, y: f64): f64 { // see: musl/tree/src/math/__cos.c\n const C1 = reinterpret(0x3FA555555555554C); // 4.16666666666666019037e-02\n const C2 = reinterpret(0xBF56C16C16C15177); // -1.38888888888741095749e-03\n const C3 = reinterpret(0x3EFA01A019CB1590); // 2.48015872894767294178e-05\n const C4 = reinterpret(0xBE927E4F809C52AD); // -2.75573143513906633035e-07\n const C5 = reinterpret(0x3E21EE9EBDB4B1C4); // 2.08757232129817482790e-09\n const C6 = reinterpret(0xBDA8FAE9BE8838D4); // -1.13596475577881948265e-11\n\n var z = x * x;\n var w = z * z;\n var r = z * (C1 + z * (C2 + z * C3)) + w * w * (C4 + z * (C5 + z * C6));\n var hz = 0.5 * z;\n w = 1.0 - hz;\n return w + (((1.0 - w) - hz) + (z * r - x * y));\n}\n\n/** @internal */\nfunction tan_kern(x: f64, y: f64, iy: i32): f64 { // see: src/lib/msun/src/k_tan.c\n const T0 = reinterpret(0x3FD5555555555563); // 3.33333333333334091986e-01\n const T1 = reinterpret(0x3FC111111110FE7A); // 1.33333333333201242699e-01\n const T2 = reinterpret(0x3FABA1BA1BB341FE); // 5.39682539762260521377e-02\n const T3 = reinterpret(0x3F9664F48406D637); // 2.18694882948595424599e-02\n const T4 = reinterpret(0x3F8226E3E96E8493); // 8.86323982359930005737e-03\n const T5 = reinterpret(0x3F6D6D22C9560328); // 3.59207910759131235356e-03\n const T6 = reinterpret(0x3F57DBC8FEE08315); // 1.45620945432529025516e-03\n const T7 = reinterpret(0x3F4344D8F2F26501); // 5.88041240820264096874e-04\n const T8 = reinterpret(0x3F3026F71A8D1068); // 2.46463134818469906812e-04\n const T9 = reinterpret(0x3F147E88A03792A6); // 7.81794442939557092300e-05\n const T10 = reinterpret(0x3F12B80F32F0A7E9); // 7.14072491382608190305e-05\n const T11 = reinterpret(0xBEF375CBDB605373); // -1.85586374855275456654e-05\n const T12 = reinterpret(0x3EFB2A7074BF7AD4); // 2.59073051863633712884e-05\n\n const one = reinterpret(0x3FF0000000000000); // 1.00000000000000000000e+00\n const pio4 = reinterpret(0x3FE921FB54442D18); // 7.85398163397448278999e-01\n const pio4lo = reinterpret(0x3C81A62633145C07); // 3.06161699786838301793e-17\n\n var z: f64, r: f64, v: f64, w: f64, s: f64;\n var hx = (reinterpret(x) >> 32); /* high word of x */\n var ix = hx & 0x7FFFFFFF; /* high word of |x| */\n var big = ix >= 0x3FE59428;\n if (big) { /* |x| >= 0.6744 */\n if (hx < 0) { x = -x, y = -y; }\n z = pio4 - x;\n w = pio4lo - y;\n x = z + w;\n y = 0.0;\n }\n z = x * x;\n w = z * z;\n r = T1 + w * (T3 + w * (T5 + w * (T7 + w * (T9 + w * T11))));\n v = z * (T2 + w * (T4 + w * (T6 + w * (T8 + w * (T10 + w * T12)))));\n s = z * x;\n r = y + z * (s * (r + v) + y);\n r += T0 * s;\n w = x + r;\n if (big) {\n v = iy;\n return (1 - ((hx >> 30) & 2)) * (v - 2.0 * (x - (w * w / (w + v) - r)));\n }\n if (iy == 1) return w;\n var a: f64, t: f64;\n z = w;\n z = reinterpret(reinterpret(z) & 0xFFFFFFFF00000000);\n v = r - (z - x); /* z + v = r + x */\n t = a = -one / w; /* a = -1.0 / w */\n t = reinterpret(reinterpret(t) & 0xFFFFFFFF00000000);\n s = one + t * z;\n return t + a * (s + t * v);\n}\n\n/** @internal */\nfunction dtoi32(x: f64): i32 {\n if (ASC_SHRINK_LEVEL > 0) {\n const inv32 = 1.0 / 4294967296;\n return (x - 4294967296 * floor(x * inv32));\n } else {\n let result = 0;\n let u = reinterpret(x);\n let e = (u >> 52) & 0x7FF;\n if (e <= 1023 + 30) {\n result = x;\n } else if (e <= 1023 + 30 + 53) {\n let v = (u & ((1 << 52) - 1)) | (1 << 52);\n v = v << e - 1023 - 52 + 32;\n result = (v >> 32);\n result = select(-result, result, u >> 63);\n }\n return result;\n }\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 @lazy\n export var sincos_sin: f64 = 0;\n\n // @ts-ignore: decorator\n @lazy\n export var sincos_cos: f64 = 0;\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 y = builtin_abs(x);\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 let t = m & 2 ? 3 * PI / 4 : PI / 4;\n return m & 1 ? -t : t;\n } else {\n let t = m & 2 ? PI : 0;\n return m & 1 ? -t : t;\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(dtoi32(x));\n }\n\n export function cos(x: f64): f64 { // see: musl/src/math/cos.c\n var u = reinterpret(x);\n var ix = (u >> 32);\n var sign = ix >> 31;\n\n ix &= 0x7FFFFFFF;\n\n /* |x| ~< pi/4 */\n if (ix <= 0x3FE921FB) {\n if (ix < 0x3E46A09E) { /* |x| < 2**-27 * sqrt(2) */\n return 1.0;\n }\n return cos_kern(x, 0);\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7FF00000) return x - x;\n\n /* argument reduction needed */\n var n = rempio2(x, u, sign);\n var y0 = rempio2_y0;\n var y1 = rempio2_y1;\n\n x = n & 1 ? sin_kern(y0, y1, 1) : cos_kern(y0, y1);\n return (n + 1) & 2 ? -x : x;\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): f64 {\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 return dtoi32(x) * dtoi32(y);\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 offset = select(52, 20, k > 20) - k;\n let Ly = select(ly, iy, k > 20);\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 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 assert(\n random_state0_64 != 0 && random_state1_64 != 0 &&\n random_state0_32 != 0 && random_state1_32 != 0\n );\n }\n\n export function random(): f64 { // see: v8/src/base/utils/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 >> 12) | 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 { // see: musl/src/math/sin.c\n var u = reinterpret(x);\n var ix = (u >> 32);\n var sign = ix >> 31;\n\n ix &= 0x7FFFFFFF;\n\n /* |x| ~< pi/4 */\n if (ix <= 0x3FE921FB) {\n if (ix < 0x3E500000) { /* |x| < 2**-26 */\n return x;\n }\n return sin_kern(x, 0.0, 0);\n }\n\n /* sin(Inf or NaN) is NaN */\n if (ix >= 0x7FF00000) return x - x;\n\n /* argument reduction needed */\n var n = rempio2(x, u, sign);\n var y0 = rempio2_y0;\n var y1 = rempio2_y1;\n\n x = n & 1 ? cos_kern(y0, y1) : sin_kern(y0, y1, 1);\n return n & 2 ? -x : x;\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 { // see: musl/src/math/tan.c\n var u = reinterpret(x);\n var ix = (u >> 32);\n var sign = ix >>> 31;\n\n ix &= 0x7FFFFFFF;\n\n /* |x| ~< pi/4 */\n if (ix <= 0x3FE921FB) {\n if (ix < 0x3E400000) { /* |x| < 2**-27 */\n return x;\n }\n return tan_kern(x, 0.0, 1);\n }\n\n /* tan(Inf or NaN) is NaN */\n if (ix >= 0x7FF00000) return x - x;\n\n var n = rempio2(x, u, sign);\n return tan_kern(rempio2_y0, rempio2_y1, 1 - ((n & 1) << 1));\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 export function sincos(x: f64): void { // see: musl/tree/src/math/sincos.c\n var u = reinterpret(x);\n var ix = (u >> 32);\n var sign = ix >> 31;\n ix &= 0x7FFFFFFF;\n\n if (ix <= 0x3FE921FB) { /* |x| ~<= π/4 */\n if (ix < 0x3E46A09E) { /* if |x| < 2**-27 * sqrt(2) */\n sincos_sin = x;\n sincos_cos = 1;\n return;\n }\n sincos_sin = sin_kern(x, 0, 0);\n sincos_cos = cos_kern(x, 0);\n return;\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 /* general argument reduction needed */\n var n = rempio2(x, u, sign);\n var y0 = rempio2_y0;\n var y1 = rempio2_y1;\n var s = sin_kern(y0, y1, 1);\n var c = cos_kern(y0, y1);\n var sin = s, cos = c;\n if (n & 1) {\n sin = c;\n cos = -s;\n }\n if (n & 2) {\n sin = -sin;\n cos = -cos;\n }\n sincos_sin = sin;\n sincos_cos = cos;\n }\n}\n\n// @ts-ignore: decorator\n@lazy\nvar rempio2f_y: f64;\n\n// @ts-ignore: decorator\n@lazy\nconst PIO2F_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 pio2f_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 = PIO2F_TABLE.dataStart;\n\n var offset = (u >> 23) - 152;\n var shift = (offset & 63);\n var tblPtr = bits + (offset >> 6 << 3);\n\n var b0 = load(tblPtr, 0 << 3);\n var b1 = load(tblPtr, 1 << 3);\n var lo: u64;\n\n if (shift > 32) {\n let b2 = load(tblPtr, 2 << 3);\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 = mantissa * hi + (mantissa * lo >> 32);\n var r: i64 = product << 2;\n var q = ((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 = pio2f_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 var y = builtin_abs(x);\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 let t: f32 = m & 2 ? 3 * pi / 4 : pi / 4;\n return m & 1 ? -t : t;\n } else {\n let t: f32 = m & 2 ? pi : 0.0;\n return m & 1 ? -t : t;\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(dtoi32(x));\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 > 0x7F800000) return x; // NaN\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 return (dtoi32(x) * dtoi32(y));\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 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 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 /* 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 /* 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 var sin = s, cos = c;\n if (n & 1) {\n sin = c;\n cos = -s;\n }\n if (n & 2) {\n sin = -sin;\n cos = -cos;\n }\n sincos_sin = sin;\n sincos_cos = cos;\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 { strtol } from "./util/string";\n\n// @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 isNaN(value: T): bool;\n\n// @ts-ignore: decorator\n@builtin\nexport declare function isFinite(value: T): bool;\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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 strtol(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 isNaN(value);\n }\n\n static isFinite(value: f64): bool {\n return 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 isFinite(value) && trunc(value) == value;\n }\n\n static parseInt(value: string, radix: i32 = 0): f64 {\n return strtol(value, radix);\n }\n\n static parseFloat(value: string): f64 {\n return parseFloat(value);\n }\n\n toString(this: f64, radix: i32 = 0): String {\n // TODO: radix\n return dtoa(this);\n }\n}\n\nexport { F64 as Number };\n',object:"export class Object {\n static is(value1: T, value2: T): bool {\n if (isFloat()) {\n if (value1 == value2) {\n // 0 === -0, but they are not identical\n if (sizeof() == 8) {\n // @ts-ignore: typecast\n return reinterpret(value1) == reinterpret(value2);\n } else {\n // @ts-ignore: typecast\n return reinterpret(value1) == reinterpret(value2);\n }\n }\n // NaN !== NaN, but they are identical.\n // @ts-ignore: typecast\n return bool(i32(isNaN(value1)) & i32(isNaN(value2)));\n }\n // For references, strings, integers and booleans\n return value1 == value2;\n }\n}\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",reference:"/** Host reference abstraction. */\n@sealed @unmanaged\nexport abstract class Anyref {\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("buffer"));\n store(array, buffer, offsetof("dataStart"));\n store(array, bufferSize, offsetof("byteLength"));\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 } 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 } 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 export 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\n// @ts-ignore: decorator\n@global @unsafe\nexport function __reset(): void {\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, AL_SIZE, DEBUG } 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\nfunction maybeGrowMemory(newOffset: usize): void {\n // assumes newOffset is aligned\n var pagesBefore = memory.size();\n var maxOffset = pagesBefore << 16;\n if (newOffset > maxOffset) {\n let pagesNeeded = ((newOffset - maxOffset + 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 = newOffset;\n}\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 actualSize = max((size + AL_MASK) & ~AL_MASK, AL_SIZE);\n maybeGrowMemory(ptr + actualSize);\n var block = changetype(ptr - BLOCK_OVERHEAD);\n block.mmInfo = actualSize;\n if (DEBUG) block.gcInfo = -1;\n block.rtId = id;\n block.rtSize = size;\n return ptr;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __realloc(ptr: usize, size: usize): usize {\n assert(ptr != 0 && !(ptr & AL_MASK)); // must exist and be aligned\n var block = changetype(ptr - BLOCK_OVERHEAD);\n var actualSize = block.mmInfo;\n if (DEBUG) assert(block.gcInfo == -1);\n var isLast = ptr + actualSize == offset;\n var alignedSize = (size + AL_MASK) & ~AL_MASK;\n if (size > actualSize) {\n if (isLast) { // last block: grow\n if (size > BLOCK_MAXSIZE) unreachable();\n maybeGrowMemory(ptr + alignedSize);\n block.mmInfo = alignedSize;\n } else { // copy to new block at least double the size\n let newPtr = __alloc(max(alignedSize, actualSize << 1), block.rtId);\n memory.copy(newPtr, ptr, block.rtSize);\n block = changetype((ptr = newPtr) - BLOCK_OVERHEAD);\n }\n } else if (isLast) { // last block: shrink\n offset = ptr + alignedSize;\n block.mmInfo = alignedSize;\n }\n block.rtSize = size;\n return ptr;\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __free(ptr: usize): void {\n assert(ptr != 0 && !(ptr & AL_MASK)); // must exist and be aligned\n var block = changetype(ptr - BLOCK_OVERHEAD);\n if (DEBUG) assert(block.gcInfo == -1);\n if (ptr + block.mmInfo == offset) { // last block: discard\n offset = changetype(block);\n }\n}\n\n// @ts-ignore: decorator\n@unsafe @global\nexport function __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\nfunction __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\";\nimport { REFCOUNT_MASK } from \"./pure\";\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 - (BLOCK_OVERHEAD << 1);\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 // Here, both rounding performed in searchBlock ...\n const halfMaxSize = BLOCK_MAXSIZE >> 1;\n if (size < halfMaxSize) { // don't round last fl\n const invRound = (sizeof() * 8 - 1) - SL_BITS;\n size += (1 << (invRound - clz(size))) - 1;\n }\n // and additional BLOCK_OVERHEAD must be taken into account. If we are going\n // to merge with the tail block, that's one time, otherwise it's two times.\n var pagesBefore = memory.size();\n size += BLOCK_OVERHEAD << usize((pagesBefore << 16) - BLOCK_OVERHEAD != changetype(GETTAIL(root)));\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// @ts-ignore: decorator\n@lazy\nvar collectLock: bool = false;\n\n/** Allocates a block of the specified size. */\nexport function allocateBlock(root: Root, size: usize): Block {\n if (DEBUG) assert(!collectLock); // must not allocate while collecting\n var payloadSize = prepareSize(size);\n var block = searchBlock(root, payloadSize);\n if (!block) {\n if (gc.auto) {\n if (DEBUG) collectLock = true;\n __collect();\n if (DEBUG) collectLock = false;\n 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 } else {\n growMemory(root, payloadSize);\n block = searchBlock(root, payloadSize);\n if (DEBUG) assert(block); // must be found now\n }\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) {\n assert(\n !(blockInfo & FREE) && // must be used\n !(block.gcInfo & ~REFCOUNT_MASK) // not buffered or != BLACK\n );\n }\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.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 if (isDefined(ASC_RTRACE)) onfree(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_N = 8;\n\n// @ts-ignore: decorator\n@inline\nconst FILL_FACTOR_D = 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR_N = 3;\n\n// @ts-ignore: decorator\n@inline\nconst FREE_FACTOR_D = 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: T, 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 @operator("[]")\n has(key: T): bool {\n return this.find(key, HASH(key)) !== null;\n }\n\n add(key: T): 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 / FREE_FACTOR_D\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 @operator("[]=")\n private __set(key: T, value: bool): void {\n if (value) this.add(key);\n else this.delete(key);\n }\n\n delete(key: T): 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 / FREE_FACTOR_D\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 / FILL_FACTOR_D;\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 values(): T[] {\n // FIXME: this is preliminary, needs iterators/closures\n var start = changetype(this.entries);\n var size = this.entriesOffset;\n var values = new Array(size);\n var length = 0;\n for (let i = 0; i < size; ++i) {\n let entry = changetype>(start + i * ENTRY_SIZE());\n if (!(entry.taggedNext & EMPTY)) {\n values.push(entry.key);\n ++length;\n }\n }\n values.length = length;\n return values;\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_GLOBALS = 1 << 1, // see: https://github.com/WebAssembly/mutable-global\n /** Non-trapping float to integer operations. */\n NONTRAPPING_F2I = 1 << 2, // see: https://github.com/WebAssembly/nontrapping-float-to-int-conversions\n /** Bulk memory operations. */\n BULK_MEMORY = 1 << 3, // see: https://github.com/WebAssembly/bulk-memory-operations\n /** SIMD types and operations. */\n SIMD = 1 << 4, // see: https://github.com/WebAssembly/simd\n /** Threading and atomic operations. */\n THREADS = 1 << 5, // see: https://github.com/WebAssembly/threads\n /** Exception handling operations. */\n EXCEPTION_HANDLING = 1 << 6, // see: https://github.com/WebAssembly/exception-handling\n /** Tail call operations. */\n TAIL_CALLS = 1 << 7, // see: https://github.com/WebAssembly/tail-call\n /** Reference types. */\n REFERENCE_TYPES = 1 << 8 // see: https://github.com/WebAssembly/reference-types\n}\n\n/** Gets the name of the specified feature one would specify on the command line. */\nexport function featureToString(feature: Feature): string {\n switch (feature) {\n case Feature.SIGN_EXTENSION: return "sign-extension";\n case Feature.MUTABLE_GLOBALS: return "mutable-globals";\n case Feature.NONTRAPPING_F2I: return "nontrapping-f2i";\n case Feature.BULK_MEMORY: return "bulk-memory";\n case Feature.SIMD: return "simd";\n case Feature.THREADS: return "threads";\n case Feature.EXCEPTION_HANDLING: return "exception-handling";\n case Feature.TAIL_CALLS: return "tail-calls";\n case Feature.REFERENCE_TYPES: return "reference-types";\n }\n assert(false);\n return "";\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 /** Key is a signed type. */\n KEY_SIGNED = 1 << 19,\n /** Key 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, strtol, strtod, isSpace } 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 static fromCharCode(unit: i32, surr: i32 = -1): string {\n var hasSur = surr > 0;\n var out = __alloc(2 << i32(hasSur), idof());\n store(out, unit);\n if (hasSur) store(out, surr, 2);\n return changetype(out); // retains\n }\n\n static fromCodePoint(code: i32): string {\n assert(code <= 0x10FFFF);\n var hasSur = code > 0xFFFF;\n var out = __alloc(2 << i32(hasSur), idof());\n if (!hasSur) {\n store(out, code);\n } else {\n code -= 0x10000;\n let lo: u32 = (code & 0x3FF) + 0xDC00;\n let hi: u32 = (code >>> 10) + 0xD800;\n store(out, hi | (lo << 16));\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 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(search: String, end: i32 = String.MAX_LENGTH): bool {\n if (search === null) return false;\n end = min(max(end, 0), this.length);\n var searchLength = search.length;\n var searchStart = end - searchLength;\n if (searchStart < 0) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, searchStart, search, 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 includes(search: String, start: i32 = 0): bool {\n return this.indexOf(search, start) != -1;\n }\n\n indexOf(search: String, start: i32 = 0): i32 {\n var searchLen = search.length;\n if (!searchLen) return 0;\n var len = this.length;\n if (!len) return -1;\n var searchStart = min(max(start, 0), len);\n for (len -= searchLen; searchStart <= len; ++searchStart) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, searchStart, search, 0, searchLen)) return searchStart;\n }\n return -1;\n }\n\n lastIndexOf(search: String, start: i32 = i32.MAX_VALUE): i32 {\n var searchLen = search.length;\n if (!searchLen) return this.length;\n var len = this.length;\n if (!len) return -1;\n var searchStart = min(max(start, 0), len - searchLen);\n for (; searchStart >= 0; --searchStart) {\n // @ts-ignore: string <-> String\n if (!compareImpl(this, searchStart, search, 0, searchLen)) return searchStart;\n }\n return -1;\n }\n\n startsWith(search: String, start: i32 = 0): bool {\n if (search === null) search = changetype("null");\n var len = this.length;\n var searchStart = min(max(start, 0), len);\n var searchLength = search.length;\n if (searchLength + searchStart > len) return false;\n // @ts-ignore: string <-> String\n return !compareImpl(this, searchStart, search, 0, searchLength);\n }\n\n substr(start: i32, length: i32 = i32.MAX_VALUE): String { // legacy\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 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 var length = this.length;\n var size: usize = length << 1;\n while (size && isSpace(load(changetype(this) + size - 2))) {\n size -= 2;\n }\n var offset: usize = 0;\n while (offset < size && isSpace(load(changetype(this) + offset))) {\n offset += 2; size -= 2;\n }\n if (!size) return changetype("");\n if (!offset && 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 var size = this.length << 1;\n var offset: usize = 0;\n while (offset < size && isSpace(load(changetype(this) + offset))) {\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 var originalSize = this.length << 1;\n var size = originalSize;\n while (size && isSpace(load(changetype(this) + size - 2))) {\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(length: i32, pad: string = " "): String {\n var thisSize = this.length << 1;\n var targetSize = length << 1;\n var padSize = pad.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(pad), padSize, repeatCount);\n memory.copy(out + restBase, changetype(pad), restSize);\n } else {\n memory.copy(out, changetype(pad), prependSize);\n }\n memory.copy(out + prependSize, changetype(this), thisSize);\n return changetype(out); // retains\n }\n\n padEnd(length: i32, pad: string = " "): String {\n var thisSize = this.length << 1;\n var targetSize = length << 1;\n var padSize = pad.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(pad), padSize, repeatCount);\n memory.copy(out + thisSize + restBase, changetype(pad), restSize);\n } else {\n memory.copy(out + thisSize, changetype(pad), appendSize);\n }\n return changetype(out); // retains\n }\n\n repeat(count: i32 = 0): String {\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 replace(search: String, replacement: String): String {\n var len: usize = this.length;\n var slen: usize = search.length;\n if (len <= slen) {\n return len < slen ? this : select(replacement, this, search == this);\n }\n var index: isize = this.indexOf(search);\n if (~index) {\n let rlen: usize = replacement.length;\n len -= slen;\n let olen = len + rlen;\n if (olen) {\n let out = __alloc(olen << 1, idof());\n memory.copy(out, changetype(this), index << 1);\n memory.copy(\n out + (index << 1),\n changetype(replacement),\n rlen << 1\n );\n memory.copy(\n out + ((index + rlen) << 1),\n changetype(this) + ((index + slen) << 1),\n (len - index) << 1\n );\n return changetype(out);\n }\n }\n return this;\n }\n\n replaceAll(search: String, replacement: String): String {\n var len: usize = this.length;\n var slen: usize = search.length;\n if (len <= slen) {\n return len < slen ? this : select(replacement, this, search == this);\n }\n var rlen: usize = replacement.length;\n if (!slen) {\n if (!rlen) return this;\n // Special case: \'abc\'.replaceAll(\'\', \'-\') -> \'-a-b-c-\'\n let out = __alloc((len + (len + 1) * rlen) << 1, idof());\n memory.copy(out, changetype(replacement), rlen << 1);\n let offset = rlen;\n for (let i: usize = 0; i < len; ++i) {\n store(\n changetype(out) + (offset++ << 1),\n load(changetype(this) + (i << 1))\n );\n memory.copy(\n out + (offset << 1),\n changetype(replacement),\n rlen << 1\n );\n offset += rlen;\n }\n return changetype(out);\n }\n var prev: isize = 0, next: isize = 0;\n if (slen == rlen) {\n // Fast path when search and replacement have same length\n let size = len << 1;\n let out = __alloc(size, idof());\n memory.copy(out, changetype(this), size);\n while (~(next = this.indexOf(search, prev))) {\n memory.copy(out + (next << 1), changetype(replacement), rlen << 1);\n prev = next + slen;\n }\n return changetype(out);\n }\n var out: usize = 0, offset: usize = 0, resLen = len;\n while (~(next = this.indexOf(search, prev))) {\n if (!out) out = __alloc(len << 1, idof());\n if (offset > resLen) {\n let newLength = resLen << 1;\n out = __realloc(out, newLength << 1);\n resLen = newLength;\n }\n let chunk = next - prev;\n memory.copy(\n out + (offset << 1),\n changetype(this) + (prev << 1),\n chunk << 1\n );\n offset += chunk;\n memory.copy(\n out + (offset << 1),\n changetype(replacement),\n rlen << 1\n );\n offset += rlen;\n prev = next + slen;\n }\n if (offset) {\n if (offset > resLen) {\n let newLength = resLen << 1;\n out = __realloc(out, newLength << 1);\n resLen = newLength;\n }\n let rest = len - prev;\n if (rest) {\n memory.copy(\n out + (offset << 1),\n changetype(this) + (prev << 1),\n rest << 1\n );\n }\n rest += offset;\n if (resLen > rest) out = __realloc(out, rest << 1);\n return changetype(out);\n }\n return this;\n }\n\n slice(start: i32, end: i32 = i32.MAX_VALUE): String {\n var len = this.length;\n start = start < 0 ? max(start + len, 0) : min(start, len);\n end = end < 0 ? max(end + len, 0) : min(end, len);\n len = end - start;\n if (len <= 0) return changetype("");\n var out = __alloc(len << 1, idof());\n memory.copy(out, changetype(this) + (start << 1), len << 1);\n return changetype(out); // retains\n }\n\n split(separator: String | null = null, limit: i32 = i32.MAX_VALUE): String[] {\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))) {\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\n// @ts-ignore: nolib\nexport type string = String;\n\nexport function parseInt(str: string, radix: i32 = 0): f64 {\n return strtol(str, radix);\n}\n\nexport function parseFloat(str: string): f64 {\n return strtod(str);\n}\n\n// Encoding helpers\nexport namespace String {\n\n export namespace UTF8 {\n\n export function byteLength(str: string, nullTerminated: bool = false): i32 {\n var strOff = changetype(str);\n var strEnd = strOff + changetype(changetype(str) - BLOCK_OVERHEAD).rtSize;\n var bufLen = nullTerminated ? 1 : 0;\n while (strOff < strEnd) {\n let c1 = load(strOff);\n if (c1 < 128) {\n if (nullTerminated && !c1) break;\n bufLen += 1; strOff += 2;\n } else if (c1 < 2048) {\n bufLen += 2; strOff += 2;\n } else {\n if ((c1 & 0xFC00) == 0xD800 && strOff + 2 < strEnd) {\n if ((load(strOff, 2) & 0xFC00) == 0xDC00) {\n strOff += 4; bufLen += 4;\n continue;\n }\n }\n strOff += 2; bufLen += 3;\n }\n }\n return bufLen;\n }\n\n export function encode(str: string, nullTerminated: bool = false): ArrayBuffer {\n var strOff = changetype(str);\n var strEnd = changetype(str) + changetype(changetype(str) - BLOCK_OVERHEAD).rtSize;\n var buf = __alloc(UTF8.byteLength(str, nullTerminated), idof());\n var bufOff = buf;\n while (strOff < strEnd) {\n let c1 = load(strOff);\n if (c1 < 128) {\n if (nullTerminated && !c1) break;\n store(bufOff, c1);\n bufOff += 1; strOff += 2;\n } else if (c1 < 2048) {\n store(bufOff, c1 >> 6 | 192);\n store(bufOff, c1 & 63 | 128, 1);\n bufOff += 2; strOff += 2;\n } else {\n if ((c1 & 0xFC00) == 0xD800 && strOff + 2 < strEnd) {\n let c2 = load(strOff, 2);\n if ((c2 & 0xFC00) == 0xDC00) {\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\n store(bufOff, c1 >> 18 | 240);\n store(bufOff, c1 >> 12 & 63 | 128, 1);\n store(bufOff, c1 >> 6 & 63 | 128, 2);\n store(bufOff, c1 & 63 | 128, 3);\n strOff += 4; bufOff += 4;\n continue;\n }\n }\n store(bufOff, c1 >> 12 | 224);\n store(bufOff, c1 >> 6 & 63 | 128, 1);\n store(bufOff, c1 & 63 | 128, 2);\n strOff += 2; bufOff += 3;\n }\n }\n if (nullTerminated) {\n assert(strOff <= strEnd);\n buf = __realloc(buf, bufOff - buf + 1);\n store(bufOff, 0);\n } else {\n assert(strOff == strEnd);\n }\n return changetype(buf); // retains\n }\n\n export function decode(buf: ArrayBuffer, nullTerminated: bool = false): string {\n return decodeUnsafe(changetype(buf), buf.byteLength, nullTerminated);\n }\n\n // @ts-ignore: decorator\n @unsafe\n export function decodeUnsafe(buf: usize, len: usize, nullTerminated: bool = false): string {\n var bufOff = buf;\n var bufEnd = buf + len;\n assert(bufEnd >= bufOff); // guard wraparound\n var str = __alloc(len << 1, idof()); // max is one u16 char per u8 byte\n var strOff = str;\n while (bufOff < bufEnd) {\n let cp = load(bufOff++);\n if (cp < 128) {\n if (nullTerminated && !cp) break;\n store(strOff, cp);\n strOff += 2;\n } else if (cp > 191 && cp < 224) {\n if (bufEnd - bufOff < 1) break;\n store(strOff, (cp & 31) << 6 | load(bufOff++) & 63);\n strOff += 2;\n } else if (cp > 239 && cp < 365) {\n if (bufEnd - bufOff < 3) break;\n cp = (\n (cp & 7) << 18 |\n (load(bufOff) & 63) << 12 |\n (load(bufOff, 1) & 63) << 6 |\n load(bufOff, 2) & 63\n ) - 0x10000;\n bufOff += 3;\n store(strOff, 0xD800 + (cp >> 10));\n store(strOff, 0xDC00 + (cp & 1023), 2);\n strOff += 4;\n } else {\n if (bufEnd - bufOff < 2) break;\n store(strOff,\n (cp & 15) << 12 |\n (load(bufOff) & 63) << 6 |\n load(bufOff, 1) & 63\n );\n bufOff += 2; strOff += 2;\n }\n }\n return changetype(__realloc(str, strOff - str)); // retains\n }\n }\n\n export namespace UTF16 {\n\n export function byteLength(str: string): i32 {\n return changetype(changetype(str) - BLOCK_OVERHEAD).rtSize;\n }\n\n export function encode(str: string): ArrayBuffer {\n var size = changetype(changetype(str) - BLOCK_OVERHEAD).rtSize;\n var buf = __alloc(size, idof());\n memory.copy(buf, changetype(str), size);\n return changetype(buf); // retains\n }\n\n export function decode(buf: ArrayBuffer): string {\n return decodeUnsafe(changetype(buf), buf.byteLength);\n }\n\n // @ts-ignore: decorator\n @unsafe\n export function decodeUnsafe(buf: usize, len: usize): string {\n var str = __alloc(len &= ~1, idof());\n memory.copy(str, buf, len);\n return changetype(str); // retains\n }\n }\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, E_INVALIDLENGTH } from "./util/error";\nimport { joinIntegerArray, joinFloatArray } from "./util/string";\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 length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]")\n private __get(index: i32): i8 {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): i8 {\n return load(this.dataStart + index);\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + index, value);\n }\n\n includes(searchElement: i8, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: i8, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: i8, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int8Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: i8, index: i32, array: Int8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: i8, index: i32, self: Int8Array) => i8): Int8Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: i8, index: i32, self: Int8Array) => bool): Int8Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: i8, index: i32, self: Int8Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: i8, index: i32, self: Int8Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: i8, index: i32, self: Int8Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int8Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]")\n private __get(index: i32): u8 {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u8 {\n return load(this.dataStart + index);\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + index, value);\n }\n\n includes(searchElement: u8, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u8, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u8, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint8Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u8, index: i32, array: Uint8Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u8, index: i32, self: Uint8Array) => u8): Uint8Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u8, index: i32, self: Uint8Array) => bool): Uint8Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u8, index: i32, self: Uint8Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u8, index: i32, self: Uint8Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u8, index: i32, self: Uint8Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint8Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength;\n }\n\n @operator("[]")\n private __get(index: i32): u8 {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + index);\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u8 {\n return load(this.dataStart + index);\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + index, ~(value >> 31) & (((255 - value) >> 31) | value));\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + index, ~(value >> 31) & (((255 - value) >> 31) | value));\n }\n\n includes(searchElement: u8, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u8, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u8, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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(fn: (a: u8, b: u8) => i32 = COMPARATOR()): Uint8ClampedArray {\n return SORT(this, fn);\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return SLICE(this, begin, end);\n }\n\n subarray(start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return SUBARRAY(this, start, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint8ClampedArray {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u8, index: i32, array: Uint8ClampedArray) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u8, index: i32, self: Uint8ClampedArray) => u8): Uint8ClampedArray {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): Uint8ClampedArray {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u8, index: i32, self: Uint8ClampedArray) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u8, index: i32, self: Uint8ClampedArray) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint8ClampedArray {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): i16 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): i16 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: i16, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: i16, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: i16, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int16Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: i16, index: i32, array: Int16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: i16, index: i32, self: Int16Array) => i16): Int16Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: i16, index: i32, self: Int16Array) => bool): Int16Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: i16, index: i32, self: Int16Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: i16, index: i32, self: Int16Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: i16, index: i32, self: Int16Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int16Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): u16 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u16 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: native): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: native): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: u16, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u16, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u16, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint16Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u16, index: i32, array: Uint16Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u16, index: i32, self: Uint16Array) => u16): Uint16Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u16, index: i32, self: Uint16Array) => bool): Uint16Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u16, index: i32, self: Uint16Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u16, index: i32, self: Uint16Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u16, index: i32, self: Uint16Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint16Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): i32 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): i32 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: i32): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: i32): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: i32, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: i32, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: i32, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int32Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: i32, index: i32, array: Int32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: i32, index: i32, self: Int32Array) => i32): Int32Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: i32, index: i32, self: Int32Array) => bool): Int32Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: i32, index: i32, self: Int32Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: i32, index: i32, self: Int32Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: i32, index: i32, self: Int32Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int32Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): u32 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u32 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: u32): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: u32): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: u32, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u32, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u32, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint32Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u32, index: i32, array: Uint32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u32, index: i32, self: Uint32Array) => u32): Uint32Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u32, index: i32, self: Uint32Array) => bool): Uint32Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u32, index: i32, self: Uint32Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u32, index: i32, self: Uint32Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u32, index: i32, self: Uint32Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint32Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): i64 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): i64 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: i64): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: i64): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: i64, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: i64, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: i64, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Int64Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: i64, index: i32, array: Int64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: i64, index: i32, self: Int64Array) => i64): Int64Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: i64, index: i32, self: Int64Array) => bool): Int64Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: i64, index: i32, self: Int64Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: i64, index: i32, self: Int64Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: i64, index: i32, self: Int64Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Int64Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): u64 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): u64 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: u64): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: u64): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: u64, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: u64, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: u64, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Uint64Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: u64, index: i32, array: Uint64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: u64, index: i32, self: Uint64Array) => u64): Uint64Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: u64, index: i32, self: Uint64Array) => bool): Uint64Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: u64, index: i32, self: Uint64Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: u64, index: i32, self: Uint64Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: u64, index: i32, self: Uint64Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinIntegerArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Uint64Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): f32 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): f32 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: f32): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: f32): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: f32, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: f32, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: f32, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Float32Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: f32, index: i32, array: Float32Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: f32, index: i32, self: Float32Array) => f32): Float32Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: f32, index: i32, self: Float32Array) => bool): Float32Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: f32, index: i32, self: Float32Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: f32, index: i32, self: Float32Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: f32, index: i32, self: Float32Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinFloatArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Float32Array {\n return WRAP(buffer, byteOffset, length);\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 length(): i32 {\n return this.byteLength >>> alignof();\n }\n\n @operator("[]")\n private __get(index: i32): f64 {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n return load(this.dataStart + (index << alignof()));\n }\n\n @unsafe @operator("{}")\n private __uget(index: i32): f64 {\n return load(this.dataStart + (index << alignof()));\n }\n\n @operator("[]=")\n private __set(index: i32, value: f64): void {\n if (index >= this.byteLength >>> alignof()) throw new RangeError(E_INDEXOUTOFRANGE);\n store(this.dataStart + (index << alignof()), value);\n }\n\n @unsafe @operator("{}=")\n private __uset(index: i32, value: f64): void {\n store(this.dataStart + (index << alignof()), value);\n }\n\n includes(searchElement: f64, fromIndex: i32 = 0): bool {\n return INCLUDES(this, searchElement, fromIndex);\n }\n\n indexOf(searchElement: f64, fromIndex: i32 = 0): i32 {\n return INDEX_OF(this, searchElement, fromIndex);\n }\n\n lastIndexOf(searchElement: f64, fromIndex: i32 = this.length): i32 {\n return LAST_INDEX_OF(this, searchElement, fromIndex);\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 slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {\n return SLICE(this, begin, end);\n }\n\n subarray(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array {\n return SUBARRAY(this, begin, end);\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): Float64Array {\n return COPY_WITHIN(this, target, start, end);\n }\n\n reduce(\n fn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE(this, fn, initialValue);\n }\n\n reduceRight(\n fn: (accumulator: T, value: f64, index: i32, array: Float64Array) => T,\n initialValue: T,\n ): T {\n return REDUCE_RIGHT(this, fn, initialValue);\n }\n\n map(fn: (value: f64, index: i32, self: Float64Array) => f64): Float64Array {\n return MAP(this, fn);\n }\n\n filter(fn: (value: f64, index: i32, self: Float64Array) => bool): Float64Array {\n return FILTER(this, fn);\n }\n\n findIndex(fn: (value: f64, index: i32, self: Float64Array) => bool): i32 {\n return FIND_INDEX(this, fn);\n }\n\n some(fn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return SOME(this, fn);\n }\n\n every(fn: (value: f64, index: i32, self: Float64Array) => bool): bool {\n return EVERY(this, fn);\n }\n\n forEach(fn: (value: f64, index: i32, self: Float64Array) => void): void {\n FOREACH(this, fn);\n }\n\n reverse(): this {\n return REVERSE(this);\n }\n\n join(separator: string = ","): string {\n return joinFloatArray(this.dataStart, this.length, separator);\n }\n\n toString(): string {\n return this.join();\n }\n\n static wrap(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): Float64Array {\n return WRAP(buffer, byteOffset, length);\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 len = array.length;\n start = start < 0 ? max(len + start, 0) : min(start, len);\n end = end < 0 ? max(len + end, 0) : min(end, len);\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 len = array.length;\n if (len <= 1) return array;\n var base = array.dataStart;\n if (len == 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, len, comparator);\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SLICE(\n array: TArray,\n start: i32,\n end: i32\n): TArray {\n var len = array.length;\n start = start < 0 ? max(start + len, 0) : min(start, len);\n end = end < 0 ? max(end + len, 0) : min(end , len);\n len = max(end - start, 0);\n var slice = instantiate(len);\n memory.copy(\n slice.dataStart,\n array.dataStart + (start << alignof()),\n len << alignof()\n );\n return slice;\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\n var out = __alloc(offsetof(), idof());\n store(out, __retain(changetype(array.buffer)), offsetof("buffer"));\n store(out, array.dataStart + (begin << alignof()), offsetof("dataStart"));\n store(out, (end - begin) << alignof(), offsetof("byteLength"));\n return changetype(out); // retains\n}\n\n// @ts-ignore: decorator\n@inline\nfunction COPY_WITHIN(\n array: TArray,\n target: i32,\n start: i32,\n end: i32\n): TArray {\n var len = array.length;\n var dataStart = array.dataStart;\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 memory.copy(\n dataStart + (to << alignof()),\n dataStart + (from << alignof()),\n count << alignof()\n );\n return array;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REDUCE(\n array: TArray,\n fn: (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 = fn(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 fn: (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 = fn(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 fn: (value: T, index: i32, self: TArray) => T,\n): TArray {\n var len = array.length;\n var dataStart = array.dataStart;\n\n var byteLength = len << alignof();\n var out = __alloc(offsetof(), idof());\n var buffer = __alloc(byteLength, idof());\n for (let i = 0; i < len; i++) {\n store(\n buffer + (i << alignof()),\n fn(load(dataStart + (i << alignof())), i, array)\n );\n }\n store(out, __retain(buffer), offsetof("buffer"));\n store(out, buffer, offsetof("dataStart"));\n store(out, byteLength, offsetof("byteLength"));\n return changetype(out); // retains\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FILTER(\n array: TArray,\n fn: (value: T, index: i32, self: TArray) => bool,\n): TArray {\n var len = array.length;\n var out = __alloc(offsetof(), idof());\n var buffer = __alloc(len << alignof(), idof());\n var dataStart = array.dataStart;\n var j: usize = 0;\n for (let i = 0; i < len; i++) {\n let value = load(dataStart + (i << alignof()));\n if (fn(value, i, array)) {\n store(\n buffer + (j++ << alignof()),\n value\n );\n }\n }\n // shrink output buffer\n var byteLength = j << alignof();\n var data = __realloc(buffer, byteLength);\n store(out, __retain(data), offsetof("buffer"));\n store(out, byteLength, offsetof("byteLength"));\n store(out, data, offsetof("dataStart"));\n return changetype(out); // retains\n}\n\n// @ts-ignore: decorator\n@inline\nfunction FIND_INDEX(\n array: TArray,\n fn: (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 (fn(load(dataStart + (i << alignof())), i, array)) return i;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction INCLUDES(\n array: TArray,\n searchElement: T,\n fromIndex: i32,\n): bool {\n if (isFloat()) {\n let index: isize = fromIndex;\n let length: isize = array.length;\n if (length == 0 || index >= length) return false;\n if (index < 0) index = max(length + index, 0);\n let dataStart = array.dataStart;\n while (index < length) {\n let elem = load(dataStart + (index << alignof()));\n // @ts-ignore\n if (elem == searchElement || isNaN(elem) & isNaN(searchElement)) return true;\n ++index;\n }\n return false;\n } else {\n return INDEX_OF(array, searchElement, fromIndex) >= 0;\n }\n}\n\n// @ts-ignore: decorator\n@inline\nfunction INDEX_OF(\n array: TArray,\n searchElement: T,\n fromIndex: i32,\n): i32 {\n var index: isize = fromIndex;\n var length: isize = array.length;\n if (length == 0 || index >= length) return -1;\n if (index < 0) index = max(length + index, 0);\n var dataStart = array.dataStart;\n while (index < length) {\n if (load(dataStart + (index << alignof())) == searchElement) return index;\n ++index;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction LAST_INDEX_OF(\n array: TArray,\n searchElement: T,\n fromIndex: i32,\n): i32 {\n var index: isize = fromIndex;\n var length: isize = array.length;\n if (length == 0) return -1;\n if (index < 0) index = length + index; // no need to clamp\n else if (index >= length) index = length - 1;\n var dataStart = array.dataStart;\n while (index >= 0) {\n if (load(dataStart + (index << alignof())) == searchElement) return index;\n --index;\n }\n return -1;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction SOME(\n array: TArray,\n fn: (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 (fn(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 fn: (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 (fn(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 fn: (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 fn(load(dataStart + (i << alignof())), i, array);\n }\n}\n\n// @ts-ignore: decorator\n@inline\nfunction REVERSE(array: TArray): TArray {\n var dataStart = array.dataStart;\n for (let front: usize = 0, back: usize = 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\n// @ts-ignore: decorator\n@inline\nfunction WRAP(buffer: ArrayBuffer, byteOffset: i32 = 0, length: i32 = -1): TArray {\n var bufferByteLength = buffer.byteLength;\n if (byteOffset >= bufferByteLength) {\n throw new RangeError(E_INDEXOUTOFRANGE);\n }\n var byteLength: i32;\n if (length < 0) {\n if (length == -1) {\n const mask = (1 << alignof() - 1);\n if (buffer.byteLength & mask) {\n throw new RangeError(E_INVALIDLENGTH);\n } else {\n byteLength = buffer.byteLength;\n }\n } else {\n throw new RangeError(E_INVALIDLENGTH);\n }\n } else {\n byteLength = length << alignof();\n }\n if (byteOffset + byteLength > buffer.byteLength) {\n throw new RangeError(E_INVALIDLENGTH);\n }\n var out = __alloc(offsetof(), idof());\n store(out, __retain(changetype(buffer)), offsetof("buffer"));\n store(out, byteLength, offsetof("byteLength"));\n store(out, changetype(buffer) + byteOffset, offsetof("dataStart"));\n return changetype(out); // retains\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\n// @ts-ignore: decorator\n@lazy @inline\nexport const E_KEYNOTFOUND: string = "Key does not exist";\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 {\n if (vl == vr) return 0;\n if (ASC_SHRINK_LEVEL < 2) {\n if ((vl & 7) == (vr & 7)) {\n while (vl & 7) {\n if (!n) return 0;\n let a = load(vl);\n let b = load(vr);\n if (a != b) return a - b;\n n--; vl++; vr++;\n }\n while (n >= 8) {\n if (load(vl) != load(vr)) break;\n vl += 8;\n vr += 8;\n n -= 8;\n }\n }\n }\n while (n--) {\n let a = load(vl);\n let b = load(vr);\n if (a != b) return a - b;\n vl++; vr++;\n }\n return 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 let m = select(11, 12, value < 100000000000);\n return select(10, m, value < 10000000000);\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":'import { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./number";\nimport { ipow32 } from "../math";\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 I = 0x49,\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\n// 9 * 8 = 72 bytes\n// @ts-ignore: decorator\n@lazy\nconst Powers10Hi: f64[] = [1, 1e32, 1e64, 1e96, 1e128, 1e160, 1e192, 1e224, 1e256, 1e288];\n// 32 * 8 = 256 bytes\n// @ts-ignore: decorator\n@lazy\nconst Powers10Lo: f64[] = [\n 1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09,\n 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,\n 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29,\n 1e30, 1e31\n];\n\nexport function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 {\n var ptr1 = changetype(str1) + (index1 << 1);\n var ptr2 = changetype(str2) + (index2 << 1);\n if (ASC_SHRINK_LEVEL < 2) {\n if (len >= 4 && !((ptr1 & 7) | (ptr2 & 7))) {\n do {\n if (load(ptr1) != load(ptr2)) break;\n ptr1 += 8;\n ptr2 += 8;\n len -= 4;\n } while (len >= 4);\n }\n }\n while (len--) {\n let a = load(ptr1);\n let b = load(ptr2);\n if (a != b) return a - b;\n ptr1 += 2;\n ptr2 += 2;\n }\n return 0;\n}\n\nexport function isSpace(c: i32): bool {\n if (c <= 0xFF) {\n // , , , , , and \n return c == 0x20 || (c - 0x09) <= 0x0D - 0x09 || c == 0xA0;\n }\n if ((c - 0x2000) <= 0x200A - 0x2000) return true;\n switch (c) {\n case 0x1680: // (1)\n case 0x2028: // (2)\n case 0x2029: // \n case 0x202F: // \n case 0x205F: // \n case 0x3000: // \n case 0xFEFF: return true; // \n }\n return false;\n}\n\n/** Parses a string to an integer (usually), using the specified radix. */\nexport function strtol(str: string, radix: i32 = 0): T {\n var len = str.length;\n if (!len) {\n // @ts-ignore: cast\n if (isFloat()) return NaN;\n // @ts-ignore: cast\n return 0;\n }\n\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr);\n\n // determine sign\n // @ts-ignore: cast\n var sign: T = 1;\n // trim white spaces\n while (isSpace(code)) {\n code = load(ptr += 2);\n --len;\n }\n if (code == CharCode.MINUS) {\n if (!--len) {\n // @ts-ignore: cast\n if (isFloat()) return NaN;\n // @ts-ignore: cast\n return 0;\n }\n code = load(ptr += 2);\n // @ts-ignore: type\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len) {\n // @ts-ignore: cast\n if (isFloat()) return NaN;\n // @ts-ignore: cast\n return 0;\n }\n code = load(ptr += 2);\n }\n\n // determine radix\n if (!radix) {\n if (code == CharCode._0 && len > 2) {\n switch (load(ptr + 2) | 32) {\n case CharCode.b: {\n ptr += 4; len -= 2;\n radix = 2;\n break;\n }\n case CharCode.o: {\n ptr += 4; len -= 2;\n radix = 8;\n break;\n }\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 if (isFloat()) return NaN;\n // @ts-ignore: cast\n return 0;\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 < 10) {\n code -= CharCode._0;\n } else if (code - CharCode.A <= (CharCode.Z - CharCode.A)) {\n code -= CharCode.A - 10;\n } else if (code - CharCode.a <= (CharCode.z - CharCode.a)) {\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\nexport function strtod(str: string): f64 {\n var len = str.length;\n if (!len) return NaN;\n\n var ptr = changetype(str);\n var code = load(ptr);\n\n var sign = 1.;\n // skip white spaces\n while (len && isSpace(code)) {\n code = load(ptr += 2);\n --len;\n }\n if (!len) return NaN;\n\n // try parse \'-\' or \'+\'\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 }\n\n // try parse Infinity\n if (len >= 8 && code == CharCode.I) {\n if (\n load(ptr, 0) == 0x690066006E0049 && // ifnI\n load(ptr, 8) == 0x7900740069006E // ytin\n ) {\n return copysign(Infinity, sign);\n }\n return NaN;\n }\n // validate next symbol\n if (code != CharCode.DOT && (code - CharCode._0) >= 10) {\n return NaN;\n }\n var savedPtr = ptr;\n // skip zeros\n while (code == CharCode._0) {\n code = load(ptr += 2);\n --len;\n }\n if (len <= 0) return 0;\n const capacity = 19; // int(64 * 0.3010)\n var pointed = false;\n var consumed = 0;\n var position = 0;\n var x: u64 = 0;\n if (code == CharCode.DOT) {\n let noDigits = !(savedPtr - ptr);\n ptr += 2; --len;\n if (!len && noDigits) return NaN;\n for (pointed = true; (code = load(ptr)) == CharCode._0; --position, ptr += 2) --len;\n if (len <= 0) return 0;\n if (!position && noDigits && code - CharCode._0 >= 10) return NaN;\n }\n for (let digit = code - CharCode._0; digit < 10 || (code == CharCode.DOT && !pointed); digit = code - CharCode._0) {\n if (digit < 10) {\n x = consumed < capacity ? 10 * x + digit : x | u64(!!digit);\n ++consumed;\n } else {\n position = consumed;\n pointed = true;\n }\n if (!--len) break;\n code = load(ptr += 2);\n }\n\n if (!pointed) position = consumed;\n return copysign(scientific(x, position - min(capacity, consumed) + parseExp(ptr, len)), sign);\n}\n\nexport function joinBooleanArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\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\nexport function joinIntegerArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\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\nexport function joinFloatArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\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\nexport function joinStringArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\n if (!lastIndex) {\n // @ts-ignore: type\n return load(dataStart) || "";\n }\n var estLen = 0;\n var value: string;\n for (let i = 0; i < length; ++i) {\n value = load(dataStart + (i << alignof()));\n // @ts-ignore: type\n if (value !== null) estLen += value.length;\n }\n var offset = 0;\n var sepLen = separator.length;\n var result = __alloc((estLen + sepLen * lastIndex) << 1, idof());\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n if (value !== null) {\n let valueLen = value.length;\n memory.copy(\n result + (offset << 1),\n changetype(value),\n valueLen << 1\n );\n offset += valueLen;\n }\n if (sepLen) {\n memory.copy(\n 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 result + (offset << 1),\n changetype(value),\n value.length << 1\n );\n }\n return changetype(result); // retains\n}\n\nexport function joinReferenceArray(dataStart: usize, length: i32, separator: string): string {\n var lastIndex = length - 1;\n if (lastIndex < 0) return "";\n var value: T;\n if (!lastIndex) {\n value = load(dataStart);\n // @ts-ignore: type\n return value !== null ? value.toString() : "";\n }\n var result = "";\n var sepLen = separator.length;\n for (let i = 0; i < lastIndex; ++i) {\n value = load(dataStart + (i << alignof()));\n // @ts-ignore: type\n if (value !== null) result += value.toString();\n if (sepLen) result += separator;\n }\n value = load(dataStart + (lastIndex << alignof()));\n // @ts-ignore: type\n if (value !== null) result += value.toString();\n return result;\n}\n\n// @ts-ignore: decorator\n@inline\nfunction scientific(significand: u64, exp: i32): f64 {\n if (!significand || exp < -342) return 0;\n if (exp > 308) return Infinity;\n // Try use fast path\n // Use fast path for string-to-double conversion if possible\n // see http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion\n // Simple integer\n var significandf = significand;\n if (!exp) return significandf;\n if (exp > 22 && exp <= 22 + 15) {\n significandf *= pow10(exp - 22);\n exp = 22;\n }\n if (significand <= 9007199254740991 && abs(exp) <= 22) {\n if (exp > 0) return significandf * pow10(exp);\n return significandf / pow10(-exp);\n } else if (exp < 0) {\n return scaledown(significand, exp);\n } else {\n return scaleup(significand, exp);\n }\n}\n\n// Adopted from metallic lib:\n// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h\n// @ts-ignore: decorator\n@inline\nfunction scaledown(significand: u64, exp: i32): f64 {\n const denom: u64 = 6103515625; // 1e14 * 0x1p-14\n const scale = reinterpret(0x3F06849B86A12B9B); // 1e-14 * 0x1p32\n\n var shift = clz(significand);\n significand <<= shift;\n shift = exp - shift;\n\n for (; exp <= -14; exp += 14) {\n let q = significand / denom;\n let r = significand % denom;\n let s = clz(q);\n significand = (q << s) + nearest(scale * (r << (s - 18)));\n shift -= s;\n }\n var b = ipow32(5, -exp);\n var q = significand / b;\n var r = significand % b;\n var s = clz(q);\n significand = (q << s) + (reinterpret(reinterpret(r) + (s << 52)) / b);\n shift -= s;\n\n return NativeMath.scalbn(significand, shift);\n}\n\n// Adopted from metallic lib:\n// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h\n// @ts-ignore: decorator\n@inline\nfunction scaleup(significand: u64, exp: i32): f64 {\n const coeff: u32 = 1220703125; // 1e13 * 0x1p-13;\n var shift = ctz(significand);\n significand >>= shift;\n shift += exp;\n\n __fixmulShift = shift;\n for (; exp >= 13; exp -= 13) {\n significand = fixmul(significand, coeff);\n }\n significand = fixmul(significand, ipow32(5, exp));\n shift = __fixmulShift;\n return NativeMath.scalbn(significand, shift);\n}\n\n// Adopted from metallic lib:\n// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h\n// @ts-ignore: decorator\n@inline\nfunction parseExp(ptr: usize, len: i32): i32 {\n var sign = 1, magnitude = 0;\n var code = load(ptr);\n // check code is \'e\' or \'E\'\n if ((code | 32) != CharCode.e) return 0;\n\n code = load(ptr += 2);\n if (code == CharCode.MINUS) {\n if (!--len) return 0;\n code = load(ptr += 2);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len) return 0;\n code = load(ptr += 2);\n }\n // skip zeros\n while (code == CharCode._0) {\n if (!--len) return 0;\n code = load(ptr += 2);\n }\n for (let digit: u32 = code - CharCode._0; len && digit < 10; digit = code - CharCode._0) {\n if (magnitude >= 3200) return sign * 3200;\n magnitude = 10 * magnitude + digit;\n code = load(ptr += 2);\n --len;\n }\n return sign * magnitude;\n}\n\n// @ts-ignore: decorator\n@lazy\nvar __fixmulShift: u64 = 0;\n\n// Adopted from metallic lib:\n// https://github.com/jdh8/metallic/blob/master/src/stdlib/parse/scientific.h\n// @ts-ignore: decorator\n@inline\nfunction fixmul(a: u64, b: u32): u64 {\n var low = (a & 0xFFFFFFFF) * b;\n var high = (a >> 32) * b + (low >> 32);\n var overflow = (high >> 32);\n var space = clz(overflow);\n var revspace: u64 = 32 - space;\n __fixmulShift += revspace;\n return (high << space | (low & 0xFFFFFFFF) >> revspace) + (low << space >> 31 & 1);\n}\n\n// @ts-ignore: decorator\nfunction pow10(n: i32): f64 {\n // @ts-ignore: type\n const hi = Powers10Hi.dataStart;\n // @ts-ignore: type\n const lo = Powers10Lo.dataStart;\n return (\n load(hi + ((n >> 5) << alignof())) *\n load(lo + ((n & 31) << alignof()))\n );\n}\n',vector:"/** Vector abstraction. */\n@sealed @unmanaged\nexport abstract class V128 {\n}\n"}):(()=>{const n=path.join(".","..","std","assembly"),e={};return find.files(n,find.TS_EXCEPT_DTS).forEach(t=>e[t.replace(/\.ts$/,"")]=fs.readFileSync(path.join(n,t),"utf8")),e})(),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/** A host reference. */\ndeclare type anyref = 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 sign extension feature is enabled. */\ndeclare const ASC_FEATURE_SIGN_EXTENSION: bool;\n/** Whether the mutable globals feature is enabled. */\ndeclare const ASC_FEATURE_MUTABLE_GLOBALS: bool;\n/** Whether the non-trapping float-to-int feature is enabled. */\ndeclare const ASC_FEATURE_NONTRAPPING_F2I: 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/** Whether the exception handling feature is enabled. */\ndeclare const ASC_FEATURE_EXCEPTION_HANDLING: bool;\n/** Whether the tail calls feature is enabled. */\ndeclare const ASC_FEATURE_TAIL_CALLS: bool;\n/** Whether the reference types feature is enabled. */\ndeclare const ASC_FEATURE_REFERENCE_TYPES: 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 end offset of the given class type. Compiles to a constant. */\ndeclare function offsetof(): usize;\n/** Determines the offset of the specified field within the given class type. Compiles to a constant. */\ndeclare function offsetof(fieldName: keyof T | string): 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 name of a given type. */\ndeclare function nameof(value?: T): string;\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/** Tests if the specified type is void. Compiles to a constant. */\ndeclare function isVoid(): 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 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/** Returns the number of parameters in the given function signature type. */\ndeclare function lengthof any>(func?: T): i32;\n\n/** Atomic operations. */\ndeclare namespace atomic {\n /** Atomically loads an integer value from memory and returns it. */\n export function load(ptr: usize, immOffset?: usize): T;\n /** Atomically stores an integer value to memory. */\n export function store(ptr: 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 /** Performs a fence operation, preserving synchronization guarantees of higher level languages. */\n export function fence(): void;\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(ptr: 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(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Loads a 32-bit integer value from memory. */\n export function load(ptr: usize, immOffset?: usize, immAlign?: usize): i32;\n /** Stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(ptr: 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(ptr: usize, value: i32, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 32-bit integer value to memory. */\n export function store(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize): i32;\n /** Atomically loads a 32-bit integer value from memory and returns it. */\n export function load(ptr: usize, immOffset?: usize): i32;\n /** Atomically stores a 32-bit integer value to memory as an 8-bit integer. */\n export function store8(ptr: 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(ptr: usize, value: i32, immOffset?: usize): void;\n /** Atomically stores a 32-bit integer value to memory. */\n export function store(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically adds a 16-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically subtracts a 32-bit integer value in memory. */\n export function sub(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise AND operation a 32-bit integer value in memory. */\n export function and(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise OR operation a 32-bit integer value in memory. */\n export function or(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically performs a bitwise XOR operation a 32-bit integer value in memory. */\n export function xor(ptr: usize, value: i32, immOffset?: usize): i32;\n /** Atomically exchanges a 32-bit integer value in memory. */\n export function xchg(ptr: 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(ptr: 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(ptr: 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(ptr: 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(ptr: 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(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Loads a 64-bit unsigned integer value from memory. */\n export function load(ptr: usize, immOffset?: usize, immAlign?: usize): i64;\n /** Stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize, immAlign?: usize): void;\n /** Stores a 64-bit integer value to memory. */\n export function store(ptr: 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(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize): i64;\n /** Atomically loads a 64-bit integer value from memory and returns it. */\n export function load(ptr: usize, immOffset?: usize): i64;\n /** Atomically stores a 64-bit integer value to memory as an 8-bit integer. */\n export function store8(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): void;\n /** Atomically stores a 64-bit integer value to memory. */\n export function store(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts an 8-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges an 8-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 16-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 16-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 32-bit unsigned integer value in memory. */\n export function sub_u(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 32-bit unsigned integer value in memory. */\n export function xchg_u(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically subtracts a 64-bit integer value in memory. */\n export function sub(ptr: 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(ptr: 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(ptr: 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(ptr: usize, value: i64, immOffset?: usize): i64;\n /** Atomically exchanges a 64-bit integer value in memory. */\n export function xchg(ptr: 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(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): f32;\n /** Stores a 32-bit float to memory. */\n export function store(ptr: 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(ptr: usize, immOffset?: usize, immAlign?: usize): f64;\n /** Stores a 64-bit float to memory. */\n export function store(ptr: 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 vector with identical lanes. */\n export function splat(x: T): v128;\n /** Extracts one lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): T;\n /** Replaces one lane. */\n export function replace_lane(x: v128, idx: u8, value: T): v128;\n /** Selects lanes from either vector according to the specified lane indexes. */\n export function shuffle(a: v128, b: v128, ...lanes: u8[]): v128;\n /** Selects 8-bit lanes from the first vector according to the indexes [0-15] specified by the 8-bit lanes of the second vector. */\n export function swizzle(a: v128, s: v128): v128;\n /** Loads a vector from memory. */\n export function load(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n /** Creates a vector with identical lanes by loading the splatted value. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128\n /** Creates a vector by loading the lanes of the specified type and extending each to the next larger type. */\n export function load_ext(ptr: usize, immOffset?: usize, immAlign?: usize): v128\n /** Stores a vector to memory. */\n export function store(ptr: usize, value: v128, immOffset?: usize, immAlign?: usize): void;\n /** Adds each lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each lane. */\n export function mul(a: v128, b: v128): v128; // except i64\n /** Divides each lane. */\n export function div(a: v128, b: v128): v128;\n /** Negates each lane of a vector. */\n export function neg(a: v128): v128;\n /** Adds each lane using saturation. */\n export function add_saturate(a: v128, b: v128): v128;\n /** Subtracts each lane using saturation. */\n export function sub_saturate(a: v128, b: v128): v128;\n /** Performs a bitwise left shift on each lane of a vector by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise right shift on each lane of a vector by a scalar. */\n export function shr(a: v128, b: i32): v128;\n /** Performs the bitwise AND operation on two vectors. */\n export function and(a: v128, b: v128): v128;\n /** Performs the bitwise OR operation on two vectors. */\n export function or(a: v128, b: v128): v128;\n /** Performs the bitwise XOR operation on two vectors. */\n export function xor(a: v128, b: v128): v128;\n /** Performs the bitwise ANDNOT operation on two vectors. */\n export function andnot(a: v128, b: v128): v128;\n /** Performs the bitwise NOT operation on a vector. */\n export function not(a: v128): v128;\n /** Selects bits of either vector according to the specified mask. */\n export function bitselect(v1: v128, v2: v128, mask: v128): v128;\n /** Reduces a vector to a scalar indicating whether any lane is considered `true`. */\n export function any_true(a: v128): bool;\n /** Reduces a 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. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each lane. */\n export function max(a: v128, b: v128): v128;\n /** Computes the dot product of two lanes each, yielding lanes one size wider than the input. */\n export function dot(a: v128, b: v128): v128;\n /** Computes the absolute value of each lane. */\n export function abs(a: v128): v128;\n /** Computes the square root of each lane. */\n export function sqrt(a: v128): v128;\n /** Computes which lanes are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which lanes of the first vector are less than those of the second. */\n export function lt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 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 vector are greater than those of the second. */\n export function gt(a: v128, b: v128): v128;\n /** Computes which lanes of the first 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 vector from integer to floating point. */\n export function convert(a: v128): v128;\n /** Truncates each lane of a vector from floating point to integer with saturation. Takes the target type. */\n export function trunc_sat(a: v128): v128;\n /** Narrows each lane to their respective narrower lanes. */\n export function narrow(a: v128, b: v128): v128;\n /** Widens the low lanes of a vector to their respective wider lanes. */\n export function widen_low(a: v128): v128;\n /** Widens the high lanes of a vector to their respective wider lanes. */\n export function widen_high(a: v128): v128;\n /** Computes `(a * b) + c` for each lane. */\n export function qfma(a: v128, b: v128, c: v128): v128;\n /** Computes `(a * b) - c` for each lane. */\n export function qfms(a: v128, b: v128, c: 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 as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i8;\n /** Extracts one 8-bit integer lane as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u8;\n /** Replaces one 8-bit integer lane. */\n export function replace_lane(x: v128, idx: u8, value: i8): v128;\n /** Adds each 8-bit integer lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 8-bit integer lane. */\n export function mul(a: v128, b: v128): v128;\n /** Computes the signed minimum of each 8-bit integer lane. */\n export function min_s(a: v128, b: v128): v128;\n /** Computes the unsigned minimum of each 8-bit integer lane. */\n export function min_u(a: v128, b: v128): v128;\n /** Computes the signed maximum of each 8-bit integer lane. */\n export function max_s(a: v128, b: v128): v128;\n /** Computes the unsigned maximum of each 8-bit integer lane. */\n export function max_u(a: v128, b: v128): v128;\n /** Negates each 8-bit integer lane. */\n export function neg(a: v128): v128;\n /** Adds each 8-bit integer lane using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 8-bit integer lane using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 8-bit integer lane 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 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 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 by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 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 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 are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 8-bit integer lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 8-bit signed integer lanes of the first 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 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 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 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 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 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 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 vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n /** Narrows each 16-bit signed integer lane to 8-bit signed integer lanes. */\n export function narrow_i16x8_s(a: v128, b: v128): v128;\n /** Narrows each 16-bit signed integer lane to 8-bit unsigned integer lanes. */\n export function narrow_i16x8_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 as a signed scalar. */\n export function extract_lane_s(x: v128, idx: u8): i16;\n /** Extracts one 16-bit integer lane as an unsigned scalar. */\n export function extract_lane_u(x: v128, idx: u8): u16;\n /** Replaces one 16-bit integer lane. */\n export function replace_lane(x: v128, idx: u8, value: i16): v128;\n /** Adds each 16-bit integer lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 16-bit integer lane. */\n export function mul(a: v128, b: v128): v128;\n /** Computes the signed minimum of each 16-bit integer lane. */\n export function min_s(a: v128, b: v128): v128;\n /** Computes the unsigned minimum of each 16-bit integer lane. */\n export function min_u(a: v128, b: v128): v128;\n /** Computes the signed maximum of each 16-bit integer lane. */\n export function max_s(a: v128, b: v128): v128;\n /** Computes the unsigned maximum of each 16-bit integer lane. */\n export function max_u(a: v128, b: v128): v128;\n /** Negates each 16-bit integer lane. */\n export function neg(a: v128): v128;\n /** Adds each 16-bit integer lane using signed saturation. */\n export function add_saturate_s(a: v128, b: v128): v128;\n /** Adds each 16-bit integer lane using unsigned saturation. */\n export function add_saturate_u(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane using signed saturation. */\n export function sub_saturate_s(a: v128, b: v128): v128;\n /** Subtracts each 16-bit integer lane 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 by a scalar. */\n export function shl(a: v128, b: i32): v128;\n /** Performs a bitwise arithmetic right shift each 16-bit integer lane 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 by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 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 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 are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 16-bit integer lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 16-bit signed integer lanes of the first 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 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 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 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 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 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 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 vector are greater than or equal those of the second. */\n export function ge_u(a: v128, b: v128): v128;\n /** Narrows each 32-bit signed integer lane to 16-bit signed integer lanes. */\n export function narrow_i32x4_s(a: v128, b: v128): v128;\n /** Narrows each 32-bit signed integer lane to 16-bit unsigned integer lanes. */\n export function narrow_i32x4_u(a: v128, b: v128): v128;\n /** Widens the low 8-bit signed integer lanes to 16-bit signed integer lanes. */\n export function widen_low_i8x16_s(a: v128): v128;\n /** Widens the low 8-bit unsigned integer lanes to 16-bit unsigned integer lanes. */\n export function widen_low_i8x16_u(a: v128): v128;\n /** Widens the high 8-bit signed integer lanes to 16-bit signed integer lanes. */\n export function widen_high_i8x16_s(a: v128): v128;\n /** Widens the high 8-bit unsigned integer lanes to 16-bit unsigned integer lanes. */\n export function widen_high_i8x16_u(a: v128): v128;\n /** Creates a vector with eight 16-bit integer lanes by loading and sign extending eight 8-bit integers. */\n export function load8x8_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n /** Creates a vector with eight 16-bit integer lanes by loading and zero extending eight 8-bit integers. */\n export function load8x8_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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 vector with four identical 32-bit integer lanes. */\n export function splat(x: i32): v128;\n /** Extracts one 32-bit integer lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): i32;\n /** Replaces one 32-bit integer lane. */\n export function replace_lane(x: v128, idx: u8, value: i32): v128;\n /** Adds each 32-bit integer lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit integer lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit integer lane. */\n export function mul(a: v128, b: v128): v128;\n /** Computes the signed minimum of each 32-bit integer lane. */\n export function min_s(a: v128, b: v128): v128;\n /** Computes the unsigned minimum of each 32-bit integer lane. */\n export function min_u(a: v128, b: v128): v128;\n /** Computes the signed maximum of each 32-bit integer lane. */\n export function max_s(a: v128, b: v128): v128;\n /** Computes the unsigned maximum of each 32-bit integer lane. */\n export function max_u(a: v128, b: v128): v128;\n /** Computes the dot product of two 16-bit integer lanes each, yielding 32-bit integer lanes. */\n export function dot_i16x8_s(a: v128, b: v128): v128;\n /** Negates each 32-bit integer lane. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 32-bit integer lane 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 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 by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 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 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 are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit integer lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit signed integer lanes of the first 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 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 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 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 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 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 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 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 to a signed integer with saturation. */\n export function trunc_sat_f32x4_s(a: v128): v128;\n /** Truncates each 32-bit float lane to an unsigned integer with saturation. */\n export function trunc_sat_f32x4_u(a: v128): v128;\n /** Widens the low 16-bit signed integer lanes to 32-bit signed integer lanes. */\n export function widen_low_i16x8_s(a: v128): v128;\n /** Widens the low 16-bit unsigned integer lane to 32-bit unsigned integer lanes. */\n export function widen_low_i16x8_u(a: v128): v128;\n /** Widens the high 16-bit signed integer lanes to 32-bit signed integer lanes. */\n export function widen_high_i16x8_s(a: v128): v128;\n /** Widens the high 16-bit unsigned integer lanes to 32-bit unsigned integer lanes. */\n export function widen_high_i16x8_u(a: v128): v128;\n /** Creates a vector with four 32-bit integer lanes by loading and sign extending four 16-bit integers. */\n export function load16x4_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n /** Creates a vector with four 32-bit integer lanes by loading and zero extending four 16-bit integers. */\n export function load16x4_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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 vector with two identical 64-bit integer lanes. */\n export function splat(x: i64): v128;\n /** Extracts one 64-bit integer lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): i64;\n /** Replaces one 64-bit integer lane. */\n export function replace_lane(x: v128, idx: u8, value: i64): v128;\n /** Adds each 64-bit integer lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit integer lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit integer lane. */\n export function mul(a: v128, b: v128): v128;\n /** Negates each 64-bit integer lane. */\n export function neg(a: v128): v128;\n /** Performs a bitwise left shift on each 64-bit integer lane 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 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 by a scalar. */\n export function shr_u(a: v128, b: i32): v128;\n /** Reduces a 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 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 to a signed integer with saturation. */\n export function trunc_sat_f64x2_s(a: v128): v128;\n /** Truncates each 64-bit float lane to an unsigned integer with saturation. */\n export function trunc_sat_f64x2_u(a: v128): v128;\n /** Creates a vector with two 64-bit integer lanes by loading and sign extending two 32-bit integers. */\n export function load32x2_s(ptr: usize, immOffset?: u32, immAlign?: u32): v128;\n /** Creates a vector with two 64-bit integer lanes by loading and zero extending two 32-bit integers. */\n export function load32x2_u(ptr: usize, immOffset?: u32, immAlign?: u32): 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 vector with four identical 32-bit float lanes. */\n export function splat(x: f32): v128;\n /** Extracts one 32-bit float lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): f32;\n /** Replaces one 32-bit float lane. */\n export function replace_lane(x: v128, idx: u8, value: f32): v128;\n /** Adds each 32-bit float lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 32-bit float lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 32-bit float lane. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 32-bit float lane. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 32-bit float lane. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 32-bit float lane. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 32-bit float lane. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 32-bit float lane. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 32-bit float lane. */\n export function sqrt(a: v128): v128;\n /** Computes which 32-bit float lanes are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 32-bit float lanes of the first 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 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 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 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 vector to floating point. */\n export function convert_i32x4_s(a: v128): v128;\n /** Converts each 32-bit unsigned integer lane of a vector to floating point. */\n export function convert_i32x4_u(a: v128): v128;\n /** Computes `(a * b) + c` for each 32-bit float lane. */\n export function qfma(a: v128, b: v128, c: v128): v128;\n /** Computes `(a * b) - c` for each 32-bit float lane. */\n export function qfms(a: v128, b: v128, c: 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 vector with two identical 64-bit float lanes. */\n export function splat(x: f64): v128;\n /** Extracts one 64-bit float lane as a scalar. */\n export function extract_lane(x: v128, idx: u8): f64;\n /** Replaces one 64-bit float lane. */\n export function replace_lane(x: v128, idx: u8, value: f64): v128;\n /** Adds each 64-bit float lane. */\n export function add(a: v128, b: v128): v128;\n /** Subtracts each 64-bit float lane. */\n export function sub(a: v128, b: v128): v128;\n /** Multiplies each 64-bit float lane. */\n export function mul(a: v128, b: v128): v128;\n /** Divides each 64-bit float lane. */\n export function div(a: v128, b: v128): v128;\n /** Negates each 64-bit float lane. */\n export function neg(a: v128): v128;\n /** Computes the minimum of each 64-bit float lane. */\n export function min(a: v128, b: v128): v128;\n /** Computes the maximum of each 64-bit float lane. */\n export function max(a: v128, b: v128): v128;\n /** Computes the absolute value of each 64-bit float lane. */\n export function abs(a: v128): v128;\n /** Computes the square root of each 64-bit float lane. */\n export function sqrt(a: v128): v128;\n /** Computes which 64-bit float lanes are equal. */\n export function eq(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes are not equal. */\n export function ne(a: v128, b: v128): v128;\n /** Computes which 64-bit float lanes of the first 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 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 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 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 vector to floating point. */\n export function convert_i64x2_s(a: v128): v128;\n /** Converts each 64-bit unsigned integer lane of a vector to floating point. */\n export function convert_i64x2_u(a: v128): v128;\n /** Computes `(a * b) + c` for each 64-bit float lane. */\n export function qfma(a: v128, b: v128, c: v128): v128;\n /** Computes `(a * b) - c` for each 64-bit float lane. */\n export function qfms(a: v128, b: v128, c: v128): v128;\n}\ndeclare namespace v8x16 {\n /** Selects 8-bit lanes from either vector according to the specified [0-15] respectively [16-31] 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 /** Selects 8-bit lanes from the first vector according to the indexes [0-15] specified by the 8-bit lanes of the second vector. */\n export function swizzle(a: v128, s: v128): v128;\n /** Loads an 8-bit integer and splats it sixteen times forming a new vector. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n}\ndeclare namespace v16x8 {\n /** Loads a 16-bit integer and splats it eight times forming a new vector. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n}\ndeclare namespace v32x4 {\n /** Loads a 32-bit integer and splats it four times forming a new vector. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n}\ndeclare namespace v64x2 {\n /** Loads a 64-bit integer and splats it two times forming a new vector. */\n export function load_splat(ptr: usize, immOffset?: usize, immAlign?: usize): v128;\n}\n/** Macro type evaluating to the underlying native WebAssembly type. */\ndeclare type native = T;\n/** Special type evaluating the indexed access index type. */\ndeclare type indexof = keyof T;\n/** Special type evaluating the indexed access value type. */\ndeclare type valueof = T[0];\n/** A special type evaluated to the return type of T if T is a callable function. */\ndeclare type ReturnType any> = T extends (...args: any) => infer R ? R : any;\n/** A special type evaluated to the return type of T if T is a callable function. */\ndeclare type returnof any> = ReturnType;\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 interface. */\ndeclare namespace gc {\n /** Can be set to `false` to disable automatic collection. Defaults to `true`. */\n export var auto: bool;\n /** Performs a full garbage collection cycle. */\n export function collect(): 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\ndeclare namespace Atomics {\n export function load(array: TypedArray, index: i32): T;\n export function store(array: TypedArray, index: i32, value: T): void;\n export function add(array: TypedArray, index: i32, value: T): T;\n export function sub(array: TypedArray, index: i32, value: T): T;\n export function and(array: TypedArray, index: i32, value: T): T;\n export function or(array: TypedArray, index: i32, value: T): T;\n export function xor(array: TypedArray, index: i32, value: T): T;\n export function exchange(array: TypedArray, index: i32, value: T): T;\n export function compareExchange(array: TypedArray, index: i32, expectedValue: T, replacementValue: T): T;\n export function wait(array: TypedArray, value: T, timeout?: i64): AtomicWaitResult;\n export function notify(array: TypedArray, index: i32, count?: i32): i32;\n /** The static Atomics.isLockFree() method is used to determine whether to use locks or atomic operations. It returns true, if the given size is one of the BYTES_PER_ELEMENT */\n export function isLockFree(size: usize): bool;\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 /** 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 /** The includes() method determines whether a typed array includes a certain element, returning true or false as appropriate. */\n includes(searchElement: T, fromIndex?: i32): bool;\n /** The indexOf() method returns the first index at which a given element can be found in the typed array, or -1 if it is not present. */\n indexOf(searchElement: T, fromIndex?: i32): i32;\n /** The lastIndexOf() method returns the last index at which a given element can be found in the typed array, or -1 if it is not present. The typed array is searched backwards, starting at fromIndex. */\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n /** Returns copied section of an TypedArray from begin inclusive to end exclusive */\n slice(begin?: i32, end?: i32): TypedArray;\n /** Returns a new TypedArray of this type on the same ArrayBuffer from begin inclusive to end exclusive. */\n subarray(begin?: i32, end?: i32): TypedArray;\n /** The copyWithin() method copies the sequence of array elements within the array to the position starting at target. The copy is taken from the index positions of the second and third arguments start and end. The end argument is optional and defaults to the length of the array. */\n copyWithin(target: i32, start: 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(callbackfn: (accumulator: U, value: T, index: i32, self: this) => U, initialValue: U): U;\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(callbackfn: (accumulator: U, value: T, index: i32, self: this) => U, initialValue: U): U;\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): TypedArray;\n /** The filter() method creates a new typed array with all elements that pass the test implemented by the provided function. This method has the same algorithm as Array.prototype.filter(). */\n filter(callbackfn: (value: T, index: i32, self: this) => bool): TypedArray;\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 /** The join() method joins all elements of an array into a string. This method has the same algorithm as Array.prototype.join(). */\n join(separator?: string): string;\n /** The toString() method returns a string representing the specified array and its elements. This method has the same algorithm as Array.prototype.toString() */\n toString(): string;\n}\n\n/** An array of twos-complement 8-bit signed integers. */\ndeclare class Int8Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int8Array;\n}\n/** An array of 8-bit unsigned integers. */\ndeclare class Uint8Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8Array;\n}\n/** A clamped array of 8-bit unsigned integers. */\ndeclare class Uint8ClampedArray extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8ClampedArray;\n}\n/** An array of twos-complement 16-bit signed integers. */\ndeclare class Int16Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int16Array;\n}\n/** An array of 16-bit unsigned integers. */\ndeclare class Uint16Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint16Array;\n}\n/** An array of twos-complement 32-bit signed integers. */\ndeclare class Int32Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int32Array;\n}\n/** An array of 32-bit unsigned integers. */\ndeclare class Uint32Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint32Array;\n}\n/** An array of twos-complement 64-bit signed integers. */\ndeclare class Int64Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int64Array;\n}\n/** An array of 64-bit unsigned integers. */\ndeclare class Uint64Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint64Array;\n}\n/** An array of 32-bit floating point numbers. */\ndeclare class Float32Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float32Array;\n}\n/** An array of 64-bit floating point numbers. */\ndeclare class Float64Array extends TypedArray {\n /** Wrap an ArrayBuffer */\n static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float64Array;\n}\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\n [key: number]: T;\n /** Current length of the array. */\n length: i32;\n /** Constructs a new array. */\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 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 readonly length: i32;\n charAt(index: i32): string;\n charCodeAt(index: i32): i32;\n codePointAt(index: i32): i32;\n concat(other: string): string;\n endsWith(other: string): bool;\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 substr(start: i32, length?: i32): string;\n substring(start: i32, end?: 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 repeat(count?: i32): string;\n replace(search: string, replacement: string): string;\n replaceAll(search: string, replacement: string): string;\n slice(beginIndex: i32, endIndex?: i32): string;\n split(separator?: string, limit?: i32): string[];\n toString(): string;\n}\n\ndeclare namespace String {\n /** Encoding helpers for UTF-8. */\n export namespace UTF8 {\n /** Calculates the byte length of the specified string when encoded as UTF-8, optionally null terminated. */\n export function byteLength(str: string, nullTerminated?: bool): i32;\n /** Encodes the specified string to UTF-8 bytes, optionally null terminated. */\n export function encode(str: string, nullTerminated?: bool): ArrayBuffer;\n /** Decodes the specified buffer from UTF-8 bytes to a string, optionally null terminated. */\n export function decode(buf: ArrayBuffer, nullTerminated?: bool): string;\n /** Decodes raw UTF-8 bytes to a string, optionally null terminated. */\n export function decodeUnsafe(buf: usize, len: usize, nullTerminated?: bool): string;\n }\n /** Encoding helpers for UTF-16. */\n export namespace UTF16 {\n /** Calculates the byte length of the specified string when encoded as UTF-16. */\n export function byteLength(str: string): i32;\n /** Encodes the specified string to UTF-16 bytes. */\n export function encode(str: string): ArrayBuffer;\n /** Decodes the specified buffer from UTF-16 bytes to a string. */\n export function decode(buf: ArrayBuffer): string;\n /** Decodes raw UTF-16 bytes to a string. */\n export function decodeUnsafe(buf: usize, len: usize): string;\n }\n}\n\ndeclare class Object {\n /** The Object.is() method determines whether two values are the same value. */\n static is(value1: T, value2: T): bool;\n}\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/** 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 {\n toString(): string;\n}\n\ninterface Number {\n toString(radix?: number): string;\n}\n\ninterface Function {}\ninterface IArguments {}\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 keys(): K[]; // preliminary\n values(): V[]; // preliminary\n toString(): string;\n}\n\ndeclare class Set {\n readonly size: i32;\n has(value: K): bool;\n add(value: K): void;\n delete(value: K): bool;\n clear(): void;\n values(): K[]; // preliminary\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): T;\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 /** Multiplies a floating point `x` by 2 raised to power exp `n`. */\n scalbn(x: T, n: i32): T;\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\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// 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/** Special type evaluating the indexed access index type. */\ndeclare type indexof = keyof T;\n/** Special type evaluating the indexed access value type. */\ndeclare type valueof = T[0];\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/** 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 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 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\ndeclare const Mathf: typeof Math;\ndeclare const JSMath: typeof Math;\n\ndeclare interface StringConstructor {\n /** Equivalent to calling `String.fromCharCode` with multiple arguments. */\n fromCharCodes(arr: u16[]): string;\n /** Equivalent to calling `String.fromCodePoint` with multiple arguments. */\n fromCodePoints(arr: i32[]): string;\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,a=e.readFile||O,o=e.writeFile||w,s=e.listFiles||C,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(a===O)throw Error("'options.readFile' must be specified");if(o===w)throw Error("'options.writeFile' must be specified");if(s===C)throw Error("'options.listFiles' must be specified")}const p=f.baseDir?path.resolve(f.baseDir):".",h=[];if(f.transform){let n=f.transform;for(let e=0,l=n.length;e{n.indexOf("/")>=0||(l.parseCount++,l.parseTime+=measure(()=>{x=assemblyscript.parseFile(exports.libraryFiles[n],exports.libraryPrefix+n+".ts",!1,x)}))});const m=[];if(f.lib){let n=f.lib;"string"==typeof n&&(n=n.split(",")),Array.prototype.push.apply(m,n.map(n=>n.trim()));for(let n=0,e=m.length;n{x=assemblyscript.parseFile(o,exports.libraryPrefix+i,!1,x)})}}}f.path=f.path||[];var v=new Map,y=new Map;function b(n,e){var t=null,r=null;if(n.startsWith(exports.libraryPrefix)){const o=n.substring(exports.libraryPrefix.length),s=o+"/index";if(exports.libraryFiles.hasOwnProperty(o))t=exports.libraryFiles[o],r=exports.libraryPrefix+o+".ts";else if(exports.libraryFiles.hasOwnProperty(s))t=exports.libraryFiles[s],r=exports.libraryPrefix+s+".ts";else{for(const n of m){if(null!=(t=a(o+".ts",n))){r=exports.libraryPrefix+o+".ts";break}if(null!=(t=a(s+".ts",n))){r=exports.libraryPrefix+s+".ts";break}}if(null==t){const o=n.match(/^~lib\/((?:@[^\/]+\/)?[^\/]+)(?:\/(.+))?/);if(o){const n=o[1],s=void 0===o[2],l=s?"index":o[2],u=y.has(e)?y.get(e):".";f.traceResolution&&i.write("Looking for package '"+n+"' file '"+l+"' relative to '"+u+"'"+EOL);const c=[];for(let n=(path.isAbsolute(u)?u:path.join(p,u)).split(SEP),e=n.length,t="/"==SEP?0:1;e>=t;--e)"node_modules"!=n[e-1]&&c.push(n.slice(0,e).join(SEP)+SEP+"node_modules");for(const e of c.concat(...f.path).map(n=>path.relative(p,n))){f.traceResolution&&i.write(" in "+path.join(e,n)+EOL);let o="assembly";if(v.has(n))o=v.get(n);else{let t=path.join(e,n,"package.json"),r=a(t,p);if(null!=r)try{let e=JSON.parse(r);"string"==typeof e.ascMain&&(o=e.ascMain.replace(/[\/\\]index\.ts$/,""),v.set(n,o))}catch(n){}}const u=path.join(e,n,o),c=l;if(null!=(t=a(path.join(u,c+".ts"),p))){r=exports.libraryPrefix+n+"/"+c+".ts",y.set(r.replace(/\.ts$/,""),path.join(e,n)),f.traceResolution&&i.write(" -> "+path.join(u,c+".ts")+EOL);break}if(!s){const o=l+"/index";if(null!==(t=a(path.join(u,o+".ts"),p))){r=exports.libraryPrefix+n+"/"+o+".ts",y.set(r.replace(/\.ts$/,""),path.join(e,n)),f.traceResolution&&i.write(" -> "+path.join(u,o+".ts")+EOL);break}}}}}}}else null==(t=a(r=n+".ts",p))&&(t=a(r=n+"/index.ts",p));return null==t?null:{sourceText:t,sourcePath:r}}function _(){for(var n;null!=(n=x.nextFile());){let e=b(n,assemblyscript.getDependee(x,n));if(!e)return t(Error("Import file '"+n+".ts' not found."));l.parseCount++,l.parseTime+=measure(()=>{assemblyscript.parseFile(e.sourceText,e.sourcePath,!1,x)})}if(checkDiagnostics(x,i))return t(Error("Parse error"))}{let n=String(f.runtime),e="rt/index-"+n,r=exports.libraryFiles[e];if(null==r){if(null==(r=a((e=n)+".ts",p)))return t(Error("Runtime '"+n+"' not found."))}else e="~lib/"+e;l.parseCount++,l.parseTime+=measure(()=>{x=assemblyscript.parseFile(r,e,!0,x)})}for(let e=0,r=n.length;e{x=assemblyscript.parseFile(o,i,!0,x)})}{let n=_();if(n)return n}{let n=g("afterParse",x);if(n)return t(n)}{let n=_();if(n)return n}const T=assemblyscript.finishParsing(x);if(f.listFiles)return i.write(T.sources.map(n=>n.normalizedPath).sort().join(EOL)+EOL),t(null);var A=0,E=0;f.optimize&&(A=exports.defaultOptimizeLevel,E=exports.defaultShrinkLevel),"number"==typeof f.optimizeLevel&&(A=f.optimizeLevel),"number"==typeof f.shrinkLevel&&(E=f.shrinkLevel),A=Math.min(Math.max(A,0),3),E=Math.min(Math.max(E,0),2);const F=assemblyscript.createOptions();if(assemblyscript.setTarget(F,0),assemblyscript.setNoAssert(F,f.noAssert),assemblyscript.setImportMemory(F,f.importMemory),assemblyscript.setSharedMemory(F,f.sharedMemory),assemblyscript.setImportTable(F,f.importTable),assemblyscript.setExplicitStart(F,f.explicitStart),assemblyscript.setMemoryBase(F,f.memoryBase>>>0),assemblyscript.setSourceMap(F,null!=f.sourceMap),assemblyscript.setOptimizeLevelHints(F,A,E),assemblyscript.setNoUnsafe(F,f.noUnsafe),assemblyscript.setGlobalAlias(F,"Math","NativeMath"),assemblyscript.setGlobalAlias(F,"Mathf","NativeMathf"),assemblyscript.setGlobalAlias(F,"abort","~lib/builtins/abort"),assemblyscript.setGlobalAlias(F,"trace","~lib/builtins/trace"),f.use){let n=f.use;for(let e=0,r=n.length;e{S=assemblyscript.compileProgram(T,F)})}catch(n){return t(n)}if(checkDiagnostics(x,i))return S&&S.dispose(),t(Error("Compile error"));{let n=g("afterCompile",S);if(n)return t(n)}if(f.validate&&(l.validateCount++,l.validateTime+=measure(()=>{if(!S.validate())return S.dispose(),t(Error("Validate error"))})),"clamp"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{S.runPasses(["trap-mode-clamp"])});else if("js"===f.trapMode)l.optimizeCount++,l.optimizeTime+=measure(()=>{S.runPasses(["trap-mode-js"])});else if("allow"!==f.trapMode)return S.dispose(),t(Error("Unsupported trap mode"));(A>=3||E>=2)&&(A=4),S.setOptimizeLevel(A),S.setShrinkLevel(E),S.setDebugInfo(f.debug);var I=[];if(f.runPasses&&("string"==typeof f.runPasses&&(f.runPasses=f.runPasses.split(",")),f.runPasses.length&&f.runPasses.forEach(n=>{I.indexOf(n)<0&&I.push(n)})),(A>0||E>0)&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{S.optimize()})),I.length&&(l.optimizeCount++,l.optimizeTime+=measure(()=>{S.runPasses(I.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,a=null!=f.sourceMap?f.sourceMap.length?f.sourceMap:path.basename(f.binaryFile)+".map":null;if(l.emitCount++,l.emitTime+=measure(()=>{r=S.toBinary(a)}),f.binaryFile.length?o(f.binaryFile,r.output,p):(L(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=assemblyscript.getSource(T,e.replace(/\.ts$/,""));if(null==i)return t(Error("Source of file '"+e+"' not found."));n.sourceContents||(n.sourceContents=[]),n.sourceContents[r]=i}),o(path.join(path.dirname(f.binaryFile),path.basename(a)).replace(/^\.\//,""),JSON.stringify(n),p)}else i.write("Skipped source map (stdout already occupied)"+EOL)}if(null!=f.asmjsFile){let t;f.asmjsFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=S.toAsmjs()}),o(f.asmjsFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=S.toAsmjs()}),L(t),n=!0),e=!0}if(null!=f.idlFile){let t;f.idlFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(T)}),o(f.idlFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildIDL(T)}),L(t),n=!0),e=!0}if(null!=f.tsdFile){let t;f.tsdFile.length?(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(T)}),o(f.tsdFile,t,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{t=assemblyscript.buildTSD(T)}),L(t),n=!0),e=!0}if(null!=f.textFile||!e){let e;f.textFile&&f.textFile.length?(l.emitCount++,l.emitTime+=measure(()=>{e=S.toText()}),o(f.textFile,e,p)):n||(l.emitCount++,l.emitTime+=measure(()=>{e=S.toText()}),L(e))}}return S.dispose(),f.measure&&printStats(l,i),f.printrtti&&printRTTI(T,i),t(null);function O(n,e){let t=path.resolve(e,n);try{let n;return l.readCount++,l.readTime+=measure(()=>{n=fs.readFileSync(t,{encoding:"utf8"})}),n}catch(n){return null}}function w(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 C(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 null}}function L(n){L.used||(l.writeCount++,L.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__(14)),exports.measure=measure,exports.formatTime=formatTime,exports.printStats=printStats,exports.printRTTI=printRTTI;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?a[o++]=(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,a[o++]=55296+(r>>10),a[o++]=56320+(1023&r)):a[o++]=(15&r)<<12|(63&n[e++])<<6|63&n[e++],o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,a)),o=0);return i?(o&&i.push(String.fromCharCode.apply(String,a.slice(0,o))),i.join("")):String.fromCharCode.apply(String,a.slice(0,o))},t.write=function(n,e,t){for(var r,i,a=t,o=0;o>6|192,e[t++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=n.charCodeAt(o+1)))?(r=65536+((1023&r)<<10)+(1023&i),++o,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-a}},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=[],a={};Object.keys(e).forEach(n=>{if(!n.startsWith(" ")){var r=e[n];null!=r.alias&&("string"==typeof r.alias?a[r.alias]=n:Array.isArray(r.alias)&&r.alias.forEach(e=>a[e]=n)),null!=r.default&&(t[n]=r.default)}});for(var o=0,s=(n=n.slice()).length;ot[n]=s.value[n])}else r.push(i)}for(;o{var o=n[e];if(null!=o.description){for(var s="";s.length{for(let e=0;e{r.statSync(i.join(e,o)).isDirectory()?n(i.join(e,o),t).forEach(n=>a.push(o+"/"+n)):(t&&"function"!=typeof t?t.test(o):t(o))&&a.push(o)}),a},e.TS=/\.ts$/,e.TS_EXCEPT_DTS=/[^\.][^\d]\.ts$/},function(n,e){if(void 0===__WEBPACK_EXTERNAL_MODULE__12__){var t=new Error("Cannot find module 'assemblyscript'");throw t.code="MODULE_NOT_FOUND",t}n.exports=__WEBPACK_EXTERNAL_MODULE__12__},function(n){n.exports=JSON.parse('{"version":{"description":"Prints just the compiler\'s version and exits.","type":"b","alias":"v"},"help":{"description":"Prints this message and exits.","type":"b","alias":"h"},"optimize":{"description":["Optimizes the module. Also has the usual shorthands:",""," -O Uses defaults. Equivalent to -O3s"," -O0 Equivalent to --optimizeLevel 0"," -O1 Equivalent to --optimizeLevel 1"," -O2 Equivalent to --optimizeLevel 2"," -O3 Equivalent to --optimizeLevel 3"," -Oz Equivalent to -O but with --shrinkLevel 2"," -O3s Equivalent to -O3 with --shrinkLevel 1 etc.",""],"type":"b","alias":"O"},"optimizeLevel":{"description":"How much to focus on optimizing code. [0-3]","type":"i"},"shrinkLevel":{"description":"How much to focus on shrinking code size. [0-2, s=1, z=2]","type":"i"},"validate":{"description":"Validates the module using Binaryen. Exits if invalid.","type":"b","alias":"c","default":false},"baseDir":{"description":"Specifies the base directory of input and output files.","type":"s","default":"."},"outFile":{"description":"Specifies the output file. File extension indicates format.","type":"s","alias":"o"},"binaryFile":{"description":"Specifies the binary output file (.wasm).","type":"s","alias":"b"},"textFile":{"description":"Specifies the text output file (.wat).","type":"s","alias":"t"},"asmjsFile":{"description":"Specifies the asm.js output file (.js).","type":"s","alias":"a"},"idlFile":{"description":"Specifies the WebIDL output file (.webidl).","type":"s","alias":"i"},"tsdFile":{"description":"Specifies the TypeScript definition output file (.d.ts).","type":"s","alias":"d"},"sourceMap":{"description":["Enables source map generation. Optionally takes the URL","used to reference the source map from the binary file."],"type":"s"},"runtime":{"description":["Specifies the runtime variant to include in the program.",""," full Default runtime based on TLSF and reference counting."," half Same as \'full\', but not exported to the host."," stub Minimal stub implementation without free/GC support."," none Same as \'stub\', but not exported to the host.",""],"type":"s","default":"full"},"noUnsafe":{"description":["Disallows the use of unsafe features in user code.","Does not affect library files and external modules."],"type":"b","default":false},"debug":{"description":"Enables debug information in emitted binaries.","type":"b","default":false},"noAssert":{"description":"Replaces assertions with just their value without trapping.","type":"b","default":false},"noEmit":{"description":"Performs compilation as usual but does not emit code.","type":"b","default":false},"importMemory":{"description":"Imports the memory instance provided by the embedder.","type":"b","default":false},"sharedMemory":{"description":"Declare memory as shared by settings the max shared memory.","type":"i","default":0},"memoryBase":{"description":"Sets the start offset of compiler-generated static memory.","type":"i","default":0},"importTable":{"description":"Imports the function table instance provided by the embedder.","type":"b","default":false},"explicitStart":{"description":"Exports an explicit start function to be called manually.","type":"b","default":false},"lib":{"description":["Adds one or multiple paths to custom library components and","uses exports of all top-level files at this path as globals."],"type":"s"},"path":{"description":["Adds one or multiple paths to package resolution, similar","to node_modules. Prefers an \'ascMain\' entry in a package\'s","package.json and falls back to an inner \'assembly/\' folder."],"type":"S"},"use":{"description":["Aliases a global object under another name, e.g., to switch","the default \'Math\' implementation used: --use Math=JSMath"],"type":"S","alias":"u"},"trapMode":{"description":["Sets the trap mode to use.",""," allow Allow trapping operations. This is the default."," clamp Replace trapping operations with clamping semantics."," js Replace trapping operations with JS semantics.",""],"type":"s","default":"allow"},"runPasses":{"description":["Specifies additional Binaryen passes to run after other","optimizations, if any. See: Binaryen/src/passes/pass.cpp"],"type":"s"},"enable":{"description":["Enables WebAssembly features that are disabled by default.",""," sign-extension Sign-extension operations"," bulk-memory Bulk memory operations."," simd SIMD types and operations."," threads Threading and atomic operations."," reference-types Reference types and operations.",""],"TODO_doesNothingYet":[" nontrapping-f2i Non-trapping float to integer ops."," exception-handling Exception handling."," tail-calls Tail call operations."],"type":"s"},"disable":{"description":["Disables WebAssembly features that are enabled by default.",""," mutable-globals Mutable global imports and exports.",""]},"transform":{"description":"Specifies the path to a custom transform to \'require\'.","type":"S"},"traceResolution":{"description":"Enables tracing of package resolution.","type":"b","default":false},"listFiles":{"description":"Lists files to be compiled and exits.","type":"b","default":false},"measure":{"description":"Prints measuring information on I/O and compile times.","type":"b","default":false},"printrtti":{"description":"Prints the module\'s runtime type information to stderr.","type":"b","default":false},"noColors":{"description":"Disables terminal colors.","type":"b","default":false}," ...":{"description":"Specifies node.js options (CLI only). See: node --help"},"-Os":{"value":{"optimize":true,"shrinkLevel":1}},"-Oz":{"value":{"optimize":true,"shrinkLevel":2}},"-O0":{"value":{"optimizeLevel":0,"shrinkLevel":0}},"-O1":{"value":{"optimizeLevel":1,"shrinkLevel":0}},"-O2":{"value":{"optimizeLevel":2,"shrinkLevel":0}},"-O3":{"value":{"optimizeLevel":3,"shrinkLevel":0}},"-O0s":{"value":{"optimizeLevel":0,"shrinkLevel":1}},"-O1s":{"value":{"optimizeLevel":1,"shrinkLevel":1}},"-O2s":{"value":{"optimizeLevel":2,"shrinkLevel":1}},"-O3s":{"value":{"optimizeLevel":3,"shrinkLevel":1}},"-O0z":{"value":{"optimizeLevel":0,"shrinkLevel":2}},"-O1z":{"value":{"optimizeLevel":1,"shrinkLevel":2}},"-O2z":{"value":{"optimizeLevel":2,"shrinkLevel":2}},"-O3z":{"value":{"optimizeLevel":3,"shrinkLevel":2}}}')},function(n,e,t){(function(e,t){n.exports=e.hrtime||function(n){var e=.001*i.call(r),t=Math.floor(e),a=Math.floor(e%1*1e9);n&&(t-=n[0],(a-=n[1])<0&&(t--,a+=1e9));return[t,a]};var r=t.performance||{},i=r.now||r.mozNow||r.msNow||r.oNow||r.webkitNow||function(){return(new Date).getTime()}}).call(this,t(0),t(3))}])})); //# sourceMappingURL=asc.js.map \ No newline at end of file diff --git a/dist/asc.js.map b/dist/asc.js.map index d8e727bffa..8114c337d6 100644 --- a/dist/asc.js.map +++ b/dist/asc.js.map @@ -1 +1 @@ -{"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/. sync","webpack://asc/./asc.js","webpack://asc/./util/utf8.js","webpack://asc/./util/colors.js","webpack://asc/./util/options.js","webpack://asc/./util/mkdirp.js","webpack://asc/./util/find.js","webpack://asc/external \"assemblyscript\"","webpack://asc/../node_modules/browser-process-hrtime/index.js"],"names":["root","factory","exports","module","require","e","define","amd","self","this","__WEBPACK_EXTERNAL_MODULE__12__","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","args","Array","slice","arguments","shift","setTimeout","apply","platform","arch","execPath","title","pid","browser","env","argv","binding","Error","chdir","dir","resolve","exit","kill","umask","dlopen","uptime","memoryUsage","uvCounters","features","normalizeArray","parts","allowAboveRoot","up","length","last","splice","unshift","filter","xs","f","res","push","resolvedPath","resolvedAbsolute","process","TypeError","charAt","split","join","normalize","isAbsolute","trailingSlash","substr","paths","index","relative","from","to","trim","arr","start","end","fromParts","toParts","Math","min","samePartsLength","outputParts","concat","sep","delimiter","dirname","code","charCodeAt","hasRoot","matchedSlash","basename","ext","extname","startDot","startPart","preDotState","str","len","g","Function","window","webpackEmptyContext","req","keys","id","fs","utf8","colorsUtil","optionsUtil","mkdirp","find","EOL","SEP","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","printRTTI","program","buildRTTI","register","project","skipIgnore","e_ts","eval","message","stack","isBundle","version","options","sourceMapRoot","libraryPrefix","LIBRARY_PREFIX","defaultOptimizeLevel","defaultShrinkLevel","libraryFiles","libDir","bundled","files","TS_EXCEPT_DTS","forEach","file","replace","readFileSync","definitionFiles","stdDir","compileString","sources","createMemoryStream","val","isArray","String","main","readFile","writeFile","contents","listFiles","callback","readFileNode","writeFileNode","listFilesNode","opts","parse","noColors","supported","unknown","arg","yellow","trailing","err","red","help","out","color","white","cyan","baseDir","transforms","transform","transformArgs","k","filename","test","transpileOnly","skipProject","classOrModule","assign","log","console","error","applyTransform","parser","libPath","indexOf","parseFile","customLibDirs","lib","map","libFiles","endsWith","j","libText","packageMains","Map","packageBases","getFile","internalPath","dependeePath","sourceText","sourcePath","startsWith","plainName","substring","indexName","match","packageName","isPackageRoot","undefined","filePath","basePath","has","traceResolution","currentPath","mainPath","jsonPath","jsonText","json","JSON","ascMain","set","mainDir","parseBacklog","nextFile","getDependee","runtimeName","runtime","runtimePath","runtimeText","finishParsing","normalizedPath","sort","optimizeLevel","shrinkLevel","optimize","max","compilerOptions","createOptions","setTarget","setNoAssert","noAssert","setImportMemory","importMemory","setSharedMemory","sharedMemory","setImportTable","importTable","setExplicitStart","explicitStart","setMemoryBase","memoryBase","setSourceMap","sourceMap","setOptimizeLevelHints","setNoUnsafe","noUnsafe","setGlobalAlias","use","aliases","part","alias","disable","flag","toUpperCase","disableFeature","enable","enableFeature","compileProgram","dispose","validate","trapMode","runPasses","setOptimizeLevel","setShrinkLevel","setDebugInfo","debug","pass","noEmit","hasStdout","hasOutput","outFile","textFile","asmjsFile","binaryFile","wasm","sourceMapURL","toBinary","writeStdout","sourceRoot","text","getSource","sourceContents","stringify","asm","toAsmjs","idlFile","idl","buildIDL","tsdFile","tsd","buildTSD","wat","toText","printrtti","encoding","writeFileSync","readdirSync","used","allocBuffer","global","Buffer","allocUnsafe","Uint8Array","stream","chunk","buffer","reset","toBuffer","offset","toString","read","tscOptions","alwaysStrict","noImplicitAny","noImplicitReturns","noImplicitThis","noEmitOnError","strictNullChecks","experimentalDecorators","target","noLib","types","allowJs","string","fromCharCode","c1","c2","isCI","proc","base","colors","gray","GRAY","RESET","RED","green","GREEN","YELLOW","blue","BLUE","magenta","MAGENTA","CYAN","WHITE","config","option","default","exec","type","parseInt","parseFloat","indent","padding","eol","sb","description","line","_0777","made","mkdirSync","err0","stat","statSync","err1","isDirectory","findFiles","iname","TS","previousTimestamp","clocktime","performanceNow","performance","seconds","floor","nanoseconds","now","mozNow","msNow","oNow","webkitNow","Date","getTime"],"mappings":"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","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__12__) {\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 = 5);\n","exports.nextTick = function nextTick(fn) {\n var args = Array.prototype.slice.call(arguments);\n args.shift();\n setTimeout(function () {\n fn.apply(null, args);\n }, 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","// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,\n// backported and transplited with Babel, with backwards-compat fixes\n\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// 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 if (typeof path !== 'string') path = path + '';\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) {\n // return '//';\n // Backwards-compat fix:\n return '/';\n }\n return path.slice(0, end);\n};\n\nfunction basename(path) {\n if (typeof path !== 'string') path = path + '';\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n}\n\n// Uses a mixed approach for backwards-compatibility, as ext behavior changed\n// in new Node.js versions, so only basename() above is backported here\nexports.basename = function (path, ext) {\n var f = basename(path);\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\nexports.extname = function (path) {\n if (typeof path !== 'string') path = path + '';\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\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","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 = 4;","\"use strict\";\n/**\n * Compiler frontend for node.js\n *\n * Uses the low-level API exported from src/index.ts so it works with the compiler compiled to\n * JavaScript as well as the compiler compiled to WebAssembly (eventually). Runs the sources\n * directly through ts-node if distribution files are not present (indicated by a `-dev` version).\n *\n * Can also be packaged as a bundle suitable for in-browser use with the standard library injected\n * in the build step. See dist/asc.js for the bundle and webpack.config.js for building details.\n *\n * @module cli/asc\n */\n\n// Use \".\" instead of \"/\" as cwd in browsers\nif (process.browser) process.cwd = function() { return \".\"; };\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\nconst utf8 = require(\"./util/utf8\");\nconst colorsUtil = require(\"./util/colors\");\nconst optionsUtil = require(\"./util/options\");\nconst mkdirp = require(\"./util/mkdirp\");\nconst find = require(\"./util/find\");\nconst EOL = process.platform === \"win32\" ? \"\\r\\n\" : \"\\n\";\nconst SEP = process.platform === \"win32\" ? \"\\\\\" : \"/\";\n\n// global.Binaryen = require(\"../lib/binaryen\");\n\n// Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional\n// useless code fragment on top of an actual error. suppress this:\nif (process.removeAllListeners) process.removeAllListeners(\"uncaughtException\");\n\n// Use distribution files if present, otherwise run the sources directly\nvar assemblyscript, isDev = false;\n(() => {\n try { // `asc` on the command line\n assemblyscript = require(\"../dist/assemblyscript.js\");\n } catch (e) {\n try { // `asc` on the command line without dist files\n require(\"ts-node\").register({\n project: path.join(__dirname, \"..\", \"src\", \"tsconfig.json\"),\n skipIgnore: true\n });\n require(\"../src/glue/js\");\n assemblyscript = require(\"../src\");\n isDev = true;\n } catch (e_ts) {\n try { // `require(\"dist/asc.js\")` in explicit browser tests\n assemblyscript = eval(\"require('./assemblyscript')\");\n } catch (e) {\n // combine both errors that lead us here\n e.message = e_ts.stack + \"\\n---\\n\" + e.stack;\n throw e;\n }\n }\n }\n})();\n\n/** Whether this is a webpack bundle or not. */\nexports.isBundle = typeof BUNDLE_VERSION === \"string\";\n\n/** Whether asc runs the sources directly or not. */\nexports.isDev = isDev;\n\n/** AssemblyScript version. */\nexports.version = exports.isBundle ? BUNDLE_VERSION : require(\"../package.json\").version;\n\n/** Available CLI options. */\nexports.options = require(\"./asc.json\");\n\n/** Common root used in source maps. */\nexports.sourceMapRoot = \"assemblyscript:///\";\n\n/** Prefix used for library files. */\nexports.libraryPrefix = assemblyscript.LIBRARY_PREFIX;\n\n/** Default Binaryen optimization level. */\nexports.defaultOptimizeLevel = 3;\n\n/** Default Binaryen shrink level. */\nexports.defaultShrinkLevel = 1;\n\n/** Bundled library files. */\nexports.libraryFiles = exports.isBundle ? BUNDLE_LIBRARY : (() => { // set up if not a bundle\n const libDir = path.join(__dirname, \"..\", \"std\", \"assembly\");\n const bundled = {};\n find.files(libDir, find.TS_EXCEPT_DTS)\n .forEach(file => bundled[file.replace(/\\.ts$/, \"\")] = fs.readFileSync(path.join(libDir, file), \"utf8\" ));\n return bundled;\n})();\n\n/** Bundled definition files. */\nexports.definitionFiles = exports.isBundle ? BUNDLE_DEFINITIONS : (() => { // set up if not a bundle\n const stdDir = path.join(__dirname, \"..\", \"std\");\n return {\n \"assembly\": fs.readFileSync(path.join(stdDir, \"assembly\", \"index.d.ts\"), \"utf8\"),\n \"portable\": fs.readFileSync(path.join(stdDir, \"portable\", \"index.d.ts\"), \"utf8\")\n };\n})();\n\n/** Convenience function that parses and compiles source strings directly. */\nexports.compileString = (sources, options) => {\n if (typeof sources === \"string\") sources = { \"input.ts\": sources };\n const output = Object.create({\n stdout: createMemoryStream(),\n stderr: createMemoryStream()\n });\n var argv = [\n \"--binaryFile\", \"binary\",\n \"--textFile\", \"text\",\n ];\n Object.keys(options || {}).forEach(key => {\n var val = options[key];\n if (Array.isArray(val)) val.forEach(val => argv.push(\"--\" + key, String(val)));\n else argv.push(\"--\" + key, String(val));\n });\n exports.main(argv.concat(Object.keys(sources)), {\n stdout: output.stdout,\n stderr: output.stderr,\n readFile: name => sources.hasOwnProperty(name) ? sources[name] : null,\n writeFile: (name, contents) => output[name] = contents,\n listFiles: () => []\n });\n return output;\n}\n\n/** Runs the command line utility using the specified arguments array. */\nexports.main = function main(argv, options, callback) {\n if (typeof options === \"function\") {\n callback = options;\n options = {};\n } else if (!options) {\n options = {};\n }\n\n const stdout = options.stdout || process.stdout;\n const stderr = options.stderr || process.stderr;\n const readFile = options.readFile || readFileNode;\n const writeFile = options.writeFile || writeFileNode;\n const listFiles = options.listFiles || listFilesNode;\n const stats = options.stats || createStats();\n\n // Output must be specified if not present in the environment\n if (!stdout) throw Error(\"'options.stdout' must be specified\");\n if (!stderr) throw Error(\"'options.stderr' must be specified\");\n\n const opts = optionsUtil.parse(argv, exports.options);\n const args = opts.options;\n argv = opts.arguments;\n if (args.noColors) {\n colorsUtil.stdout.supported =\n colorsUtil.stderr.supported = false;\n } else {\n colorsUtil.stdout = colorsUtil.from(stdout);\n colorsUtil.stderr = colorsUtil.from(stderr);\n }\n\n // Check for unknown arguments\n if (opts.unknown.length) {\n opts.unknown.forEach(arg => {\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unknown option '\" + arg + \"'\" + EOL);\n });\n }\n\n // Check for trailing arguments\n if (opts.trailing.length) {\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unsupported trailing arguments: \" + opts.trailing.join(\" \") + EOL);\n }\n\n // Use default callback if none is provided\n if (!callback) callback = function defaultCallback(err) {\n var code = 0;\n if (err) {\n stderr.write(colorsUtil.stderr.red(\"ERROR: \") + err.stack.replace(/^ERROR: /i, \"\") + EOL);\n code = 1;\n }\n return code;\n };\n\n // Just print the version if requested\n if (args.version) {\n stdout.write(\"Version \" + exports.version + (isDev ? \"-dev\" : \"\") + EOL);\n return callback(null);\n }\n // Print the help message if requested or no source files are provided\n if (args.help || !argv.length) {\n var out = args.help ? stdout : stderr;\n var color = args.help ? colorsUtil.stdout : colorsUtil.stderr;\n out.write([\n color.white(\"SYNTAX\"),\n \" \" + color.cyan(\"asc\") + \" [entryFile ...] [options]\",\n \"\",\n color.white(\"EXAMPLES\"),\n \" \" + color.cyan(\"asc\") + \" hello.ts\",\n \" \" + color.cyan(\"asc\") + \" hello.ts -b hello.wasm -t hello.wat\",\n \" \" + color.cyan(\"asc\") + \" hello1.ts hello2.ts -b -O > hello.wasm\",\n \"\",\n color.white(\"OPTIONS\"),\n ].concat(\n optionsUtil.help(exports.options, 24, EOL)\n ).join(EOL) + EOL);\n return callback(null);\n }\n\n // I/O must be specified if not present in the environment\n if (!fs.readFileSync) {\n if (readFile === readFileNode) throw Error(\"'options.readFile' must be specified\");\n if (writeFile === writeFileNode) throw Error(\"'options.writeFile' must be specified\");\n if (listFiles === listFilesNode) throw Error(\"'options.listFiles' must be specified\");\n }\n\n // Set up base directory\n const baseDir = args.baseDir ? path.resolve(args.baseDir) : \".\";\n\n // Set up transforms\n const transforms = [];\n if (args.transform) {\n let transformArgs = args.transform;\n for (let i = 0, k = transformArgs.length; i < k; ++i) {\n let filename = transformArgs[i].trim();\n if (/\\.ts$/.test(filename)) require(\"ts-node\").register({ transpileOnly: true, skipProject: true });\n try {\n const classOrModule = require(require.resolve(filename, { paths: [baseDir, process.cwd()] }));\n if (typeof classOrModule === \"function\") {\n Object.assign(classOrModule.prototype, {\n baseDir,\n stdout,\n stderr,\n log: console.error,\n readFile,\n writeFile,\n listFiles\n });\n transforms.push(new classOrModule());\n } else {\n transforms.push(classOrModule); // legacy module\n }\n } catch (e) {\n return callback(e);\n }\n }\n }\n function applyTransform(name, ...args) {\n for (let i = 0, k = transforms.length; i < k; ++i) {\n let transform = transforms[i];\n if (typeof transform[name] === \"function\") {\n try {\n transform[name](...args);\n } catch (e) {\n return e;\n }\n }\n }\n }\n\n // Begin parsing\n var parser = null;\n\n // Include library files\n Object.keys(exports.libraryFiles).forEach(libPath => {\n if (libPath.indexOf(\"/\") >= 0) return; // in sub-directory: imported on demand\n stats.parseCount++;\n stats.parseTime += measure(() => {\n parser = assemblyscript.parseFile(exports.libraryFiles[libPath], exports.libraryPrefix + libPath + \".ts\", false, parser);\n });\n });\n const customLibDirs = [];\n if (args.lib) {\n let lib = args.lib;\n if (typeof lib === \"string\") lib = lib.split(\",\");\n Array.prototype.push.apply(customLibDirs, lib.map(lib => lib.trim()));\n for (let i = 0, k = customLibDirs.length; i < k; ++i) { // custom\n let libDir = customLibDirs[i];\n let libFiles;\n if (libDir.endsWith(\".ts\")) {\n libFiles = [ path.basename(libDir) ];\n libDir = path.dirname(libDir);\n } else {\n libFiles = listFiles(libDir, baseDir) || [];\n }\n for (let j = 0, l = libFiles.length; j < l; ++j) {\n let libPath = libFiles[j];\n let libText = readFile(libPath, libDir);\n if (libText === null) return callback(Error(\"Library file '\" + libPath + \"' not found.\"));\n stats.parseCount++;\n exports.libraryFiles[libPath.replace(/\\.ts$/, \"\")] = libText;\n stats.parseTime += measure(() => {\n parser = assemblyscript.parseFile(libText, exports.libraryPrefix + libPath, false, parser);\n });\n }\n }\n }\n args.path = args.path || [];\n\n // Maps package names to parent directory\n var packageMains = new Map();\n var packageBases = new Map();\n\n // Gets the file matching the specified source path, imported at the given dependee path\n function getFile(internalPath, dependeePath) {\n var sourceText = null; // text reported back to the compiler\n var sourcePath = null; // path reported back to the compiler\n\n // Try file.ts, file/index.ts\n if (!internalPath.startsWith(exports.libraryPrefix)) {\n if ((sourceText = readFile(sourcePath = internalPath + \".ts\", baseDir)) == null) {\n sourceText = readFile(sourcePath = internalPath + \"/index.ts\", baseDir);\n }\n\n // Search library in this order: stdlib, custom lib dirs, paths\n } else {\n const plainName = internalPath.substring(exports.libraryPrefix.length);\n const indexName = plainName + \"/index\";\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\n sourceText = exports.libraryFiles[plainName];\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\n sourceText = exports.libraryFiles[indexName];\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\n } else { // custom lib dirs\n for (const libDir of customLibDirs) {\n if ((sourceText = readFile(plainName + \".ts\", libDir)) != null) {\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\n break;\n } else {\n if ((sourceText = readFile(indexName + \".ts\", libDir)) != null) {\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\n break;\n }\n }\n }\n if (sourceText == null) { // paths\n const match = internalPath.match(/^~lib\\/((?:@[^\\/]+\\/)?[^\\/]+)(?:\\/(.+))?/); // ~lib/(pkg)/(path), ~lib/(@org/pkg)/(path)\n if (match) {\n const packageName = match[1];\n const isPackageRoot = match[2] === undefined;\n const filePath = isPackageRoot ? \"index\" : match[2];\n const basePath = packageBases.has(dependeePath) ? packageBases.get(dependeePath) : \".\";\n if (args.traceResolution) stderr.write(\"Looking for package '\" + packageName + \"' file '\" + filePath + \"' relative to '\" + basePath + \"'\" + EOL);\n const absBasePath = path.isAbsolute(basePath) ? basePath : path.join(baseDir, basePath);\n const paths = [];\n for (let parts = absBasePath.split(SEP), i = parts.length, k = SEP == \"/\" ? 0 : 1; i >= k; --i) {\n if (parts[i - 1] != \"node_modules\") paths.push(parts.slice(0, i).join(SEP) + SEP + \"node_modules\");\n }\n for (const currentPath of paths.concat(...args.path).map(p => path.relative(baseDir, p))) {\n if (args.traceResolution) stderr.write(\" in \" + path.join(currentPath, packageName) + EOL);\n let mainPath = \"assembly\";\n if (packageMains.has(packageName)) { // use cached\n mainPath = packageMains.get(packageName);\n } else { // evaluate package.json\n let jsonPath = path.join(currentPath, packageName, \"package.json\");\n let jsonText = readFile(jsonPath, baseDir);\n if (jsonText != null) {\n try {\n let json = JSON.parse(jsonText);\n if (typeof json.ascMain === \"string\") {\n mainPath = json.ascMain.replace(/[\\/\\\\]index\\.ts$/, \"\");\n packageMains.set(packageName, mainPath);\n }\n } catch (e) { }\n }\n }\n const mainDir = path.join(currentPath, packageName, mainPath);\n const plainName = filePath;\n if ((sourceText = readFile(path.join(mainDir, plainName + \".ts\"), baseDir)) != null) {\n sourcePath = exports.libraryPrefix + packageName + \"/\" + plainName + \".ts\";\n packageBases.set(sourcePath.replace(/\\.ts$/, \"\"), path.join(currentPath, packageName));\n if (args.traceResolution) stderr.write(\" -> \" + path.join(mainDir, plainName + \".ts\") + EOL);\n break;\n } else if (!isPackageRoot) {\n const indexName = filePath + \"/index\";\n if ((sourceText = readFile(path.join(mainDir, indexName + \".ts\"), baseDir)) !== null) {\n sourcePath = exports.libraryPrefix + packageName + \"/\" + indexName + \".ts\";\n packageBases.set(sourcePath.replace(/\\.ts$/, \"\"), path.join(currentPath, packageName));\n if (args.traceResolution) stderr.write(\" -> \" + path.join(mainDir, indexName + \".ts\") + EOL);\n break;\n }\n }\n }\n }\n }\n }\n }\n\n // No such file\n if (sourceText == null) return null;\n\n return { sourceText, sourcePath };\n }\n\n // Parses the backlog of imported files after including entry files\n function parseBacklog() {\n var internalPath;\n while ((internalPath = parser.nextFile()) != null) {\n let file = getFile(internalPath, assemblyscript.getDependee(parser, internalPath));\n if (!file) return callback(Error(\"Import file '\" + internalPath + \".ts' not found.\"))\n stats.parseCount++;\n stats.parseTime += measure(() => {\n assemblyscript.parseFile(file.sourceText, file.sourcePath, false, parser);\n });\n }\n if (checkDiagnostics(parser, stderr)) return callback(Error(\"Parse error\"));\n }\n\n // Include runtime template before entry files so its setup runs first\n {\n let runtimeName = String(args.runtime);\n let runtimePath = \"rt/index-\" + runtimeName;\n let runtimeText = exports.libraryFiles[runtimePath];\n if (runtimeText == null) {\n runtimePath = runtimeName;\n runtimeText = readFile(runtimePath + \".ts\", baseDir);\n if (runtimeText == null) return callback(Error(\"Runtime '\" + runtimeName + \"' not found.\"));\n } else {\n runtimePath = \"~lib/\" + runtimePath;\n }\n stats.parseCount++;\n stats.parseTime += measure(() => {\n parser = assemblyscript.parseFile(runtimeText, runtimePath, true, parser);\n });\n }\n\n // Include entry files\n for (let i = 0, k = argv.length; i < k; ++i) {\n const filename = argv[i];\n\n let sourcePath = String(filename).replace(/\\\\/g, \"/\").replace(/(\\.ts|\\/)$/, \"\");\n // Setting the path to relative path\n sourcePath = path.isAbsolute(sourcePath) ? path.relative(baseDir, sourcePath) : sourcePath;\n\n // Try entryPath.ts, then entryPath/index.ts\n let sourceText = readFile(sourcePath + \".ts\", baseDir);\n if (sourceText == null) {\n sourceText = readFile(sourcePath + \"/index.ts\", baseDir);\n if (sourceText == null) return callback(Error(\"Entry file '\" + sourcePath + \".ts' not found.\"));\n sourcePath += \"/index.ts\";\n } else {\n sourcePath += \".ts\";\n }\n\n stats.parseCount++;\n stats.parseTime += measure(() => {\n parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);\n });\n }\n\n // Parse entry files\n {\n let code = parseBacklog();\n if (code) return code;\n }\n\n // Call afterParse transform hook\n {\n let error = applyTransform(\"afterParse\", parser);\n if (error) return callback(error);\n }\n\n // Parse additional files, if any\n {\n let code = parseBacklog();\n if (code) return code;\n }\n\n // Finish parsing\n const program = assemblyscript.finishParsing(parser);\n\n // Print files and exit if listFiles\n if (args.listFiles) {\n // FIXME: not a proper C-like API\n stderr.write(program.sources.map(s => s.normalizedPath).sort().join(EOL) + EOL);\n return callback(null);\n }\n\n // Set up optimization levels\n var optimizeLevel = 0;\n var shrinkLevel = 0;\n if (args.optimize) {\n optimizeLevel = exports.defaultOptimizeLevel;\n shrinkLevel = exports.defaultShrinkLevel;\n }\n if (typeof args.optimizeLevel === \"number\") {\n optimizeLevel = args.optimizeLevel;\n }\n if (typeof args.shrinkLevel === \"number\") {\n shrinkLevel = args.shrinkLevel;\n }\n optimizeLevel = Math.min(Math.max(optimizeLevel, 0), 3);\n shrinkLevel = Math.min(Math.max(shrinkLevel, 0), 2);\n\n // Begin compilation\n const compilerOptions = assemblyscript.createOptions();\n assemblyscript.setTarget(compilerOptions, 0);\n assemblyscript.setNoAssert(compilerOptions, args.noAssert);\n assemblyscript.setImportMemory(compilerOptions, args.importMemory);\n assemblyscript.setSharedMemory(compilerOptions, args.sharedMemory);\n assemblyscript.setImportTable(compilerOptions, args.importTable);\n assemblyscript.setExplicitStart(compilerOptions, args.explicitStart);\n assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);\n assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);\n assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel);\n assemblyscript.setNoUnsafe(compilerOptions, args.noUnsafe);\n\n // Initialize default aliases\n assemblyscript.setGlobalAlias(compilerOptions, \"Math\", \"NativeMath\");\n assemblyscript.setGlobalAlias(compilerOptions, \"Mathf\", \"NativeMathf\");\n assemblyscript.setGlobalAlias(compilerOptions, \"abort\", \"~lib/builtins/abort\");\n assemblyscript.setGlobalAlias(compilerOptions, \"trace\", \"~lib/builtins/trace\");\n\n // Add or override aliases if specified\n if (args.use) {\n let aliases = args.use;\n for (let i = 0, k = aliases.length; i < k; ++i) {\n let part = aliases[i];\n let p = part.indexOf(\"=\");\n if (p < 0) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\n let alias = part.substring(0, p).trim();\n let name = part.substring(p + 1).trim();\n if (!alias.length) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\n assemblyscript.setGlobalAlias(compilerOptions, alias, name);\n }\n }\n\n // Disable default features if specified\n var features;\n if ((features = args.disable) != null) {\n if (typeof features === \"string\") features = features.split(\",\");\n for (let i = 0, k = features.length; i < k; ++i) {\n let name = features[i].trim();\n let flag = assemblyscript[\"FEATURE_\" + name.replace(/\\-/g, \"_\").toUpperCase()];\n if (!flag) return callback(Error(\"Feature '\" + name + \"' is unknown.\"));\n assemblyscript.disableFeature(compilerOptions, flag);\n }\n }\n\n // Enable experimental features if specified\n if ((features = args.enable) != null) {\n if (typeof features === \"string\") features = features.split(\",\");\n for (let i = 0, k = features.length; i < k; ++i) {\n let name = features[i].trim();\n let flag = assemblyscript[\"FEATURE_\" + name.replace(/\\-/g, \"_\").toUpperCase()];\n if (!flag) return callback(Error(\"Feature '\" + name + \"' is unknown.\"));\n assemblyscript.enableFeature(compilerOptions, flag);\n }\n }\n\n var module;\n stats.compileCount++;\n try {\n stats.compileTime += measure(() => {\n module = assemblyscript.compileProgram(program, compilerOptions);\n });\n } catch (e) {\n return callback(e);\n }\n if (checkDiagnostics(parser, stderr)) {\n if (module) module.dispose();\n return callback(Error(\"Compile error\"));\n }\n\n // Call afterCompile transform hook\n {\n let error = applyTransform(\"afterCompile\", module);\n if (error) return callback(error);\n }\n\n // Validate the module if requested\n if (args.validate) {\n stats.validateCount++;\n stats.validateTime += measure(() => {\n if (!module.validate()) {\n module.dispose();\n return callback(Error(\"Validate error\"));\n }\n });\n }\n\n // Set Binaryen-specific options\n if (args.trapMode === \"clamp\") {\n stats.optimizeCount++;\n stats.optimizeTime += measure(() => {\n module.runPasses([ \"trap-mode-clamp\" ]);\n });\n } else if (args.trapMode === \"js\") {\n stats.optimizeCount++;\n stats.optimizeTime += measure(() => {\n module.runPasses([ \"trap-mode-js\" ]);\n });\n } else if (args.trapMode !== \"allow\") {\n module.dispose();\n return callback(Error(\"Unsupported trap mode\"));\n }\n\n // Implicitly run costly non-LLVM optimizations on -O3 or -Oz\n // see: https://github.com/WebAssembly/binaryen/pull/1596\n if (optimizeLevel >= 3 || shrinkLevel >= 2) optimizeLevel = 4;\n\n module.setOptimizeLevel(optimizeLevel);\n module.setShrinkLevel(shrinkLevel);\n module.setDebugInfo(args.debug);\n\n var runPasses = [];\n if (args.runPasses) {\n if (typeof args.runPasses === \"string\") {\n args.runPasses = args.runPasses.split(\",\");\n }\n if (args.runPasses.length) {\n args.runPasses.forEach(pass => {\n if (runPasses.indexOf(pass) < 0)\n runPasses.push(pass);\n });\n }\n }\n\n // Optimize the module if requested\n if (optimizeLevel > 0 || shrinkLevel > 0) {\n stats.optimizeCount++;\n stats.optimizeTime += measure(() => {\n module.optimize();\n });\n }\n\n // Run additional passes if requested\n if (runPasses.length) {\n stats.optimizeCount++;\n stats.optimizeTime += measure(() => {\n module.runPasses(runPasses.map(pass => pass.trim()));\n });\n }\n\n // Prepare output\n if (!args.noEmit) {\n let hasStdout = false;\n let hasOutput = false;\n\n if (args.outFile != null) {\n if (/\\.was?t$/.test(args.outFile) && args.textFile == null) {\n args.textFile = args.outFile;\n } else if (/\\.js$/.test(args.outFile) && args.asmjsFile == null) {\n args.asmjsFile = args.outFile;\n } else if (args.binaryFile == null) {\n args.binaryFile = args.outFile;\n }\n }\n\n // Write binary\n if (args.binaryFile != null) {\n let sourceMapURL = args.sourceMap != null\n ? args.sourceMap.length\n ? args.sourceMap\n : path.basename(args.binaryFile) + \".map\"\n : null;\n\n let wasm;\n stats.emitCount++;\n stats.emitTime += measure(() => {\n wasm = module.toBinary(sourceMapURL)\n });\n\n if (args.binaryFile.length) {\n writeFile(args.binaryFile, wasm.output, baseDir);\n } else {\n writeStdout(wasm.output);\n hasStdout = true;\n }\n hasOutput = true;\n\n // Post-process source map\n if (wasm.sourceMap != null) {\n if (args.binaryFile.length) {\n let sourceMap = JSON.parse(wasm.sourceMap);\n sourceMap.sourceRoot = exports.sourceMapRoot;\n sourceMap.sources.forEach((name, index) => {\n let text = assemblyscript.getSource(program, name.replace(/\\.ts$/, \"\"));\n if (text == null) return callback(Error(\"Source of file '\" + name + \"' not found.\"));\n if (!sourceMap.sourceContents) sourceMap.sourceContents = [];\n sourceMap.sourceContents[index] = text;\n });\n writeFile(path.join(\n path.dirname(args.binaryFile),\n path.basename(sourceMapURL)\n ).replace(/^\\.\\//, \"\"), JSON.stringify(sourceMap), baseDir);\n } else {\n stderr.write(\"Skipped source map (stdout already occupied)\" + EOL);\n }\n }\n }\n\n // Write asm.js\n if (args.asmjsFile != null) {\n let asm;\n if (args.asmjsFile.length) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n asm = module.toAsmjs();\n });\n writeFile(args.asmjsFile, asm, baseDir);\n } else if (!hasStdout) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n asm = module.toAsmjs();\n });\n writeStdout(asm);\n hasStdout = true;\n }\n hasOutput = true;\n }\n\n // Write WebIDL\n if (args.idlFile != null) {\n let idl;\n if (args.idlFile.length) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n idl = assemblyscript.buildIDL(program);\n });\n writeFile(args.idlFile, idl, baseDir);\n } else if (!hasStdout) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n idl = assemblyscript.buildIDL(program);\n });\n writeStdout(idl);\n hasStdout = true;\n }\n hasOutput = true;\n }\n\n // Write TypeScript definition\n if (args.tsdFile != null) {\n let tsd;\n if (args.tsdFile.length) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n tsd = assemblyscript.buildTSD(program);\n });\n writeFile(args.tsdFile, tsd, baseDir);\n } else if (!hasStdout) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n tsd = assemblyscript.buildTSD(program);\n });\n writeStdout(tsd);\n hasStdout = true;\n }\n hasOutput = true;\n }\n\n // Write text (must be last)\n if (args.textFile != null || !hasOutput) {\n let wat;\n if (args.textFile && args.textFile.length) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n wat = module.toText();\n });\n writeFile(args.textFile, wat, baseDir);\n } else if (!hasStdout) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n wat = module.toText()\n });\n writeStdout(wat);\n }\n }\n }\n\n module.dispose();\n if (args.measure) {\n printStats(stats, stderr);\n }\n if (args.printrtti) {\n printRTTI(program, stderr);\n }\n return callback(null);\n\n function readFileNode(filename, baseDir) {\n let name = path.resolve(baseDir, filename);\n try {\n let text;\n stats.readCount++;\n stats.readTime += measure(() => {\n text = fs.readFileSync(name, { encoding: \"utf8\" });\n });\n return text;\n } catch (e) {\n return null;\n }\n }\n\n function writeFileNode(filename, contents, baseDir) {\n try {\n stats.writeCount++;\n stats.writeTime += measure(() => {\n mkdirp(path.join(baseDir, path.dirname(filename)));\n if (typeof contents === \"string\") {\n fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: \"utf8\" } );\n } else {\n fs.writeFileSync(path.join(baseDir, filename), contents);\n }\n });\n return true;\n } catch (e) {\n return false;\n }\n }\n\n function listFilesNode(dirname, baseDir) {\n var files;\n try {\n stats.readTime += measure(() => {\n files = fs.readdirSync(path.join(baseDir, dirname)).filter(file => /^(?!.*\\.d\\.ts$).*\\.ts$/.test(file));\n });\n return files;\n } catch (e) {\n return null;\n }\n }\n\n function writeStdout(contents) {\n if (!writeStdout.used) {\n stats.writeCount++;\n writeStdout.used = true;\n }\n stats.writeTime += measure(() => {\n if (typeof contents === \"string\") {\n stdout.write(contents, { encoding: \"utf8\" });\n } else {\n stdout.write(contents);\n }\n });\n }\n}\n\n/** Checks diagnostics emitted so far for errors. */\nfunction checkDiagnostics(emitter, stderr) {\n var diagnostic;\n var hasErrors = false;\n while ((diagnostic = assemblyscript.nextDiagnostic(emitter)) != null) {\n if (stderr) {\n stderr.write(\n assemblyscript.formatDiagnostic(diagnostic, stderr.isTTY, true) +\n EOL + EOL\n );\n }\n if (assemblyscript.isError(diagnostic)) hasErrors = true;\n }\n return hasErrors;\n}\n\nexports.checkDiagnostics = checkDiagnostics;\n\n/** Creates an empty set of stats. */\nfunction createStats() {\n return {\n readTime: 0,\n readCount: 0,\n writeTime: 0,\n writeCount: 0,\n parseTime: 0,\n parseCount: 0,\n compileTime: 0,\n compileCount: 0,\n emitTime: 0,\n emitCount: 0,\n validateTime: 0,\n validateCount: 0,\n optimizeTime: 0,\n optimizeCount: 0\n };\n}\n\nexports.createStats = createStats;\n\nif (!process.hrtime) process.hrtime = require(\"browser-process-hrtime\");\n\n/** Measures the execution time of the specified function. */\nfunction measure(fn) {\n const start = process.hrtime();\n fn();\n const times = process.hrtime(start);\n return times[0] * 1e9 + times[1];\n}\n\nexports.measure = measure;\n\n/** Formats a high resolution time to a human readable string. */\nfunction formatTime(time) {\n return time ? (time / 1e6).toFixed(3) + \" ms\" : \"N/A\";\n}\n\nexports.formatTime = formatTime;\n\n/** Formats and prints out the contents of a set of stats. */\nfunction printStats(stats, output) {\n function format(time, count) {\n return formatTime(time);\n }\n (output || process.stdout).write([\n \"I/O Read : \" + format(stats.readTime, stats.readCount),\n \"I/O Write : \" + format(stats.writeTime, stats.writeCount),\n \"Parse : \" + format(stats.parseTime, stats.parseCount),\n \"Compile : \" + format(stats.compileTime, stats.compileCount),\n \"Emit : \" + format(stats.emitTime, stats.emitCount),\n \"Validate : \" + format(stats.validateTime, stats.validateCount),\n \"Optimize : \" + format(stats.optimizeTime, stats.optimizeCount)\n ].join(EOL) + EOL);\n}\n\nexports.printStats = printStats;\n\n/** Prints runtime type information. */\nfunction printRTTI(program, output) {\n if (!output) output = process.stderr;\n output.write(\"# Runtime type information (RTTI)\\n\");\n output.write(assemblyscript.buildRTTI(program));\n}\n\nexports.printRTTI = printRTTI;\n\nvar allocBuffer = typeof global !== \"undefined\" && global.Buffer\n ? global.Buffer.allocUnsafe || function(len) { return new global.Buffer(len); }\n : function(len) { return new Uint8Array(len) };\n\n/** Creates a memory stream that can be used in place of stdout/stderr. */\nfunction createMemoryStream(fn) {\n var stream = [];\n stream.write = function(chunk) {\n if (fn) fn(chunk);\n if (typeof chunk === \"string\") {\n let buffer = allocBuffer(utf8.length(chunk));\n utf8.write(chunk, buffer, 0);\n chunk = buffer;\n }\n this.push(chunk);\n };\n stream.reset = function() {\n stream.length = 0;\n };\n stream.toBuffer = function() {\n var offset = 0, i = 0, k = this.length;\n while (i < k) offset += this[i++].length;\n var buffer = allocBuffer(offset);\n offset = i = 0;\n while (i < k) {\n buffer.set(this[i], offset);\n offset += this[i].length;\n ++i;\n }\n return buffer;\n };\n stream.toString = function() {\n var buffer = this.toBuffer();\n return utf8.read(buffer, 0, buffer.length);\n };\n return stream;\n}\n\nexports.createMemoryStream = createMemoryStream;\n\n/** Compatible TypeScript compiler options for syntax highlighting etc. */\nexports.tscOptions = {\n alwaysStrict: true,\n noImplicitAny: true,\n noImplicitReturns: true,\n noImplicitThis: true,\n noEmitOnError: true,\n strictNullChecks: true,\n experimentalDecorators: true,\n target: \"esnext\",\n module: \"commonjs\",\n noLib: true,\n types: [],\n allowJs: false\n};\n","// @protobufjs/utf8\n\n/**\n * A minimal UTF8 implementation for number arrays.\n * @memberof util\n * @namespace\n */\nvar utf8 = exports;\n\n/**\n * Calculates the UTF8 byte length of a string.\n * @param {string} string String\n * @returns {number} Byte length\n */\nutf8.length = function utf8_length(string) {\n var len = 0,\n c = 0;\n for (var i = 0; i < string.length; ++i) {\n c = string.charCodeAt(i);\n if (c < 128)\n len += 1;\n else if (c < 2048)\n len += 2;\n else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {\n ++i;\n len += 4;\n } else\n len += 3;\n }\n return len;\n};\n\n/**\n * Reads UTF8 bytes as a string.\n * @param {Uint8Array} buffer Source buffer\n * @param {number} start Source start\n * @param {number} end Source end\n * @returns {string} String read\n */\nutf8.read = function utf8_read(buffer, start, end) {\n var len = end - start;\n if (len < 1)\n return \"\";\n var parts = null,\n chunk = [],\n i = 0, // char offset\n t; // temporary\n while (start < end) {\n t = buffer[start++];\n if (t < 128)\n chunk[i++] = t;\n else if (t > 191 && t < 224)\n chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;\n else if (t > 239 && t < 365) {\n t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;\n chunk[i++] = 0xD800 + (t >> 10);\n chunk[i++] = 0xDC00 + (t & 1023);\n } else\n chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;\n if (i > 8191) {\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\n i = 0;\n }\n }\n if (parts) {\n if (i)\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\n return parts.join(\"\");\n }\n return String.fromCharCode.apply(String, chunk.slice(0, i));\n};\n\n/**\n * Writes a string as UTF8 bytes.\n * @param {string} string Source string\n * @param {Uint8Array} buffer Destination buffer\n * @param {number} offset Destination offset\n * @returns {number} Bytes written\n */\nutf8.write = function utf8_write(string, buffer, offset) {\n var start = offset,\n c1, // character 1\n c2; // character 2\n for (var i = 0; i < string.length; ++i) {\n c1 = string.charCodeAt(i);\n if (c1 < 128) {\n buffer[offset++] = c1;\n } else if (c1 < 2048) {\n buffer[offset++] = c1 >> 6 | 192;\n buffer[offset++] = c1 & 63 | 128;\n } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\n ++i;\n buffer[offset++] = c1 >> 18 | 240;\n buffer[offset++] = c1 >> 12 & 63 | 128;\n buffer[offset++] = c1 >> 6 & 63 | 128;\n buffer[offset++] = c1 & 63 | 128;\n } else {\n buffer[offset++] = c1 >> 12 | 224;\n buffer[offset++] = c1 >> 6 & 63 | 128;\n buffer[offset++] = c1 & 63 | 128;\n }\n }\n return offset - start;\n};\n","var proc = typeof process !== \"undefined\" && process || {};\nvar isCI = proc.env && \"CI\" in proc.env; // doesn't work when bundled because 'process' is a mock\n\nfunction from(stream, base) {\n var colors = base || {};\n colors.supported = (stream && !!stream.isTTY) || isCI;\n colors.gray = text => colors.supported ? exports.GRAY + text + exports.RESET : text;\n colors.red = text => colors.supported ? exports.RED + text + exports.RESET : text;\n colors.green = text => colors.supported ? exports.GREEN + text + exports.RESET : text;\n colors.yellow = text => colors.supported ? exports.YELLOW + text + exports.RESET : text;\n colors.blue = text => colors.supported ? exports.BLUE + text + exports.RESET : text;\n colors.magenta = text => colors.supported ? exports.MAGENTA + text + exports.RESET : text;\n colors.cyan = text => colors.supported ? exports.CYAN + text + exports.RESET : text;\n colors.white = text => colors.supported ? exports.WHITE + text + exports.RESET : text;\n return colors;\n}\n\nexports.stdout = from(proc.stdout, exports);\nexports.stderr = from(proc.stderr);\nexports.from = from;\n\nexports.GRAY = \"\\u001b[90m\";\nexports.RED = \"\\u001b[91m\";\nexports.GREEN = \"\\u001b[92m\";\nexports.YELLOW = \"\\u001b[93m\";\nexports.BLUE = \"\\u001b[94m\";\nexports.MAGENTA = \"\\u001b[95m\";\nexports.CYAN = \"\\u001b[96m\";\nexports.WHITE = \"\\u001b[97m\";\nexports.RESET = \"\\u001b[0m\";\n","// type | meaning\n// -----|---------------\n// b | boolean\n// i | integer\n// f | float\n// s | string\n// I | integer array\n// F | float array\n// S | string array\n\n/** Parses the specified command line arguments according to the given configuration. */\nfunction parse(argv, config) {\n var options = {};\n var unknown = [];\n var arguments = [];\n var trailing = [];\n\n // make an alias map and initialize defaults\n var aliases = {};\n Object.keys(config).forEach(key => {\n if (key.startsWith(\" \")) return;\n var option = config[key];\n if (option.alias != null) {\n if (typeof option.alias === \"string\") aliases[option.alias] = key;\n else if (Array.isArray(option.alias)) option.alias.forEach(alias => aliases[alias] = key);\n }\n if (option.default != null) options[key] = option.default;\n });\n\n // iterate over argv\n for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {\n let arg = argv[i];\n if (arg == \"--\") { ++i; break; }\n let match = /^(?:(\\-\\w)(?:=(.*))?|(\\-\\-\\w{2,})(?:=(.*))?)$/.exec(arg), option, key;\n if (match) {\n if (config[arg]) option = config[key = arg]; // exact\n else if (match[1] != null) { // alias\n option = config[key = aliases[match[1].substring(1)]];\n if (option && match[2] != null) argv[i--] = match[2];\n } else if (match[3] != null) { // full\n option = config[key = match[3].substring(2)];\n if (option && match[4] != null) argv[i--] = match[4];\n }\n } else {\n if (arg.charCodeAt(0) == 45) option = config[key = arg]; // exact\n else { arguments.push(arg); continue; } // argument\n }\n if (option) {\n if (option.type == null || option.type === \"b\") options[key] = true; // flag\n else {\n if (i + 1 < argv.length && argv[i + 1].charCodeAt(0) != 45) { // present\n switch (option.type) {\n case \"i\": options[key] = parseInt(argv[++i], 10); break;\n case \"I\": options[key] = (options[key] || []).concat(parseInt(argv[++i], 10)); break;\n case \"f\": options[key] = parseFloat(argv[++i]); break;\n case \"F\": options[key] = (options[key] || []).concat(parseFloat(argv[++i])); break;\n case \"s\": options[key] = String(argv[++i]); break;\n case \"S\": options[key] = (options[key] || []).concat(argv[++i].split(\",\")); break;\n default: unknown.push(arg); --i;\n }\n } else { // omitted\n switch (option.type) {\n case \"i\":\n case \"f\": options[key] = option.default || 0; break;\n case \"s\": options[key] = option.default || \"\"; break;\n case \"I\":\n case \"F\":\n case \"S\": options[key] = options.default || []; break;\n default: unknown.push(arg);\n }\n }\n }\n if (option.value) Object.keys(option.value).forEach(k => options[k] = option.value[k]);\n } else unknown.push(arg);\n }\n while (i < k) trailing.push(argv[i++]); // trailing\n\n return { options, unknown, arguments, trailing };\n}\n\nexports.parse = parse;\n\n/** Generates the help text for the specified configuration. */\nfunction help(config, options) {\n if (!options) options = {};\n var indent = options.indent || 2;\n var padding = options.padding || 24;\n var eol = options.eol || \"\\n\";\n var sb = [];\n Object.keys(config).forEach(key => {\n var option = config[key];\n if (option.description == null) return;\n var text = \"\";\n while (text.length < indent) text += \" \";\n text += \"--\" + key;\n if (option.alias) text += \", -\" + option.alias;\n while (text.length < padding) text += \" \";\n if (Array.isArray(option.description)) {\n sb.push(text + option.description[0] + option.description.slice(1).map(line => {\n for (let i = 0; i < padding; ++i) line = \" \" + line;\n return eol + line;\n }).join(\"\"));\n } else sb.push(text + option.description);\n });\n return sb.join(eol);\n}\n\nexports.help = help;\n","/*\nCopyright 2010 James Halliday (mail@substack.net)\n\nThis project is free software released under the MIT/X11 license:\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n\nvar path = require(\"path\");\nvar fs = require(\"fs\");\nvar _0777 = parseInt(\"0777\", 8);\n\nmodule.exports = function mkdirp(p, opts, made) {\n if (!opts || typeof opts !== \"object\") {\n opts = { mode: opts };\n }\n var mode = opts.mode;\n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n p = path.resolve(p);\n try {\n fs.mkdirSync(p, mode);\n made = made || p;\n } catch (err0) {\n switch (err0.code) {\n case \"ENOENT\":\n made = mkdirp(path.dirname(p), opts, made);\n mkdirp(p, opts, made);\n break;\n default:\n var stat;\n try {\n stat = fs.statSync(p);\n } catch (err1) {\n throw err0;\n }\n if (!stat.isDirectory()) throw err0;\n break;\n }\n }\n return made;\n};\n","const fs = require(\"fs\");\nconst path = require(\"path\");\n\nfunction findFiles(dirname, filter) {\n var out = [];\n fs.readdirSync(dirname).forEach(name => {\n if (fs.statSync(path.join(dirname, name)).isDirectory()) {\n findFiles(path.join(dirname, name), filter).forEach(iname => out.push(name + \"/\" + iname));\n } else if (!filter || typeof filter === \"function\" ? filter(name) : filter.test(name)) {\n out.push(name);\n }\n });\n return out;\n}\n\nexports.files = findFiles;\n\nexports.TS = /\\.ts$/;\nexports.TS_EXCEPT_DTS = /[^\\.][^\\d]\\.ts$/;\n","if(typeof __WEBPACK_EXTERNAL_MODULE__12__ === 'undefined') {var e = new Error(\"Cannot find module 'assemblyscript'\"); e.code = 'MODULE_NOT_FOUND'; throw e;}\nmodule.exports = __WEBPACK_EXTERNAL_MODULE__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/. sync","webpack://asc/./asc.js","webpack://asc/./util/utf8.js","webpack://asc/./util/colors.js","webpack://asc/./util/options.js","webpack://asc/./util/mkdirp.js","webpack://asc/./util/find.js","webpack://asc/external \"assemblyscript\"","webpack://asc/../node_modules/browser-process-hrtime/index.js"],"names":["root","factory","exports","module","require","e","define","amd","self","this","__WEBPACK_EXTERNAL_MODULE__12__","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","args","Array","slice","arguments","shift","setTimeout","apply","platform","arch","execPath","title","pid","browser","env","argv","binding","Error","chdir","dir","resolve","exit","kill","umask","dlopen","uptime","memoryUsage","uvCounters","features","normalizeArray","parts","allowAboveRoot","up","length","last","splice","unshift","filter","xs","f","res","push","resolvedPath","resolvedAbsolute","process","TypeError","charAt","split","join","normalize","isAbsolute","trailingSlash","substr","paths","index","relative","from","to","trim","arr","start","end","fromParts","toParts","Math","min","samePartsLength","outputParts","concat","sep","delimiter","dirname","code","charCodeAt","hasRoot","matchedSlash","basename","ext","extname","startDot","startPart","preDotState","str","len","g","Function","window","webpackEmptyContext","req","keys","id","fs","utf8","colorsUtil","optionsUtil","mkdirp","find","EOL","SEP","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","printRTTI","program","buildRTTI","register","project","skipIgnore","e_ts","eval","message","stack","isBundle","version","options","sourceMapRoot","libraryPrefix","LIBRARY_PREFIX","defaultOptimizeLevel","defaultShrinkLevel","libraryFiles","libDir","bundled","files","TS_EXCEPT_DTS","forEach","file","replace","readFileSync","definitionFiles","stdDir","compileString","sources","createMemoryStream","val","isArray","String","main","readFile","writeFile","contents","listFiles","callback","readFileNode","writeFileNode","listFilesNode","opts","parse","noColors","supported","unknown","arg","yellow","trailing","err","red","help","out","color","white","cyan","baseDir","transforms","transform","transformArgs","k","filename","test","transpileOnly","skipProject","classOrModule","assign","log","console","error","applyTransform","parser","libPath","indexOf","parseFile","customLibDirs","lib","map","libFiles","endsWith","j","libText","packageMains","Map","packageBases","getFile","internalPath","dependeePath","sourceText","sourcePath","startsWith","plainName","substring","indexName","match","packageName","isPackageRoot","undefined","filePath","basePath","has","traceResolution","currentPath","mainPath","jsonPath","jsonText","json","JSON","ascMain","set","mainDir","parseBacklog","nextFile","getDependee","runtimeName","runtime","runtimePath","runtimeText","finishParsing","normalizedPath","sort","optimizeLevel","shrinkLevel","optimize","max","compilerOptions","createOptions","setTarget","setNoAssert","noAssert","setImportMemory","importMemory","setSharedMemory","sharedMemory","setImportTable","importTable","setExplicitStart","explicitStart","setMemoryBase","memoryBase","setSourceMap","sourceMap","setOptimizeLevelHints","setNoUnsafe","noUnsafe","setGlobalAlias","use","aliases","part","alias","disable","flag","toUpperCase","disableFeature","enable","enableFeature","compileProgram","dispose","validate","trapMode","runPasses","setOptimizeLevel","setShrinkLevel","setDebugInfo","debug","pass","noEmit","hasStdout","hasOutput","outFile","textFile","asmjsFile","binaryFile","wasm","sourceMapURL","toBinary","writeStdout","sourceRoot","text","getSource","sourceContents","stringify","asm","toAsmjs","idlFile","idl","buildIDL","tsdFile","tsd","buildTSD","wat","toText","printrtti","encoding","writeFileSync","readdirSync","used","allocBuffer","global","Buffer","allocUnsafe","Uint8Array","stream","chunk","buffer","reset","toBuffer","offset","toString","read","tscOptions","alwaysStrict","noImplicitAny","noImplicitReturns","noImplicitThis","noEmitOnError","strictNullChecks","experimentalDecorators","target","noLib","types","allowJs","string","fromCharCode","c1","c2","isCI","proc","base","colors","gray","GRAY","RESET","RED","green","GREEN","YELLOW","blue","BLUE","magenta","MAGENTA","CYAN","WHITE","config","option","default","exec","type","parseInt","parseFloat","indent","padding","eol","sb","description","line","_0777","made","mkdirSync","err0","stat","statSync","err1","isDirectory","findFiles","iname","TS","previousTimestamp","clocktime","performanceNow","performance","seconds","floor","nanoseconds","now","mozNow","msNow","oNow","webkitNow","Date","getTime"],"mappings":"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","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__12__) {\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 = 5);\n","exports.nextTick = function nextTick(fn) {\n var args = Array.prototype.slice.call(arguments);\n args.shift();\n setTimeout(function () {\n fn.apply(null, args);\n }, 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","// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,\n// backported and transplited with Babel, with backwards-compat fixes\n\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// 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 if (typeof path !== 'string') path = path + '';\n if (path.length === 0) return '.';\n var code = path.charCodeAt(0);\n var hasRoot = code === 47 /*/*/;\n var end = -1;\n var matchedSlash = true;\n for (var i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n\n if (end === -1) return hasRoot ? '/' : '.';\n if (hasRoot && end === 1) {\n // return '//';\n // Backwards-compat fix:\n return '/';\n }\n return path.slice(0, end);\n};\n\nfunction basename(path) {\n if (typeof path !== 'string') path = path + '';\n\n var start = 0;\n var end = -1;\n var matchedSlash = true;\n var i;\n\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n\n if (end === -1) return '';\n return path.slice(start, end);\n}\n\n// Uses a mixed approach for backwards-compatibility, as ext behavior changed\n// in new Node.js versions, so only basename() above is backported here\nexports.basename = function (path, ext) {\n var f = basename(path);\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\nexports.extname = function (path) {\n if (typeof path !== 'string') path = path + '';\n var startDot = -1;\n var startPart = 0;\n var end = -1;\n var matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n var preDotState = 0;\n for (var i = path.length - 1; i >= 0; --i) {\n var code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1)\n startDot = i;\n else if (preDotState !== 1)\n preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return '';\n }\n return path.slice(startDot, end);\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","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 = 4;","\"use strict\";\n/**\n * Compiler frontend for node.js\n *\n * Uses the low-level API exported from src/index.ts so it works with the compiler compiled to\n * JavaScript as well as the compiler compiled to WebAssembly (eventually). Runs the sources\n * directly through ts-node if distribution files are not present (indicated by a `-dev` version).\n *\n * Can also be packaged as a bundle suitable for in-browser use with the standard library injected\n * in the build step. See dist/asc.js for the bundle and webpack.config.js for building details.\n *\n * @module cli/asc\n */\n\n// Use \".\" instead of \"/\" as cwd in browsers\nif (process.browser) process.cwd = function() { return \".\"; };\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\nconst utf8 = require(\"./util/utf8\");\nconst colorsUtil = require(\"./util/colors\");\nconst optionsUtil = require(\"./util/options\");\nconst mkdirp = require(\"./util/mkdirp\");\nconst find = require(\"./util/find\");\nconst EOL = process.platform === \"win32\" ? \"\\r\\n\" : \"\\n\";\nconst SEP = process.platform === \"win32\" ? \"\\\\\" : \"/\";\n\n// global.Binaryen = require(\"../lib/binaryen\");\n\n// Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional\n// useless code fragment on top of an actual error. suppress this:\nif (process.removeAllListeners) process.removeAllListeners(\"uncaughtException\");\n\n// Use distribution files if present, otherwise run the sources directly\nvar assemblyscript, isDev = false;\n(() => {\n try { // `asc` on the command line\n assemblyscript = require(\"../dist/assemblyscript.js\");\n } catch (e) {\n try { // `asc` on the command line without dist files\n require(\"ts-node\").register({\n project: path.join(__dirname, \"..\", \"src\", \"tsconfig.json\"),\n skipIgnore: true\n });\n require(\"../src/glue/js\");\n assemblyscript = require(\"../src\");\n isDev = true;\n } catch (e_ts) {\n try { // `require(\"dist/asc.js\")` in explicit browser tests\n assemblyscript = eval(\"require('./assemblyscript')\");\n } catch (e) {\n // combine both errors that lead us here\n e.message = e_ts.stack + \"\\n---\\n\" + e.stack;\n throw e;\n }\n }\n }\n})();\n\n/** Whether this is a webpack bundle or not. */\nexports.isBundle = typeof BUNDLE_VERSION === \"string\";\n\n/** Whether asc runs the sources directly or not. */\nexports.isDev = isDev;\n\n/** AssemblyScript version. */\nexports.version = exports.isBundle ? BUNDLE_VERSION : require(\"../package.json\").version;\n\n/** Available CLI options. */\nexports.options = require(\"./asc.json\");\n\n/** Common root used in source maps. */\nexports.sourceMapRoot = \"assemblyscript:///\";\n\n/** Prefix used for library files. */\nexports.libraryPrefix = assemblyscript.LIBRARY_PREFIX;\n\n/** Default Binaryen optimization level. */\nexports.defaultOptimizeLevel = 3;\n\n/** Default Binaryen shrink level. */\nexports.defaultShrinkLevel = 1;\n\n/** Bundled library files. */\nexports.libraryFiles = exports.isBundle ? BUNDLE_LIBRARY : (() => { // set up if not a bundle\n const libDir = path.join(__dirname, \"..\", \"std\", \"assembly\");\n const bundled = {};\n find.files(libDir, find.TS_EXCEPT_DTS)\n .forEach(file => bundled[file.replace(/\\.ts$/, \"\")] = fs.readFileSync(path.join(libDir, file), \"utf8\" ));\n return bundled;\n})();\n\n/** Bundled definition files. */\nexports.definitionFiles = exports.isBundle ? BUNDLE_DEFINITIONS : (() => { // set up if not a bundle\n const stdDir = path.join(__dirname, \"..\", \"std\");\n return {\n \"assembly\": fs.readFileSync(path.join(stdDir, \"assembly\", \"index.d.ts\"), \"utf8\"),\n \"portable\": fs.readFileSync(path.join(stdDir, \"portable\", \"index.d.ts\"), \"utf8\")\n };\n})();\n\n/** Convenience function that parses and compiles source strings directly. */\nexports.compileString = (sources, options) => {\n if (typeof sources === \"string\") sources = { \"input.ts\": sources };\n const output = Object.create({\n stdout: createMemoryStream(),\n stderr: createMemoryStream()\n });\n var argv = [\n \"--binaryFile\", \"binary\",\n \"--textFile\", \"text\",\n ];\n Object.keys(options || {}).forEach(key => {\n var val = options[key];\n if (Array.isArray(val)) val.forEach(val => argv.push(\"--\" + key, String(val)));\n else argv.push(\"--\" + key, String(val));\n });\n exports.main(argv.concat(Object.keys(sources)), {\n stdout: output.stdout,\n stderr: output.stderr,\n readFile: name => sources.hasOwnProperty(name) ? sources[name] : null,\n writeFile: (name, contents) => output[name] = contents,\n listFiles: () => []\n });\n return output;\n}\n\n/** Runs the command line utility using the specified arguments array. */\nexports.main = function main(argv, options, callback) {\n if (typeof options === \"function\") {\n callback = options;\n options = {};\n } else if (!options) {\n options = {};\n }\n\n const stdout = options.stdout || process.stdout;\n const stderr = options.stderr || process.stderr;\n const readFile = options.readFile || readFileNode;\n const writeFile = options.writeFile || writeFileNode;\n const listFiles = options.listFiles || listFilesNode;\n const stats = options.stats || createStats();\n\n // Output must be specified if not present in the environment\n if (!stdout) throw Error(\"'options.stdout' must be specified\");\n if (!stderr) throw Error(\"'options.stderr' must be specified\");\n\n const opts = optionsUtil.parse(argv, exports.options);\n const args = opts.options;\n argv = opts.arguments;\n if (args.noColors) {\n colorsUtil.stdout.supported =\n colorsUtil.stderr.supported = false;\n } else {\n colorsUtil.stdout = colorsUtil.from(stdout);\n colorsUtil.stderr = colorsUtil.from(stderr);\n }\n\n // Check for unknown arguments\n if (opts.unknown.length) {\n opts.unknown.forEach(arg => {\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unknown option '\" + arg + \"'\" + EOL);\n });\n }\n\n // Check for trailing arguments\n if (opts.trailing.length) {\n stderr.write(colorsUtil.stderr.yellow(\"WARN: \") + \"Unsupported trailing arguments: \" + opts.trailing.join(\" \") + EOL);\n }\n\n // Use default callback if none is provided\n if (!callback) callback = function defaultCallback(err) {\n var code = 0;\n if (err) {\n stderr.write(colorsUtil.stderr.red(\"ERROR: \") + err.stack.replace(/^ERROR: /i, \"\") + EOL);\n code = 1;\n }\n return code;\n };\n\n // Just print the version if requested\n if (args.version) {\n stdout.write(\"Version \" + exports.version + (isDev ? \"-dev\" : \"\") + EOL);\n return callback(null);\n }\n // Print the help message if requested or no source files are provided\n if (args.help || !argv.length) {\n var out = args.help ? stdout : stderr;\n var color = args.help ? colorsUtil.stdout : colorsUtil.stderr;\n out.write([\n color.white(\"SYNTAX\"),\n \" \" + color.cyan(\"asc\") + \" [entryFile ...] [options]\",\n \"\",\n color.white(\"EXAMPLES\"),\n \" \" + color.cyan(\"asc\") + \" hello.ts\",\n \" \" + color.cyan(\"asc\") + \" hello.ts -b hello.wasm -t hello.wat\",\n \" \" + color.cyan(\"asc\") + \" hello1.ts hello2.ts -b -O > hello.wasm\",\n \"\",\n color.white(\"OPTIONS\"),\n ].concat(\n optionsUtil.help(exports.options, 24, EOL)\n ).join(EOL) + EOL);\n return callback(null);\n }\n\n // I/O must be specified if not present in the environment\n if (!fs.readFileSync) {\n if (readFile === readFileNode) throw Error(\"'options.readFile' must be specified\");\n if (writeFile === writeFileNode) throw Error(\"'options.writeFile' must be specified\");\n if (listFiles === listFilesNode) throw Error(\"'options.listFiles' must be specified\");\n }\n\n // Set up base directory\n const baseDir = args.baseDir ? path.resolve(args.baseDir) : \".\";\n\n // Set up transforms\n const transforms = [];\n if (args.transform) {\n let transformArgs = args.transform;\n for (let i = 0, k = transformArgs.length; i < k; ++i) {\n let filename = transformArgs[i].trim();\n if (/\\.ts$/.test(filename)) require(\"ts-node\").register({ transpileOnly: true, skipProject: true });\n try {\n const classOrModule = require(require.resolve(filename, { paths: [baseDir, process.cwd()] }));\n if (typeof classOrModule === \"function\") {\n Object.assign(classOrModule.prototype, {\n baseDir,\n stdout,\n stderr,\n log: console.error,\n readFile,\n writeFile,\n listFiles\n });\n transforms.push(new classOrModule());\n } else {\n transforms.push(classOrModule); // legacy module\n }\n } catch (e) {\n return callback(e);\n }\n }\n }\n function applyTransform(name, ...args) {\n for (let i = 0, k = transforms.length; i < k; ++i) {\n let transform = transforms[i];\n if (typeof transform[name] === \"function\") {\n try {\n transform[name](...args);\n } catch (e) {\n return e;\n }\n }\n }\n }\n\n // Begin parsing\n var parser = null;\n\n // Include library files\n Object.keys(exports.libraryFiles).forEach(libPath => {\n if (libPath.indexOf(\"/\") >= 0) return; // in sub-directory: imported on demand\n stats.parseCount++;\n stats.parseTime += measure(() => {\n parser = assemblyscript.parseFile(exports.libraryFiles[libPath], exports.libraryPrefix + libPath + \".ts\", false, parser);\n });\n });\n const customLibDirs = [];\n if (args.lib) {\n let lib = args.lib;\n if (typeof lib === \"string\") lib = lib.split(\",\");\n Array.prototype.push.apply(customLibDirs, lib.map(lib => lib.trim()));\n for (let i = 0, k = customLibDirs.length; i < k; ++i) { // custom\n let libDir = customLibDirs[i];\n let libFiles;\n if (libDir.endsWith(\".ts\")) {\n libFiles = [ path.basename(libDir) ];\n libDir = path.dirname(libDir);\n } else {\n libFiles = listFiles(libDir, baseDir) || [];\n }\n for (let j = 0, l = libFiles.length; j < l; ++j) {\n let libPath = libFiles[j];\n let libText = readFile(libPath, libDir);\n if (libText === null) return callback(Error(\"Library file '\" + libPath + \"' not found.\"));\n stats.parseCount++;\n exports.libraryFiles[libPath.replace(/\\.ts$/, \"\")] = libText;\n stats.parseTime += measure(() => {\n parser = assemblyscript.parseFile(libText, exports.libraryPrefix + libPath, false, parser);\n });\n }\n }\n }\n args.path = args.path || [];\n\n // Maps package names to parent directory\n var packageMains = new Map();\n var packageBases = new Map();\n\n // Gets the file matching the specified source path, imported at the given dependee path\n function getFile(internalPath, dependeePath) {\n var sourceText = null; // text reported back to the compiler\n var sourcePath = null; // path reported back to the compiler\n\n // Try file.ts, file/index.ts\n if (!internalPath.startsWith(exports.libraryPrefix)) {\n if ((sourceText = readFile(sourcePath = internalPath + \".ts\", baseDir)) == null) {\n sourceText = readFile(sourcePath = internalPath + \"/index.ts\", baseDir);\n }\n\n // Search library in this order: stdlib, custom lib dirs, paths\n } else {\n const plainName = internalPath.substring(exports.libraryPrefix.length);\n const indexName = plainName + \"/index\";\n if (exports.libraryFiles.hasOwnProperty(plainName)) {\n sourceText = exports.libraryFiles[plainName];\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\n } else if (exports.libraryFiles.hasOwnProperty(indexName)) {\n sourceText = exports.libraryFiles[indexName];\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\n } else { // custom lib dirs\n for (const libDir of customLibDirs) {\n if ((sourceText = readFile(plainName + \".ts\", libDir)) != null) {\n sourcePath = exports.libraryPrefix + plainName + \".ts\";\n break;\n } else {\n if ((sourceText = readFile(indexName + \".ts\", libDir)) != null) {\n sourcePath = exports.libraryPrefix + indexName + \".ts\";\n break;\n }\n }\n }\n if (sourceText == null) { // paths\n const match = internalPath.match(/^~lib\\/((?:@[^\\/]+\\/)?[^\\/]+)(?:\\/(.+))?/); // ~lib/(pkg)/(path), ~lib/(@org/pkg)/(path)\n if (match) {\n const packageName = match[1];\n const isPackageRoot = match[2] === undefined;\n const filePath = isPackageRoot ? \"index\" : match[2];\n const basePath = packageBases.has(dependeePath) ? packageBases.get(dependeePath) : \".\";\n if (args.traceResolution) stderr.write(\"Looking for package '\" + packageName + \"' file '\" + filePath + \"' relative to '\" + basePath + \"'\" + EOL);\n const absBasePath = path.isAbsolute(basePath) ? basePath : path.join(baseDir, basePath);\n const paths = [];\n for (let parts = absBasePath.split(SEP), i = parts.length, k = SEP == \"/\" ? 0 : 1; i >= k; --i) {\n if (parts[i - 1] != \"node_modules\") paths.push(parts.slice(0, i).join(SEP) + SEP + \"node_modules\");\n }\n for (const currentPath of paths.concat(...args.path).map(p => path.relative(baseDir, p))) {\n if (args.traceResolution) stderr.write(\" in \" + path.join(currentPath, packageName) + EOL);\n let mainPath = \"assembly\";\n if (packageMains.has(packageName)) { // use cached\n mainPath = packageMains.get(packageName);\n } else { // evaluate package.json\n let jsonPath = path.join(currentPath, packageName, \"package.json\");\n let jsonText = readFile(jsonPath, baseDir);\n if (jsonText != null) {\n try {\n let json = JSON.parse(jsonText);\n if (typeof json.ascMain === \"string\") {\n mainPath = json.ascMain.replace(/[\\/\\\\]index\\.ts$/, \"\");\n packageMains.set(packageName, mainPath);\n }\n } catch (e) { }\n }\n }\n const mainDir = path.join(currentPath, packageName, mainPath);\n const plainName = filePath;\n if ((sourceText = readFile(path.join(mainDir, plainName + \".ts\"), baseDir)) != null) {\n sourcePath = exports.libraryPrefix + packageName + \"/\" + plainName + \".ts\";\n packageBases.set(sourcePath.replace(/\\.ts$/, \"\"), path.join(currentPath, packageName));\n if (args.traceResolution) stderr.write(\" -> \" + path.join(mainDir, plainName + \".ts\") + EOL);\n break;\n } else if (!isPackageRoot) {\n const indexName = filePath + \"/index\";\n if ((sourceText = readFile(path.join(mainDir, indexName + \".ts\"), baseDir)) !== null) {\n sourcePath = exports.libraryPrefix + packageName + \"/\" + indexName + \".ts\";\n packageBases.set(sourcePath.replace(/\\.ts$/, \"\"), path.join(currentPath, packageName));\n if (args.traceResolution) stderr.write(\" -> \" + path.join(mainDir, indexName + \".ts\") + EOL);\n break;\n }\n }\n }\n }\n }\n }\n }\n\n // No such file\n if (sourceText == null) return null;\n\n return { sourceText, sourcePath };\n }\n\n // Parses the backlog of imported files after including entry files\n function parseBacklog() {\n var internalPath;\n while ((internalPath = parser.nextFile()) != null) {\n let file = getFile(internalPath, assemblyscript.getDependee(parser, internalPath));\n if (!file) return callback(Error(\"Import file '\" + internalPath + \".ts' not found.\"))\n stats.parseCount++;\n stats.parseTime += measure(() => {\n assemblyscript.parseFile(file.sourceText, file.sourcePath, false, parser);\n });\n }\n if (checkDiagnostics(parser, stderr)) return callback(Error(\"Parse error\"));\n }\n\n // Include runtime template before entry files so its setup runs first\n {\n let runtimeName = String(args.runtime);\n let runtimePath = \"rt/index-\" + runtimeName;\n let runtimeText = exports.libraryFiles[runtimePath];\n if (runtimeText == null) {\n runtimePath = runtimeName;\n runtimeText = readFile(runtimePath + \".ts\", baseDir);\n if (runtimeText == null) return callback(Error(\"Runtime '\" + runtimeName + \"' not found.\"));\n } else {\n runtimePath = \"~lib/\" + runtimePath;\n }\n stats.parseCount++;\n stats.parseTime += measure(() => {\n parser = assemblyscript.parseFile(runtimeText, runtimePath, true, parser);\n });\n }\n\n // Include entry files\n for (let i = 0, k = argv.length; i < k; ++i) {\n const filename = argv[i];\n\n let sourcePath = String(filename).replace(/\\\\/g, \"/\").replace(/(\\.ts|\\/)$/, \"\");\n // Setting the path to relative path\n sourcePath = path.isAbsolute(sourcePath) ? path.relative(baseDir, sourcePath) : sourcePath;\n\n // Try entryPath.ts, then entryPath/index.ts\n let sourceText = readFile(sourcePath + \".ts\", baseDir);\n if (sourceText == null) {\n sourceText = readFile(sourcePath + \"/index.ts\", baseDir);\n if (sourceText == null) return callback(Error(\"Entry file '\" + sourcePath + \".ts' not found.\"));\n sourcePath += \"/index.ts\";\n } else {\n sourcePath += \".ts\";\n }\n\n stats.parseCount++;\n stats.parseTime += measure(() => {\n parser = assemblyscript.parseFile(sourceText, sourcePath, true, parser);\n });\n }\n\n // Parse entry files\n {\n let code = parseBacklog();\n if (code) return code;\n }\n\n // Call afterParse transform hook\n {\n let error = applyTransform(\"afterParse\", parser);\n if (error) return callback(error);\n }\n\n // Parse additional files, if any\n {\n let code = parseBacklog();\n if (code) return code;\n }\n\n // Finish parsing\n const program = assemblyscript.finishParsing(parser);\n\n // Print files and exit if listFiles\n if (args.listFiles) {\n // FIXME: not a proper C-like API\n stderr.write(program.sources.map(s => s.normalizedPath).sort().join(EOL) + EOL);\n return callback(null);\n }\n\n // Set up optimization levels\n var optimizeLevel = 0;\n var shrinkLevel = 0;\n if (args.optimize) {\n optimizeLevel = exports.defaultOptimizeLevel;\n shrinkLevel = exports.defaultShrinkLevel;\n }\n if (typeof args.optimizeLevel === \"number\") {\n optimizeLevel = args.optimizeLevel;\n }\n if (typeof args.shrinkLevel === \"number\") {\n shrinkLevel = args.shrinkLevel;\n }\n optimizeLevel = Math.min(Math.max(optimizeLevel, 0), 3);\n shrinkLevel = Math.min(Math.max(shrinkLevel, 0), 2);\n\n // Begin compilation\n const compilerOptions = assemblyscript.createOptions();\n assemblyscript.setTarget(compilerOptions, 0);\n assemblyscript.setNoAssert(compilerOptions, args.noAssert);\n assemblyscript.setImportMemory(compilerOptions, args.importMemory);\n assemblyscript.setSharedMemory(compilerOptions, args.sharedMemory);\n assemblyscript.setImportTable(compilerOptions, args.importTable);\n assemblyscript.setExplicitStart(compilerOptions, args.explicitStart);\n assemblyscript.setMemoryBase(compilerOptions, args.memoryBase >>> 0);\n assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);\n assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel);\n assemblyscript.setNoUnsafe(compilerOptions, args.noUnsafe);\n\n // Initialize default aliases\n assemblyscript.setGlobalAlias(compilerOptions, \"Math\", \"NativeMath\");\n assemblyscript.setGlobalAlias(compilerOptions, \"Mathf\", \"NativeMathf\");\n assemblyscript.setGlobalAlias(compilerOptions, \"abort\", \"~lib/builtins/abort\");\n assemblyscript.setGlobalAlias(compilerOptions, \"trace\", \"~lib/builtins/trace\");\n\n // Add or override aliases if specified\n if (args.use) {\n let aliases = args.use;\n for (let i = 0, k = aliases.length; i < k; ++i) {\n let part = aliases[i];\n let p = part.indexOf(\"=\");\n if (p < 0) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\n let alias = part.substring(0, p).trim();\n let name = part.substring(p + 1).trim();\n if (!alias.length) return callback(Error(\"Global alias '\" + part + \"' is invalid.\"));\n assemblyscript.setGlobalAlias(compilerOptions, alias, name);\n }\n }\n\n // Disable default features if specified\n var features;\n if ((features = args.disable) != null) {\n if (typeof features === \"string\") features = features.split(\",\");\n for (let i = 0, k = features.length; i < k; ++i) {\n let name = features[i].trim();\n let flag = assemblyscript[\"FEATURE_\" + name.replace(/\\-/g, \"_\").toUpperCase()];\n if (!flag) return callback(Error(\"Feature '\" + name + \"' is unknown.\"));\n assemblyscript.disableFeature(compilerOptions, flag);\n }\n }\n\n // Enable experimental features if specified\n if ((features = args.enable) != null) {\n if (typeof features === \"string\") features = features.split(\",\");\n for (let i = 0, k = features.length; i < k; ++i) {\n let name = features[i].trim();\n let flag = assemblyscript[\"FEATURE_\" + name.replace(/\\-/g, \"_\").toUpperCase()];\n if (!flag) return callback(Error(\"Feature '\" + name + \"' is unknown.\"));\n assemblyscript.enableFeature(compilerOptions, flag);\n }\n }\n\n var module;\n stats.compileCount++;\n try {\n stats.compileTime += measure(() => {\n module = assemblyscript.compileProgram(program, compilerOptions);\n });\n } catch (e) {\n return callback(e);\n }\n if (checkDiagnostics(parser, stderr)) {\n if (module) module.dispose();\n return callback(Error(\"Compile error\"));\n }\n\n // Call afterCompile transform hook\n {\n let error = applyTransform(\"afterCompile\", module);\n if (error) return callback(error);\n }\n\n // Validate the module if requested\n if (args.validate) {\n stats.validateCount++;\n stats.validateTime += measure(() => {\n if (!module.validate()) {\n module.dispose();\n return callback(Error(\"Validate error\"));\n }\n });\n }\n\n // Set Binaryen-specific options\n if (args.trapMode === \"clamp\") {\n stats.optimizeCount++;\n stats.optimizeTime += measure(() => {\n module.runPasses([ \"trap-mode-clamp\" ]);\n });\n } else if (args.trapMode === \"js\") {\n stats.optimizeCount++;\n stats.optimizeTime += measure(() => {\n module.runPasses([ \"trap-mode-js\" ]);\n });\n } else if (args.trapMode !== \"allow\") {\n module.dispose();\n return callback(Error(\"Unsupported trap mode\"));\n }\n\n // Implicitly run costly non-LLVM optimizations on -O3 or -Oz\n // see: https://github.com/WebAssembly/binaryen/pull/1596\n if (optimizeLevel >= 3 || shrinkLevel >= 2) optimizeLevel = 4;\n\n module.setOptimizeLevel(optimizeLevel);\n module.setShrinkLevel(shrinkLevel);\n module.setDebugInfo(args.debug);\n\n var runPasses = [];\n if (args.runPasses) {\n if (typeof args.runPasses === \"string\") {\n args.runPasses = args.runPasses.split(\",\");\n }\n if (args.runPasses.length) {\n args.runPasses.forEach(pass => {\n if (runPasses.indexOf(pass) < 0)\n runPasses.push(pass);\n });\n }\n }\n\n // Optimize the module if requested\n if (optimizeLevel > 0 || shrinkLevel > 0) {\n stats.optimizeCount++;\n stats.optimizeTime += measure(() => {\n module.optimize();\n });\n }\n\n // Run additional passes if requested\n if (runPasses.length) {\n stats.optimizeCount++;\n stats.optimizeTime += measure(() => {\n module.runPasses(runPasses.map(pass => pass.trim()));\n });\n }\n\n // Prepare output\n if (!args.noEmit) {\n let hasStdout = false;\n let hasOutput = false;\n\n if (args.outFile != null) {\n if (/\\.was?t$/.test(args.outFile) && args.textFile == null) {\n args.textFile = args.outFile;\n } else if (/\\.js$/.test(args.outFile) && args.asmjsFile == null) {\n args.asmjsFile = args.outFile;\n } else if (args.binaryFile == null) {\n args.binaryFile = args.outFile;\n }\n }\n\n // Write binary\n if (args.binaryFile != null) {\n let sourceMapURL = args.sourceMap != null\n ? args.sourceMap.length\n ? args.sourceMap\n : path.basename(args.binaryFile) + \".map\"\n : null;\n\n let wasm;\n stats.emitCount++;\n stats.emitTime += measure(() => {\n wasm = module.toBinary(sourceMapURL)\n });\n\n if (args.binaryFile.length) {\n writeFile(args.binaryFile, wasm.output, baseDir);\n } else {\n writeStdout(wasm.output);\n hasStdout = true;\n }\n hasOutput = true;\n\n // Post-process source map\n if (wasm.sourceMap != null) {\n if (args.binaryFile.length) {\n let sourceMap = JSON.parse(wasm.sourceMap);\n sourceMap.sourceRoot = exports.sourceMapRoot;\n sourceMap.sources.forEach((name, index) => {\n let text = assemblyscript.getSource(program, name.replace(/\\.ts$/, \"\"));\n if (text == null) return callback(Error(\"Source of file '\" + name + \"' not found.\"));\n if (!sourceMap.sourceContents) sourceMap.sourceContents = [];\n sourceMap.sourceContents[index] = text;\n });\n writeFile(path.join(\n path.dirname(args.binaryFile),\n path.basename(sourceMapURL)\n ).replace(/^\\.\\//, \"\"), JSON.stringify(sourceMap), baseDir);\n } else {\n stderr.write(\"Skipped source map (stdout already occupied)\" + EOL);\n }\n }\n }\n\n // Write asm.js\n if (args.asmjsFile != null) {\n let asm;\n if (args.asmjsFile.length) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n asm = module.toAsmjs();\n });\n writeFile(args.asmjsFile, asm, baseDir);\n } else if (!hasStdout) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n asm = module.toAsmjs();\n });\n writeStdout(asm);\n hasStdout = true;\n }\n hasOutput = true;\n }\n\n // Write WebIDL\n if (args.idlFile != null) {\n let idl;\n if (args.idlFile.length) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n idl = assemblyscript.buildIDL(program);\n });\n writeFile(args.idlFile, idl, baseDir);\n } else if (!hasStdout) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n idl = assemblyscript.buildIDL(program);\n });\n writeStdout(idl);\n hasStdout = true;\n }\n hasOutput = true;\n }\n\n // Write TypeScript definition\n if (args.tsdFile != null) {\n let tsd;\n if (args.tsdFile.length) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n tsd = assemblyscript.buildTSD(program);\n });\n writeFile(args.tsdFile, tsd, baseDir);\n } else if (!hasStdout) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n tsd = assemblyscript.buildTSD(program);\n });\n writeStdout(tsd);\n hasStdout = true;\n }\n hasOutput = true;\n }\n\n // Write text (must be last)\n if (args.textFile != null || !hasOutput) {\n let wat;\n if (args.textFile && args.textFile.length) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n wat = module.toText();\n });\n writeFile(args.textFile, wat, baseDir);\n } else if (!hasStdout) {\n stats.emitCount++;\n stats.emitTime += measure(() => {\n wat = module.toText()\n });\n writeStdout(wat);\n }\n }\n }\n\n module.dispose();\n if (args.measure) {\n printStats(stats, stderr);\n }\n if (args.printrtti) {\n printRTTI(program, stderr);\n }\n return callback(null);\n\n function readFileNode(filename, baseDir) {\n let name = path.resolve(baseDir, filename);\n try {\n let text;\n stats.readCount++;\n stats.readTime += measure(() => {\n text = fs.readFileSync(name, { encoding: \"utf8\" });\n });\n return text;\n } catch (e) {\n return null;\n }\n }\n\n function writeFileNode(filename, contents, baseDir) {\n try {\n stats.writeCount++;\n stats.writeTime += measure(() => {\n mkdirp(path.join(baseDir, path.dirname(filename)));\n if (typeof contents === \"string\") {\n fs.writeFileSync(path.join(baseDir, filename), contents, { encoding: \"utf8\" } );\n } else {\n fs.writeFileSync(path.join(baseDir, filename), contents);\n }\n });\n return true;\n } catch (e) {\n return false;\n }\n }\n\n function listFilesNode(dirname, baseDir) {\n var files;\n try {\n stats.readTime += measure(() => {\n files = fs.readdirSync(path.join(baseDir, dirname)).filter(file => /^(?!.*\\.d\\.ts$).*\\.ts$/.test(file));\n });\n return files;\n } catch (e) {\n return null;\n }\n }\n\n function writeStdout(contents) {\n if (!writeStdout.used) {\n stats.writeCount++;\n writeStdout.used = true;\n }\n stats.writeTime += measure(() => {\n if (typeof contents === \"string\") {\n stdout.write(contents, { encoding: \"utf8\" });\n } else {\n stdout.write(contents);\n }\n });\n }\n}\n\n/** Checks diagnostics emitted so far for errors. */\nfunction checkDiagnostics(emitter, stderr) {\n var diagnostic;\n var hasErrors = false;\n while ((diagnostic = assemblyscript.nextDiagnostic(emitter)) != null) {\n if (stderr) {\n stderr.write(\n assemblyscript.formatDiagnostic(diagnostic, stderr.isTTY, true) +\n EOL + EOL\n );\n }\n if (assemblyscript.isError(diagnostic)) hasErrors = true;\n }\n return hasErrors;\n}\n\nexports.checkDiagnostics = checkDiagnostics;\n\n/** Creates an empty set of stats. */\nfunction createStats() {\n return {\n readTime: 0,\n readCount: 0,\n writeTime: 0,\n writeCount: 0,\n parseTime: 0,\n parseCount: 0,\n compileTime: 0,\n compileCount: 0,\n emitTime: 0,\n emitCount: 0,\n validateTime: 0,\n validateCount: 0,\n optimizeTime: 0,\n optimizeCount: 0\n };\n}\n\nexports.createStats = createStats;\n\nif (!process.hrtime) process.hrtime = require(\"browser-process-hrtime\");\n\n/** Measures the execution time of the specified function. */\nfunction measure(fn) {\n const start = process.hrtime();\n fn();\n const times = process.hrtime(start);\n return times[0] * 1e9 + times[1];\n}\n\nexports.measure = measure;\n\n/** Formats a high resolution time to a human readable string. */\nfunction formatTime(time) {\n return time ? (time / 1e6).toFixed(3) + \" ms\" : \"N/A\";\n}\n\nexports.formatTime = formatTime;\n\n/** Formats and prints out the contents of a set of stats. */\nfunction printStats(stats, output) {\n function format(time, count) {\n return formatTime(time);\n }\n (output || process.stdout).write([\n \"I/O Read : \" + format(stats.readTime, stats.readCount),\n \"I/O Write : \" + format(stats.writeTime, stats.writeCount),\n \"Parse : \" + format(stats.parseTime, stats.parseCount),\n \"Compile : \" + format(stats.compileTime, stats.compileCount),\n \"Emit : \" + format(stats.emitTime, stats.emitCount),\n \"Validate : \" + format(stats.validateTime, stats.validateCount),\n \"Optimize : \" + format(stats.optimizeTime, stats.optimizeCount)\n ].join(EOL) + EOL);\n}\n\nexports.printStats = printStats;\n\n/** Prints runtime type information. */\nfunction printRTTI(program, output) {\n if (!output) output = process.stderr;\n output.write(\"# Runtime type information (RTTI)\\n\");\n output.write(assemblyscript.buildRTTI(program));\n}\n\nexports.printRTTI = printRTTI;\n\nvar allocBuffer = typeof global !== \"undefined\" && global.Buffer\n ? global.Buffer.allocUnsafe || function(len) { return new global.Buffer(len); }\n : function(len) { return new Uint8Array(len) };\n\n/** Creates a memory stream that can be used in place of stdout/stderr. */\nfunction createMemoryStream(fn) {\n var stream = [];\n stream.write = function(chunk) {\n if (fn) fn(chunk);\n if (typeof chunk === \"string\") {\n let buffer = allocBuffer(utf8.length(chunk));\n utf8.write(chunk, buffer, 0);\n chunk = buffer;\n }\n this.push(chunk);\n };\n stream.reset = function() {\n stream.length = 0;\n };\n stream.toBuffer = function() {\n var offset = 0, i = 0, k = this.length;\n while (i < k) offset += this[i++].length;\n var buffer = allocBuffer(offset);\n offset = i = 0;\n while (i < k) {\n buffer.set(this[i], offset);\n offset += this[i].length;\n ++i;\n }\n return buffer;\n };\n stream.toString = function() {\n var buffer = this.toBuffer();\n return utf8.read(buffer, 0, buffer.length);\n };\n return stream;\n}\n\nexports.createMemoryStream = createMemoryStream;\n\n/** Compatible TypeScript compiler options for syntax highlighting etc. */\nexports.tscOptions = {\n alwaysStrict: true,\n noImplicitAny: true,\n noImplicitReturns: true,\n noImplicitThis: true,\n noEmitOnError: true,\n strictNullChecks: true,\n experimentalDecorators: true,\n target: \"esnext\",\n module: \"commonjs\",\n noLib: true,\n types: [],\n allowJs: false\n};\n","// @protobufjs/utf8\n\n/**\n * A minimal UTF8 implementation for number arrays.\n * @memberof util\n * @namespace\n */\nvar utf8 = exports;\n\n/**\n * Calculates the UTF8 byte length of a string.\n * @param {string} string String\n * @returns {number} Byte length\n */\nutf8.length = function utf8_length(string) {\n var len = 0,\n c = 0;\n for (var i = 0; i < string.length; ++i) {\n c = string.charCodeAt(i);\n if (c < 128)\n len += 1;\n else if (c < 2048)\n len += 2;\n else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {\n ++i;\n len += 4;\n } else\n len += 3;\n }\n return len;\n};\n\n/**\n * Reads UTF8 bytes as a string.\n * @param {Uint8Array} buffer Source buffer\n * @param {number} start Source start\n * @param {number} end Source end\n * @returns {string} String read\n */\nutf8.read = function utf8_read(buffer, start, end) {\n var len = end - start;\n if (len < 1)\n return \"\";\n var parts = null,\n chunk = [],\n i = 0, // char offset\n t; // temporary\n while (start < end) {\n t = buffer[start++];\n if (t < 128)\n chunk[i++] = t;\n else if (t > 191 && t < 224)\n chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;\n else if (t > 239 && t < 365) {\n t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;\n chunk[i++] = 0xD800 + (t >> 10);\n chunk[i++] = 0xDC00 + (t & 1023);\n } else\n chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;\n if (i > 8191) {\n (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));\n i = 0;\n }\n }\n if (parts) {\n if (i)\n parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));\n return parts.join(\"\");\n }\n return String.fromCharCode.apply(String, chunk.slice(0, i));\n};\n\n/**\n * Writes a string as UTF8 bytes.\n * @param {string} string Source string\n * @param {Uint8Array} buffer Destination buffer\n * @param {number} offset Destination offset\n * @returns {number} Bytes written\n */\nutf8.write = function utf8_write(string, buffer, offset) {\n var start = offset,\n c1, // character 1\n c2; // character 2\n for (var i = 0; i < string.length; ++i) {\n c1 = string.charCodeAt(i);\n if (c1 < 128) {\n buffer[offset++] = c1;\n } else if (c1 < 2048) {\n buffer[offset++] = c1 >> 6 | 192;\n buffer[offset++] = c1 & 63 | 128;\n } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {\n c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);\n ++i;\n buffer[offset++] = c1 >> 18 | 240;\n buffer[offset++] = c1 >> 12 & 63 | 128;\n buffer[offset++] = c1 >> 6 & 63 | 128;\n buffer[offset++] = c1 & 63 | 128;\n } else {\n buffer[offset++] = c1 >> 12 | 224;\n buffer[offset++] = c1 >> 6 & 63 | 128;\n buffer[offset++] = c1 & 63 | 128;\n }\n }\n return offset - start;\n};\n","var proc = typeof process !== \"undefined\" && process || {};\nvar isCI = proc.env && \"CI\" in proc.env; // doesn't work when bundled because 'process' is a mock\n\nfunction from(stream, base) {\n var colors = base || {};\n colors.supported = (stream && !!stream.isTTY) || isCI;\n colors.gray = text => colors.supported ? exports.GRAY + text + exports.RESET : text;\n colors.red = text => colors.supported ? exports.RED + text + exports.RESET : text;\n colors.green = text => colors.supported ? exports.GREEN + text + exports.RESET : text;\n colors.yellow = text => colors.supported ? exports.YELLOW + text + exports.RESET : text;\n colors.blue = text => colors.supported ? exports.BLUE + text + exports.RESET : text;\n colors.magenta = text => colors.supported ? exports.MAGENTA + text + exports.RESET : text;\n colors.cyan = text => colors.supported ? exports.CYAN + text + exports.RESET : text;\n colors.white = text => colors.supported ? exports.WHITE + text + exports.RESET : text;\n return colors;\n}\n\nexports.stdout = from(proc.stdout, exports);\nexports.stderr = from(proc.stderr);\nexports.from = from;\n\nexports.GRAY = \"\\u001b[90m\";\nexports.RED = \"\\u001b[91m\";\nexports.GREEN = \"\\u001b[92m\";\nexports.YELLOW = \"\\u001b[93m\";\nexports.BLUE = \"\\u001b[94m\";\nexports.MAGENTA = \"\\u001b[95m\";\nexports.CYAN = \"\\u001b[96m\";\nexports.WHITE = \"\\u001b[97m\";\nexports.RESET = \"\\u001b[0m\";\n","// type | meaning\n// -----|---------------\n// b | boolean\n// i | integer\n// f | float\n// s | string\n// I | integer array\n// F | float array\n// S | string array\n\n/** Parses the specified command line arguments according to the given configuration. */\nfunction parse(argv, config) {\n var options = {};\n var unknown = [];\n var arguments = [];\n var trailing = [];\n\n // make an alias map and initialize defaults\n var aliases = {};\n Object.keys(config).forEach(key => {\n if (key.startsWith(\" \")) return;\n var option = config[key];\n if (option.alias != null) {\n if (typeof option.alias === \"string\") aliases[option.alias] = key;\n else if (Array.isArray(option.alias)) option.alias.forEach(alias => aliases[alias] = key);\n }\n if (option.default != null) options[key] = option.default;\n });\n\n // iterate over argv\n for (var i = 0, k = (argv = argv.slice()).length; i < k; ++i) {\n let arg = argv[i];\n if (arg == \"--\") { ++i; break; }\n let match = /^(?:(\\-\\w)(?:=(.*))?|(\\-\\-\\w{2,})(?:=(.*))?)$/.exec(arg), option, key;\n if (match) {\n if (config[arg]) option = config[key = arg]; // exact\n else if (match[1] != null) { // alias\n option = config[key = aliases[match[1].substring(1)]];\n if (option && match[2] != null) argv[i--] = match[2];\n } else if (match[3] != null) { // full\n option = config[key = match[3].substring(2)];\n if (option && match[4] != null) argv[i--] = match[4];\n }\n } else {\n if (arg.charCodeAt(0) == 45) option = config[key = arg]; // exact\n else { arguments.push(arg); continue; } // argument\n }\n if (option) {\n if (option.type == null || option.type === \"b\") options[key] = true; // flag\n else {\n if (i + 1 < argv.length && argv[i + 1].charCodeAt(0) != 45) { // present\n switch (option.type) {\n case \"i\": options[key] = parseInt(argv[++i], 10); break;\n case \"I\": options[key] = (options[key] || []).concat(parseInt(argv[++i], 10)); break;\n case \"f\": options[key] = parseFloat(argv[++i]); break;\n case \"F\": options[key] = (options[key] || []).concat(parseFloat(argv[++i])); break;\n case \"s\": options[key] = String(argv[++i]); break;\n case \"S\": options[key] = (options[key] || []).concat(argv[++i].split(\",\")); break;\n default: unknown.push(arg); --i;\n }\n } else { // omitted\n switch (option.type) {\n case \"i\":\n case \"f\": options[key] = option.default || 0; break;\n case \"s\": options[key] = option.default || \"\"; break;\n case \"I\":\n case \"F\":\n case \"S\": options[key] = options.default || []; break;\n default: unknown.push(arg);\n }\n }\n }\n if (option.value) Object.keys(option.value).forEach(k => options[k] = option.value[k]);\n } else unknown.push(arg);\n }\n while (i < k) trailing.push(argv[i++]); // trailing\n\n return { options, unknown, arguments, trailing };\n}\n\nexports.parse = parse;\n\n/** Generates the help text for the specified configuration. */\nfunction help(config, options) {\n if (!options) options = {};\n var indent = options.indent || 2;\n var padding = options.padding || 24;\n var eol = options.eol || \"\\n\";\n var sb = [];\n Object.keys(config).forEach(key => {\n var option = config[key];\n if (option.description == null) return;\n var text = \"\";\n while (text.length < indent) text += \" \";\n text += \"--\" + key;\n if (option.alias) text += \", -\" + option.alias;\n while (text.length < padding) text += \" \";\n if (Array.isArray(option.description)) {\n sb.push(text + option.description[0] + option.description.slice(1).map(line => {\n for (let i = 0; i < padding; ++i) line = \" \" + line;\n return eol + line;\n }).join(\"\"));\n } else sb.push(text + option.description);\n });\n return sb.join(eol);\n}\n\nexports.help = help;\n","/*\nCopyright 2010 James Halliday (mail@substack.net)\n\nThis project is free software released under the MIT/X11 license:\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n\nvar path = require(\"path\");\nvar fs = require(\"fs\");\nvar _0777 = parseInt(\"0777\", 8);\n\nmodule.exports = function mkdirp(p, opts, made) {\n if (!opts || typeof opts !== \"object\") {\n opts = { mode: opts };\n }\n var mode = opts.mode;\n if (mode === undefined) {\n mode = _0777 & (~process.umask());\n }\n if (!made) made = null;\n p = path.resolve(p);\n try {\n fs.mkdirSync(p, mode);\n made = made || p;\n } catch (err0) {\n switch (err0.code) {\n case \"ENOENT\":\n made = mkdirp(path.dirname(p), opts, made);\n mkdirp(p, opts, made);\n break;\n default:\n var stat;\n try {\n stat = fs.statSync(p);\n } catch (err1) {\n throw err0;\n }\n if (!stat.isDirectory()) throw err0;\n break;\n }\n }\n return made;\n};\n","const fs = require(\"fs\");\nconst path = require(\"path\");\n\nfunction findFiles(dirname, filter) {\n var out = [];\n fs.readdirSync(dirname).forEach(name => {\n if (fs.statSync(path.join(dirname, name)).isDirectory()) {\n findFiles(path.join(dirname, name), filter).forEach(iname => out.push(name + \"/\" + iname));\n } else if (!filter || typeof filter === \"function\" ? filter(name) : filter.test(name)) {\n out.push(name);\n }\n });\n return out;\n}\n\nexports.files = findFiles;\n\nexports.TS = /\\.ts$/;\nexports.TS_EXCEPT_DTS = /[^\\.][^\\d]\\.ts$/;\n","if(typeof __WEBPACK_EXTERNAL_MODULE__12__ === 'undefined') {var e = new Error(\"Cannot find module 'assemblyscript'\"); e.code = 'MODULE_NOT_FOUND'; throw e;}\nmodule.exports = __WEBPACK_EXTERNAL_MODULE__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