From 4165099c6040a15a351a3278feb1f19d86690be9 Mon Sep 17 00:00:00 2001 From: Robert Plummer Date: Thu, 14 Jun 2018 10:53:15 -0400 Subject: [PATCH] fix #319 add rudimentary infinity handling --- bin/gpu-core.js | 4 +- bin/gpu-core.min.js | 4 +- bin/gpu.js | 164 ++++++++++---------------- bin/gpu.min.js | 18 +-- dist/backend/cpu/function-node.js | 4 +- dist/backend/web-gl/function-node.js | 4 + dist/backend/web-gl2/function-node.js | 158 ++++++------------------- dist/backend/web-gl2/runner.js | 31 ++++- package.json | 2 +- src/backend/cpu/function-node.js | 4 +- src/backend/web-gl/function-node.js | 4 + src/backend/web-gl2/function-node.js | 160 +++++++------------------ src/backend/web-gl2/runner.js | 20 +++- test/all.html | 1 + test/features/infinity.js | 29 +++++ 15 files changed, 241 insertions(+), 366 deletions(-) create mode 100644 test/features/infinity.js diff --git a/bin/gpu-core.js b/bin/gpu-core.js index ac4730bf..d03cff97 100644 --- a/bin/gpu-core.js +++ b/bin/gpu-core.js @@ -4,8 +4,8 @@ * * GPU Accelerated JavaScript * - * @version 1.4.2 - * @date Tue Jun 12 2018 14:07:16 GMT-0400 (EDT) + * @version 1.4.3 + * @date Thu Jun 14 2018 10:52:52 GMT-0400 (EDT) * * @license MIT * The MIT License diff --git a/bin/gpu-core.min.js b/bin/gpu-core.min.js index 6cf32ef8..59988745 100644 --- a/bin/gpu-core.min.js +++ b/bin/gpu-core.min.js @@ -4,8 +4,8 @@ * * GPU Accelerated JavaScript * - * @version 1.4.2 - * @date Tue Jun 12 2018 14:07:16 GMT-0400 (EDT) + * @version 1.4.3 + * @date Thu Jun 14 2018 10:52:52 GMT-0400 (EDT) * * @license MIT * The MIT License diff --git a/bin/gpu.js b/bin/gpu.js index eb8671c3..ca6873b6 100644 --- a/bin/gpu.js +++ b/bin/gpu.js @@ -4,8 +4,8 @@ * * GPU Accelerated JavaScript * - * @version 1.4.2 - * @date Tue Jun 12 2018 14:07:16 GMT-0400 (EDT) + * @version 1.4.3 + * @date Thu Jun 14 2018 10:52:52 GMT-0400 (EDT) * * @license MIT * The MIT License @@ -283,6 +283,9 @@ module.exports = function (_BaseFunctionNode) { case 'gpu_outputZ': retArr.push('uOutputDim.z'); break; + case 'Infinity': + retArr.push('Infinity'); + break; default: if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { retArr.push('constants_' + idtNode.name); @@ -736,7 +739,6 @@ module.exports = function (_BaseFunctionNode) { if (i > 0) { retArr.push(', '); } - retArr.push(funcParam.paramTypes[i]); retArr.push(' '); retArr.push('user_'); @@ -2296,6 +2298,9 @@ module.exports = function (_FunctionNodeBase) { case 'gpu_outputZ': retArr.push('uOutputDim.z'); break; + case 'Infinity': + retArr.push('3.402823466e+38'); + break; default: if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { retArr.push('constants_' + idtNode.name); @@ -4118,107 +4123,47 @@ module.exports = function (_WebGLFunctionNode) { }, { - key: 'astVariableDeclaration', - value: function astVariableDeclaration(vardecNode, retArr, funcParam) { - for (var i = 0; i < vardecNode.declarations.length; i++) { - var declaration = vardecNode.declarations[i]; - if (i > 0) { - retArr.push(','); - } - var retDeclaration = []; - this.astGeneric(declaration, retDeclaration, funcParam); - if (i === 0) { - if (retDeclaration[0] === 'get(' && funcParam.getParamType(retDeclaration[1]) === 'HTMLImage' && retDeclaration.length === 18) { - retArr.push('sampler2D '); - } else { - retArr.push('float '); - } - } - retArr.push.apply(retArr, retDeclaration); + key: 'astIdentifierExpression', + value: function astIdentifierExpression(idtNode, retArr, funcParam) { + if (idtNode.type !== 'Identifier') { + throw this.astErrorOutput('IdentifierExpression - not an Identifier', idtNode, funcParam); } - retArr.push(';'); - return retArr; - } - - - }, { - key: 'astMemberExpression', - value: function astMemberExpression(mNode, retArr, funcParam) { - if (mNode.computed) { - if (mNode.object.type === 'Identifier') { - var reqName = mNode.object.name; - var funcName = funcParam.functionName || 'kernel'; - var assumeNotTexture = false; - if (funcParam.paramNames) { - var idx = funcParam.paramNames.indexOf(reqName); - if (idx >= 0 && funcParam.paramTypes[idx] === 'float') { - assumeNotTexture = true; - } - } - - if (assumeNotTexture) { - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('[int('); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(')]'); + switch (idtNode.name) { + case 'gpu_threadX': + retArr.push('threadId.x'); + break; + case 'gpu_threadY': + retArr.push('threadId.y'); + break; + case 'gpu_threadZ': + retArr.push('threadId.z'); + break; + case 'gpu_outputX': + retArr.push('uOutputDim.x'); + break; + case 'gpu_outputY': + retArr.push('uOutputDim.y'); + break; + case 'gpu_outputZ': + retArr.push('uOutputDim.z'); + break; + case 'Infinity': + retArr.push('intBitsToFloat(2139095039)'); + break; + default: + if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { + retArr.push('constants_' + idtNode.name); } else { - retArr.push('get('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push(', vec2('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Size[0],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Size[1]), vec3('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[0],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[1],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[2]'); - retArr.push('), '); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(')'); + var userParamName = funcParam.getUserParamName(idtNode.name); + if (userParamName !== null) { + retArr.push('user_' + userParamName); + } else { + retArr.push('user_' + idtNode.name); + } } - } else { - this.astGeneric(mNode.object, retArr, funcParam); - var last = retArr.pop(); - retArr.push(','); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(last); - } - } else { - - var unrolled = this.astMemberExpressionUnroll(mNode); - var unrolled_lc = unrolled.toLowerCase(); - - if (unrolled.indexOf(constantsPrefix) === 0) { - unrolled = 'constants_' + unrolled.slice(constantsPrefix.length); - } - - switch (unrolled_lc) { - case 'this.thread.x': - retArr.push('threadId.x'); - break; - case 'this.thread.y': - retArr.push('threadId.y'); - break; - case 'this.thread.z': - retArr.push('threadId.z'); - break; - case 'this.output.x': - retArr.push(this.output[0] + '.0'); - break; - case 'this.output.y': - retArr.push(this.output[1] + '.0'); - break; - case 'this.output.z': - retArr.push(this.output[2] + '.0'); - break; - default: - retArr.push(unrolled); - } } + return retArr; } }]); @@ -4807,18 +4752,20 @@ module.exports = function (_WebGLKernel) { },{"../../core/texture":30,"../../core/utils":32,"../web-gl/kernel":14,"./shader-frag":23,"./shader-vert":24}],22:[function(require,module,exports){ 'use strict'; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var WebGLRunner = require('../web-gl/runner'); +var RunnerBase = require('../runner-base'); var WebGL2FunctionBuilder = require('./function-builder'); var WebGL2Kernel = require('./kernel'); -module.exports = function (_WebGLRunner) { - _inherits(WebGL2Runner, _WebGLRunner); +module.exports = function (_RunnerBase) { + _inherits(WebGL2Runner, _RunnerBase); function WebGL2Runner(settings) { _classCallCheck(this, WebGL2Runner); @@ -4830,9 +4777,18 @@ module.exports = function (_WebGLRunner) { return _this; } + + + _createClass(WebGL2Runner, [{ + key: 'getMode', + value: function getMode() { + return 'gpu'; + } + }]); + return WebGL2Runner; -}(WebGLRunner); -},{"../web-gl/runner":15,"./function-builder":19,"./kernel":21}],23:[function(require,module,exports){ +}(RunnerBase); +},{"../runner-base":10,"./function-builder":19,"./kernel":21}],23:[function(require,module,exports){ "use strict"; module.exports = "#version 300 es\n__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n#define EPSILON 0.0000001;\n\n__CONSTANTS__;\n\nin highp vec2 vTexCoord;\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nhighp float integerMod(highp float x, highp float y) {\n highp float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nhighp int integerMod(highp int x, highp int y) {\n return int(integerMod(float(x), float(y)));\n}\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nhighp float decode32(highp vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nhighp vec4 encode32(highp float f) {\n highp float F = abs(f);\n highp float sign = f < 0.0 ? 1.0 : 0.0;\n highp float exponent = floor(log2(F));\n highp float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nhighp float index;\nhighp vec3 threadId;\n\nhighp vec3 indexTo3D(highp float idx, highp vec3 texDim) {\n highp float z = floor(idx / (texDim.x * texDim.y));\n idx -= z * texDim.x * texDim.y;\n highp float y = floor(idx / texDim.x);\n highp float x = integerMod(idx, texDim.x);\n return vec3(x, y, z);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float z, highp float y, highp float x) {\n highp vec3 xyz = vec3(x, y, z);\n xyz = floor(xyz + 0.5);\n __GET_WRAPAROUND__;\n highp float index = round(xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z));\n __GET_TEXTURE_CHANNEL__;\n highp float w = round(texSize.x);\n vec2 st = vec2(integerMod(index, w), float(int(index) / int(w))) + 0.5;\n __GET_TEXTURE_INDEX__;\n highp vec4 texel = texture(tex, st / texSize);\n __GET_RESULT__;\n}\n\nhighp vec4 getImage2D(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float z, highp float y, highp float x) {\n highp vec3 xyz = vec3(x, y, z);\n xyz = floor(xyz + 0.5);\n __GET_WRAPAROUND__;\n highp float index = round(xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z));\n __GET_TEXTURE_CHANNEL__;\n highp float w = round(texSize.x);\n vec2 st = vec2(integerMod(index, w), float(int(index) / int(w))) + 0.5;\n __GET_TEXTURE_INDEX__;\n return texture(tex, st / texSize);\n}\n\nhighp vec4 getImage3D(highp sampler2DArray tex, highp vec2 texSize, highp vec3 texDim, highp float z, highp float y, highp float x) {\n highp vec3 xyz = vec3(x, y, z);\n xyz = floor(xyz + 0.5);\n __GET_WRAPAROUND__;\n highp float index = round(xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z));\n __GET_TEXTURE_CHANNEL__;\n highp float w = round(texSize.x);\n vec2 st = vec2(integerMod(index, w), float(int(index) / int(w))) + 0.5;\n __GET_TEXTURE_INDEX__;\n return texture(tex, vec3(st / texSize, z));\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float y, highp float x) {\n return get(tex, texSize, texDim, 0.0, y, x);\n}\n\nhighp vec4 getImage2D(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float y, highp float x) {\n return getImage2D(tex, texSize, texDim, 0.0, y, x);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float x) {\n return get(tex, texSize, texDim, 0.0, 0.0, x);\n}\n\nhighp vec4 getImage2D(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float x) {\n return getImage2D(tex, texSize, texDim, 0.0, 0.0, x);\n}\n\nhighp vec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = floor(vTexCoord.s * float(uTexSize.x)) + floor(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}"; diff --git a/bin/gpu.min.js b/bin/gpu.min.js index 8737f2b2..313ff2cd 100644 --- a/bin/gpu.min.js +++ b/bin/gpu.min.js @@ -4,18 +4,18 @@ * * GPU Accelerated JavaScript * - * @version 1.4.2 - * @date Tue Jun 12 2018 14:07:16 GMT-0400 (EDT) + * @version 1.4.3 + * @date Thu Jun 14 2018 10:52:52 GMT-0400 (EDT) * * @license MIT * The MIT License * * Copyright (c) 2018 gpu.js Team */ -"use strict";!function(){function e(t,n,r){function i(a,o){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a0&&t.push(", "),t.push(" "),t.push("user_"),t.push(i)}t.push(") {\n")}for(var s=0;s1){for(var a=null,o=0;o0&&t.push(","),this.astGeneric(e.declarations[r],t,n);return t.push(";"),t}},{key:"astVariableDeclarator",value:function(e,t,n){return this.astGeneric(e.id,t,n),null!==e.init&&(t.push("="),this.astGeneric(e.init,t,n)),t}},{key:"astIfStatement",value:function(e,t,n){return t.push("if ("),this.astGeneric(e.test,t,n),t.push(")"),"BlockStatement"===e.consequent.type?this.astGeneric(e.consequent,t,n):(t.push(" {\n"),this.astGeneric(e.consequent,t,n),t.push("\n}\n")),e.alternate&&(t.push("else "),"BlockStatement"===e.alternate.type?this.astGeneric(e.alternate,t,n):(t.push(" {\n"),this.astGeneric(e.alternate,t,n),t.push("\n}\n"))),t}},{key:"astBreakStatement",value:function(e,t,n){return t.push("break;\n"),t}},{key:"astContinueStatement",value:function(e,t,n){return t.push("continue;\n"),t}},{key:"astLogicalExpression",value:function(e,t,n){return t.push("("),this.astGeneric(e.left,t,n),t.push(e.operator),this.astGeneric(e.right,t,n),t.push(")"),t}},{key:"astUpdateExpression",value:function(e,t,n){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,n)):(this.astGeneric(e.argument,t,n),t.push(e.operator)),t}},{key:"astUnaryExpression",value:function(e,t,n){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,n)):(this.astGeneric(e.argument,t,n),t.push(e.operator)),t}},{key:"astThisExpression",value:function(e,t,n){return t.push("_this"),t}},{key:"astMemberExpression",value:function(e,t,n){if(e.computed)if("Identifier"===e.object.type)this.astGeneric(e.object,t,n),t.push("["),this.astGeneric(e.property,t,n),t.push("]");else{this.astGeneric(e.object,t,n);var r=t.pop();t.push("]["),this.astGeneric(e.property,t,n),t.push(r)}else{var i=this.astMemberExpressionUnroll(e);switch("Identifier"===e.property.type&&e.computed&&(i="user_"+i),0===i.indexOf("this")&&(i="_"+i),i){case"_this.output.x":t.push(this.output[0]);break;case"_this.output.y":t.push(this.output[1]);break;case"_this.output.z":t.push(this.output[2]);break;default:t.push(i)}}return t}},{key:"astSequenceExpression",value:function(e,t,n){for(var r=0;r0&&t.push(","),this.astGeneric(e.expressions,t,n);return t}},{key:"astCallExpression",value:function(e,t,n){if(e.callee){var r=this.astMemberExpressionUnroll(e.callee);n.calledFunctions.indexOf(r)<0&&n.calledFunctions.push(r),n.hasOwnProperty("funcName")||(n.calledFunctionsArguments[r]=[]);var i=[];n.calledFunctionsArguments[r].push(i),t.push(r),t.push("(");for(var s=0;s0&&t.push(", "),this.astGeneric(a,t,n),"Identifier"===a.type){var o=n.paramNames.indexOf(a.name);o===-1?i.push(null):i.push({name:a.name,type:n.paramTypes[o]})}else i.push(null)}return t.push(")"),t}throw this.astErrorOutput("Unknown CallExpression",e,n)}},{key:"astArrayExpression",value:function(e,t,n){var r=e.elements.length;t.push("new Float32Array(");for(var i=0;i0&&t.push(", ");var s=e.elements[i];this.astGeneric(s,t,n)}return t.push(")"),t}},{key:"astDebuggerStatement",value:function(e,t,n){return t.push("debugger;"),t}}],[{key:"astFunctionPrototype",value:function(e,t,n){if(n.isRootKernel||n.isSubKernel)return t;t.push(n.returnType),t.push(" "),t.push(n.functionName),t.push("(");for(var r=0;r0&&t.push(", "),t.push(n.paramTypes[r]),t.push(" "),t.push("user_"),t.push(n.paramNames[r]);return t.push(");\n"),t}}]),t}(o)},{"../../core/utils":32,"../function-node-base":7}],3:[function(e,t,n){function r(e){return/^function /.test(e)&&(e=e.substring(9)),e.replace(/[_]typeof/g,"typeof")}function i(e){return e.replace(/[_]typeof/g,"typeof")}var s=e("../../core/utils"),a=e("../kernel-run-shortcut");t.exports=function(e,t){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+"\n };\n const Utils = utils;\n class "+(t||"Kernel")+" {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(e.paramNames)+";\n this.paramTypes = "+JSON.stringify(e.paramTypes)+";\n this.texSize = "+JSON.stringify(e.texSize)+";\n this.output = "+JSON.stringify(e.output)+";\n this._kernelString = `"+e._kernelString+"`;\n this.output = "+JSON.stringify(e.output)+";\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(e.build.toString())+"\n "+r(e.setupParams.toString())+"\n run () { "+e.kernelString+" }\n getKernelString() { return this._kernelString; }\n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],4:[function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n1?h=h.filter(function(e){return/^function/.test(e)?e:(l=e,!1)}):l=h.shift();var p=this._kernelString="\n\t\tvar LOOP_MAX = "+this._getLoopMaxString()+";\n\t\tvar _this = this;\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" var "+e+" = null;\n"}).join(""))+"\n return function ("+this.paramNames.map(function(e){return"user_"+e}).join(", ")+") {\n "+this._processInputs()+"\n var ret = new Array("+n[2]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z = new Array("+n[2]+");\n"}).join(""))+"\n for (this.thread.z = 0; this.thread.z < "+n[2]+"; this.thread.z++) {\n ret[this.thread.z] = new Array("+n[1]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z[this.thread.z] = new Array("+n[1]+");\n"}).join(""))+"\n for (this.thread.y = 0; this.thread.y < "+n[1]+"; this.thread.y++) {\n ret[this.thread.z][this.thread.y] = new Array("+n[0]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z[this.thread.z][this.thread.y] = new Array("+n[0]+");\n"}).join(""))+"\n for (this.thread.x = 0; this.thread.x < "+n[0]+"; this.thread.x++) {\n var kernelResult;\n "+l+"\n ret[this.thread.z][this.thread.y][this.thread.x] = kernelResult;\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z[this.thread.z][this.thread.y][this.thread.x] = "+e+";\n"}).join(""))+"\n }\n }\n }\n \n if (this.graphical) {\n this._imageData.data.set(this._colorData);\n this._canvasCtx.putImageData(this._imageData, 0, 0);\n return;\n }\n \n if (this.output.length === 1) {\n ret = ret[0][0];\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+" = "+e+"Z[0][0];\n"}).join(""))+"\n \n } else if (this.output.length === 2) {\n ret = ret[0];\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+" = "+e+"Z[0];\n"}).join(""))+"\n }\n \n "+(null===this.subKernelOutputVariableNames?"return ret;\n":null!==this.subKernels?"var result = [\n "+this.subKernelOutputVariableNames.map(function(e){return""+e}).join(",\n")+"\n ];\n result.result = ret;\n return result;\n":"return {\n result: ret,\n "+Object.keys(this.subKernelProperties).map(function(t,n){return t+": "+e.subKernelOutputVariableNames[n]}).join(",\n")+"\n };")+"\n "+(h.length>0?h.join("\n"):"")+"\n }.bind(this);";return p}},{key:"toString",value:function(){return h(this)}},{key:"precompileKernelObj",value:function(e){var t=this.threadDim||(this.threadDim=u.clone(this.output));return{threadDim:t}}},{key:"_getLoopMaxString",value:function(){return this.loopMaxIterations?" "+parseInt(this.loopMaxIterations)+";\n":" 1000;\n"}},{key:"_processInputs",value:function(){for(var e=[],t=0;t=0;i--){n[i]=new Array(e.width);for(var s=0;s=0||t.push(e)),t}},{key:"addKernel",value:function(e,t,n,r){var i=new this.Node("kernel",e,t,r);return i.setAddFunction(this.addFunction.bind(this)),i.paramNames=n,i.paramTypes=r,i.isRootKernel=!0,this.addFunctionNode(i),i}},{key:"addSubKernel",value:function(e,t,n,r){var i=new this.Node(null,e,t,n,r);return i.setAddFunction(this.addFunction.bind(this)),i.isSubKernel=!0,this.addFunctionNode(i),i}},{key:"getPrototypeString",value:function(e){return this.getPrototypes(e).join("\n")}},{key:"getPrototypes",value:function(e){return this.rootKernel.generate(),e?this.getPrototypesFromFunctionNames(this.traceFunctionCalls(e,[]).reverse()):this.getPrototypesFromFunctionNames(Object.keys(this.nodeMap))}},{key:"getStringFromFunctionNames",value:function(e){for(var t=[],n=0;n ("+r.length+","+this.paramNames.length+")";this.paramTypes=r}else if("object"===("undefined"==typeof r?"undefined":_typeof(r))){var s=Object.keys(r);if(r.hasOwnProperty("returns")&&(this.returnType=r.returns,s.splice(s.indexOf("returns"),1)),s.length>0&&s.length!==this.paramNames.length)throw"Invalid argument type array length, against function length -> ("+s.length+","+this.paramNames.length+")";this.paramTypes=this.paramNames.map(function(e){return r.hasOwnProperty(e)?r[e]:"float"})}}else this.paramTypes=[];this.returnType||(this.returnType=i||"float")}return _createClass(BaseFunctionNode,[{key:"isIdentifierConstant",value:function(e){return!!this.constants&&this.constants.hasOwnProperty(e)}},{key:"setAddFunction",value:function(e){return this.addFunction=e,this}},{key:"getJsFunction",value:function getJsFunction(){if(this.jsFunction)return this.jsFunction;if(this.jsFunctionString)return this.jsFunction=eval(this.jsFunctionString),this.jsFunction;throw"Missing jsFunction, and jsFunctionString parameter"}},{key:"astMemberExpressionUnroll",value:function(e,t){if("Identifier"===e.type)return e.name;if("ThisExpression"===e.type)return"this";if("MemberExpression"===e.type&&e.object&&e.property)return e.object.hasOwnProperty("name")&&"_"===e.object.name[0]?this.astMemberExpressionUnroll(e.property,t):this.astMemberExpressionUnroll(e.object,t)+"."+this.astMemberExpressionUnroll(e.property,t);if(e.hasOwnProperty("expressions")){var n=e.expressions[0];if("Literal"===n.type&&0===n.value&&2===e.expressions.length)return this.astMemberExpressionUnroll(e.expressions[1])}throw this.astErrorOutput("Unknown CallExpression_unroll",e,t)}},{key:"getJsAST",value:function(e){if(this.jsFunctionAST)return this.jsFunctionAST;if(e=e||acorn,null===e)throw"Missing JS to AST parser";var t=e.parse("var "+this.functionName+" = "+this.jsFunctionString+";",{locations:!0});if(null===t)throw"Failed to parse JS code";var n=t.body[0].declarations[0].init;return this.jsFunctionAST=n,n}},{key:"getFunctionString",value:function(){return this.generate(),this.functionString}},{key:"setFunctionString",value:function(e){this.functionString=e}},{key:"getParamType",value:function(e){var t=this.paramNames.indexOf(e);if(t===-1)return this.declarations.hasOwnProperty(e)?this.declarations[e]:null;if(this.parent){if(this.paramTypes[t])return this.paramTypes[t];for(var n=this.parent.calledFunctionsArguments[this.functionName],r=0;r0&&t.push(", ");var s=n.getParamType(i);switch(s){case"Texture":case"Input":case"Array":t.push("sampler2D");break;default:t.push("float")}t.push(" "),t.push("user_"),t.push(i)}t.push(") {\n");for(var a=0;a1){for(var a=null,o=0;o0&&t.push(",");var s=[];this.astGeneric(i,s,n),"getImage2D("===s[2]||"getImage3D("===s[2]?(0===r&&t.push("vec4 "),this.declarations[i.id.name]="vec4"):(0===r&&t.push("float "),this.declarations[i.id.name]="float"),t.push.apply(t,s)}return t.push(";"),t}},{key:"astVariableDeclarator",value:function(e,t,n){return this.astGeneric(e.id,t,n),null!==e.init&&(t.push("="),this.astGeneric(e.init,t,n)),t}},{key:"astIfStatement",value:function(e,t,n){return t.push("if ("),this.astGeneric(e.test,t,n),t.push(")"),"BlockStatement"===e.consequent.type?this.astGeneric(e.consequent,t,n):(t.push(" {\n"),this.astGeneric(e.consequent,t,n),t.push("\n}\n")),e.alternate&&(t.push("else "),"BlockStatement"===e.alternate.type?this.astGeneric(e.alternate,t,n):(t.push(" {\n"),this.astGeneric(e.alternate,t,n),t.push("\n}\n"))),t}},{key:"astBreakStatement",value:function(e,t,n){return t.push("break;\n"),t}},{key:"astContinueStatement",value:function(e,t,n){return t.push("continue;\n"),t}},{key:"astLogicalExpression",value:function(e,t,n){return t.push("("),this.astGeneric(e.left,t,n),t.push(e.operator),this.astGeneric(e.right,t,n),t.push(")"),t}},{key:"astUpdateExpression",value:function(e,t,n){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,n)):(this.astGeneric(e.argument,t,n),t.push(e.operator)),t}},{key:"astUnaryExpression",value:function(e,t,n){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,n)):(this.astGeneric(e.argument,t,n),t.push(e.operator)),t}},{key:"astThisExpression",value:function(e,t,n){return t.push("this"),t}},{key:"astMemberExpression",value:function(e,t,n){if(e.computed)if("Identifier"===e.object.type){var r=e.object.name,i=(n.functionName||"kernel",!1);if(n.paramNames){var s=n.paramNames.indexOf(r);s>=0&&"float"===n.paramTypes[s]&&(i=!0)}if(i)this.astGeneric(e.object,t,n),t.push("[int("),this.astGeneric(e.property,t,n),t.push(")]");else switch(n.getParamType(e.object.name)){case"vec4":this.astGeneric(e.object,t,n),t.push("["),t.push(e.property.raw),t.push("]");break;case"HTMLImageArray":t.push("getImage3D("),this.astGeneric(e.object,t,n),t.push(", vec2("),this.astGeneric(e.object,t,n),t.push("Size[0],"),this.astGeneric(e.object,t,n),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,n),t.push("Dim[0],"),this.astGeneric(e.object,t,n),t.push("Dim[1],"),this.astGeneric(e.object,t,n),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,n),t.push(")");break;case"HTMLImage":t.push("getImage2D("),this.astGeneric(e.object,t,n),t.push(", vec2("),this.astGeneric(e.object,t,n),t.push("Size[0],"),this.astGeneric(e.object,t,n),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,n),t.push("Dim[0],"),this.astGeneric(e.object,t,n),t.push("Dim[1],"),this.astGeneric(e.object,t,n),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,n),t.push(")");break;default:t.push("get("),this.astGeneric(e.object,t,n),t.push(", vec2("),this.astGeneric(e.object,t,n),t.push("Size[0],"),this.astGeneric(e.object,t,n),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,n),t.push("Dim[0],"),this.astGeneric(e.object,t,n),t.push("Dim[1],"),this.astGeneric(e.object,t,n),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,n),t.push(")")}}else{this.astGeneric(e.object,t,n);var a=t.pop();t.push(","),this.astGeneric(e.property,t,n),t.push(a)}else{var o=this.astMemberExpressionUnroll(e),u=o.toLowerCase();switch(0===o.indexOf(c)&&(o="constants_"+o.slice(c.length)),u){case"this.thread.x":t.push("threadId.x");break;case"this.thread.y":t.push("threadId.y");break;case"this.thread.z":t.push("threadId.z");break;case"this.output.x":t.push(this.output[0]+".0");break;case"this.output.y":t.push(this.output[1]+".0");break;case"this.output.z":t.push(this.output[2]+".0");break;default:t.push(o)}}return t}},{key:"astSequenceExpression",value:function(e,t,n){for(var r=0;r0&&t.push(","),this.astGeneric(e.expressions,t,n);return t}},{key:"astCallExpression",value:function(e,t,n){if(e.callee){var r=this.astMemberExpressionUnroll(e.callee);0===r.indexOf(l)&&(r=r.slice(l.length)),0===r.indexOf(p)&&(r=r.slice(p.length)),"atan2"===r&&(r="atan"),n.calledFunctions.indexOf(r)<0&&n.calledFunctions.push(r),n.hasOwnProperty("funcName")||(n.calledFunctionsArguments[r]=[]);var i=[];n.calledFunctionsArguments[r].push(i),t.push(r),t.push("(");for(var s=0;s0&&t.push(", "),this.astGeneric(a,t,n),"Identifier"===a.type){var o=n.paramNames.indexOf(a.name);o===-1?i.push(null):i.push({name:a.name,type:n.paramTypes[o]})}else i.push(null)}return t.push(")"),t}throw this.astErrorOutput("Unknown CallExpression",e,n)}},{key:"astArrayExpression",value:function(e,t,n){var r=e.elements.length;t.push("float["+r+"](");for(var i=0;i0&&t.push(", ");var s=e.elements[i];this.astGeneric(s,t,n)}return t.push(")"),t}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"build",value:function(){return this.getFunctionPrototypeString().length>0}}],[{key:"astFunctionPrototype",value:function(e,t,n){if(n.isRootKernel||n.isSubKernel)return t;t.push(n.returnType),t.push(" "),t.push(n.functionName),t.push("(");for(var r=0;r0&&t.push(", "),t.push(n.paramTypes[r]),t.push(" "),t.push("user_"),t.push(n.paramNames[r]);return t.push(");\n"),t}}]),t}(u)},{"../../core/utils":32,"../function-node-base":7}],13:[function(e,t,n){function r(e){return/^function /.test(e)&&(e=e.substring(9)),e.replace(/[_]typeof/g,"typeof")}function i(e){return e.replace(/[_]typeof/g,"typeof")}var s=e("../../core/utils"),a=e("../kernel-run-shortcut");t.exports=function(e,t){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+",\n splitArray: "+i(s.splitArray.toString())+",\n getArgumentType: "+i(s.getArgumentType.toString())+",\n getDimensions: "+i(s.getDimensions.toString())+",\n dimToTexSize: "+i(s.dimToTexSize.toString())+",\n flattenTo: "+i(s.flattenTo.toString())+",\n flatten2dArrayTo: "+i(s.flatten2dArrayTo.toString())+",\n flatten3dArrayTo: "+i(s.flatten3dArrayTo.toString())+",\n systemEndianness: '"+i(s.systemEndianness())+"',\n initWebGl: "+i(s.initWebGl.toString())+",\n isArray: "+i(s.isArray.toString())+"\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class "+(t||"Kernel")+" {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(e.paramNames)+";\n this.paramTypes = "+JSON.stringify(e.paramTypes)+";\n this.texSize = "+JSON.stringify(e.texSize)+";\n this.output = "+JSON.stringify(e.output)+";\n this.compiledFragShaderString = `"+e.compiledFragShaderString+"`;\n\t\t this.compiledVertShaderString = `"+e.compiledVertShaderString+"`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n "+r(e._getFragShaderString.toString())+"\n "+r(e._getVertShaderString.toString())+"\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(e.getUniformLocation.toString())+"\n "+r(e.setupParams.toString())+"\n "+r(e.build.toString())+"\n\t\t "+r(e.run.toString())+"\n\t\t "+r(e._addArgument.toString())+"\n\t\t "+r(e.getArgumentTexture.toString())+"\n\t\t "+r(e.getTextureCache.toString())+"\n\t\t "+r(e.getOutputTexture.toString())+"\n\t\t "+r(e.renderOutput.toString())+"\n\t\t "+r(e.updateMaxTexSize.toString())+"\n\t\t "+r(e._setupOutputTexture.toString())+"\n\t\t "+r(e.detachTextureCache.toString())+"\n\t\t "+r(e.setUniform1f.toString())+"\n\t\t "+r(e.setUniform1i.toString())+"\n\t\t "+r(e.setUniform2f.toString())+"\n\t\t "+r(e.setUniform2fv.toString())+"\n\t\t "+r(e.setUniform3fv.toString())+" \n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],14:[function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n0&&this._setupSubOutputTextures(this.subKernelOutputVariableNames.length))}},{key:"run",value:function(){null===this.program&&this.build.apply(this,arguments);var e=this.paramNames,t=this.paramTypes,n=this.texSize,r=this._webGl;r.useProgram(this.program),r.scissor(0,0,n[0],n[1]),this.hardcodeConstants||(this.setUniform3fv("uOutputDim",this.threadDim),this.setUniform2fv("uTexSize",n)),this.setUniform2f("ratio",n[0]/this.maxTexSize[0],n[1]/this.maxTexSize[1]),this.argumentsLength=0;for(var i=0;i0?e.join(";\n")+";\n":"\n"}},{key:"_replaceArtifacts",value:function(e,t){return e.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g,function(e,n){if(t.hasOwnProperty(n))return t[n];throw"unhandled artifact "+n})}},{key:"_addKernels",value:function(){var e=this,t=this.functionBuilder,n=this._webGl;if(t.addFunctions(this.functions,{constants:this.constants,output:this.output}),t.addNativeFunctions(this.nativeFunctions),t.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations},this.paramNames,this.paramTypes),null!==this.subKernels){var r=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!r)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],this.subKernels.forEach(function(t){return e._addSubKernel(t)})}else if(null!==this.subKernelProperties){var i=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!i)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],Object.keys(this.subKernelProperties).forEach(function(t){return e._addSubKernel(e.subKernelProperties[t])})}}},{key:"_addSubKernel",value:function(e){this.functionBuilder.addSubKernel(e,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations}),this.subKernelOutputVariableNames.push(e.name+"Result")}},{key:"_getFragShaderString",value:function(e){return null!==this.compiledFragShaderString?this.compiledFragShaderString:this.compiledFragShaderString=this._replaceArtifacts(this.constructor.fragShaderString,this._getFragShaderArtifactMap(e))}},{key:"_getVertShaderString",value:function(e){return null!==this.compiledVertShaderString?this.compiledVertShaderString:this.compiledVertShaderString=this.constructor.vertShaderString}},{key:"toString",value:function(){return c(this)}},{key:"addFunction",value:function(e){this.functionBuilder.addFunction(null,e)}}]),t}(o)},{"../../core/texture":30,"../../core/utils":32,"../kernel-base":8,"./kernel-string":13,"./shader-frag":16,"./shader-vert":17}],15:[function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n0&&t.push(", ");var s=n.getParamType(i);switch(s){case"Texture":case"Input":case"Array":case"HTMLImage":t.push("sampler2D");break;default:t.push("float")}t.push(" "),t.push("user_"),t.push(i)}t.push(") {\n");for(var a=0;a0&&t.push(",");var s=[];this.astGeneric(i,s,n),0===r&&("get("===s[0]&&"HTMLImage"===n.getParamType(s[1])&&18===s.length?t.push("sampler2D "):t.push("float ")),t.push.apply(t,s)}return t.push(";"),t}},{key:"astMemberExpression",value:function(e,t,n){if(e.computed)if("Identifier"===e.object.type){var r=e.object.name,i=(n.functionName||"kernel",!1);if(n.paramNames){var s=n.paramNames.indexOf(r);s>=0&&"float"===n.paramTypes[s]&&(i=!0)}i?(this.astGeneric(e.object,t,n),t.push("[int("),this.astGeneric(e.property,t,n),t.push(")]")):(t.push("get("),this.astGeneric(e.object,t,n),t.push(", vec2("),this.astGeneric(e.object,t,n),t.push("Size[0],"),this.astGeneric(e.object,t,n),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,n),t.push("Dim[0],"),this.astGeneric(e.object,t,n),t.push("Dim[1],"),this.astGeneric(e.object,t,n),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,n),t.push(")"))}else{this.astGeneric(e.object,t,n);var a=t.pop();t.push(","),this.astGeneric(e.property,t,n),t.push(a)}else{var o=this.astMemberExpressionUnroll(e),u=o.toLowerCase();switch(0===o.indexOf(h)&&(o="constants_"+o.slice(h.length)),u){case"this.thread.x":t.push("threadId.x");break;case"this.thread.y":t.push("threadId.y");break;case"this.thread.z":t.push("threadId.z");break;case"this.output.x":t.push(this.output[0]+".0");break;case"this.output.y":t.push(this.output[1]+".0");break;case"this.output.z":t.push(this.output[2]+".0");break;default:t.push(o)}}return t}}]),t}(u)},{"../web-gl/function-node":12}],21:[function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;ne)return!1;if(n+=t[r+1],n>=e)return!0}}function n(e,n){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&U.test(String.fromCharCode(e)):n!==!1&&t(e,V)))}function r(e,n){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&M.test(String.fromCharCode(e)):n!==!1&&(t(e,V)||t(e,B)))))}function i(e,t){return new j(e,{beforeExpr:!0,binop:t})}function s(e,t){return void 0===t&&(t={}),t.keyword=e,X[e]=new j(e,t)}function a(e){return 10===e||13===e||8232===e||8233===e}function o(e,t){return Z.call(e,t)}function u(e,t){for(var n=1,r=0;;){q.lastIndex=r;var i=q.exec(e);if(!(i&&i.index=2015&&(t.ecmaVersion-=2009),null==t.allowReserved&&(t.allowReserved=t.ecmaVersion<5),ee(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}return ee(t.onComment)&&(t.onComment=l(t,t.onComment)),t}function l(e,t){return function(n,r,i,s,a,o){var u={type:n?"Block":"Line",value:r,start:i,end:s};e.locations&&(u.loc=new ne(this,a,o)),e.ranges&&(u.range=[i,s]),t.push(u)}}function p(e){return new RegExp("^(?:"+e.replace(/ /g,"|")+")$")}function c(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}function f(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n), -e}function d(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(1023&e)+56320))}function g(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function m(e){return n(e,!0)||36===e||95===e}function x(e){return r(e,!0)||36===e||95===e||8204===e||8205===e}function y(e){return e>=65&&e<=90||e>=97&&e<=122}function v(e){return e>=0&&e<=1114111}function b(e){return 100===e||68===e||115===e||83===e||119===e||87===e}function _(e){return y(e)||95===e}function E(e){return _(e)||T(e)}function T(e){return e>=48&&e<=57}function S(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function k(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}function w(e){return e>=48&&e<=55}function A(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(1023&e)+56320))}function O(e,t){return new se(t,e).parse()}function C(e,t,n){var r=new se(n,e,t);return r.nextToken(),r.parseExpression()}function R(e,t){return new se(t,e)}function P(t,n,r){e.parse_dammit=t,e.LooseParser=n,e.pluginsLoose=r}var N={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},I="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",D={5:I,6:I+" const class extends export import super"},L=/^in(stanceof)?$/,F="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄮㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿪ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",G="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳷-᳹᷀-᷹᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",U=new RegExp("["+F+"]"),M=new RegExp("["+F+G+"]");F=G=null;var V=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,55,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,698,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,1,31,6124,20,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541],B=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,19719,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],j=function(e,t){void 0===t&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null},z={beforeExpr:!0},K={startsExpr:!0},X={},W={num:new j("num",K),regexp:new j("regexp",K),string:new j("string",K),name:new j("name",K),eof:new j("eof"),bracketL:new j("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new j("]"),braceL:new j("{",{beforeExpr:!0,startsExpr:!0}),braceR:new j("}"),parenL:new j("(",{beforeExpr:!0,startsExpr:!0}),parenR:new j(")"),comma:new j(",",z),semi:new j(";",z),colon:new j(":",z),dot:new j("."),question:new j("?",z),arrow:new j("=>",z),template:new j("template"),invalidTemplate:new j("invalidTemplate"),ellipsis:new j("...",z),backQuote:new j("`",K),dollarBraceL:new j("${",{beforeExpr:!0,startsExpr:!0}),eq:new j("=",{beforeExpr:!0,isAssign:!0}),assign:new j("_=",{beforeExpr:!0,isAssign:!0}),incDec:new j("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new j("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:i("||",1),logicalAND:i("&&",2),bitwiseOR:i("|",3),bitwiseXOR:i("^",4),bitwiseAND:i("&",5),equality:i("==/!=/===/!==",6),relational:i("/<=/>=",7),bitShift:i("<>/>>>",8),plusMin:new j("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:i("%",10),star:i("*",10),slash:i("/",10),starstar:new j("**",{beforeExpr:!0}),_break:s("break"),_case:s("case",z),_catch:s("catch"),_continue:s("continue"),_debugger:s("debugger"),_default:s("default",z),_do:s("do",{isLoop:!0,beforeExpr:!0}),_else:s("else",z),_finally:s("finally"),_for:s("for",{isLoop:!0}),_function:s("function",K),_if:s("if"),_return:s("return",z),_switch:s("switch"),_throw:s("throw",z),_try:s("try"),_var:s("var"),_const:s("const"),_while:s("while",{isLoop:!0}),_with:s("with"),_new:s("new",{beforeExpr:!0,startsExpr:!0}),_this:s("this",K),_super:s("super",K),_class:s("class",K),_extends:s("extends",z),_export:s("export"),_import:s("import"),_null:s("null",K),_true:s("true",K),_false:s("false",K),_in:s("in",{beforeExpr:!0,binop:7}),_instanceof:s("instanceof",{beforeExpr:!0,binop:7}),_typeof:s("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:s("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:s("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,q=new RegExp(H.source,"g"),Y=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,J=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Q=Object.prototype,Z=Q.hasOwnProperty,$=Q.toString,ee=Array.isArray||function(e){return"[object Array]"===$.call(e)},te=function(e,t){this.line=e,this.column=t};te.prototype.offset=function(e){return new te(this.line,this.column+e)};var ne=function(e,t,n){this.start=t,this.end=n,null!==e.sourceFile&&(this.source=e.sourceFile)},re={ecmaVersion:7,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1,plugins:{}},ie={},se=function(e,t,n){this.options=e=h(e),this.sourceFile=e.sourceFile,this.keywords=p(D[e.ecmaVersion>=6?6:5]);var r="";if(!e.allowReserved){for(var i=e.ecmaVersion;!(r=N[i]);i--);"module"==e.sourceType&&(r+=" await")}this.reservedWords=p(r);var s=(r?r+" ":"")+N.strict;this.reservedWordsStrict=p(s),this.reservedWordsStrictBind=p(s+" "+N.strictBind),this.input=String(t),this.containsEsc=!1,this.loadPlugins(e.plugins),n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=W.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===e.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&e.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope(),this.regexpState=null};se.prototype.isKeyword=function(e){return this.keywords.test(e)},se.prototype.isReservedWord=function(e){return this.reservedWords.test(e)},se.prototype.extend=function(e,t){this[e]=t(this[e])},se.prototype.loadPlugins=function(e){var t=this;for(var n in e){var r=ie[n];if(!r)throw new Error("Plugin '"+n+"' not found");r(t,e[n])}},se.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};var ae=se.prototype,oe=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;ae.strictDirective=function(e){for(var t=this;;){J.lastIndex=e,e+=J.exec(t.input)[0].length;var n=oe.exec(t.input.slice(e));if(!n)return!1;if("use strict"==(n[1]||n[2]))return!0;e+=n[0].length}},ae.eat=function(e){return this.type===e&&(this.next(),!0)},ae.isContextual=function(e){return this.type===W.name&&this.value===e&&!this.containsEsc},ae.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},ae.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},ae.canInsertSemicolon=function(){return this.type===W.eof||this.type===W.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))},ae.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},ae.semicolon=function(){this.eat(W.semi)||this.insertSemicolon()||this.unexpected()},ae.afterTrailingComma=function(e,t){if(this.type==e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},ae.expect=function(e){this.eat(e)||this.unexpected()},ae.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")},ae.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,"Parenthesized pattern")}},ae.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;return t?(n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),void(r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property"))):n>=0||r>=0},ae.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(e.sourceType=this.options.sourceType),this.finishNode(e,"Program")};var he={kind:"loop"},le={kind:"switch"};ue.isLet=function(){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;J.lastIndex=this.pos;var e=J.exec(this.input),t=this.pos+e[0].length,i=this.input.charCodeAt(t);if(91===i||123==i)return!0;if(n(i,!0)){for(var s=t+1;r(this.input.charCodeAt(s),!0);)++s;var a=this.input.slice(t,s);if(!L.test(a))return!0}return!1},ue.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;J.lastIndex=this.pos;var e=J.exec(this.input),t=this.pos+e[0].length;return!(H.test(this.input.slice(this.pos,t))||"function"!==this.input.slice(t,t+8)||t+8!=this.input.length&&r(this.input.charAt(t+8)))},ue.parseStatement=function(e,t,n){var r,i=this.type,s=this.startNode();switch(this.isLet()&&(i=W._var,r="let"),i){case W._break:case W._continue:return this.parseBreakContinueStatement(s,i.keyword);case W._debugger:return this.parseDebuggerStatement(s);case W._do:return this.parseDoStatement(s);case W._for:return this.parseForStatement(s);case W._function:return!e&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1);case W._class:return e||this.unexpected(),this.parseClass(s,!0);case W._if:return this.parseIfStatement(s);case W._return:return this.parseReturnStatement(s);case W._switch:return this.parseSwitchStatement(s);case W._throw:return this.parseThrowStatement(s);case W._try:return this.parseTryStatement(s);case W._const:case W._var:return r=r||this.value,e||"var"==r||this.unexpected(),this.parseVarStatement(s,r);case W._while:return this.parseWhileStatement(s);case W._with:return this.parseWithStatement(s);case W.braceL:return this.parseBlock();case W.semi:return this.parseEmptyStatement(s);case W._export:case W._import:return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===W._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return e||this.unexpected(),this.next(),this.parseFunctionStatement(s,!0);var a=this.value,o=this.parseExpression();return i===W.name&&"Identifier"===o.type&&this.eat(W.colon)?this.parseLabeledStatement(s,a,o):this.parseExpressionStatement(s,o)}},ue.parseBreakContinueStatement=function(e,t){var n=this,r="break"==t;this.next(),this.eat(W.semi)||this.insertSemicolon()?e.label=null:this.type!==W.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var i=0;i=6?this.eat(W.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},ue.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.inAsync&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(he),this.enterLexicalScope(),this.expect(W.parenL),this.type===W.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===W._var||this.type===W._const||n){var r=this.startNode(),i=n?"let":this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,"VariableDeclaration"),!(this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==r.declarations.length||"var"!==i&&r.declarations[0].init?(t>-1&&this.unexpected(t),this.parseFor(e,r)):(this.options.ecmaVersion>=9&&(this.type===W._in?t>-1&&this.unexpected(t):e.await=t>-1),this.parseForIn(e,r))}var s=new c,a=this.parseExpression(!0,s);return this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.options.ecmaVersion>=9&&(this.type===W._in?t>-1&&this.unexpected(t):e.await=t>-1),this.toAssignable(a,!1,s),this.checkLVal(a),this.parseForIn(e,a)):(this.checkExpressionErrors(s,!0),t>-1&&this.unexpected(t),this.parseFor(e,a))},ue.parseFunctionStatement=function(e,t){return this.next(),this.parseFunction(e,!0,!1,t)},ue.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(!this.strict&&this.type==W._function),e.alternate=this.eat(W._else)?this.parseStatement(!this.strict&&this.type==W._function):null,this.finishNode(e,"IfStatement")},ue.parseReturnStatement=function(e){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(W.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},ue.parseSwitchStatement=function(e){var t=this;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(W.braceL),this.labels.push(le),this.enterLexicalScope();for(var n,r=!1;this.type!=W.braceR;)if(t.type===W._case||t.type===W._default){var i=t.type===W._case;n&&t.finishNode(n,"SwitchCase"),e.cases.push(n=t.startNode()),n.consequent=[],t.next(),i?n.test=t.parseExpression():(r&&t.raiseRecoverable(t.lastTokStart,"Multiple default clauses"),r=!0,n.test=null),t.expect(W.colon)}else n||t.unexpected(),n.consequent.push(t.parseStatement(!0));return this.exitLexicalScope(),n&&this.finishNode(n,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},ue.parseThrowStatement=function(e){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var pe=[];ue.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===W._catch){var t=this.startNode();this.next(),this.expect(W.parenL),t.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(t.param,"let"),this.expect(W.parenR),t.body=this.parseBlock(!1),this.exitLexicalScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(W._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},ue.parseVarStatement=function(e,t){return this.next(),this.parseVar(e,!1,t),this.semicolon(),this.finishNode(e,"VariableDeclaration")},ue.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(he),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,"WhileStatement")},ue.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(!1),this.finishNode(e,"WithStatement")},ue.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},ue.parseLabeledStatement=function(e,t,n){for(var r=this,i=0,s=r.labels;i=0;u--){var h=r.labels[u];if(h.statementStart!=e.start)break;h.statementStart=r.start,h.kind=o}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(!0),("ClassDeclaration"==e.body.type||"VariableDeclaration"==e.body.type&&"var"!=e.body.kind||"FunctionDeclaration"==e.body.type&&(this.strict||e.body.generator))&&this.raiseRecoverable(e.body.start,"Invalid labeled declaration"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")},ue.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},ue.parseBlock=function(e){var t=this;void 0===e&&(e=!0);var n=this.startNode();for(n.body=[],this.expect(W.braceL),e&&this.enterLexicalScope();!this.eat(W.braceR);){var r=t.parseStatement(!0);n.body.push(r)}return e&&this.exitLexicalScope(),this.finishNode(n,"BlockStatement")},ue.parseFor=function(e,t){return e.init=t,this.expect(W.semi),e.test=this.type===W.semi?null:this.parseExpression(),this.expect(W.semi),e.update=this.type===W.parenR?null:this.parseExpression(),this.expect(W.parenR),this.exitLexicalScope(),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,"ForStatement")},ue.parseForIn=function(e,t){var n=this.type===W._in?"ForInStatement":"ForOfStatement";return this.next(),"ForInStatement"==n&&("AssignmentPattern"===t.type||"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(this.strict||"Identifier"!==t.declarations[0].id.type))&&this.raise(t.start,"Invalid assignment in for-in loop head"),e.left=t,e.right="ForInStatement"==n?this.parseExpression():this.parseMaybeAssign(),this.expect(W.parenR),this.exitLexicalScope(),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,n)},ue.parseVar=function(e,t,n){var r=this;for(e.declarations=[],e.kind=n;;){var i=r.startNode();if(r.parseVarId(i,n),r.eat(W.eq)?i.init=r.parseMaybeAssign(t):"const"!==n||r.type===W._in||r.options.ecmaVersion>=6&&r.isContextual("of")?"Identifier"==i.id.type||t&&(r.type===W._in||r.isContextual("of"))?i.init=null:r.raise(r.lastTokEnd,"Complex binding patterns require an initialization value"):r.unexpected(),e.declarations.push(r.finishNode(i,"VariableDeclarator")),!r.eat(W.comma))break}return e},ue.parseVarId=function(e,t){e.id=this.parseBindingAtom(t),this.checkLVal(e.id,t,!1)},ue.parseFunction=function(e,t,n,r){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(e.generator=this.eat(W.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&&(e.id="nullableID"===t&&this.type!=W.name?null:this.parseIdent(),e.id&&this.checkLVal(e.id,"var"));var i=this.inGenerator,s=this.inAsync,a=this.yieldPos,o=this.awaitPos,u=this.inFunction;return this.inGenerator=e.generator,this.inAsync=e.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),t||(e.id=this.type==W.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n),this.inGenerator=i,this.inAsync=s,this.yieldPos=a,this.awaitPos=o,this.inFunction=u,this.finishNode(e,t?"FunctionDeclaration":"FunctionExpression")},ue.parseFunctionParams=function(e){this.expect(W.parenL),e.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},ue.parseClass=function(e,t){var n=this;this.next(),this.parseClassId(e,t),this.parseClassSuper(e);var r=this.startNode(),i=!1;for(r.body=[],this.expect(W.braceL);!this.eat(W.braceR);){var s=n.parseClassMember(r);s&&"MethodDefinition"===s.type&&"constructor"===s.kind&&(i&&n.raise(s.start,"Duplicate constructor in the same class"),i=!0)}return e.body=this.finishNode(r,"ClassBody"),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},ue.parseClassMember=function(e){var t=this;if(this.eat(W.semi))return null;var n=this.startNode(),r=function(e,r){void 0===r&&(r=!1);var i=t.start,s=t.startLoc;return!!t.eatContextual(e)&&(!(t.type===W.parenL||r&&t.canInsertSemicolon())||(n.key&&t.unexpected(),n.computed=!1,n.key=t.startNodeAt(i,s),n.key.name=e,t.finishNode(n.key,"Identifier"),!1))};n.kind="method",n["static"]=r("static");var i=this.eat(W.star),s=!1;i||(this.options.ecmaVersion>=8&&r("async",!0)?(s=!0,i=this.options.ecmaVersion>=9&&this.eat(W.star)):r("get")?n.kind="get":r("set")&&(n.kind="set")),n.key||this.parsePropertyName(n);var a=n.key;return n.computed||n["static"]||!("Identifier"===a.type&&"constructor"===a.name||"Literal"===a.type&&"constructor"===a.value)?n["static"]&&"Identifier"===a.type&&"prototype"===a.name&&this.raise(a.start,"Classes may not have a static property named prototype"):("method"!==n.kind&&this.raise(a.start,"Constructor can't have get/set modifier"),i&&this.raise(a.start,"Constructor can't be a generator"),s&&this.raise(a.start,"Constructor can't be an async method"),n.kind="constructor"),this.parseClassMethod(e,n,i,s),"get"===n.kind&&0!==n.value.params.length&&this.raiseRecoverable(n.value.start,"getter should have no params"),"set"===n.kind&&1!==n.value.params.length&&this.raiseRecoverable(n.value.start,"setter should have exactly one param"),"set"===n.kind&&"RestElement"===n.value.params[0].type&&this.raiseRecoverable(n.value.params[0].start,"Setter cannot use rest params"),n},ue.parseClassMethod=function(e,t,n,r){t.value=this.parseMethod(n,r),e.body.push(this.finishNode(t,"MethodDefinition"))},ue.parseClassId=function(e,t){e.id=this.type===W.name?this.parseIdent():t===!0?this.unexpected():null},ue.parseClassSuper=function(e){e.superClass=this.eat(W._extends)?this.parseExprSubscripts():null},ue.parseExport=function(e,t){var n=this;if(this.next(),this.eat(W.star))return this.expectContextual("from"),this.type!==W.string&&this.unexpected(),e.source=this.parseExprAtom(),this.semicolon(),this.finishNode(e,"ExportAllDeclaration");if(this.eat(W._default)){this.checkExport(t,"default",this.lastTokStart);var r;if(this.type===W._function||(r=this.isAsyncFunction())){var i=this.startNode();this.next(),r&&this.next(),e.declaration=this.parseFunction(i,"nullableID",!1,r)}else if(this.type===W._class){var s=this.startNode();e.declaration=this.parseClass(s,"nullableID")}else e.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(e,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())e.declaration=this.parseStatement(!0),"VariableDeclaration"===e.declaration.type?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id.name,e.declaration.id.start),e.specifiers=[],e.source=null;else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==W.string&&this.unexpected(),e.source=this.parseExprAtom();else{for(var a=0,o=e.specifiers;a=6&&e)switch(e.type){case"Identifier":this.inAsync&&"await"===e.name&&this.raise(e.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var i=0,s=e.properties;i=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r,i=e.key;switch(i.type){case"Identifier":r=i.name;break;case"Literal":r=String(i.value);break;default:return}var s=e.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===r&&"init"===s&&(t.proto&&(n&&n.doubleProto<0?n.doubleProto=i.start:this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0));r="$"+r;var a=t[r];if(a){var o;o="init"===s?this.strict&&a.init||a.get||a.set:a.init||a[s],o&&this.raiseRecoverable(i.start,"Redefinition of property")}else a=t[r]={init:!1,get:!1,set:!1};a[s]=!0}},fe.parseExpression=function(e,t){var n=this,r=this.start,i=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===W.comma){var a=this.startNodeAt(r,i);for(a.expressions=[s];this.eat(W.comma);)a.expressions.push(n.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s},fe.parseMaybeAssign=function(e,t,n){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var r=!1,i=-1,s=-1;t?(i=t.parenthesizedAssign,s=t.trailingComma,t.parenthesizedAssign=t.trailingComma=-1):(t=new c,r=!0);var a=this.start,o=this.startLoc;this.type!=W.parenL&&this.type!=W.name||(this.potentialArrowAt=this.start);var u=this.parseMaybeConditional(e,t);if(n&&(u=n.call(this,u,a,o)),this.type.isAssign){var h=this.startNodeAt(a,o);return h.operator=this.value,h.left=this.type===W.eq?this.toAssignable(u,!1,t):u,r||c.call(t),t.shorthandAssign=-1,this.checkLVal(u),this.next(),h.right=this.parseMaybeAssign(e),this.finishNode(h,"AssignmentExpression")}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),s>-1&&(t.trailingComma=s),u},fe.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(W.question)){var s=this.startNodeAt(n,r);return s.test=i,s.consequent=this.parseMaybeAssign(),this.expect(W.colon),s.alternate=this.parseMaybeAssign(e),this.finishNode(s,"ConditionalExpression")}return i},fe.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1);return this.checkExpressionErrors(t)?i:i.start==n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,r,-1,e)},fe.parseExprOp=function(e,t,n,r,i){var s=this.type.binop;if(null!=s&&(!i||this.type!==W._in)&&s>r){var a=this.type===W.logicalOR||this.type===W.logicalAND,o=this.value;this.next();var u=this.start,h=this.startLoc,l=this.parseExprOp(this.parseMaybeUnary(null,!1),u,h,s,i),p=this.buildBinary(t,n,e,l,o,a);return this.parseExprOp(p,t,n,r,i)}return e},fe.buildBinary=function(e,t,n,r,i,s){var a=this.startNodeAt(e,t);return a.left=n,a.operator=i,a.right=r,this.finishNode(a,s?"LogicalExpression":"BinaryExpression")},fe.parseMaybeUnary=function(e,t){var n,r=this,i=this.start,s=this.startLoc;if(this.inAsync&&this.isContextual("await"))n=this.parseAwait(),t=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===W.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(e,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):t=!0,n=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(n=this.parseExprSubscripts(e),this.checkExpressionErrors(e))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=r.startNodeAt(i,s);u.operator=r.value,u.prefix=!1,u.argument=n,r.checkLVal(n),r.next(),n=r.finishNode(u,"UpdateExpression")}}return!t&&this.eat(W.starstar)?this.buildBinary(i,s,n,this.parseMaybeUnary(null,!1),"**",!1):n},fe.parseExprSubscripts=function(e){var t=this.start,n=this.startLoc,r=this.parseExprAtom(e),i="ArrowFunctionExpression"===r.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(e)||i)return r;var s=this.parseSubscripts(r,t,n);return e&&"MemberExpression"===s.type&&(e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1)),s},fe.parseSubscripts=function(e,t,n,r){for(var i=this,s=this.options.ecmaVersion>=8&&"Identifier"===e.type&&"async"===e.name&&this.lastTokEnd==e.end&&!this.canInsertSemicolon()&&"async"===this.input.slice(e.start,e.end),a=void 0;;)if((a=i.eat(W.bracketL))||i.eat(W.dot)){var o=i.startNodeAt(t,n);o.object=e,o.property=a?i.parseExpression():i.parseIdent(!0),o.computed=!!a,a&&i.expect(W.bracketR),e=i.finishNode(o,"MemberExpression")}else if(!r&&i.eat(W.parenL)){var u=new c,h=i.yieldPos,l=i.awaitPos;i.yieldPos=0,i.awaitPos=0;var p=i.parseExprList(W.parenR,i.options.ecmaVersion>=8,!1,u);if(s&&!i.canInsertSemicolon()&&i.eat(W.arrow))return i.checkPatternErrors(u,!1),i.checkYieldAwaitInDefaultParams(),i.yieldPos=h,i.awaitPos=l,i.parseArrowExpression(i.startNodeAt(t,n),p,!0);i.checkExpressionErrors(u,!0),i.yieldPos=h||i.yieldPos,i.awaitPos=l||i.awaitPos;var f=i.startNodeAt(t,n);f.callee=e,f.arguments=p,e=i.finishNode(f,"CallExpression")}else{if(i.type!==W.backQuote)return e;var d=i.startNodeAt(t,n);d.tag=e,d.quasi=i.parseTemplate({isTagged:!0}),e=i.finishNode(d,"TaggedTemplateExpression")}},fe.parseExprAtom=function(e){var t,n=this.potentialArrowAt==this.start;switch(this.type){case W._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),t=this.startNode(),this.next(),this.type!==W.dot&&this.type!==W.bracketL&&this.type!==W.parenL&&this.unexpected(),this.finishNode(t,"Super");case W._this:return t=this.startNode(),this.next(),this.finishNode(t,"ThisExpression");case W.name:var r=this.start,i=this.startLoc,s=this.containsEsc,a=this.parseIdent(this.type!==W.name);if(this.options.ecmaVersion>=8&&!s&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(W._function))return this.parseFunction(this.startNodeAt(r,i),!1,!1,!0);if(n&&!this.canInsertSemicolon()){if(this.eat(W.arrow))return this.parseArrowExpression(this.startNodeAt(r,i),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===W.name&&!s)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(W.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,i),[a],!0)}return a;case W.regexp:var o=this.value;return t=this.parseLiteral(o.value),t.regex={pattern:o.pattern,flags:o.flags},t;case W.num:case W.string:return this.parseLiteral(this.value);case W._null:case W._true:case W._false:return t=this.startNode(),t.value=this.type===W._null?null:this.type===W._true,t.raw=this.type.keyword,this.next(),this.finishNode(t,"Literal");case W.parenL:var u=this.start,h=this.parseParenAndDistinguishExpression(n);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),h;case W.bracketL:return t=this.startNode(),this.next(),t.elements=this.parseExprList(W.bracketR,!0,!0,e),this.finishNode(t,"ArrayExpression");case W.braceL:return this.parseObj(!1,e);case W._function:return t=this.startNode(),this.next(),this.parseFunction(t,!1);case W._class:return this.parseClass(this.startNode(),!1);case W._new:return this.parseNew();case W.backQuote:return this.parseTemplate();default:this.unexpected()}},fe.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(t,"Literal")},fe.parseParenExpression=function(){this.expect(W.parenL);var e=this.parseExpression();return this.expect(W.parenR),e},fe.parseParenAndDistinguishExpression=function(e){var t,n=this,r=this.start,i=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,u=this.startLoc,h=[],l=!0,p=!1,f=new c,d=this.yieldPos,g=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==W.parenR;){if(l?l=!1:n.expect(W.comma),s&&n.afterTrailingComma(W.parenR,!0)){p=!0;break}if(n.type===W.ellipsis){a=n.start,h.push(n.parseParenItem(n.parseRestBinding())),n.type===W.comma&&n.raise(n.start,"Comma is not permitted after the rest element");break}h.push(n.parseMaybeAssign(!1,f,n.parseParenItem))}var m=this.start,x=this.startLoc;if(this.expect(W.parenR),e&&!this.canInsertSemicolon()&&this.eat(W.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=g,this.parseParenArrowList(r,i,h);h.length&&!p||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(f,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=g||this.awaitPos,h.length>1?(t=this.startNodeAt(o,u),t.expressions=h,this.finishNodeAt(t,"SequenceExpression",m,x)):t=h[0]}else t=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(r,i);return y.expression=t,this.finishNode(y,"ParenthesizedExpression")}return t},fe.parseParenItem=function(e){return e},fe.parseParenArrowList=function(e,t,n){return this.parseArrowExpression(this.startNodeAt(e,t),n)};var de=[];fe.parseNew=function(){var e=this.startNode(),t=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(W.dot)){e.meta=t;var n=this.containsEsc;return e.property=this.parseIdent(!0),("target"!==e.property.name||n)&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(e.start,"new.target can only be used in functions"),this.finishNode(e,"MetaProperty")}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(),r,i,!0),this.eat(W.parenL)?e.arguments=this.parseExprList(W.parenR,this.options.ecmaVersion>=8,!1):e.arguments=de,this.finishNode(e,"NewExpression")},fe.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===W.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===W.backQuote,this.finishNode(n,"TemplateElement")},fe.parseTemplate=function(e){var t=this;void 0===e&&(e={});var n=e.isTagged;void 0===n&&(n=!1);var r=this.startNode();this.next(),r.expressions=[];var i=this.parseTemplateElement({isTagged:n});for(r.quasis=[i];!i.tail;)t.expect(W.dollarBraceL),r.expressions.push(t.parseExpression()),t.expect(W.braceR),r.quasis.push(i=t.parseTemplateElement({isTagged:n}));return this.next(),this.finishNode(r,"TemplateLiteral")},fe.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===W.name||this.type===W.num||this.type===W.string||this.type===W.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===W.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))},fe.parseObj=function(e,t){var n=this,r=this.startNode(),i=!0,s={};for(r.properties=[],this.next();!this.eat(W.braceR);){if(i)i=!1;else if(n.expect(W.comma),n.afterTrailingComma(W.braceR))break;var a=n.parseProperty(e,t);e||n.checkPropClash(a,s,t),r.properties.push(a)}return this.finishNode(r,e?"ObjectPattern":"ObjectExpression")},fe.parseProperty=function(e,t){var n,r,i,s,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(W.ellipsis))return e?(a.argument=this.parseIdent(!1),this.type===W.comma&&this.raise(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(this.type===W.parenL&&t&&(t.parenthesizedAssign<0&&(t.parenthesizedAssign=this.start),t.parenthesizedBind<0&&(t.parenthesizedBind=this.start)),a.argument=this.parseMaybeAssign(!1,t),this.type===W.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(e||t)&&(i=this.start,s=this.startLoc),e||(n=this.eat(W.star)));var o=this.containsEsc;return this.parsePropertyName(a),!e&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(r=!0,n=this.options.ecmaVersion>=9&&this.eat(W.star),this.parsePropertyName(a,t)):r=!1,this.parsePropertyValue(a,e,n,r,i,s,t,o),this.finishNode(a,"Property")},fe.parsePropertyValue=function(e,t,n,r,i,s,a,o){if((n||r)&&this.type===W.colon&&this.unexpected(),this.eat(W.colon))e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init";else if(this.options.ecmaVersion>=6&&this.type===W.parenL)t&&this.unexpected(),e.kind="init",e.method=!0,e.value=this.parseMethod(n,r);else if(t||o||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type==W.comma||this.type==W.braceR)this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?(this.checkUnreserved(e.key),e.kind="init",t?e.value=this.parseMaybeDefault(i,s,e.key):this.type===W.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,s,e.key)):e.value=e.key,e.shorthand=!0):this.unexpected();else{(n||r)&&this.unexpected(),e.kind=e.key.name,this.parsePropertyName(e),e.value=this.parseMethod(!1);var u="get"===e.kind?0:1;if(e.value.params.length!==u){var h=e.value.start;"get"===e.kind?this.raiseRecoverable(h,"getter should have no params"):this.raiseRecoverable(h,"setter should have exactly one param")}else"set"===e.kind&&"RestElement"===e.value.params[0].type&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")}},fe.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(W.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(W.bracketR),e.key;e.computed=!1}return e.key=this.type===W.num||this.type===W.string?this.parseExprAtom():this.parseIdent(!0)},fe.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=!1,e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},fe.parseMethod=function(e,t){var n=this.startNode(),r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=e),this.options.ecmaVersion>=8&&(n.async=!!t),this.inGenerator=n.generator,this.inAsync=n.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(W.parenL),n.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(n,"FunctionExpression")},fe.parseArrowExpression=function(e,t,n){var r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.enterFunctionScope(),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.inGenerator=!1,this.inAsync=e.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(e,"ArrowFunctionExpression")},fe.parseFunctionBody=function(e,t){var n=t&&this.type!==W.braceL,r=this.strict,i=!1;if(n)e.body=this.parseMaybeAssign(),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);r&&!s||(i=this.strictDirective(this.end),i&&s&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var a=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!r&&!i&&!t&&this.isSimpleParamList(e.params)),e.body=this.parseBlock(!1),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=a}this.exitFunctionScope(),this.strict&&e.id&&this.checkLVal(e.id,"none"),this.strict=r},fe.isSimpleParamList=function(e){for(var t=0,n=e;t0;)t[n]=arguments[n+1];for(var r=0,i=t;r=1;t--){var n=e.context[t];if("function"===n.token)return n.generator}return!1},Ee.updateContext=function(e){var t,n=this.type;n.keyword&&e==W.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},W.parenR.updateContext=W.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var e=this.context.pop();e===_e.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},W.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?_e.b_stat:_e.b_expr),this.exprAllowed=!0},W.dollarBraceL.updateContext=function(){this.context.push(_e.b_tmpl),this.exprAllowed=!0},W.parenL.updateContext=function(e){var t=e===W._if||e===W._for||e===W._with||e===W._while;this.context.push(t?_e.p_stat:_e.p_expr),this.exprAllowed=!0},W.incDec.updateContext=function(){},W._function.updateContext=W._class.updateContext=function(e){e.beforeExpr&&e!==W.semi&&e!==W._else&&(e!==W.colon&&e!==W.braceL||this.curContext()!==_e.b_stat)?this.context.push(_e.f_expr):this.context.push(_e.f_stat),this.exprAllowed=!1},W.backQuote.updateContext=function(){this.curContext()===_e.q_tmpl?this.context.pop():this.context.push(_e.q_tmpl),this.exprAllowed=!1},W.star.updateContext=function(e){if(e==W._function){var t=this.context.length-1;this.context[t]===_e.f_expr?this.context[t]=_e.f_expr_gen:this.context[t]=_e.f_gen}this.exprAllowed=!0},W.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&("of"==this.value&&!this.exprAllowed||"yield"==this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var Te={$LONE:["ASCII","ASCII_Hex_Digit","AHex","Alphabetic","Alpha","Any","Assigned","Bidi_Control","Bidi_C","Bidi_Mirrored","Bidi_M","Case_Ignorable","CI","Cased","Changes_When_Casefolded","CWCF","Changes_When_Casemapped","CWCM","Changes_When_Lowercased","CWL","Changes_When_NFKC_Casefolded","CWKCF","Changes_When_Titlecased","CWT","Changes_When_Uppercased","CWU","Dash","Default_Ignorable_Code_Point","DI","Deprecated","Dep","Diacritic","Dia","Emoji","Emoji_Component","Emoji_Modifier","Emoji_Modifier_Base","Emoji_Presentation","Extender","Ext","Grapheme_Base","Gr_Base","Grapheme_Extend","Gr_Ext","Hex_Digit","Hex","IDS_Binary_Operator","IDSB","IDS_Trinary_Operator","IDST","ID_Continue","IDC","ID_Start","IDS","Ideographic","Ideo","Join_Control","Join_C","Logical_Order_Exception","LOE","Lowercase","Lower","Math","Noncharacter_Code_Point","NChar","Pattern_Syntax","Pat_Syn","Pattern_White_Space","Pat_WS","Quotation_Mark","QMark","Radical","Regional_Indicator","RI","Sentence_Terminal","STerm","Soft_Dotted","SD","Terminal_Punctuation","Term","Unified_Ideograph","UIdeo","Uppercase","Upper","Variation_Selector","VS","White_Space","space","XID_Continue","XIDC","XID_Start","XIDS"],General_Category:["Cased_Letter","LC","Close_Punctuation","Pe","Connector_Punctuation","Pc","Control","Cc","cntrl","Currency_Symbol","Sc","Dash_Punctuation","Pd","Decimal_Number","Nd","digit","Enclosing_Mark","Me","Final_Punctuation","Pf","Format","Cf","Initial_Punctuation","Pi","Letter","L","Letter_Number","Nl","Line_Separator","Zl","Lowercase_Letter","Ll","Mark","M","Combining_Mark","Math_Symbol","Sm","Modifier_Letter","Lm","Modifier_Symbol","Sk","Nonspacing_Mark","Mn","Number","N","Open_Punctuation","Ps","Other","C","Other_Letter","Lo","Other_Number","No","Other_Punctuation","Po","Other_Symbol","So","Paragraph_Separator","Zp","Private_Use","Co","Punctuation","P","punct","Separator","Z","Space_Separator","Zs","Spacing_Mark","Mc","Surrogate","Cs","Symbol","S","Titlecase_Letter","Lt","Unassigned","Cn","Uppercase_Letter","Lu"],Script:["Adlam","Adlm","Ahom","Anatolian_Hieroglyphs","Hluw","Arabic","Arab","Armenian","Armn","Avestan","Avst","Balinese","Bali","Bamum","Bamu","Bassa_Vah","Bass","Batak","Batk","Bengali","Beng","Bhaiksuki","Bhks","Bopomofo","Bopo","Brahmi","Brah","Braille","Brai","Buginese","Bugi","Buhid","Buhd","Canadian_Aboriginal","Cans","Carian","Cari","Caucasian_Albanian","Aghb","Chakma","Cakm","Cham","Cherokee","Cher","Common","Zyyy","Coptic","Copt","Qaac","Cuneiform","Xsux","Cypriot","Cprt","Cyrillic","Cyrl","Deseret","Dsrt","Devanagari","Deva","Duployan","Dupl","Egyptian_Hieroglyphs","Egyp","Elbasan","Elba","Ethiopic","Ethi","Georgian","Geor","Glagolitic","Glag","Gothic","Goth","Grantha","Gran","Greek","Grek","Gujarati","Gujr","Gurmukhi","Guru","Han","Hani","Hangul","Hang","Hanunoo","Hano","Hatran","Hatr","Hebrew","Hebr","Hiragana","Hira","Imperial_Aramaic","Armi","Inherited","Zinh","Qaai","Inscriptional_Pahlavi","Phli","Inscriptional_Parthian","Prti","Javanese","Java","Kaithi","Kthi","Kannada","Knda","Katakana","Kana","Kayah_Li","Kali","Kharoshthi","Khar","Khmer","Khmr","Khojki","Khoj","Khudawadi","Sind","Lao","Laoo","Latin","Latn","Lepcha","Lepc","Limbu","Limb","Linear_A","Lina","Linear_B","Linb","Lisu","Lycian","Lyci","Lydian","Lydi","Mahajani","Mahj","Malayalam","Mlym","Mandaic","Mand","Manichaean","Mani","Marchen","Marc","Masaram_Gondi","Gonm","Meetei_Mayek","Mtei","Mende_Kikakui","Mend","Meroitic_Cursive","Merc","Meroitic_Hieroglyphs","Mero","Miao","Plrd","Modi","Mongolian","Mong","Mro","Mroo","Multani","Mult","Myanmar","Mymr","Nabataean","Nbat","New_Tai_Lue","Talu","Newa","Nko","Nkoo","Nushu","Nshu","Ogham","Ogam","Ol_Chiki","Olck","Old_Hungarian","Hung","Old_Italic","Ital","Old_North_Arabian","Narb","Old_Permic","Perm","Old_Persian","Xpeo","Old_South_Arabian","Sarb","Old_Turkic","Orkh","Oriya","Orya","Osage","Osge","Osmanya","Osma","Pahawh_Hmong","Hmng","Palmyrene","Palm","Pau_Cin_Hau","Pauc","Phags_Pa","Phag","Phoenician","Phnx","Psalter_Pahlavi","Phlp","Rejang","Rjng","Runic","Runr","Samaritan","Samr","Saurashtra","Saur","Sharada","Shrd","Shavian","Shaw","Siddham","Sidd","SignWriting","Sgnw","Sinhala","Sinh","Sora_Sompeng","Sora","Soyombo","Soyo","Sundanese","Sund","Syloti_Nagri","Sylo","Syriac","Syrc","Tagalog","Tglg","Tagbanwa","Tagb","Tai_Le","Tale","Tai_Tham","Lana","Tai_Viet","Tavt","Takri","Takr","Tamil","Taml","Tangut","Tang","Telugu","Telu","Thaana","Thaa","Thai","Tibetan","Tibt","Tifinagh","Tfng","Tirhuta","Tirh","Ugaritic","Ugar","Vai","Vaii","Warang_Citi","Wara","Yi","Yiii","Zanabazar_Square","Zanb"]};Array.prototype.push.apply(Te.$LONE,Te.General_Category),Te.gc=Te.General_Category,Te.sc=Te.Script_Extensions=Te.scx=Te.Script;var Se=se.prototype,ke=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":""),this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=[],this.backReferenceNames=[]};ke.prototype.reset=function(e,t,n){var r=n.indexOf("u")!==-1;this.start=0|e,this.source=t+"",this.flags=n,this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchN=r&&this.parser.options.ecmaVersion>=9},ke.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},ke.prototype.at=function(e){var t=this.source,n=t.length;if(e>=n)return-1;var r=t.charCodeAt(e);return!this.switchU||r<=55295||r>=57344||e+1>=n?r:(r<<10)+t.charCodeAt(e+1)-56613888},ke.prototype.nextIndex=function(e){var t=this.source,n=t.length;if(e>=n)return n;var r=t.charCodeAt(e);return!this.switchU||r<=55295||r>=57344||e+1>=n?e+1:e+2},ke.prototype.current=function(){return this.at(this.pos)},ke.prototype.lookahead=function(){return this.at(this.nextIndex(this.pos))},ke.prototype.advance=function(){this.pos=this.nextIndex(this.pos)},ke.prototype.eat=function(e){return this.current()===e&&(this.advance(),!0)},Se.validateRegExpFlags=function(e){for(var t=this,n=e.validFlags,r=e.flags,i=0;i-1&&t.raise(e.start,"Duplicate regular expression flag")}},Se.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&e.groupNames.length>0&&(e.switchN=!0,this.regexp_pattern(e))},Se.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames.length=0,e.backReferenceNames.length=0,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t=9&&(n=e.eat(60)), -e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},Se.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},Se.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},Se.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i=9?this.regexp_groupSpecifier(e):63===e.current()&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},Se.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},Se.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},Se.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!g(t)&&(e.lastIntValue=t,e.advance(),!0)},Se.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!g(n);)e.advance();return e.pos!==t},Se.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return!(t===-1||36===t||t>=40&&t<=43||46===t||63===t||91===t||94===t||124===t)&&(e.advance(),!0)},Se.regexp_groupSpecifier=function(e){if(e.eat(63)){if(this.regexp_eatGroupName(e))return e.groupNames.indexOf(e.lastStringValue)!==-1&&e.raise("Duplicate capture group name"),void e.groupNames.push(e.lastStringValue);e.raise("Invalid group")}},Se.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},Se.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=d(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=d(e.lastIntValue);return!0}return!1},Se.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=e.current();return e.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(e)&&(n=e.lastIntValue),m(n)?(e.lastIntValue=n,!0):(e.pos=t,!1)},Se.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=e.current();return e.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(e)&&(n=e.lastIntValue),x(n)?(e.lastIntValue=n,!0):(e.pos=t,!1)},Se.regexp_eatAtomEscape=function(e){return!!(this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e))||(e.switchU&&(99===e.current()&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},Se.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},Se.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},Se.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},Se.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},Se.regexp_eatZero=function(e){return 48===e.current()&&!T(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},Se.regexp_eatControlEscape=function(e){var t=e.current();return 116===t?(e.lastIntValue=9,e.advance(),!0):110===t?(e.lastIntValue=10,e.advance(),!0):118===t?(e.lastIntValue=11,e.advance(),!0):102===t?(e.lastIntValue=12,e.advance(),!0):114===t&&(e.lastIntValue=13,e.advance(),!0)},Se.regexp_eatControlLetter=function(e){var t=e.current();return!!y(t)&&(e.lastIntValue=t%32,e.advance(),!0)},Se.regexp_eatRegExpUnicodeEscapeSequence=function(e){var t=e.pos;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var n=e.lastIntValue;if(e.switchU&&n>=55296&&n<=56319){var r=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(i>=56320&&i<=57343)return e.lastIntValue=1024*(n-55296)+(i-56320)+65536,!0}e.pos=r,e.lastIntValue=n}return!0}if(e.switchU&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&v(e.lastIntValue))return!0;e.switchU&&e.raise("Invalid unicode escape"),e.pos=t}return!1},Se.regexp_eatIdentityEscape=function(e){if(e.switchU)return!!this.regexp_eatSyntaxCharacter(e)||!!e.eat(47)&&(e.lastIntValue=47,!0);var t=e.current();return!(99===t||e.switchN&&107===t)&&(e.lastIntValue=t,e.advance(),!0)},Se.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1},Se.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(b(t))return e.lastIntValue=-1,e.advance(),!0;if(e.switchU&&this.options.ecmaVersion>=9&&(80===t||112===t)){if(e.lastIntValue=-1,e.advance(),e.eat(123)&&this.regexp_eatUnicodePropertyValueExpression(e)&&e.eat(125))return!0;e.raise("Invalid property name")}return!1},Se.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),!0}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i),!0}return!1},Se.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Te.hasOwnProperty(t)&&Te[t].indexOf(n)!==-1||e.raise("Invalid property name")},Se.regexp_validateUnicodePropertyNameOrValue=function(e,t){Te.$LONE.indexOf(t)===-1&&e.raise("Invalid property name")},Se.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";_(t=e.current());)e.lastStringValue+=d(t),e.advance();return""!==e.lastStringValue},Se.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";E(t=e.current());)e.lastStringValue+=d(t),e.advance();return""!==e.lastStringValue},Se.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},Se.regexp_eatCharacterClass=function(e){if(e.eat(91)){if(e.eat(94),this.regexp_classRanges(e),e.eat(93))return!0;e.raise("Unterminated character class")}return!1},Se.regexp_classRanges=function(e){for(var t=this;this.regexp_eatClassAtom(e);){var n=e.lastIntValue;if(e.eat(45)&&t.regexp_eatClassAtom(e)){var r=e.lastIntValue;!e.switchU||n!==-1&&r!==-1||e.raise("Invalid character class"),n!==-1&&r!==-1&&n>r&&e.raise("Range out of order in character class")}}},Se.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(99===n||w(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return 93!==r&&(e.lastIntValue=r,e.advance(),!0)},Se.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},Se.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!T(t)&&95!==t)&&(e.lastIntValue=t%32,e.advance(),!0)},Se.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1},Se.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;T(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t},Se.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;S(n=e.current());)e.lastIntValue=16*e.lastIntValue+k(n),e.advance();return e.pos!==t},Se.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*n+e.lastIntValue:e.lastIntValue=8*t+n}else e.lastIntValue=t;return!0}return!1},Se.regexp_eatOctalDigit=function(e){var t=e.current();return w(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},Se.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r=this.input.length?this.finishToken(W.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},Ae.readToken=function(e){return n(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},Ae.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=57344)return e;var t=this.input.charCodeAt(this.pos+1);return(e<<10)+t-56613888},Ae.skipBlockComment=function(){var e=this,t=this.options.onComment&&this.curPosition(),n=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(r===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations){q.lastIndex=n;for(var i;(i=q.exec(this.input))&&i.index8&&t<14||t>=5760&&Y.test(String.fromCharCode(t))))break e;++e.pos}}},Ae.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},Ae.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===e&&46===t?(this.pos+=3,this.finishToken(W.ellipsis)):(++this.pos,this.finishToken(W.dot))},Ae.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(W.assign,2):this.finishOp(W.slash,1)},Ae.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=42===e?W.star:W.modulo;return this.options.ecmaVersion>=7&&42==e&&42===t&&(++n,r=W.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(W.assign,n+1):this.finishOp(r,n)},Ae.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.finishOp(124===e?W.logicalOR:W.logicalAND,2):61===t?this.finishOp(W.assign,2):this.finishOp(124===e?W.bitwiseOR:W.bitwiseAND,1)},Ae.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(W.assign,2):this.finishOp(W.bitwiseXOR,1)},Ae.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?45!=t||this.inModule||62!=this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!H.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(W.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(W.assign,2):this.finishOp(W.plusMin,1)},Ae.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(W.assign,n+1):this.finishOp(W.bitShift,n)):33!=t||60!=e||this.inModule||45!=this.input.charCodeAt(this.pos+2)||45!=this.input.charCodeAt(this.pos+3)?(61===t&&(n=2),this.finishOp(W.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},Ae.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(W.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(W.arrow)):this.finishOp(61===e?W.eq:W.prefix,1)},Ae.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(W.parenL);case 41:return++this.pos,this.finishToken(W.parenR);case 59:return++this.pos,this.finishToken(W.semi);case 44:return++this.pos,this.finishToken(W.comma);case 91:return++this.pos,this.finishToken(W.bracketL);case 93:return++this.pos,this.finishToken(W.bracketR);case 123:return++this.pos,this.finishToken(W.braceL);case 125:return++this.pos,this.finishToken(W.braceR);case 58:return++this.pos,this.finishToken(W.colon);case 63:return++this.pos,this.finishToken(W.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(W.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 126:return this.finishOp(W.prefix,1)}this.raise(this.pos,"Unexpected character '"+A(e)+"'")},Ae.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},Ae.readRegexp=function(){for(var e,t,n=this,r=this.pos;;){n.pos>=n.input.length&&n.raise(r,"Unterminated regular expression");var i=n.input.charAt(n.pos);if(H.test(i)&&n.raise(r,"Unterminated regular expression"),e)e=!1;else{if("["===i)t=!0;else if("]"===i&&t)t=!1;else if("/"===i&&!t)break;e="\\"===i}++n.pos}var s=this.input.slice(r,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var u=this.regexpState||(this.regexpState=new ke(this));u.reset(r,s,o),this.validateRegExpFlags(u),this.validateRegExpPattern(u);var h=null;try{h=new RegExp(s,o)}catch(l){}return this.finishToken(W.regexp,{pattern:s,flags:o,value:h})},Ae.readInt=function(e,t){for(var n=this,r=this.pos,i=0,s=0,a=null==t?1/0:t;s=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0,u>=e)break;++n.pos,i=i*e+u}return this.pos===r||null!=t&&this.pos-r!==t?null:i},Ae.readRadixNumber=function(e){this.pos+=2;var t=this.readInt(e);return null==t&&this.raise(this.start+2,"Expected number in radix "+e),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(W.num,t)},Ae.readNumber=function(e){var t=this.pos;e||null!==this.readInt(10)||this.raise(t,"Invalid number");var r=this.pos-t>=2&&48===this.input.charCodeAt(t);r&&this.strict&&this.raise(t,"Invalid number"),r&&/[89]/.test(this.input.slice(t,this.pos))&&(r=!1);var i=this.input.charCodeAt(this.pos);46!==i||r||(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||r||(i=this.input.charCodeAt(++this.pos),43!==i&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s=this.input.slice(t,this.pos),a=r?parseInt(s,8):parseFloat(s);return this.finishToken(W.num,a)},Ae.readCodePoint=function(){var e,t=this.input.charCodeAt(this.pos);if(123===t){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else e=this.readHexChar(4);return e},Ae.readString=function(e){for(var t=this,n="",r=++this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated string constant");var i=t.input.charCodeAt(t.pos);if(i===e)break;92===i?(n+=t.input.slice(r,t.pos),n+=t.readEscapedChar(!1),r=t.pos):(a(i)&&t.raise(t.start,"Unterminated string constant"),++t.pos)}return n+=this.input.slice(r,this.pos++),this.finishToken(W.string,n)};var Oe={};Ae.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==Oe)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},Ae.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Oe;this.raise(e,t)},Ae.readTmplToken=function(){for(var e=this,t="",n=this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated template");var r=e.input.charCodeAt(e.pos);if(96===r||36===r&&123===e.input.charCodeAt(e.pos+1))return e.pos!==e.start||e.type!==W.template&&e.type!==W.invalidTemplate?(t+=e.input.slice(n,e.pos),e.finishToken(W.template,t)):36===r?(e.pos+=2,e.finishToken(W.dollarBraceL)):(++e.pos,e.finishToken(W.backQuote));if(92===r)t+=e.input.slice(n,e.pos),t+=e.readEscapedChar(!0),n=e.pos;else if(a(r)){switch(t+=e.input.slice(n,e.pos),++e.pos,r){case 13:10===e.input.charCodeAt(e.pos)&&++e.pos;case 10:t+="\n";break;default:t+=String.fromCharCode(r)}e.options.locations&&(++e.curLine,e.lineStart=e.pos),n=e.pos}else++e.pos}},Ae.readInvalidTemplateToken=function(){for(var e=this;this.pos=48&&t<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(n,8);return r>255&&(n=n.slice(0,-1),r=parseInt(n,8)),this.pos+=n.length-1,t=this.input.charCodeAt(this.pos),"0"===n&&56!=t&&57!=t||!this.strict&&!e||this.invalidStringToken(this.pos-1-n.length,"Octal literal in strict mode"),String.fromCharCode(r)}return String.fromCharCode(t)}},Ae.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return null===n&&this.invalidStringToken(t,"Bad character escape sequence"),n},Ae.readWord1=function(){var e=this;this.containsEsc=!1;for(var t="",i=!0,s=this.pos,a=this.options.ecmaVersion>=6;this.pos0&&t.push(", "),t.push(" "),t.push("user_"),t.push(i)}t.push(") {\n")}for(var s=0;s1){for(var a=null,o=0;o0&&t.push(","),this.astGeneric(e.declarations[r],t,n);return t.push(";"),t}},{key:"astVariableDeclarator",value:function(e,t,n){return this.astGeneric(e.id,t,n),null!==e.init&&(t.push("="),this.astGeneric(e.init,t,n)),t}},{key:"astIfStatement",value:function(e,t,n){return t.push("if ("),this.astGeneric(e.test,t,n),t.push(")"),"BlockStatement"===e.consequent.type?this.astGeneric(e.consequent,t,n):(t.push(" {\n"),this.astGeneric(e.consequent,t,n),t.push("\n}\n")),e.alternate&&(t.push("else "),"BlockStatement"===e.alternate.type?this.astGeneric(e.alternate,t,n):(t.push(" {\n"),this.astGeneric(e.alternate,t,n),t.push("\n}\n"))),t}},{key:"astBreakStatement",value:function(e,t,n){return t.push("break;\n"),t}},{key:"astContinueStatement",value:function(e,t,n){return t.push("continue;\n"),t}},{key:"astLogicalExpression",value:function(e,t,n){return t.push("("),this.astGeneric(e.left,t,n),t.push(e.operator),this.astGeneric(e.right,t,n),t.push(")"),t}},{key:"astUpdateExpression",value:function(e,t,n){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,n)):(this.astGeneric(e.argument,t,n),t.push(e.operator)),t}},{key:"astUnaryExpression",value:function(e,t,n){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,n)):(this.astGeneric(e.argument,t,n),t.push(e.operator)),t}},{key:"astThisExpression",value:function(e,t,n){return t.push("_this"),t}},{key:"astMemberExpression",value:function(e,t,n){if(e.computed)if("Identifier"===e.object.type)this.astGeneric(e.object,t,n),t.push("["),this.astGeneric(e.property,t,n),t.push("]");else{this.astGeneric(e.object,t,n);var r=t.pop();t.push("]["),this.astGeneric(e.property,t,n),t.push(r)}else{var i=this.astMemberExpressionUnroll(e);switch("Identifier"===e.property.type&&e.computed&&(i="user_"+i),0===i.indexOf("this")&&(i="_"+i),i){case"_this.output.x":t.push(this.output[0]);break;case"_this.output.y":t.push(this.output[1]);break;case"_this.output.z":t.push(this.output[2]);break;default:t.push(i)}}return t}},{key:"astSequenceExpression",value:function(e,t,n){for(var r=0;r0&&t.push(","),this.astGeneric(e.expressions,t,n);return t}},{key:"astCallExpression",value:function(e,t,n){if(e.callee){var r=this.astMemberExpressionUnroll(e.callee);n.calledFunctions.indexOf(r)<0&&n.calledFunctions.push(r),n.hasOwnProperty("funcName")||(n.calledFunctionsArguments[r]=[]);var i=[];n.calledFunctionsArguments[r].push(i),t.push(r),t.push("(");for(var s=0;s0&&t.push(", "),this.astGeneric(a,t,n),"Identifier"===a.type){var o=n.paramNames.indexOf(a.name);o===-1?i.push(null):i.push({name:a.name,type:n.paramTypes[o]})}else i.push(null)}return t.push(")"),t}throw this.astErrorOutput("Unknown CallExpression",e,n)}},{key:"astArrayExpression",value:function(e,t,n){var r=e.elements.length;t.push("new Float32Array(");for(var i=0;i0&&t.push(", ");var s=e.elements[i];this.astGeneric(s,t,n)}return t.push(")"),t}},{key:"astDebuggerStatement",value:function(e,t,n){return t.push("debugger;"),t}}],[{key:"astFunctionPrototype",value:function(e,t,n){if(n.isRootKernel||n.isSubKernel)return t;t.push(n.returnType),t.push(" "),t.push(n.functionName),t.push("(");for(var r=0;r0&&t.push(", "),t.push(n.paramTypes[r]),t.push(" "),t.push("user_"),t.push(n.paramNames[r]);return t.push(");\n"),t}}]),t}(o)},{"../../core/utils":32,"../function-node-base":7}],3:[function(e,t,n){function r(e){return/^function /.test(e)&&(e=e.substring(9)),e.replace(/[_]typeof/g,"typeof")}function i(e){return e.replace(/[_]typeof/g,"typeof")}var s=e("../../core/utils"),a=e("../kernel-run-shortcut");t.exports=function(e,t){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+"\n };\n const Utils = utils;\n class "+(t||"Kernel")+" {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(e.paramNames)+";\n this.paramTypes = "+JSON.stringify(e.paramTypes)+";\n this.texSize = "+JSON.stringify(e.texSize)+";\n this.output = "+JSON.stringify(e.output)+";\n this._kernelString = `"+e._kernelString+"`;\n this.output = "+JSON.stringify(e.output)+";\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(e.build.toString())+"\n "+r(e.setupParams.toString())+"\n run () { "+e.kernelString+" }\n getKernelString() { return this._kernelString; }\n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],4:[function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n1?h=h.filter(function(e){return/^function/.test(e)?e:(l=e,!1)}):l=h.shift();var p=this._kernelString="\n\t\tvar LOOP_MAX = "+this._getLoopMaxString()+";\n\t\tvar _this = this;\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" var "+e+" = null;\n"}).join(""))+"\n return function ("+this.paramNames.map(function(e){return"user_"+e}).join(", ")+") {\n "+this._processInputs()+"\n var ret = new Array("+n[2]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z = new Array("+n[2]+");\n"}).join(""))+"\n for (this.thread.z = 0; this.thread.z < "+n[2]+"; this.thread.z++) {\n ret[this.thread.z] = new Array("+n[1]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z[this.thread.z] = new Array("+n[1]+");\n"}).join(""))+"\n for (this.thread.y = 0; this.thread.y < "+n[1]+"; this.thread.y++) {\n ret[this.thread.z][this.thread.y] = new Array("+n[0]+");\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z[this.thread.z][this.thread.y] = new Array("+n[0]+");\n"}).join(""))+"\n for (this.thread.x = 0; this.thread.x < "+n[0]+"; this.thread.x++) {\n var kernelResult;\n "+l+"\n ret[this.thread.z][this.thread.y][this.thread.x] = kernelResult;\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+"Z[this.thread.z][this.thread.y][this.thread.x] = "+e+";\n"}).join(""))+"\n }\n }\n }\n \n if (this.graphical) {\n this._imageData.data.set(this._colorData);\n this._canvasCtx.putImageData(this._imageData, 0, 0);\n return;\n }\n \n if (this.output.length === 1) {\n ret = ret[0][0];\n"+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+" = "+e+"Z[0][0];\n"}).join(""))+"\n \n } else if (this.output.length === 2) {\n ret = ret[0];\n "+(null===this.subKernelOutputVariableNames?"":this.subKernelOutputVariableNames.map(function(e){return" "+e+" = "+e+"Z[0];\n"}).join(""))+"\n }\n \n "+(null===this.subKernelOutputVariableNames?"return ret;\n":null!==this.subKernels?"var result = [\n "+this.subKernelOutputVariableNames.map(function(e){return""+e}).join(",\n")+"\n ];\n result.result = ret;\n return result;\n":"return {\n result: ret,\n "+Object.keys(this.subKernelProperties).map(function(t,n){return t+": "+e.subKernelOutputVariableNames[n]}).join(",\n")+"\n };")+"\n "+(h.length>0?h.join("\n"):"")+"\n }.bind(this);";return p}},{key:"toString",value:function(){return h(this)}},{key:"precompileKernelObj",value:function(e){var t=this.threadDim||(this.threadDim=u.clone(this.output));return{threadDim:t}}},{key:"_getLoopMaxString",value:function(){return this.loopMaxIterations?" "+parseInt(this.loopMaxIterations)+";\n":" 1000;\n"}},{key:"_processInputs",value:function(){for(var e=[],t=0;t=0;i--){n[i]=new Array(e.width);for(var s=0;s=0||t.push(e)),t}},{key:"addKernel",value:function(e,t,n,r){var i=new this.Node("kernel",e,t,r);return i.setAddFunction(this.addFunction.bind(this)),i.paramNames=n,i.paramTypes=r,i.isRootKernel=!0,this.addFunctionNode(i),i}},{key:"addSubKernel",value:function(e,t,n,r){var i=new this.Node(null,e,t,n,r);return i.setAddFunction(this.addFunction.bind(this)),i.isSubKernel=!0,this.addFunctionNode(i),i}},{key:"getPrototypeString",value:function(e){return this.getPrototypes(e).join("\n")}},{key:"getPrototypes",value:function(e){return this.rootKernel.generate(),e?this.getPrototypesFromFunctionNames(this.traceFunctionCalls(e,[]).reverse()):this.getPrototypesFromFunctionNames(Object.keys(this.nodeMap))}},{key:"getStringFromFunctionNames",value:function(e){for(var t=[],n=0;n ("+r.length+","+this.paramNames.length+")";this.paramTypes=r}else if("object"===("undefined"==typeof r?"undefined":_typeof(r))){var s=Object.keys(r);if(r.hasOwnProperty("returns")&&(this.returnType=r.returns,s.splice(s.indexOf("returns"),1)),s.length>0&&s.length!==this.paramNames.length)throw"Invalid argument type array length, against function length -> ("+s.length+","+this.paramNames.length+")";this.paramTypes=this.paramNames.map(function(e){return r.hasOwnProperty(e)?r[e]:"float"})}}else this.paramTypes=[];this.returnType||(this.returnType=i||"float")}return _createClass(BaseFunctionNode,[{key:"isIdentifierConstant",value:function(e){return!!this.constants&&this.constants.hasOwnProperty(e)}},{key:"setAddFunction",value:function(e){return this.addFunction=e,this}},{key:"getJsFunction",value:function getJsFunction(){if(this.jsFunction)return this.jsFunction;if(this.jsFunctionString)return this.jsFunction=eval(this.jsFunctionString),this.jsFunction;throw"Missing jsFunction, and jsFunctionString parameter"}},{key:"astMemberExpressionUnroll",value:function(e,t){if("Identifier"===e.type)return e.name;if("ThisExpression"===e.type)return"this";if("MemberExpression"===e.type&&e.object&&e.property)return e.object.hasOwnProperty("name")&&"_"===e.object.name[0]?this.astMemberExpressionUnroll(e.property,t):this.astMemberExpressionUnroll(e.object,t)+"."+this.astMemberExpressionUnroll(e.property,t);if(e.hasOwnProperty("expressions")){var n=e.expressions[0];if("Literal"===n.type&&0===n.value&&2===e.expressions.length)return this.astMemberExpressionUnroll(e.expressions[1])}throw this.astErrorOutput("Unknown CallExpression_unroll",e,t)}},{key:"getJsAST",value:function(e){if(this.jsFunctionAST)return this.jsFunctionAST;if(e=e||acorn,null===e)throw"Missing JS to AST parser";var t=e.parse("var "+this.functionName+" = "+this.jsFunctionString+";",{locations:!0});if(null===t)throw"Failed to parse JS code";var n=t.body[0].declarations[0].init;return this.jsFunctionAST=n,n}},{key:"getFunctionString",value:function(){return this.generate(),this.functionString}},{key:"setFunctionString",value:function(e){this.functionString=e}},{key:"getParamType",value:function(e){var t=this.paramNames.indexOf(e);if(t===-1)return this.declarations.hasOwnProperty(e)?this.declarations[e]:null;if(this.parent){if(this.paramTypes[t])return this.paramTypes[t];for(var n=this.parent.calledFunctionsArguments[this.functionName],r=0;r0&&t.push(", ");var s=n.getParamType(i);switch(s){case"Texture":case"Input":case"Array":t.push("sampler2D");break;default:t.push("float")}t.push(" "),t.push("user_"),t.push(i)}t.push(") {\n");for(var a=0;a1){for(var a=null,o=0;o0&&t.push(",");var s=[];this.astGeneric(i,s,n),"getImage2D("===s[2]||"getImage3D("===s[2]?(0===r&&t.push("vec4 "),this.declarations[i.id.name]="vec4"):(0===r&&t.push("float "),this.declarations[i.id.name]="float"),t.push.apply(t,s)}return t.push(";"),t}},{key:"astVariableDeclarator",value:function(e,t,n){return this.astGeneric(e.id,t,n),null!==e.init&&(t.push("="),this.astGeneric(e.init,t,n)),t}},{key:"astIfStatement",value:function(e,t,n){return t.push("if ("),this.astGeneric(e.test,t,n),t.push(")"),"BlockStatement"===e.consequent.type?this.astGeneric(e.consequent,t,n):(t.push(" {\n"),this.astGeneric(e.consequent,t,n),t.push("\n}\n")),e.alternate&&(t.push("else "),"BlockStatement"===e.alternate.type?this.astGeneric(e.alternate,t,n):(t.push(" {\n"),this.astGeneric(e.alternate,t,n),t.push("\n}\n"))),t}},{key:"astBreakStatement",value:function(e,t,n){return t.push("break;\n"),t}},{key:"astContinueStatement",value:function(e,t,n){return t.push("continue;\n"),t}},{key:"astLogicalExpression",value:function(e,t,n){return t.push("("),this.astGeneric(e.left,t,n),t.push(e.operator),this.astGeneric(e.right,t,n),t.push(")"),t}},{key:"astUpdateExpression",value:function(e,t,n){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,n)):(this.astGeneric(e.argument,t,n),t.push(e.operator)),t}},{key:"astUnaryExpression",value:function(e,t,n){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,n)):(this.astGeneric(e.argument,t,n),t.push(e.operator)),t}},{key:"astThisExpression",value:function(e,t,n){return t.push("this"),t}},{key:"astMemberExpression",value:function(e,t,n){if(e.computed)if("Identifier"===e.object.type){var r=e.object.name,i=(n.functionName||"kernel",!1);if(n.paramNames){var s=n.paramNames.indexOf(r);s>=0&&"float"===n.paramTypes[s]&&(i=!0)}if(i)this.astGeneric(e.object,t,n),t.push("[int("),this.astGeneric(e.property,t,n),t.push(")]");else switch(n.getParamType(e.object.name)){case"vec4":this.astGeneric(e.object,t,n),t.push("["),t.push(e.property.raw),t.push("]");break;case"HTMLImageArray":t.push("getImage3D("),this.astGeneric(e.object,t,n),t.push(", vec2("),this.astGeneric(e.object,t,n),t.push("Size[0],"),this.astGeneric(e.object,t,n),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,n),t.push("Dim[0],"),this.astGeneric(e.object,t,n),t.push("Dim[1],"),this.astGeneric(e.object,t,n),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,n),t.push(")");break;case"HTMLImage":t.push("getImage2D("),this.astGeneric(e.object,t,n),t.push(", vec2("),this.astGeneric(e.object,t,n),t.push("Size[0],"),this.astGeneric(e.object,t,n),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,n),t.push("Dim[0],"),this.astGeneric(e.object,t,n),t.push("Dim[1],"),this.astGeneric(e.object,t,n),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,n),t.push(")");break;default:t.push("get("),this.astGeneric(e.object,t,n),t.push(", vec2("),this.astGeneric(e.object,t,n),t.push("Size[0],"),this.astGeneric(e.object,t,n),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,n),t.push("Dim[0],"),this.astGeneric(e.object,t,n),t.push("Dim[1],"),this.astGeneric(e.object,t,n),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,n),t.push(")")}}else{this.astGeneric(e.object,t,n);var a=t.pop();t.push(","),this.astGeneric(e.property,t,n),t.push(a)}else{var o=this.astMemberExpressionUnroll(e),u=o.toLowerCase();switch(0===o.indexOf(c)&&(o="constants_"+o.slice(c.length)),u){case"this.thread.x":t.push("threadId.x");break;case"this.thread.y":t.push("threadId.y");break;case"this.thread.z":t.push("threadId.z");break;case"this.output.x":t.push(this.output[0]+".0");break;case"this.output.y":t.push(this.output[1]+".0");break;case"this.output.z":t.push(this.output[2]+".0");break;default:t.push(o)}}return t}},{key:"astSequenceExpression",value:function(e,t,n){for(var r=0;r0&&t.push(","),this.astGeneric(e.expressions,t,n);return t}},{key:"astCallExpression",value:function(e,t,n){if(e.callee){var r=this.astMemberExpressionUnroll(e.callee);0===r.indexOf(l)&&(r=r.slice(l.length)),0===r.indexOf(p)&&(r=r.slice(p.length)),"atan2"===r&&(r="atan"),n.calledFunctions.indexOf(r)<0&&n.calledFunctions.push(r),n.hasOwnProperty("funcName")||(n.calledFunctionsArguments[r]=[]);var i=[];n.calledFunctionsArguments[r].push(i),t.push(r),t.push("(");for(var s=0;s0&&t.push(", "),this.astGeneric(a,t,n),"Identifier"===a.type){var o=n.paramNames.indexOf(a.name);o===-1?i.push(null):i.push({name:a.name,type:n.paramTypes[o]})}else i.push(null)}return t.push(")"),t}throw this.astErrorOutput("Unknown CallExpression",e,n)}},{key:"astArrayExpression",value:function(e,t,n){var r=e.elements.length;t.push("float["+r+"](");for(var i=0;i0&&t.push(", ");var s=e.elements[i];this.astGeneric(s,t,n)}return t.push(")"),t}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"build",value:function(){return this.getFunctionPrototypeString().length>0}}],[{key:"astFunctionPrototype",value:function(e,t,n){if(n.isRootKernel||n.isSubKernel)return t;t.push(n.returnType),t.push(" "),t.push(n.functionName),t.push("(");for(var r=0;r0&&t.push(", "),t.push(n.paramTypes[r]),t.push(" "),t.push("user_"),t.push(n.paramNames[r]);return t.push(");\n"),t}}]),t}(u)},{"../../core/utils":32,"../function-node-base":7}],13:[function(e,t,n){function r(e){return/^function /.test(e)&&(e=e.substring(9)),e.replace(/[_]typeof/g,"typeof")}function i(e){return e.replace(/[_]typeof/g,"typeof")}var s=e("../../core/utils"),a=e("../kernel-run-shortcut");t.exports=function(e,t){return"() => {\n "+a.toString()+";\n const utils = {\n allPropertiesOf: "+i(s.allPropertiesOf.toString())+",\n clone: "+i(s.clone.toString())+",\n splitArray: "+i(s.splitArray.toString())+",\n getArgumentType: "+i(s.getArgumentType.toString())+",\n getDimensions: "+i(s.getDimensions.toString())+",\n dimToTexSize: "+i(s.dimToTexSize.toString())+",\n flattenTo: "+i(s.flattenTo.toString())+",\n flatten2dArrayTo: "+i(s.flatten2dArrayTo.toString())+",\n flatten3dArrayTo: "+i(s.flatten3dArrayTo.toString())+",\n systemEndianness: '"+i(s.systemEndianness())+"',\n initWebGl: "+i(s.initWebGl.toString())+",\n isArray: "+i(s.isArray.toString())+"\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class "+(t||"Kernel")+" {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(e.paramNames)+";\n this.paramTypes = "+JSON.stringify(e.paramTypes)+";\n this.texSize = "+JSON.stringify(e.texSize)+";\n this.output = "+JSON.stringify(e.output)+";\n this.compiledFragShaderString = `"+e.compiledFragShaderString+"`;\n\t\t this.compiledVertShaderString = `"+e.compiledVertShaderString+"`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n\t\t this.uniform1fCache = {};\n\t\t this.uniform1iCache = {};\n\t\t this.uniform2fCache = {};\n\t\t this.uniform2fvCache = {};\n\t\t this.uniform3fvCache = {};\n }\n "+r(e._getFragShaderString.toString())+"\n "+r(e._getVertShaderString.toString())+"\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+r(e.getUniformLocation.toString())+"\n "+r(e.setupParams.toString())+"\n "+r(e.build.toString())+"\n\t\t "+r(e.run.toString())+"\n\t\t "+r(e._addArgument.toString())+"\n\t\t "+r(e.getArgumentTexture.toString())+"\n\t\t "+r(e.getTextureCache.toString())+"\n\t\t "+r(e.getOutputTexture.toString())+"\n\t\t "+r(e.renderOutput.toString())+"\n\t\t "+r(e.updateMaxTexSize.toString())+"\n\t\t "+r(e._setupOutputTexture.toString())+"\n\t\t "+r(e.detachTextureCache.toString())+"\n\t\t "+r(e.setUniform1f.toString())+"\n\t\t "+r(e.setUniform1i.toString())+"\n\t\t "+r(e.setUniform2f.toString())+"\n\t\t "+r(e.setUniform2fv.toString())+"\n\t\t "+r(e.setUniform3fv.toString())+" \n };\n return kernelRunShortcut(new Kernel());\n };"}},{"../../core/utils":32,"../kernel-run-shortcut":9}],14:[function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n0&&this._setupSubOutputTextures(this.subKernelOutputVariableNames.length))}},{key:"run",value:function(){null===this.program&&this.build.apply(this,arguments);var e=this.paramNames,t=this.paramTypes,n=this.texSize,r=this._webGl;r.useProgram(this.program),r.scissor(0,0,n[0],n[1]),this.hardcodeConstants||(this.setUniform3fv("uOutputDim",this.threadDim),this.setUniform2fv("uTexSize",n)),this.setUniform2f("ratio",n[0]/this.maxTexSize[0],n[1]/this.maxTexSize[1]),this.argumentsLength=0;for(var i=0;i0?e.join(";\n")+";\n":"\n"}},{key:"_replaceArtifacts",value:function(e,t){return e.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g,function(e,n){if(t.hasOwnProperty(n))return t[n];throw"unhandled artifact "+n})}},{key:"_addKernels",value:function(){var e=this,t=this.functionBuilder,n=this._webGl;if(t.addFunctions(this.functions,{constants:this.constants,output:this.output}),t.addNativeFunctions(this.nativeFunctions),t.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations},this.paramNames,this.paramTypes),null!==this.subKernels){var r=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!r)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],this.subKernels.forEach(function(t){return e._addSubKernel(t)})}else if(null!==this.subKernelProperties){var i=this.drawBuffers=n.getExtension("WEBGL_draw_buffers");if(!i)throw new Error("could not instantiate draw buffers extension");this.subKernelOutputVariableNames=[],Object.keys(this.subKernelProperties).forEach(function(t){return e._addSubKernel(e.subKernelProperties[t])})}}},{key:"_addSubKernel",value:function(e){this.functionBuilder.addSubKernel(e,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations}),this.subKernelOutputVariableNames.push(e.name+"Result")}},{key:"_getFragShaderString",value:function(e){return null!==this.compiledFragShaderString?this.compiledFragShaderString:this.compiledFragShaderString=this._replaceArtifacts(this.constructor.fragShaderString,this._getFragShaderArtifactMap(e))}},{key:"_getVertShaderString",value:function(e){return null!==this.compiledVertShaderString?this.compiledVertShaderString:this.compiledVertShaderString=this.constructor.vertShaderString}},{key:"toString",value:function(){return c(this)}},{key:"addFunction",value:function(e){this.functionBuilder.addFunction(null,e)}}]),t}(o)},{"../../core/texture":30,"../../core/utils":32,"../kernel-base":8,"./kernel-string":13,"./shader-frag":16,"./shader-vert":17}],15:[function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var a=function(){function e(e,t){for(var n=0;n0&&t.push(", ");var s=n.getParamType(i);switch(s){case"Texture":case"Input":case"Array":case"HTMLImage":t.push("sampler2D");break;default:t.push("float")}t.push(" "),t.push("user_"),t.push(i)}t.push(") {\n");for(var a=0;ae)return!1;if(n+=t[r+1],n>=e)return!0}}function n(e,n){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&U.test(String.fromCharCode(e)):n!==!1&&t(e,V)))}function r(e,n){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&M.test(String.fromCharCode(e)):n!==!1&&(t(e,V)||t(e,B)))))}function i(e,t){return new j(e,{beforeExpr:!0,binop:t})}function s(e,t){return void 0===t&&(t={}),t.keyword=e,X[e]=new j(e,t)}function a(e){return 10===e||13===e||8232===e||8233===e}function o(e,t){return Z.call(e,t)}function u(e,t){for(var n=1,r=0;;){q.lastIndex=r;var i=q.exec(e);if(!(i&&i.index=2015&&(t.ecmaVersion-=2009),null==t.allowReserved&&(t.allowReserved=t.ecmaVersion<5),ee(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}return ee(t.onComment)&&(t.onComment=l(t,t.onComment)),t}function l(e,t){return function(n,r,i,s,a,o){var u={type:n?"Block":"Line",value:r,start:i,end:s};e.locations&&(u.loc=new ne(this,a,o)),e.ranges&&(u.range=[i,s]),t.push(u)}}function p(e){return new RegExp("^(?:"+e.replace(/ /g,"|")+")$")}function c(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}function f(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}function d(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(1023&e)+56320))}function g(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function m(e){return n(e,!0)||36===e||95===e}function x(e){return r(e,!0)||36===e||95===e||8204===e||8205===e}function y(e){return e>=65&&e<=90||e>=97&&e<=122}function v(e){return e>=0&&e<=1114111}function b(e){return 100===e||68===e||115===e||83===e||119===e||87===e}function _(e){return y(e)||95===e}function E(e){ +return _(e)||T(e)}function T(e){return e>=48&&e<=57}function S(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function k(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}function w(e){return e>=48&&e<=55}function A(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(1023&e)+56320))}function O(e,t){return new se(t,e).parse()}function C(e,t,n){var r=new se(n,e,t);return r.nextToken(),r.parseExpression()}function R(e,t){return new se(t,e)}function P(t,n,r){e.parse_dammit=t,e.LooseParser=n,e.pluginsLoose=r}var N={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},I="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",D={5:I,6:I+" const class extends export import super"},L=/^in(stanceof)?$/,F="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄮㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿪ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",G="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳷-᳹᷀-᷹᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",U=new RegExp("["+F+"]"),M=new RegExp("["+F+G+"]");F=G=null;var V=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,55,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,698,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,1,31,6124,20,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541],B=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,19719,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],j=function(e,t){void 0===t&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null},z={beforeExpr:!0},K={startsExpr:!0},X={},W={num:new j("num",K),regexp:new j("regexp",K),string:new j("string",K),name:new j("name",K),eof:new j("eof"),bracketL:new j("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new j("]"),braceL:new j("{",{beforeExpr:!0,startsExpr:!0}),braceR:new j("}"),parenL:new j("(",{beforeExpr:!0,startsExpr:!0}),parenR:new j(")"),comma:new j(",",z),semi:new j(";",z),colon:new j(":",z),dot:new j("."),question:new j("?",z),arrow:new j("=>",z),template:new j("template"),invalidTemplate:new j("invalidTemplate"),ellipsis:new j("...",z),backQuote:new j("`",K),dollarBraceL:new j("${",{beforeExpr:!0,startsExpr:!0}),eq:new j("=",{beforeExpr:!0,isAssign:!0}),assign:new j("_=",{beforeExpr:!0,isAssign:!0}),incDec:new j("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new j("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:i("||",1),logicalAND:i("&&",2),bitwiseOR:i("|",3),bitwiseXOR:i("^",4),bitwiseAND:i("&",5),equality:i("==/!=/===/!==",6),relational:i("/<=/>=",7),bitShift:i("<>/>>>",8),plusMin:new j("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:i("%",10),star:i("*",10),slash:i("/",10),starstar:new j("**",{beforeExpr:!0}),_break:s("break"),_case:s("case",z),_catch:s("catch"),_continue:s("continue"),_debugger:s("debugger"),_default:s("default",z),_do:s("do",{isLoop:!0,beforeExpr:!0}),_else:s("else",z),_finally:s("finally"),_for:s("for",{isLoop:!0}),_function:s("function",K),_if:s("if"),_return:s("return",z),_switch:s("switch"),_throw:s("throw",z),_try:s("try"),_var:s("var"),_const:s("const"),_while:s("while",{isLoop:!0}),_with:s("with"),_new:s("new",{beforeExpr:!0,startsExpr:!0}),_this:s("this",K),_super:s("super",K),_class:s("class",K),_extends:s("extends",z),_export:s("export"),_import:s("import"),_null:s("null",K),_true:s("true",K),_false:s("false",K),_in:s("in",{beforeExpr:!0,binop:7}),_instanceof:s("instanceof",{beforeExpr:!0,binop:7}),_typeof:s("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:s("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:s("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,q=new RegExp(H.source,"g"),Y=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,J=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Q=Object.prototype,Z=Q.hasOwnProperty,$=Q.toString,ee=Array.isArray||function(e){return"[object Array]"===$.call(e)},te=function(e,t){this.line=e,this.column=t};te.prototype.offset=function(e){return new te(this.line,this.column+e)};var ne=function(e,t,n){this.start=t,this.end=n,null!==e.sourceFile&&(this.source=e.sourceFile)},re={ecmaVersion:7,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1,plugins:{}},ie={},se=function(e,t,n){this.options=e=h(e),this.sourceFile=e.sourceFile,this.keywords=p(D[e.ecmaVersion>=6?6:5]);var r="";if(!e.allowReserved){for(var i=e.ecmaVersion;!(r=N[i]);i--);"module"==e.sourceType&&(r+=" await")}this.reservedWords=p(r);var s=(r?r+" ":"")+N.strict;this.reservedWordsStrict=p(s),this.reservedWordsStrictBind=p(s+" "+N.strictBind),this.input=String(t),this.containsEsc=!1,this.loadPlugins(e.plugins),n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=W.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===e.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&e.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope(),this.regexpState=null};se.prototype.isKeyword=function(e){return this.keywords.test(e)},se.prototype.isReservedWord=function(e){return this.reservedWords.test(e)},se.prototype.extend=function(e,t){this[e]=t(this[e])},se.prototype.loadPlugins=function(e){var t=this;for(var n in e){var r=ie[n];if(!r)throw new Error("Plugin '"+n+"' not found");r(t,e[n])}},se.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};var ae=se.prototype,oe=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;ae.strictDirective=function(e){for(var t=this;;){J.lastIndex=e,e+=J.exec(t.input)[0].length;var n=oe.exec(t.input.slice(e));if(!n)return!1;if("use strict"==(n[1]||n[2]))return!0;e+=n[0].length}},ae.eat=function(e){return this.type===e&&(this.next(),!0)},ae.isContextual=function(e){return this.type===W.name&&this.value===e&&!this.containsEsc},ae.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},ae.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},ae.canInsertSemicolon=function(){return this.type===W.eof||this.type===W.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))},ae.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},ae.semicolon=function(){this.eat(W.semi)||this.insertSemicolon()||this.unexpected()},ae.afterTrailingComma=function(e,t){if(this.type==e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},ae.expect=function(e){this.eat(e)||this.unexpected()},ae.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")},ae.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,"Parenthesized pattern")}},ae.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;return t?(n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),void(r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property"))):n>=0||r>=0},ae.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(e.sourceType=this.options.sourceType),this.finishNode(e,"Program")};var he={kind:"loop"},le={kind:"switch"};ue.isLet=function(){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;J.lastIndex=this.pos;var e=J.exec(this.input),t=this.pos+e[0].length,i=this.input.charCodeAt(t);if(91===i||123==i)return!0;if(n(i,!0)){for(var s=t+1;r(this.input.charCodeAt(s),!0);)++s;var a=this.input.slice(t,s);if(!L.test(a))return!0}return!1},ue.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;J.lastIndex=this.pos;var e=J.exec(this.input),t=this.pos+e[0].length;return!(H.test(this.input.slice(this.pos,t))||"function"!==this.input.slice(t,t+8)||t+8!=this.input.length&&r(this.input.charAt(t+8)))},ue.parseStatement=function(e,t,n){var r,i=this.type,s=this.startNode();switch(this.isLet()&&(i=W._var,r="let"),i){case W._break:case W._continue:return this.parseBreakContinueStatement(s,i.keyword);case W._debugger:return this.parseDebuggerStatement(s);case W._do:return this.parseDoStatement(s);case W._for:return this.parseForStatement(s);case W._function:return!e&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1);case W._class:return e||this.unexpected(),this.parseClass(s,!0);case W._if:return this.parseIfStatement(s);case W._return:return this.parseReturnStatement(s);case W._switch:return this.parseSwitchStatement(s);case W._throw:return this.parseThrowStatement(s);case W._try:return this.parseTryStatement(s);case W._const:case W._var:return r=r||this.value,e||"var"==r||this.unexpected(),this.parseVarStatement(s,r);case W._while:return this.parseWhileStatement(s);case W._with:return this.parseWithStatement(s);case W.braceL:return this.parseBlock();case W.semi:return this.parseEmptyStatement(s);case W._export:case W._import:return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===W._import?this.parseImport(s):this.parseExport(s,n);default:if(this.isAsyncFunction())return e||this.unexpected(),this.next(),this.parseFunctionStatement(s,!0);var a=this.value,o=this.parseExpression();return i===W.name&&"Identifier"===o.type&&this.eat(W.colon)?this.parseLabeledStatement(s,a,o):this.parseExpressionStatement(s,o)}},ue.parseBreakContinueStatement=function(e,t){var n=this,r="break"==t;this.next(),this.eat(W.semi)||this.insertSemicolon()?e.label=null:this.type!==W.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var i=0;i=6?this.eat(W.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},ue.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.inAsync&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(he),this.enterLexicalScope(),this.expect(W.parenL),this.type===W.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===W._var||this.type===W._const||n){var r=this.startNode(),i=n?"let":this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,"VariableDeclaration"),!(this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==r.declarations.length||"var"!==i&&r.declarations[0].init?(t>-1&&this.unexpected(t),this.parseFor(e,r)):(this.options.ecmaVersion>=9&&(this.type===W._in?t>-1&&this.unexpected(t):e.await=t>-1),this.parseForIn(e,r))}var s=new c,a=this.parseExpression(!0,s);return this.type===W._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.options.ecmaVersion>=9&&(this.type===W._in?t>-1&&this.unexpected(t):e.await=t>-1),this.toAssignable(a,!1,s),this.checkLVal(a),this.parseForIn(e,a)):(this.checkExpressionErrors(s,!0),t>-1&&this.unexpected(t),this.parseFor(e,a))},ue.parseFunctionStatement=function(e,t){return this.next(),this.parseFunction(e,!0,!1,t)},ue.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(!this.strict&&this.type==W._function),e.alternate=this.eat(W._else)?this.parseStatement(!this.strict&&this.type==W._function):null,this.finishNode(e,"IfStatement")},ue.parseReturnStatement=function(e){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(W.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},ue.parseSwitchStatement=function(e){var t=this;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(W.braceL),this.labels.push(le),this.enterLexicalScope();for(var n,r=!1;this.type!=W.braceR;)if(t.type===W._case||t.type===W._default){var i=t.type===W._case;n&&t.finishNode(n,"SwitchCase"),e.cases.push(n=t.startNode()),n.consequent=[],t.next(),i?n.test=t.parseExpression():(r&&t.raiseRecoverable(t.lastTokStart,"Multiple default clauses"),r=!0,n.test=null),t.expect(W.colon)}else n||t.unexpected(),n.consequent.push(t.parseStatement(!0));return this.exitLexicalScope(),n&&this.finishNode(n,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},ue.parseThrowStatement=function(e){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var pe=[];ue.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===W._catch){var t=this.startNode();this.next(),this.expect(W.parenL),t.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(t.param,"let"),this.expect(W.parenR),t.body=this.parseBlock(!1),this.exitLexicalScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(W._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},ue.parseVarStatement=function(e,t){return this.next(),this.parseVar(e,!1,t),this.semicolon(),this.finishNode(e,"VariableDeclaration")},ue.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(he),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,"WhileStatement")},ue.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(!1),this.finishNode(e,"WithStatement")},ue.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},ue.parseLabeledStatement=function(e,t,n){for(var r=this,i=0,s=r.labels;i=0;u--){var h=r.labels[u];if(h.statementStart!=e.start)break;h.statementStart=r.start,h.kind=o}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(!0),("ClassDeclaration"==e.body.type||"VariableDeclaration"==e.body.type&&"var"!=e.body.kind||"FunctionDeclaration"==e.body.type&&(this.strict||e.body.generator))&&this.raiseRecoverable(e.body.start,"Invalid labeled declaration"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")},ue.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},ue.parseBlock=function(e){var t=this;void 0===e&&(e=!0);var n=this.startNode();for(n.body=[],this.expect(W.braceL),e&&this.enterLexicalScope();!this.eat(W.braceR);){var r=t.parseStatement(!0);n.body.push(r)}return e&&this.exitLexicalScope(),this.finishNode(n,"BlockStatement")},ue.parseFor=function(e,t){return e.init=t,this.expect(W.semi),e.test=this.type===W.semi?null:this.parseExpression(),this.expect(W.semi),e.update=this.type===W.parenR?null:this.parseExpression(),this.expect(W.parenR),this.exitLexicalScope(),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,"ForStatement")},ue.parseForIn=function(e,t){var n=this.type===W._in?"ForInStatement":"ForOfStatement";return this.next(),"ForInStatement"==n&&("AssignmentPattern"===t.type||"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(this.strict||"Identifier"!==t.declarations[0].id.type))&&this.raise(t.start,"Invalid assignment in for-in loop head"),e.left=t,e.right="ForInStatement"==n?this.parseExpression():this.parseMaybeAssign(),this.expect(W.parenR),this.exitLexicalScope(),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,n)},ue.parseVar=function(e,t,n){var r=this;for(e.declarations=[],e.kind=n;;){var i=r.startNode();if(r.parseVarId(i,n),r.eat(W.eq)?i.init=r.parseMaybeAssign(t):"const"!==n||r.type===W._in||r.options.ecmaVersion>=6&&r.isContextual("of")?"Identifier"==i.id.type||t&&(r.type===W._in||r.isContextual("of"))?i.init=null:r.raise(r.lastTokEnd,"Complex binding patterns require an initialization value"):r.unexpected(),e.declarations.push(r.finishNode(i,"VariableDeclarator")),!r.eat(W.comma))break}return e},ue.parseVarId=function(e,t){e.id=this.parseBindingAtom(t),this.checkLVal(e.id,t,!1)},ue.parseFunction=function(e,t,n,r){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(e.generator=this.eat(W.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&&(e.id="nullableID"===t&&this.type!=W.name?null:this.parseIdent(),e.id&&this.checkLVal(e.id,"var"));var i=this.inGenerator,s=this.inAsync,a=this.yieldPos,o=this.awaitPos,u=this.inFunction;return this.inGenerator=e.generator,this.inAsync=e.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),t||(e.id=this.type==W.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n),this.inGenerator=i,this.inAsync=s,this.yieldPos=a,this.awaitPos=o,this.inFunction=u,this.finishNode(e,t?"FunctionDeclaration":"FunctionExpression")},ue.parseFunctionParams=function(e){this.expect(W.parenL),e.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},ue.parseClass=function(e,t){var n=this;this.next(),this.parseClassId(e,t),this.parseClassSuper(e);var r=this.startNode(),i=!1;for(r.body=[],this.expect(W.braceL);!this.eat(W.braceR);){var s=n.parseClassMember(r);s&&"MethodDefinition"===s.type&&"constructor"===s.kind&&(i&&n.raise(s.start,"Duplicate constructor in the same class"),i=!0)}return e.body=this.finishNode(r,"ClassBody"),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},ue.parseClassMember=function(e){var t=this;if(this.eat(W.semi))return null;var n=this.startNode(),r=function(e,r){void 0===r&&(r=!1);var i=t.start,s=t.startLoc;return!!t.eatContextual(e)&&(!(t.type===W.parenL||r&&t.canInsertSemicolon())||(n.key&&t.unexpected(),n.computed=!1,n.key=t.startNodeAt(i,s),n.key.name=e,t.finishNode(n.key,"Identifier"),!1))};n.kind="method",n["static"]=r("static");var i=this.eat(W.star),s=!1;i||(this.options.ecmaVersion>=8&&r("async",!0)?(s=!0,i=this.options.ecmaVersion>=9&&this.eat(W.star)):r("get")?n.kind="get":r("set")&&(n.kind="set")),n.key||this.parsePropertyName(n);var a=n.key;return n.computed||n["static"]||!("Identifier"===a.type&&"constructor"===a.name||"Literal"===a.type&&"constructor"===a.value)?n["static"]&&"Identifier"===a.type&&"prototype"===a.name&&this.raise(a.start,"Classes may not have a static property named prototype"):("method"!==n.kind&&this.raise(a.start,"Constructor can't have get/set modifier"),i&&this.raise(a.start,"Constructor can't be a generator"),s&&this.raise(a.start,"Constructor can't be an async method"),n.kind="constructor"),this.parseClassMethod(e,n,i,s),"get"===n.kind&&0!==n.value.params.length&&this.raiseRecoverable(n.value.start,"getter should have no params"),"set"===n.kind&&1!==n.value.params.length&&this.raiseRecoverable(n.value.start,"setter should have exactly one param"),"set"===n.kind&&"RestElement"===n.value.params[0].type&&this.raiseRecoverable(n.value.params[0].start,"Setter cannot use rest params"),n},ue.parseClassMethod=function(e,t,n,r){t.value=this.parseMethod(n,r),e.body.push(this.finishNode(t,"MethodDefinition"))},ue.parseClassId=function(e,t){e.id=this.type===W.name?this.parseIdent():t===!0?this.unexpected():null},ue.parseClassSuper=function(e){e.superClass=this.eat(W._extends)?this.parseExprSubscripts():null},ue.parseExport=function(e,t){var n=this;if(this.next(),this.eat(W.star))return this.expectContextual("from"),this.type!==W.string&&this.unexpected(),e.source=this.parseExprAtom(),this.semicolon(),this.finishNode(e,"ExportAllDeclaration");if(this.eat(W._default)){this.checkExport(t,"default",this.lastTokStart);var r;if(this.type===W._function||(r=this.isAsyncFunction())){var i=this.startNode();this.next(),r&&this.next(),e.declaration=this.parseFunction(i,"nullableID",!1,r)}else if(this.type===W._class){var s=this.startNode();e.declaration=this.parseClass(s,"nullableID")}else e.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(e,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())e.declaration=this.parseStatement(!0),"VariableDeclaration"===e.declaration.type?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id.name,e.declaration.id.start),e.specifiers=[],e.source=null;else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==W.string&&this.unexpected(),e.source=this.parseExprAtom();else{for(var a=0,o=e.specifiers;a=6&&e)switch(e.type){case"Identifier":this.inAsync&&"await"===e.name&&this.raise(e.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var i=0,s=e.properties;i=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r,i=e.key;switch(i.type){case"Identifier":r=i.name;break;case"Literal":r=String(i.value);break;default:return}var s=e.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===r&&"init"===s&&(t.proto&&(n&&n.doubleProto<0?n.doubleProto=i.start:this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0));r="$"+r;var a=t[r];if(a){var o;o="init"===s?this.strict&&a.init||a.get||a.set:a.init||a[s],o&&this.raiseRecoverable(i.start,"Redefinition of property")}else a=t[r]={init:!1,get:!1,set:!1};a[s]=!0}},fe.parseExpression=function(e,t){var n=this,r=this.start,i=this.startLoc,s=this.parseMaybeAssign(e,t);if(this.type===W.comma){var a=this.startNodeAt(r,i);for(a.expressions=[s];this.eat(W.comma);)a.expressions.push(n.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return s},fe.parseMaybeAssign=function(e,t,n){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var r=!1,i=-1,s=-1;t?(i=t.parenthesizedAssign,s=t.trailingComma,t.parenthesizedAssign=t.trailingComma=-1):(t=new c,r=!0);var a=this.start,o=this.startLoc;this.type!=W.parenL&&this.type!=W.name||(this.potentialArrowAt=this.start);var u=this.parseMaybeConditional(e,t);if(n&&(u=n.call(this,u,a,o)),this.type.isAssign){var h=this.startNodeAt(a,o);return h.operator=this.value,h.left=this.type===W.eq?this.toAssignable(u,!1,t):u,r||c.call(t),t.shorthandAssign=-1,this.checkLVal(u),this.next(),h.right=this.parseMaybeAssign(e),this.finishNode(h,"AssignmentExpression")}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),s>-1&&(t.trailingComma=s),u},fe.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(W.question)){var s=this.startNodeAt(n,r);return s.test=i,s.consequent=this.parseMaybeAssign(),this.expect(W.colon),s.alternate=this.parseMaybeAssign(e),this.finishNode(s,"ConditionalExpression")}return i},fe.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1);return this.checkExpressionErrors(t)?i:i.start==n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,r,-1,e)},fe.parseExprOp=function(e,t,n,r,i){var s=this.type.binop;if(null!=s&&(!i||this.type!==W._in)&&s>r){var a=this.type===W.logicalOR||this.type===W.logicalAND,o=this.value;this.next();var u=this.start,h=this.startLoc,l=this.parseExprOp(this.parseMaybeUnary(null,!1),u,h,s,i),p=this.buildBinary(t,n,e,l,o,a);return this.parseExprOp(p,t,n,r,i)}return e},fe.buildBinary=function(e,t,n,r,i,s){var a=this.startNodeAt(e,t);return a.left=n,a.operator=i,a.right=r,this.finishNode(a,s?"LogicalExpression":"BinaryExpression")},fe.parseMaybeUnary=function(e,t){var n,r=this,i=this.start,s=this.startLoc;if(this.inAsync&&this.isContextual("await"))n=this.parseAwait(),t=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===W.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(e,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):t=!0,n=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(n=this.parseExprSubscripts(e),this.checkExpressionErrors(e))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=r.startNodeAt(i,s);u.operator=r.value,u.prefix=!1,u.argument=n,r.checkLVal(n),r.next(),n=r.finishNode(u,"UpdateExpression")}}return!t&&this.eat(W.starstar)?this.buildBinary(i,s,n,this.parseMaybeUnary(null,!1),"**",!1):n},fe.parseExprSubscripts=function(e){var t=this.start,n=this.startLoc,r=this.parseExprAtom(e),i="ArrowFunctionExpression"===r.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(e)||i)return r;var s=this.parseSubscripts(r,t,n);return e&&"MemberExpression"===s.type&&(e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1)),s},fe.parseSubscripts=function(e,t,n,r){for(var i=this,s=this.options.ecmaVersion>=8&&"Identifier"===e.type&&"async"===e.name&&this.lastTokEnd==e.end&&!this.canInsertSemicolon()&&"async"===this.input.slice(e.start,e.end),a=void 0;;)if((a=i.eat(W.bracketL))||i.eat(W.dot)){var o=i.startNodeAt(t,n);o.object=e,o.property=a?i.parseExpression():i.parseIdent(!0),o.computed=!!a,a&&i.expect(W.bracketR),e=i.finishNode(o,"MemberExpression")}else if(!r&&i.eat(W.parenL)){var u=new c,h=i.yieldPos,l=i.awaitPos;i.yieldPos=0,i.awaitPos=0;var p=i.parseExprList(W.parenR,i.options.ecmaVersion>=8,!1,u);if(s&&!i.canInsertSemicolon()&&i.eat(W.arrow))return i.checkPatternErrors(u,!1),i.checkYieldAwaitInDefaultParams(),i.yieldPos=h,i.awaitPos=l,i.parseArrowExpression(i.startNodeAt(t,n),p,!0);i.checkExpressionErrors(u,!0),i.yieldPos=h||i.yieldPos,i.awaitPos=l||i.awaitPos;var f=i.startNodeAt(t,n);f.callee=e,f.arguments=p,e=i.finishNode(f,"CallExpression")}else{if(i.type!==W.backQuote)return e;var d=i.startNodeAt(t,n);d.tag=e,d.quasi=i.parseTemplate({isTagged:!0}),e=i.finishNode(d,"TaggedTemplateExpression")}},fe.parseExprAtom=function(e){var t,n=this.potentialArrowAt==this.start;switch(this.type){case W._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),t=this.startNode(),this.next(),this.type!==W.dot&&this.type!==W.bracketL&&this.type!==W.parenL&&this.unexpected(),this.finishNode(t,"Super");case W._this:return t=this.startNode(),this.next(),this.finishNode(t,"ThisExpression");case W.name:var r=this.start,i=this.startLoc,s=this.containsEsc,a=this.parseIdent(this.type!==W.name);if(this.options.ecmaVersion>=8&&!s&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(W._function))return this.parseFunction(this.startNodeAt(r,i),!1,!1,!0);if(n&&!this.canInsertSemicolon()){if(this.eat(W.arrow))return this.parseArrowExpression(this.startNodeAt(r,i),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===W.name&&!s)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(W.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,i),[a],!0)}return a;case W.regexp:var o=this.value;return t=this.parseLiteral(o.value),t.regex={pattern:o.pattern,flags:o.flags},t;case W.num:case W.string:return this.parseLiteral(this.value);case W._null:case W._true:case W._false:return t=this.startNode(),t.value=this.type===W._null?null:this.type===W._true,t.raw=this.type.keyword,this.next(),this.finishNode(t,"Literal");case W.parenL:var u=this.start,h=this.parseParenAndDistinguishExpression(n);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),h;case W.bracketL:return t=this.startNode(),this.next(),t.elements=this.parseExprList(W.bracketR,!0,!0,e),this.finishNode(t,"ArrayExpression");case W.braceL:return this.parseObj(!1,e);case W._function:return t=this.startNode(),this.next(),this.parseFunction(t,!1);case W._class:return this.parseClass(this.startNode(),!1);case W._new:return this.parseNew();case W.backQuote:return this.parseTemplate();default:this.unexpected()}},fe.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(t,"Literal")},fe.parseParenExpression=function(){this.expect(W.parenL);var e=this.parseExpression();return this.expect(W.parenR),e},fe.parseParenAndDistinguishExpression=function(e){var t,n=this,r=this.start,i=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,u=this.startLoc,h=[],l=!0,p=!1,f=new c,d=this.yieldPos,g=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==W.parenR;){if(l?l=!1:n.expect(W.comma),s&&n.afterTrailingComma(W.parenR,!0)){p=!0;break}if(n.type===W.ellipsis){a=n.start,h.push(n.parseParenItem(n.parseRestBinding())),n.type===W.comma&&n.raise(n.start,"Comma is not permitted after the rest element");break}h.push(n.parseMaybeAssign(!1,f,n.parseParenItem))}var m=this.start,x=this.startLoc;if(this.expect(W.parenR),e&&!this.canInsertSemicolon()&&this.eat(W.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=d,this.awaitPos=g,this.parseParenArrowList(r,i,h);h.length&&!p||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(f,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=g||this.awaitPos,h.length>1?(t=this.startNodeAt(o,u),t.expressions=h,this.finishNodeAt(t,"SequenceExpression",m,x)):t=h[0]}else t=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(r,i);return y.expression=t,this.finishNode(y,"ParenthesizedExpression")}return t},fe.parseParenItem=function(e){return e},fe.parseParenArrowList=function(e,t,n){return this.parseArrowExpression(this.startNodeAt(e,t),n)};var de=[];fe.parseNew=function(){var e=this.startNode(),t=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(W.dot)){e.meta=t;var n=this.containsEsc;return e.property=this.parseIdent(!0),("target"!==e.property.name||n)&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(e.start,"new.target can only be used in functions"),this.finishNode(e,"MetaProperty")}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(),r,i,!0),this.eat(W.parenL)?e.arguments=this.parseExprList(W.parenR,this.options.ecmaVersion>=8,!1):e.arguments=de,this.finishNode(e,"NewExpression")},fe.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===W.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===W.backQuote,this.finishNode(n,"TemplateElement")},fe.parseTemplate=function(e){var t=this;void 0===e&&(e={});var n=e.isTagged;void 0===n&&(n=!1);var r=this.startNode();this.next(),r.expressions=[];var i=this.parseTemplateElement({isTagged:n});for(r.quasis=[i];!i.tail;)t.expect(W.dollarBraceL),r.expressions.push(t.parseExpression()),t.expect(W.braceR),r.quasis.push(i=t.parseTemplateElement({isTagged:n}));return this.next(),this.finishNode(r,"TemplateLiteral")},fe.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===W.name||this.type===W.num||this.type===W.string||this.type===W.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===W.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))},fe.parseObj=function(e,t){var n=this,r=this.startNode(),i=!0,s={};for(r.properties=[],this.next();!this.eat(W.braceR);){if(i)i=!1;else if(n.expect(W.comma),n.afterTrailingComma(W.braceR))break;var a=n.parseProperty(e,t);e||n.checkPropClash(a,s,t),r.properties.push(a)}return this.finishNode(r,e?"ObjectPattern":"ObjectExpression")},fe.parseProperty=function(e,t){var n,r,i,s,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(W.ellipsis))return e?(a.argument=this.parseIdent(!1),this.type===W.comma&&this.raise(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(this.type===W.parenL&&t&&(t.parenthesizedAssign<0&&(t.parenthesizedAssign=this.start),t.parenthesizedBind<0&&(t.parenthesizedBind=this.start)),a.argument=this.parseMaybeAssign(!1,t),this.type===W.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(e||t)&&(i=this.start,s=this.startLoc),e||(n=this.eat(W.star)));var o=this.containsEsc;return this.parsePropertyName(a),!e&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(r=!0,n=this.options.ecmaVersion>=9&&this.eat(W.star),this.parsePropertyName(a,t)):r=!1,this.parsePropertyValue(a,e,n,r,i,s,t,o),this.finishNode(a,"Property")},fe.parsePropertyValue=function(e,t,n,r,i,s,a,o){if((n||r)&&this.type===W.colon&&this.unexpected(),this.eat(W.colon))e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init";else if(this.options.ecmaVersion>=6&&this.type===W.parenL)t&&this.unexpected(),e.kind="init",e.method=!0,e.value=this.parseMethod(n,r);else if(t||o||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type==W.comma||this.type==W.braceR)this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?(this.checkUnreserved(e.key),e.kind="init",t?e.value=this.parseMaybeDefault(i,s,e.key):this.type===W.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,s,e.key)):e.value=e.key,e.shorthand=!0):this.unexpected();else{(n||r)&&this.unexpected(),e.kind=e.key.name,this.parsePropertyName(e),e.value=this.parseMethod(!1);var u="get"===e.kind?0:1;if(e.value.params.length!==u){var h=e.value.start;"get"===e.kind?this.raiseRecoverable(h,"getter should have no params"):this.raiseRecoverable(h,"setter should have exactly one param")}else"set"===e.kind&&"RestElement"===e.value.params[0].type&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")}},fe.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(W.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(W.bracketR),e.key;e.computed=!1}return e.key=this.type===W.num||this.type===W.string?this.parseExprAtom():this.parseIdent(!0)},fe.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=!1,e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},fe.parseMethod=function(e,t){var n=this.startNode(),r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=e),this.options.ecmaVersion>=8&&(n.async=!!t),this.inGenerator=n.generator,this.inAsync=n.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(W.parenL),n.params=this.parseBindingList(W.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(n,"FunctionExpression")},fe.parseArrowExpression=function(e,t,n){var r=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.enterFunctionScope(),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.inGenerator=!1,this.inAsync=e.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0),this.inGenerator=r,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.inFunction=o,this.finishNode(e,"ArrowFunctionExpression")},fe.parseFunctionBody=function(e,t){var n=t&&this.type!==W.braceL,r=this.strict,i=!1;if(n)e.body=this.parseMaybeAssign(),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);r&&!s||(i=this.strictDirective(this.end),i&&s&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var a=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!r&&!i&&!t&&this.isSimpleParamList(e.params)),e.body=this.parseBlock(!1),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=a}this.exitFunctionScope(),this.strict&&e.id&&this.checkLVal(e.id,"none"),this.strict=r},fe.isSimpleParamList=function(e){for(var t=0,n=e;t0;)t[n]=arguments[n+1];for(var r=0,i=t;r=1;t--){var n=e.context[t];if("function"===n.token)return n.generator}return!1},Ee.updateContext=function(e){var t,n=this.type;n.keyword&&e==W.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},W.parenR.updateContext=W.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var e=this.context.pop();e===_e.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},W.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?_e.b_stat:_e.b_expr),this.exprAllowed=!0},W.dollarBraceL.updateContext=function(){this.context.push(_e.b_tmpl),this.exprAllowed=!0},W.parenL.updateContext=function(e){var t=e===W._if||e===W._for||e===W._with||e===W._while;this.context.push(t?_e.p_stat:_e.p_expr),this.exprAllowed=!0},W.incDec.updateContext=function(){},W._function.updateContext=W._class.updateContext=function(e){e.beforeExpr&&e!==W.semi&&e!==W._else&&(e!==W.colon&&e!==W.braceL||this.curContext()!==_e.b_stat)?this.context.push(_e.f_expr):this.context.push(_e.f_stat),this.exprAllowed=!1},W.backQuote.updateContext=function(){this.curContext()===_e.q_tmpl?this.context.pop():this.context.push(_e.q_tmpl),this.exprAllowed=!1},W.star.updateContext=function(e){if(e==W._function){var t=this.context.length-1;this.context[t]===_e.f_expr?this.context[t]=_e.f_expr_gen:this.context[t]=_e.f_gen}this.exprAllowed=!0},W.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&("of"==this.value&&!this.exprAllowed||"yield"==this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var Te={$LONE:["ASCII","ASCII_Hex_Digit","AHex","Alphabetic","Alpha","Any","Assigned","Bidi_Control","Bidi_C","Bidi_Mirrored","Bidi_M","Case_Ignorable","CI","Cased","Changes_When_Casefolded","CWCF","Changes_When_Casemapped","CWCM","Changes_When_Lowercased","CWL","Changes_When_NFKC_Casefolded","CWKCF","Changes_When_Titlecased","CWT","Changes_When_Uppercased","CWU","Dash","Default_Ignorable_Code_Point","DI","Deprecated","Dep","Diacritic","Dia","Emoji","Emoji_Component","Emoji_Modifier","Emoji_Modifier_Base","Emoji_Presentation","Extender","Ext","Grapheme_Base","Gr_Base","Grapheme_Extend","Gr_Ext","Hex_Digit","Hex","IDS_Binary_Operator","IDSB","IDS_Trinary_Operator","IDST","ID_Continue","IDC","ID_Start","IDS","Ideographic","Ideo","Join_Control","Join_C","Logical_Order_Exception","LOE","Lowercase","Lower","Math","Noncharacter_Code_Point","NChar","Pattern_Syntax","Pat_Syn","Pattern_White_Space","Pat_WS","Quotation_Mark","QMark","Radical","Regional_Indicator","RI","Sentence_Terminal","STerm","Soft_Dotted","SD","Terminal_Punctuation","Term","Unified_Ideograph","UIdeo","Uppercase","Upper","Variation_Selector","VS","White_Space","space","XID_Continue","XIDC","XID_Start","XIDS"],General_Category:["Cased_Letter","LC","Close_Punctuation","Pe","Connector_Punctuation","Pc","Control","Cc","cntrl","Currency_Symbol","Sc","Dash_Punctuation","Pd","Decimal_Number","Nd","digit","Enclosing_Mark","Me","Final_Punctuation","Pf","Format","Cf","Initial_Punctuation","Pi","Letter","L","Letter_Number","Nl","Line_Separator","Zl","Lowercase_Letter","Ll","Mark","M","Combining_Mark","Math_Symbol","Sm","Modifier_Letter","Lm","Modifier_Symbol","Sk","Nonspacing_Mark","Mn","Number","N","Open_Punctuation","Ps","Other","C","Other_Letter","Lo","Other_Number","No","Other_Punctuation","Po","Other_Symbol","So","Paragraph_Separator","Zp","Private_Use","Co","Punctuation","P","punct","Separator","Z","Space_Separator","Zs","Spacing_Mark","Mc","Surrogate","Cs","Symbol","S","Titlecase_Letter","Lt","Unassigned","Cn","Uppercase_Letter","Lu"],Script:["Adlam","Adlm","Ahom","Anatolian_Hieroglyphs","Hluw","Arabic","Arab","Armenian","Armn","Avestan","Avst","Balinese","Bali","Bamum","Bamu","Bassa_Vah","Bass","Batak","Batk","Bengali","Beng","Bhaiksuki","Bhks","Bopomofo","Bopo","Brahmi","Brah","Braille","Brai","Buginese","Bugi","Buhid","Buhd","Canadian_Aboriginal","Cans","Carian","Cari","Caucasian_Albanian","Aghb","Chakma","Cakm","Cham","Cherokee","Cher","Common","Zyyy","Coptic","Copt","Qaac","Cuneiform","Xsux","Cypriot","Cprt","Cyrillic","Cyrl","Deseret","Dsrt","Devanagari","Deva","Duployan","Dupl","Egyptian_Hieroglyphs","Egyp","Elbasan","Elba","Ethiopic","Ethi","Georgian","Geor","Glagolitic","Glag","Gothic","Goth","Grantha","Gran","Greek","Grek","Gujarati","Gujr","Gurmukhi","Guru","Han","Hani","Hangul","Hang","Hanunoo","Hano","Hatran","Hatr","Hebrew","Hebr","Hiragana","Hira","Imperial_Aramaic","Armi","Inherited","Zinh","Qaai","Inscriptional_Pahlavi","Phli","Inscriptional_Parthian","Prti","Javanese","Java","Kaithi","Kthi","Kannada","Knda","Katakana","Kana","Kayah_Li","Kali","Kharoshthi","Khar","Khmer","Khmr","Khojki","Khoj","Khudawadi","Sind","Lao","Laoo","Latin","Latn","Lepcha","Lepc","Limbu","Limb","Linear_A","Lina","Linear_B","Linb","Lisu","Lycian","Lyci","Lydian","Lydi","Mahajani","Mahj","Malayalam","Mlym","Mandaic","Mand","Manichaean","Mani","Marchen","Marc","Masaram_Gondi","Gonm","Meetei_Mayek","Mtei","Mende_Kikakui","Mend","Meroitic_Cursive","Merc","Meroitic_Hieroglyphs","Mero","Miao","Plrd","Modi","Mongolian","Mong","Mro","Mroo","Multani","Mult","Myanmar","Mymr","Nabataean","Nbat","New_Tai_Lue","Talu","Newa","Nko","Nkoo","Nushu","Nshu","Ogham","Ogam","Ol_Chiki","Olck","Old_Hungarian","Hung","Old_Italic","Ital","Old_North_Arabian","Narb","Old_Permic","Perm","Old_Persian","Xpeo","Old_South_Arabian","Sarb","Old_Turkic","Orkh","Oriya","Orya","Osage","Osge","Osmanya","Osma","Pahawh_Hmong","Hmng","Palmyrene","Palm","Pau_Cin_Hau","Pauc","Phags_Pa","Phag","Phoenician","Phnx","Psalter_Pahlavi","Phlp","Rejang","Rjng","Runic","Runr","Samaritan","Samr","Saurashtra","Saur","Sharada","Shrd","Shavian","Shaw","Siddham","Sidd","SignWriting","Sgnw","Sinhala","Sinh","Sora_Sompeng","Sora","Soyombo","Soyo","Sundanese","Sund","Syloti_Nagri","Sylo","Syriac","Syrc","Tagalog","Tglg","Tagbanwa","Tagb","Tai_Le","Tale","Tai_Tham","Lana","Tai_Viet","Tavt","Takri","Takr","Tamil","Taml","Tangut","Tang","Telugu","Telu","Thaana","Thaa","Thai","Tibetan","Tibt","Tifinagh","Tfng","Tirhuta","Tirh","Ugaritic","Ugar","Vai","Vaii","Warang_Citi","Wara","Yi","Yiii","Zanabazar_Square","Zanb"]};Array.prototype.push.apply(Te.$LONE,Te.General_Category),Te.gc=Te.General_Category,Te.sc=Te.Script_Extensions=Te.scx=Te.Script;var Se=se.prototype,ke=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":""),this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=[],this.backReferenceNames=[]};ke.prototype.reset=function(e,t,n){var r=n.indexOf("u")!==-1;this.start=0|e,this.source=t+"",this.flags=n,this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchN=r&&this.parser.options.ecmaVersion>=9},ke.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},ke.prototype.at=function(e){var t=this.source,n=t.length;if(e>=n)return-1;var r=t.charCodeAt(e);return!this.switchU||r<=55295||r>=57344||e+1>=n?r:(r<<10)+t.charCodeAt(e+1)-56613888},ke.prototype.nextIndex=function(e){var t=this.source,n=t.length;if(e>=n)return n;var r=t.charCodeAt(e);return!this.switchU||r<=55295||r>=57344||e+1>=n?e+1:e+2},ke.prototype.current=function(){return this.at(this.pos)},ke.prototype.lookahead=function(){return this.at(this.nextIndex(this.pos))},ke.prototype.advance=function(){this.pos=this.nextIndex(this.pos)},ke.prototype.eat=function(e){return this.current()===e&&(this.advance(),!0)},Se.validateRegExpFlags=function(e){for(var t=this,n=e.validFlags,r=e.flags,i=0;i-1&&t.raise(e.start,"Duplicate regular expression flag")}},Se.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&e.groupNames.length>0&&(e.switchN=!0,this.regexp_pattern(e))},Se.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames.length=0,e.backReferenceNames.length=0,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},Se.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},Se.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},Se.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1; +if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i=9?this.regexp_groupSpecifier(e):63===e.current()&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},Se.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},Se.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},Se.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!g(t)&&(e.lastIntValue=t,e.advance(),!0)},Se.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!g(n);)e.advance();return e.pos!==t},Se.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return!(t===-1||36===t||t>=40&&t<=43||46===t||63===t||91===t||94===t||124===t)&&(e.advance(),!0)},Se.regexp_groupSpecifier=function(e){if(e.eat(63)){if(this.regexp_eatGroupName(e))return e.groupNames.indexOf(e.lastStringValue)!==-1&&e.raise("Duplicate capture group name"),void e.groupNames.push(e.lastStringValue);e.raise("Invalid group")}},Se.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},Se.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=d(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=d(e.lastIntValue);return!0}return!1},Se.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=e.current();return e.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(e)&&(n=e.lastIntValue),m(n)?(e.lastIntValue=n,!0):(e.pos=t,!1)},Se.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=e.current();return e.advance(),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(e)&&(n=e.lastIntValue),x(n)?(e.lastIntValue=n,!0):(e.pos=t,!1)},Se.regexp_eatAtomEscape=function(e){return!!(this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e))||(e.switchU&&(99===e.current()&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},Se.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},Se.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},Se.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},Se.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},Se.regexp_eatZero=function(e){return 48===e.current()&&!T(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},Se.regexp_eatControlEscape=function(e){var t=e.current();return 116===t?(e.lastIntValue=9,e.advance(),!0):110===t?(e.lastIntValue=10,e.advance(),!0):118===t?(e.lastIntValue=11,e.advance(),!0):102===t?(e.lastIntValue=12,e.advance(),!0):114===t&&(e.lastIntValue=13,e.advance(),!0)},Se.regexp_eatControlLetter=function(e){var t=e.current();return!!y(t)&&(e.lastIntValue=t%32,e.advance(),!0)},Se.regexp_eatRegExpUnicodeEscapeSequence=function(e){var t=e.pos;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var n=e.lastIntValue;if(e.switchU&&n>=55296&&n<=56319){var r=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(i>=56320&&i<=57343)return e.lastIntValue=1024*(n-55296)+(i-56320)+65536,!0}e.pos=r,e.lastIntValue=n}return!0}if(e.switchU&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&v(e.lastIntValue))return!0;e.switchU&&e.raise("Invalid unicode escape"),e.pos=t}return!1},Se.regexp_eatIdentityEscape=function(e){if(e.switchU)return!!this.regexp_eatSyntaxCharacter(e)||!!e.eat(47)&&(e.lastIntValue=47,!0);var t=e.current();return!(99===t||e.switchN&&107===t)&&(e.lastIntValue=t,e.advance(),!0)},Se.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1},Se.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(b(t))return e.lastIntValue=-1,e.advance(),!0;if(e.switchU&&this.options.ecmaVersion>=9&&(80===t||112===t)){if(e.lastIntValue=-1,e.advance(),e.eat(123)&&this.regexp_eatUnicodePropertyValueExpression(e)&&e.eat(125))return!0;e.raise("Invalid property name")}return!1},Se.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),!0}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i),!0}return!1},Se.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Te.hasOwnProperty(t)&&Te[t].indexOf(n)!==-1||e.raise("Invalid property name")},Se.regexp_validateUnicodePropertyNameOrValue=function(e,t){Te.$LONE.indexOf(t)===-1&&e.raise("Invalid property name")},Se.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";_(t=e.current());)e.lastStringValue+=d(t),e.advance();return""!==e.lastStringValue},Se.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";E(t=e.current());)e.lastStringValue+=d(t),e.advance();return""!==e.lastStringValue},Se.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},Se.regexp_eatCharacterClass=function(e){if(e.eat(91)){if(e.eat(94),this.regexp_classRanges(e),e.eat(93))return!0;e.raise("Unterminated character class")}return!1},Se.regexp_classRanges=function(e){for(var t=this;this.regexp_eatClassAtom(e);){var n=e.lastIntValue;if(e.eat(45)&&t.regexp_eatClassAtom(e)){var r=e.lastIntValue;!e.switchU||n!==-1&&r!==-1||e.raise("Invalid character class"),n!==-1&&r!==-1&&n>r&&e.raise("Range out of order in character class")}}},Se.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(99===n||w(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var r=e.current();return 93!==r&&(e.lastIntValue=r,e.advance(),!0)},Se.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},Se.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!T(t)&&95!==t)&&(e.lastIntValue=t%32,e.advance(),!0)},Se.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1},Se.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;T(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t},Se.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;S(n=e.current());)e.lastIntValue=16*e.lastIntValue+k(n),e.advance();return e.pos!==t},Se.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*n+e.lastIntValue:e.lastIntValue=8*t+n}else e.lastIntValue=t;return!0}return!1},Se.regexp_eatOctalDigit=function(e){var t=e.current();return w(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},Se.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r=this.input.length?this.finishToken(W.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},Ae.readToken=function(e){return n(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},Ae.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=57344)return e;var t=this.input.charCodeAt(this.pos+1);return(e<<10)+t-56613888},Ae.skipBlockComment=function(){var e=this,t=this.options.onComment&&this.curPosition(),n=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(r===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations){q.lastIndex=n;for(var i;(i=q.exec(this.input))&&i.index8&&t<14||t>=5760&&Y.test(String.fromCharCode(t))))break e;++e.pos}}},Ae.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},Ae.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===e&&46===t?(this.pos+=3,this.finishToken(W.ellipsis)):(++this.pos,this.finishToken(W.dot))},Ae.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(W.assign,2):this.finishOp(W.slash,1)},Ae.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=42===e?W.star:W.modulo;return this.options.ecmaVersion>=7&&42==e&&42===t&&(++n,r=W.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(W.assign,n+1):this.finishOp(r,n)},Ae.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.finishOp(124===e?W.logicalOR:W.logicalAND,2):61===t?this.finishOp(W.assign,2):this.finishOp(124===e?W.bitwiseOR:W.bitwiseAND,1)},Ae.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(W.assign,2):this.finishOp(W.bitwiseXOR,1)},Ae.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?45!=t||this.inModule||62!=this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!H.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(W.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(W.assign,2):this.finishOp(W.plusMin,1)},Ae.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(W.assign,n+1):this.finishOp(W.bitShift,n)):33!=t||60!=e||this.inModule||45!=this.input.charCodeAt(this.pos+2)||45!=this.input.charCodeAt(this.pos+3)?(61===t&&(n=2),this.finishOp(W.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},Ae.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(W.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(W.arrow)):this.finishOp(61===e?W.eq:W.prefix,1)},Ae.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(W.parenL);case 41:return++this.pos,this.finishToken(W.parenR);case 59:return++this.pos,this.finishToken(W.semi);case 44:return++this.pos,this.finishToken(W.comma);case 91:return++this.pos,this.finishToken(W.bracketL);case 93:return++this.pos,this.finishToken(W.bracketR);case 123:return++this.pos,this.finishToken(W.braceL);case 125:return++this.pos,this.finishToken(W.braceR);case 58:return++this.pos,this.finishToken(W.colon);case 63:return++this.pos,this.finishToken(W.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(W.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 126:return this.finishOp(W.prefix,1)}this.raise(this.pos,"Unexpected character '"+A(e)+"'")},Ae.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},Ae.readRegexp=function(){for(var e,t,n=this,r=this.pos;;){n.pos>=n.input.length&&n.raise(r,"Unterminated regular expression");var i=n.input.charAt(n.pos);if(H.test(i)&&n.raise(r,"Unterminated regular expression"),e)e=!1;else{if("["===i)t=!0;else if("]"===i&&t)t=!1;else if("/"===i&&!t)break;e="\\"===i}++n.pos}var s=this.input.slice(r,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var u=this.regexpState||(this.regexpState=new ke(this));u.reset(r,s,o),this.validateRegExpFlags(u),this.validateRegExpPattern(u);var h=null;try{h=new RegExp(s,o)}catch(l){}return this.finishToken(W.regexp,{pattern:s,flags:o,value:h})},Ae.readInt=function(e,t){for(var n=this,r=this.pos,i=0,s=0,a=null==t?1/0:t;s=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0,u>=e)break;++n.pos,i=i*e+u}return this.pos===r||null!=t&&this.pos-r!==t?null:i},Ae.readRadixNumber=function(e){this.pos+=2;var t=this.readInt(e);return null==t&&this.raise(this.start+2,"Expected number in radix "+e),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(W.num,t)},Ae.readNumber=function(e){var t=this.pos;e||null!==this.readInt(10)||this.raise(t,"Invalid number");var r=this.pos-t>=2&&48===this.input.charCodeAt(t);r&&this.strict&&this.raise(t,"Invalid number"),r&&/[89]/.test(this.input.slice(t,this.pos))&&(r=!1);var i=this.input.charCodeAt(this.pos);46!==i||r||(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||r||(i=this.input.charCodeAt(++this.pos),43!==i&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),n(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s=this.input.slice(t,this.pos),a=r?parseInt(s,8):parseFloat(s);return this.finishToken(W.num,a)},Ae.readCodePoint=function(){var e,t=this.input.charCodeAt(this.pos);if(123===t){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else e=this.readHexChar(4);return e},Ae.readString=function(e){for(var t=this,n="",r=++this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated string constant");var i=t.input.charCodeAt(t.pos);if(i===e)break;92===i?(n+=t.input.slice(r,t.pos),n+=t.readEscapedChar(!1),r=t.pos):(a(i)&&t.raise(t.start,"Unterminated string constant"),++t.pos)}return n+=this.input.slice(r,this.pos++),this.finishToken(W.string,n)};var Oe={};Ae.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==Oe)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},Ae.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Oe;this.raise(e,t)},Ae.readTmplToken=function(){for(var e=this,t="",n=this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated template");var r=e.input.charCodeAt(e.pos);if(96===r||36===r&&123===e.input.charCodeAt(e.pos+1))return e.pos!==e.start||e.type!==W.template&&e.type!==W.invalidTemplate?(t+=e.input.slice(n,e.pos),e.finishToken(W.template,t)):36===r?(e.pos+=2,e.finishToken(W.dollarBraceL)):(++e.pos,e.finishToken(W.backQuote));if(92===r)t+=e.input.slice(n,e.pos),t+=e.readEscapedChar(!0),n=e.pos;else if(a(r)){switch(t+=e.input.slice(n,e.pos),++e.pos,r){case 13:10===e.input.charCodeAt(e.pos)&&++e.pos;case 10:t+="\n";break;default:t+=String.fromCharCode(r)}e.options.locations&&(++e.curLine,e.lineStart=e.pos),n=e.pos}else++e.pos}},Ae.readInvalidTemplateToken=function(){for(var e=this;this.pos=48&&t<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(n,8);return r>255&&(n=n.slice(0,-1),r=parseInt(n,8)),this.pos+=n.length-1,t=this.input.charCodeAt(this.pos),"0"===n&&56!=t&&57!=t||!this.strict&&!e||this.invalidStringToken(this.pos-1-n.length,"Octal literal in strict mode"),String.fromCharCode(r)}return String.fromCharCode(t)}},Ae.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return null===n&&this.invalidStringToken(t,"Bad character escape sequence"),n},Ae.readWord1=function(){var e=this;this.containsEsc=!1;for(var t="",i=!0,s=this.pos,a=this.options.ecmaVersion>=6;this.pos 0) { retArr.push(', '); } - retArr.push(funcParam.paramTypes[i]); retArr.push(' '); retArr.push('user_'); diff --git a/dist/backend/web-gl/function-node.js b/dist/backend/web-gl/function-node.js index 1e13f9ca..6dc90cd8 100644 --- a/dist/backend/web-gl/function-node.js +++ b/dist/backend/web-gl/function-node.js @@ -409,6 +409,10 @@ module.exports = function (_FunctionNodeBase) { case 'gpu_outputZ': retArr.push('uOutputDim.z'); break; + case 'Infinity': + // https://stackoverflow.com/a/47543127/1324039 + retArr.push('3.402823466e+38'); + break; default: if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { retArr.push('constants_' + idtNode.name); diff --git a/dist/backend/web-gl2/function-node.js b/dist/backend/web-gl2/function-node.js index 3270d06b..e3fff0de 100644 --- a/dist/backend/web-gl2/function-node.js +++ b/dist/backend/web-gl2/function-node.js @@ -123,11 +123,11 @@ module.exports = function (_WebGLFunctionNode) { /** * @memberOf WebGL2FunctionNode# * @function - * @name astVariableDeclaration + * @name astIdentifierExpression * - * @desc Parses the abstract syntax tree for *Variable Declaration* + * @desc Parses the abstract syntax tree for *identifier* expression * - * @param {Object} vardecNode - An ast Node + * @param {Object} idtNode - An ast Node * @param {Array} retArr - return array string * @param {Function} funcParam - FunctionNode, that tracks compilation state * @@ -135,127 +135,47 @@ module.exports = function (_WebGLFunctionNode) { */ }, { - key: 'astVariableDeclaration', - value: function astVariableDeclaration(vardecNode, retArr, funcParam) { - for (var i = 0; i < vardecNode.declarations.length; i++) { - var declaration = vardecNode.declarations[i]; - if (i > 0) { - retArr.push(','); - } - var retDeclaration = []; - this.astGeneric(declaration, retDeclaration, funcParam); - if (i === 0) { - if (retDeclaration[0] === 'get(' && funcParam.getParamType(retDeclaration[1]) === 'HTMLImage' && retDeclaration.length === 18) { - retArr.push('sampler2D '); - } else { - retArr.push('float '); - } - } - retArr.push.apply(retArr, retDeclaration); + key: 'astIdentifierExpression', + value: function astIdentifierExpression(idtNode, retArr, funcParam) { + if (idtNode.type !== 'Identifier') { + throw this.astErrorOutput('IdentifierExpression - not an Identifier', idtNode, funcParam); } - retArr.push(';'); - return retArr; - } - /** - * @memberOf WebGL2FunctionNode# - * @function - * @name astMemberExpression - * - * @desc Parses the abstract syntax tree for *Member* Expression - * - * @param {Object} mNode - An ast Node - * @param {Array} retArr - return array string - * @param {Function} funcParam - FunctionNode, that tracks compilation state - * - * @returns {Array} the append retArr - */ - - }, { - key: 'astMemberExpression', - value: function astMemberExpression(mNode, retArr, funcParam) { - if (mNode.computed) { - if (mNode.object.type === 'Identifier') { - // Working logger - var reqName = mNode.object.name; - var funcName = funcParam.functionName || 'kernel'; - var assumeNotTexture = false; - - // Possibly an array request - handle it as such - if (funcParam.paramNames) { - var idx = funcParam.paramNames.indexOf(reqName); - if (idx >= 0 && funcParam.paramTypes[idx] === 'float') { - assumeNotTexture = true; - } - } - - if (assumeNotTexture) { - // Get from array - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('[int('); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(')]'); + switch (idtNode.name) { + case 'gpu_threadX': + retArr.push('threadId.x'); + break; + case 'gpu_threadY': + retArr.push('threadId.y'); + break; + case 'gpu_threadZ': + retArr.push('threadId.z'); + break; + case 'gpu_outputX': + retArr.push('uOutputDim.x'); + break; + case 'gpu_outputY': + retArr.push('uOutputDim.y'); + break; + case 'gpu_outputZ': + retArr.push('uOutputDim.z'); + break; + case 'Infinity': + retArr.push('intBitsToFloat(2139095039)'); + break; + default: + if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { + retArr.push('constants_' + idtNode.name); } else { - // Get from texture - // This normally refers to the global read only input vars - retArr.push('get('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push(', vec2('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Size[0],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Size[1]), vec3('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[0],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[1],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[2]'); - retArr.push('), '); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(')'); + var userParamName = funcParam.getUserParamName(idtNode.name); + if (userParamName !== null) { + retArr.push('user_' + userParamName); + } else { + retArr.push('user_' + idtNode.name); + } } - } else { - this.astGeneric(mNode.object, retArr, funcParam); - var last = retArr.pop(); - retArr.push(','); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(last); - } - } else { - - // Unroll the member expression - var unrolled = this.astMemberExpressionUnroll(mNode); - var unrolled_lc = unrolled.toLowerCase(); - - // Its a constant, remove this.constants. - if (unrolled.indexOf(constantsPrefix) === 0) { - unrolled = 'constants_' + unrolled.slice(constantsPrefix.length); - } - - switch (unrolled_lc) { - case 'this.thread.x': - retArr.push('threadId.x'); - break; - case 'this.thread.y': - retArr.push('threadId.y'); - break; - case 'this.thread.z': - retArr.push('threadId.z'); - break; - case 'this.output.x': - retArr.push(this.output[0] + '.0'); - break; - case 'this.output.y': - retArr.push(this.output[1] + '.0'); - break; - case 'this.output.z': - retArr.push(this.output[2] + '.0'); - break; - default: - retArr.push(unrolled); - } } + return retArr; } }]); diff --git a/dist/backend/web-gl2/runner.js b/dist/backend/web-gl2/runner.js index 601f38b3..e1ef2140 100644 --- a/dist/backend/web-gl2/runner.js +++ b/dist/backend/web-gl2/runner.js @@ -1,20 +1,22 @@ 'use strict'; +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } -var WebGLRunner = require('../web-gl/runner'); +var RunnerBase = require('../runner-base'); var WebGL2FunctionBuilder = require('./function-builder'); var WebGL2Kernel = require('./kernel'); -module.exports = function (_WebGLRunner) { - _inherits(WebGL2Runner, _WebGLRunner); +module.exports = function (_RunnerBase) { + _inherits(WebGL2Runner, _RunnerBase); /** - * @constructor WebGLRunner + * @constructor WebGL2Runner * * @extends RunnerBase * @desc Instantiates a Runner instance for the kernel. @@ -32,5 +34,24 @@ module.exports = function (_WebGLRunner) { return _this; } + /** + * @memberOf WebGL2Runner# + * @function + * @name getMode + * + * @desc Return the current mode in which gpu.js is executing. + * + * @returns {String} The current mode; "gpu". + * + */ + + + _createClass(WebGL2Runner, [{ + key: 'getMode', + value: function getMode() { + return 'gpu'; + } + }]); + return WebGL2Runner; -}(WebGLRunner); \ No newline at end of file +}(RunnerBase); \ No newline at end of file diff --git a/package.json b/package.json index 90e9cdbe..8217bba2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gpu.js", - "version": "1.4.2", + "version": "1.4.3", "description": "GPU Accelerated JavaScript", "main": "./dist/index.js", "directories": { diff --git a/src/backend/cpu/function-node.js b/src/backend/cpu/function-node.js index da007d36..4c5a15d4 100644 --- a/src/backend/cpu/function-node.js +++ b/src/backend/cpu/function-node.js @@ -188,7 +188,6 @@ module.exports = class CPUFunctionNode extends BaseFunctionNode { if (i > 0) { retArr.push(', '); } - retArr.push(funcParam.paramTypes[i]); retArr.push(' '); retArr.push('user_'); @@ -380,6 +379,9 @@ module.exports = class CPUFunctionNode extends BaseFunctionNode { case 'gpu_outputZ': retArr.push('uOutputDim.z'); break; + case 'Infinity': + retArr.push('Infinity'); + break; default: if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { retArr.push('constants_' + idtNode.name); diff --git a/src/backend/web-gl/function-node.js b/src/backend/web-gl/function-node.js index 4e92e7b5..287c0bb7 100644 --- a/src/backend/web-gl/function-node.js +++ b/src/backend/web-gl/function-node.js @@ -404,6 +404,10 @@ module.exports = class WebGLFunctionNode extends FunctionNodeBase { case 'gpu_outputZ': retArr.push('uOutputDim.z'); break; + case 'Infinity': + // https://stackoverflow.com/a/47543127/1324039 + retArr.push('3.402823466e+38'); + break; default: if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { retArr.push('constants_' + idtNode.name); diff --git a/src/backend/web-gl2/function-node.js b/src/backend/web-gl2/function-node.js index 7fcc91a3..19aada2d 100644 --- a/src/backend/web-gl2/function-node.js +++ b/src/backend/web-gl2/function-node.js @@ -105,137 +105,59 @@ module.exports = class WebGL2FunctionNode extends WebGLFunctionNode { /** * @memberOf WebGL2FunctionNode# * @function - * @name astVariableDeclaration + * @name astIdentifierExpression * - * @desc Parses the abstract syntax tree for *Variable Declaration* + * @desc Parses the abstract syntax tree for *identifier* expression * - * @param {Object} vardecNode - An ast Node + * @param {Object} idtNode - An ast Node * @param {Array} retArr - return array string * @param {Function} funcParam - FunctionNode, that tracks compilation state * * @returns {Array} the append retArr */ - astVariableDeclaration(vardecNode, retArr, funcParam) { - for (let i = 0; i < vardecNode.declarations.length; i++) { - const declaration = vardecNode.declarations[i]; - if (i > 0) { - retArr.push(','); - } - const retDeclaration = []; - this.astGeneric(declaration, retDeclaration, funcParam); - if (i === 0) { - if ( - retDeclaration[0] === 'get(' && - funcParam.getParamType(retDeclaration[1]) === 'HTMLImage' && - retDeclaration.length === 18 - ) { - retArr.push('sampler2D '); - } else { - retArr.push('float '); - } - } - retArr.push.apply(retArr, retDeclaration); + astIdentifierExpression(idtNode, retArr, funcParam) { + if (idtNode.type !== 'Identifier') { + throw this.astErrorOutput( + 'IdentifierExpression - not an Identifier', + idtNode, funcParam + ); } - retArr.push(';'); - return retArr; - } - /** - * @memberOf WebGL2FunctionNode# - * @function - * @name astMemberExpression - * - * @desc Parses the abstract syntax tree for *Member* Expression - * - * @param {Object} mNode - An ast Node - * @param {Array} retArr - return array string - * @param {Function} funcParam - FunctionNode, that tracks compilation state - * - * @returns {Array} the append retArr - */ - astMemberExpression(mNode, retArr, funcParam) { - if (mNode.computed) { - if (mNode.object.type === 'Identifier') { - // Working logger - const reqName = mNode.object.name; - const funcName = funcParam.functionName || 'kernel'; - let assumeNotTexture = false; - - // Possibly an array request - handle it as such - if (funcParam.paramNames) { - const idx = funcParam.paramNames.indexOf(reqName); - if (idx >= 0 && funcParam.paramTypes[idx] === 'float') { - assumeNotTexture = true; - } - } - - if (assumeNotTexture) { - // Get from array - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('[int('); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(')]'); + switch (idtNode.name) { + case 'gpu_threadX': + retArr.push('threadId.x'); + break; + case 'gpu_threadY': + retArr.push('threadId.y'); + break; + case 'gpu_threadZ': + retArr.push('threadId.z'); + break; + case 'gpu_outputX': + retArr.push('uOutputDim.x'); + break; + case 'gpu_outputY': + retArr.push('uOutputDim.y'); + break; + case 'gpu_outputZ': + retArr.push('uOutputDim.z'); + break; + case 'Infinity': + retArr.push('intBitsToFloat(2139095039)'); + break; + default: + if (this.constants && this.constants.hasOwnProperty(idtNode.name)) { + retArr.push('constants_' + idtNode.name); } else { - // Get from texture - // This normally refers to the global read only input vars - retArr.push('get('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push(', vec2('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Size[0],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Size[1]), vec3('); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[0],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[1],'); - this.astGeneric(mNode.object, retArr, funcParam); - retArr.push('Dim[2]'); - retArr.push('), '); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(')'); + const userParamName = funcParam.getUserParamName(idtNode.name); + if (userParamName !== null) { + retArr.push('user_' + userParamName); + } else { + retArr.push('user_' + idtNode.name); + } } - } else { - this.astGeneric(mNode.object, retArr, funcParam); - const last = retArr.pop(); - retArr.push(','); - this.astGeneric(mNode.property, retArr, funcParam); - retArr.push(last); - } - } else { - - // Unroll the member expression - let unrolled = this.astMemberExpressionUnroll(mNode); - let unrolled_lc = unrolled.toLowerCase(); - - // Its a constant, remove this.constants. - if (unrolled.indexOf(constantsPrefix) === 0) { - unrolled = 'constants_' + unrolled.slice(constantsPrefix.length); - } - - switch (unrolled_lc) { - case 'this.thread.x': - retArr.push('threadId.x'); - break; - case 'this.thread.y': - retArr.push('threadId.y'); - break; - case 'this.thread.z': - retArr.push('threadId.z'); - break; - case 'this.output.x': - retArr.push(this.output[0] + '.0'); - break; - case 'this.output.y': - retArr.push(this.output[1] + '.0'); - break; - case 'this.output.z': - retArr.push(this.output[2] + '.0'); - break; - default: - retArr.push(unrolled); - } } + return retArr; } }; diff --git a/src/backend/web-gl2/runner.js b/src/backend/web-gl2/runner.js index b8596501..3cf3ab4d 100644 --- a/src/backend/web-gl2/runner.js +++ b/src/backend/web-gl2/runner.js @@ -1,10 +1,10 @@ -const WebGLRunner = require('../web-gl/runner'); +const RunnerBase = require('../runner-base'); const WebGL2FunctionBuilder = require('./function-builder'); const WebGL2Kernel = require('./kernel'); -module.exports = class WebGL2Runner extends WebGLRunner { +module.exports = class WebGL2Runner extends RunnerBase { /** - * @constructor WebGLRunner + * @constructor WebGL2Runner * * @extends RunnerBase @@ -18,4 +18,18 @@ module.exports = class WebGL2Runner extends WebGLRunner { this.Kernel = WebGL2Kernel; this.kernel = null; } + + /** + * @memberOf WebGL2Runner# + * @function + * @name getMode + * + * @desc Return the current mode in which gpu.js is executing. + * + * @returns {String} The current mode; "gpu". + * + */ + getMode() { + return 'gpu'; + } }; \ No newline at end of file diff --git a/test/all.html b/test/all.html index 0fbdf984..a8c72e90 100644 --- a/test/all.html +++ b/test/all.html @@ -27,6 +27,7 @@ + diff --git a/test/features/infinity.js b/test/features/infinity.js new file mode 100644 index 00000000..87b64e77 --- /dev/null +++ b/test/features/infinity.js @@ -0,0 +1,29 @@ +(function() { + function input(mode) { + const gpu = new GPU({ mode: mode || undefined }); + return gpu.createKernel(function() { + return Infinity; + }) + .setOutput([1])(); + } + + QUnit.test( "Infinity (auto)", function() { + QUnit.assert.deepEqual(input()[0], NaN); + }); + + QUnit.test( "Infinity (cpu)", function() { + QUnit.assert.deepEqual(input('cpu')[0], Infinity); + }); + + QUnit.test( "Infinity (gpu)", function() { + QUnit.assert.deepEqual(input('gpu')[0], NaN); + }); + + QUnit.test( "Infinity (webgl)", function() { + QUnit.assert.deepEqual(input('webgl')[0], NaN); + }); + + QUnit.test( "Infinity (webgl2)", function() { + QUnit.assert.deepEqual(input('webgl2')[0], NaN); + }); +})(); \ No newline at end of file