diff --git a/bin/asc.js b/bin/asc.js index d9505a68..0094f57e 100644 --- a/bin/asc.js +++ b/bin/asc.js @@ -553,3 +553,18 @@ function createMemoryStream(fn) { } exports.createMemoryStream = createMemoryStream; + +exports.tscOptions = { + alwaysStrict: true, + noImplicitAny: true, + noImplicitReturns: true, + noImplicitThis: true, + noEmitOnError: true, + strictNullChecks: true, + experimentalDecorators: true, + target: "esnext", + module: "commonjs", + noLib: true, + types: [], + allowJs: false +}; diff --git a/dist/asc.js b/dist/asc.js index ed3cd227..2e65ffbd 100644 --- a/dist/asc.js +++ b/dist/asc.js @@ -1,4 +1,4 @@ -(function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t(function(){try{return require('assemblyscript')}catch(t){}}(),require('./assemblyscript')):'function'==typeof define&&define.amd?define(['assemblyscript'],t):'object'==typeof exports?exports.asc=t(function(){try{return require('assemblyscript')}catch(t){}}(),require('./assemblyscript')):e.asc=t(e._,e[void 0])})('undefined'==typeof self?this:self,function(t,e){var r=Math.floor,n=Math.pow,s=Math.min;return function(e){function t(r){if(i[r])return i[r].exports;var n=i[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,r){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var i=e&&e.__esModule?function(){return e['default']}:function(){return e};return t.d(i,'a',i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p='',t(t.s=3)}([function(e,t,i){t.nextTick=function(e){setTimeout(e,0)},t.platform=t.arch=t.execPath=t.title='browser',t.pid=1,t.browser=!0,t.env={},t.argv=[],t.binding=function(){throw new Error('No such module. (Possibly not yet loaded)')},function(){var e,r='/';t.cwd=function(){return r},t.chdir=function(t){e||(e=i(1)),r=e.resolve(t,r)}}(),t.exit=t.kill=t.umask=t.dlopen=t.uptime=t.memoryUsage=t.uvCounters=function(){},t.features={}},function(e,t,i){(function(e){function r(e,t){for(var r,n=0,s=e.length-1;0<=s;s--)r=e[s],'.'===r?e.splice(s,1):'..'===r?(e.splice(s,1),n++):n&&(e.splice(s,1),n--);if(t)for(;n--;n)e.unshift('..');return e}function n(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;ni?[]:e.slice(t,i-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var o=n(e.split('/')),a=n(r.split('/')),l=s(o.length,a.length),u=l,c=0;c{t=d.readFileSync(e,{encoding:'utf8'})}),t}catch(t){return null}}function h(e,t){try{return I.writeCount++,I.writeTime+=l(()=>d.writeFileSync(e,t,'string'==typeof t?{encoding:'utf8'}:void 0)),!0}catch(t){return!1}}function z(e){var t;try{return I.readTime+=l(()=>{t=i(!function(){var t=new Error('Cannot find module "glob"');throw t.code='MODULE_NOT_FOUND',t}()).sync('*.ts',{cwd:e})}),t}catch(t){return[]}}function A(e){A.used||(I.writeCount++,A.used=!0),I.writeTime+=l(()=>E.write(e,'string'==typeof e?{encoding:'utf8'}:void 0))}'function'==typeof r?(n=r,r={}):!r&&(r={});const E=r.stdout||e.stdout,w=r.stderr||e.stderr,L=r.readFile||m,S=r.writeFile||h,C=r.listFiles||z,I=r.stats||a();if(!E)throw Error('\'options.stdout\' must be specified');if(!w)throw Error('\'options.stderr\' must be specified');if(!d.readFileSync){if(L===m)throw Error('\'options.readFile\' must be specified');if(S===h)throw Error('\'options.writeFile\' must be specified');if(C===z)throw Error('\'options.listFiles\' must be specified')}const N=s(t),k=24;if(n||(n=function(e){var t=0;return e&&(w.write(e.stack+f.EOL),t=1),t}),N.version)return E.write('Version '+g+f.EOL),n(null);if(N.help||1>N._.length){const e=[];return Object.keys(y).forEach((t)=>{var i=y[t],r=' ';for(r+='--'+t,i.aliases&&1===i.aliases[0].length&&(r+=', -'+i.aliases[0]);r.length{for(let t=0;t hello.wasm','','Options:'].concat(e).join(f.EOL)+f.EOL),n(null)}const P=null==N.baseDir?e.cwd():c.resolve(N.baseDir),M=c.join('.','..','std','assembly'),U=N.noLib?[]:[M];N.lib&&('string'==typeof N.lib&&(N.lib=N.lib.split(',')),Array.prototype.push.apply(U,N.lib.map(trim)));var O=null;for(let e=0,i=N._.length;eO=p.parseFile(s,r,O,!0));null!=(r=O.nextFile());){if(r.startsWith(_)){for(let e=0,t=U.length;ep.parseFile(s,r,O))}if(o(O,w))return n(Error('Parse error'))}var D=!1;N.noLib||Object.keys(x).forEach((e)=>{e.lastIndexOf('/')>=_.length||(I.parseCount++,I.parseTime+=l(()=>{O=p.parseFile(x[e],e+'.ts',O,!1)}),D=!0)});for(let e=0,i=U.length;e{O=p.parseFile(s,_+r,O,!1)})}}const F=p.createOptions();p.setTarget(F,0),p.setNoTreeShaking(F,!!N.noTreeShaking),p.setNoAssert(F,!!N.noAssert),p.setNoMemory(F,!!N.noMemory),p.setSourceMap(F,null!=N.sourceMap);var R;I.compileCount++;try{I.compileTime+=l(()=>R=p.compile(O,F))}catch(t){return n(t)}if(o(O,w))return R&&R.dispose(),n(Error('Compile error'));if(N.validate&&(I.validateCount++,I.validateTime+=l(()=>{if(!R.validate())return R.dispose(),n(Error('Validate error'))})),'clamp'===N.trapMode)I.optimizeCount++,I.optimizeTime+=l(()=>R.runPasses(['trap-mode-clamp']));else if('js'===N.trapMode)I.optimizeCount++,I.optimizeTime+=l(()=>R.runPasses(['trap-mode-js']));else if('allow'!==N.trapMode)return R.dispose(),n(Error('Unsupported trap mode'));var V=-1,B=0,j=!N.noDebug;!1!==N.optimize&&('number'==typeof N.optimize?V=N.optimize:N[0]?V=0:N[1]?V=1:N[2]?V=2:N[3]?V=3:!0===N.optimize?(V=v,B=T):V=0),N.s?B=1:N.z&&(B=2),'number'==typeof N.optimizeLevel&&(V=N.optimizeLevel),'number'==typeof N.shrinkLevel?B=N.shrinkLevel:'s'===N.shrinkLevel?B=1:'z'===N.shrinkLevel&&(B=2),R.setOptimizeLevel(V),R.setShrinkLevel(B),R.setDebugInfo(j);var H=[];if(N.runPasses&&('string'==typeof N.runPasses&&(N.runPasses=N.runPasses.split(',')),N.runPasses.length&&N.runPasses.forEach((e)=>{0>H.indexOf(e)&&H.push(e)})),0<=V&&(I.optimizeCount++,I.optimizeTime+=l(()=>R.optimize())),H.length&&(I.optimizeCount++,I.optimizeTime+=l(()=>R.runPasses(H.map((e)=>e.trim())))),!N.noEmit){let e=!1;if(null!=N.outFile&&(/\.wast$/.test(N.outFile)&&null==N.textFile?N.textFile=N.outFile:/\.js$/.test(N.outFile)&&null==N.asmjsFile?N.asmjsFile=N.outFile:null==N.binaryFile&&(N.binaryFile=N.outFile)),null!=N.binaryFile){let t,i=null==N.sourceMap?null:N.sourceMap.length?N.sourceMap:c.basename(N.binaryFile)+'.map';if(I.emitCount++,I.emitTime+=l(()=>t=R.toBinary(i)),N.binaryFile.length?S(c.join(P,N.binaryFile),t.output):(A(t.output),e=!0),null!=t.sourceMap)if(N.binaryFile.length){let e=JSON.parse(t.sourceMap);e.sourceRoot=b,e.sources.forEach((t,i)=>{let r=null;if(t.startsWith(_))for(let e=0,i=U.length;et=R.toText()),S(c.join(P,N.textFile),t)):!e&&(I.emitCount++,I.emitTime+=l(()=>t=R.toText()),A(t),e=!0)}if(null!=N.asmjsFile&&N.asmjsFile.length){let t;N.asmjsFile.length?(I.emitCount++,I.emitTime+=l(()=>t=R.toAsmjs()),S(c.join(P,N.asmjsFile),t)):!e&&(I.emitCount++,I.emitTime+=l(()=>t=R.toAsmjs()),A(t),e=!0)}}return R.dispose(),N.measure&&u(I,w),n(null)}function s(e){const t={};return Object.keys(y).forEach((e)=>{const i=y[e];i.aliases&&((t.alias||(t.alias={}))[e]=i.aliases),void 0!==i.default&&((t.default||(t.default={}))[e]=i.default),'string'===i.type?(t.string||(t.string=[])).push(e):'boolean'===i.type&&(t.boolean||(t.boolean=[])).push(e)}),i(14)(e,t)}function o(e,t){for(var i,r=!1;null!=(i=p.nextDiagnostic(e));)t.write(p.formatDiagnostic(i,t.isTTY,!0)+f.EOL+f.EOL),p.isError(i)&&(r=!0);return r}function a(){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 l(t){const i=e.hrtime();t();const r=e.hrtime(i);return 1e9*r[0]+r[1]}function u(t,i){(i||e.stdout).write(['I/O Read : '+(t.readTime?(t.readTime/1e6).toFixed(3)+' ms ('+t.readCount+' files)':'N/A'),'I/O Write : '+(t.writeTime?(t.writeTime/1e6).toFixed(3)+' ms ('+t.writeCount+' files)':'N/A'),'Parse : '+(t.parseTime?(t.parseTime/1e6).toFixed(3)+' ms ('+t.parseCount+' times)':'N/A'),'Compile : '+(t.compileTime?(t.compileTime/1e6).toFixed(3)+' ms ('+t.compileCount+' times)':'N/A'),'Emit : '+(t.emitTime?(t.emitTime/1e6).toFixed(3)+' ms ('+t.emitCount+' times)':'N/A'),'Validate : '+(t.validateTime?(t.validateTime/1e6).toFixed(3)+' ms ('+t.validateCount+' times)':'N/A'),'Optimize : '+(t.optimizeTime?(t.optimizeTime/1e6).toFixed(3)+' ms ('+t.optimizeCount+' times)':'N/A')].join(f.EOL)+f.EOL)}const c=i(1),d=i(9),f=i(10);var p,m;try{p=i(11),m=!1;try{i(!function(){var t=new Error('Cannot find module "source-map-support"');throw t.code='MODULE_NOT_FOUND',t}()).install()}catch(t){}}catch(t){try{i(!function(){var t=new Error('Cannot find module "ts-node"');throw t.code='MODULE_NOT_FOUND',t}()).register({project:i(1).join('.','..','src')}),i(!function(){var t=new Error('Cannot find module "../src/glue/js"');throw t.code='MODULE_NOT_FOUND',t}()),p=i(!function(){var t=new Error('Cannot find module "../src"');throw t.code='MODULE_NOT_FOUND',t}()),m=!0}catch(t){p=i(12),m=!1}}const h=!0,g=t.version='0.5.0',y=t.options=i(13),b='assemblyscript:///',_=p.LIBRARY_PREFIX,v=t.defaultOptimizeLevel=2,T=t.defaultShrinkLevel=1,x=t.libraryFiles={"(lib)/allocator/arena":'/////////////// A simple yet effective Arena Memory Allocator /////////////////\n\n// Provides a `reset_memory` function to reset the heap to its initial state. A\n// user has to make sure that there are no more references to cleared memory\n// afterwards. Always aligns to 8 bytes.\n\nconst ALIGN_LOG2: usize = 3;\nconst ALIGN_SIZE: usize = 1 << ALIGN_LOG2;\nconst ALIGN_MASK: usize = ALIGN_SIZE - 1;\n\nvar HEAP_OFFSET: usize = HEAP_BASE;\n\nexport function allocate_memory(size: usize): usize {\n if (!size) return 0;\n var ptr = HEAP_OFFSET;\n var off = (ptr + size + ALIGN_MASK) & ~ALIGN_MASK;\n var avail = current_memory() << 16;\n if (off > avail && grow_memory(\n max(\n (((off + 0xffff) & ~0xffff) - avail) >> 16, // minimum required pages\n avail >> 16 // at least double memory\n )\n ) < 0) unreachable(); // out of memory\n HEAP_OFFSET = off;\n return ptr;\n}\n\nexport function free_memory(ptr: usize): void {\n // nop\n}\n\nexport function reset_memory(): void {\n HEAP_OFFSET = HEAP_BASE;\n}\n',"(lib)/allocator/emscripten":'///////////////////////// Emscripten Memory Allocator //////////////////////////\n\n// Uses Emscripten\'s exported _malloc and _free implementations, i.e., when\n// linking with Emscripten-compiled programs that already provide these.\n// Differs from \'system\' in that their names are prefixed with an underscore.\n\ndeclare function _malloc(size: usize): usize;\ndeclare function _free(ptr: usize): void;\n\nexport function allocate_memory(size: usize): usize {\n return _malloc(size);\n}\n\nexport function free_memory(ptr: usize): void {\n _free(ptr);\n}\n\nexport function reset_memory(): void {\n throw new Error("not supported");\n}\n',"(lib)/allocator/system":'/////////////////////////// System Memory Allocator ////////////////////////////\n\n// Uses the environment\'s malloc and free implementations, i.e., when linking\n// with other C-like programs that already provide these.\n\ndeclare function malloc(size: usize): usize;\ndeclare function free(ptr: usize): void;\n\nexport function allocate_memory(size: usize): usize {\n return malloc(size);\n}\n\nexport function free_memory(ptr: usize): void {\n free(ptr);\n}\n\nexport function reset_memory(): void {\n throw new Error("not supported");\n}\n',"(lib)/allocator/tlsf":'////////////// TLSF (Two-Level Segregate Fit) Memory Allocator ////////////////\n\n// Re-export for now, so there\'s just one source file being worked on\n\nexport {\n allocate_memory,\n free_memory\n} from "../../../examples/tlsf/assembly/tlsf";\n\nexport function reset_memory(): void {\n throw new Error("not supported");\n}\n',"(lib)/array":'export class Array {\n\n private __memory: usize;\n private __capacity: i32; // capped to [0, 0x7fffffff]\n private __length: i32; // capped to [0, __capacity]\n\n private __grow(newCapacity: i32): void {\n assert(newCapacity > this.__capacity);\n var newMemory = allocate_memory(newCapacity * sizeof());\n if (this.__memory) {\n move_memory(newMemory, this.__memory, this.__capacity * sizeof());\n free_memory(this.__memory);\n }\n this.__memory = newMemory;\n this.__capacity = newCapacity;\n }\n\n constructor(capacity: i32 = 0) {\n if (capacity < 0)\n throw new RangeError("Invalid array length");\n this.__memory = capacity ? allocate_memory(capacity * sizeof()) : 0;\n this.__capacity = this.__length = capacity;\n }\n\n get length(): i32 {\n return this.__length;\n }\n\n set length(length: i32) {\n if (length < 0)\n throw new RangeError("Invalid array length");\n if (length > this.__capacity)\n this.__grow(max(length, this.__capacity << 1));\n this.__length = length;\n }\n\n @operator("[]")\n private __get(index: i32): T {\n if (index >= this.__capacity)\n throw new Error("Index out of bounds"); // return changetype(0) ?\n return load(this.__memory + index * sizeof());\n }\n\n @operator("[]=")\n private __set(index: i32, value: T): void {\n if (index < 0)\n throw new Error("Index out of bounds");\n if (index >= this.__capacity)\n this.__grow(max(index + 1, this.__capacity << 1));\n store(this.__memory + index * sizeof(), value);\n }\n\n indexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n if (fromIndex < 0)\n fromIndex = this.__length + fromIndex;\n while (fromIndex < this.__length) {\n if (load(this.__memory + fromIndex * sizeof()) == searchElement)\n return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n if (fromIndex < 0)\n fromIndex = this.__length + fromIndex;\n else if (fromIndex >= this.__length)\n fromIndex = this.__length - 1;\n while (fromIndex >= 0) {\n if (load(this.__memory + fromIndex * sizeof()) == searchElement)\n return fromIndex;\n --fromIndex;\n }\n return -1;\n }\n\n push(element: T): i32 {\n if (this.__length == this.__capacity)\n this.__grow(this.__capacity ? this.__capacity << 1 : 1);\n store(this.__memory + this.__length * sizeof(), element);\n return ++this.__length;\n }\n\n pop(): T {\n if (this.__length < 1)\n throw new RangeError("Array is empty"); // return changetype(0) ?\n return load(this.__memory + --this.__length * sizeof());\n }\n\n shift(): T {\n if (this.__length < 1)\n throw new RangeError("Array is empty"); // return changetype(0) ?\n var element = load(this.__memory);\n move_memory(this.__memory, this.__memory + sizeof(), (this.__capacity - 1) * sizeof());\n set_memory(this.__memory + (this.__capacity - 1) * sizeof(), 0, sizeof());\n --this.__length;\n return element;\n }\n\n unshift(element: T): i32 {\n var oldCapacity = this.__capacity;\n if (this.__length == oldCapacity) {\n // inlined __grow (avoids moving twice)\n var newCapacity: i32 = oldCapacity ? oldCapacity << 1 : 1;\n assert(newCapacity > this.__capacity);\n var newMemory = allocate_memory(newCapacity * sizeof());\n if (this.__memory) {\n move_memory(newMemory + sizeof(), this.__memory, oldCapacity * sizeof());\n free_memory(this.__memory);\n }\n this.__memory = newMemory;\n this.__capacity = newCapacity;\n } else\n move_memory(this.__memory + sizeof(), this.__memory, oldCapacity * sizeof());\n store(this.__memory, element);\n return ++this.__length;\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n if (begin < 0) {\n begin = this.__length + begin;\n if (begin < 0)\n begin = 0;\n } else if (begin > this.__length)\n begin = this.__length;\n if (end < 0)\n end = this.__length + end;\n else if (end > this.__length)\n end = this.__length;\n if (end < begin)\n end = begin;\n var capacity = end - begin;\n assert(capacity >= 0);\n var sliced = new Array(capacity);\n if (capacity)\n move_memory(sliced.__memory, this.__memory + begin * sizeof(), capacity * sizeof());\n return sliced;\n }\n\n splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): void {\n if (deleteCount < 1)\n return;\n if (start < 0) {\n start = this.__length + start;\n if (start < 0)\n start = 0;\n else if (start >= this.__length)\n return;\n } else if (start >= this.__length)\n return;\n deleteCount = min(deleteCount, this.__length - start);\n move_memory(this.__memory + start * sizeof(), this.__memory + (start + deleteCount) * sizeof(), deleteCount * sizeof());\n this.__length -= deleteCount;\n }\n\n reverse(): Array {\n for (var front: usize = 0, back: usize = this.__length - 1; front < back; ++front, --back) {\n var temp = load(this.__memory + front * sizeof());\n store(this.__memory + front * sizeof(), load(this.__memory + back * sizeof()));\n store(this.__memory + back * sizeof(), temp);\n }\n return this;\n }\n}\n\n@unmanaged\nexport class CArray {\n\n private constructor() {}\n\n @operator("[]")\n private __get(index: i32): T {\n if (index < 0)\n throw new RangeError("Index out of range");\n return load(changetype(this) + index * sizeof());\n }\n\n @operator("[]=")\n private __set(index: i32, value: T): void {\n if (index < 0)\n throw new RangeError("Index out of range");\n store(changetype(this) + index * sizeof(), value);\n }\n}\n',"(lib)/builtins":'@builtin\nexport declare const NaN: f64; // | f32\n\n@builtin\nexport declare const Infinity: f64; // | f32\n\n@builtin\nexport declare function isNaN(value: T): bool;\n\n@builtin\nexport declare function isFinite(value: T): bool;\n\n@builtin\nexport declare function clz(value: T): T;\n\n@builtin\nexport declare function ctz(value: T): T;\n\n@builtin\nexport declare function popcnt(value: T): T;\n\n@builtin\nexport declare function rotl(value: T, shift: T): T;\n\n@builtin\nexport declare function rotr(value: T, shift: T): T;\n\n@builtin\nexport declare function abs(value: T): T;\n\n@builtin\nexport declare function max(left: T, right: T): T;\n\n@builtin\nexport declare function min(left: T, right: T): T;\n\n@builtin\nexport declare function ceil(value: T): T;\n\n@builtin\nexport declare function floor(value: T): T;\n\n@builtin\nexport declare function copysign(left: T, right: T): T;\n\n@builtin\nexport declare function nearest(left: T, right: T): T;\n\n@builtin\nexport declare function reinterpret(value: void): T;\n\n@builtin\nexport declare function sqrt(value: T): T;\n\n@builtin\nexport declare function trunc(value: T): T;\n\n@builtin\nexport declare function load(offset: usize, constantOffset?: usize): T;\n\n@builtin\nexport declare function store(offset: usize, value: void, constantOffset?: usize): T;\n\n@builtin\nexport declare function sizeof(): usize;\n\n@builtin\nexport declare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n\n@builtin\nexport declare function unreachable(): void;\n\n@builtin\nexport declare function current_memory(): i32;\n\n@builtin\nexport declare function grow_memory(pages: i32): i32;\n\n// @builtin\n// export declare function move_memory(dest: usize, src: usize: n: usize): void;\n\n// @builtin\n// export declare function set_memory(dest: usize, value: u32, n: usize): void;\n\n@builtin\nexport declare function changetype(value: void): T;\n\n@builtin\nexport declare function assert(isTrueish: T, message?: string): T;\n\n@builtin\nexport declare function abort(message?: string | null, fileName?: string | null, lineNumber?: u32, columnNumber?: u32): void;\n\n@builtin\ndeclare function i8(value: void): i8;\nnamespace i8 {\n export const MIN_VALUE: i8 = -128;\n export const MAX_VALUE: i8 = 127;\n}\nexport { i8 };\n\n@builtin\ndeclare function i16(value: void): i16;\nnamespace i16 {\n export const MIN_VALUE: i16 = -32768;\n export const MAX_VALUE: i16 = 32767;\n}\nexport { i16 };\n\n@builtin\ndeclare function i32(value: void): i32;\nnamespace i32 {\n export const MIN_VALUE: i32 = -2147483648;\n export const MAX_VALUE: i32 = 2147483647;\n}\nexport { i32 };\n\n@builtin\ndeclare function i64(value: void): i64;\nnamespace i64 {\n export const MIN_VALUE: i64 = -9223372036854775808;\n export const MAX_VALUE: i64 = 9223372036854775807;\n}\nexport { i64 };\n\n@builtin\ndeclare function isize(value: void): isize;\nnamespace isize {\n export const MIN_VALUE: isize = sizeof() == sizeof() ? -2147483648 : -9223372036854775808;\n export const MAX_VALUE: isize = sizeof() == sizeof() ? 2147483647 : 9223372036854775807;\n}\nexport { isize };\n\n@builtin\ndeclare function u8(value: void): u8;\nnamespace u8 {\n export const MIN_VALUE: u8 = 0;\n export const MAX_VALUE: u8 = 255;\n}\nexport { u8 };\n\n@builtin\ndeclare function u16(value: void): u16;\nnamespace u16 {\n export const MIN_VALUE: u16 = 0;\n export const MAX_VALUE: u16 = 65535;\n}\nexport { u16 };\n\n@builtin\ndeclare function u32(value: void): u32;\nnamespace u32 {\n export const MIN_VALUE: u32 = 0;\n export const MAX_VALUE: u32 = 4294967295;\n}\nexport { u32 };\n\n@builtin\ndeclare function u64(value: void): u64;\nnamespace u64 {\n export const MIN_VALUE: u64 = 0;\n export const MAX_VALUE: u64 = 18446744073709551615;\n}\nexport { u64 };\n\n@builtin\ndeclare function usize(value: void): usize;\nnamespace usize {\n export const MIN_VALUE: usize = 0;\n export const MAX_VALUE: usize = sizeof() == sizeof() ? 4294967295 : 18446744073709551615;\n}\nexport { usize };\n\n@builtin\ndeclare function bool(value: void): bool;\nnamespace bool {\n export const MIN_VALUE: bool = 0;\n export const MAX_VALUE: bool = 1;\n}\nexport { bool };\n\n@builtin\ndeclare function f32(value: void): f32;\nnamespace f32 {\n export const MIN_VALUE: f32 = -3.40282347e+38;\n export const MAX_VALUE: f32 = 3.40282347e+38;\n export const MIN_SAFE_INTEGER: f32 = -16777215;\n export const MAX_SAFE_INTEGER: f32 = 16777215;\n export const EPSILON: f32 = 1.19209290e-07;\n}\nexport { f32 };\n\n@builtin\ndeclare function f64(value: void): f64;\nnamespace f64 {\n export const MIN_VALUE: f64 = -1.7976931348623157e+308;\n export const MAX_VALUE: f64 = 1.7976931348623157e+308;\n export const MIN_SAFE_INTEGER: f64 = -9007199254740991;\n export const MAX_SAFE_INTEGER: f64 = 9007199254740991;\n export const EPSILON: f64 = 2.2204460492503131e-16;\n}\nexport{ f64 };\n\n@builtin\nexport declare const HEAP_BASE: usize;\n\n@builtin\nexport declare function start(): void;\n',"(lib)/error":'export class Error {\n\n name: string = "Error";\n message: string;\n stack: string = ""; // TODO\n\n constructor(message: string = "") {\n this.message = message;\n }\n}\n\nexport class RangeError extends Error {\n name: string = "RangeError";\n}\n',"(lib)/iterator":'// export abstract class Iterator {\n// abstract get done(): bool;\n// abstract next(): T;\n// }\n',"(lib)/map":'export class Map {\n\n private __keys: K[] = [];\n private __values: V[] = [];\n\n // FIXME: not a proper map implementation, just a filler\n\n get size(): i32 {\n return this.__keys.length;\n }\n\n get(key: K): V | null {\n var keys = this.__keys;\n for (var i = 0, k = keys.length; i < k; ++i)\n if (keys[i] == key)\n return this.__values[i];\n return null;\n }\n\n has(key: K): bool {\n var keys = this.__keys;\n for (var i = 0, k = keys.length; i < k; ++i)\n if (keys[i] == key)\n return true;\n return false;\n }\n\n set(key: K, value: V): void {\n this.__keys.push(key);\n this.__values.push(value);\n }\n\n clear(): void {\n this.__keys.length = 0;\n this.__values.length = 0;\n }\n}\n',"(lib)/memory":'function copy_memory(dest: usize, src: usize, n: usize): void {\n // based on musl\'s implementation of memcpy\n // not a future instruction and sufficiently covered by the upcoming move_memory intrinsic\n\n var w: u32, x: u32;\n\n // copy 1 byte each until src is aligned to 4 bytes\n while (n && src % 4) {\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 % 4 == 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 % 4) {\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 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 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 // 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\nexport function move_memory(dest: usize, src: usize, n: usize): void {\n // based on musl\'s implementation of memmove\n // becomes obsolete once https://github.com/WebAssembly/bulk-memory-operations lands\n\n if (dest == src)\n return;\n if (src + n <= dest || dest + n <= src) {\n copy_memory(dest, src, n);\n return;\n }\n if (dest < src) {\n if (src % 8 == dest % 8) {\n while (dest % 8) {\n if (!n)\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 % 8 == dest % 8) {\n while ((dest + n) % 8) {\n if (!n)\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\nexport function set_memory(dest: usize, c: u8, n: usize): void {\n // based on musl\'s implementation of memset\n // becomes obsolete once https://github.com/WebAssembly/bulk-memory-operations lands\n\n // fill head and tail with minimal branching\n if (!n)\n return;\n store(dest, c);\n store(dest + n - 1, c);\n if (n <= 2)\n 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)\n return;\n store(dest + 3, c);\n store(dest + n - 4, c);\n if (n <= 8)\n return;\n\n // advance pointer to align it at 4-byte boundary\n var k: usize = -dest & 3;\n dest += k;\n n -= k;\n n &= -4;\n\n var 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)\n 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)\n 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 var 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\nexport function compare_memory(vl: usize, vr: usize, n: usize): i32 {\n // based on musl\'s implementation of memcmp\n // provided because there\'s no proposed alternative\n if (vl == vr)\n return 0;\n while (n && load(vl) == load(vr)) {\n n--;\n vl++;\n vr++;\n }\n return n ? load(vl) - load(vr) : 0;\n}\n',"(lib)/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',"(lib)/set":'// const prime1: u32 = 73;\n// const prime2: u32 = 5009;\n\nexport class Set {\n\n private __memory: usize;\n private __capacity: u32;\n private __size: u32;\n\n constructor() {\n this.__memory = 0;\n this.__capacity = this.__size = 0;\n }\n\n get size(): i32 {\n return this.__size;\n }\n\n // FIXME: not a proper set implementation, just a filler\n\n has(value: T): bool {\n assert(this != null);\n\n for (var index: usize = 0, limit: usize = this.__size; index < limit; ++index)\n if (load(this.__memory + index * sizeof()) == value)\n return true;\n return false;\n }\n\n add(value: T): Set {\n assert(this != null);\n\n if (this.__size >= this.__capacity) {\n var newCapacity = max(this.__capacity << 1, 8);\n var newMemory = allocate_memory(newCapacity * sizeof());\n if (this.__memory) {\n move_memory(newMemory, this.__memory, this.__capacity * sizeof());\n free_memory(this.__memory);\n }\n this.__capacity = newCapacity;\n this.__memory = newMemory;\n }\n store(this.__memory + this.__size * sizeof(), value);\n ++this.__size;\n return this;\n }\n\n delete(value: T): bool {\n assert(this != null);\n\n for (var index: usize = 0, limit: usize = this.__size; index < limit; ++index)\n if (load(this.__memory + index * sizeof()) == value) {\n if (index + 1 < this.__size)\n move_memory(this.__memory + index * sizeof(), this.__memory + (index + 1) * sizeof(), this.__size - index - 1);\n --this.__size;\n return true;\n }\n return false;\n }\n\n clear(): void {\n assert(this != null);\n\n this.__size = 0;\n }\n\n // TODO: think about iterators\n}\n\n// class SetIterator extends Iterator {\n\n// get done(): bool {\n// throw new Error("not implemented");\n// }\n\n// next(): T {\n// throw new Error("not implemented");\n// }\n// }\n',"(lib)/string":'// singleton empty string\nconst EMPTY: String = changetype("");\n\n// number of bytes preceeding string data\nconst HEAD: usize = 4;\n\nfunction allocate(length: i32): String {\n assert(length > 0); // 0 -> EMPTY\n var ptr = allocate_memory(HEAD + (length << 1));\n store(ptr, length);\n return changetype(ptr);\n}\n\nexport class String {\n\n readonly length: i32;\n\n @operator("[]")\n charAt(pos: i32): String {\n assert(this != null);\n\n if (pos >= this.length)\n return EMPTY;\n\n var out = allocate(1);\n store(\n changetype(out),\n load(\n changetype(this) + (pos << 1),\n HEAD\n ),\n HEAD\n );\n return out;\n }\n\n charCodeAt(pos: i32): i32 {\n assert(this != null);\n\n if (pos >= this.length)\n return -1; // (NaN)\n\n return load(\n changetype(this) + (pos << 1),\n HEAD\n );\n }\n\n codePointAt(pos: i32): i32 {\n assert(this != null);\n\n if (pos >= this.length)\n return -1; // (undefined)\n var first = load(\n changetype(this) + (pos << 1),\n HEAD\n );\n if (first < 0xD800 || first > 0xDBFF || pos + 1 == this.length)\n return first;\n var second = load(\n changetype(this) + ((pos + 1) << 1),\n HEAD\n );\n if (second < 0xDC00 || second > 0xDFFF)\n return first;\n return ((first - 0xD800) << 10) + (second - 0xDC00) + 0x10000;\n }\n\n @operator("+")\n private static __concat(left: String, right: String): String {\n if (left == null)\n left = changetype("null");\n return left.concat(right);\n }\n\n concat(other: String): String {\n assert(this != null);\n\n if (other == null)\n other = changetype("null");\n\n var thisLen: isize = this.length;\n var otherLen: isize = other.length;\n var outLen: usize = thisLen + otherLen;\n if (outLen == 0)\n return EMPTY;\n\n var out = allocate(outLen);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD,\n thisLen << 1\n );\n move_memory(\n changetype(out) + HEAD + (thisLen << 1),\n changetype(other) + HEAD,\n otherLen << 1\n );\n return out;\n }\n\n endsWith(searchString: String, endPosition: i32 = 0x7fffffff): bool {\n assert(this != null);\n\n if (searchString == null)\n return false;\n\n var end: isize = min(max(endPosition, 0), this.length);\n var searchLength: isize = searchString.length;\n var start: isize = end - searchLength;\n if (start < 0)\n return false;\n\n return !compare_memory(\n changetype(this) + HEAD + (start << 1),\n changetype(searchString) + HEAD,\n searchLength << 1\n );\n }\n\n @operator("==")\n private static __eq(left: String, right: String): bool {\n if (left == null)\n return right == null;\n else if (right == null)\n return false;\n\n var leftLength = left.length;\n if (leftLength != right.length)\n return false;\n\n return !compare_memory(\n changetype(left) + HEAD,\n changetype(right) + HEAD,\n (leftLength << 1)\n );\n }\n\n includes(searchString: String, position: i32 = 0): bool {\n return this.indexOf(searchString, position) != -1;\n }\n\n indexOf(searchString: String, position: i32 = 0): i32 {\n assert(this != null);\n\n if (searchString == null)\n searchString = changetype("null");\n\n var pos: isize = position;\n var len: isize = this.length;\n var start: isize = min(max(pos, 0), len);\n var searchLen: isize = searchString.length;\n\n // TODO: two-way, multiple char codes\n for (var k: usize = start; k + searchLen <= len; ++k)\n if (!compare_memory(\n changetype(this) + HEAD + (k << 1),\n changetype(searchString) + HEAD,\n searchLen << 1)\n )\n return k;\n return -1;\n }\n\n startsWith(searchString: String, position: i32 = 0): bool {\n assert(this != null);\n\n if (searchString == null)\n searchString = changetype("null");\n\n var pos: isize = position;\n var len: isize = this.length;\n var start: isize = min(max(position, 0), len);\n var searchLength: isize = searchString.length;\n if (searchLength + start > len)\n return false;\n\n return !compare_memory(\n changetype(this) + HEAD + (start << 1),\n changetype(searchString) + HEAD,\n searchLength << 1\n );\n }\n\n substr(start: i32, length: i32 = i32.MAX_VALUE): String {\n assert(this != null);\n\n var intStart: isize = start;\n var end: isize = length;\n var size: isize = this.length;\n if (intStart < 0)\n intStart = max(size + intStart, 0);\n\n var resultLength: isize = min(max(end, 0), size - intStart);\n if (resultLength <= 0)\n return EMPTY;\n\n var out = allocate(resultLength);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD + (intStart << 1),\n resultLength << 1\n );\n return out;\n }\n\n substring(start: i32, end: i32 = i32.MAX_VALUE): String {\n assert(this != null);\n\n var len = this.length;\n var finalStart = min(max(start, 0), len);\n var finalEnd = min(max(end, 0), len);\n var from = min(finalStart, finalEnd);\n var to = max(finalStart, finalEnd);\n len = to - from;\n if (!len)\n return EMPTY;\n\n if (!from && to == this.length)\n return this;\n\n var out = allocate(len);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD + (from << 1),\n len << 1\n );\n return out;\n }\n\n trim(): String {\n assert(this != null);\n\n var length: usize = this.length;\n while (length && isWhiteSpaceOrLineTerminator(load(changetype(this) + (length << 1), HEAD)))\n --length;\n\n var start: usize = 0;\n while (start < length && isWhiteSpaceOrLineTerminator(load(changetype(this) + (start << 1), HEAD)))\n ++start, --length;\n\n if (!length)\n return EMPTY;\n\n if (!start && length == this.length)\n return this;\n\n var out = allocate(length);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD + (start << 1),\n length << 1\n );\n return out;\n }\n\n trimLeft(): String {\n assert(this != null);\n\n var start: isize = 0;\n var len: isize = this.length;\n while (start < len && isWhiteSpaceOrLineTerminator(load(changetype(this) + (start << 1), HEAD)))\n ++start;\n\n if (!start)\n return this;\n\n var outLen = len - start;\n if (!outLen)\n return EMPTY;\n\n var out = allocate(outLen);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD + (start << 1),\n outLen << 1\n );\n return out;\n }\n\n trimRight(): String {\n assert(this != null);\n\n var len: isize = this.length;\n while (len > 0 && isWhiteSpaceOrLineTerminator(load(changetype(this) + (len << 1), HEAD)))\n --len;\n\n if (len <= 0)\n return EMPTY;\n\n if (len == this.length)\n return this;\n\n var out = allocate(len);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD,\n len << 1\n );\n return out;\n }\n}\n\nfunction isWhiteSpaceOrLineTerminator(c: u16): bool {\n switch (c) {\n\n case 10: // \n case 13: // \n case 8232: // \n case 8233: // \n\n case 9: // \n case 11: // \n case 12: // \n case 32: // \n case 160: // \n case 65279: // \n\n return true;\n default:\n return false;\n }\n}\n\nconst 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 O = 0x4F,\n X = 0x58,\n Z = 0x5a,\n a = 0x61,\n b = 0x62,\n e = 0x65,\n o = 0x6F,\n x = 0x78,\n z = 0x7A\n}\n\nexport function parseInt(str: String, radix: i32 = 0): f64 {\n return parse(str, radix);\n}\n\nexport function parseI32(str: String, radix: i32 = 0): i32 {\n return parse(str, radix);\n}\n\nexport function parseI64(str: String, radix: i32 = 0): i64 {\n return parse(str, radix);\n}\n\nfunction parse(str: String, radix: i32 = 0): T {\n var len: i32 = str.length;\n if (!len)\n return NaN;\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr, HEAD);\n\n // determine sign\n var sign: T;\n if (code == CharCode.MINUS) {\n if (!--len)\n return NaN;\n code = load(ptr += 2, HEAD);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len)\n return NaN;\n code = load(ptr += 2, HEAD);\n sign = 1;\n } else\n sign = 1;\n\n // determine radix\n if (!radix) {\n if (code == CharCode._0 && len > 2) {\n switch (load(ptr + 2, HEAD)) {\n\n case CharCode.B:\n case CharCode.b:\n ptr += 4; len -= 2;\n radix = 2;\n break;\n\n case CharCode.O:\n case CharCode.o:\n ptr += 4; len -= 2;\n radix = 8;\n break;\n\n case CharCode.X:\n case CharCode.x:\n ptr += 4; len -= 2;\n radix = 16;\n break;\n\n default:\n radix = 10;\n }\n } else radix = 10;\n } else if (radix < 2 || radix > 36)\n return NaN;\n\n // calculate value\n var num: T = 0;\n while (len--) {\n code = load(ptr, HEAD);\n if (code >= CharCode._0 && code <= CharCode._9)\n code -= CharCode._0;\n else if (code >= CharCode.A && code <= CharCode.Z)\n code -= CharCode.A - 10;\n else if (code >= CharCode.a && code <= CharCode.z)\n code -= CharCode.a - 10;\n else\n break;\n if (code >= radix)\n break;\n num = (num * radix) + code;\n ptr += 2;\n }\n return sign * num;\n}\n\nexport function parseFloat(str: String): f64 {\n var len: i32 = str.length;\n if (!len)\n return NaN;\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr, HEAD);\n\n // determine sign\n var sign: f64;\n if (code == CharCode.MINUS) {\n if (!--len)\n return NaN;\n code = load(ptr += 2, HEAD);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len)\n return NaN;\n code = load(ptr += 2, HEAD);\n sign = 1;\n } else\n sign = 1;\n\n // calculate value\n var num: f64 = 0;\n while (len--) {\n code = load(ptr, HEAD);\n if (code == CharCode.DOT) {\n ptr += 2;\n var fac: f64 = 0.1; // precision :(\n while (len--) {\n code = load(ptr, HEAD);\n if (code == CharCode.E || code == CharCode.e)\n assert(false); // TODO\n code -= CharCode._0;\n if (code > 9)\n break;\n num += code * fac;\n fac *= 0.1;\n ptr += 2;\n }\n break;\n }\n code -= CharCode._0;\n if (code >= 10)\n break;\n num = (num * 10) + code;\n ptr += 2;\n }\n return sign * num;\n}\n'},z=t.definitionFiles={assembly:'// Definitions for the "AssemblyScript" subset.\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 = any; // sic\n/** A 32-bit float. */\ndeclare type f32 = number;\n/** A 64-bit float. */\ndeclare type f64 = number;\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i8;\ndeclare namespace i8 {\n export const MIN_VALUE: i8;\n export const MAX_VALUE: i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i8;\ndeclare namespace i16 {\n export const MIN_VALUE: i16;\n export const MAX_VALUE: i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i32;\ndeclare namespace i32 {\n export const MIN_VALUE: i32;\n export const MAX_VALUE: i32;\n}\n/** Converts any other numeric value to a 64-bit signed integer. */\ndeclare function i64(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i64;\ndeclare namespace i64 {\n export const MIN_VALUE: i64;\n export const MAX_VALUE: i64;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare function isize(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): isize;\ndeclare namespace isize {\n export const MIN_VALUE: isize;\n export const MAX_VALUE: isize;\n}\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i8;\ndeclare namespace u8 {\n export const MIN_VALUE: u8;\n export const MAX_VALUE: u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i8;\ndeclare namespace u16 {\n export const MIN_VALUE: u16;\n export const MAX_VALUE: u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i32;\ndeclare namespace u32 {\n export const MIN_VALUE: u32;\n export const MAX_VALUE: u32;\n}\n/** Converts any other numeric value to a 64-bit unsigned integer. */\ndeclare function u64(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i64;\ndeclare namespace u64 {\n export const MIN_VALUE: u64;\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 function usize(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): isize;\ndeclare namespace usize {\n export const MIN_VALUE: usize;\n export const MAX_VALUE: usize;\n}\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): bool;\ndeclare namespace bool {\n export const MIN_VALUE: bool;\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): f32;\ndeclare namespace f32 {\n export const MIN_VALUE: f32;\n export const MAX_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}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): f64;\ndeclare namespace f64 {\n export const MIN_VALUE: f64;\n export const MAX_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}\n\n// Built-ins\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, constantOffset?: usize): any;\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, constantOffset?: usize): void;\n/** Returns the current memory size in units of pages. One page is 64kb. */\ndeclare function current_memory(): 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. */\ndeclare function grow_memory(value: i32): i32;\n/** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\ndeclare function move_memory(destination: usize, source: usize, n: usize): void;\n/** Sets n bytes beginning at the specified destination in memory to the specified byte value. */\ndeclare function set_memory(destination: usize, value: u8, count: usize): void;\n/** Compares two chunks of memory. Returns `0` if equal, otherwise the difference of the first differing bytes. */\ndeclare function compare_memory(vl: usize, vr: usize, n: usize): i32;\n/** Allocates a chunk of memory of the specified size and returns a pointer to it. */\ndeclare function allocate_memory(size: usize): usize;\n/** Disposes a chunk of memory by its pointer. */\ndeclare function free_memory(ptr: 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 core or class type. Compiles to a constant. */\ndeclare function sizeof(): usize;\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/** 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/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */\ndeclare function assert(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses an integer string to a 64-bit integer. */\ndeclare function parseI64(str: string, radix?: i32): i64;\n/** Parses a string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n\n// Standard library (not yet implemented)\n\n/** Class representing a sequence of values of type `T`. */\ndeclare class Array {\n [key: number]: T;\n /** Current length of the array. */\n length: i32;\n /** Constructs a new array. */\n constructor(capacity?: i32);\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): void;\n pop(): T;\n shift(): T;\n unshift(element: T): i32;\n slice(from: i32, to?: i32): T[];\n splice(start: i32, deleteCount?: i32): void;\n reverse(): T[];\n}\n\n/** Class representing a C-like array of values of type `T` with limited capabilities. */\ndeclare class CArray {\n [key: number]: T;\n private constructor();\n}\n\n/** Class representing a sequence of characters. */\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(cp: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: u32;\n\n charAt(index: u32): string;\n charCodeAt(index: u32): u16;\n concat(other: string): string;\n endsWith(other: string): bool;\n indexOf(other: string): u32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(start: u32, end?: u32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n}\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\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\ninterface Boolean {}\ninterface Function {}\ninterface IArguments {}\ninterface Number {}\ninterface Object {}\ninterface RegExp {}\n\ndeclare class Set {\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n}\n\n// Internal decorators\n\n/** Annotates an element as a program global. */\ndeclare function global(target: Function): any;\n\n/** Annotates a method as an operator overload. */\ndeclare function operator(token: string): any;\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(target: Function): any;\n\n/** Annotates a class field with an explicit offset. */\ndeclare function offset(offset: usize): any;\n\n/** Annotates an element as begin built-in. */\ndeclare function builtin(target: Function): any;\n',portable:'// Definitions for the "portable AssemblyScript" subset.\n\n// Portable types\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 value\n// of 2^53-1) and instead require a compatibility layer to work in JS as well. See: src/util/i64.ts\n\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 bool = boolean;\ndeclare type usize = number;\ndeclare type f32 = number;\ndeclare type f64 = number;\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i8;\ndeclare namespace i8 {\n export const MIN_VALUE: i8;\n export const MAX_VALUE: i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i8;\ndeclare namespace i16 {\n export const MIN_VALUE: i16;\n export const MAX_VALUE: i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i32;\ndeclare namespace i32 {\n export const MIN_VALUE: i32;\n export const MAX_VALUE: 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: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): isize;\ndeclare namespace isize {\n export const MIN_VALUE: isize;\n export const MAX_VALUE: isize;\n}\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i8;\ndeclare namespace u8 {\n export const MIN_VALUE: u8;\n export const MAX_VALUE: u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i8;\ndeclare namespace u16 {\n export const MIN_VALUE: u16;\n export const MAX_VALUE: u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i32;\ndeclare namespace u32 {\n export const MIN_VALUE: u32;\n export const MAX_VALUE: 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: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): isize;\ndeclare namespace usize {\n export const MIN_VALUE: usize;\n export const MAX_VALUE: usize;\n}\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): bool;\ndeclare namespace bool {\n export const MIN_VALUE: bool;\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): f32;\ndeclare namespace 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}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): f64;\ndeclare namespace 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}\n\n// Portable built-ins\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/** 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/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(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/** Allocates a chunk of memory of the specified size and returns a pointer to it. */\ndeclare function allocate_memory(size: usize): usize;\n/** Disposes a chunk of memory by its pointer. */\ndeclare function free_memory(ptr: usize): void;\n/** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\ndeclare function move_memory(destination: usize, source: usize, n: usize): void;\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/** Traps if the specified value is not true-ish, otherwise returns the value. */\ndeclare function assert(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses a floating point string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n\n// Portable standard library\n// Everything marked @deprecated is a temporary filler. Do not use.\n\ndeclare const NaN: f32 | f64;\ndeclare const Infinity: f32 | f64;\n\ndeclare class Array {\n [key: number]: T;\n length: i32;\n constructor(capacity?: i32);\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): void;\n pop(): T;\n shift(): T;\n unshift(element: T): i32;\n slice(from: i32, to?: i32): T[];\n splice(start: i32, deleteCount?: i32): void;\n reverse(): T[];\n\n join(delim: string): string;\n}\n\ndeclare class Uint8Array extends Array {}\ndeclare class Uint16Array extends Array {}\ndeclare class Uint32Array extends Array {}\ndeclare class Int8Array extends Array {}\ndeclare class Int16Array extends Array {}\ndeclare class Int32Array extends Array {}\ndeclare class Float32Array extends Array {}\ndeclare class Float64Array extends Array {}\n\ndeclare class String {\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(cp: i32): string;\n static fromCodePoints(arr: i32[]): string;\n readonly length: i32;\n private constructor();\n indexOf(subject: string): i32;\n includes(other: string): bool;\n lastIndexOf(subject: string): i32;\n charAt(index: i32): string;\n charCodeAt(index: i32): i32;\n substring(from: i32, to?: i32): string;\n startsWith(subject: string): bool;\n endsWith(subject: string): bool;\n replace(search: string, replacement: string): string;\n toString(): string;\n}\n\ninterface Boolean {}\n\ndeclare class Number {\n private constructor();\n toString(radix?: i32): string;\n}\n\ninterface Object {}\n\ninterface Function {}\n\ninterface RegExp {}\n\ninterface IArguments {}\n\ndeclare class Error {\n constructor(message: string);\n message: string;\n stack: string | null;\n}\n\ndeclare class Symbol {\n private constructor();\n static readonly iterator: symbol;\n}\n\ndeclare class Set {\n constructor(entries?: T[]);\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n [Symbol.iterator](): Iterator;\n}\n\ndeclare class Map {\n constructor(entries?: [K, V][]);\n readonly size: i32;\n set(key: K, value: V): void;\n has(key: K): bool;\n get(key: K): V | null;\n clear(): void;\n entries(): Iterable<[K, V]>;\n keys(): Iterable;\n values(): Iterable;\n [Symbol.iterator](): Iterator<[K,V]>;\n}\n\ninterface Iterable {\n [Symbol.iterator](): Iterator;\n}\n\ninterface Iterator {}\n\ndeclare namespace console {\n /** @deprecated */\n function log(message: string): void;\n}\n'};t.main=n,t.parseArguments=s,t.checkDiagnostics=o,t.createStats=a,e.hrtime||(e.hrtime=i(15)),t.measure=l,t.printStats=u,t.createMemoryStream=function(e){var t=[];return t.write=function(t){'string'==typeof t?this.push(r.from(t,'utf8')):this.push(t),e&&e(t)},t.toBuffer=function(){return r.concat(this)},t.toString=function(){return this.toBuffer().toString('utf8')},t}}).call(t,i(0),i(5).Buffer)},function(e,t,i){'use strict';(function(e){function o(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()e)throw new RangeError('"size" argument must not be negative')}function d(e,t,i,r){return c(t),0>=t?a(e,t):void 0===i?a(e,t):'string'==typeof r?a(e,t).fill(i,r):a(e,t).fill(i)}function f(e,t){if(c(t),e=a(e,0>t?0:0|y(t)),!l.TYPED_ARRAY_SUPPORT)for(var r=0;rt.length?0:0|y(t.length);e=a(e,r);for(var n=0;ni||t.byteLength=o())throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x'+o().toString(16)+' bytes');return 0|e}function b(e,t){if(l.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var i=e.length;if(0===i)return 0;for(var r=!1;;)switch(t){case'ascii':case'latin1':case'binary':return i;case'utf8':case'utf-8':case void 0:return W(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*i;case'hex':return i>>>1;case'base64':return K(e).length;default:if(r)return W(e).length;t=(''+t).toLowerCase(),r=!0;}}function _(e,t,i){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return'';if((void 0===i||i>this.length)&&(i=this.length),0>=i)return'';if(i>>>=0,t>>>=0,i<=t)return'';for(e||(e='utf8');;)switch(e){case'hex':return M(this,t,i);case'utf8':case'utf-8':return I(this,t,i);case'ascii':return N(this,t,i);case'latin1':case'binary':return P(this,t,i);case'base64':return C(this,t,i);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return U(this,t,i);default:if(r)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),r=!0;}}function v(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function T(e,t,i,r,n){if(0===e.length)return-1;if('string'==typeof i?(r=i,i=0):2147483647i&&(i=-2147483648),i=+i,isNaN(i)&&(i=n?0:e.length-1),0>i&&(i=e.length+i),i>=e.length){if(n)return-1;i=e.length-1}else if(0>i)if(n)i=0;else return-1;if('string'==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:x(e,t,i,r,n);if('number'==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):x(e,[t],i,r,n);throw new TypeError('val must be string, number or Buffer')}function x(e,t,r,n,s){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,l=e.length,u=t.length;if(void 0!==n&&(n=(n+'').toLowerCase(),'ucs2'===n||'ucs-2'===n||'utf16le'===n||'utf-16le'===n)){if(2>e.length||2>t.length)return-1;a=2,l/=2,u/=2,r/=2}var c;if(s){var i=-1;for(c=r;cl&&(r=l-u),c=r;0<=c;c--){for(var d=!0,f=0;fs&&(n=s)):n=s;var o=t.length;if(0!=o%2)throw new TypeError('Invalid hex string');n>o/2&&(n=o/2);for(var a,l=0;li&&(a=i):2==l?(u=e[o+1],128==(192&u)&&(f=(31&i)<<6|63&u,127f||57343f&&(a=f))):void 0}null===a?(a=65533,l=1):65535>>10),a=56320|1023&a),n.push(a),o+=l}return k(n)}function k(e){var t=e.length;if(t<=ie)return Q.apply(String,e);for(var r='',n=0;nt)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var s='',o=t;oe)throw new RangeError('offset is not uint');if(e+t>i)throw new RangeError('Trying to access beyond buffer length')}function D(e,t,i,r,n,s){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||te.length)throw new RangeError('Index out of range')}function F(e,t,r,n){0>t&&(t=65535+t+1);for(var o=0,i=s(e.length-r,2);o>>8*(n?o:1-o)}function R(e,t,r,n){0>t&&(t=4294967295+t+1);for(var o=0,i=s(e.length-r,4);o>>8*(n?o:3-o)}function V(e,t,i,r){if(i+r>e.length)throw new RangeError('Index out of range');if(0>i)throw new RangeError('Index out of range')}function B(e,t,i,r,n){return n||V(e,t,i,4,34028234663852886e22,-34028234663852886e22),ee.write(e,t,i,r,23,4),i+4}function j(e,t,i,r,n){return n||V(e,t,i,8,17976931348623157e292,-17976931348623157e292),ee.write(e,t,i,r,52,8),i+8}function H(e){if(e=Y(e).replace(re,''),2>e.length)return'';for(;0!=e.length%4;)e+='=';return e}function Y(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function X(e){return 16>e?'0'+e.toString(16):e.toString(16)}function W(e,t){t=t||Infinity;for(var r,n=e.length,s=null,o=[],a=0;ar){if(!s){if(56319r){-1<(t-=3)&&o.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&-1<(t-=3)&&o.push(239,191,189);if(s=null,128>r){if(0>(t-=1))break;o.push(r)}else if(2048>r){if(0>(t-=2))break;o.push(192|r>>6,128|63&r)}else if(65536>r){if(0>(t-=3))break;o.push(224|r>>12,128|63&r>>6,128|63&r)}else if(1114112>r){if(0>(t-=4))break;o.push(240|r>>18,128|63&r>>12,128|63&r>>6,128|63&r)}else throw new Error('Invalid code point')}return o}function G(e){for(var t=[],r=0;r(t-=2));++a)r=e.charCodeAt(a),n=r>>8,s=r%256,o.push(s),o.push(n);return o}function K(e){return $.toByteArray(H(e))}function J(e,t,r,n){for(var s=0;s=t.length||s>=e.length);++s)t[s+r]=e[s];return s}function Z(e){return e!==e}var Q=String.fromCharCode,$=i(6),ee=i(7),te=i(8);/*! +(function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t(function(){try{return require('assemblyscript')}catch(t){}}(),require('./assemblyscript')):'function'==typeof define&&define.amd?define(['assemblyscript'],t):'object'==typeof exports?exports.asc=t(function(){try{return require('assemblyscript')}catch(t){}}(),require('./assemblyscript')):e.asc=t(e._,e[void 0])})('undefined'==typeof self?this:self,function(t,e){var r=Math.floor,n=Math.pow,s=Math.min;return function(e){function t(r){if(i[r])return i[r].exports;var n=i[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var i={};return t.m=e,t.c=i,t.d=function(e,i,r){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var i=e&&e.__esModule?function(){return e['default']}:function(){return e};return t.d(i,'a',i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p='',t(t.s=3)}([function(e,t,i){t.nextTick=function(e){setTimeout(e,0)},t.platform=t.arch=t.execPath=t.title='browser',t.pid=1,t.browser=!0,t.env={},t.argv=[],t.binding=function(){throw new Error('No such module. (Possibly not yet loaded)')},function(){var e,r='/';t.cwd=function(){return r},t.chdir=function(t){e||(e=i(1)),r=e.resolve(t,r)}}(),t.exit=t.kill=t.umask=t.dlopen=t.uptime=t.memoryUsage=t.uvCounters=function(){},t.features={}},function(e,t,i){(function(e){function r(e,t){for(var r,n=0,s=e.length-1;0<=s;s--)r=e[s],'.'===r?e.splice(s,1):'..'===r?(e.splice(s,1),n++):n&&(e.splice(s,1),n--);if(t)for(;n--;n)e.unshift('..');return e}function n(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;ni?[]:e.slice(t,i-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var o=n(e.split('/')),a=n(r.split('/')),l=s(o.length,a.length),u=l,c=0;c{t=d.readFileSync(e,{encoding:'utf8'})}),t}catch(t){return null}}function h(e,t){try{return I.writeCount++,I.writeTime+=l(()=>d.writeFileSync(e,t,'string'==typeof t?{encoding:'utf8'}:void 0)),!0}catch(t){return!1}}function z(e){var t;try{return I.readTime+=l(()=>{t=i(!function(){var t=new Error('Cannot find module "glob"');throw t.code='MODULE_NOT_FOUND',t}()).sync('*.ts',{cwd:e})}),t}catch(t){return[]}}function A(e){A.used||(I.writeCount++,A.used=!0),I.writeTime+=l(()=>E.write(e,'string'==typeof e?{encoding:'utf8'}:void 0))}'function'==typeof r?(n=r,r={}):!r&&(r={});const E=r.stdout||e.stdout,w=r.stderr||e.stderr,L=r.readFile||m,S=r.writeFile||h,C=r.listFiles||z,I=r.stats||a();if(!E)throw Error('\'options.stdout\' must be specified');if(!w)throw Error('\'options.stderr\' must be specified');if(!d.readFileSync){if(L===m)throw Error('\'options.readFile\' must be specified');if(S===h)throw Error('\'options.writeFile\' must be specified');if(C===z)throw Error('\'options.listFiles\' must be specified')}const N=s(t),k=24;if(n||(n=function(e){var t=0;return e&&(w.write(e.stack+f.EOL),t=1),t}),N.version)return E.write('Version '+g+f.EOL),n(null);if(N.help||1>N._.length){const e=[];return Object.keys(y).forEach((t)=>{var i=y[t],r=' ';for(r+='--'+t,i.aliases&&1===i.aliases[0].length&&(r+=', -'+i.aliases[0]);r.length{for(let t=0;t hello.wasm','','Options:'].concat(e).join(f.EOL)+f.EOL),n(null)}const P=null==N.baseDir?e.cwd():c.resolve(N.baseDir),M=c.join('.','..','std','assembly'),U=N.noLib?[]:[M];N.lib&&('string'==typeof N.lib&&(N.lib=N.lib.split(',')),Array.prototype.push.apply(U,N.lib.map(trim)));var O=null;for(let e=0,i=N._.length;eO=p.parseFile(s,r,O,!0));null!=(r=O.nextFile());){if(r.startsWith(_)){for(let e=0,t=U.length;ep.parseFile(s,r,O))}if(o(O,w))return n(Error('Parse error'))}var D=!1;N.noLib||Object.keys(x).forEach((e)=>{e.lastIndexOf('/')>=_.length||(I.parseCount++,I.parseTime+=l(()=>{O=p.parseFile(x[e],e+'.ts',O,!1)}),D=!0)});for(let e=0,i=U.length;e{O=p.parseFile(s,_+r,O,!1)})}}const F=p.createOptions();p.setTarget(F,0),p.setNoTreeShaking(F,!!N.noTreeShaking),p.setNoAssert(F,!!N.noAssert),p.setNoMemory(F,!!N.noMemory),p.setSourceMap(F,null!=N.sourceMap);var R;I.compileCount++;try{I.compileTime+=l(()=>R=p.compile(O,F))}catch(t){return n(t)}if(o(O,w))return R&&R.dispose(),n(Error('Compile error'));if(N.validate&&(I.validateCount++,I.validateTime+=l(()=>{if(!R.validate())return R.dispose(),n(Error('Validate error'))})),'clamp'===N.trapMode)I.optimizeCount++,I.optimizeTime+=l(()=>R.runPasses(['trap-mode-clamp']));else if('js'===N.trapMode)I.optimizeCount++,I.optimizeTime+=l(()=>R.runPasses(['trap-mode-js']));else if('allow'!==N.trapMode)return R.dispose(),n(Error('Unsupported trap mode'));var V=-1,B=0,j=!N.noDebug;!1!==N.optimize&&('number'==typeof N.optimize?V=N.optimize:N[0]?V=0:N[1]?V=1:N[2]?V=2:N[3]?V=3:!0===N.optimize?(V=v,B=T):V=0),N.s?B=1:N.z&&(B=2),'number'==typeof N.optimizeLevel&&(V=N.optimizeLevel),'number'==typeof N.shrinkLevel?B=N.shrinkLevel:'s'===N.shrinkLevel?B=1:'z'===N.shrinkLevel&&(B=2),R.setOptimizeLevel(V),R.setShrinkLevel(B),R.setDebugInfo(j);var H=[];if(N.runPasses&&('string'==typeof N.runPasses&&(N.runPasses=N.runPasses.split(',')),N.runPasses.length&&N.runPasses.forEach((e)=>{0>H.indexOf(e)&&H.push(e)})),0<=V&&(I.optimizeCount++,I.optimizeTime+=l(()=>R.optimize())),H.length&&(I.optimizeCount++,I.optimizeTime+=l(()=>R.runPasses(H.map((e)=>e.trim())))),!N.noEmit){let e=!1;if(null!=N.outFile&&(/\.wast$/.test(N.outFile)&&null==N.textFile?N.textFile=N.outFile:/\.js$/.test(N.outFile)&&null==N.asmjsFile?N.asmjsFile=N.outFile:null==N.binaryFile&&(N.binaryFile=N.outFile)),null!=N.binaryFile){let t,i=null==N.sourceMap?null:N.sourceMap.length?N.sourceMap:c.basename(N.binaryFile)+'.map';if(I.emitCount++,I.emitTime+=l(()=>t=R.toBinary(i)),N.binaryFile.length?S(c.join(P,N.binaryFile),t.output):(A(t.output),e=!0),null!=t.sourceMap)if(N.binaryFile.length){let e=JSON.parse(t.sourceMap);e.sourceRoot=b,e.sources.forEach((t,i)=>{let r=null;if(t.startsWith(_))for(let e=0,i=U.length;et=R.toText()),S(c.join(P,N.textFile),t)):!e&&(I.emitCount++,I.emitTime+=l(()=>t=R.toText()),A(t),e=!0)}if(null!=N.asmjsFile&&N.asmjsFile.length){let t;N.asmjsFile.length?(I.emitCount++,I.emitTime+=l(()=>t=R.toAsmjs()),S(c.join(P,N.asmjsFile),t)):!e&&(I.emitCount++,I.emitTime+=l(()=>t=R.toAsmjs()),A(t),e=!0)}}return R.dispose(),N.measure&&u(I,w),n(null)}function s(e){const t={};return Object.keys(y).forEach((e)=>{const i=y[e];i.aliases&&((t.alias||(t.alias={}))[e]=i.aliases),void 0!==i.default&&((t.default||(t.default={}))[e]=i.default),'string'===i.type?(t.string||(t.string=[])).push(e):'boolean'===i.type&&(t.boolean||(t.boolean=[])).push(e)}),i(14)(e,t)}function o(e,t){for(var i,r=!1;null!=(i=p.nextDiagnostic(e));)t.write(p.formatDiagnostic(i,t.isTTY,!0)+f.EOL+f.EOL),p.isError(i)&&(r=!0);return r}function a(){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 l(t){const i=e.hrtime();t();const r=e.hrtime(i);return 1e9*r[0]+r[1]}function u(t,i){(i||e.stdout).write(['I/O Read : '+(t.readTime?(t.readTime/1e6).toFixed(3)+' ms ('+t.readCount+' files)':'N/A'),'I/O Write : '+(t.writeTime?(t.writeTime/1e6).toFixed(3)+' ms ('+t.writeCount+' files)':'N/A'),'Parse : '+(t.parseTime?(t.parseTime/1e6).toFixed(3)+' ms ('+t.parseCount+' times)':'N/A'),'Compile : '+(t.compileTime?(t.compileTime/1e6).toFixed(3)+' ms ('+t.compileCount+' times)':'N/A'),'Emit : '+(t.emitTime?(t.emitTime/1e6).toFixed(3)+' ms ('+t.emitCount+' times)':'N/A'),'Validate : '+(t.validateTime?(t.validateTime/1e6).toFixed(3)+' ms ('+t.validateCount+' times)':'N/A'),'Optimize : '+(t.optimizeTime?(t.optimizeTime/1e6).toFixed(3)+' ms ('+t.optimizeCount+' times)':'N/A')].join(f.EOL)+f.EOL)}const c=i(1),d=i(9),f=i(10);var p,m;try{p=i(11),m=!1;try{i(!function(){var t=new Error('Cannot find module "source-map-support"');throw t.code='MODULE_NOT_FOUND',t}()).install()}catch(t){}}catch(t){try{i(!function(){var t=new Error('Cannot find module "ts-node"');throw t.code='MODULE_NOT_FOUND',t}()).register({project:i(1).join('.','..','src')}),i(!function(){var t=new Error('Cannot find module "../src/glue/js"');throw t.code='MODULE_NOT_FOUND',t}()),p=i(!function(){var t=new Error('Cannot find module "../src"');throw t.code='MODULE_NOT_FOUND',t}()),m=!0}catch(t){p=i(12),m=!1}}const h=!0,g=t.version='0.5.0',y=t.options=i(13),b='assemblyscript:///',_=p.LIBRARY_PREFIX,v=t.defaultOptimizeLevel=2,T=t.defaultShrinkLevel=1,x=t.libraryFiles={"(lib)/allocator/arena":'/////////////// A simple yet effective Arena Memory Allocator /////////////////\n\n// Provides a `reset_memory` function to reset the heap to its initial state. A\n// user has to make sure that there are no more references to cleared memory\n// afterwards. Always aligns to 8 bytes.\n\nconst ALIGN_LOG2: usize = 3;\nconst ALIGN_SIZE: usize = 1 << ALIGN_LOG2;\nconst ALIGN_MASK: usize = ALIGN_SIZE - 1;\n\nvar HEAP_OFFSET: usize = HEAP_BASE;\n\nexport function allocate_memory(size: usize): usize {\n if (!size) return 0;\n var ptr = HEAP_OFFSET;\n var off = (ptr + size + ALIGN_MASK) & ~ALIGN_MASK;\n var avail = current_memory() << 16;\n if (off > avail && grow_memory(\n max(\n (((off + 0xffff) & ~0xffff) - avail) >> 16, // minimum required pages\n avail >> 16 // at least double memory\n )\n ) < 0) unreachable(); // out of memory\n HEAP_OFFSET = off;\n return ptr;\n}\n\nexport function free_memory(ptr: usize): void {\n // nop\n}\n\nexport function reset_memory(): void {\n HEAP_OFFSET = HEAP_BASE;\n}\n',"(lib)/allocator/emscripten":'///////////////////////// Emscripten Memory Allocator //////////////////////////\n\n// Uses Emscripten\'s exported _malloc and _free implementations, i.e., when\n// linking with Emscripten-compiled programs that already provide these.\n// Differs from \'system\' in that their names are prefixed with an underscore.\n\ndeclare function _malloc(size: usize): usize;\ndeclare function _free(ptr: usize): void;\n\nexport function allocate_memory(size: usize): usize {\n return _malloc(size);\n}\n\nexport function free_memory(ptr: usize): void {\n _free(ptr);\n}\n\nexport function reset_memory(): void {\n throw new Error("not supported");\n}\n',"(lib)/allocator/system":'/////////////////////////// System Memory Allocator ////////////////////////////\n\n// Uses the environment\'s malloc and free implementations, i.e., when linking\n// with other C-like programs that already provide these.\n\ndeclare function malloc(size: usize): usize;\ndeclare function free(ptr: usize): void;\n\nexport function allocate_memory(size: usize): usize {\n return malloc(size);\n}\n\nexport function free_memory(ptr: usize): void {\n free(ptr);\n}\n\nexport function reset_memory(): void {\n throw new Error("not supported");\n}\n',"(lib)/allocator/tlsf":'////////////// TLSF (Two-Level Segregate Fit) Memory Allocator ////////////////\n\n// Re-export for now, so there\'s just one source file being worked on\n\nexport {\n allocate_memory,\n free_memory\n} from "../../../examples/tlsf/assembly/tlsf";\n\nexport function reset_memory(): void {\n throw new Error("not supported");\n}\n',"(lib)/array":'export class Array {\n\n private __memory: usize;\n private __capacity: i32; // capped to [0, 0x7fffffff]\n private __length: i32; // capped to [0, __capacity]\n\n private __grow(newCapacity: i32): void {\n assert(newCapacity > this.__capacity);\n var newMemory = allocate_memory(newCapacity * sizeof());\n if (this.__memory) {\n move_memory(newMemory, this.__memory, this.__capacity * sizeof());\n free_memory(this.__memory);\n }\n this.__memory = newMemory;\n this.__capacity = newCapacity;\n }\n\n constructor(capacity: i32 = 0) {\n if (capacity < 0)\n throw new RangeError("Invalid array length");\n this.__memory = capacity ? allocate_memory(capacity * sizeof()) : 0;\n this.__capacity = this.__length = capacity;\n }\n\n get length(): i32 {\n return this.__length;\n }\n\n set length(length: i32) {\n if (length < 0)\n throw new RangeError("Invalid array length");\n if (length > this.__capacity)\n this.__grow(max(length, this.__capacity << 1));\n this.__length = length;\n }\n\n @operator("[]")\n private __get(index: i32): T {\n if (index >= this.__capacity)\n throw new Error("Index out of bounds"); // return changetype(0) ?\n return load(this.__memory + index * sizeof());\n }\n\n @operator("[]=")\n private __set(index: i32, value: T): void {\n if (index < 0)\n throw new Error("Index out of bounds");\n if (index >= this.__capacity)\n this.__grow(max(index + 1, this.__capacity << 1));\n store(this.__memory + index * sizeof(), value);\n }\n\n indexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n if (fromIndex < 0)\n fromIndex = this.__length + fromIndex;\n while (fromIndex < this.__length) {\n if (load(this.__memory + fromIndex * sizeof()) == searchElement)\n return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n if (fromIndex < 0)\n fromIndex = this.__length + fromIndex;\n else if (fromIndex >= this.__length)\n fromIndex = this.__length - 1;\n while (fromIndex >= 0) {\n if (load(this.__memory + fromIndex * sizeof()) == searchElement)\n return fromIndex;\n --fromIndex;\n }\n return -1;\n }\n\n push(element: T): i32 {\n if (this.__length == this.__capacity)\n this.__grow(this.__capacity ? this.__capacity << 1 : 1);\n store(this.__memory + this.__length * sizeof(), element);\n return ++this.__length;\n }\n\n pop(): T {\n if (this.__length < 1)\n throw new RangeError("Array is empty"); // return changetype(0) ?\n return load(this.__memory + --this.__length * sizeof());\n }\n\n shift(): T {\n if (this.__length < 1)\n throw new RangeError("Array is empty"); // return changetype(0) ?\n var element = load(this.__memory);\n move_memory(this.__memory, this.__memory + sizeof(), (this.__capacity - 1) * sizeof());\n set_memory(this.__memory + (this.__capacity - 1) * sizeof(), 0, sizeof());\n --this.__length;\n return element;\n }\n\n unshift(element: T): i32 {\n var oldCapacity = this.__capacity;\n if (this.__length == oldCapacity) {\n // inlined __grow (avoids moving twice)\n var newCapacity: i32 = oldCapacity ? oldCapacity << 1 : 1;\n assert(newCapacity > this.__capacity);\n var newMemory = allocate_memory(newCapacity * sizeof());\n if (this.__memory) {\n move_memory(newMemory + sizeof(), this.__memory, oldCapacity * sizeof());\n free_memory(this.__memory);\n }\n this.__memory = newMemory;\n this.__capacity = newCapacity;\n } else\n move_memory(this.__memory + sizeof(), this.__memory, oldCapacity * sizeof());\n store(this.__memory, element);\n return ++this.__length;\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n if (begin < 0) {\n begin = this.__length + begin;\n if (begin < 0)\n begin = 0;\n } else if (begin > this.__length)\n begin = this.__length;\n if (end < 0)\n end = this.__length + end;\n else if (end > this.__length)\n end = this.__length;\n if (end < begin)\n end = begin;\n var capacity = end - begin;\n assert(capacity >= 0);\n var sliced = new Array(capacity);\n if (capacity)\n move_memory(sliced.__memory, this.__memory + begin * sizeof(), capacity * sizeof());\n return sliced;\n }\n\n splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): void {\n if (deleteCount < 1)\n return;\n if (start < 0) {\n start = this.__length + start;\n if (start < 0)\n start = 0;\n else if (start >= this.__length)\n return;\n } else if (start >= this.__length)\n return;\n deleteCount = min(deleteCount, this.__length - start);\n move_memory(this.__memory + start * sizeof(), this.__memory + (start + deleteCount) * sizeof(), deleteCount * sizeof());\n this.__length -= deleteCount;\n }\n\n reverse(): Array {\n for (var front: usize = 0, back: usize = this.__length - 1; front < back; ++front, --back) {\n var temp = load(this.__memory + front * sizeof());\n store(this.__memory + front * sizeof(), load(this.__memory + back * sizeof()));\n store(this.__memory + back * sizeof(), temp);\n }\n return this;\n }\n}\n\n@unmanaged\nexport class CArray {\n\n private constructor() {}\n\n @operator("[]")\n private __get(index: i32): T {\n if (index < 0)\n throw new RangeError("Index out of range");\n return load(changetype(this) + index * sizeof());\n }\n\n @operator("[]=")\n private __set(index: i32, value: T): void {\n if (index < 0)\n throw new RangeError("Index out of range");\n store(changetype(this) + index * sizeof(), value);\n }\n}\n',"(lib)/builtins":'@builtin\nexport declare const NaN: f64; // | f32\n\n@builtin\nexport declare const Infinity: f64; // | f32\n\n@builtin\nexport declare function isNaN(value: T): bool;\n\n@builtin\nexport declare function isFinite(value: T): bool;\n\n@builtin\nexport declare function clz(value: T): T;\n\n@builtin\nexport declare function ctz(value: T): T;\n\n@builtin\nexport declare function popcnt(value: T): T;\n\n@builtin\nexport declare function rotl(value: T, shift: T): T;\n\n@builtin\nexport declare function rotr(value: T, shift: T): T;\n\n@builtin\nexport declare function abs(value: T): T;\n\n@builtin\nexport declare function max(left: T, right: T): T;\n\n@builtin\nexport declare function min(left: T, right: T): T;\n\n@builtin\nexport declare function ceil(value: T): T;\n\n@builtin\nexport declare function floor(value: T): T;\n\n@builtin\nexport declare function copysign(left: T, right: T): T;\n\n@builtin\nexport declare function nearest(left: T, right: T): T;\n\n@builtin\nexport declare function reinterpret(value: void): T;\n\n@builtin\nexport declare function sqrt(value: T): T;\n\n@builtin\nexport declare function trunc(value: T): T;\n\n@builtin\nexport declare function load(offset: usize, constantOffset?: usize): T;\n\n@builtin\nexport declare function store(offset: usize, value: void, constantOffset?: usize): T;\n\n@builtin\nexport declare function sizeof(): usize;\n\n@builtin\nexport declare function select(ifTrue: T, ifFalse: T, condition: bool): T;\n\n@builtin\nexport declare function unreachable(): void;\n\n@builtin\nexport declare function current_memory(): i32;\n\n@builtin\nexport declare function grow_memory(pages: i32): i32;\n\n// @builtin\n// export declare function move_memory(dest: usize, src: usize: n: usize): void;\n\n// @builtin\n// export declare function set_memory(dest: usize, value: u32, n: usize): void;\n\n@builtin\nexport declare function changetype(value: void): T;\n\n@builtin\nexport declare function assert(isTrueish: T, message?: string): T;\n\n@builtin\nexport declare function abort(message?: string | null, fileName?: string | null, lineNumber?: u32, columnNumber?: u32): void;\n\n@builtin\ndeclare function i8(value: void): i8;\nnamespace i8 {\n export const MIN_VALUE: i8 = -128;\n export const MAX_VALUE: i8 = 127;\n}\nexport { i8 };\n\n@builtin\ndeclare function i16(value: void): i16;\nnamespace i16 {\n export const MIN_VALUE: i16 = -32768;\n export const MAX_VALUE: i16 = 32767;\n}\nexport { i16 };\n\n@builtin\ndeclare function i32(value: void): i32;\nnamespace i32 {\n export const MIN_VALUE: i32 = -2147483648;\n export const MAX_VALUE: i32 = 2147483647;\n}\nexport { i32 };\n\n@builtin\ndeclare function i64(value: void): i64;\nnamespace i64 {\n export const MIN_VALUE: i64 = -9223372036854775808;\n export const MAX_VALUE: i64 = 9223372036854775807;\n}\nexport { i64 };\n\n@builtin\ndeclare function isize(value: void): isize;\nnamespace isize {\n export const MIN_VALUE: isize = sizeof() == sizeof() ? -2147483648 : -9223372036854775808;\n export const MAX_VALUE: isize = sizeof() == sizeof() ? 2147483647 : 9223372036854775807;\n}\nexport { isize };\n\n@builtin\ndeclare function u8(value: void): u8;\nnamespace u8 {\n export const MIN_VALUE: u8 = 0;\n export const MAX_VALUE: u8 = 255;\n}\nexport { u8 };\n\n@builtin\ndeclare function u16(value: void): u16;\nnamespace u16 {\n export const MIN_VALUE: u16 = 0;\n export const MAX_VALUE: u16 = 65535;\n}\nexport { u16 };\n\n@builtin\ndeclare function u32(value: void): u32;\nnamespace u32 {\n export const MIN_VALUE: u32 = 0;\n export const MAX_VALUE: u32 = 4294967295;\n}\nexport { u32 };\n\n@builtin\ndeclare function u64(value: void): u64;\nnamespace u64 {\n export const MIN_VALUE: u64 = 0;\n export const MAX_VALUE: u64 = 18446744073709551615;\n}\nexport { u64 };\n\n@builtin\ndeclare function usize(value: void): usize;\nnamespace usize {\n export const MIN_VALUE: usize = 0;\n export const MAX_VALUE: usize = sizeof() == sizeof() ? 4294967295 : 18446744073709551615;\n}\nexport { usize };\n\n@builtin\ndeclare function bool(value: void): bool;\nnamespace bool {\n export const MIN_VALUE: bool = 0;\n export const MAX_VALUE: bool = 1;\n}\nexport { bool };\n\n@builtin\ndeclare function f32(value: void): f32;\nnamespace f32 {\n export const MIN_VALUE: f32 = -3.40282347e+38;\n export const MAX_VALUE: f32 = 3.40282347e+38;\n export const MIN_SAFE_INTEGER: f32 = -16777215;\n export const MAX_SAFE_INTEGER: f32 = 16777215;\n export const EPSILON: f32 = 1.19209290e-07;\n}\nexport { f32 };\n\n@builtin\ndeclare function f64(value: void): f64;\nnamespace f64 {\n export const MIN_VALUE: f64 = -1.7976931348623157e+308;\n export const MAX_VALUE: f64 = 1.7976931348623157e+308;\n export const MIN_SAFE_INTEGER: f64 = -9007199254740991;\n export const MAX_SAFE_INTEGER: f64 = 9007199254740991;\n export const EPSILON: f64 = 2.2204460492503131e-16;\n}\nexport{ f64 };\n\n@builtin\nexport declare const HEAP_BASE: usize;\n\n@builtin\nexport declare function start(): void;\n',"(lib)/error":'export class Error {\n\n name: string = "Error";\n message: string;\n stack: string = ""; // TODO\n\n constructor(message: string = "") {\n this.message = message;\n }\n}\n\nexport class RangeError extends Error {\n name: string = "RangeError";\n}\n',"(lib)/iterator":'// export abstract class Iterator {\n// abstract get done(): bool;\n// abstract next(): T;\n// }\n',"(lib)/map":'export class Map {\n\n private __keys: K[] = [];\n private __values: V[] = [];\n\n // FIXME: not a proper map implementation, just a filler\n\n get size(): i32 {\n return this.__keys.length;\n }\n\n get(key: K): V | null {\n var keys = this.__keys;\n for (var i = 0, k = keys.length; i < k; ++i)\n if (keys[i] == key)\n return this.__values[i];\n return null;\n }\n\n has(key: K): bool {\n var keys = this.__keys;\n for (var i = 0, k = keys.length; i < k; ++i)\n if (keys[i] == key)\n return true;\n return false;\n }\n\n set(key: K, value: V): void {\n this.__keys.push(key);\n this.__values.push(value);\n }\n\n clear(): void {\n this.__keys.length = 0;\n this.__values.length = 0;\n }\n}\n',"(lib)/memory":'function copy_memory(dest: usize, src: usize, n: usize): void {\n // based on musl\'s implementation of memcpy\n // not a future instruction and sufficiently covered by the upcoming move_memory intrinsic\n\n var w: u32, x: u32;\n\n // copy 1 byte each until src is aligned to 4 bytes\n while (n && src % 4) {\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 % 4 == 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 % 4) {\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 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 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 // 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\nexport function move_memory(dest: usize, src: usize, n: usize): void {\n // based on musl\'s implementation of memmove\n // becomes obsolete once https://github.com/WebAssembly/bulk-memory-operations lands\n\n if (dest == src)\n return;\n if (src + n <= dest || dest + n <= src) {\n copy_memory(dest, src, n);\n return;\n }\n if (dest < src) {\n if (src % 8 == dest % 8) {\n while (dest % 8) {\n if (!n)\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 % 8 == dest % 8) {\n while ((dest + n) % 8) {\n if (!n)\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\nexport function set_memory(dest: usize, c: u8, n: usize): void {\n // based on musl\'s implementation of memset\n // becomes obsolete once https://github.com/WebAssembly/bulk-memory-operations lands\n\n // fill head and tail with minimal branching\n if (!n)\n return;\n store(dest, c);\n store(dest + n - 1, c);\n if (n <= 2)\n 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)\n return;\n store(dest + 3, c);\n store(dest + n - 4, c);\n if (n <= 8)\n return;\n\n // advance pointer to align it at 4-byte boundary\n var k: usize = -dest & 3;\n dest += k;\n n -= k;\n n &= -4;\n\n var 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)\n 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)\n 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 var 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\nexport function compare_memory(vl: usize, vr: usize, n: usize): i32 {\n // based on musl\'s implementation of memcmp\n // provided because there\'s no proposed alternative\n if (vl == vr)\n return 0;\n while (n && load(vl) == load(vr)) {\n n--;\n vl++;\n vr++;\n }\n return n ? load(vl) - load(vr) : 0;\n}\n',"(lib)/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',"(lib)/set":'// const prime1: u32 = 73;\n// const prime2: u32 = 5009;\n\nexport class Set {\n\n private __memory: usize;\n private __capacity: u32;\n private __size: u32;\n\n constructor() {\n this.__memory = 0;\n this.__capacity = this.__size = 0;\n }\n\n get size(): i32 {\n return this.__size;\n }\n\n // FIXME: not a proper set implementation, just a filler\n\n has(value: T): bool {\n assert(this != null);\n\n for (var index: usize = 0, limit: usize = this.__size; index < limit; ++index)\n if (load(this.__memory + index * sizeof()) == value)\n return true;\n return false;\n }\n\n add(value: T): Set {\n assert(this != null);\n\n if (this.__size >= this.__capacity) {\n var newCapacity = max(this.__capacity << 1, 8);\n var newMemory = allocate_memory(newCapacity * sizeof());\n if (this.__memory) {\n move_memory(newMemory, this.__memory, this.__capacity * sizeof());\n free_memory(this.__memory);\n }\n this.__capacity = newCapacity;\n this.__memory = newMemory;\n }\n store(this.__memory + this.__size * sizeof(), value);\n ++this.__size;\n return this;\n }\n\n delete(value: T): bool {\n assert(this != null);\n\n for (var index: usize = 0, limit: usize = this.__size; index < limit; ++index)\n if (load(this.__memory + index * sizeof()) == value) {\n if (index + 1 < this.__size)\n move_memory(this.__memory + index * sizeof(), this.__memory + (index + 1) * sizeof(), this.__size - index - 1);\n --this.__size;\n return true;\n }\n return false;\n }\n\n clear(): void {\n assert(this != null);\n\n this.__size = 0;\n }\n\n // TODO: think about iterators\n}\n\n// class SetIterator extends Iterator {\n\n// get done(): bool {\n// throw new Error("not implemented");\n// }\n\n// next(): T {\n// throw new Error("not implemented");\n// }\n// }\n',"(lib)/string":'// singleton empty string\nconst EMPTY: String = changetype("");\n\n// number of bytes preceeding string data\nconst HEAD: usize = 4;\n\nfunction allocate(length: i32): String {\n assert(length > 0); // 0 -> EMPTY\n var ptr = allocate_memory(HEAD + (length << 1));\n store(ptr, length);\n return changetype(ptr);\n}\n\nexport class String {\n\n readonly length: i32;\n\n @operator("[]")\n charAt(pos: i32): String {\n assert(this != null);\n\n if (pos >= this.length)\n return EMPTY;\n\n var out = allocate(1);\n store(\n changetype(out),\n load(\n changetype(this) + (pos << 1),\n HEAD\n ),\n HEAD\n );\n return out;\n }\n\n charCodeAt(pos: i32): i32 {\n assert(this != null);\n\n if (pos >= this.length)\n return -1; // (NaN)\n\n return load(\n changetype(this) + (pos << 1),\n HEAD\n );\n }\n\n codePointAt(pos: i32): i32 {\n assert(this != null);\n\n if (pos >= this.length)\n return -1; // (undefined)\n var first = load(\n changetype(this) + (pos << 1),\n HEAD\n );\n if (first < 0xD800 || first > 0xDBFF || pos + 1 == this.length)\n return first;\n var second = load(\n changetype(this) + ((pos + 1) << 1),\n HEAD\n );\n if (second < 0xDC00 || second > 0xDFFF)\n return first;\n return ((first - 0xD800) << 10) + (second - 0xDC00) + 0x10000;\n }\n\n @operator("+")\n private static __concat(left: String, right: String): String {\n if (left == null)\n left = changetype("null");\n return left.concat(right);\n }\n\n concat(other: String): String {\n assert(this != null);\n\n if (other == null)\n other = changetype("null");\n\n var thisLen: isize = this.length;\n var otherLen: isize = other.length;\n var outLen: usize = thisLen + otherLen;\n if (outLen == 0)\n return EMPTY;\n\n var out = allocate(outLen);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD,\n thisLen << 1\n );\n move_memory(\n changetype(out) + HEAD + (thisLen << 1),\n changetype(other) + HEAD,\n otherLen << 1\n );\n return out;\n }\n\n endsWith(searchString: String, endPosition: i32 = 0x7fffffff): bool {\n assert(this != null);\n\n if (searchString == null)\n return false;\n\n var end: isize = min(max(endPosition, 0), this.length);\n var searchLength: isize = searchString.length;\n var start: isize = end - searchLength;\n if (start < 0)\n return false;\n\n return !compare_memory(\n changetype(this) + HEAD + (start << 1),\n changetype(searchString) + HEAD,\n searchLength << 1\n );\n }\n\n @operator("==")\n private static __eq(left: String, right: String): bool {\n if (left == null)\n return right == null;\n else if (right == null)\n return false;\n\n var leftLength = left.length;\n if (leftLength != right.length)\n return false;\n\n return !compare_memory(\n changetype(left) + HEAD,\n changetype(right) + HEAD,\n (leftLength << 1)\n );\n }\n\n includes(searchString: String, position: i32 = 0): bool {\n return this.indexOf(searchString, position) != -1;\n }\n\n indexOf(searchString: String, position: i32 = 0): i32 {\n assert(this != null);\n\n if (searchString == null)\n searchString = changetype("null");\n\n var pos: isize = position;\n var len: isize = this.length;\n var start: isize = min(max(pos, 0), len);\n var searchLen: isize = searchString.length;\n\n // TODO: two-way, multiple char codes\n for (var k: usize = start; k + searchLen <= len; ++k)\n if (!compare_memory(\n changetype(this) + HEAD + (k << 1),\n changetype(searchString) + HEAD,\n searchLen << 1)\n )\n return k;\n return -1;\n }\n\n startsWith(searchString: String, position: i32 = 0): bool {\n assert(this != null);\n\n if (searchString == null)\n searchString = changetype("null");\n\n var pos: isize = position;\n var len: isize = this.length;\n var start: isize = min(max(position, 0), len);\n var searchLength: isize = searchString.length;\n if (searchLength + start > len)\n return false;\n\n return !compare_memory(\n changetype(this) + HEAD + (start << 1),\n changetype(searchString) + HEAD,\n searchLength << 1\n );\n }\n\n substr(start: i32, length: i32 = i32.MAX_VALUE): String {\n assert(this != null);\n\n var intStart: isize = start;\n var end: isize = length;\n var size: isize = this.length;\n if (intStart < 0)\n intStart = max(size + intStart, 0);\n\n var resultLength: isize = min(max(end, 0), size - intStart);\n if (resultLength <= 0)\n return EMPTY;\n\n var out = allocate(resultLength);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD + (intStart << 1),\n resultLength << 1\n );\n return out;\n }\n\n substring(start: i32, end: i32 = i32.MAX_VALUE): String {\n assert(this != null);\n\n var len = this.length;\n var finalStart = min(max(start, 0), len);\n var finalEnd = min(max(end, 0), len);\n var from = min(finalStart, finalEnd);\n var to = max(finalStart, finalEnd);\n len = to - from;\n if (!len)\n return EMPTY;\n\n if (!from && to == this.length)\n return this;\n\n var out = allocate(len);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD + (from << 1),\n len << 1\n );\n return out;\n }\n\n trim(): String {\n assert(this != null);\n\n var length: usize = this.length;\n while (length && isWhiteSpaceOrLineTerminator(load(changetype(this) + (length << 1), HEAD)))\n --length;\n\n var start: usize = 0;\n while (start < length && isWhiteSpaceOrLineTerminator(load(changetype(this) + (start << 1), HEAD)))\n ++start, --length;\n\n if (!length)\n return EMPTY;\n\n if (!start && length == this.length)\n return this;\n\n var out = allocate(length);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD + (start << 1),\n length << 1\n );\n return out;\n }\n\n trimLeft(): String {\n assert(this != null);\n\n var start: isize = 0;\n var len: isize = this.length;\n while (start < len && isWhiteSpaceOrLineTerminator(load(changetype(this) + (start << 1), HEAD)))\n ++start;\n\n if (!start)\n return this;\n\n var outLen = len - start;\n if (!outLen)\n return EMPTY;\n\n var out = allocate(outLen);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD + (start << 1),\n outLen << 1\n );\n return out;\n }\n\n trimRight(): String {\n assert(this != null);\n\n var len: isize = this.length;\n while (len > 0 && isWhiteSpaceOrLineTerminator(load(changetype(this) + (len << 1), HEAD)))\n --len;\n\n if (len <= 0)\n return EMPTY;\n\n if (len == this.length)\n return this;\n\n var out = allocate(len);\n move_memory(\n changetype(out) + HEAD,\n changetype(this) + HEAD,\n len << 1\n );\n return out;\n }\n}\n\nfunction isWhiteSpaceOrLineTerminator(c: u16): bool {\n switch (c) {\n\n case 10: // \n case 13: // \n case 8232: // \n case 8233: // \n\n case 9: // \n case 11: // \n case 12: // \n case 32: // \n case 160: // \n case 65279: // \n\n return true;\n default:\n return false;\n }\n}\n\nconst 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 O = 0x4F,\n X = 0x58,\n Z = 0x5a,\n a = 0x61,\n b = 0x62,\n e = 0x65,\n o = 0x6F,\n x = 0x78,\n z = 0x7A\n}\n\nexport function parseInt(str: String, radix: i32 = 0): f64 {\n return parse(str, radix);\n}\n\nexport function parseI32(str: String, radix: i32 = 0): i32 {\n return parse(str, radix);\n}\n\nexport function parseI64(str: String, radix: i32 = 0): i64 {\n return parse(str, radix);\n}\n\nfunction parse(str: String, radix: i32 = 0): T {\n var len: i32 = str.length;\n if (!len)\n return NaN;\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr, HEAD);\n\n // determine sign\n var sign: T;\n if (code == CharCode.MINUS) {\n if (!--len)\n return NaN;\n code = load(ptr += 2, HEAD);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len)\n return NaN;\n code = load(ptr += 2, HEAD);\n sign = 1;\n } else\n sign = 1;\n\n // determine radix\n if (!radix) {\n if (code == CharCode._0 && len > 2) {\n switch (load(ptr + 2, HEAD)) {\n\n case CharCode.B:\n case CharCode.b:\n ptr += 4; len -= 2;\n radix = 2;\n break;\n\n case CharCode.O:\n case CharCode.o:\n ptr += 4; len -= 2;\n radix = 8;\n break;\n\n case CharCode.X:\n case CharCode.x:\n ptr += 4; len -= 2;\n radix = 16;\n break;\n\n default:\n radix = 10;\n }\n } else radix = 10;\n } else if (radix < 2 || radix > 36)\n return NaN;\n\n // calculate value\n var num: T = 0;\n while (len--) {\n code = load(ptr, HEAD);\n if (code >= CharCode._0 && code <= CharCode._9)\n code -= CharCode._0;\n else if (code >= CharCode.A && code <= CharCode.Z)\n code -= CharCode.A - 10;\n else if (code >= CharCode.a && code <= CharCode.z)\n code -= CharCode.a - 10;\n else\n break;\n if (code >= radix)\n break;\n num = (num * radix) + code;\n ptr += 2;\n }\n return sign * num;\n}\n\nexport function parseFloat(str: String): f64 {\n var len: i32 = str.length;\n if (!len)\n return NaN;\n var ptr = changetype(str) /* + HEAD -> offset */;\n var code = load(ptr, HEAD);\n\n // determine sign\n var sign: f64;\n if (code == CharCode.MINUS) {\n if (!--len)\n return NaN;\n code = load(ptr += 2, HEAD);\n sign = -1;\n } else if (code == CharCode.PLUS) {\n if (!--len)\n return NaN;\n code = load(ptr += 2, HEAD);\n sign = 1;\n } else\n sign = 1;\n\n // calculate value\n var num: f64 = 0;\n while (len--) {\n code = load(ptr, HEAD);\n if (code == CharCode.DOT) {\n ptr += 2;\n var fac: f64 = 0.1; // precision :(\n while (len--) {\n code = load(ptr, HEAD);\n if (code == CharCode.E || code == CharCode.e)\n assert(false); // TODO\n code -= CharCode._0;\n if (code > 9)\n break;\n num += code * fac;\n fac *= 0.1;\n ptr += 2;\n }\n break;\n }\n code -= CharCode._0;\n if (code >= 10)\n break;\n num = (num * 10) + code;\n ptr += 2;\n }\n return sign * num;\n}\n'},z=t.definitionFiles={assembly:'// Definitions for the "AssemblyScript" subset.\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 = any; // sic\n/** A 32-bit float. */\ndeclare type f32 = number;\n/** A 64-bit float. */\ndeclare type f64 = number;\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i8;\ndeclare namespace i8 {\n export const MIN_VALUE: i8;\n export const MAX_VALUE: i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i8;\ndeclare namespace i16 {\n export const MIN_VALUE: i16;\n export const MAX_VALUE: i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i32;\ndeclare namespace i32 {\n export const MIN_VALUE: i32;\n export const MAX_VALUE: i32;\n}\n/** Converts any other numeric value to a 64-bit signed integer. */\ndeclare function i64(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i64;\ndeclare namespace i64 {\n export const MIN_VALUE: i64;\n export const MAX_VALUE: i64;\n}\n/** Converts any other numeric value to a 32-bit (in WASM32) respectivel 64-bit (in WASM64) signed integer. */\ndeclare function isize(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): isize;\ndeclare namespace isize {\n export const MIN_VALUE: isize;\n export const MAX_VALUE: isize;\n}\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i8;\ndeclare namespace u8 {\n export const MIN_VALUE: u8;\n export const MAX_VALUE: u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i8;\ndeclare namespace u16 {\n export const MIN_VALUE: u16;\n export const MAX_VALUE: u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i32;\ndeclare namespace u32 {\n export const MIN_VALUE: u32;\n export const MAX_VALUE: u32;\n}\n/** Converts any other numeric value to a 64-bit unsigned integer. */\ndeclare function u64(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): i64;\ndeclare namespace u64 {\n export const MIN_VALUE: u64;\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 function usize(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): isize;\ndeclare namespace usize {\n export const MIN_VALUE: usize;\n export const MAX_VALUE: usize;\n}\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): bool;\ndeclare namespace bool {\n export const MIN_VALUE: bool;\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): f32;\ndeclare namespace f32 {\n export const MIN_VALUE: f32;\n export const MAX_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}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): f64;\ndeclare namespace f64 {\n export const MIN_VALUE: f64;\n export const MAX_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}\n\n// Built-ins\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, constantOffset?: usize): any;\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, constantOffset?: usize): void;\n/** Returns the current memory size in units of pages. One page is 64kb. */\ndeclare function current_memory(): 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. */\ndeclare function grow_memory(value: i32): i32;\n/** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\ndeclare function move_memory(destination: usize, source: usize, n: usize): void;\n/** Sets n bytes beginning at the specified destination in memory to the specified byte value. */\ndeclare function set_memory(destination: usize, value: u8, count: usize): void;\n/** Compares two chunks of memory. Returns `0` if equal, otherwise the difference of the first differing bytes. */\ndeclare function compare_memory(vl: usize, vr: usize, n: usize): i32;\n/** Allocates a chunk of memory of the specified size and returns a pointer to it. */\ndeclare function allocate_memory(size: usize): usize;\n/** Disposes a chunk of memory by its pointer. */\ndeclare function free_memory(ptr: 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 core or class type. Compiles to a constant. */\ndeclare function sizeof(): usize;\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/** 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/** Traps if the specified value is not true-ish, otherwise returns the (non-nullable) value. */\ndeclare function assert(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses an integer string to a 64-bit integer. */\ndeclare function parseI64(str: string, radix?: i32): i64;\n/** Parses a string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n\n// Standard library (not yet implemented)\n\n/** Class representing a sequence of values of type `T`. */\ndeclare class Array {\n [key: number]: T;\n /** Current length of the array. */\n length: i32;\n /** Constructs a new array. */\n constructor(capacity?: i32);\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): void;\n pop(): T;\n shift(): T;\n unshift(element: T): i32;\n slice(from: i32, to?: i32): T[];\n splice(start: i32, deleteCount?: i32): void;\n reverse(): T[];\n}\n\n/** Class representing a C-like array of values of type `T` with limited capabilities. */\ndeclare class CArray {\n [key: number]: T;\n private constructor();\n}\n\n/** Class representing a sequence of characters. */\ndeclare class String {\n\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(cp: i32): string;\n static fromCodePoints(arr: i32[]): string;\n\n readonly length: u32;\n\n charAt(index: u32): string;\n charCodeAt(index: u32): u16;\n concat(other: string): string;\n endsWith(other: string): bool;\n indexOf(other: string): u32;\n includes(other: string): bool;\n startsWith(other: string): bool;\n substr(start: u32, length?: u32): string;\n substring(start: u32, end?: u32): string;\n trim(): string;\n trimLeft(): string;\n trimRight(): string;\n}\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\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\ninterface Boolean {}\ninterface Function {}\ninterface IArguments {}\ninterface Number {}\ninterface Object {}\ninterface RegExp {}\n\ndeclare class Set {\n readonly size: i32;\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n}\n\n// Internal decorators\n\n/** Annotates an element as a program global. */\ndeclare function global(target: Function): any;\n\n/** Annotates a method as an operator overload. */\ndeclare function operator(token: string): any;\n\n/** Annotates a class as being unmanaged with limited capabilities. */\ndeclare function unmanaged(target: Function): any;\n\n/** Annotates a class field with an explicit offset. */\ndeclare function offset(offset: usize): any;\n\n/** Annotates an element as begin built-in. */\ndeclare function builtin(target: Function): any;\n',portable:'// Definitions for the "portable AssemblyScript" subset.\n\n// Portable types\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 value\n// of 2^53-1) and instead require a compatibility layer to work in JS as well. See: src/util/i64.ts\n\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 bool = boolean;\ndeclare type usize = number;\ndeclare type f32 = number;\ndeclare type f64 = number;\n\n/** Converts any other numeric value to an 8-bit signed integer. */\ndeclare function i8(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i8;\ndeclare namespace i8 {\n export const MIN_VALUE: i8;\n export const MAX_VALUE: i8;\n}\n/** Converts any other numeric value to a 16-bit signed integer. */\ndeclare function i16(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i8;\ndeclare namespace i16 {\n export const MIN_VALUE: i16;\n export const MAX_VALUE: i16;\n}\n/** Converts any other numeric value to a 32-bit signed integer. */\ndeclare function i32(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i32;\ndeclare namespace i32 {\n export const MIN_VALUE: i32;\n export const MAX_VALUE: 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: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): isize;\ndeclare namespace isize {\n export const MIN_VALUE: isize;\n export const MAX_VALUE: isize;\n}\n/** Converts any other numeric value to an 8-bit unsigned integer. */\ndeclare function u8(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i8;\ndeclare namespace u8 {\n export const MIN_VALUE: u8;\n export const MAX_VALUE: u8;\n}\n/** Converts any other numeric value to a 16-bit unsigned integer. */\ndeclare function u16(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i8;\ndeclare namespace u16 {\n export const MIN_VALUE: u16;\n export const MAX_VALUE: u16;\n}\n/** Converts any other numeric value to a 32-bit unsigned integer. */\ndeclare function u32(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): i32;\ndeclare namespace u32 {\n export const MIN_VALUE: u32;\n export const MAX_VALUE: 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: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): isize;\ndeclare namespace usize {\n export const MIN_VALUE: usize;\n export const MAX_VALUE: usize;\n}\n/** Converts any other numeric value to a 1-bit unsigned integer. */\ndeclare function bool(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): bool;\ndeclare namespace bool {\n export const MIN_VALUE: bool;\n export const MAX_VALUE: bool;\n}\n/** Converts any other numeric value to a 32-bit float. */\ndeclare function f32(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): f32;\ndeclare namespace 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}\n/** Converts any other numeric value to a 64-bit float. */\ndeclare function f64(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): f64;\ndeclare namespace 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}\n\n// Portable built-ins\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/** 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/** Performs the floor operation on a 32-bit or 64-bit float. */\ndeclare function floor(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/** Allocates a chunk of memory of the specified size and returns a pointer to it. */\ndeclare function allocate_memory(size: usize): usize;\n/** Disposes a chunk of memory by its pointer. */\ndeclare function free_memory(ptr: usize): void;\n/** Copies n bytes from the specified source to the specified destination in memory. These regions may overlap. */\ndeclare function move_memory(destination: usize, source: usize, n: usize): void;\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/** Traps if the specified value is not true-ish, otherwise returns the value. */\ndeclare function assert(isTrueish: T, message?: string): T & object; // any better way to model `: T != null`?\n/** Parses an integer string to a 64-bit float. */\ndeclare function parseInt(str: string, radix?: i32): f64;\n/** Parses an integer string to a 32-bit integer. */\ndeclare function parseI32(str: string, radix?: i32): i32;\n/** Parses a floating point string to a 64-bit float. */\ndeclare function parseFloat(str: string): f64;\n\n// Portable standard library\n// Everything marked @deprecated is a temporary filler. Do not use.\n\ndeclare const NaN: f32 | f64;\ndeclare const Infinity: f32 | f64;\n\ndeclare class Array {\n [key: number]: T;\n length: i32;\n constructor(capacity?: i32);\n indexOf(searchElement: T, fromIndex?: i32): i32;\n lastIndexOf(searchElement: T, fromIndex?: i32): i32;\n push(element: T): void;\n pop(): T;\n shift(): T;\n unshift(element: T): i32;\n slice(from: i32, to?: i32): T[];\n splice(start: i32, deleteCount?: i32): void;\n reverse(): T[];\n\n join(delim: string): string;\n}\n\ndeclare class Uint8Array extends Array {}\ndeclare class Uint16Array extends Array {}\ndeclare class Uint32Array extends Array {}\ndeclare class Int8Array extends Array {}\ndeclare class Int16Array extends Array {}\ndeclare class Int32Array extends Array {}\ndeclare class Float32Array extends Array {}\ndeclare class Float64Array extends Array {}\n\ndeclare class String {\n static fromCharCode(ls: i32, hs?: i32): string;\n static fromCharCodes(arr: u16[]): string;\n static fromCodePoint(cp: i32): string;\n static fromCodePoints(arr: i32[]): string;\n readonly length: i32;\n private constructor();\n indexOf(subject: string): i32;\n includes(other: string): bool;\n lastIndexOf(subject: string): i32;\n charAt(index: i32): string;\n charCodeAt(index: i32): i32;\n substring(from: i32, to?: i32): string;\n startsWith(subject: string): bool;\n endsWith(subject: string): bool;\n replace(search: string, replacement: string): string;\n toString(): string;\n}\n\ninterface Boolean {}\n\ndeclare class Number {\n private constructor();\n toString(radix?: i32): string;\n}\n\ninterface Object {}\n\ninterface Function {}\n\ninterface RegExp {}\n\ninterface IArguments {}\n\ndeclare class Error {\n constructor(message: string);\n message: string;\n stack: string | null;\n}\n\ndeclare class Symbol {\n private constructor();\n static readonly iterator: symbol;\n}\n\ndeclare class Set {\n constructor(entries?: T[]);\n has(value: T): bool;\n add(value: T): void;\n delete(value: T): bool;\n clear(): void;\n [Symbol.iterator](): Iterator;\n}\n\ndeclare class Map {\n constructor(entries?: [K, V][]);\n readonly size: i32;\n set(key: K, value: V): void;\n has(key: K): bool;\n get(key: K): V | null;\n clear(): void;\n entries(): Iterable<[K, V]>;\n keys(): Iterable;\n values(): Iterable;\n [Symbol.iterator](): Iterator<[K,V]>;\n}\n\ninterface Iterable {\n [Symbol.iterator](): Iterator;\n}\n\ninterface Iterator {}\n\ndeclare namespace console {\n /** @deprecated */\n function log(message: string): void;\n}\n'};t.main=n,t.parseArguments=s,t.checkDiagnostics=o,t.createStats=a,e.hrtime||(e.hrtime=i(15)),t.measure=l,t.printStats=u,t.createMemoryStream=function(e){var t=[];return t.write=function(t){'string'==typeof t?this.push(r.from(t,'utf8')):this.push(t),e&&e(t)},t.toBuffer=function(){return r.concat(this)},t.toString=function(){return this.toBuffer().toString('utf8')},t},t.tscOptions={alwaysStrict:!0,noImplicitAny:!0,noImplicitReturns:!0,noImplicitThis:!0,noEmitOnError:!0,strictNullChecks:!0,experimentalDecorators:!0,target:'esnext',module:'commonjs',noLib:!0,types:[],allowJs:!1}}).call(t,i(0),i(5).Buffer)},function(e,t,i){'use strict';(function(e){function o(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()e)throw new RangeError('"size" argument must not be negative')}function d(e,t,i,r){return c(t),0>=t?a(e,t):void 0===i?a(e,t):'string'==typeof r?a(e,t).fill(i,r):a(e,t).fill(i)}function f(e,t){if(c(t),e=a(e,0>t?0:0|y(t)),!l.TYPED_ARRAY_SUPPORT)for(var r=0;rt.length?0:0|y(t.length);e=a(e,r);for(var n=0;ni||t.byteLength=o())throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x'+o().toString(16)+' bytes');return 0|e}function b(e,t){if(l.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var i=e.length;if(0===i)return 0;for(var r=!1;;)switch(t){case'ascii':case'latin1':case'binary':return i;case'utf8':case'utf-8':case void 0:return W(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*i;case'hex':return i>>>1;case'base64':return K(e).length;default:if(r)return W(e).length;t=(''+t).toLowerCase(),r=!0;}}function _(e,t,i){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return'';if((void 0===i||i>this.length)&&(i=this.length),0>=i)return'';if(i>>>=0,t>>>=0,i<=t)return'';for(e||(e='utf8');;)switch(e){case'hex':return M(this,t,i);case'utf8':case'utf-8':return I(this,t,i);case'ascii':return N(this,t,i);case'latin1':case'binary':return P(this,t,i);case'base64':return C(this,t,i);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return U(this,t,i);default:if(r)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),r=!0;}}function v(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function T(e,t,i,r,n){if(0===e.length)return-1;if('string'==typeof i?(r=i,i=0):2147483647i&&(i=-2147483648),i=+i,isNaN(i)&&(i=n?0:e.length-1),0>i&&(i=e.length+i),i>=e.length){if(n)return-1;i=e.length-1}else if(0>i)if(n)i=0;else return-1;if('string'==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:x(e,t,i,r,n);if('number'==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):x(e,[t],i,r,n);throw new TypeError('val must be string, number or Buffer')}function x(e,t,r,n,s){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var a=1,l=e.length,u=t.length;if(void 0!==n&&(n=(n+'').toLowerCase(),'ucs2'===n||'ucs-2'===n||'utf16le'===n||'utf-16le'===n)){if(2>e.length||2>t.length)return-1;a=2,l/=2,u/=2,r/=2}var c;if(s){var i=-1;for(c=r;cl&&(r=l-u),c=r;0<=c;c--){for(var d=!0,f=0;fs&&(n=s)):n=s;var o=t.length;if(0!=o%2)throw new TypeError('Invalid hex string');n>o/2&&(n=o/2);for(var a,l=0;li&&(a=i):2==l?(u=e[o+1],128==(192&u)&&(f=(31&i)<<6|63&u,127f||57343f&&(a=f))):void 0}null===a?(a=65533,l=1):65535>>10),a=56320|1023&a),n.push(a),o+=l}return k(n)}function k(e){var t=e.length;if(t<=ie)return Q.apply(String,e);for(var r='',n=0;nt)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var s='',o=t;oe)throw new RangeError('offset is not uint');if(e+t>i)throw new RangeError('Trying to access beyond buffer length')}function D(e,t,i,r,n,s){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||te.length)throw new RangeError('Index out of range')}function F(e,t,r,n){0>t&&(t=65535+t+1);for(var o=0,i=s(e.length-r,2);o>>8*(n?o:1-o)}function R(e,t,r,n){0>t&&(t=4294967295+t+1);for(var o=0,i=s(e.length-r,4);o>>8*(n?o:3-o)}function V(e,t,i,r){if(i+r>e.length)throw new RangeError('Index out of range');if(0>i)throw new RangeError('Index out of range')}function B(e,t,i,r,n){return n||V(e,t,i,4,34028234663852886e22,-34028234663852886e22),ee.write(e,t,i,r,23,4),i+4}function j(e,t,i,r,n){return n||V(e,t,i,8,17976931348623157e292,-17976931348623157e292),ee.write(e,t,i,r,52,8),i+8}function H(e){if(e=Y(e).replace(re,''),2>e.length)return'';for(;0!=e.length%4;)e+='=';return e}function Y(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function X(e){return 16>e?'0'+e.toString(16):e.toString(16)}function W(e,t){t=t||Infinity;for(var r,n=e.length,s=null,o=[],a=0;ar){if(!s){if(56319r){-1<(t-=3)&&o.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&-1<(t-=3)&&o.push(239,191,189);if(s=null,128>r){if(0>(t-=1))break;o.push(r)}else if(2048>r){if(0>(t-=2))break;o.push(192|r>>6,128|63&r)}else if(65536>r){if(0>(t-=3))break;o.push(224|r>>12,128|63&r>>6,128|63&r)}else if(1114112>r){if(0>(t-=4))break;o.push(240|r>>18,128|63&r>>12,128|63&r>>6,128|63&r)}else throw new Error('Invalid code point')}return o}function G(e){for(var t=[],r=0;r(t-=2));++a)r=e.charCodeAt(a),n=r>>8,s=r%256,o.push(s),o.push(n);return o}function K(e){return $.toByteArray(H(e))}function J(e,t,r,n){for(var s=0;s=t.length||s>=e.length);++s)t[s+r]=e[s];return s}function Z(e){return e!==e}var Q=String.fromCharCode,$=i(6),ee=i(7),te=i(8);/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh diff --git a/package-lock.json b/package-lock.json index cfae0c33..371d41de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,9 @@ "integrity": "sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==" }, "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.4.1.tgz", + "integrity": "sha512-XLmq3H/BVvW6/GbxKryGxWORz1ebilSsUDlyC27bXhWGWAZWkGwS6FLHjOlwFXNFoWFQEO/Df4u0YYd0K3BQgQ==", "dev": true }, "acorn-dynamic-import": { @@ -27,24 +27,31 @@ "dev": true, "requires": { "acorn": "4.0.13" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + } } }, "ajv": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.1.tgz", - "integrity": "sha1-s4u4h22ehr7plJVqBOch6IskjrI=", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.1.1.tgz", + "integrity": "sha1-l41Zf7wrfQ5aXD3esUmmgvKr+g4=", "dev": true, "requires": { - "co": "4.6.0", "fast-deep-equal": "1.0.0", "fast-json-stable-stringify": "2.0.0", "json-schema-traverse": "0.3.1" } }, "ajv-keywords": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", - "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.1.0.tgz", + "integrity": "sha1-rCsnk5xUPpXSwG5/f1wnvkqlQ74=", "dev": true }, "align-text": { @@ -737,7 +744,7 @@ "dev": true, "requires": { "bn.js": "4.11.8", - "randombytes": "2.0.5" + "randombytes": "2.0.6" } }, "browserify-sign": { @@ -764,6 +771,17 @@ "pako": "1.0.6" } }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "dev": true, + "requires": { + "base64-js": "1.2.1", + "ieee754": "1.1.8", + "isarray": "1.0.0" + } + }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -957,12 +975,6 @@ "wordwrap": "0.0.2" } }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -1067,7 +1079,7 @@ "cipher-base": "1.0.4", "inherits": "2.0.3", "ripemd160": "2.0.1", - "sha.js": "2.4.9" + "sha.js": "2.4.10" } }, "create-hmac": { @@ -1081,7 +1093,7 @@ "inherits": "2.0.3", "ripemd160": "2.0.1", "safe-buffer": "5.1.1", - "sha.js": "2.4.9" + "sha.js": "2.4.10" } }, "cross-spawn": { @@ -1110,7 +1122,7 @@ "inherits": "2.0.3", "pbkdf2": "3.0.14", "public-encrypt": "4.0.0", - "randombytes": "2.0.5", + "randombytes": "2.0.6", "randomfill": "1.0.3" } }, @@ -1120,7 +1132,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "date-now": { @@ -1191,13 +1203,13 @@ "requires": { "bn.js": "4.11.8", "miller-rabin": "4.0.1", - "randombytes": "2.0.5" + "randombytes": "2.0.6" } }, "domain-browser": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", - "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", "dev": true }, "elliptic": { @@ -1252,9 +1264,9 @@ } }, "es5-ext": { - "version": "0.10.37", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.37.tgz", - "integrity": "sha1-DudB0Ui4AGm6J9AgOTdWryV978M=", + "version": "0.10.38", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.38.tgz", + "integrity": "sha512-jCMyePo7AXbUESwbl8Qi01VSH2piY9s/a3rSU/5w/MlTIx8HPL1xn2InGN8ejt/xulcJgnTO7vqNtOAxzYd2Kg==", "dev": true, "requires": { "es6-iterator": "2.0.3", @@ -1268,7 +1280,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-symbol": "3.1.1" } }, @@ -1279,7 +1291,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-set": "0.1.5", "es6-symbol": "3.1.1", @@ -1293,7 +1305,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1", "event-emitter": "0.3.5" @@ -1306,7 +1318,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "es6-weak-map": { @@ -1316,7 +1328,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37", + "es5-ext": "0.10.38", "es6-iterator": "2.0.3", "es6-symbol": "3.1.1" } @@ -1373,7 +1385,7 @@ "dev": true, "requires": { "d": "1.0.0", - "es5-ext": "0.10.37" + "es5-ext": "0.10.38" } }, "events": { @@ -3081,7 +3093,7 @@ "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", "dev": true, "requires": { - "mimic-fn": "1.1.0" + "mimic-fn": "1.2.0" } }, "memory-fs": { @@ -3126,9 +3138,9 @@ } }, "mimic-fn": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", - "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", "dev": true }, "minimalistic-assert": { @@ -3256,7 +3268,7 @@ "console-browserify": "1.1.0", "constants-browserify": "1.0.0", "crypto-browserify": "3.12.0", - "domain-browser": "1.1.7", + "domain-browser": "1.2.0", "events": "1.1.1", "https-browserify": "1.0.0", "os-browserify": "0.3.0", @@ -3266,35 +3278,13 @@ "querystring-es3": "0.2.1", "readable-stream": "2.3.3", "stream-browserify": "2.0.1", - "stream-http": "2.7.2", + "stream-http": "2.8.0", "string_decoder": "1.0.3", - "timers-browserify": "2.0.4", + "timers-browserify": "2.0.6", "tty-browserify": "0.0.0", "url": "0.11.0", "util": "0.10.3", "vm-browserify": "0.0.4" - }, - "dependencies": { - "buffer": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", - "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", - "dev": true, - "requires": { - "base64-js": "1.2.1", - "ieee754": "1.1.8", - "isarray": "1.0.0" - } - }, - "timers-browserify": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.4.tgz", - "integrity": "sha512-uZYhyU3EX8O7HQP+J9fTVYwsq90Vr68xPEFo7yrVImIxYvHgukBEgOB/SgGoorWVTzGM/3Z+wUNnboA4M8jWrg==", - "dev": true, - "requires": { - "setimmediate": "1.0.5" - } - } } }, "normalize-package-data": { @@ -3486,10 +3476,13 @@ "dev": true }, "p-limit": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.1.0.tgz", - "integrity": "sha1-sH/y2aXYi+yAYDWJWiurZqJ5iLw=", - "dev": true + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz", + "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", + "dev": true, + "requires": { + "p-try": "1.0.0" + } }, "p-locate": { "version": "2.0.0", @@ -3497,9 +3490,15 @@ "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", "dev": true, "requires": { - "p-limit": "1.1.0" + "p-limit": "1.2.0" } }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, "pako": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", @@ -3599,7 +3598,7 @@ "create-hmac": "1.1.6", "ripemd160": "2.0.1", "safe-buffer": "5.1.1", - "sha.js": "2.4.9" + "sha.js": "2.4.10" } }, "pify": { @@ -3660,7 +3659,7 @@ "browserify-rsa": "4.0.1", "create-hash": "1.1.3", "parse-asn1": "5.1.0", - "randombytes": "2.0.5" + "randombytes": "2.0.6" } }, "punycode": { @@ -3723,9 +3722,9 @@ } }, "randombytes": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", - "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", + "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", "dev": true, "requires": { "safe-buffer": "5.1.1" @@ -3737,7 +3736,7 @@ "integrity": "sha512-YL6GrhrWoic0Eq8rXVbMptH7dAxCs0J+mh5Y0euNekPPYaxEmdVGim6GdoxoRzKW2yJoU8tueifS7mYxvcFDEQ==", "dev": true, "requires": { - "randombytes": "2.0.5", + "randombytes": "2.0.6", "safe-buffer": "5.1.1" } }, @@ -3938,9 +3937,9 @@ "dev": true }, "sha.js": { - "version": "2.4.9", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.9.tgz", - "integrity": "sha512-G8zektVqbiPHrylgew9Zg1VRB1L/DtXNUVAM6q4QLy8NE3qtHlFXTf8VLL4k1Yl6c7NMjtZUTdXV+X44nFaT6A==", + "version": "2.4.10", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.10.tgz", + "integrity": "sha512-vnwmrFDlOExK4Nm16J2KMWHLrp14lBrjxMxBJpu++EnsuBmpiYaM/MEs46Vxxm/4FvdP5yTwuCTO9it5FSjrqA==", "dev": true, "requires": { "inherits": "2.0.3", @@ -4278,9 +4277,9 @@ } }, "stream-http": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", - "integrity": "sha512-c0yTD2rbQzXtSsFSVhtpvY/vS6u066PcXOX9kBB3mSO76RiUQzL340uJkGBWnlBg4/HZzqiUXtaVA7wcRcJgEw==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.0.tgz", + "integrity": "sha512-sZOFxI/5xw058XIRHl4dU3dZ+TTOIGJR78Dvo0oEAejIt4ou27k+3ne1zYmCV+v7UucbxIFQuOgnkTVHh8YPnw==", "dev": true, "requires": { "builtin-status-codes": "3.0.0", @@ -4371,6 +4370,15 @@ "integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI=", "dev": true }, + "timers-browserify": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.6.tgz", + "integrity": "sha512-HQ3nbYRAowdVd0ckGFvmJPPCOH/CHleFN/Y0YQCX1DVaB7t+KFvisuyN09fuP8Jtp1CpfSh8O8bMkHbdbPe6Pw==", + "dev": true, + "requires": { + "setimmediate": "1.0.5" + } + }, "to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", @@ -4796,12 +4804,6 @@ "yargs": "3.10.0" }, "dependencies": { - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, "yargs": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", @@ -4832,14 +4834,6 @@ "source-map": "0.5.7", "uglify-js": "2.8.29", "webpack-sources": "1.1.0" - }, - "dependencies": { - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } } }, "union-value": { @@ -5094,15 +5088,15 @@ } }, "webpack": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-3.10.0.tgz", - "integrity": "sha512-fxxKXoicjdXNUMY7LIdY89tkJJJ0m1Oo8PQutZ5rLgWbV5QVKI15Cn7+/IHnRTd3vfKfiwBx6SBqlorAuNA8LA==", + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-3.11.0.tgz", + "integrity": "sha512-3kOFejWqj5ISpJk4Qj/V7w98h9Vl52wak3CLiw/cDOfbVTq7FeoZ0SdoHHY9PYlHr50ZS42OfvzE2vB4nncKQg==", "dev": true, "requires": { - "acorn": "5.2.1", + "acorn": "5.4.1", "acorn-dynamic-import": "2.0.2", - "ajv": "5.5.1", - "ajv-keywords": "2.1.1", + "ajv": "6.1.1", + "ajv-keywords": "3.1.0", "async": "2.6.0", "enhanced-resolve": "3.4.1", "escope": "3.6.0", @@ -5121,20 +5115,6 @@ "watchpack": "1.4.0", "webpack-sources": "1.1.0", "yargs": "8.0.2" - }, - "dependencies": { - "acorn": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz", - "integrity": "sha512-jG0u7c4Ly+3QkkW18V+NRDN+4bWHdln30NL1ZL2AvFZZmQe/BfopYCtghCKKVBUSetZ4QKcyA0pY6/4Gw8Pv8w==", - "dev": true - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } } }, "webpack-sources": { diff --git a/package.json b/package.json index b051982b..c234474a 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "ts-loader": "^3.5.0", "tslint": "^5.9.1", "typescript": "^2.7.1", - "webpack": "^3.10.0" + "webpack": "^3.11.0" }, "main": "index.js", "types": "index.d.ts", diff --git a/tests/compiler.js b/tests/compiler.js index ff4e1742..71f07711 100644 --- a/tests/compiler.js +++ b/tests/compiler.js @@ -69,12 +69,12 @@ tests.forEach(filename => { console.log(); if (err) stderr.write(err + os.EOL); + var actual = stdout.toString().replace(/\r\n/g, "\n"); if (args.create) { - fs.writeFileSync(path.join(basedir, basename + ".wast"), stdout.toString(), { encoding: "utf8" }); + fs.writeFileSync(path.join(basedir, basename + ".wast"), actual, { encoding: "utf8" }); console.log("- " + chalk.yellow("Created fixture")); } else { - let actual = stdout.toString(); - let expected = fs.readFileSync(path.join(basedir, basename + ".wast"), { encoding: "utf8" }); + let expected = fs.readFileSync(path.join(basedir, basename + ".wast"), { encoding: "utf8" }).replace(/\r\n/g, "\n"); let diffs = diff(basename + ".wast", expected, actual); if (diffs !== null) { console.log(diffs); diff --git a/tests/parser.js b/tests/parser.js index d388f404..9ed287e3 100644 --- a/tests/parser.js +++ b/tests/parser.js @@ -27,14 +27,14 @@ glob.sync(filter, { cwd: __dirname + "/parser" }).forEach(filename => { var sb = []; serializeSource(parser.program.sources[0], sb); - var actual = sb.join("") + parser.diagnostics.map(diagnostic => "// " + diagnostic + "\n").join("");; + var actual = sb.join("") + parser.diagnostics.map(diagnostic => "// " + diagnostic + "\n").join(""); var fixture = filename + ".fixture.ts"; if (isCreate) { fs.writeFileSync(__dirname + "/parser/" + fixture, actual, { encoding: "utf8" }); console.log("Created\n"); } else { - var expected = fs.readFileSync(__dirname + "/parser/" + fixture, { encoding: "utf8" }); + var expected = fs.readFileSync(__dirname + "/parser/" + fixture, { encoding: "utf8" }).replace(/\r\n/g, "\n"); var diffs = diff("parser/" + fixture, expected, actual); if (diffs !== null) { failed = true;