Comparing version 0.0.8 to 0.0.9
@@ -1,1 +0,1 @@ | ||
(function () {var ia={};var oa={};function Ka(r,e){var o={destCol:1,srcCol:1,srcLine:1};r.forEach(function(r){r.destCol>e||(o=r)});var t=e-o.destCol;return{column:o.srcCol+t,line:o.srcLine}}function ib(r){for(var e=[],o=1,t="",s=0,$=!1,c=!1,n=!1,l=0;l<r.length;l++){var p=r[l];if(n){var i=t.length+1,a=l-s+1;e.push({destCol:i,srcCol:a,srcLine:o}),n=!1}"\n"===p?($=!1,o++,s=l+1,n=!0):"\r"===p&&"\n"===r[l+1]?($=!1,o++,s=++l+1,n=!0):c&&"*"===p&&"/"===r[l+1]?(c=!1,l++,n=!0):"\\"===p&&"\\"===r[l+1]||"/"===p&&"/"===r[l+1]?($=!0,l++):"/"===p&&"*"===r[l+1]?(c=!0,l++):$||c||(t+=p)}return[t,e]}var ja,ka,jb={},F=jb={};function ya(){throw new Error("setTimeout has not been defined")}function za(){throw new Error("clearTimeout has not been defined")}function La($){if(ja===setTimeout)return setTimeout($,0);if((ja===ya||!ja)&&setTimeout)return ja=setTimeout,setTimeout($,0);try{return ja($,0)}catch(e){try{return ja.call(null,$,0)}catch(e){return ja.call(this,$,0)}}}function kb($){if(ka===clearTimeout)return clearTimeout($);if((ka===za||!ka)&&clearTimeout)return ka=clearTimeout,clearTimeout($);try{return ka($)}catch(e){try{return ka.call(null,$)}catch(e){return ka.call(this,$)}}}!function(){try{ja="function"==typeof setTimeout?setTimeout:ya}catch($){ja=ya}try{ka="function"==typeof clearTimeout?clearTimeout:za}catch($){ka=za}}();var pa,fa=[],Aa=!1,Ma=-1;function lb(){Aa&&pa&&(Aa=!1,pa.length?fa=pa.concat(fa):Ma=-1,fa.length&&Na())}function Na(){if(!Aa){var $=La(lb);Aa=!0;for(var e=fa.length;e;){for(pa=fa,fa=[];++Ma<e;)pa&&pa[Ma].run();Ma=-1,e=fa.length}pa=null,Aa=!1,kb($)}}function Oa($,e){this.fun=$,this.array=e}function Q(){}F.nextTick=function($){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];fa.push(new Oa($,e)),1!==fa.length||Aa||La(Na)},Oa.prototype.run=function(){this.fun.apply(null,this.array)},F.title="browser",F.env={},F.argv=[],F.version="",F.versions={},F.on=Q,F.addListener=Q,F.once=Q,F.off=Q,F.removeListener=Q,F.removeAllListeners=Q,F.emit=Q,F.prependListener=Q,F.prependOnceListener=Q,F.listeners=function($){return[]},F.binding=function($){throw new Error("process.binding is not supported")},F.cwd=function(){return"/"},F.chdir=function($){throw new Error("process.chdir is not supported")},F.umask=function(){return 0};var mb=function(){var t={exports:this},i=function(){var t=function(t,e,i,s){for(i=i||{},s=t.length;s--;i[t[s]]=e);return i},e=[1,18],i=[1,7],s=[1,19],n=[1,20],r=[1,14],h=[1,15],o=[1,16],a=[1,33],c=[1,31],l=[1,23],y=[1,22],u=[1,24],p=[1,25],_=[1,26],f=[1,27],g=[1,28],m=[1,29],E=[1,30],k=[5,8,15,18,20,28,29,32,33,34,35,36,37,38],I=[5,15,18],b=[5,12,15,17,18,24,25,28,29,30],S=[1,57],d=[5,8,12,15,17,18,24,25,28,29,30],N=[15,18],O=[5,8,15,18,28,29,38],$=[5,8,15,18,28,29,32,33,38],x=[5,8,15,18,28,29,32,33,34,37,38],A=[5,8,15,18,28,29,32,33,34,35,36,37,38],R=[5,8,15,18],v=[5,8,15,18,20,22,28,29,32,33,34,35,36,37,38],T={trace:function(){},yy:{},symbols_:{error:2,SCRIPT:3,expression:4,EOF:5,expressionsOptionalTrailingSemi:6,separator:7,";":8,expressions:9,EXPRESSION_BLOCK:10,IDENTIFIER:11,IDENTIFIER_TOKEN:12,argument:13,arguments:14,",":15,FUNCTION_CALL:16,"(":17,")":18,LOGICAL_EXPRESSION:19,LOGICAL_OPERATOR_TOKEN:20,ASSIGNMENT:21,ASSIGNMENT_OPERATOR_TOKEN:22,number:23,DIGITS_TOKEN:24,".":25,NUMBER_LITERAL:26,UNARY_EXPRESSION:27,"-":28,"+":29,"!":30,BINARY_EXPRESSION:31,"*":32,"/":33,"%":34,"&":35,"|":36,"^":37,COMPARISON_TOKEN:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:";",12:"IDENTIFIER_TOKEN",15:",",17:"(",18:")",20:"LOGICAL_OPERATOR_TOKEN",22:"ASSIGNMENT_OPERATOR_TOKEN",24:"DIGITS_TOKEN",25:".",28:"-",29:"+",30:"!",32:"*",33:"/",34:"%",35:"&",36:"|",37:"^",38:"COMPARISON_TOKEN"},productions_:[0,[3,2],[3,2],[3,1],[7,1],[7,2],[9,2],[9,3],[6,1],[6,2],[10,1],[11,1],[13,1],[13,1],[14,1],[14,3],[16,3],[16,4],[19,3],[21,3],[21,3],[23,1],[23,2],[23,3],[23,2],[23,1],[26,1],[27,2],[27,2],[27,2],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[4,1],[4,1],[4,3],[4,1],[4,1],[4,1],[4,1],[4,1],[4,3]],performAction:function(t,e,i,s,n,r,h){var o=r.length-1;switch(n){case 1:return{type:"SCRIPT",body:[r[o-1]],loc:this._$};case 2:return{type:"SCRIPT",body:r[o-1],loc:this._$};case 3:return{type:"SCRIPT",body:[],loc:this._$};case 6:this.$=[r[o-1]];break;case 7:this.$=r[o-2].concat([r[o-1]]);break;case 8:this.$=r[o];break;case 9:this.$=r[o-1].concat([r[o]]);break;case 10:this.$={type:"EXPRESSION_BLOCK",body:r[o],loc:this._$};break;case 11:this.$={type:"IDENTIFIER",value:r[o].toLowerCase(),loc:this._$};break;case 14:this.$=[r[o]];break;case 15:this.$=r[o-2].concat([r[o]]);break;case 16:this.$={type:"CALL_EXPRESSION",callee:r[o-2],arguments:[],loc:this._$};break;case 17:this.$={type:"CALL_EXPRESSION",callee:r[o-3],arguments:r[o-1],loc:this._$};break;case 18:this.$={type:"LOGICAL_EXPRESSION",left:r[o-2],right:r[o],operator:r[o-1],loc:this._$};break;case 19:case 20:this.$={type:"ASSIGNMENT_EXPRESSION",left:r[o-2],operator:r[o-1],right:r[o],loc:this._$};break;case 21:this.$=Number(r[o]);break;case 22:this.$=Number(r[o-1]);break;case 23:this.$=Number(r[o-2]+r[o-1]+r[o]);break;case 24:this.$=Number("0"+r[o-1]+r[o]);break;case 25:this.$=0;break;case 26:this.$={type:"NUMBER_LITERAL",value:r[o],loc:this._$};break;case 27:case 28:case 29:this.$={type:"UNARY_EXPRESSION",value:r[o],operator:r[o-1],loc:this._$};break;case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:this.$={type:"BINARY_EXPRESSION",left:r[o-2],right:r[o],operator:r[o-1],loc:this._$};break;case 41:case 47:this.$=r[o-1];}},table:[{3:1,4:2,5:[1,4],6:3,9:13,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{1:[3]},{5:[1,21],7:32,8:a,20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E},{5:[1,34]},{1:[2,3]},t(k,[2,39]),t(k,[2,40]),{4:35,6:37,9:13,10:36,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(k,[2,42]),t(k,[2,43]),t(k,[2,44],{22:[1,38]}),t(k,[2,45],{17:[1,40],22:[1,39]}),t(k,[2,46]),t(I,[2,8],{31:5,27:6,26:8,21:9,16:10,11:11,19:12,23:17,4:41,12:e,17:i,24:s,25:n,28:r,29:h,30:o}),{4:42,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:43,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:44,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(k,[2,26]),t([5,8,15,17,18,20,22,28,29,32,33,34,35,36,37,38],[2,11]),t(k,[2,21],{25:[1,45]}),t(k,[2,25],{24:[1,46]}),{1:[2,1]},{4:47,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:48,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:49,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:50,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:51,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:52,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:53,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:54,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:55,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:56,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(b,[2,6],{8:S}),t(d,[2,4]),{1:[2,2]},{7:32,8:a,18:[1,58],20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E},{18:[1,59]},t(N,[2,10]),{4:60,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:61,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:65,6:37,9:13,10:66,11:11,12:e,13:64,14:63,16:10,17:i,18:[1,62],19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(I,[2,9],{7:67,8:a,20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(O,[2,27],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t(O,[2,28],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t(O,[2,29],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t(k,[2,22],{24:[1,68]}),t(k,[2,24]),t(O,[2,30],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t(O,[2,31],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t($,[2,32],{20:c,34:_,35:f,36:g,37:m}),t($,[2,33],{20:c,34:_,35:f,36:g,37:m}),t(x,[2,34],{20:c,35:f,36:g}),t(A,[2,35],{20:c}),t(A,[2,36],{20:c}),t(x,[2,37],{20:c,35:f,36:g}),t(R,[2,38],{20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(k,[2,18]),t(d,[2,5]),t(k,[2,41]),t(k,[2,47]),t(R,[2,20],{20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(R,[2,19],{20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(v,[2,16]),{15:[1,70],18:[1,69]},t(N,[2,14]),t(N,[2,12],{7:32,8:a,20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(N,[2,13]),t(b,[2,7],{8:S}),t(k,[2,23]),t(v,[2,17]),{4:65,6:37,9:13,10:66,11:11,12:e,13:71,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(N,[2,15])],defaultActions:{4:[2,3],21:[2,1],34:[2,2]},parseError:function(t,e){if(!e.recoverable){var i=new Error(t);throw i.hash=e,i}this.trace(t)},parse:function(t){var e=this,i=[0],s=[null],n=[],r=this.table,h="",o=0,a=0,c=0,l=n.slice.call(arguments,1),y=Object.create(this.lexer),u={yy:{}};for(var p in this.yy)Object.prototype.hasOwnProperty.call(this.yy,p)&&(u.yy[p]=this.yy[p]);y.setInput(t,u.yy),u.yy.lexer=y,u.yy.parser=this,void 0===y.yylloc&&(y.yylloc={});var _=y.yylloc;n.push(_);var f=y.options&&y.options.ranges;"function"==typeof u.yy.parseError?this.parseError=u.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,m,E,k,I,b,S,d,N,O=function(){var t;return"number"!=typeof(t=y.lex()||1)&&(t=e.symbols_[t]||t),t},$={};;){if(E=i[i.length-1],this.defaultActions[E]?k=this.defaultActions[E]:(null==g&&(g=O()),k=r[E]&&r[E][g]),void 0===k||!k.length||!k[0]){var x="";for(b in N=[],r[E])this.terminals_[b]&&b>2&&N.push("'"+this.terminals_[b]+"'");x=y.showPosition?"Parse error on line "+(o+1)+":\n"+y.showPosition()+"\nExpecting "+N.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==g?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(x,{text:y.match,token:this.terminals_[g]||g,line:y.yylineno,loc:_,expected:N})}if(k[0]instanceof Array&&k.length>1)throw new Error("Parse Error: multiple actions possible at state: "+E+", token: "+g);switch(k[0]){case 1:i.push(g),s.push(y.yytext),n.push(y.yylloc),i.push(k[1]),g=null,m?(g=m,m=null):(a=y.yyleng,h=y.yytext,o=y.yylineno,_=y.yylloc,c>0&&c--);break;case 2:if(S=this.productions_[k[1]][1],$.$=s[s.length-S],$._$={first_line:n[n.length-(S||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(S||1)].first_column,last_column:n[n.length-1].last_column},f&&($._$.range=[n[n.length-(S||1)].range[0],n[n.length-1].range[1]]),void 0!==(I=this.performAction.apply($,[h,a,o,u.yy,k[1],s,n].concat(l))))return I;S&&(i=i.slice(0,-1*S*2),s=s.slice(0,-1*S),n=n.slice(0,-1*S)),i.push(this.productions_[k[1]][0]),s.push($.$),n.push($._$),d=r[i[i.length-2]][i[i.length-1]],i.push(d);break;case 3:return!0;}}return!0}},P={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===s.length?this.yylloc.first_column:0)+s[s.length-i.length].length-i[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var i,s,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var r in n)this[r]=n[r];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,i,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),r=0;r<n.length;r++)if((i=this._input.match(this.rules[n[r]]))&&(!e||i[0].length>e[0].length)){if(e=i,s=r,this.options.backtrack_lexer){if(!1!==(t=this.test_match(i,n[r])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,n[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,i,s){switch(i){case 0:break;case 1:return 24;case 2:return 38;case 3:return 22;case 4:return 20;case 5:return 12;case 6:return 5;case 7:return e.yytext[0];}},rules:[/^(?:\s+)/,/^(?:[0-9]+)/,/^(?:(==|!=|<=|>=|<|>))/,/^(?:[+\-*/%]?=)/,/^(?:(\&\&)|\|\|)/,/^(?:[a-zA-Z_][a-zA-Z0-9._]*)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};function L(){this.yy={}}return T.lexer=P,L.prototype=T,T.Parser=L,new L}();return"undefined"!=typeof require&&void 0!==this&&(this.parser=i,this.Parser=i.Parser,this.parse=function(){return i.parse.apply(i,arguments)},this.main=function(){},void 0!==t&&require.main===t&&this.main(jb.argv.slice(1))),t.exports}.call({});var nb={};nb={parse:mb.parse};function Pa(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function Qa(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?Pa(Object(t),!0).forEach(function(r){Ba(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Pa(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function Ba(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var ob={ASSIGNMENT_EXPRESSION:[{type:"NODE",key:"right"}],SCRIPT:[{type:"ARRAY",key:"body"}],EXPRESSION_BLOCK:[{type:"ARRAY",key:"body"}],UNARY_EXPRESSION:[{type:"NODE",key:"value"}],NUMBER_LITERAL:[],IDENTIFIER:[],CALL_EXPRESSION:[{type:"ARRAY",key:"arguments"},{type:"NODE",key:"callee"}],BINARY_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}],LOGICAL_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}]};function Ca(e,r){var t=ob[e.type],n=e;if(null==t)throw new Error("Unknown children definition for ".concat(e.type));return t.forEach(function(t){if("NODE"===t.type){var o=e[t.key],$=Ca(o,r);$!==o&&(n=Qa({},n,Ba({},t.key,$)))}else if("ARRAY"===t.type){var p=e[t.key],y=p.map(function(e){return Ca(e,r)});p.some(function(e,r){return e!==y[r]})&&(n=Qa({},n,Ba({},t.key,y)))}}),r(n)}var qa={};var aa={},pb=aa&&aa.__read||function(r,t){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var $,a,f=e.call(r),n=[];try{for(;(void 0===t||t-->0)&&!($=f.next()).done;)n.push($.value)}catch(o){a={error:o}}finally{try{$&&!$.done&&(e=f.return)&&e.call(f)}finally{if(a)throw a.error}}return n},qb=aa&&aa.__spread||function(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(pb(arguments[t]));return r};function Ra(r,t){for(var e=[],$=0;$<r.length;$++){e.push(r[$]),$===r.length-1||e.push(t)}return e}function va(r){var t=[];return r.forEach(function(r){t.push.apply(t,qb(r))}),t}aa.arrayJoin=Ra,aa.flatten=va;var Sa=function(r){return[].concat.apply([],r)};function Da(r,t){return new Array(r).fill(t).join("")}aa.flattenTwice=Sa,aa.repeat=Da;var Ta=qa&&qa.__extends||function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}();function Ua(r,t,e){void 0===e&&(e=1);var o=Math.max(r.first_line-1-e,0),n=r.last_line+e,$=t.split("\n").slice(o,n).map(function(t,e){var n=e+o+1;return(n>=r.first_line&&n<=r.last_line?">":" ")+" "+n+" | "+t});if(r.first_line===r.last_line){var i=Da(r.first_column," "),p=Da(r.last_column-r.first_column,"^"),a=r.first_line-o;$.splice(a,0," | "+i+p)}return $.join("\n")}qa.printLoc=Ua;var Va=function(r){function t(t,e,o){var n=r.call(this,t)||this;return n.sourceContext=Ua(e,o),n.loc=e,n}return Ta(t,r),t}(Error),rb=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return Ta(t,r),t}(Va);function ba(r,t,e){return new rb(r,t,e)}function U(r,t,e){return new Va(r,t,e)}qa.createUserError=ba,qa.createCompilerError=U;var Wa=oa&&oa.__assign||function(){return(Wa=Object.assign||function(r){for(var e,$=1,t=arguments.length;$<t;$++)for(var o in e=arguments[$])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)},sb=oa&&oa.__read||function(r,e){var $="function"==typeof Symbol&&r[Symbol.iterator];if(!$)return r;var t,o,a=$.call(r),n=[];try{for(;(void 0===e||e-->0)&&!(t=a.next()).done;)n.push(t.value)}catch(i){o={error:i}}finally{try{t&&!t.done&&($=a.return)&&$.call(a)}finally{if(o)throw o.error}}return n};function Xa(r,e){var $=Ka(e,r.first_column),t=Ka(e,r.last_column);return{first_column:$.column,last_column:t.column,first_line:$.line,last_line:t.line}}function Ea(r){var e=sb(ib(r),2),$=e[0],t=e[1];try{var o=nb.parse($);return Ca(o,function(e){if(1!==e.loc.first_line||1!=e.loc.last_line)throw U("Unexpected multiline",e.loc,r);return Wa(Wa({},e),{loc:Xa(e.loc,t)})})}catch(a){if(null==a.hash)throw a;throw ba("Parse Error: "+a.message.split("\n")[3],Xa(a.hash.loc,t),r)}}oa.parse=Ea;var ra={};var sa={};var B={};function tb(a,t){var o,r,h,p=52,M=64-p-1,w=(1<<M)-1,$=w>>1,e=23===p?Math.pow(2,-24)-Math.pow(2,-77):0,i=0,c=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(r=isNaN(t)?1:0,o=w):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),(t+=o+$>=1?e/h:e*Math.pow(2,1-$))*h>=2&&(o++,h/=2),o+$>=w?(r=0,o=w):o+$>=1?(r=(t*h-1)*Math.pow(2,p),o+=$):(r=t*Math.pow(2,$-1)*Math.pow(2,p),o=0));p>=8;a[0+i]=255&r,i+=1,r/=256,p-=8);for(o=o<<p|r,M+=p;M>0;a[0+i]=255&o,i+=1,o/=256,M-=8);a[0+i-1]|=128*c}var ub=B&&B.__read||function($,r){var e="function"==typeof Symbol&&$[Symbol.iterator];if(!e)return $;var x,t,o=e.call($),n=[];try{for(;(void 0===r||r-->0)&&!(x=o.next()).done;)n.push(x.value)}catch(Y){t={error:Y}}finally{try{x&&!x.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return n},H=B&&B.__spread||function(){for(var $=[],r=0;r<arguments.length;r++)$=$.concat(ub(arguments[r]));return $},Ya=[0,97,115,109];B.MAGIC=Ya;var Za=[1,0,0,0];B.WASM_VERSION=Za;var wa=1e-5;B.EPSILON=wa;var ca={TYPE:1,IMPORT:2,FUNC:3,MEMORY:5,GLOBAL:6,EXPORT:7,CODE:10};B.SECTION=ca;var $a={FUNC:0,TABLE:1,MEMORY:2,GLOBAL:3};B.EXPORT_TYPE=$a;var j={loop:function($){return[3,$]},if:function($){return[4,$]},else:5,end:11,br_if:function($){return H([13],G($))},call:function($){return H([16],G($))},drop:26,select:27,local_get:function($){return H([32],G($))},local_set:function($){return H([33],G($))},local_tee:function($){return H([34],G($))},global_get:function($){return H([35],G($))},global_set:function($){return H([36],G($))},f64_load:function($,r){return H([43],G($),G(r))},f64_store:function($,r){return H([57],G($),G(r))},i32_const:function($){return H([65],db($))},f64_const:function($){return H([68],cb($))},i32_eqz:69,i32_ne:71,i32_lt_s:72,i32_gt_s:74,i32_le_s:76,i32_le_u:77,i32_ge_s:78,f64_eq:97,f64_ne:98,f64_lt:99,f64_gt:100,f64_le:101,f64_ge:102,i32_add:106,i32_sub:107,i32_mul:108,i32_and:113,i32_or:114,i64_rem_s:129,i64_and:131,i64_or:132,f64_abs:153,f64_neg:154,f64_floor:156,f64_sqrt:159,f64_add:160,f64_sub:161,f64_mul:162,f64_div:163,f64_min:164,f64_max:165,i32_trunc_f64_s:170,i64_trunc_s_f64:176,f64_convert_i64_s:185,f64_convert_i32_s:183};B.op=j;var q={i32:127,i64:126,f32:125,f64:124};B.VAL_TYPE=q;var Fa={const:0,var:1};B.MUTABILITY=Fa;var Z={void:64,i32:127,i64:126,f32:125,f64:124};B.BLOCK=Z;var _a=96;B.FUNCTION_TYPE=_a;var vb=2;B.MEMORY_IDX=vb;var ab=3;B.GLOBAL_TYPE=ab;var bb=0;B.TYPE_IDX=bb;var la=H([j.f64_abs],j.f64_const(wa),[j.f64_lt]);B.IS_ZEROISH=la;var K=H([j.f64_abs],j.f64_const(wa),[j.f64_gt]);function cb($){var r=new Uint8Array(8);return tb(r,$),r}B.IS_NOT_ZEROISH=K,B.encodef64=cb;var ma=function($){return H([$.length],$.split("").map(function($){return $.charCodeAt(0)}))};function G($){var r=[];do{var e=127&$;0!==($>>>=7)&&(e|=128),r.push(e)}while(0!==$);return r}function db($){for(var r=[],e=0,x=Math.ceil(Math.log2(Math.abs($))),t=$<0,o=!0;o;)e=127&$,$>>=7,t&&($|=-(1<<x-7)),0==$&&0==(64&e)||-1==$&&64==(64&e)?o=!1:e|=128,r.push(e);return r}B.encodeString=ma,B.unsignedLEB128=G,B.signedLEB128=db;var ga=function($){return H(G($.length),Sa($))};function da($,r){return 0===r.length?[]:H([$],ga(ga(r)))}B.encodeVector=ga,B.encodeSection=da;var wb=1e-5,na={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,rand:function(a){return Math.floor(Math.random()*a)},pow:Math.pow,log:Math.log,log10:Math.log10,exp:Math.exp,sigmoid:function(a,t){var o=1+Math.exp(-a*t);return Math.abs(o)>wb?1/o:0},floor:Math.floor,ceil:Math.ceil};var ta={};var xb=65536,yb=8,zb=2,Ga=8388608;var eb=Math.ceil(Ga*yb*zb/xb);var Ab=ta&&ta.__read||function($,o){var r="function"==typeof Symbol&&$[Symbol.iterator];if(!r)return $;var e,n,t=r.call($),p=[];try{for(;(void 0===o||o-->0)&&!(e=t.next()).done;)p.push(e.value)}catch(i){n={error:i}}finally{try{e&&!e.done&&(r=t.return)&&r.call(t)}finally{if(n)throw n.error}}return p},ea=ta&&ta.__spread||function(){for(var $=[],o=0;o<arguments.length;o++)$=$.concat(Ab(arguments[o]));return $},ua={sqr:{args:[q.f64],returns:[q.f64],binary:ea(j.local_get(0),j.local_get(0),[j.f64_mul])},bor:{args:[q.f64,q.f64],returns:[q.f64],binary:ea(j.local_get(0),K,j.local_get(1),K,[j.i32_or],j.i32_const(0),[j.i32_ne,j.f64_convert_i32_s])},band:{args:[q.f64,q.f64],returns:[q.f64],binary:ea(j.local_get(0),K,j.local_get(1),K,[j.i32_and],j.i32_const(0),[j.i32_ne,j.f64_convert_i32_s])},sign:{args:[q.f64],returns:[q.f64],binary:ea(j.f64_const(0),j.local_get(0),[j.f64_lt],j.local_get(0),j.f64_const(0),[j.f64_lt,j.i32_sub,j.f64_convert_i32_s])},mod:{args:[q.f64,q.f64],returns:[q.f64],binary:ea(j.local_get(0),[j.i64_trunc_s_f64],j.local_get(1),[j.i64_trunc_s_f64,j.i64_rem_s,j.f64_convert_i64_s])},bitwiseOr:{args:[q.f64,q.f64],returns:[q.f64],binary:ea(j.local_get(0),[j.i64_trunc_s_f64],j.local_get(1),[j.i64_trunc_s_f64,j.i64_or,j.f64_convert_i64_s])},bitwiseAnd:{args:[q.f64,q.f64],returns:[q.f64],binary:ea(j.local_get(0),[j.i64_trunc_s_f64],j.local_get(1),[j.i64_trunc_s_f64,j.i64_and,j.f64_convert_i64_s])},_getBufferIndex:{args:[q.f64],returns:[q.i32],localVariables:[q.f64,q.i32],binary:ea(j.f64_const(wa),j.local_get(0),[j.f64_add],j.local_tee(1),[j.i32_trunc_f64_s],j.local_set(2),j.i32_const(-1),j.local_get(2),j.i32_const(8),[j.i32_mul],j.local_get(2),j.i32_const(0),[j.i32_lt_s],j.local_get(2),j.i32_const(Ga-1),[j.i32_gt_s,j.i32_or,j.select])}};ta.localFuncMap=ua;var fb=sa&&sa.__read||function($,r){var o="function"==typeof Symbol&&$[Symbol.iterator];if(!o)return $;var e,t,p=o.call($),i=[];try{for(;(void 0===r||r-->0)&&!(e=p.next()).done;)i.push(e.value)}catch(a){t={error:a}}finally{try{e&&!e.done&&(o=p.return)&&o.call(p)}finally{if(t)throw t.error}}return i},z=sa&&sa.__spread||function(){for(var $=[],r=0;r<arguments.length;r++)$=$.concat(fb(arguments[r]));return $};function Ha($,r){var o=$.map(function($,o){return C($,r)});return va(Ra(o,[j.drop]))}function Bb($,r){var o=C($,r);return z(j.loop(Z.void),o,K,j.br_if(0),[j.end],j.f64_const(0))}function Cb($,r,o){var e=C(r,o),t=o.resolveLocal(q.f64);return z(C($,o),j.local_set(t),j.loop(Z.void),e,[j.drop],j.local_get(t),j.f64_const(1),[j.f64_sub],j.local_tee(t),K,j.br_if(0),[j.end],j.f64_const(0))}function Db($,r,o,e){return z(C($,e),K,j.if(Z.f64),C(r,e),[j.else],C(o,e),[j.end])}function gb($){switch($){case"gmegabuf":return 8*Ga;case"megabuf":return 0;}}function Eb($,r){var o={"+=":[j.f64_add],"-=":[j.f64_sub],"*=":[j.f64_mul],"/=":[j.f64_div],"%=":r.resolveLocalFunc("mod"),"=":null}[$.operator];if(void 0===o)throw U("Unknown assignment operator \""+$.operator+"\"",$.loc,r.rawSource);return o}function C($,r){switch($.type){case"SCRIPT":var o=$.body.map(function($,o){return z(C($,r),[j.drop])});return va(o);case"EXPRESSION_BLOCK":return Ha($.body,r);case"BINARY_EXPRESSION":var e=C($.left,r),t=C($.right,r);if(null==(b={"+":[j.f64_add],"-":[j.f64_sub],"*":[j.f64_mul],"/":[j.f64_div],"%":r.resolveLocalFunc("mod"),"|":r.resolveLocalFunc("bitwiseOr"),"&":r.resolveLocalFunc("bitwiseAnd"),"^":r.resolveLocalFunc("pow"),"==":z([j.f64_sub],la,[j.f64_convert_i32_s]),"!=":z([j.f64_sub],K,[j.f64_convert_i32_s]),"<":[j.f64_lt,j.f64_convert_i32_s],">":[j.f64_gt,j.f64_convert_i32_s],"<=":[j.f64_le,j.f64_convert_i32_s],">=":[j.f64_ge,j.f64_convert_i32_s]}[$.operator]))throw U("Unknown binary expression operator "+$.operator,$.loc,r.rawSource);return z(e,t,b);case"CALL_EXPRESSION":var p=$.callee.value,i=$.arguments,a=function(o){if(i.length<o)throw ba("Too few arguments passed to `"+p+"()`. Expected "+o+" but only got "+i.length+".",$.loc,r.rawSource);if(i.length>o)throw ba("Too many arguments passed to `"+p+"()`. Expected "+o+" but got "+i.length+".",i[o].loc,r.rawSource)},m=va($.arguments.map(function($){return C($,r)}));switch(p){case"exec2":return a(2),Ha($.arguments,r);case"exec3":return a(3),Ha($.arguments,r);case"if":a(3);var V=fb($.arguments,3);return Db(V[0],V[1],V[2],r);case"while":return a(1),Bb($.arguments[0],r);case"loop":return a(2),Cb($.arguments[0],$.arguments[1],r);case"megabuf":case"gmegabuf":a(1);var n=r.resolveLocal(q.i32);return z(C($.arguments[0],r),r.resolveLocalFunc("_getBufferIndex"),j.local_tee(n),j.i32_const(-1),[j.i32_ne],j.if(Z.f64),j.local_get(n),j.f64_load(3,gb(p)),[j.else],j.f64_const(0),[j.end]);case"assign":a(2);var W=$.arguments[0];if("IDENTIFIER"!=W.type)throw ba("Expected the first argument of `assign()` to be an identifier.",W.loc,r.rawSource);var l=r.resolveVar(W.value);return z(C($.arguments[1],r),j.global_set(l),j.global_get(l));case"abs":return a(1),z(m,[j.f64_abs]);case"sqrt":return a(1),z(m,[j.f64_sqrt]);case"int":return a(1),z(m,[j.f64_floor]);case"min":return a(2),z(m,[j.f64_min]);case"max":return a(2),z(m,[j.f64_max]);case"above":return a(2),z(m,[j.f64_gt,j.f64_convert_i32_s]);case"below":return a(2),z(m,[j.f64_lt,j.f64_convert_i32_s]);case"equal":return a(2),z(m,[j.f64_sub],la,[j.f64_convert_i32_s]);case"bnot":return a(1),z(m,la,[j.f64_convert_i32_s]);}var s=r.resolveLocalFunc(p);if(null==s||p.startsWith("_"))throw ba("\""+p+"\" is not defined.",$.callee.loc,r.rawSource);if(null!=na[p])a(na[p].length);else{if(null==ua[p])throw U("Missing arity information for the function `"+p+"()`",$.callee.loc,r.rawSource);a(ua[p].args.length)}return z(m,s);case"ASSIGNMENT_EXPRESSION":e=$.left;var _=C($.right,r),c=Eb($,r);if("IDENTIFIER"===e.type){l=r.resolveVar(e.value);var u=j.global_get(l),f=j.global_set(l);return null===c?z(_,f,u):z(u,_,c,f,u)}if("CALL_EXPRESSION"!==e.type)throw U("Unexpected left hand side type for assignment: "+e.type,$.loc,r.rawSource);var v=r.resolveLocal(q.i32);if(1!==e.arguments.length)throw ba("Expected 1 argument when assinging to a buffer but got "+e.arguments.length+".",0===e.arguments.length?e.loc:e.arguments[1].loc,r.rawSource);var d=e.callee.value;if("gmegabuf"!==d&&"megabuf"!==d)throw ba("The only function calls which may be assigned to are `gmegabuf()` and `megabuf()`.",e.callee.loc,r.rawSource);var g=gb(d);if(null===c){var E=r.resolveLocal(q.i32),S=r.resolveLocal(q.f64);return z(_,j.local_set(S),C(e.arguments[0],r),r.resolveLocalFunc("_getBufferIndex"),j.local_tee(E),j.i32_const(0),[j.i32_lt_s],j.if(Z.f64),j.f64_const(0),[j.else],j.local_get(E),j.local_tee(v),j.local_get(S),j.f64_store(3,g),j.local_get(S),[j.end])}n=r.resolveLocal(q.i32);var h=r.resolveLocal(q.i32),I=r.resolveLocal(q.f64),x=r.resolveLocal(q.f64);return z(_,j.local_set(I),C(e.arguments[0],r),r.resolveLocalFunc("_getBufferIndex"),j.local_tee(n),j.i32_const(-1),[j.i32_ne],j.local_tee(h),j.if(Z.f64),j.local_get(n),j.f64_load(3,g),[j.else],j.f64_const(0),[j.end],j.local_get(I),c,j.local_tee(x),j.local_get(h),j.if(Z.void),j.local_get(n),j.local_get(x),j.f64_store(3,g),[j.end]);case"LOGICAL_EXPRESSION":e=C($.left,r),t=C($.right,r);var L={"&&":{comparison:la,shortCircutValue:0},"||":{comparison:K,shortCircutValue:1}}[$.operator];if(null==L)throw U("Unknown logical expression operator "+$.operator,$.loc,r.rawSource);var w=L.comparison,O=L.shortCircutValue;return z(e,w,j.if(Z.f64),j.f64_const(O),[j.else],t,K,[j.f64_convert_i32_s,j.end]);case"UNARY_EXPRESSION":var b,y=C($.value,r);if(null==(b={"-":[j.f64_neg],"+":[],"!":z(la,[j.f64_convert_i32_s])}[$.operator]))throw U("Unknown logical unary operator "+$.operator,$.loc,r.rawSource);return z(y,b);case"IDENTIFIER":var R=$.value;return j.global_get(r.resolveVar(R));case"NUMBER_LITERAL":return j.f64_const($.value);default:throw U("Unknown AST node type "+$.type,$.loc,r.rawSource);}}sa.emit=C;var xa=ra&&ra.__read||function(r,$){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var t,n,o=e.call(r),a=[];try{for(;(void 0===$||$-->0)&&!(t=o.next()).done;)a.push(t.value)}catch(d){n={error:d}}finally{try{t&&!t.done&&(e=o.return)&&e.call(o)}finally{if(n)throw n.error}}return a},J=ra&&ra.__spread||function(){for(var r=[],$=0;$<arguments.length;$++)r=r.concat(xa(arguments[$]));return r},Ia=function(){function r(r,$){var e=this;void 0===r&&(r=[]),void 0===$&&($=0),this._counter=-1+$,this._map=new Map,r.forEach(function(r){return e.get(r)})}return r.prototype.get=function(r){return this._map.has(r)||(this._counter++,this._map.set(r,this._counter)),this._map.get(r)},r.prototype.map=function(r){return Array.from(this._map.entries()).map(function($){var e=xa($,2),t=e[0],n=e[1];return r(t,n)})},r}();function Ja(r){var $=r.globals,e=r.functions,t=r.preParsed,n=void 0!==t&&t,o=Object.entries(na).map(function(r){var $=xa(r,2),e=$[0],t=$[1];return{args:new Array(t.length).fill(null).map(function(r){return q.f64}),returns:[q.f64],name:e}}),a=new Ia(Array.from($)),d=new Ia([],$.size),i=new Ia(o.map(function(r){return r.name})),p=Object.entries(e).map(function(r){var e=xa(r,2),t=e[0],o=e[1],p=n?o:Ea(o);if("string"==typeof p)throw new Error("Got passed unparsed code without setting the preParsed flag");var c=[];return{binary:C(p,{resolveVar:function(r){return $.has(r)?a.get(r):d.get(r)},resolveLocal:function(r){return c.push(r),c.length-1},resolveLocalFunc:function(r){if(null==na[r]&&null==ua[r])return null;var $=i.get(r);return j.call($)},rawSource:o}),exportName:t,args:[],returns:[],localVariables:c}}),c=i.map(function(r){return r}).slice(o.length).map(function(r){var $=ua[r];if(null==$)throw new Error("Undefined local function \""+r+"\"");return $}),u=function(r){return J(r.args,["|"],r.returns).join("-")},m=[],s=new Map;function X(r){var $=u(r),e=s.get($);if(null==e)throw new Error("Failed to get a type index for key "+$);return e}J(o,c,p).forEach(function(r){var $=u(r);s.has($)||(m.push(J([_a],ga(r.args),ga(r.returns))),s.set($,m.length-1))});var D=J(Array.from($).map(function(r){return J(ma("js"),ma(r),[ab,q.f64,Fa.var])}),o.map(function(r,$){var e=X(r);return J(ma("imports"),ma(r.name),J([bb],G(e)))})),l=J(c,p).map(function(r){var $=X(r);return G($)}),_=[J([1],G(eb),G(eb))],v=d.map(function(){return J([q.f64,Fa.var],j.f64_const(0),[j.end])}),f=J(p).map(function(r,$){var e=$+o.length+c.length;return J(ma(r.exportName),[$a.FUNC],G(e))}),E=J(c,p).map(function(r){var $,e=(null!==($=r.localVariables)&&void 0!==$?$:[]).map(function(r){return J(G(1),[r])});return ga(J(ga(e),r.binary,[j.end]))});return new Uint8Array(J(Ya,Za,da(ca.TYPE,m),da(ca.IMPORT,D),da(ca.FUNC,l),da(ca.MEMORY,_),da(ca.GLOBAL,v),da(ca.EXPORT,f),da(ca.CODE,E)))}ra.compileModule=Ja;var ha={};var Fb=ha&&ha.__assign||function(){return(Fb=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var i in r=arguments[t])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)},Gb=ha&&ha.__awaiter||function(e,r,t,n){return new(t||(t=Promise))(function(i,o){function a(e){try{s(n.next(e))}catch(r){o(r)}}function c(e){try{s(n.throw(e))}catch(r){o(r)}}function s(e){var r;e.done?i(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(a,c)}s((n=n.apply(e,r||[])).next())})},Hb=ha&&ha.__generator||function(e,r){var t,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=r.call(e,a)}catch(c){o=[6,c],n=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}};function hb(e){var r=e.globals,t=e.functions;return Gb(this,void 0,void 0,function(){var e,n,i;return Hb(this,function(o){switch(o.label){case 0:return e=Ja({globals:new Set(Object.keys(r)),functions:t}),[4,WebAssembly.compile(e)];case 1:return n=o.sent(),i={js:Fb({},r),imports:na},[4,WebAssembly.instantiate(n,i)];case 2:return[2,o.sent()];}})})}ha.loadModule=hb;ia.loadModule=hb,ia.shims=na,ia.compileModule=Ja,ia.parse=Ea;if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=ia}else if(typeof define==="function"&&define.amd){define(function(){return ia})}})(); | ||
(function () {var ia={};var oa={};function Ja(r,e){var o={destCol:1,srcCol:1,srcLine:1};r.forEach(function(r){r.destCol>e||(o=r)});var t=e-o.destCol;return{column:o.srcCol+t,line:o.srcLine}}function mb(r){for(var e=[],o=1,t="",s=0,$=!1,c=!1,n=!1,l=0;l<r.length;l++){var p=r[l];if(n){var i=t.length+1,a=l-s+1;e.push({destCol:i,srcCol:a,srcLine:o}),n=!1}"\n"===p?($=!1,o++,s=l+1,n=!0):"\r"===p&&"\n"===r[l+1]?($=!1,o++,s=++l+1,n=!0):c&&"*"===p&&"/"===r[l+1]?(c=!1,l++,n=!0):"\\"===p&&"\\"===r[l+1]||"/"===p&&"/"===r[l+1]?($=!0,l++):"/"===p&&"*"===r[l+1]?(c=!0,l++):$||c||(t+=p)}return[t,e]}var ja,ka,nb={},F=nb={};function ya(){throw new Error("setTimeout has not been defined")}function za(){throw new Error("clearTimeout has not been defined")}function Ka($){if(ja===setTimeout)return setTimeout($,0);if((ja===ya||!ja)&&setTimeout)return ja=setTimeout,setTimeout($,0);try{return ja($,0)}catch(e){try{return ja.call(null,$,0)}catch(e){return ja.call(this,$,0)}}}function ob($){if(ka===clearTimeout)return clearTimeout($);if((ka===za||!ka)&&clearTimeout)return ka=clearTimeout,clearTimeout($);try{return ka($)}catch(e){try{return ka.call(null,$)}catch(e){return ka.call(this,$)}}}!function(){try{ja="function"==typeof setTimeout?setTimeout:ya}catch($){ja=ya}try{ka="function"==typeof clearTimeout?clearTimeout:za}catch($){ka=za}}();var pa,ga=[],Aa=!1,La=-1;function pb(){Aa&&pa&&(Aa=!1,pa.length?ga=pa.concat(ga):La=-1,ga.length&&Ma())}function Ma(){if(!Aa){var $=Ka(pb);Aa=!0;for(var e=ga.length;e;){for(pa=ga,ga=[];++La<e;)pa&&pa[La].run();La=-1,e=ga.length}pa=null,Aa=!1,ob($)}}function Na($,e){this.fun=$,this.array=e}function U(){}F.nextTick=function($){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];ga.push(new Na($,e)),1!==ga.length||Aa||Ka(Ma)},Na.prototype.run=function(){this.fun.apply(null,this.array)},F.title="browser",F.env={},F.argv=[],F.version="",F.versions={},F.on=U,F.addListener=U,F.once=U,F.off=U,F.removeListener=U,F.removeAllListeners=U,F.emit=U,F.prependListener=U,F.prependOnceListener=U,F.listeners=function($){return[]},F.binding=function($){throw new Error("process.binding is not supported")},F.cwd=function(){return"/"},F.chdir=function($){throw new Error("process.chdir is not supported")},F.umask=function(){return 0};var qb=function(){var t={exports:this},i=function(){var t=function(t,e,i,s){for(i=i||{},s=t.length;s--;i[t[s]]=e);return i},e=[1,18],i=[1,7],s=[1,19],n=[1,20],r=[1,14],h=[1,15],o=[1,16],a=[1,33],c=[1,31],l=[1,23],y=[1,22],u=[1,24],p=[1,25],_=[1,26],f=[1,27],g=[1,28],m=[1,29],E=[1,30],k=[5,8,15,18,20,28,29,32,33,34,35,36,37,38],I=[5,15,18],b=[5,12,15,17,18,24,25,28,29,30],S=[1,57],d=[5,8,12,15,17,18,24,25,28,29,30],N=[15,18],O=[5,8,15,18,28,29,38],$=[5,8,15,18,28,29,32,33,38],x=[5,8,15,18,28,29,32,33,34,37,38],A=[5,8,15,18,28,29,32,33,34,35,36,37,38],R=[5,8,15,18],v=[5,8,15,18,20,22,28,29,32,33,34,35,36,37,38],T={trace:function(){},yy:{},symbols_:{error:2,SCRIPT:3,expression:4,EOF:5,expressionsOptionalTrailingSemi:6,separator:7,";":8,expressions:9,EXPRESSION_BLOCK:10,IDENTIFIER:11,IDENTIFIER_TOKEN:12,argument:13,arguments:14,",":15,FUNCTION_CALL:16,"(":17,")":18,LOGICAL_EXPRESSION:19,LOGICAL_OPERATOR_TOKEN:20,ASSIGNMENT:21,ASSIGNMENT_OPERATOR_TOKEN:22,number:23,DIGITS_TOKEN:24,".":25,NUMBER_LITERAL:26,UNARY_EXPRESSION:27,"-":28,"+":29,"!":30,BINARY_EXPRESSION:31,"*":32,"/":33,"%":34,"&":35,"|":36,"^":37,COMPARISON_TOKEN:38,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",8:";",12:"IDENTIFIER_TOKEN",15:",",17:"(",18:")",20:"LOGICAL_OPERATOR_TOKEN",22:"ASSIGNMENT_OPERATOR_TOKEN",24:"DIGITS_TOKEN",25:".",28:"-",29:"+",30:"!",32:"*",33:"/",34:"%",35:"&",36:"|",37:"^",38:"COMPARISON_TOKEN"},productions_:[0,[3,2],[3,2],[3,1],[7,1],[7,2],[9,2],[9,3],[6,1],[6,2],[10,1],[11,1],[13,1],[13,1],[14,1],[14,3],[16,3],[16,4],[19,3],[21,3],[21,3],[23,1],[23,2],[23,3],[23,2],[23,1],[26,1],[27,2],[27,2],[27,2],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[31,3],[4,1],[4,1],[4,3],[4,1],[4,1],[4,1],[4,1],[4,1],[4,3]],performAction:function(t,e,i,s,n,r,h){var o=r.length-1;switch(n){case 1:return{type:"SCRIPT",body:[r[o-1]],loc:this._$};case 2:return{type:"SCRIPT",body:r[o-1],loc:this._$};case 3:return{type:"SCRIPT",body:[],loc:this._$};case 6:this.$=[r[o-1]];break;case 7:this.$=r[o-2].concat([r[o-1]]);break;case 8:this.$=r[o];break;case 9:this.$=r[o-1].concat([r[o]]);break;case 10:this.$={type:"EXPRESSION_BLOCK",body:r[o],loc:this._$};break;case 11:this.$={type:"IDENTIFIER",value:r[o].toLowerCase(),loc:this._$};break;case 14:this.$=[r[o]];break;case 15:this.$=r[o-2].concat([r[o]]);break;case 16:this.$={type:"CALL_EXPRESSION",callee:r[o-2],arguments:[],loc:this._$};break;case 17:this.$={type:"CALL_EXPRESSION",callee:r[o-3],arguments:r[o-1],loc:this._$};break;case 18:this.$={type:"LOGICAL_EXPRESSION",left:r[o-2],right:r[o],operator:r[o-1],loc:this._$};break;case 19:case 20:this.$={type:"ASSIGNMENT_EXPRESSION",left:r[o-2],operator:r[o-1],right:r[o],loc:this._$};break;case 21:this.$=Number(r[o]);break;case 22:this.$=Number(r[o-1]);break;case 23:this.$=Number(r[o-2]+r[o-1]+r[o]);break;case 24:this.$=Number("0"+r[o-1]+r[o]);break;case 25:this.$=0;break;case 26:this.$={type:"NUMBER_LITERAL",value:r[o],loc:this._$};break;case 27:case 28:case 29:this.$={type:"UNARY_EXPRESSION",value:r[o],operator:r[o-1],loc:this._$};break;case 30:case 31:case 32:case 33:case 34:case 35:case 36:case 37:case 38:this.$={type:"BINARY_EXPRESSION",left:r[o-2],right:r[o],operator:r[o-1],loc:this._$};break;case 41:case 47:this.$=r[o-1];}},table:[{3:1,4:2,5:[1,4],6:3,9:13,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{1:[3]},{5:[1,21],7:32,8:a,20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E},{5:[1,34]},{1:[2,3]},t(k,[2,39]),t(k,[2,40]),{4:35,6:37,9:13,10:36,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(k,[2,42]),t(k,[2,43]),t(k,[2,44],{22:[1,38]}),t(k,[2,45],{17:[1,40],22:[1,39]}),t(k,[2,46]),t(I,[2,8],{31:5,27:6,26:8,21:9,16:10,11:11,19:12,23:17,4:41,12:e,17:i,24:s,25:n,28:r,29:h,30:o}),{4:42,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:43,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:44,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(k,[2,26]),t([5,8,15,17,18,20,22,28,29,32,33,34,35,36,37,38],[2,11]),t(k,[2,21],{25:[1,45]}),t(k,[2,25],{24:[1,46]}),{1:[2,1]},{4:47,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:48,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:49,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:50,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:51,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:52,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:53,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:54,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:55,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:56,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(b,[2,6],{8:S}),t(d,[2,4]),{1:[2,2]},{7:32,8:a,18:[1,58],20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E},{18:[1,59]},t(N,[2,10]),{4:60,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:61,11:11,12:e,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},{4:65,6:37,9:13,10:66,11:11,12:e,13:64,14:63,16:10,17:i,18:[1,62],19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(I,[2,9],{7:67,8:a,20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(O,[2,27],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t(O,[2,28],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t(O,[2,29],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t(k,[2,22],{24:[1,68]}),t(k,[2,24]),t(O,[2,30],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t(O,[2,31],{20:c,32:u,33:p,34:_,35:f,36:g,37:m}),t($,[2,32],{20:c,34:_,35:f,36:g,37:m}),t($,[2,33],{20:c,34:_,35:f,36:g,37:m}),t(x,[2,34],{20:c,35:f,36:g}),t(A,[2,35],{20:c}),t(A,[2,36],{20:c}),t(x,[2,37],{20:c,35:f,36:g}),t(R,[2,38],{20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(k,[2,18]),t(d,[2,5]),t(k,[2,41]),t(k,[2,47]),t(R,[2,20],{20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(R,[2,19],{20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(v,[2,16]),{15:[1,70],18:[1,69]},t(N,[2,14]),t(N,[2,12],{7:32,8:a,20:c,28:l,29:y,32:u,33:p,34:_,35:f,36:g,37:m,38:E}),t(N,[2,13]),t(b,[2,7],{8:S}),t(k,[2,23]),t(v,[2,17]),{4:65,6:37,9:13,10:66,11:11,12:e,13:71,16:10,17:i,19:12,21:9,23:17,24:s,25:n,26:8,27:6,28:r,29:h,30:o,31:5},t(N,[2,15])],defaultActions:{4:[2,3],21:[2,1],34:[2,2]},parseError:function(t,e){if(!e.recoverable){var i=new Error(t);throw i.hash=e,i}this.trace(t)},parse:function(t){var e=this,i=[0],s=[null],n=[],r=this.table,h="",o=0,a=0,c=0,l=n.slice.call(arguments,1),y=Object.create(this.lexer),u={yy:{}};for(var p in this.yy)Object.prototype.hasOwnProperty.call(this.yy,p)&&(u.yy[p]=this.yy[p]);y.setInput(t,u.yy),u.yy.lexer=y,u.yy.parser=this,void 0===y.yylloc&&(y.yylloc={});var _=y.yylloc;n.push(_);var f=y.options&&y.options.ranges;"function"==typeof u.yy.parseError?this.parseError=u.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var g,m,E,k,I,b,S,d,N,O=function(){var t;return"number"!=typeof(t=y.lex()||1)&&(t=e.symbols_[t]||t),t},$={};;){if(E=i[i.length-1],this.defaultActions[E]?k=this.defaultActions[E]:(null==g&&(g=O()),k=r[E]&&r[E][g]),void 0===k||!k.length||!k[0]){var x="";for(b in N=[],r[E])this.terminals_[b]&&b>2&&N.push("'"+this.terminals_[b]+"'");x=y.showPosition?"Parse error on line "+(o+1)+":\n"+y.showPosition()+"\nExpecting "+N.join(", ")+", got '"+(this.terminals_[g]||g)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==g?"end of input":"'"+(this.terminals_[g]||g)+"'"),this.parseError(x,{text:y.match,token:this.terminals_[g]||g,line:y.yylineno,loc:_,expected:N})}if(k[0]instanceof Array&&k.length>1)throw new Error("Parse Error: multiple actions possible at state: "+E+", token: "+g);switch(k[0]){case 1:i.push(g),s.push(y.yytext),n.push(y.yylloc),i.push(k[1]),g=null,m?(g=m,m=null):(a=y.yyleng,h=y.yytext,o=y.yylineno,_=y.yylloc,c>0&&c--);break;case 2:if(S=this.productions_[k[1]][1],$.$=s[s.length-S],$._$={first_line:n[n.length-(S||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(S||1)].first_column,last_column:n[n.length-1].last_column},f&&($._$.range=[n[n.length-(S||1)].range[0],n[n.length-1].range[1]]),void 0!==(I=this.performAction.apply($,[h,a,o,u.yy,k[1],s,n].concat(l))))return I;S&&(i=i.slice(0,-1*S*2),s=s.slice(0,-1*S),n=n.slice(0,-1*S)),i.push(this.productions_[k[1]][0]),s.push($.$),n.push($._$),d=r[i[i.length-2]][i[i.length-1]],i.push(d);break;case 3:return!0;}}return!0}},P={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===s.length?this.yylloc.first_column:0)+s[s.length-i.length].length-i[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var i,s,n;if(this.options.backtrack_lexer&&(n={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(n.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],i=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),i)return i;if(this._backtrack){for(var r in n)this[r]=n[r];return!1}return!1},next:function(){if(this.done)return this.EOF;var t,e,i,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),r=0;r<n.length;r++)if((i=this._input.match(this.rules[n[r]]))&&(!e||i[0].length>e[0].length)){if(e=i,s=r,this.options.backtrack_lexer){if(!1!==(t=this.test_match(i,n[r])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,n[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,i,s){switch(i){case 0:break;case 1:return 24;case 2:return 38;case 3:return 22;case 4:return 20;case 5:return 12;case 6:return 5;case 7:return e.yytext[0];}},rules:[/^(?:\s+)/,/^(?:[0-9]+)/,/^(?:(==|!=|<=|>=|<|>))/,/^(?:[+\-*/%]?=)/,/^(?:(\&\&)|\|\|)/,/^(?:[a-zA-Z_][a-zA-Z0-9._]*)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7],inclusive:!0}}};function L(){this.yy={}}return T.lexer=P,L.prototype=T,T.Parser=L,new L}();return"undefined"!=typeof require&&void 0!==this&&(this.parser=i,this.Parser=i.Parser,this.parse=function(){return i.parse.apply(i,arguments)},this.main=function(){},void 0!==t&&require.main===t&&this.main(nb.argv.slice(1))),t.exports}.call({});var rb={};rb={parse:qb.parse};function Oa(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function Pa(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?Oa(Object(t),!0).forEach(function(r){Ba(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Oa(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function Ba(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var sb={ASSIGNMENT_EXPRESSION:[{type:"NODE",key:"right"}],SCRIPT:[{type:"ARRAY",key:"body"}],EXPRESSION_BLOCK:[{type:"ARRAY",key:"body"}],UNARY_EXPRESSION:[{type:"NODE",key:"value"}],NUMBER_LITERAL:[],IDENTIFIER:[],CALL_EXPRESSION:[{type:"ARRAY",key:"arguments"},{type:"NODE",key:"callee"}],BINARY_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}],LOGICAL_EXPRESSION:[{type:"NODE",key:"left"},{type:"NODE",key:"right"}]};function Ca(e,r){var t=sb[e.type],n=e;if(null==t)throw new Error("Unknown children definition for ".concat(e.type));return t.forEach(function(t){if("NODE"===t.type){var o=e[t.key],$=Ca(o,r);$!==o&&(n=Pa({},n,Ba({},t.key,$)))}else if("ARRAY"===t.type){var p=e[t.key],y=p.map(function(e){return Ca(e,r)});p.some(function(e,r){return e!==y[r]})&&(n=Pa({},n,Ba({},t.key,y)))}}),r(n)}var qa={};var K={},Qa=K&&K.__read||function(r,t){var n="function"==typeof Symbol&&r[Symbol.iterator];if(!n)return r;var e,$,o=n.call(r),a=[];try{for(;(void 0===t||t-->0)&&!(e=o.next()).done;)a.push(e.value)}catch(p){$={error:p}}finally{try{e&&!e.done&&(n=o.return)&&n.call(o)}finally{if($)throw $.error}}return a},tb=K&&K.__spread||function(){for(var r=[],t=0;t<arguments.length;t++)r=r.concat(Qa(arguments[t]));return r};function Ra(r,t){for(var n=[],e=0;e<r.length;e++){n.push(r[e]),e===r.length-1||n.push(t)}return n}function wa(r){var t=[];return r.forEach(function(r){t.push.apply(t,tb(r))}),t}K.arrayJoin=Ra,K.flatten=wa;var Sa=function(r){return[].concat.apply([],r)};function Ta(r,t){return new Array(r).fill(null).map(function(r,n){return t(n)})}function Da(r,t){return new Array(r).fill(t).join("")}K.flattenTwice=Sa,K.times=Ta,K.repeat=Da;var Ua=function(){function r(){this._list=[]}return r.prototype.get=function(r,t){var n=this._list.findIndex(function(n){var e=Qa(n,2),$=e[0],o=e[1];return $===r&&o===t});return-1===n?(this._list.push([r,t]),this._list.length-1):n},r.prototype.size=function(){return this._list.length},r}();function Va(r){if(0===r.length)throw new Error("Cannot format an empty list");if(1===r.length)return r[0];var t=r.map(function(r){return"\""+r+"\""}),n=t.pop();return t.join(", ")+" and "+n}K.ScopedIdMap=Ua,K.formatList=Va;var Wa=qa&&qa.__extends||function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}();function Xa(r,t,e){void 0===e&&(e=1);var o=Math.max(r.first_line-1-e,0),n=r.last_line+e,$=t.split("\n").slice(o,n).map(function(t,e){var n=e+o+1;return(n>=r.first_line&&n<=r.last_line?">":" ")+" "+n+" | "+t});if(r.first_line===r.last_line){var i=Da(r.first_column," "),p=Da(r.last_column-r.first_column,"^"),a=r.first_line-o;$.splice(a,0," | "+i+p)}return $.join("\n")}qa.printLoc=Xa;var Ya=function(r){function t(t,e,o){var n=r.call(this,t)||this;return n.sourceContext=Xa(e,o),n.loc=e,n}return Wa(t,r),t}(Error),ub=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return Wa(t,r),t}(Ya);function ca(r,t,e){return new ub(r,t,e)}function Z(r,t,e){return new Ya(r,t,e)}qa.createUserError=ca,qa.createCompilerError=Z;var Za=oa&&oa.__assign||function(){return(Za=Object.assign||function(r){for(var e,$=1,t=arguments.length;$<t;$++)for(var o in e=arguments[$])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)},vb=oa&&oa.__read||function(r,e){var $="function"==typeof Symbol&&r[Symbol.iterator];if(!$)return r;var t,o,a=$.call(r),n=[];try{for(;(void 0===e||e-->0)&&!(t=a.next()).done;)n.push(t.value)}catch(i){o={error:i}}finally{try{t&&!t.done&&($=a.return)&&$.call(a)}finally{if(o)throw o.error}}return n};function $a(r,e){var $=Ja(e,r.first_column),t=Ja(e,r.last_column);return{first_column:$.column,last_column:t.column,first_line:$.line,last_line:t.line}}function Ea(r){var e=vb(mb(r),2),$=e[0],t=e[1];try{var o=rb.parse($);return Ca(o,function(e){if(1!==e.loc.first_line||1!=e.loc.last_line)throw Z("Unexpected multiline",e.loc,r);return Za(Za({},e),{loc:$a(e.loc,t)})})}catch(a){if(null==a.hash)throw a;throw ca("Parse Error: "+a.message.split("\n")[3],$a(a.hash.loc,t),r)}}oa.parse=Ea;var ra={};var sa={};var B={};function wb(a,t){var o,r,h,p=52,M=64-p-1,w=(1<<M)-1,$=w>>1,e=23===p?Math.pow(2,-24)-Math.pow(2,-77):0,i=0,c=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(r=isNaN(t)?1:0,o=w):(o=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-o))<1&&(o--,h*=2),(t+=o+$>=1?e/h:e*Math.pow(2,1-$))*h>=2&&(o++,h/=2),o+$>=w?(r=0,o=w):o+$>=1?(r=(t*h-1)*Math.pow(2,p),o+=$):(r=t*Math.pow(2,$-1)*Math.pow(2,p),o=0));p>=8;a[0+i]=255&r,i+=1,r/=256,p-=8);for(o=o<<p|r,M+=p;M>0;a[0+i]=255&o,i+=1,o/=256,M-=8);a[0+i-1]|=128*c}var xb=B&&B.__read||function($,r){var e="function"==typeof Symbol&&$[Symbol.iterator];if(!e)return $;var x,t,o=e.call($),n=[];try{for(;(void 0===r||r-->0)&&!(x=o.next()).done;)n.push(x.value)}catch(Y){t={error:Y}}finally{try{x&&!x.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return n},H=B&&B.__spread||function(){for(var $=[],r=0;r<arguments.length;r++)$=$.concat(xb(arguments[r]));return $},_a=[0,97,115,109];B.MAGIC=_a;var ab=[1,0,0,0];B.WASM_VERSION=ab;var xa=1e-5;B.EPSILON=xa;var da={TYPE:1,IMPORT:2,FUNC:3,MEMORY:5,GLOBAL:6,EXPORT:7,CODE:10};B.SECTION=da;var bb={FUNC:0,TABLE:1,MEMORY:2,GLOBAL:3};B.EXPORT_TYPE=bb;var j={loop:function($){return[3,$]},if:function($){return[4,$]},else:5,end:11,br_if:function($){return H([13],G($))},call:function($){return H([16],G($))},drop:26,select:27,local_get:function($){return H([32],G($))},local_set:function($){return H([33],G($))},local_tee:function($){return H([34],G($))},global_get:function($){return H([35],G($))},global_set:function($){return H([36],G($))},f64_load:function($,r){return H([43],G($),G(r))},f64_store:function($,r){return H([57],G($),G(r))},i32_const:function($){return H([65],gb($))},f64_const:function($){return H([68],fb($))},i32_eqz:69,i32_ne:71,i32_lt_s:72,i32_gt_s:74,i32_le_s:76,i32_le_u:77,i32_ge_s:78,f64_eq:97,f64_ne:98,f64_lt:99,f64_gt:100,f64_le:101,f64_ge:102,i32_add:106,i32_sub:107,i32_mul:108,i32_and:113,i32_or:114,i64_rem_s:129,i64_and:131,i64_or:132,f64_abs:153,f64_neg:154,f64_floor:156,f64_sqrt:159,f64_add:160,f64_sub:161,f64_mul:162,f64_div:163,f64_min:164,f64_max:165,i32_trunc_f64_s:170,i64_trunc_s_f64:176,f64_convert_i64_s:185,f64_convert_i32_s:183};B.op=j;var q={i32:127,i64:126,f32:125,f64:124};B.VAL_TYPE=q;var Fa={const:0,var:1};B.MUTABILITY=Fa;var aa={void:64,i32:127,i64:126,f32:125,f64:124};B.BLOCK=aa;var cb=96;B.FUNCTION_TYPE=cb;var yb=2;B.MEMORY_IDX=yb;var db=3;B.GLOBAL_TYPE=db;var eb=0;B.TYPE_IDX=eb;var la=H([j.f64_abs],j.f64_const(xa),[j.f64_lt]);B.IS_ZEROISH=la;var Q=H([j.f64_abs],j.f64_const(xa),[j.f64_gt]);function fb($){var r=new Uint8Array(8);return wb(r,$),r}B.IS_NOT_ZEROISH=Q,B.encodef64=fb;var ma=function($){return H([$.length],$.split("").map(function($){return $.charCodeAt(0)}))};function G($){var r=[];do{var e=127&$;0!==($>>>=7)&&(e|=128),r.push(e)}while(0!==$);return r}function gb($){for(var r=[],e=0,x=Math.ceil(Math.log2(Math.abs($))),t=$<0,o=!0;o;)e=127&$,$>>=7,t&&($|=-(1<<x-7)),0==$&&0==(64&e)||-1==$&&64==(64&e)?o=!1:e|=128,r.push(e);return r}B.encodeString=ma,B.unsignedLEB128=G,B.signedLEB128=gb;var ha=function($){return H(G($.length),Sa($))};function ea($,r){return 0===r.length?[]:H([$],ha(ha(r)))}B.encodeVector=ha,B.encodeSection=ea;var zb=1e-5,ta={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,rand:function(a){return Math.floor(Math.random()*a)},pow:Math.pow,log:Math.log,log10:Math.log10,exp:Math.exp,sigmoid:function(a,t){var o=1+Math.exp(-a*t);return Math.abs(o)>zb?1/o:0},floor:Math.floor,ceil:Math.ceil};var ua={};var Ab=65536,Bb=8,Cb=2,Ga=8388608;var hb=Math.ceil(Ga*Bb*Cb/Ab);var Db=ua&&ua.__read||function($,o){var r="function"==typeof Symbol&&$[Symbol.iterator];if(!r)return $;var e,n,t=r.call($),p=[];try{for(;(void 0===o||o-->0)&&!(e=t.next()).done;)p.push(e.value)}catch(i){n={error:i}}finally{try{e&&!e.done&&(r=t.return)&&r.call(t)}finally{if(n)throw n.error}}return p},fa=ua&&ua.__spread||function(){for(var $=[],o=0;o<arguments.length;o++)$=$.concat(Db(arguments[o]));return $},va={sqr:{args:[q.f64],returns:[q.f64],binary:fa(j.local_get(0),j.local_get(0),[j.f64_mul])},bor:{args:[q.f64,q.f64],returns:[q.f64],binary:fa(j.local_get(0),Q,j.local_get(1),Q,[j.i32_or],j.i32_const(0),[j.i32_ne,j.f64_convert_i32_s])},band:{args:[q.f64,q.f64],returns:[q.f64],binary:fa(j.local_get(0),Q,j.local_get(1),Q,[j.i32_and],j.i32_const(0),[j.i32_ne,j.f64_convert_i32_s])},sign:{args:[q.f64],returns:[q.f64],binary:fa(j.f64_const(0),j.local_get(0),[j.f64_lt],j.local_get(0),j.f64_const(0),[j.f64_lt,j.i32_sub,j.f64_convert_i32_s])},mod:{args:[q.f64,q.f64],returns:[q.f64],binary:fa(j.local_get(0),[j.i64_trunc_s_f64],j.local_get(1),[j.i64_trunc_s_f64,j.i64_rem_s,j.f64_convert_i64_s])},bitwiseOr:{args:[q.f64,q.f64],returns:[q.f64],binary:fa(j.local_get(0),[j.i64_trunc_s_f64],j.local_get(1),[j.i64_trunc_s_f64,j.i64_or,j.f64_convert_i64_s])},bitwiseAnd:{args:[q.f64,q.f64],returns:[q.f64],binary:fa(j.local_get(0),[j.i64_trunc_s_f64],j.local_get(1),[j.i64_trunc_s_f64,j.i64_and,j.f64_convert_i64_s])},_getBufferIndex:{args:[q.f64],returns:[q.i32],localVariables:[q.f64,q.i32],binary:fa(j.f64_const(xa),j.local_get(0),[j.f64_add],j.local_tee(1),[j.i32_trunc_f64_s],j.local_set(2),j.i32_const(-1),j.local_get(2),j.i32_const(8),[j.i32_mul],j.local_get(2),j.i32_const(0),[j.i32_lt_s],j.local_get(2),j.i32_const(Ga-1),[j.i32_gt_s,j.i32_or,j.select])}};ua.localFuncMap=va;var ib=sa&&sa.__read||function($,r){var o="function"==typeof Symbol&&$[Symbol.iterator];if(!o)return $;var e,t,p=o.call($),i=[];try{for(;(void 0===r||r-->0)&&!(e=p.next()).done;)i.push(e.value)}catch(a){t={error:a}}finally{try{e&&!e.done&&(o=p.return)&&o.call(p)}finally{if(t)throw t.error}}return i},z=sa&&sa.__spread||function(){for(var $=[],r=0;r<arguments.length;r++)$=$.concat(ib(arguments[r]));return $};function Ha($,r){var o=$.map(function($,o){return C($,r)});return wa(Ra(o,[j.drop]))}function Eb($,r){var o=C($,r);return z(j.loop(aa.void),o,Q,j.br_if(0),[j.end],j.f64_const(0))}function Fb($,r,o){var e=C(r,o),t=o.resolveLocal(q.f64);return z(C($,o),j.local_set(t),j.loop(aa.void),e,[j.drop],j.local_get(t),j.f64_const(1),[j.f64_sub],j.local_tee(t),Q,j.br_if(0),[j.end],j.f64_const(0))}function Gb($,r,o,e){return z(C($,e),Q,j.if(aa.f64),C(r,e),[j.else],C(o,e),[j.end])}function jb($){switch($){case"gmegabuf":return 8*Ga;case"megabuf":return 0;}}function Hb($,r){var o={"+=":[j.f64_add],"-=":[j.f64_sub],"*=":[j.f64_mul],"/=":[j.f64_div],"%=":r.resolveFunc("mod"),"=":null}[$.operator];if(void 0===o)throw Z("Unknown assignment operator \""+$.operator+"\"",$.loc,r.rawSource);return o}function C($,r){switch($.type){case"SCRIPT":var o=$.body.map(function($,o){return z(C($,r),[j.drop])});return wa(o);case"EXPRESSION_BLOCK":return Ha($.body,r);case"BINARY_EXPRESSION":var e=C($.left,r),t=C($.right,r);if(null==(L={"+":[j.f64_add],"-":[j.f64_sub],"*":[j.f64_mul],"/":[j.f64_div],"%":r.resolveFunc("mod"),"|":r.resolveFunc("bitwiseOr"),"&":r.resolveFunc("bitwiseAnd"),"^":r.resolveFunc("pow"),"==":z([j.f64_sub],la,[j.f64_convert_i32_s]),"!=":z([j.f64_sub],Q,[j.f64_convert_i32_s]),"<":[j.f64_lt,j.f64_convert_i32_s],">":[j.f64_gt,j.f64_convert_i32_s],"<=":[j.f64_le,j.f64_convert_i32_s],">=":[j.f64_ge,j.f64_convert_i32_s]}[$.operator]))throw Z("Unknown binary expression operator "+$.operator,$.loc,r.rawSource);return z(e,t,L);case"CALL_EXPRESSION":var p=$.callee.value,i=$.arguments,a=function(o){if(i.length<o)throw ca("Too few arguments passed to `"+p+"()`. Expected "+o+" but only got "+i.length+".",$.loc,r.rawSource);if(i.length>o)throw ca("Too many arguments passed to `"+p+"()`. Expected "+o+" but got "+i.length+".",i[o].loc,r.rawSource)},m=wa($.arguments.map(function($){return C($,r)}));switch(p){case"exec2":return a(2),Ha($.arguments,r);case"exec3":return a(3),Ha($.arguments,r);case"if":a(3);var V=ib($.arguments,3);return Gb(V[0],V[1],V[2],r);case"while":return a(1),Eb($.arguments[0],r);case"loop":return a(2),Fb($.arguments[0],$.arguments[1],r);case"megabuf":case"gmegabuf":a(1);var n=r.resolveLocal(q.i32);return z(C($.arguments[0],r),r.resolveFunc("_getBufferIndex"),j.local_tee(n),j.i32_const(-1),[j.i32_ne],j.if(aa.f64),j.local_get(n),j.f64_load(3,jb(p)),[j.else],j.f64_const(0),[j.end]);case"assign":a(2);var W=$.arguments[0];if("IDENTIFIER"!=W.type)throw ca("Expected the first argument of `assign()` to be an identifier.",W.loc,r.rawSource);var s=r.resolveVar(W.value);return z(C($.arguments[1],r),j.global_set(s),j.global_get(s));case"abs":return a(1),z(m,[j.f64_abs]);case"sqrt":return a(1),z(m,[j.f64_sqrt]);case"int":return a(1),z(m,[j.f64_floor]);case"min":return a(2),z(m,[j.f64_min]);case"max":return a(2),z(m,[j.f64_max]);case"above":return a(2),z(m,[j.f64_gt,j.f64_convert_i32_s]);case"below":return a(2),z(m,[j.f64_lt,j.f64_convert_i32_s]);case"equal":return a(2),z(m,[j.f64_sub],la,[j.f64_convert_i32_s]);case"bnot":return a(1),z(m,la,[j.f64_convert_i32_s]);}var l=r.resolveFunc(p);if(null==l||p.startsWith("_"))throw ca("\""+p+"\" is not defined.",$.callee.loc,r.rawSource);if(null!=ta[p])a(ta[p].length);else{if(null==va[p])throw Z("Missing arity information for the function `"+p+"()`",$.callee.loc,r.rawSource);a(va[p].args.length)}return z(m,l);case"ASSIGNMENT_EXPRESSION":e=$.left;var _=C($.right,r),c=Hb($,r);if("IDENTIFIER"===e.type){s=r.resolveVar(e.value);var u=j.global_get(s),f=j.global_set(s);return null===c?z(_,f,u):z(u,_,c,f,u)}if("CALL_EXPRESSION"!==e.type)throw Z("Unexpected left hand side type for assignment: "+e.type,$.loc,r.rawSource);var v=r.resolveLocal(q.i32);if(1!==e.arguments.length)throw ca("Expected 1 argument when assinging to a buffer but got "+e.arguments.length+".",0===e.arguments.length?e.loc:e.arguments[1].loc,r.rawSource);var d=e.callee.value;if("gmegabuf"!==d&&"megabuf"!==d)throw ca("The only function calls which may be assigned to are `gmegabuf()` and `megabuf()`.",e.callee.loc,r.rawSource);var g=jb(d);if(null===c){var E=r.resolveLocal(q.i32),S=r.resolveLocal(q.f64);return z(_,j.local_set(S),C(e.arguments[0],r),r.resolveFunc("_getBufferIndex"),j.local_tee(E),j.i32_const(0),[j.i32_lt_s],j.if(aa.f64),j.f64_const(0),[j.else],j.local_get(E),j.local_tee(v),j.local_get(S),j.f64_store(3,g),j.local_get(S),[j.end])}n=r.resolveLocal(q.i32);var h=r.resolveLocal(q.i32),I=r.resolveLocal(q.f64),x=r.resolveLocal(q.f64);return z(_,j.local_set(I),C(e.arguments[0],r),r.resolveFunc("_getBufferIndex"),j.local_tee(n),j.i32_const(-1),[j.i32_ne],j.local_tee(h),j.if(aa.f64),j.local_get(n),j.f64_load(3,g),[j.else],j.f64_const(0),[j.end],j.local_get(I),c,j.local_tee(x),j.local_get(h),j.if(aa.void),j.local_get(n),j.local_get(x),j.f64_store(3,g),[j.end]);case"LOGICAL_EXPRESSION":e=C($.left,r),t=C($.right,r);var w={"&&":{comparison:la,shortCircutValue:0},"||":{comparison:Q,shortCircutValue:1}}[$.operator];if(null==w)throw Z("Unknown logical expression operator "+$.operator,$.loc,r.rawSource);var O=w.comparison,b=w.shortCircutValue;return z(e,O,j.if(aa.f64),j.f64_const(b),[j.else],t,Q,[j.f64_convert_i32_s,j.end]);case"UNARY_EXPRESSION":var L,y=C($.value,r);if(null==(L={"-":[j.f64_neg],"+":[],"!":z(la,[j.f64_convert_i32_s])}[$.operator]))throw Z("Unknown logical unary operator "+$.operator,$.loc,r.rawSource);return z(y,L);case"IDENTIFIER":var R=$.value;return j.global_get(r.resolveVar(R));case"NUMBER_LITERAL":return j.f64_const($.value);default:throw Z("Unknown AST node type "+$.type,$.loc,r.rawSource);}}sa.emit=C;var na=ra&&ra.__read||function(r,$){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var o,t,n=e.call(r),d=[];try{for(;(void 0===$||$-->0)&&!(o=n.next()).done;)d.push(o.value)}catch(i){t={error:i}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return d},J=ra&&ra.__spread||function(){for(var r=[],$=0;$<arguments.length;$++)r=r.concat(na(arguments[$]));return r};function Ia(r){var $=r.pools,e=r.functions,o=r.preParsed,t=void 0!==o&&o;if(Object.keys($).includes("shims"))throw new Error("You may not name a pool \"shims\". \"shims\" is reserved for injected JavaScript functions.");var n=[];Object.entries($).forEach(function(r){var $=na(r,2),e=$[0];$[1].forEach(function(r){n.push([e,r])})});var d=new Ua;n.forEach(function(r){var $=na(r,2),e=$[0],o=$[1];d.get(e,o)});var i=Object.entries(ta).map(function(r){var $=na(r,2),e=$[0],o=$[1];return{args:new Array(o.length).fill(null).map(function(r){return q.f64}),returns:[q.f64],name:e}}),a=[],p=[];Object.entries(e).forEach(function(r){var e=na(r,2),o=e[0],n=e[1],c=n.pool,s=n.code;if(null==$[c]){var u=Object.keys($);if(0===u.length)throw new Error("The function \""+o+"\" was declared as using a variable pool named \""+c+"\" but no pools were defined.");throw new Error("The function \""+o+"\" was declared as using a variable pool named \""+c+"\" which is not among the variable pools defined. The defined variable pools are: "+Va(u)+".")}var X=t?s:Ea(s);if("string"==typeof X)throw new Error("Got passed unparsed code without setting the preParsed flag");var D=[],m=C(X,{resolveVar:function(r){return /reg\d\d/.test(r)?d.get("shims",r):d.get(c,r)},resolveLocal:function(r){return D.push(r),D.length-1},resolveFunc:function(r){var $=i.findIndex(function($){return $.name===r});if(-1!==$)return j.call($);if(null==va[r])return null;var e=a.indexOf(r);return-1===e&&(a.push(r),e=a.length-1),j.call(e+i.length)},rawSource:s});p.push({binary:m,exportName:o,args:[],returns:[],localVariables:D})});var c=a.map(function(r){var $=va[r];if(null==$)throw new Error("Undefined local function \""+r+"\"");return $}),s=function(r){return J(r.args,["|"],r.returns).join("-")},u=[],X=new Map;function D(r){var $=s(r),e=X.get($);if(null==e)throw new Error("Failed to get a type index for key "+$);return e}J(i,c,p).forEach(function(r){var $=s(r);X.has($)||(u.push(J([cb],ha(r.args),ha(r.returns))),X.set($,u.length-1))});var m=J(n.map(function(r){var $=na(r,2),e=$[0],o=$[1];return J(ma(e),ma(o),[db,q.f64,Fa.var])}),i.map(function(r,$){var e=D(r);return J(ma("shims"),ma(r.name),J([eb],G(e)))})),l=J(c,p).map(function(r){var $=D(r);return G($)}),f=[J([1],G(hb),G(hb))],v=d.size()-n.length,_=Ta(v,function(){return J([q.f64,Fa.var],j.f64_const(0),[j.end])}),h=J(p).map(function(r,$){var e=$+i.length+c.length;return J(ma(r.exportName),[bb.FUNC],G(e))}),E=J(c,p).map(function(r){var $,e=(null!==($=r.localVariables)&&void 0!==$?$:[]).map(function(r){return J(G(1),[r])});return ha(J(ha(e),r.binary,[j.end]))});return new Uint8Array(J(_a,ab,ea(da.TYPE,u),ea(da.IMPORT,m),ea(da.FUNC,l),ea(da.MEMORY,f),ea(da.GLOBAL,_),ea(da.EXPORT,h),ea(da.CODE,E)))}ra.compileModule=Ia;var ba={};var kb=ba&&ba.__assign||function(){return(kb=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i]);return r}).apply(this,arguments)},Ib=ba&&ba.__awaiter||function(r,e,t,n){return new(t||(t=Promise))(function(i,o){function a(r){try{s(n.next(r))}catch(e){o(e)}}function c(r){try{s(n.throw(r))}catch(e){o(e)}}function s(r){var e;r.done?i(r.value):(e=r.value,e instanceof t?e:new t(function(r){r(e)})).then(a,c)}s((n=n.apply(r,e||[])).next())})},Jb=ba&&ba.__generator||function(r,e){var t,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(r,a)}catch(c){o=[6,c],n=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}},Kb=ba&&ba.__read||function(r,e){var t="function"==typeof Symbol&&r[Symbol.iterator];if(!t)return r;var n,i,o=t.call(r),a=[];try{for(;(void 0===e||e-->0)&&!(n=o.next()).done;)a.push(n.value)}catch(c){i={error:c}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(i)throw i.error}}return a};function lb(r){var e=r.pools,t=r.functions;return Ib(this,void 0,void 0,function(){var r,n,i,o;return Jb(this,function(a){switch(a.label){case 0:return r={},Object.entries(e).forEach(function(e){var t=Kb(e,2),n=t[0],i=t[1];r[n]=new Set(Object.keys(i))}),n=Ia({pools:r,functions:t}),[4,WebAssembly.compile(n)];case 1:return i=a.sent(),o=kb(kb({},e),{shims:ta}),[4,WebAssembly.instantiate(i,o)];case 2:return[2,a.sent()];}})})}ba.loadModule=lb;ia.loadModule=lb,ia.shims=ta,ia.compileModule=Ia,ia.parse=Ea;if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=ia}else if(typeof define==="function"&&define.amd){define(function(){return ia})}})(); |
@@ -19,3 +19,6 @@ "use strict"; | ||
try { | ||
compiler_1.compileModule({ globals: new Set(), functions: { run: eel } }); | ||
compiler_1.compileModule({ | ||
pools: { main: new Set() }, | ||
functions: { run: { pool: "main", code: eel } } | ||
}); | ||
} | ||
@@ -22,0 +25,0 @@ catch (e) { |
@@ -61,3 +61,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
test("Minimal example", function () { return __awaiter(_this, void 0, void 0, function () { | ||
var globals, functions, mod; | ||
var globals, mod; | ||
return __generator(this, function (_a) { | ||
@@ -70,7 +70,9 @@ switch (_a.label) { | ||
}; | ||
functions = { | ||
ten: "x = 10;", | ||
setXToY: "x = y;" | ||
}; | ||
return [4 /*yield*/, loadModule({ globals: globals, functions: functions })]; | ||
return [4 /*yield*/, loadModule({ | ||
pools: { main: globals }, | ||
functions: { | ||
ten: { pool: "main", code: "x = 10" }, | ||
setXToY: { pool: "main", code: "x = y" } | ||
} | ||
})]; | ||
case 1: | ||
@@ -107,4 +109,6 @@ mod = _a.sent(); | ||
return [4 /*yield*/, loadModule({ | ||
globals: { g: g, x: x }, | ||
functions: { run: expression } | ||
pools: { main: { g: g, x: x } }, | ||
functions: { | ||
run: { pool: "main", code: expression } | ||
} | ||
})]; | ||
@@ -121,2 +125,112 @@ case 1: | ||
}); | ||
describe("Scopes", function () { | ||
test("isolate variables", function () { return __awaiter(_this, void 0, void 0, function () { | ||
var ax, bx, mod; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
ax = new WebAssembly.Global({ value: "f64", mutable: true }, 0); | ||
bx = new WebAssembly.Global({ value: "f64", mutable: true }, 0); | ||
return [4 /*yield*/, loadModule({ | ||
pools: { | ||
a: { x: ax }, | ||
b: { x: bx } | ||
}, | ||
functions: { | ||
setInA: { pool: "a", code: "x = 10;" }, | ||
setInB: { pool: "b", code: "x = 20;" } | ||
} | ||
})]; | ||
case 1: | ||
mod = _a.sent(); | ||
expect(ax.value).toBe(0); | ||
expect(bx.value).toBe(0); | ||
mod.exports.setInA(); | ||
expect(ax.value).toBe(10); | ||
expect(bx.value).toBe(0); | ||
mod.exports.setInB(); | ||
expect(ax.value).toBe(10); | ||
expect(bx.value).toBe(20); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
test.only("share reg variables", function () { return __awaiter(_this, void 0, void 0, function () { | ||
var g, mod; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
g = new WebAssembly.Global({ value: "f64", mutable: true }, 0); | ||
return [4 /*yield*/, loadModule({ | ||
pools: { | ||
a: {}, | ||
b: { g: g } | ||
}, | ||
functions: { | ||
setRegOne: { pool: "a", code: "reg01 = 10;" }, | ||
setRegNintyNine: { pool: "a", code: "reg99 = 10;" }, | ||
getRegOne: { pool: "b", code: "g = reg01;" }, | ||
getRegNintyNine: { pool: "b", code: "g = reg99;" } | ||
} | ||
})]; | ||
case 1: | ||
mod = _a.sent(); | ||
mod.exports.getRegOne(); | ||
expect(g.value).toBe(0); | ||
mod.exports.setRegOne(); | ||
mod.exports.getRegOne(); | ||
expect(g.value).toBe(10); | ||
mod.exports.getRegNintyNine(); | ||
expect(g.value).toBe(0); | ||
mod.exports.setRegNintyNine(); | ||
mod.exports.getRegNintyNine(); | ||
expect(g.value).toBe(10); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
describe("Invalid pool for function", function () { | ||
test("function pool is not among defined", function () { return __awaiter(_this, void 0, void 0, function () { | ||
var ax, bx, moduleOptions; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
ax = new WebAssembly.Global({ value: "f64", mutable: true }, 0); | ||
bx = new WebAssembly.Global({ value: "f64", mutable: true }, 0); | ||
moduleOptions = { | ||
pools: { | ||
a: { x: ax }, | ||
b: { x: bx } | ||
}, | ||
functions: { | ||
myInvalidFunction: { pool: "c", code: "x = 10;" } | ||
} | ||
}; | ||
return [4 /*yield*/, expect(loadModule(moduleOptions)).rejects.toEqual(new Error("The function \"myInvalidFunction\" was declared as using a variable pool named \"c\" which is not among the variable pools defined. The defined variable pools are: \"a\" and \"b\"."))]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
test("no function pools are defined", function () { return __awaiter(_this, void 0, void 0, function () { | ||
var moduleOptions; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
moduleOptions = { | ||
pools: {}, | ||
functions: { | ||
myInvalidFunction: { pool: "c", code: "x = 10;" } | ||
} | ||
}; | ||
return [4 /*yield*/, expect(loadModule(moduleOptions)).rejects.toEqual(new Error("The function \"myInvalidFunction\" was declared as using a variable pool named \"c\" but no pools were defined."))]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
test("Some actual equations", function () { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -134,6 +248,8 @@ var globals, perFrame, perPixel, mod; | ||
return [4 /*yield*/, loadModule({ | ||
globals: globals, | ||
pools: { | ||
main: globals | ||
}, | ||
functions: { | ||
perFrame: perFrame, | ||
perPixel: perPixel | ||
perFrame: { pool: "main", code: perFrame }, | ||
perPixel: { pool: "main", code: perPixel } | ||
} | ||
@@ -140,0 +256,0 @@ })]; |
@@ -25,2 +25,9 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
exports.__esModule = true; | ||
@@ -31,31 +38,24 @@ var parser_1 = require("./parser"); | ||
var shims_1 = __importDefault(require("./shims")); | ||
var Utils = __importStar(require("./utils")); | ||
var wasmFunctions_1 = require("./wasmFunctions"); | ||
var constants_1 = require("./constants"); | ||
var NamespaceResolver = /** @class */ (function () { | ||
function NamespaceResolver(initial, offset) { | ||
var _this = this; | ||
if (initial === void 0) { initial = []; } | ||
if (offset === void 0) { offset = 0; } | ||
this._counter = -1 + offset; | ||
this._map = new Map(); | ||
initial.forEach(function (name) { return _this.get(name); }); | ||
function compileModule(_a) { | ||
var pools = _a.pools, funcs = _a.functions, _b = _a.preParsed, preParsed = _b === void 0 ? false : _b; | ||
if (Object.keys(pools).includes("shims")) { | ||
throw new Error('You may not name a pool "shims". "shims" is reserved for injected JavaScript functions.'); | ||
} | ||
NamespaceResolver.prototype.get = function (name) { | ||
if (!this._map.has(name)) { | ||
this._counter++; | ||
this._map.set(name, this._counter); | ||
} | ||
// @ts-ignore we just set this. | ||
return this._map.get(name); | ||
}; | ||
NamespaceResolver.prototype.map = function (cb) { | ||
return Array.from(this._map.entries()).map(function (_a) { | ||
var _b = __read(_a, 2), value = _b[0], i = _b[1]; | ||
return cb(value, i); | ||
// Collect all the globals that we expect to get as imports. | ||
var importedVars = []; | ||
Object.entries(pools).forEach(function (_a) { | ||
var _b = __read(_a, 2), poolName = _b[0], pool = _b[1]; | ||
pool.forEach(function (variableName) { | ||
importedVars.push([poolName, variableName]); | ||
}); | ||
}; | ||
return NamespaceResolver; | ||
}()); | ||
function compileModule(_a) { | ||
var globalVariables = _a.globals, functionCode = _a.functions, _b = _a.preParsed, preParsed = _b === void 0 ? false : _b; | ||
}); | ||
// Ensure all the imported globals get the first ids. | ||
var varResolver = new Utils.ScopedIdMap(); | ||
importedVars.forEach(function (_a) { | ||
var _b = __read(_a, 2), poolName = _b[0], variableName = _b[1]; | ||
varResolver.get(poolName, variableName); | ||
}); | ||
var functionImports = Object.entries(shims_1["default"]).map(function (_a) { | ||
@@ -70,7 +70,17 @@ var _b = __read(_a, 2), name = _b[0], func = _b[1]; | ||
}); | ||
var externalVarsResolver = new NamespaceResolver(Array.from(globalVariables)); | ||
var userVarsResolver = new NamespaceResolver([], globalVariables.size); | ||
var localFuncResolver = new NamespaceResolver(functionImports.map(function (func) { return func.name; })); | ||
var moduleFuncs = Object.entries(functionCode).map(function (_a) { | ||
var _b = __read(_a, 2), name = _b[0], code = _b[1]; | ||
var localFuncOrder = []; | ||
var moduleFuncs = []; | ||
Object.entries(funcs).forEach(function (_a) { | ||
var _b = __read(_a, 2), name = _b[0], _c = _b[1], pool = _c.pool, code = _c.code; | ||
if (pools[pool] == null) { | ||
var poolsList = Object.keys(pools); | ||
if (poolsList.length === 0) { | ||
throw new Error("The function \"" + name + "\" was declared as using a variable " + | ||
("pool named \"" + pool + "\" but no pools were defined.")); | ||
} | ||
throw new Error("The function \"" + name + "\" was declared as using a variable " + | ||
("pool named \"" + pool + "\" which is not among the variable ") + | ||
"pools defined. The defined variable pools are: " + | ||
(Utils.formatList(poolsList) + ".")); | ||
} | ||
var ast = preParsed ? code : parser_1.parse(code); | ||
@@ -84,17 +94,36 @@ if (typeof ast === "string") { | ||
resolveVar: function (name) { | ||
if (globalVariables.has(name)) { | ||
return externalVarsResolver.get(name); | ||
// The `reg00`-`reg99` variables are special in that they are shared between all pools. | ||
if (/reg\d\d/.test(name)) { | ||
// TODO: Hack! We need a scope name here that is guaranteed not to be | ||
// used by our users. Since the "shims" namespace is already reserverd | ||
// (see above) we use it here, even though the `reg00`-`reg99` values | ||
// have nothing to do with shims. | ||
return varResolver.get("shims", name); | ||
} | ||
return userVarsResolver.get(name); | ||
return varResolver.get(pool, name); | ||
}, | ||
resolveLocal: function (type) { | ||
// TODO: We could provide a way for the emitter to release a local | ||
// variable so that we can reuse it, much in the same way a traditional | ||
// compiler does in register allocation. | ||
localVariables.push(type); | ||
return localVariables.length - 1; | ||
}, | ||
resolveLocalFunc: function (name) { | ||
if (shims_1["default"][name] == null && wasmFunctions_1.localFuncMap[name] == null) { | ||
resolveFunc: function (name) { | ||
// If this is a shim, return the shim index. | ||
var shimdex = functionImports.findIndex(function (func) { return func.name === name; }); | ||
if (shimdex !== -1) { | ||
return encoding_1.op.call(shimdex); | ||
} | ||
// If it's not a shim and it's not a defined function, return null. | ||
// The emitter will generate a nice error. | ||
if (wasmFunctions_1.localFuncMap[name] == null) { | ||
return null; | ||
} | ||
var offset = localFuncResolver.get(name); | ||
return encoding_1.op.call(offset); | ||
var index = localFuncOrder.indexOf(name); | ||
if (index === -1) { | ||
localFuncOrder.push(name); | ||
index = localFuncOrder.length - 1; | ||
} | ||
return encoding_1.op.call(index + functionImports.length); | ||
}, | ||
@@ -104,3 +133,3 @@ rawSource: code | ||
var binary = emitter_1.emit(ast, context); | ||
return { | ||
moduleFuncs.push({ | ||
binary: binary, | ||
@@ -111,10 +140,8 @@ exportName: name, | ||
localVariables: localVariables | ||
}; | ||
}); | ||
}); | ||
var localFuncs = localFuncResolver | ||
.map(function (name) { return name; }) | ||
// TODO: This .slice es muy grosso. | ||
.slice(functionImports.length) | ||
.map(function (name) { | ||
var localFuncs = localFuncOrder.map(function (name) { | ||
var func = wasmFunctions_1.localFuncMap[name]; | ||
// This check is technicaly redundant since we check inside resolveLocalFunc | ||
// in the compiler context. It's here just to catch potential compiler bugs. | ||
if (func == null) { | ||
@@ -151,7 +178,8 @@ throw new Error("Undefined local function \"" + name + "\""); | ||
// https://webassembly.github.io/spec/core/binary/modules.html#import-section | ||
var imports = __spread(Array.from(globalVariables).map(function (name) { | ||
return __spread(encoding_1.encodeString("js"), encoding_1.encodeString(name), [encoding_1.GLOBAL_TYPE, encoding_1.VAL_TYPE.f64, encoding_1.MUTABILITY["var"]]); | ||
var imports = __spread(importedVars.map(function (_a) { | ||
var _b = __read(_a, 2), namespace = _b[0], name = _b[1]; | ||
return __spread(encoding_1.encodeString(namespace), encoding_1.encodeString(name), [encoding_1.GLOBAL_TYPE, encoding_1.VAL_TYPE.f64, encoding_1.MUTABILITY["var"]]); | ||
}), functionImports.map(function (func, i) { | ||
var typeIndex = getTypeIndex(func); | ||
return __spread(encoding_1.encodeString("imports"), encoding_1.encodeString(func.name), __spread([encoding_1.TYPE_IDX], encoding_1.unsignedLEB128(typeIndex))); | ||
return __spread(encoding_1.encodeString("shims"), encoding_1.encodeString(func.name), __spread([encoding_1.TYPE_IDX], encoding_1.unsignedLEB128(typeIndex))); | ||
})); | ||
@@ -172,3 +200,4 @@ // https://webassembly.github.io/spec/core/binary/modules.html#function-section | ||
// https://webassembly.github.io/spec/core/binary/modules.html#global-section | ||
var globals = userVarsResolver.map(function () { | ||
var globalCount = varResolver.size() - importedVars.length; | ||
var globals = Utils.times(globalCount, function () { | ||
return __spread([ | ||
@@ -175,0 +204,0 @@ encoding_1.VAL_TYPE.f64, |
@@ -30,3 +30,3 @@ "use strict"; | ||
var wasmFunctions_1 = require("./wasmFunctions"); | ||
var arrayUtils_1 = require("./arrayUtils"); | ||
var utils_1 = require("./utils"); | ||
var constants_1 = require("./constants"); | ||
@@ -37,3 +37,3 @@ function emitExpressionBlock(body, context) { | ||
}); | ||
return arrayUtils_1.flatten(arrayUtils_1.arrayJoin(statements, [encoding_1.op.drop])); | ||
return utils_1.flatten(utils_1.arrayJoin(statements, [encoding_1.op.drop])); | ||
} | ||
@@ -83,3 +83,3 @@ function emitWhile(expression, context) { | ||
"/=": [encoding_1.op.f64_div], | ||
"%=": context.resolveLocalFunc("mod"), | ||
"%=": context.resolveFunc("mod"), | ||
"=": null | ||
@@ -99,3 +99,3 @@ }; | ||
}); | ||
return arrayUtils_1.flatten(body); | ||
return utils_1.flatten(body); | ||
} | ||
@@ -113,6 +113,6 @@ case "EXPRESSION_BLOCK": { | ||
"/": [encoding_1.op.f64_div], | ||
"%": context.resolveLocalFunc("mod"), | ||
"|": context.resolveLocalFunc("bitwiseOr"), | ||
"&": context.resolveLocalFunc("bitwiseAnd"), | ||
"^": context.resolveLocalFunc("pow"), | ||
"%": context.resolveFunc("mod"), | ||
"|": context.resolveFunc("bitwiseOr"), | ||
"&": context.resolveFunc("bitwiseAnd"), | ||
"^": context.resolveFunc("pow"), | ||
// Comparison operators | ||
@@ -144,3 +144,3 @@ "==": __spread([encoding_1.op.f64_sub], encoding_1.IS_ZEROISH, [encoding_1.op.f64_convert_i32_s]), | ||
}; | ||
var args = arrayUtils_1.flatten(ast.arguments.map(function (node) { return emit(node, context); })); | ||
var args = utils_1.flatten(ast.arguments.map(function (node) { return emit(node, context); })); | ||
// Some functions have special behavior | ||
@@ -168,3 +168,3 @@ switch (functionName_1) { | ||
var index = context.resolveLocal(encoding_1.VAL_TYPE.i32); | ||
return __spread(emit(ast.arguments[0], context), context.resolveLocalFunc("_getBufferIndex"), encoding_1.op.local_tee(index), encoding_1.op.i32_const(-1), [ | ||
return __spread(emit(ast.arguments[0], context), context.resolveFunc("_getBufferIndex"), encoding_1.op.local_tee(index), encoding_1.op.i32_const(-1), [ | ||
encoding_1.op.i32_ne | ||
@@ -213,3 +213,3 @@ ], encoding_1.op["if"](encoding_1.BLOCK.f64), encoding_1.op.local_get(index), encoding_1.op.f64_load(3, emitAddMemoryOffset(functionName_1)), [ | ||
} | ||
var invocation = context.resolveLocalFunc(functionName_1); | ||
var invocation = context.resolveFunc(functionName_1); | ||
if (invocation == null || | ||
@@ -273,3 +273,3 @@ // Ensure this isn't a private function. This is a bit awkward becuase | ||
var rightValue_1 = context.resolveLocal(encoding_1.VAL_TYPE.f64); | ||
return __spread(rightCode, encoding_1.op.local_set(rightValue_1), emit(left.arguments[0], context), context.resolveLocalFunc("_getBufferIndex"), encoding_1.op.local_tee(unnormalizedIndex), encoding_1.op.i32_const(0), [ | ||
return __spread(rightCode, encoding_1.op.local_set(rightValue_1), emit(left.arguments[0], context), context.resolveFunc("_getBufferIndex"), encoding_1.op.local_tee(unnormalizedIndex), encoding_1.op.i32_const(0), [ | ||
encoding_1.op.i32_lt_s | ||
@@ -289,3 +289,3 @@ ], encoding_1.op["if"](encoding_1.BLOCK.f64), encoding_1.op.f64_const(0), [ | ||
var result = context.resolveLocal(encoding_1.VAL_TYPE.f64); | ||
return __spread(rightCode, encoding_1.op.local_set(rightValue), emit(left.arguments[0], context), context.resolveLocalFunc("_getBufferIndex"), encoding_1.op.local_tee(index), encoding_1.op.i32_const(-1), [ | ||
return __spread(rightCode, encoding_1.op.local_set(rightValue), emit(left.arguments[0], context), context.resolveFunc("_getBufferIndex"), encoding_1.op.local_tee(index), encoding_1.op.i32_const(-1), [ | ||
encoding_1.op.i32_ne | ||
@@ -292,0 +292,0 @@ ], encoding_1.op.local_tee(inBounds), encoding_1.op["if"](encoding_1.BLOCK.f64), encoding_1.op.local_get(index), encoding_1.op.f64_load(3, addOffset), [ |
@@ -31,3 +31,3 @@ "use strict"; | ||
var ieee754 = __importStar(require("./ieee754")); | ||
var arrayUtils_1 = require("./arrayUtils"); | ||
var utils_1 = require("./utils"); | ||
exports.MAGIC = [0x00, 0x61, 0x73, 0x6d]; | ||
@@ -261,3 +261,3 @@ exports.WASM_VERSION = [0x01, 0x00, 0x00, 0x00]; | ||
// Vectors are encoded with their length followed by their element sequence | ||
exports.encodeVector = function (data) { return __spread(unsignedLEB128(data.length), arrayUtils_1.flattenTwice(data)); }; | ||
exports.encodeVector = function (data) { return __spread(unsignedLEB128(data.length), utils_1.flattenTwice(data)); }; | ||
// subSections is an array of arrays | ||
@@ -264,0 +264,0 @@ function encodeSection(type, subSections) { |
@@ -16,3 +16,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
var arrayUtils_1 = require("./arrayUtils"); | ||
var utils_1 = require("./utils"); | ||
/* Build up a string showing a formatted source location in context with line numbers. | ||
@@ -37,4 +37,4 @@ * | ||
if (loc.first_line === loc.last_line) { | ||
var padding = arrayUtils_1.repeat(loc.first_column, " "); | ||
var underline = arrayUtils_1.repeat(loc.last_column - loc.first_column, "^"); | ||
var padding = utils_1.repeat(loc.first_column, " "); | ||
var underline = utils_1.repeat(loc.last_column - loc.first_column, "^"); | ||
var insertIndex = loc.first_line - firstIndex; | ||
@@ -41,0 +41,0 @@ annotatedLines.splice(insertIndex, 0, " | " + padding + underline); |
@@ -49,2 +49,18 @@ "use strict"; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -57,10 +73,15 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
function loadModule(_a) { | ||
var globals = _a.globals, functions = _a.functions; | ||
var pools = _a.pools, functions = _a.functions; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var buffer, mod, importObject; | ||
var compilerPools, buffer, mod, importObject; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
compilerPools = {}; | ||
Object.entries(pools).forEach(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], globals = _b[1]; | ||
compilerPools[key] = new Set(Object.keys(globals)); | ||
}); | ||
buffer = compiler_1.compileModule({ | ||
globals: new Set(Object.keys(globals)), | ||
pools: compilerPools, | ||
functions: functions | ||
@@ -71,6 +92,3 @@ }); | ||
mod = _b.sent(); | ||
importObject = { | ||
js: __assign({}, globals), | ||
imports: shims_1["default"] | ||
}; | ||
importObject = __assign(__assign({}, pools), { shims: shims_1["default"] }); | ||
return [4 /*yield*/, WebAssembly.instantiate(mod, importObject)]; | ||
@@ -77,0 +95,0 @@ case 2: return [2 /*return*/, _b.sent()]; |
{ | ||
"name": "eel-wasm", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"main": "dist/src/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
326167
55
3521