@permaweb/wasm-metering
Version:
injects metering into webassembly binaries
1 lines • 964 kB
JavaScript
var wasm={};wasm.ready=new Promise((function(resolve,reject){wasm.$resolve=resolve;wasm.$reject=reject}));var Module={};Module.onRuntimeInitialized=(function(){function loadi8(addr){return HEAP8[addr]}function loadi16(addr){return HEAP16[addr>>1]}function loadi32(addr){return HEAP32[addr>>2]}function loadu8(addr){return HEAPU8[addr]}function loadu16(addr){return HEAPU16[addr>>1]}function loadu32(addr){return HEAPU32[addr>>2]}function loadf32(addr){return HEAPF32[addr>>2]}function loadf64(addr){return HEAPF64[addr>>4]}function storei8(addr,value){HEAP8[addr]=value}function storei16(addr,value){HEAP16[addr>>1]=value}function storei32(addr,value){HEAP32[addr>>2]=value}function storeu8(addr,value){HEAPU8[addr]=value}function storeu16(addr,value){HEAPU16[addr>>1]=value}function storeu32(addr,value){HEAPU32[addr>>2]=value}function storef32(addr,value){HEAPF32[addr>>2]=value}function storef64(addr,value){HEAPF64[addr>>4]=value}function loadcstr(addr){return Module.AsciiToString(addr)}function loadstrslice(addr,len){return Module.Pointer_stringify(addr,len)}function loadbuffer(addr,len){return new Uint8Array(HEAPU8.buffer,addr,len)}function sizeof(structName){return Module["_wasm_sizeof_"+structName]()}function offsetof(structName,fieldName){return Module["_wasm_offsetof_"+structName+"_"+fieldName]()}function malloc(size){var addr=Module._malloc(size);if(addr==0){throw new Error("out of memory")}return addr}function mallocz(size){var addr=malloc(size);HEAPU8.fill(0,addr,addr+size);return addr}function free(addr){Module._free(addr)}function Type(name,id){this.name=name;if(id){this.id=id}else{this.id=Type.id++;Type.map[this.id]=this}}Type.id=0;Type.map={};Type.check=(function(expected,actual){if(actual.id!=expected.id){throw new Error("type mismatch; expected "+expected.toString()+", got "+actual.toString())}});Type.prototype=Object.create(Object.prototype);Type.prototype.toString=(function(name,lastPrec){var result="";if(this.name){result=this.name;if(name){result+=" "+name}return result}name=name||"";var prec=this.prec;if(prec&&lastPrec&&prec>lastPrec){name="("+name+")"}if(this.kind=="ptr"){return this.pointee.toString("*"+result+name,prec)}else if(this.kind=="array"){return this.element.toString(result+"[]",prec)}else if(this.kind=="fn"){name+="(";if(this.params.length>0){var paramNames=[];for(var i=0;i<this.params.length;++i){paramNames.push(this.params[i].toString())}name+=paramNames.join(", ")}name+=")";return this.result.toString(name,prec)}else{throw new Error("unknown type kind")}});Type.prototype.load=(function(){throw new Error(this.toString()+" cannot be loaded")});Type.prototype.store=(function(){throw new Error(this.toString()+" cannot be stored")});Type.prototype.call=(function(){throw new Error(this.toString()+" cannot be called")});function PrimitiveType(name,size,sig,min,max){Type.call(this,name);this.size=size;this.sig=sig;this.min=min;this.max=max}PrimitiveType.prototype=Object.create(Type.prototype);PrimitiveType.prototype.kind="primitive";PrimitiveType.prototype.primitive=true;PrimitiveType.prototype.checkRange=(function(value){if(value<this.min||value>this.max){throw new Error("value out of range: "+value+" not in ["+this.min+","+this.max+"]")}});PrimitiveType.prototype.toJS=(function(value){return value});PrimitiveType.prototype.initAccessors=(function(value,addr){var type=this;value.load=(function(){return type.toJS(type.load(addr))});value.store=(function(value){type.store(addr,type.fromJS(value))})});var Void=new PrimitiveType("Void",0,"v");var Bool=new PrimitiveType("Bool",1,"i");var I8=new PrimitiveType("I8",1,"i",-128,127);var I16=new PrimitiveType("I16",2,"i",-32768,32767);var I32=new PrimitiveType("I32",4,"i",-2147483648,2147483647);var U8=new PrimitiveType("U8",1,"i",0,255);var U16=new PrimitiveType("U16",2,"i",0,65535);var U32=new PrimitiveType("U32",4,"i",0,4294967295);var U64=new PrimitiveType("U64",8,"i");var F32=new PrimitiveType("F32",4,"f");var F64=new PrimitiveType("F64",8,"d");Void.fromJS=(function(value){});Bool.fromJS=(function(value){return!!value});I8.fromJS=(function(value){this.checkRange(value);return value|0});I16.fromJS=(function(value){this.checkRange(value);return value|0});I32.fromJS=(function(value){this.checkRange(value);return value|0});U8.fromJS=(function(value){this.checkRange(value);return value>>>0});U16.fromJS=(function(value){this.checkRange(value);return value>>>0});U32.fromJS=(function(value){this.checkRange(value);return value>>>0});U64.fromJS=(function(value){throw new Error("u64 not yet supported")});F32.fromJS=(function(value){return Math.fround(value)});F64.fromJS=(function(value){return+value});Bool.toJS=(function(value){return value?true:false});Bool.load=(function(addr){return loadu8(addr)});I8.load=(function(addr){return loadi8(addr)});I16.load=(function(addr){return loadi16(addr)});I32.load=(function(addr){return loadi32(addr)});U8.load=(function(addr){return loadu8(addr)});U16.load=(function(addr){return loadu16(addr)});U32.load=(function(addr){return loadu32(addr)});U64.load=(function(addr){throw new Error("u64 not yet supported")});F32.load=(function(addr){return loadf32(addr)});F64.load=(function(addr){return loadf64(addr)});Bool.store=(function(addr,value){return storeu8(addr,value)});I8.store=(function(addr,value){return storei8(addr,value)});I16.store=(function(addr,value){return storei16(addr,value)});I32.store=(function(addr,value){return storei32(addr,value)});U8.store=(function(addr,value){return storeu8(addr,value)});U16.store=(function(addr,value){return storeu16(addr,value)});U32.store=(function(addr,value){return storeu32(addr,value)});U64.store=(function(addr,value){throw new Error("u64 not yet supported")});F32.store=(function(addr,value){return storef32(addr,value)});F64.store=(function(addr,value){return storef64(addr,value)});function Alias(name,type){var alias=Object.create(type);alias.name=name;return alias}function PtrType(type){Type.call(this);this.pointee=type}PtrType.map={};PtrType.prototype=Object.create(Type.prototype);PtrType.prototype.kind="ptr";PtrType.prototype.prec=1;PtrType.prototype.primitive=true;PtrType.prototype.sig="i";PtrType.prototype.size=4;PtrType.prototype.fromJS=(function(value){if(value===null){return 0}Value.$check(value);Type.check(this,value.$ptrType);return value.$addr});PtrType.prototype.toJS=(function(value){if(value==0){return null}return new Value(this.pointee,value)});PtrType.prototype.initAccessors=(function(value,addr){var type=this;value.load=(function(){return type.toJS(loadu32(addr))});value.store=(function(value){storeu32(addr,type.fromJS(value))})});function Ptr(type){if(type.id in PtrType.map){return PtrType.map[type.id]}var result=new PtrType(type);PtrType.map[type.id]=result;return result}var VoidPtr=Ptr(Void);var ArrayLen=Alias("ArrayLen",U32);var BufLen=Alias("BufLen",U32);var BufPtr=Alias("BufPtr",VoidPtr);var Str=Alias("Str",Ptr(U8));var StrLen=Alias("StrLen",U32);var StrPtr=Alias("StrPtr",Ptr(U8));var UserData=Alias("UserData",VoidPtr);Str.toJS=(function(addr){return loadcstr(addr)});Str.initAccessors=(function(value,addr){value.load=(function(){return loadcstr(loadu32(addr))})});function ArrayType(type){Type.call(this);this.element=type}ArrayType.map={};ArrayType.prototype=Object.create(Type.prototype);ArrayType.prototype.kind="ptr";ArrayType.prototype.prec=2;ArrayType.prototype.primitive=true;ArrayType.prototype.sig="i";ArrayType.prototype.size=4;ArrayType.prototype.initAccessors=(function(value,arrayAddr){var type=this;value.index=(function(index){return new Value(type.element,arrayAddr+index*type.element.size)})});function FnType(result,params){if(!result.primitive){throw new Error(result.toString()+" is not a primitive type")}for(var i=0;i<params.length;++i){var param=params[i];if(!param.primitive){throw new Error(param.toString()+" is not a primitive type")}}Type.call(this);this.result=result;this.params=params;this.funcSig=this.generateSig()}FnType.generateKey=(function(result,params){var key=result.id+",";for(var i=0;i<params.length;++i){key+=params[i].id+","}return key});FnType.map={};FnType.prototype=Object.create(Type.prototype);FnType.prototype.kind="fn";FnType.prototype.prec=3;FnType.prototype.primitive=true;FnType.prototype.sig="i";FnType.prototype.size=4;FnType.prototype.generateSig=(function(){var result=this.result.sig;for(var i=0;i<this.params.length;++i){result+=this.params[i].sig}return result});FnType.prototype.argsFromJS=(function(inArgs){if(inArgs.length!=this.params.length){throw new Error("argument count mismatch: expecting "+this.params.length+", got "+inArgs.length)}var outArgs=[];for(var i=0;i<inArgs.length;++i){outArgs.push(this.params[i].fromJS(inArgs[i]))}return outArgs});FnType.prototype.argsToJS=(function(inArgs){var outArgs=[];for(var i=0;i<inArgs.length;++i){outArgs.push(this.params[i].toJS(inArgs[i]))}return outArgs});FnType.prototype.define=(function(name){var type=this;return(function(){var result=Module[name].apply(Module,type.argsFromJS(arguments));return type.result.toJS(result)})});FnType.prototype.initAccessors=(function(value,addr){var type=this;value.load=(function(){return new FnValue(type,loadu32(addr))});value.store=(function(value){if(!(value instanceof FnValue)){throw new Error("fn value "+value+" not instanceof FnValue")}Type.check(type,value.$type);return storeu32(addr,value.$index)});value.call=(function(){var result=Runtime.dynCall(type.funcSig,loadu32(addr),type.argsFromJS(arguments));return type.result.toJS(result)})});function Fn(result,params){var key=FnType.generateKey(result,params);if(key in FnType.map){return FnType.map[key]}var result=new FnType(result,params);FnType.map[key]=result;return result}function Field(name,type,offset){this.name=name;this.type=type;this.offset=offset}Field.prototype=Object.create(Object.prototype);Field.prototype.initAccessors=(function(value,structAddr){value[this.name]=new Value(this.type,structAddr+this.offset)});function StructType(name){Type.call(this,name);this.fields={}}StructType.prototype=Object.create(Type.prototype);StructType.prototype.kind="struct";StructType.prototype.primitive=false;StructType.prototype.define=(function(cName,fieldTypes){this.cName=cName;this.size=sizeof(cName);for(fieldName in fieldTypes){var type=fieldTypes[fieldName];var offset=offsetof(cName,fieldName);this.fields[fieldName]=new Field(fieldName,type,offset)}});StructType.prototype.describe=(function(){var result="struct "+this.name+" {\n";var lines=[];for(fieldName in this.fields){var field=this.fields[fieldName];lines.push(" "+field.type.toString(fieldName)+";")}result+=lines.join("\n");result+="\n};";return result});StructType.prototype.initAccessors=(function(value,addr){for(fieldName in this.fields){var field=this.fields[fieldName];field.initAccessors(value,addr)}});function Struct(name){return new StructType(name)}function Value(type,addr){this.$type=type;this.$ptrType=Ptr(type);this.$addr=addr;type.initAccessors(this,this.$addr)}Value.$at=(function(type,addr){return new Value(type,addr)});Value.$malloc=(function(type){return new Value(type,mallocz(type.size))});Value.$check=(function(value){if(!(value instanceof Value)){throw new Error("value "+value+" not instanceof Value")}});Value.prototype=Object.create(Object.prototype);Value.prototype.toString=(function(){return"<"+this.$type+">@"+this.$addr});Value.prototype.$free=(function(){free(this.$addr)});function FnValue(type,f){if(!(type instanceof FnType)){throw new Error("type "+type+" not instanceof FnType")}this.$type=type;if(typeof f=="function"){if(f.length!=type.params.length){throw new Error("argument count mismatch: expecting "+type.params.length+", got "+f.length)}var wrapped=(function(){return type.result.fromJS(f.apply(null,type.argsToJS(arguments)))});this.$index=Runtime.addFunction(wrapped);this.$owned=true}else{this.$index=f|0;this.$owned=false}}FnValue.prototype=Object.create(Object.prototype);FnValue.prototype.toString=(function(){return"<"+this.type+">@"+this.$index});FnValue.prototype.$destroy=(function(){if(this.$owned){Runtime.removeFunction(this.$index)}});function StrValue(addr){Value.call(this,Str.pointee,addr)}StrValue.$at=(function(addr){return new StrValue(addr)});StrValue.$mallocCStr=(function(s){var addr=malloc(s.length+1);Module.writeAsciiToMemory(s,addr);return new StrValue(addr)});StrValue.prototype=Object.create(Value.prototype);StrValue.prototype.toString=(function(){return"<Str>@"+this.$addr});function BufferValue(addr,size){Value.call(this,VoidPtr.pointee,addr);this.size=size}BufferValue.$malloc=(function(buf){var addr;var size;if(buf instanceof ArrayBuffer){size=buf.byteLength;addr=malloc(size);HEAPU8.set(new Uint8Array(buf),addr)}else if(ArrayBuffer.isView(buf)){size=buf.byteLength;addr=malloc(size);HEAPU8.set(new Uint8Array(buf.buffer,buf.byteOffset,buf.byteLength),addr)}else if(typeof buf=="string"){size=buf.length;addr=malloc(size);Module.writeAsciiToMemory(buf,addr,true)}else{throw new Error("unknown buffer type: "+buf)}return new BufferValue(addr,size)});BufferValue.prototype=Object.create(Value.prototype);BufferValue.prototype.toString=(function(){return"<Buffer>@"+this.$addr+", "+this.size+" bytes"});var OK=0;var I=(function(){var Allocator=Struct("Allocator");var AstLexer=Struct("AstLexer");var BinaryErrorHandler=Struct("BinaryErrorHandler");var Location=Struct("Location");var MemoryWriter=Struct("MemoryWriter");var OutputBuffer=Struct("OutputBuffer");var ReadBinaryOptions=Struct("ReadBinaryOptions");var Script=Struct("Script");var SourceErrorHandler=Struct("SourceErrorHandler");var StackAllocator=Struct("StackAllocator");var Stream=Struct("Stream");var StrSlice=Struct("StrSlice");var WriteBinaryOptions=Struct("WriteBinaryOptions");var Writer=Struct("Writer");var BinaryErrorHandlerCallback=Fn(Void,[U32,Str,UserData]);var SourceErrorHandlerCallback=Fn(Void,[Ptr(Location),Str,StrPtr,StrLen,U32,UserData]);Allocator.define("allocator",{alloc:Fn(VoidPtr,[Ptr(Allocator),U32,U32,Str,I32]),realloc:Fn(VoidPtr,[Ptr(Allocator),VoidPtr,U32,U32,Str,I32]),free:Fn(VoidPtr,[Ptr(Allocator),VoidPtr,Str,I32]),destroy:Fn(Void,[Ptr(Allocator)]),mark:Fn(I32,[Ptr(Allocator)]),reset_to_mark:Fn(Void,[Ptr(Allocator),I32]),print_stats:Fn(Void,[Ptr(Allocator)])});BinaryErrorHandler.define("binary_error_handler",{on_error:BinaryErrorHandlerCallback,user_data:UserData});Location.define("location",{filename:Str,line:U32,first_column:U32,last_column:U32});MemoryWriter.define("memory_writer",{base:Writer,buf:OutputBuffer});OutputBuffer.define("output_buffer",{allocator:Allocator,start:BufPtr,size:BufLen,capacity:U32});ReadBinaryOptions.define("read_binary_options",{read_debug_names:Bool});Script.define("script");SourceErrorHandler.define("source_error_handler",{on_error:SourceErrorHandlerCallback,source_line_max_length:U32,user_data:UserData});StackAllocator.define("stack_allocator",{allocator:Allocator});Stream.define("stream",{writer:Ptr(Writer),result:U32,offset:U32,log_stream:Ptr(Stream)});StrSlice.define("string_slice",{start:StrPtr,length:StrLen});WriteBinaryOptions.define("write_binary_options",{log_stream:Ptr(Stream),canonicalize_lebs:Bool,write_debug_names:Bool});Writer.define("writer",{write_data:Fn(I32,[U32,BufPtr,BufLen,UserData]),move_data:Fn(I32,[U32,U32,U32,UserData])});var checkAst=Fn(I32,[Ptr(Allocator),Ptr(AstLexer),Ptr(Script),Ptr(SourceErrorHandler)]).define("_wasm_check_ast");var closeMemWriter=Fn(Void,[Ptr(MemoryWriter)]).define("_wasm_close_mem_writer");var defaultBinaryErrorCallback=BinaryErrorHandlerCallback.define("_wasm_default_binary_error_callback");var defaultSourceErrorCallback=SourceErrorHandlerCallback.define("_wasm_default_source_error_callback");var destroyAstLexer=Fn(Void,[Ptr(AstLexer)]).define("_wasm_destroy_ast_lexer");var destroyOutputBuffer=Fn(Void,[Ptr(OutputBuffer)]).define("_wasm_destroy_output_buffer");var destroyScript=Fn(Void,[Ptr(Script)]).define("_wasm_destroy_script");var destroyStackAllocator=Fn(Void,[Ptr(StackAllocator)]).define("_wasm_destroy_stack_allocator");var getLibcAllocator=Fn(Ptr(Allocator),[]).define("_wasm_get_libc_allocator");var initMemWriter=Fn(I32,[Ptr(Allocator),Ptr(MemoryWriter)]).define("_wasm_init_mem_writer");var initStackAllocator=Fn(Void,[Ptr(StackAllocator),Ptr(Allocator)]).define("_wasm_init_stack_allocator");var initStream=Fn(Void,[Ptr(Stream),Ptr(Writer),Ptr(Stream)]).define("_wasm_init_stream");var newAstBufferLexer=Fn(Ptr(AstLexer),[Ptr(Allocator),Str,BufPtr,BufLen]).define("_wasm_new_ast_buffer_lexer");var parseAst=Fn(I32,[Ptr(AstLexer),Ptr(Script),Ptr(SourceErrorHandler)]).define("_wasm_parse_ast");var writeBinaryScript=Fn(I32,[Ptr(Allocator),Ptr(Writer),Ptr(Script),Ptr(WriteBinaryOptions)]).define("_wasm_write_binary_script");return{Allocator:Allocator,AstLexer:AstLexer,BinaryErrorHandler:BinaryErrorHandler,Location:Location,MemoryWriter:MemoryWriter,OutputBuffer:OutputBuffer,ReadBinaryOptions:ReadBinaryOptions,Script:Script,SourceErrorHandler:SourceErrorHandler,StackAllocator:StackAllocator,Stream:Stream,StrSlice:StrSlice,WriteBinaryOptions:WriteBinaryOptions,Writer:Writer,checkAst:checkAst,closeMemWriter:closeMemWriter,defaultBinaryErrorCallback:defaultBinaryErrorCallback,defaultSourceErrorCallback:defaultSourceErrorCallback,destroyAstLexer:destroyAstLexer,destroyOutputBuffer:destroyOutputBuffer,destroyScript:destroyScript,destroyStackAllocator:destroyStackAllocator,getLibcAllocator:getLibcAllocator,initMemWriter:initMemWriter,initStackAllocator:initStackAllocator,initStream:initStream,newAstBufferLexer:newAstBufferLexer,parseAst:parseAst,writeBinaryScript:writeBinaryScript}})();function define$From(obj){obj.$from=(function($){var o=Object.create(obj.prototype);o.$=$;return o})}function definePrimitiveGetter(proto,name,cName){cName=cName||name;Object.defineProperty(proto,name,{get:(function(){return this.$[cName].load()})})}function defineStrGetter(proto,name,cName){cName=cName||name;Object.defineProperty(proto,name,{get:(function(){return this.$[cName].load()})})}function defineStrSliceGetter(proto,name,ptrName,lenName){Object.defineProperty(proto,name,{get:(function(){var offset=this.$[ptrName].load();var length=this.$[lenName].load();return loadstrslice(offset.$addr,length)})})}function defineBufferGetter(proto,name,ptrName,lenName){Object.defineProperty(proto,name,{get:(function(){var offset=this.$[ptrName].load();var length=this.$[lenName].load();return loadbuffer(offset.$addr,length)})})}function Allocator(){this.$=null}define$From(Allocator);Allocator.prototype=Object.create(Object.prototype);function StackAllocator(fallbackAllocator){this.$=Value.$malloc(I.StackAllocator);I.initStackAllocator(this.$,fallbackAllocator.$);this.allocator=Allocator.$from(this.$.allocator)}StackAllocator.prototype=Object.create(Object.prototype);StackAllocator.prototype.$destroy=(function(){I.destroyStackAllocator(this.$);this.$.$free()});LibcAllocator=Allocator.$from(I.getLibcAllocator());function Writer(writeData,moveData){this.$=Value.$malloc(I.Writer);this.$writeData=new FnValue(I.Writer.fields.write_data.type,writeData);this.$moveData=new FnValue(I.Writer.fields.move_data.type,moveData);this.$.write_data.store(this.$writeData);this.$.move_data.store(this.$moveData)}define$From(Writer);Writer.prototype=Object.create(Object.prototype);Writer.prototype.$destroy=(function(){this.$moveData.$destroy();this.$writeData.$destroy();this.$.$free()});function MemoryWriter(allocator){this.$=Value.$malloc(I.MemoryWriter);var result=I.initMemWriter(allocator.$,this.$);if(result!=OK){throw new Error("unable to initialize MemoryWriter")}this.writer=Writer.$from(this.$.base);this.buf=OutputBuffer.$from(this.$.buf)}MemoryWriter.prototype=Object.create(MemoryWriter.prototype);MemoryWriter.prototype.$destroy=(function(){I.closeMemWriter(this.$);this.$.$free()});function OutputBuffer(){this.$=null}define$From(OutputBuffer);OutputBuffer.prototype=Object.create(Object.prototype);defineBufferGetter(OutputBuffer.prototype,"buf","start","size");defineStrSliceGetter(OutputBuffer.prototype,"bufStr","start","size");definePrimitiveGetter(OutputBuffer.prototype,"size");definePrimitiveGetter(OutputBuffer.prototype,"capacity");OutputBuffer.prototype.$destroy=(function(){I.destroyOutputBuffer(this.$);this.$.$free()});function Stream(writer,logStream){this.$=Value.$malloc(I.Stream);I.initStream(this.$,writer.$,logStream?logStream.$:null)}Stream.prototype=Object.create(Object.prototype);definePrimitiveGetter(Stream.prototype,"offset");definePrimitiveGetter(Stream.prototype,"result");Stream.prototype.$destroy=(function(){this.$.$free()});function StringStream(){this.$writer=new MemoryWriter(LibcAllocator);Stream.call(this,this.$writer.writer,null)}StringStream.prototype=Object.create(Object.prototype);Object.defineProperty(StringStream.prototype,"string",{get:(function(){return this.$writer.buf.bufStr})});StringStream.prototype.$destroy=(function(){Stream.prototype.$destroy.call(this);this.$writer.$destroy()});function parseAst(allocator,filename,buffer){var sourceLineMaxLength=80;var astLexer=new AstLexer(allocator,filename,buffer);var errorHandler=new SourceErrorHandler(sourceLineMaxLength);var script=new Script;var result=I.parseAst(astLexer.$,script.$,errorHandler.$);script.$allocator=allocator;script.$astLexer=astLexer;script.$errorHandler=errorHandler;if(result!=OK){script.$destroy();throw new Error("parseAst failed:\n"+errorHandler.errorMessage)}return script}function AstLexer(allocator,filename,buffer){this.$filename=StrValue.$mallocCStr(filename);this.$buffer=BufferValue.$malloc(buffer);this.$=I.newAstBufferLexer(allocator.$,this.$filename,this.$buffer,this.$buffer.size);if(this.$===null){this.$buffer.$free();this.$filename.$free();throw new Error("unable to create AstLexer")}}AstLexer.prototype=Object.create(Object.prototype);AstLexer.prototype.$destroy=(function(){I.destroyAstLexer(this.$);this.$.$free();this.$buffer.$free();this.$filename.$free()});function SourceErrorHandler(sourceLineMaxLength){this.$=Value.$malloc(I.SourceErrorHandler);var wrapper=(function(loc,error,sourceLine,sourceLineLength,sourceLineColumnOffset,userData){loc=Location.$from(loc);sourceLine=loadstrslice(sourceLine.$addr,sourceLineLength);var lines=[loc.filename+":"+loc.line+":"+loc.firstColumn,error];if(sourceLine.length>0){var numSpaces=loc.firstColumn-1-sourceLineColumnOffset;var numCarets=Math.min(loc.lastColumn-loc.firstColumn,sourceLine.length);lines.push(sourceLine);lines.push(" ".repeat(numSpaces)+"^".repeat(numCarets))}this.errorMessage+=lines.join("\n")+"\n"}).bind(this);this.$callback=new FnValue(I.SourceErrorHandler.fields.on_error.type,wrapper);this.$.on_error.store(this.$callback);this.$.source_line_max_length.store(sourceLineMaxLength);this.errorMessage=""}SourceErrorHandler.prototype=Object.create(Object.prototype);SourceErrorHandler.prototype.$destroy=(function(){this.$callback.$destroy();this.$.$free()});function Location(){this.$=null}define$From(Location);Location.prototype=Object.create(Object.prototype);defineStrGetter(Location.prototype,"filename");definePrimitiveGetter(Location.prototype,"line");definePrimitiveGetter(Location.prototype,"firstColumn","first_column");definePrimitiveGetter(Location.prototype,"lastColumn","last_column");Location.prototype.$destroy=(function(){this.$.$free()});function Script(){this.$=Value.$malloc(I.Script);this.$allocator=null;this.$astLexer=null;this.$errorHandler=null}Script.prototype=Object.create(Object.prototype);Script.prototype.check=(function(){var result=I.checkAst(this.$allocator.$,this.$astLexer.$,this.$,this.$errorHandler.$);if(result!=OK){throw new Error("check failed:\n"+this.$errorHandler.errorMessage)}});Script.prototype.toBinary=(function(options){var mw=new MemoryWriter(this.$allocator);options=new WriteBinaryOptions(this.$allocator,options||{});try{var result=I.writeBinaryScript(this.$allocator.$,mw.writer.$,this.$,options.$);if(result!=OK){throw new Error("writeBinaryScript failed")}return{buffer:mw.buf.buf,log:options.log}}finally{options.$destroy();mw.$destroy()}});Script.prototype.$destroy=(function(){I.destroyScript(this.$);if(this.$errorHandler)this.$errorHandler.$destroy();if(this.$astLexer)this.$astLexer.$destroy();this.$.$free()});function WriteBinaryOptions(allocator,options){this.$=Value.$malloc(I.WriteBinaryOptions);if(options.log){this.$logStream=new StringStream;this.$.log_stream.store(this.$logStream.$)}else{this.$logStream=null;this.$.log_stream.store(null)}var optBool=(function(v,def){return v===undefined?def:v});this.$.canonicalize_lebs.store(optBool(options.canonicalizeLebs,true));this.$.write_debug_names.store(optBool(options.writeDebugNames,false))}WriteBinaryOptions.prototype=Object.create(Object.prototype);Object.defineProperty(WriteBinaryOptions.prototype,"log",{get:(function(){return this.$logStream?this.$logStream.string:""})});WriteBinaryOptions.prototype.$destroy=(function(){if(this.$logStream){this.$logStream.$destroy()}this.$.$free()});function BinaryErrorHandler(){this.$=Value.$malloc(I.BinaryErrorHandler);this.$callback=new FnValue(I.BinaryErrorHandler.fields.on_error.type,(function(offset,error,userData){this.errorMessage+="@0x"+offset.toString(16)+": "+error+"\n"}).bind(this));this.$.on_error.store(this.$callback);this.$.user_data.store(null);this.errorMessage=""}BinaryErrorHandler.prototype=Object.create(Object.prototype);BinaryErrorHandler.prototype.$destroy=(function(){this.$callback.$destroy();this.$.$free()});function ReadBinaryOptions(options){this.$=Value.$malloc(I.ReadBinaryOptions);this.$.read_debug_names.store(options.readDebugNames||false)}ReadBinaryOptions.prototype=Object.create(Object.prototype);ReadBinaryOptions.prototype.$destroy=(function(){this.$.$free()});var resolve=wasm.$resolve;wasm={ready:wasm.ready,LibcAllocator:LibcAllocator,StackAllocator:StackAllocator,parseAst:parseAst};resolve()});var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=console.log;if(!Module["printErr"])Module["printErr"]=console.warn;var nodeFS;var nodePath;Module["read"]=function read(filename,binary){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};Module["load"]=function load(f){globalEval(read(f))};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response)}else{onerror()}};xhr.onerror=onerror;xhr.send(null)};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.warn(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var Runtime={setTempRet0:(function(value){tempRet0=value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}),getNativeFieldSize:(function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)}),STACK_ALIGN:16,prepVararg:(function(ptr,type){if(type==="double"||type==="i64"){if(ptr&7){assert((ptr&7)===4);ptr+=4}}else{assert((ptr&3)===0)}return ptr}),getAlignSize:(function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)}),dynCall:(function(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}),functionPointers:[null,null,null,null,null,null,null,null,null,null],addFunction:(function(func){for(var i=0;i<Runtime.functionPointers.length;i++){if(!Runtime.functionPointers[i]){Runtime.functionPointers[i]=func;return 2*(1+i)}}throw"Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS."}),removeFunction:(function(index){Runtime.functionPointers[(index-2)/2]=null}),warnOnce:(function(text){if(!Runtime.warnOnce.shown)Runtime.warnOnce.shown={};if(!Runtime.warnOnce.shown[text]){Runtime.warnOnce.shown[text]=1;Module.printErr(text)}}),funcWrappers:{},getFuncWrapper:(function(func,sig){assert(sig);if(!Runtime.funcWrappers[sig]){Runtime.funcWrappers[sig]={}}var sigCache=Runtime.funcWrappers[sig];if(!sigCache[func]){if(sig.length===1){sigCache[func]=function dynCall_wrapper(){return Runtime.dynCall(sig,func)}}else if(sig.length===2){sigCache[func]=function dynCall_wrapper(arg){return Runtime.dynCall(sig,func,[arg])}}else{sigCache[func]=function dynCall_wrapper(){return Runtime.dynCall(sig,func,Array.prototype.slice.call(arguments))}}}return sigCache[func]}),getCompilerSetting:(function(name){throw"You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work"}),stackAlloc:(function(size){var ret=STACKTOP;STACKTOP=STACKTOP+size|0;STACKTOP=STACKTOP+15&-16;return ret}),staticAlloc:(function(size){var ret=STATICTOP;STATICTOP=STATICTOP+size|0;STATICTOP=STATICTOP+15&-16;return ret}),dynamicAlloc:(function(size){var ret=DYNAMICTOP;DYNAMICTOP=DYNAMICTOP+size|0;DYNAMICTOP=DYNAMICTOP+15&-16;if(DYNAMICTOP>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){DYNAMICTOP=ret;return 0}}return ret}),alignMemory:(function(size,quantum){var ret=size=Math.ceil(size/(quantum?quantum:16))*(quantum?quantum:16);return ret}),makeBigInt:(function(low,high,unsigned){var ret=unsigned?+(low>>>0)+ +(high>>>0)*+4294967296:+(low>>>0)+ +(high|0)*+4294967296;return ret}),GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module["Runtime"]=Runtime;var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];if(!func){try{func=eval("_"+ident)}catch(e){}}assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)");return func}var cwrap,ccall;((function(){var JSfuncs={"stackSave":(function(){Runtime.stackSave()}),"stackRestore":(function(){Runtime.stackRestore()}),"arrayToC":(function(arr){var ret=Runtime.stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=Runtime.stackAlloc((str.length<<2)+1);writeStringToMemory(str,ret)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};ccall=function ccallFunc(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i<args.length;i++){var converter=toC[argTypes[i]];if(converter){if(stack===0)stack=Runtime.stackSave();cArgs[i]=converter(args[i])}else{cArgs[i]=args[i]}}}var ret=func.apply(null,cArgs);if(returnType==="string")ret=Pointer_stringify(ret);if(stack!==0){if(opts&&opts.async){EmterpreterAsync.asyncFinalizers.push((function(){Runtime.stackRestore(stack)}));return}Runtime.stackRestore(stack)}return ret};var sourceRegex=/^function\s*[a-zA-Z$_0-9]*\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;function parseJSFunc(jsfunc){var parsed=jsfunc.toString().match(sourceRegex).slice(1);return{arguments:parsed[0],body:parsed[1],returnValue:parsed[2]}}var JSsource=null;function ensureJSsource(){if(!JSsource){JSsource={};for(var fun in JSfuncs){if(JSfuncs.hasOwnProperty(fun)){JSsource[fun]=parseJSFunc(JSfuncs[fun])}}}}cwrap=function cwrap(ident,returnType,argTypes){argTypes=argTypes||[];var cfunc=getCFunc(ident);var numericArgs=argTypes.every((function(type){return type==="number"}));var numericRet=returnType!=="string";if(numericRet&&numericArgs){return cfunc}var argNames=argTypes.map((function(x,i){return"$"+i}));var funcstr="(function("+argNames.join(",")+") {";var nargs=argTypes.length;if(!numericArgs){ensureJSsource();funcstr+="var stack = "+JSsource["stackSave"].body+";";for(var i=0;i<nargs;i++){var arg=argNames[i],type=argTypes[i];if(type==="number")continue;var convertCode=JSsource[type+"ToC"];funcstr+="var "+convertCode.arguments+" = "+arg+";";funcstr+=convertCode.body+";";funcstr+=arg+"=("+convertCode.returnValue+");"}}var cfuncname=parseJSFunc((function(){return cfunc})).returnValue;funcstr+="var ret = "+cfuncname+"("+argNames.join(",")+");";if(!numericRet){var strgfy=parseJSFunc((function(){return Pointer_stringify})).returnValue;funcstr+="ret = "+strgfy+"(ret);"}if(!numericArgs){ensureJSsource();funcstr+=JSsource["stackRestore"].body.replace("()","(stack)")+";"}funcstr+="return ret})";return eval(funcstr)}}))();Module["ccall"]=ccall;Module["cwrap"]=cwrap;function setValue(ptr,value,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":HEAP8[ptr>>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}Module["setValue"]=setValue;function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for setValue: "+type)}return null}Module["getValue"]=getValue;var ALLOC_NORMAL=0;var ALLOC_STACK=1;var ALLOC_STATIC=2;var ALLOC_DYNAMIC=3;var ALLOC_NONE=4;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["ALLOC_STACK"]=ALLOC_STACK;Module["ALLOC_STATIC"]=ALLOC_STATIC;Module["ALLOC_DYNAMIC"]=ALLOC_DYNAMIC;Module["ALLOC_NONE"]=ALLOC_NONE;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[typeof _malloc==="function"?_malloc:Runtime.staticAlloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var ptr=ret,stop;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr<stop;ptr+=4){HEAP32[ptr>>2]=0}stop=ret+size;while(ptr<stop){HEAP8[ptr++>>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i<size){var curr=slab[i];if(typeof curr==="function"){curr=Runtime.getFunctionIndex(curr)}type=singleType||types[i];if(type===0){i++;continue}if(type=="i64")type="i32";setValue(ret+i,curr,type);if(previousType!==type){typeSize=Runtime.getNativeTypeSize(type);previousType=type}i+=typeSize}return ret}Module["allocate"]=allocate;function getMemory(size){if(!staticSealed)return Runtime.staticAlloc(size);if(typeof _sbrk!=="undefined"&&!_sbrk.called||!runtimeInitialized)return Runtime.dynamicAlloc(size);return _malloc(size)}Module["getMemory"]=getMemory;function Pointer_stringify(ptr,length){if(length===0||!ptr)return"";var hasUtf=0;var t;var i=0;while(1){t=HEAPU8[ptr+i>>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return Module["UTF8ToString"](ptr)}Module["Pointer_stringify"]=Pointer_stringify;function AsciiToString(ptr){var str="";while(1){var ch=HEAP8[ptr++>>0];if(!ch)return str;str+=String.fromCharCode(ch)}}Module["AsciiToString"]=AsciiToString;function stringToAscii(str,outPtr){return writeAsciiToMemory(str,outPtr,false)}Module["stringToAscii"]=stringToAscii;function UTF8ArrayToString(u8Array,idx){var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}Module["UTF8ArrayToString"]=UTF8ArrayToString;function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}Module["UTF8ToString"]=UTF8ToString;function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}Module["stringToUTF8Array"]=stringToUTF8Array;function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}Module["stringToUTF8"]=stringToUTF8;function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}Module["lengthBytesUTF8"]=lengthBytesUTF8;function demangle(func){var hasLibcxxabi=!!Module["___cxa_demangle"];if(hasLibcxxabi){try{var buf=_malloc(func.length);writeStringToMemory(func.substr(1),buf);var status=_malloc(4);var ret=Module["___cxa_demangle"](buf,0,0,status);if(getValue(status,"i32")===0&&ret){return Pointer_stringify(ret)}}catch(e){}finally{if(buf)_free(buf);if(status)_free(status);if(ret)_free(ret)}return func}Runtime.warnOnce("warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling");return func}function demangleAll(text){return text.replace(/__Z[\w\d_]+/g,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){var js=jsStackTrace();if(Module["extraStackTrace"])js+="\n"+Module["extraStackTrace"]();return demangleAll(js)}Module["stackTrace"]=stackTrace;function alignMemoryPage(x){if(x%4096>0){x+=4096-x%4096}return x}var HEAP;var buffer;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE=0,STATICTOP=0,staticSealed=false;var STACK_BASE=0,STACKTOP=0,STACK_MAX=0;var DYNAMIC_BASE=0,DYNAMICTOP=0;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){abortOnCannotGrowMemory()}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;var totalMemory=64*1024;while(totalMemory<TOTAL_MEMORY||totalMemory<2*TOTAL_STACK){if(totalMemory<16*1024*1024){totalMemory*=2}else{totalMemory+=16*1024*1024}}if(totalMemory!==TOTAL_MEMORY){TOTAL_MEMORY=totalMemory}if(Module["buffer"]){buffer=Module["buffer"]}else{buffer=new ArrayBuffer(TOTAL_MEMORY)}updateGlobalBufferViews();HEAP32[0]=255;if(HEAPU8[0]!==255||HEAPU8[3]!==0)throw"Typed arrays 2 must be run on a little-endian system";Module["HEAP"]=HEAP;Module["buffer"]=buffer;Module["HEAP8"]=HEAP8;Module["HEAP16"]=HEAP16;Module["HEAP32"]=HEAP32;Module["HEAPU8"]=HEAPU8;Module["HEAPU16"]=HEAPU16;Module["HEAPU32"]=HEAPU32;Module["HEAPF32"]=HEAPF32;Module["HEAPF64"]=HEAPF64;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Runtime.dynCall("v",func)}else{Runtime.dynCall("vi",func,[callback.arg])}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}Module["addOnPreRun"]=addOnPreRun;function addOnInit(cb){__ATINIT__.unshift(cb)}Module["addOnInit"]=addOnInit;function addOnPreMain(cb){__ATMAIN__.unshift(cb)}Module["addOnPreMain"]=addOnPreMain;function addOnExit(cb){__ATEXIT__.unshift(cb)}Module["addOnExit"]=addOnExit;function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}Module["addOnPostRun"]=addOnPostRun;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}Module["intArrayFromString"]=intArrayFromString;function intArrayToString(array){var ret=[];for(var i=0;i<array.length;i++){var chr=array[i];if(chr>255){chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}Module["intArrayToString"]=intArrayToString;function writeStringToMemory(string,buffer,dontAddNull){var array=intArrayFromString(string,dontAddNull);var i=0;while(i<array.length){var chr=array[i];HEAP8[buffer+i>>0]=chr;i=i+1}}Module["writeStringToMemory"]=writeStringToMemory;function writeArrayToMemory(array,buffer){for(var i=0;i<array.length;i++){HEAP8[buffer++>>0]=array[i]}}Module["writeArrayToMemory"]=writeArrayToMemory;function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i<str.length;++i){HEAP8[buffer++>>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}Module["writeAsciiToMemory"]=writeAsciiToMemory;if(!Math["imul"]||Math["imul"](4294967295,5)!==-5)Math["imul"]=function imul(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};Math.imul=Math["imul"];if(!Math["clz32"])Math["clz32"]=(function(x){x=x>>>0;for(var i=0;i<32;i++){if(x&1<<31-i)return i}return 32});Math.clz32=Math["clz32"];if(!Math["trunc"])Math["trunc"]=(function(x){return x<0?Math.ceil(x):Math.floor(x)});Math.trunc=Math["trunc"];var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_min=Math.min;var Math_clz32=Math.clz32;var Math_trunc=Math.trunc;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}Module["addRunDependency"]=addRunDependency;function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["removeRunDependency"]=removeRunDependency;Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var ASM_CONSTS=[];STATIC_BASE=8;STATICTOP=STATIC_BASE+38384;__ATINIT__.push();memoryInitializer="libwasm.js.mem";var tempDoublePtr=STATICTOP;STATICTOP+=16;Module["_i64Subtract"]=_i64Subtract;Module["_i64Add"]=_i64Add;Module["_memset"]=_memset;M