├── .gitignore ├── .travis.yml ├── .jshintrc ├── bin └── evaljs ├── package.json ├── test.js ├── theTest.js ├── README.md ├── index.js └── dist └── eval.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 6 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "undef": true, 3 | "unused": "vars", 4 | "predef": ["-Promise"], 5 | "node": true, 6 | "strict": true, 7 | "indent": 2, 8 | "maxlen": 100 9 | } 10 | -------------------------------------------------------------------------------- /bin/evaljs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var repl = require('repl'); 4 | var evaljs = require('../'); 5 | var parse = require('acorn').parse; 6 | var fs = require('fs'); 7 | var env = new evaljs.Environment([global, {require: require}]); 8 | 9 | function run(iter){ 10 | var result = iter.next(); 11 | while(!result.done) { 12 | result = iter.next(); 13 | } 14 | return result.value; 15 | } 16 | 17 | repl.start({ 18 | eval: function (cmd, context, filename, callback) { 19 | try { 20 | callback(null, run(env.gen(cmd)())) 21 | } catch (err) { 22 | callback(err); 23 | }; 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "evaljs", 3 | "version": "2.0.1", 4 | "description": "A JavaScript interpreter written in JavaScript", 5 | "main": "index.js", 6 | "bin": "./bin/evaljs", 7 | "dependencies": { 8 | "acorn": "^4.0.4", 9 | "require-from-string": "^1.2.1" 10 | }, 11 | "devDependencies": { 12 | "browserify": "^13.1.1", 13 | "esprima": "^3.1.2", 14 | "jshint": "^2.9.4", 15 | "regenerator": "^0.9.5", 16 | "uglify-js": "^2.7.5" 17 | }, 18 | "scripts": { 19 | "test": "npm run compile && npm run jshint && node test.js", 20 | "compile": "./node_modules/regenerator/bin/regenerator --include-runtime ./index.js > ./index-compiled.js", 21 | "jshint": "./node_modules/.bin/jshint index.js test.js theTest.js", 22 | "build": "mkdir -p dist && npm run build-js && npm run minify", 23 | "build-js": "./node_modules/.bin/browserify -r acorn -r ./index-compiled.js:evaljs -o dist/eval.js", 24 | "minify": "./node_modules/.bin/uglifyjs -mc -o dist/eval.min.js dist/eval.js" 25 | }, 26 | "keywords": [ 27 | "eval", 28 | "javascript", 29 | "interpreter", 30 | "closure", 31 | "closures", 32 | "js", 33 | "evaluate", 34 | "no-eval" 35 | ], 36 | "repository": { 37 | "type": "git", 38 | "url": "https://github.com/marten-de-vries/evaljs.git" 39 | }, 40 | "license": "ISC", 41 | "author": "Marten de Vries", 42 | "contributors": [ 43 | { 44 | "name": "Jason Huggins", 45 | "email": "jrhuggins@gmail.com", 46 | "url": "http://www.hugs.io/" 47 | } 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var fs = require('fs'); 4 | var evaljs = require('./index'); 5 | var parse = require('acorn').parse; 6 | var requireFromString = require('require-from-string'); 7 | 8 | function run(iter){ 9 | var result = iter.next(); 10 | while(!result.done) { 11 | result = iter.next(); 12 | } 13 | return result.value; 14 | } 15 | 16 | // basic 17 | console.log(evaljs.evaluate('1 + 1')); 18 | 19 | // theTest.js 20 | var code = fs.readFileSync('theTest.js', {encoding: 'UTF-8'}); 21 | var parsedCode = parse(code, {'locations': true}); 22 | var env = new evaljs.Environment([{console: console}]); 23 | var iter1 = env.gen(parsedCode)(); 24 | run(iter1); 25 | 26 | // index.js 27 | var code = fs.readFileSync('index-compiled.js', {encoding: 'UTF-8'}); 28 | var script = "var evaljs = requireFromString(code);" + 29 | "console.log(evaljs.evaluate('30 + 4'));"; 30 | var envGlobal = { 31 | code: code, 32 | console: console 33 | }; 34 | envGlobal.global = global; 35 | var modLocal = { 36 | requireFromString: requireFromString, 37 | }; 38 | var env = new evaljs.Environment([envGlobal, modLocal]); 39 | var iter2 = env.gen(script)(); 40 | run(iter2); 41 | 42 | // acorn.js 43 | var code = fs.readFileSync(require.resolve('acorn'), {encoding: 'UTF-8'}); 44 | var envGlobal = { code: code }; 45 | var envModules = { requireFromString: requireFromString }; 46 | var env = new evaljs.Environment([envGlobal, envModules]); 47 | 48 | // load library 49 | var iter3 = env.gen("var acorn = requireFromString(code);")(); 50 | run(iter3); 51 | 52 | // parse file 53 | var iter4 = env.gen("acorn.parse('1 + 1');")(); 54 | var parsed = run(iter4); 55 | 56 | // for bonus points: run the parsed expression 57 | var iter5 = env.gen(parsed)(); 58 | console.log(run(iter5)); 59 | 60 | // using esprima 61 | var esprima = require('esprima'); 62 | console.log(evaljs.evaluate(esprima.parse('1 + 1'))); -------------------------------------------------------------------------------- /theTest.js: -------------------------------------------------------------------------------- 1 | // not strict, 'cause we need to parse the with statement 2 | /* jshint strict: false */ 3 | 4 | // statements after a return are ok for test cases 5 | /* jshint -W027 */ 6 | // missing break statements in switch statements are ok 7 | /* jshint -W086 */ 8 | 9 | var op = { 10 | '+': function (a, b) {return a + b; } 11 | }['+']; 12 | console.log(op(2, 2)); 13 | 14 | function Test(name) { 15 | this._name = name; 16 | } 17 | 18 | Test.prototype.hello = function () { 19 | console.log("Hello,", this._name + "!"); 20 | }; 21 | 22 | var a = new Test("Marten"); 23 | a.hello(); 24 | 25 | for (var i = 0; i < 4; i += 1) { 26 | console.log(i); 27 | } 28 | 29 | if (1) { 30 | console.log(2); 31 | } 32 | 33 | if (0) { 34 | console.warn(1); 35 | } else { 36 | console.error(3); 37 | } 38 | 39 | console.log("Hello World!"); 40 | 41 | (function (name) { 42 | console.log("Hello", name + "!"); 43 | }('Marten')); 44 | 45 | var i = 0; 46 | while (i < 2) { 47 | ++i; 48 | console.log(i); 49 | } 50 | 51 | // works if you use 'global' instead of the custom global object that 52 | // only includes 'console' 53 | // 54 | // process.nextTick(function () { 55 | // console.log("Later..."); 56 | // }); 57 | 58 | function test(def) { 59 | return function () { 60 | return def.abc; 61 | }; 62 | } 63 | 64 | console.log(test({abc: []})()); 65 | 66 | var a = (1, 2); 67 | console.log(a); 68 | 69 | var i = 0; 70 | do { 71 | console.log(i); 72 | i++; 73 | } while (i < 2); 74 | 75 | console.log(1 ? 0 : 1); 76 | console.log(0 ? 0 : 1); 77 | 78 | try { 79 | throw new Error('Hello World!'); 80 | } catch (err) { 81 | } finally { 82 | } 83 | 84 | for (var i = 0; i < 10; i++) { 85 | if (i === 1) { 86 | continue; 87 | } 88 | if (i === 3) { 89 | break; 90 | } 91 | console.log(i); 92 | } 93 | 94 | console.log(function () { 95 | var x = 4; 96 | console.log(1); 97 | if (x) { 98 | console.log(2); 99 | for (var i = 0; i < 3; i++) { 100 | console.log(3); 101 | return x; 102 | console.log(5); 103 | } 104 | console.log(6); 105 | } 106 | console.log(7); 107 | }()); 108 | 109 | var x = 2; 110 | switch (x) { 111 | case 1: 112 | console.log(1); 113 | //falls through 114 | case 2: 115 | console.log(2); 116 | case 3: 117 | console.log(3); 118 | break; 119 | case 4: 120 | console.log(4); 121 | default: 122 | console.log(5); 123 | } 124 | 125 | switch (x) { 126 | case 1: 127 | console.log(1); 128 | default: 129 | console.log(2); 130 | } 131 | 132 | switch (x) { 133 | case 2: 134 | console.log(3); 135 | break; 136 | default: 137 | console.log(4); 138 | } 139 | 140 | switch (x) { 141 | case 2: 142 | console.log(5); 143 | default: 144 | console.log(6); 145 | } 146 | 147 | switch (x) { 148 | default: 149 | console.log(7); 150 | case 2: 151 | console.log(8); 152 | } 153 | 154 | switch (x) { 155 | default: 156 | console.log(9); 157 | break; 158 | case 2: 159 | console.log(10); 160 | } 161 | 162 | var z; 163 | for (z in {a: 1, b: 2}) { 164 | console.log(z); 165 | } 166 | 167 | for (var key in {a: 1, b: 2}) { 168 | console.log(key); 169 | } 170 | 171 | abcdefg(); 172 | 173 | function abcdefg() { 174 | console.log('should be called'); 175 | } 176 | 177 | var obj = {}; 178 | obj.a = 3; 179 | console.log(obj.a); 180 | delete obj.a; 181 | console.log(obj.a); 182 | 183 | /*jshint ignore:start*/ 184 | with ({a: 1, b: 2}) { 185 | console.log(a, b); 186 | } 187 | /*jshint ignore:end*/ 188 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | eval.js 2 | ======= 3 | 4 | [![Build Status](https://travis-ci.org/marten-de-vries/evaljs.svg?branch=master)](https://travis-ci.org/marten-de-vries/evaljs) 5 | [![Dependency Status](https://david-dm.org/marten-de-vries/evaljs.svg)](https://david-dm.org/marten-de-vries/evaljs) 6 | [![devDependency Status](https://david-dm.org/marten-de-vries/evaljs/dev-status.svg)](https://david-dm.org/marten-de-vries/evaljs#info=devDependencies) 7 | 8 | A JavaScript interpreter written in JavaScript. 9 | 10 | Why? 11 | ---- 12 | 13 | You might be working in a JavaScript environment where ``eval()`` isn't 14 | allowed (and you have a genuinely good reason why you want to use it). 15 | Maybe this'll slip under the radar. You could also extend this to make 16 | it execute ES6 code in an ES5 environment. PRs welcome! 17 | 18 | How? 19 | ---- 20 | 21 | Most of the heavy lifting is done by [acorn][], a JavaScript parser 22 | written in JavaScript. **eval.js** converts the [AST] it generates into 23 | JavaScript function closures, which when run execute the whole program. 24 | 25 | It's also possible to use **eval.js** with [esprima][]. 26 | 27 | [acorn]: http://marijnhaverbeke.nl/acorn/ 28 | [AST]: https://en.wikipedia.org/wiki/Abstract_syntax_tree 29 | [esprima]: http://esprima.org/ 30 | 31 | Command line interface 32 | ---------------------- 33 | 34 | This npm package comes with a REPL which allows you to experiment with 35 | it. It's easy to install and use: 36 | 37 | ``` 38 | marten@procyon:~/git/evaljs$ npm install -g evaljs 39 | marten@procyon:~/git/evaljs$ evaljs 40 | > 1 + 1 41 | 2 42 | > new Error('Hello World!') 43 | [Error: Hello World!] 44 | > throw new Error('Hello World!') 45 | Error: Hello World! 46 | at newWithArgs (/home/marten/git/evaljs/index.js:255:10) 47 | at /home/marten/git/evaljs/index.js:249:12 48 | at Array.0 (/home/marten/git/evaljs/index.js:581:11) 49 | at /home/marten/git/evaljs/index.js:466:31 50 | at REPLServer.repl.start.eval (/home/marten/git/evaljs/bin/evaljs:12:34) 51 | at repl.js:249:20 52 | at REPLServer.repl.start.eval (/home/marten/git/evaljs/bin/evaljs:14:7) 53 | at Interface. (repl.js:239:12) 54 | at Interface.EventEmitter.emit (events.js:95:17) 55 | at Interface._onLine (readline.js:202:10) 56 | > marten@procyon:~/git/evaljs$ 57 | ``` 58 | 59 | API 60 | --- 61 | 62 | - ``evaljs.evaluate(code)`` 63 | A drop in alternative for ``window.eval()``. 64 | - ``new evaljs.Environment([scopesOrGlobalObject])`` 65 | Generates a new JS Environment to 'run' code in. The argument can be 66 | one of the following: 67 | - a global object 68 | - nothing (in this case, '{}' is used as the global object) 69 | - a list of objects. The first will be the global object, others will 70 | be other scopes loaded into the interpreter. Kind of like wrapping 71 | the code in a with statement for each further object in the array. 72 | This is handy for emulating Node.js (for passing in ``require()``, 73 | ``exports``, and ``module``.) 74 | 75 | A JS Environment has the following properties: 76 | - ``env.gen(node)``: Takes either the result of acorn's ``parse()`` 77 | method (an AST), or a JS string containing source code. This 78 | AST/code will be converted into a function that, when run, executes 79 | the AST/code passed in and returns the result. 80 | - ``env.DEBUG``: When set to ``true``, evaljs will write debug 81 | information to stdout. 82 | 83 | Size? 84 | ----- 85 | 86 | 16.3kB min+gzip 87 | 88 | License? 89 | -------- 90 | 91 | ISC 92 | 93 | Is it complete? 94 | --------------- 95 | 96 | No labeled statements; no nice error handling (although there is a 97 | ``DEBUG`` option). There are probably bugs. That said, it can run itself 98 | and acorn, so its supported subset of JS is usable. PRs containing 99 | improvements welcome! 100 | 101 | How slow is it? 102 | --------------- 103 | 104 | Not sure. I only tested with small snippets so far in Node.js, for 105 | which the speed difference isn't notable. But it's probably slow. 106 | 107 | Who? 108 | ---- 109 | 110 | **eval.js** is written by Marten de Vries. Maintained by Jason Huggins. 111 | Credits for the original idea go to [closure-interpreter][]. 112 | 113 | [closure-interpreter]: https://github.com/int3/closure-interpreter 114 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* jshint esversion: 6 */ 2 | /* jshint noyield: true */ 3 | 4 | "use strict"; 5 | 6 | //TODO: 7 | //- LabeledStatement -> including use in break/continue 8 | //- nicer error handling? 9 | //-> TESTS 10 | //-> BENCHMARKS 11 | 12 | var parse = require('acorn').parse; 13 | var util = require("util"); 14 | var EventEmitter = require("events").EventEmitter; 15 | 16 | function noop() {} 17 | 18 | function execute(func) { 19 | var result = func(); 20 | if ('' + result === 'null') { 21 | return result; 22 | } 23 | // FIXME: Convert to yield* 24 | if (result !== undefined) { 25 | if (result.next) { 26 | var iter = result; 27 | var res = iter.next(); 28 | while (!res.done) { 29 | res = iter.next(); 30 | } 31 | if ('' + res.value === 'null') { 32 | return res.value; 33 | } 34 | if ('' + res.value === 'undefined') { 35 | return res.value; 36 | } 37 | return res.value; 38 | } 39 | } 40 | return result; 41 | } 42 | 43 | function Arguments() { 44 | //TODO: add es3 'arguments.callee'? 45 | } 46 | 47 | Arguments.prototype.toString = function () { 48 | return '[object Arguments]'; 49 | }; 50 | 51 | function Return(val) { 52 | this.value = val; 53 | } 54 | 55 | // need something unique to compare a against. 56 | var Break = {}; 57 | var Continue = {}; 58 | 59 | function Environment(globalObjects) { 60 | EventEmitter.call(this); 61 | if (!Array.isArray(globalObjects)) { 62 | globalObjects = [globalObjects]; 63 | } 64 | var parent; 65 | globalObjects.forEach(function (vars) { 66 | parent = createVarStore(parent, vars); 67 | }); 68 | // the topmost store is our current store 69 | this._curVarStore = parent; 70 | this._curDeclarations = {}; 71 | this._globalObj = globalObjects[0]; 72 | this._curThis = this._globalObj; 73 | this._boundGen = this._gen.bind(this); 74 | this.DEBUG = false; 75 | this.DELAY = 0; 76 | this.STATE = 'running'; 77 | } 78 | 79 | util.inherits(Environment, EventEmitter); 80 | 81 | function createVarStore(parent, vars) { 82 | vars = vars || {}; 83 | return { 84 | parent: parent, 85 | vars: vars 86 | }; 87 | } 88 | 89 | Environment.prototype.gen = function (node) { 90 | var opts = { 91 | 'locations': true 92 | }; 93 | if (typeof node === 'string') { 94 | node = parse(node, opts); 95 | } 96 | var resp = this._gen(node); 97 | addDeclarationsToStore(this._curDeclarations, this._curVarStore); 98 | this._curDeclarations = {}; 99 | return resp; 100 | }; 101 | 102 | Environment.prototype._gen = function (node) { 103 | var closure = ({ 104 | BinaryExpression: this._genBinExpr, 105 | LogicalExpression: this._genBinExpr, 106 | UnaryExpression: this._genUnaryExpr, 107 | UpdateExpression: this._genUpdExpr, 108 | ObjectExpression: this._genObjExpr, 109 | ArrayExpression: this._genArrExpr, 110 | CallExpression: this._genCallExpr, 111 | NewExpression: this._genNewExpr, 112 | MemberExpression: this._genMemExpr, 113 | ThisExpression: this._genThisExpr, 114 | SequenceExpression: this._genSeqExpr, 115 | Literal: this._genLit, 116 | Identifier: this._genIdent, 117 | AssignmentExpression: this._genAssignExpr, 118 | FunctionDeclaration: this._genFuncDecl, 119 | VariableDeclaration: this._genVarDecl, 120 | BlockStatement: this._genProgram, 121 | Program: this._genProgram, 122 | ExpressionStatement: this._genExprStmt, 123 | EmptyStatement: this._genEmptyStmt, 124 | ReturnStatement: this._genRetStmt, 125 | FunctionExpression: this._genFuncExpr, 126 | IfStatement: this._genIfStmt, 127 | ConditionalExpression: this._genCondStmt, 128 | ForStatement: this._genLoopStmt, 129 | WhileStatement: this._genLoopStmt, 130 | DoWhileStatement: this._genDoWhileStmt, 131 | ForInStatement: this._genForInStmt, 132 | WithStatement: this._genWithStmt, 133 | ThrowStatement: this._genThrowStmt, 134 | TryStatement: this._genTryStmt, 135 | ContinueStatement: this._genContStmt, 136 | BreakStatement: this._genBreakStmt, 137 | SwitchStatement: this._genSwitchStmt 138 | }[node.type] || function () { 139 | console.warn("Not implemented yet: " + node.type); 140 | return noop; 141 | }).call(this, node); 142 | 143 | if (this.DEBUG) { 144 | return function () { 145 | var info = 'closure for ' + node.type + ' called'; 146 | var line = ((node.loc || {}).start || {}).line; 147 | if (line) { 148 | info += ' while processing line ' + line; 149 | } 150 | var resp = closure(); 151 | info += '. Result:'; 152 | console.log(info, resp); 153 | return resp; 154 | }; 155 | } 156 | return closure; 157 | }; 158 | 159 | Environment.prototype._genBinExpr = function (node) { 160 | var a = this._gen(node.left); 161 | var b = this._gen(node.right); 162 | 163 | function* callExpr(expr) { 164 | var result; 165 | if (expr.constructor.name == 'GeneratorFunction') { 166 | result = yield* expr(); 167 | } else { 168 | result = expr(); 169 | } 170 | return result; 171 | } 172 | 173 | var cmp = { 174 | '==': function* () { 175 | return (yield* callExpr(a)) == (yield* callExpr(b)); 176 | }, 177 | '!=': function* () { 178 | return (yield* callExpr(a)) != (yield* callExpr(b)); 179 | }, 180 | '===': function* () { 181 | return (yield* callExpr(a)) === (yield* callExpr(b)); 182 | }, 183 | '!==': function* () { 184 | return (yield* callExpr(a)) !== (yield* callExpr(b)); 185 | }, 186 | '<': function* () { 187 | return (yield* callExpr(a)) < (yield* callExpr(b)); 188 | }, 189 | '<=': function* () { 190 | return (yield* callExpr(a)) <= (yield* callExpr(b)); 191 | }, 192 | '>': function* () { 193 | return (yield* callExpr(a)) > (yield* callExpr(b)); 194 | }, 195 | '>=': function* () { 196 | return (yield* callExpr(a)) >= (yield* callExpr(b)); 197 | }, 198 | '<<': function* () { 199 | return (yield* callExpr(a)) << (yield* callExpr(b)); 200 | }, 201 | '>>': function* () { 202 | return (yield* callExpr(a)) >> (yield* callExpr(b)); 203 | }, 204 | '>>>': function* () { 205 | return (yield* callExpr(a)) >>> (yield* callExpr(b)); 206 | }, 207 | '+': function* () { 208 | return (yield* callExpr(a)) + (yield* callExpr(b)); 209 | }, 210 | '-': function* () { 211 | return (yield* callExpr(a)) - (yield* callExpr(b)); 212 | }, 213 | '*': function* () { 214 | return (yield* callExpr(a)) * (yield* callExpr(b)); 215 | }, 216 | '/': function* () { 217 | return (yield* callExpr(a)) / (yield* callExpr(b)); 218 | }, 219 | '%': function* () { 220 | return (yield* callExpr(a)) % (yield* callExpr(b)); 221 | }, 222 | '|': function* () { 223 | return (yield* callExpr(a)) | (yield* callExpr(b)); 224 | }, 225 | '^': function* () { 226 | return (yield* callExpr(a)) ^ (yield* callExpr(b)); 227 | }, 228 | '&': function* () { 229 | return (yield* callExpr(a)) & (yield* callExpr(b)); 230 | }, 231 | 'in': function* () { 232 | return (yield* callExpr(a)) in (yield* callExpr(b)); 233 | }, 234 | 'instanceof': function* () { 235 | return (yield* callExpr(a)) instanceof (yield* callExpr(b)); 236 | }, 237 | // logic expressions 238 | '||': function* () { 239 | return (yield* callExpr(a)) || (yield* callExpr(b)); 240 | }, 241 | '&&': function* () { 242 | return (yield* callExpr(a)) && (yield* callExpr(b)); 243 | } 244 | }[node.operator]; 245 | 246 | return function () { 247 | // FIXME: Convert to yield* 248 | var iter = cmp(); 249 | var res = iter.next(); 250 | while (!res.done) { 251 | res = iter.next(); 252 | } 253 | return res.value; 254 | }; 255 | }; 256 | 257 | Environment.prototype._genUnaryExpr = function (node) { 258 | if (node.operator === 'delete') { 259 | return this._genDelete(node); 260 | } 261 | var a = this._gen(node.argument); 262 | var op = { 263 | '-': function () { 264 | return -a(); 265 | }, 266 | '+': function () { 267 | return +a(); 268 | }, 269 | '!': function () { 270 | return !a(); 271 | }, 272 | '~': function () { 273 | return ~a(); 274 | }, 275 | 'typeof': function () { 276 | return typeof a(); 277 | }, 278 | 'void': function () { 279 | return void a(); 280 | } 281 | }[node.operator]; 282 | 283 | return function () { 284 | return op(); 285 | }; 286 | }; 287 | 288 | Environment.prototype._genDelete = function (node) { 289 | var obj = this._genObj(node.argument); 290 | var attr = this._genName(node.argument); 291 | 292 | return function () { 293 | return delete obj()[attr()]; 294 | }; 295 | }; 296 | 297 | Environment.prototype._genObjExpr = function (node) { 298 | //TODO property.kind: don't assume init when it can also be set/get 299 | var self = this; 300 | var items = []; 301 | node.properties.forEach(function (property) { 302 | // object expression keys are static so can be calculated 303 | // immediately 304 | var key = self._objKey(property.key)(); 305 | items.push({ 306 | key: key, 307 | getVal: self._gen(property.value) 308 | }); 309 | }); 310 | 311 | return function () { 312 | var result = {}; 313 | items.forEach(function (item) { 314 | result[item.key] = item.getVal(); 315 | }); 316 | return result; 317 | }; 318 | }; 319 | 320 | Environment.prototype._genArrExpr = function (node) { 321 | var items = node.elements.map(this._boundGen); 322 | 323 | return function () { 324 | return items.map(execute); 325 | }; 326 | }; 327 | 328 | Environment.prototype._objKey = function (node) { 329 | var key; 330 | if (node.type === 'Identifier') { 331 | key = node.name; 332 | } else { 333 | key = this._gen(node)(); 334 | } 335 | 336 | return function () { 337 | return key; 338 | }; 339 | }; 340 | 341 | Environment.prototype._genCallExpr = function (node) { 342 | var self = this; 343 | var callee; 344 | if (node.callee.type === 'MemberExpression') { 345 | var obj = self._genObj(node.callee); 346 | var name = self._genName(node.callee); 347 | callee = function () { 348 | var theObj = obj(); 349 | return theObj[name()].bind(theObj); 350 | }; 351 | } else { 352 | callee = self._gen(node.callee); 353 | } 354 | var args = node.arguments.map(self._gen.bind(self)); 355 | 356 | return function* () { 357 | self.emit('line', node.loc.start.line); 358 | var c = callee(); 359 | 360 | if (c === undefined) { 361 | return c; 362 | } 363 | 364 | var result; 365 | var res; 366 | 367 | if (c.next) { 368 | res = yield* c; 369 | result = res.apply(self._globalObj, args.map(execute)); 370 | } else { 371 | result = c.apply(self._globalObj, args.map(execute)); 372 | } 373 | 374 | if (result !== undefined) { 375 | if (result.next) { 376 | res = yield* result; 377 | return res; 378 | } 379 | } 380 | return result; 381 | }; 382 | }; 383 | 384 | Environment.prototype._genNewExpr = function (node) { 385 | var callee = this._gen(node.callee); 386 | var args = node.arguments.map(this._boundGen); 387 | var self = this; 388 | 389 | return function* () { 390 | self.emit('line', node.loc.start.line); 391 | var cl = callee(); 392 | var ar = args.map(execute); 393 | var newObject = Object.create(cl.prototype); 394 | var constructor = cl.apply(newObject, ar); 395 | yield* constructor; 396 | return newObject; 397 | }; 398 | }; 399 | 400 | Environment.prototype._genMemExpr = function (node) { 401 | var self = this; 402 | var obj = this._gen(node.object); 403 | var property = this._memExprProperty(node); 404 | return function () { 405 | self.emit('line', node.loc.start.line); 406 | return obj()[property()]; 407 | }; 408 | }; 409 | 410 | Environment.prototype._memExprProperty = function (node) { 411 | return node.computed ? this._gen(node.property) : this._objKey(node.property); 412 | }; 413 | 414 | Environment.prototype._genThisExpr = function () { 415 | var self = this; 416 | return function () { 417 | return self._curThis; 418 | }; 419 | }; 420 | 421 | Environment.prototype._genSeqExpr = function (node) { 422 | var exprs = node.expressions.map(this._boundGen); 423 | return function () { 424 | var result; 425 | exprs.forEach(function (expr) { 426 | result = expr(); 427 | }); 428 | return result; 429 | }; 430 | }; 431 | 432 | Environment.prototype._genUpdExpr = function (node) { 433 | var self = this; 434 | var update = { 435 | '--true': function (obj, name) { 436 | return --obj[name]; 437 | }, 438 | '--false': function (obj, name) { 439 | return obj[name]--; 440 | }, 441 | '++true': function (obj, name) { 442 | return ++obj[name]; 443 | }, 444 | '++false': function (obj, name) { 445 | return obj[name]++; 446 | } 447 | }[node.operator + node.prefix]; 448 | var obj = this._genObj(node.argument); 449 | var name = this._genName(node.argument); 450 | return function* () { 451 | self.emit('line', node.loc.start.line); 452 | yield; 453 | return update(obj(), name()); 454 | }; 455 | }; 456 | 457 | Environment.prototype._genObj = function (node) { 458 | if (node.type === 'Identifier') { 459 | return this._getVarStore.bind(this, node.name); 460 | } else if (node.type === 'MemberExpression') { 461 | return this._gen(node.object); 462 | } else { 463 | console.warn("Unknown _genObj() type: " + node.type); 464 | return noop; 465 | } 466 | }; 467 | 468 | Environment.prototype._genName = function (node) { 469 | if (node.type === 'Identifier') { 470 | return function () { 471 | return node.name; 472 | }; 473 | } else if (node.type === 'MemberExpression') { 474 | return this._memExprProperty(node); 475 | } else { 476 | console.warn("Unknown _genName() type: " + node.type); 477 | return noop; 478 | } 479 | }; 480 | 481 | Environment.prototype._genLit = function (node) { 482 | return function () { 483 | return node.value; 484 | }; 485 | }; 486 | 487 | Environment.prototype._genIdent = function (node) { 488 | var self = this; 489 | return function () { 490 | return self._getVarStore(node.name)[node.name]; 491 | }; 492 | }; 493 | 494 | Environment.prototype._getVarStore = function (name) { 495 | var store = this._curVarStore; 496 | do { 497 | if (store.vars.hasOwnProperty(name)) { 498 | return store.vars; 499 | } 500 | } while ((store = store.parent)); 501 | 502 | // global object as fallback 503 | return this._globalObj; 504 | }; 505 | 506 | Environment.prototype._genAssignExpr = function (node) { 507 | var self = this; 508 | var setter = { 509 | '=': function (obj, name, val) { 510 | return (obj[name] = val); 511 | }, 512 | '+=': function (obj, name, val) { 513 | return obj[name] += val; 514 | }, 515 | '-=': function (obj, name, val) { 516 | return obj[name] -= val; 517 | }, 518 | '*=': function (obj, name, val) { 519 | return obj[name] *= val; 520 | }, 521 | '/=': function (obj, name, val) { 522 | return obj[name] /= val; 523 | }, 524 | '%=': function (obj, name, val) { 525 | return obj[name] %= val; 526 | }, 527 | '<<=': function (obj, name, val) { 528 | return obj[name] <<= val; 529 | }, 530 | '>>=': function (obj, name, val) { 531 | return obj[name] >>= val; 532 | }, 533 | '>>>=': function (obj, name, val) { 534 | return obj[name] >>>= val; 535 | }, 536 | '|=': function (obj, name, val) { 537 | return obj[name] |= val; 538 | }, 539 | '^=': function (obj, name, val) { 540 | return obj[name] ^= val; 541 | }, 542 | '&=': function (obj, name, val) { 543 | return obj[name] &= val; 544 | } 545 | }[node.operator]; 546 | var obj = this._genObj(node.left); 547 | var name = this._genName(node.left); 548 | var val = this._gen(node.right); 549 | return function* () { 550 | self.emit('line', node.left.loc.start.line); 551 | var v = val(); 552 | if (v !== undefined) { 553 | if (v.next) { 554 | v = yield* v; 555 | } 556 | } 557 | return setter(obj(), name(), v); 558 | }; 559 | }; 560 | 561 | Environment.prototype._genFuncDecl = function (node) { 562 | this._curDeclarations[node.id.name] = this._genFuncExpr(node); 563 | return function* () { 564 | return noop; 565 | }; 566 | }; 567 | 568 | Environment.prototype._genVarDecl = function (node) { 569 | var assignments = []; 570 | for (var i = 0; i < node.declarations.length; i++) { 571 | var decl = node.declarations[i]; 572 | this._curDeclarations[decl.id.name] = noop; 573 | if (decl.init) { 574 | assignments.push({ 575 | type: 'AssignmentExpression', 576 | operator: '=', 577 | left: decl.id, 578 | right: decl.init 579 | }); 580 | } 581 | } 582 | return this._gen({ 583 | type: 'BlockStatement', 584 | body: assignments 585 | }); 586 | }; 587 | 588 | Environment.prototype.getState = function () { 589 | return this.STATE; 590 | }; 591 | 592 | Environment.prototype.setState = function (state) { 593 | this.STATE = state; 594 | }; 595 | 596 | Environment.prototype._genFuncExpr = function (node) { 597 | var self = this; 598 | 599 | var oldDeclarations = self._curDeclarations; 600 | self._curDeclarations = {}; 601 | var body = self._gen(node.body); 602 | var declarations = self._curDeclarations; 603 | self._curDeclarations = oldDeclarations; 604 | 605 | // reset var store 606 | return function () { 607 | var parent = self._curVarStore; 608 | return function* () { 609 | // build arguments object 610 | var args = new Arguments(); 611 | args.length = arguments.length; 612 | for (var i = 0; i < arguments.length; i++) { 613 | args[i] = arguments[i]; 614 | } 615 | 616 | // switch interpreter 'stack' 617 | var oldStore = self._curVarStore; 618 | var oldThis = self._curThis; 619 | self._curVarStore = createVarStore(parent); 620 | self._curThis = this; 621 | 622 | addDeclarationsToStore(declarations, self._curVarStore); 623 | self._curVarStore.vars.arguments = args; 624 | 625 | // add function args to var store 626 | node.params.forEach(function (param, i) { 627 | self._curVarStore.vars[param.name] = args[i]; 628 | }); 629 | 630 | // run function body 631 | var result = yield* body(); 632 | 633 | // switch 'stack' back 634 | self._curThis = oldThis; 635 | self._curVarStore = oldStore; 636 | 637 | if (result instanceof Return) { 638 | return result.value; 639 | } 640 | }; 641 | }; 642 | }; 643 | 644 | function addDeclarationsToStore(declarations, varStore) { 645 | for (var key in declarations) { 646 | if (declarations.hasOwnProperty(key) && !varStore.vars.hasOwnProperty(key)) { 647 | varStore.vars[key] = declarations[key](); 648 | } 649 | } 650 | } 651 | 652 | Environment.prototype._genProgram = function (node) { 653 | var self = this; 654 | var stmtClosures = node.body.map(function (stmt) { 655 | return self._gen(stmt); 656 | }); 657 | 658 | return function* () { 659 | var result; 660 | for (var i = 0; i < stmtClosures.length; i++) { 661 | if (stmtClosures[i].constructor.name === 'GeneratorFunction') { 662 | result = yield* stmtClosures[i](); 663 | yield; 664 | } else { 665 | result = stmtClosures[i](); 666 | yield; 667 | } 668 | if (result === Break || result === Continue || result instanceof Return) { 669 | break; 670 | } 671 | } 672 | //return last 673 | return result; 674 | }; 675 | }; 676 | 677 | Environment.prototype._genExprStmt = function (node) { 678 | return this._gen(node.expression); 679 | }; 680 | 681 | Environment.prototype._genEmptyStmt = function () { 682 | return noop; 683 | }; 684 | 685 | Environment.prototype._genRetStmt = function (node) { 686 | var self = this; 687 | var arg = node.argument ? this._gen(node.argument) : noop; 688 | return function () { 689 | self.emit('line', node.loc.start.line); 690 | return new Return(arg()); 691 | }; 692 | }; 693 | 694 | Environment.prototype._genIfStmt = function (node) { 695 | var self = this; 696 | var test = function () { 697 | self.emit('line', node.loc.start.line); 698 | return self._gen(node.test)(); 699 | }; 700 | var consequent = this._gen(node.consequent); 701 | var alternate = node.alternate ? this._gen(node.alternate) : function* () { 702 | return noop; 703 | }; 704 | 705 | return function* () { 706 | var result = test() ? yield* consequent() : yield* alternate(); 707 | return result; 708 | }; 709 | }; 710 | 711 | Environment.prototype._genCondStmt = function (node) { 712 | var self = this; 713 | var test = function () { 714 | self.emit('line', node.loc.start.line); 715 | return self._gen(node.test)(); 716 | }; 717 | var consequent = this._gen(node.consequent); 718 | var alternate = node.alternate ? this._gen(node.alternate) : noop; 719 | 720 | return function () { 721 | return test() ? consequent() : alternate(); 722 | }; 723 | }; 724 | 725 | Environment.prototype._genLoopStmt = function (node, body) { 726 | var self = this; 727 | var init = node.init ? this._gen(node.init) : function* () { 728 | return noop; 729 | }; 730 | var test = node.test ? function* () { 731 | self.emit('line', node.loc.start.line); 732 | return self._gen(node.test)(); 733 | } : function* () { 734 | return true; 735 | }; 736 | var update = node.update ? this._gen(node.update) : function* () { 737 | return noop; 738 | }; 739 | body = body || this._gen(node.body); 740 | 741 | return function* () { 742 | self.emit('line', node.loc.start.line); 743 | var resp; 744 | for (yield* init(); yield* test(); yield* update()) { 745 | var newResp = yield* body(); 746 | 747 | if (newResp === Break) { 748 | break; 749 | } 750 | if (newResp === Continue) { 751 | continue; 752 | } 753 | resp = newResp; 754 | if (newResp instanceof Return) { 755 | break; 756 | } 757 | } 758 | return resp; 759 | }; 760 | }; 761 | 762 | Environment.prototype._genDoWhileStmt = function (node) { 763 | var body = this._gen(node.body); 764 | var loop = this._genLoopStmt(node, body); 765 | 766 | return function* () { 767 | yield* body(); 768 | yield* loop(); 769 | }; 770 | }; 771 | 772 | Environment.prototype._genForInStmt = function (node) { 773 | var self = this; 774 | var right = self._gen(node.right); 775 | var body = self._gen(node.body); 776 | 777 | var left = node.left; 778 | if (left.type === 'VariableDeclaration') { 779 | self._curDeclarations[left.declarations[0].id.name] = noop; 780 | left = left.declarations[0].id; 781 | } 782 | return function* () { 783 | self.emit('line', node.loc.start.line); 784 | var resp; 785 | for (var x in right()) { 786 | self.emit('line', node.loc.start.line); 787 | yield* self._genAssignExpr({ 788 | operator: '=', 789 | left: left, 790 | right: { 791 | type: 'Literal', 792 | value: x 793 | } 794 | })(); 795 | resp = yield* body(); 796 | } 797 | return resp; 798 | }; 799 | }; 800 | 801 | Environment.prototype._genWithStmt = function (node) { 802 | var self = this; 803 | var obj = self._gen(node.object); 804 | var body = self._gen(node.body); 805 | return function* () { 806 | self._curVarStore = createVarStore(self._curVarStore, obj()); 807 | var result = yield* body(); 808 | self._curVarStore = self._curVarStore.parent; 809 | return result; 810 | }; 811 | }; 812 | 813 | Environment.prototype._genThrowStmt = function (node) { 814 | var arg = this._gen(node.argument); 815 | return function () { 816 | throw arg(); 817 | }; 818 | }; 819 | 820 | Environment.prototype._genTryStmt = function (node) { 821 | var block = this._gen(node.block); 822 | var handler = this._genCatchHandler(node.handler); 823 | var finalizer = node.finalizer ? this._gen(node.finalizer) : function (x) { 824 | return x; 825 | }; 826 | 827 | return function () { 828 | try { 829 | return finalizer(block()); 830 | } catch (err) { 831 | return finalizer(handler(err)); 832 | } 833 | }; 834 | }; 835 | 836 | Environment.prototype._genCatchHandler = function (node) { 837 | if (!node) { 838 | return noop; 839 | } 840 | var self = this; 841 | var body = self._gen(node.body); 842 | return function (err) { 843 | var old = self._curVarStore.vars[node.param.name]; 844 | self._curVarStore.vars[node.param.name] = err; 845 | var resp = body(); 846 | self._curVarStore.vars[node.param.name] = old; 847 | 848 | return resp; 849 | }; 850 | }; 851 | 852 | Environment.prototype._genContStmt = function () { 853 | return function () { 854 | return Continue; 855 | }; 856 | }; 857 | 858 | Environment.prototype._genBreakStmt = function () { 859 | return function () { 860 | return Break; 861 | }; 862 | }; 863 | 864 | Environment.prototype._genSwitchStmt = function (node) { 865 | var self = this; 866 | 867 | var discriminant = self._gen(node.discriminant); 868 | var cases = node.cases.map(function (curCase) { 869 | return { 870 | test: curCase.test ? self._gen(curCase.test) : null, 871 | code: self._genProgram({ body: curCase.consequent }) 872 | }; 873 | }); 874 | 875 | return function* () { 876 | var foundMatch = false; 877 | var discriminantVal = discriminant(); 878 | var resp, defaultCase; 879 | 880 | for (var i = 0; i < cases.length; i++) { 881 | var curCase = cases[i]; 882 | if (!foundMatch) { 883 | if (!curCase.test) { 884 | defaultCase = curCase; 885 | continue; 886 | } 887 | if (discriminantVal !== curCase.test()) { 888 | continue; 889 | } 890 | foundMatch = true; 891 | } 892 | // foundMatch is guaranteed to be true here 893 | var newResp = yield* curCase.code(); 894 | if (newResp === Break) { 895 | return resp; 896 | } 897 | resp = newResp; 898 | if (resp === Continue || resp instanceof Return) { 899 | return resp; 900 | } 901 | } 902 | if (!foundMatch && defaultCase) { 903 | return yield* defaultCase.code(); 904 | } 905 | }; 906 | }; 907 | 908 | exports.Environment = Environment; 909 | exports.evaluate = function (code) { 910 | var env = new Environment(global); 911 | var iterator = env.gen(code)(); 912 | var result = iterator.next(); 913 | while (!result.done) { 914 | result = iterator.next(); 915 | } 916 | return result.value; 917 | }; 918 | 919 | //console.log(exports.evaluate("1 + 1")); 920 | -------------------------------------------------------------------------------- /dist/eval.min.js: -------------------------------------------------------------------------------- 1 | require=function t(e,r,n){function i(a,o){if(!r[a]){if(!e[a]){var c="function"==typeof require&&require;if(!o&&c)return c(a,!0);if(s)return s(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var h=r[a]={exports:{}};e[a][0].call(h.exports,function(t){var r=e[a][1][t];return i(r?r:t)},h,h.exports,t,e,r,n)}return r[a].exports}for(var s="function"==typeof require&&require,a=0;a0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,s,o;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(a(r)){for(o=s;o-- >0;)if(r[o]===e||r[o].listener&&r[o].listener===e){n=o;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],2:[function(t,e,r){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(t){if(p===setTimeout)return setTimeout(t,0);if((p===n||!p)&&setTimeout)return p=setTimeout,setTimeout(t,0);try{return p(t,0)}catch(e){try{return p.call(null,t,0)}catch(e){return p.call(this,t,0)}}}function a(t){if(l===clearTimeout)return clearTimeout(t);if((l===i||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function o(){g&&d&&(g=!1,d.length?m=d.concat(m):y=-1,m.length&&c())}function c(){if(!g){var t=s(o);g=!0;for(var e=m.length;e;){for(d=m,m=[];++y1)for(var r=1;r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),m(e)?n.showHidden=e:e&&r._extend(n,e),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=s),c(n,t,n.depth)}function s(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function a(t,e){return t}function o(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}function c(t,e,n){if(t.customInspect&&e&&A(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return x(i)||(i=c(t,i,n)),i}var s=u(t,e);if(s)return s;var a=Object.keys(e),m=o(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(e)),S(e)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(e);if(0===a.length){if(A(e)){var g=e.name?": "+e.name:"";return t.stylize("[Function"+g+"]","special")}if(k(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(E(e))return t.stylize(Date.prototype.toString.call(e),"date");if(S(e))return h(e)}var y="",v=!1,b=["{","}"];if(d(e)&&(v=!0,b=["[","]"]),A(e)){var w=e.name?": "+e.name:"";y=" [Function"+w+"]"}if(k(e)&&(y=" "+RegExp.prototype.toString.call(e)),E(e)&&(y=" "+Date.prototype.toUTCString.call(e)),S(e)&&(y=" "+h(e)),0===a.length&&(!v||0==e.length))return b[0]+y+b[1];if(n<0)return k(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var _;return _=v?p(t,e,n,m,a):a.map(function(r){return l(t,e,n,m,r,v)}),t.seen.pop(),f(_,y,b)}function u(t,e){if(w(e))return t.stylize("undefined","undefined");if(x(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return v(e)?t.stylize(""+e,"number"):m(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,r,n,i){for(var s=[],a=0,o=e.length;a-1&&(o=s?o.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+o.split("\n").map(function(t){return" "+t}).join("\n"))):o=t.stylize("[Circular]","special")),w(a)){if(s&&i.match(/^\d+$/))return o;a=JSON.stringify(""+i),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+o}function f(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function m(t){return"boolean"==typeof t}function g(t){return null===t}function y(t){return null==t}function v(t){return"number"==typeof t}function x(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function w(t){return void 0===t}function k(t){return _(t)&&"[object RegExp]"===C(t)}function _(t){return"object"==typeof t&&null!==t}function E(t){return _(t)&&"[object Date]"===C(t)}function S(t){return _(t)&&("[object Error]"===C(t)||t instanceof Error)}function A(t){return"function"==typeof t}function L(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function C(t){return Object.prototype.toString.call(t)}function R(t){return t<10?"0"+t.toString(10):t.toString(10)}function N(){var t=new Date,e=[R(t.getHours()),R(t.getMinutes()),R(t.getSeconds())].join(":");return[t.getDate(),V[t.getMonth()],e].join(" ")}function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var T=/%[sdj%]/g;r.format=function(t){if(!x(t)){for(var e=[],r=0;r=s)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),o=n[r];rt)return!1;if(r+=e[n+1],r>=t)return!0}}function r(t,r){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&S.test(String.fromCharCode(t)):r!==!1&&e(t,L)))}function n(t,r){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&A.test(String.fromCharCode(t)):r!==!1&&(e(t,L)||e(t,C)))))}function i(t,e){return new R(t,{beforeExpr:!0,binop:e})}function s(t,e){return void 0===e&&(e={}),e.keyword=t,T[t]=new R(t,e)}function a(t){return 10===t||13===t||8232===t||8233===t}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}function c(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function u(t,e){for(var r=1,n=0;;){V.lastIndex=n;var i=V.exec(t);if(!(i&&i.index=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),o(e.onToken)){var n=e.onToken;e.onToken=function(t){return n.push(t)}}return o(e.onComment)&&(e.onComment=p(e,e.onComment)),e}function p(t,e){return function(r,n,i,s,a,o){var c={type:r?"Block":"Line",value:n,start:i,end:s};t.locations&&(c.loc=new Y(this,a,o)),t.ranges&&(c.range=[i,s]),e.push(c)}}function l(t){return new RegExp("^("+t.replace(/ /g,"|")+")$")}function f(t,e,r,n){return t.type=e,t.end=r,this.options.locations&&(t.loc.end=n),this.options.ranges&&(t.range[1]=r),t}function d(t,e,r,n){try{return new RegExp(t,e)}catch(t){if(void 0!==r)throw t instanceof SyntaxError&&n.raise(r,"Error parsing regular expression: "+t.message),t}}function m(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(1023&t)+56320))}function g(t,e){return new U(e,t).parse()}function y(t,e,r){var n=new U(r,t,e);return n.nextToken(),n.parseExpression()}function v(t,e){return new U(e,t)}function x(e,r,n){t.parse_dammit=e,t.LooseParser=r,t.pluginsLoose=n}var b={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"},w="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",k={5:w,6:w+" const class extends export import super"},_="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",E="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",S=new RegExp("["+_+"]"),A=new RegExp("["+_+E+"]");_=E=null;var L=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,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,449,56,264,8,2,36,18,0,50,29,881,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,0,32,6124,20,754,9486,1,3071,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,10591,541],C=[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,838,7,2,7,17,9,57,21,2,13,19882,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],R=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null},N={beforeExpr:!0},P={startsExpr:!0},T={},I={num:new R("num",P),regexp:new R("regexp",P),string:new R("string",P),name:new R("name",P),eof:new R("eof"),bracketL:new R("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new R("]"),braceL:new R("{",{beforeExpr:!0,startsExpr:!0}),braceR:new R("}"),parenL:new R("(",{beforeExpr:!0,startsExpr:!0}),parenR:new R(")"),comma:new R(",",N),semi:new R(";",N),colon:new R(":",N),dot:new R("."),question:new R("?",N),arrow:new R("=>",N),template:new R("template"),ellipsis:new R("...",N),backQuote:new R("`",P),dollarBraceL:new R("${",{beforeExpr:!0,startsExpr:!0}),eq:new R("=",{beforeExpr:!0,isAssign:!0}),assign:new R("_=",{beforeExpr:!0,isAssign:!0}),incDec:new R("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new R("prefix",{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 R("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:i("%",10),star:i("*",10),slash:i("/",10),starstar:new R("**",{beforeExpr:!0}),_break:s("break"),_case:s("case",N),_catch:s("catch"),_continue:s("continue"),_debugger:s("debugger"),_default:s("default",N),_do:s("do",{isLoop:!0,beforeExpr:!0}),_else:s("else",N),_finally:s("finally"),_for:s("for",{isLoop:!0}),_function:s("function",P),_if:s("if"),_return:s("return",N),_switch:s("switch"),_throw:s("throw",N),_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",P),_super:s("super",P),_class:s("class"),_extends:s("extends",N),_export:s("export"),_import:s("import"),_null:s("null",P),_true:s("true",P),_false:s("false",P),_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})},O=/\r\n?|\n|\u2028|\u2029/,V=new RegExp(O.source,"g"),F=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,D=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,j=function(t,e){this.line=t,this.column=e};j.prototype.offset=function(t){return new j(this.line,this.column+t)};var Y=function(t,e,r){this.start=e,this.end=r,null!==t.sourceFile&&(this.source=t.sourceFile)},B={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:{}},M={},U=function(t,e,r){this.options=t=h(t),this.sourceFile=t.sourceFile,this.keywords=l(k[t.ecmaVersion>=6?6:5]);var n="";if(!t.allowReserved){for(var i=t.ecmaVersion;!(n=b[i]);i--);"module"==t.sourceType&&(n+=" await")}this.reservedWords=l(n);var s=(n?n+" ":"")+b.strict;this.reservedWordsStrict=l(s),this.reservedWordsStrictBind=l(s+" "+b.strictBind),this.input=String(e),this.containsEsc=!1,this.loadPlugins(t.plugins),r?(this.pos=r,this.lineStart=this.input.lastIndexOf("\n",r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(O).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=I.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.strict=this.inModule="module"===t.sourceType,this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2)};U.prototype.isKeyword=function(t){return this.keywords.test(t)},U.prototype.isReservedWord=function(t){return this.reservedWords.test(t)},U.prototype.extend=function(t,e){this[t]=e(this[t])},U.prototype.loadPlugins=function(t){var e=this;for(var r in t){var n=M[r];if(!n)throw new Error("Plugin '"+r+"' not found");n(e,t[r])}},U.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};var q=U.prototype;q.isUseStrict=function(t){return this.options.ecmaVersion>=5&&"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"use strict"===t.expression.raw.slice(1,-1)},q.eat=function(t){return this.type===t&&(this.next(),!0)},q.isContextual=function(t){return this.type===I.name&&this.value===t},q.eatContextual=function(t){return this.value===t&&this.eat(I.name)},q.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},q.canInsertSemicolon=function(){return this.type===I.eof||this.type===I.braceR||O.test(this.input.slice(this.lastTokEnd,this.start))},q.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},q.semicolon=function(){this.eat(I.semi)||this.insertSemicolon()||this.unexpected()},q.afterTrailingComma=function(t,e){if(this.type==t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},q.expect=function(t){this.eat(t)||this.unexpected()},q.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")};var G=function(){this.shorthandAssign=0,this.trailingComma=0};q.checkPatternErrors=function(t,e){var r=t&&t.trailingComma;return e?void(r&&this.raise(r,"Comma is not permitted after the rest element")):!!r},q.checkExpressionErrors=function(t,e){var r=t&&t.shorthandAssign;return e?void(r&&this.raise(r,"Shorthand property assignments are valid only in destructuring patterns")):!!r},q.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(t.sourceType=this.options.sourceType),this.finishNode(t,"Program")};var W={kind:"loop"},H={kind:"switch"};z.isLet=function(){if(this.type!==I.name||this.options.ecmaVersion<6||"let"!=this.value)return!1;D.lastIndex=this.pos;var t=D.exec(this.input),e=this.pos+t[0].length,i=this.input.charCodeAt(e);if(91===i||123==i)return!0;if(r(i,!0)){for(var s=e+1;n(this.input.charCodeAt(s),!0);++s);var a=this.input.slice(e,s);if(!this.isKeyword(a))return!0}return!1},z.isAsyncFunction=function(){if(this.type!==I.name||this.options.ecmaVersion<8||"async"!=this.value)return!1;D.lastIndex=this.pos;var t=D.exec(this.input),e=this.pos+t[0].length;return!(O.test(this.input.slice(this.pos,e))||"function"!==this.input.slice(e,e+8)||e+8!=this.input.length&&n(this.input.charAt(e+8)))},z.parseStatement=function(t,e,r){var n,i=this.type,s=this.startNode();switch(this.isLet()&&(i=I._var,n="let"),i){case I._break:case I._continue:return this.parseBreakContinueStatement(s,i.keyword);case I._debugger:return this.parseDebuggerStatement(s);case I._do:return this.parseDoStatement(s);case I._for:return this.parseForStatement(s);case I._function:return!t&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1);case I._class:return t||this.unexpected(),this.parseClass(s,!0);case I._if:return this.parseIfStatement(s);case I._return:return this.parseReturnStatement(s);case I._switch:return this.parseSwitchStatement(s);case I._throw:return this.parseThrowStatement(s);case I._try:return this.parseTryStatement(s);case I._const:case I._var:return n=n||this.value,t||"var"==n||this.unexpected(),this.parseVarStatement(s,n);case I._while:return this.parseWhileStatement(s);case I._with:return this.parseWithStatement(s);case I.braceL:return this.parseBlock();case I.semi:return this.parseEmptyStatement(s);case I._export:case I._import:return this.options.allowImportExportEverywhere||(e||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===I._import?this.parseImport(s):this.parseExport(s,r);default:if(this.isAsyncFunction()&&t)return this.next(),this.parseFunctionStatement(s,!0);var a=this.value,o=this.parseExpression();return i===I.name&&"Identifier"===o.type&&this.eat(I.colon)?this.parseLabeledStatement(s,a,o):this.parseExpressionStatement(s,o)}},z.parseBreakContinueStatement=function(t,e){var r=this,n="break"==e;this.next(),this.eat(I.semi)||this.insertSemicolon()?t.label=null:this.type!==I.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var i=0;i=6?this.eat(I.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},z.parseForStatement=function(t){if(this.next(),this.labels.push(W),this.expect(I.parenL),this.type===I.semi)return this.parseFor(t,null);var e=this.isLet();if(this.type===I._var||this.type===I._const||e){var r=this.startNode(),n=e?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),!(this.type===I._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==r.declarations.length||"var"!==n&&r.declarations[0].init?this.parseFor(t,r):this.parseForIn(t,r)}var i=new G,s=this.parseExpression(!0,i);return this.type===I._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.checkPatternErrors(i,!0),this.toAssignable(s),this.checkLVal(s),this.parseForIn(t,s)):(this.checkExpressionErrors(i,!0),this.parseFor(t,s))},z.parseFunctionStatement=function(t,e){return this.next(),this.parseFunction(t,!0,!1,e)},z.isFunction=function(){return this.type===I._function||this.isAsyncFunction()},z.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(!this.strict&&this.isFunction()),t.alternate=this.eat(I._else)?this.parseStatement(!this.strict&&this.isFunction()):null,this.finishNode(t,"IfStatement")},z.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(I.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},z.parseSwitchStatement=function(t){var e=this;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(I.braceL),this.labels.push(H);for(var r,n=!1;this.type!=I.braceR;)if(e.type===I._case||e.type===I._default){var i=e.type===I._case;r&&e.finishNode(r,"SwitchCase"),t.cases.push(r=e.startNode()),r.consequent=[],e.next(),i?r.test=e.parseExpression():(n&&e.raiseRecoverable(e.lastTokStart,"Multiple default clauses"),n=!0,r.test=null),e.expect(I.colon)}else r||e.unexpected(),r.consequent.push(e.parseStatement(!0));return r&&this.finishNode(r,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},z.parseThrowStatement=function(t){return this.next(),O.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var $=[];z.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===I._catch){var e=this.startNode();this.next(),this.expect(I.parenL),e.param=this.parseBindingAtom(),this.checkLVal(e.param,!0),this.expect(I.parenR),e.body=this.parseBlock(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(I._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},z.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},z.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(W),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"WhileStatement")},z.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement(!1),this.finishNode(t,"WithStatement")},z.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},z.parseLabeledStatement=function(t,e,r){for(var n=this,i=0;i=0;a--){var o=n.labels[a];if(o.statementStart!=t.start)break;o.statementStart=n.start, 2 | o.kind=s}return this.labels.push({name:e,kind:s,statementStart:this.start}),t.body=this.parseStatement(!0),this.labels.pop(),t.label=r,this.finishNode(t,"LabeledStatement")},z.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},z.parseBlock=function(t){var e,r=this,n=this.startNode(),i=!0;for(n.body=[],this.expect(I.braceL);!this.eat(I.braceR);){var s=r.parseStatement(!0);n.body.push(s),i&&t&&r.isUseStrict(s)&&(e=r.strict,r.setStrict(r.strict=!0)),i=!1}return e===!1&&this.setStrict(!1),this.finishNode(n,"BlockStatement")},z.parseFor=function(t,e){return t.init=e,this.expect(I.semi),t.test=this.type===I.semi?null:this.parseExpression(),this.expect(I.semi),t.update=this.type===I.parenR?null:this.parseExpression(),this.expect(I.parenR),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"ForStatement")},z.parseForIn=function(t,e){var r=this.type===I._in?"ForInStatement":"ForOfStatement";return this.next(),t.left=e,t.right=this.parseExpression(),this.expect(I.parenR),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,r)},z.parseVar=function(t,e,r){var n=this;for(t.declarations=[],t.kind=r;;){var i=n.startNode();if(n.parseVarId(i),n.eat(I.eq)?i.init=n.parseMaybeAssign(e):"const"!==r||n.type===I._in||n.options.ecmaVersion>=6&&n.isContextual("of")?"Identifier"==i.id.type||e&&(n.type===I._in||n.isContextual("of"))?i.init=null:n.raise(n.lastTokEnd,"Complex binding patterns require an initialization value"):n.unexpected(),t.declarations.push(n.finishNode(i,"VariableDeclarator")),!n.eat(I.comma))break}return t},z.parseVarId=function(t){t.id=this.parseBindingAtom(),this.checkLVal(t.id,!0)},z.parseFunction=function(t,e,r,n){this.initFunction(t),this.options.ecmaVersion>=6&&!n&&(t.generator=this.eat(I.star)),this.options.ecmaVersion>=8&&(t.async=!!n),e&&(t.id=this.parseIdent());var i=this.inGenerator,s=this.inAsync,a=this.yieldPos,o=this.awaitPos;return this.inGenerator=t.generator,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,e||this.type!==I.name||(t.id=this.parseIdent()),this.parseFunctionParams(t),this.parseFunctionBody(t,r),this.inGenerator=i,this.inAsync=s,this.yieldPos=a,this.awaitPos=o,this.finishNode(t,e?"FunctionDeclaration":"FunctionExpression")},z.parseFunctionParams=function(t){this.expect(I.parenL),t.params=this.parseBindingList(I.parenR,!1,this.options.ecmaVersion>=8,!0),this.checkYieldAwaitInDefaultParams()},z.parseClass=function(t,e){var r=this;this.next(),this.parseClassId(t,e),this.parseClassSuper(t);var n=this.startNode(),i=!1;for(n.body=[],this.expect(I.braceL);!this.eat(I.braceR);)if(!r.eat(I.semi)){var s=r.startNode(),a=r.eat(I.star),o=!1,c=r.type===I.name&&"static"===r.value;r.parsePropertyName(s),s.static=c&&r.type!==I.parenL,s.static&&(a&&r.unexpected(),a=r.eat(I.star),r.parsePropertyName(s)),r.options.ecmaVersion>=8&&!a&&!s.computed&&"Identifier"===s.key.type&&"async"===s.key.name&&r.type!==I.parenL&&!r.canInsertSemicolon()&&(o=!0,r.parsePropertyName(s)),s.kind="method";var u=!1;if(!s.computed){var h=s.key;a||o||"Identifier"!==h.type||r.type===I.parenL||"get"!==h.name&&"set"!==h.name||(u=!0,s.kind=h.name,h=r.parsePropertyName(s)),!s.static&&("Identifier"===h.type&&"constructor"===h.name||"Literal"===h.type&&"constructor"===h.value)&&(i&&r.raise(h.start,"Duplicate constructor in the same class"),u&&r.raise(h.start,"Constructor can't have get/set modifier"),a&&r.raise(h.start,"Constructor can't be a generator"),o&&r.raise(h.start,"Constructor can't be an async method"),s.kind="constructor",i=!0)}if(r.parseClassMethod(n,s,a,o),u){var p="get"===s.kind?0:1;if(s.value.params.length!==p){var l=s.value.start;"get"===s.kind?r.raiseRecoverable(l,"getter should have no params"):r.raiseRecoverable(l,"setter should have exactly one param")}else"set"===s.kind&&"RestElement"===s.value.params[0].type&&r.raiseRecoverable(s.value.params[0].start,"Setter cannot use rest params")}}return t.body=this.finishNode(n,"ClassBody"),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},z.parseClassMethod=function(t,e,r,n){e.value=this.parseMethod(r,n),t.body.push(this.finishNode(e,"MethodDefinition"))},z.parseClassId=function(t,e){t.id=this.type===I.name?this.parseIdent():e?this.unexpected():null},z.parseClassSuper=function(t){t.superClass=this.eat(I._extends)?this.parseExprSubscripts():null},z.parseExport=function(t,e){var r=this;if(this.next(),this.eat(I.star))return this.expectContextual("from"),t.source=this.type===I.string?this.parseExprAtom():this.unexpected(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(I._default)){this.checkExport(e,"default",this.lastTokStart);var n=this.type==I.parenL,i=this.parseMaybeAssign(),s=!0;return n||"FunctionExpression"!=i.type&&"ClassExpression"!=i.type||(s=!1,i.id&&(i.type="FunctionExpression"==i.type?"FunctionDeclaration":"ClassDeclaration")),t.declaration=i,s&&this.semicolon(),this.finishNode(t,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())t.declaration=this.parseStatement(!0),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id.name,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))t.source=this.type===I.string?this.parseExprAtom():this.unexpected();else{for(var a=0;a=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":break;case"ObjectExpression":t.type="ObjectPattern";for(var n=0;n=8&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(I._function))return this.parseFunction(this.startNodeAt(i,s),!1,!1,!0);if(r&&!this.canInsertSemicolon()){if(this.eat(I.arrow))return this.parseArrowExpression(this.startNodeAt(i,s),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===I.name)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(I.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(i,s),[a],!0)}return a;case I.regexp:var o=this.value;return e=this.parseLiteral(o.value),e.regex={pattern:o.pattern,flags:o.flags},e;case I.num:case I.string:return this.parseLiteral(this.value);case I._null:case I._true:case I._false:return e=this.startNode(),e.value=this.type===I._null?null:this.type===I._true,e.raw=this.type.keyword,this.next(),this.finishNode(e,"Literal");case I.parenL:return this.parseParenAndDistinguishExpression(r);case I.bracketL:return e=this.startNode(),this.next(),e.elements=this.parseExprList(I.bracketR,!0,!0,t),this.finishNode(e,"ArrayExpression");case I.braceL:return this.parseObj(!1,t);case I._function:return e=this.startNode(),this.next(),this.parseFunction(e,!1);case I._class:return this.parseClass(this.startNode(),!1);case I._new:return this.parseNew();case I.backQuote:return this.parseTemplate();default:this.unexpected()}},Q.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(e,"Literal")},Q.parseParenExpression=function(){this.expect(I.parenL);var t=this.parseExpression();return this.expect(I.parenR),t},Q.parseParenAndDistinguishExpression=function(t){var e,r=this,n=this.start,i=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o,c=this.start,u=this.startLoc,h=[],p=!0,l=!1,f=new G,d=this.yieldPos,m=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==I.parenR;){if(p?p=!1:r.expect(I.comma),s&&r.afterTrailingComma(I.parenR,!0)){l=!0;break}if(r.type===I.ellipsis){a=r.start,h.push(r.parseParenItem(r.parseRest())),r.type===I.comma&&r.raise(r.start,"Comma is not permitted after the rest element");break}r.type!==I.parenL||o||(o=r.start),h.push(r.parseMaybeAssign(!1,f,r.parseParenItem))}var g=this.start,y=this.startLoc;if(this.expect(I.parenR),t&&!this.canInsertSemicolon()&&this.eat(I.arrow))return this.checkPatternErrors(f,!0),this.checkYieldAwaitInDefaultParams(),o&&this.unexpected(o),this.yieldPos=d,this.awaitPos=m,this.parseParenArrowList(n,i,h);h.length&&!l||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(f,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=m||this.awaitPos,h.length>1?(e=this.startNodeAt(c,u),e.expressions=h,this.finishNodeAt(e,"SequenceExpression",g,y)):e=h[0]}else e=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(n,i);return v.expression=e,this.finishNode(v,"ParenthesizedExpression")}return e},Q.parseParenItem=function(t){return t},Q.parseParenArrowList=function(t,e,r){return this.parseArrowExpression(this.startNodeAt(t,e),r)};var K=[];Q.parseNew=function(){var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(I.dot))return t.meta=e,t.property=this.parseIdent(!0),"target"!==t.property.name&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(t.start,"new.target can only be used in functions"),this.finishNode(t,"MetaProperty");var r=this.start,n=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(),r,n,!0),this.eat(I.parenL)?t.arguments=this.parseExprList(I.parenR,this.options.ecmaVersion>=8,!1):t.arguments=K,this.finishNode(t,"NewExpression")},Q.parseTemplateElement=function(){var t=this.startNode();return t.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),t.tail=this.type===I.backQuote,this.finishNode(t,"TemplateElement")},Q.parseTemplate=function(){var t=this,e=this.startNode();this.next(),e.expressions=[];var r=this.parseTemplateElement();for(e.quasis=[r];!r.tail;)t.expect(I.dollarBraceL),e.expressions.push(t.parseExpression()),t.expect(I.braceR),e.quasis.push(r=t.parseTemplateElement());return this.next(),this.finishNode(e,"TemplateLiteral")},Q.parseObj=function(t,e){var r=this,n=this.startNode(),i=!0,s={};for(n.properties=[],this.next();!this.eat(I.braceR);){if(i)i=!1;else if(r.expect(I.comma),r.afterTrailingComma(I.braceR))break;var a,o,c,u,h=r.startNode();r.options.ecmaVersion>=6&&(h.method=!1,h.shorthand=!1,(t||e)&&(c=r.start,u=r.startLoc),t||(a=r.eat(I.star))),r.parsePropertyName(h),t||!(r.options.ecmaVersion>=8)||a||h.computed||"Identifier"!==h.key.type||"async"!==h.key.name||r.type===I.parenL||r.type===I.colon||r.canInsertSemicolon()?o=!1:(o=!0,r.parsePropertyName(h,e)),r.parsePropertyValue(h,t,a,o,c,u,e),r.checkPropClash(h,s),n.properties.push(r.finishNode(h,"Property"))}return this.finishNode(n,t?"ObjectPattern":"ObjectExpression")},Q.parsePropertyValue=function(t,e,r,n,i,s,a){if((r||n)&&this.type===I.colon&&this.unexpected(),this.eat(I.colon))t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init";else if(this.options.ecmaVersion>=6&&this.type===I.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(r,n);else if(this.options.ecmaVersion>=5&&!t.computed&&"Identifier"===t.key.type&&("get"===t.key.name||"set"===t.key.name)&&this.type!=I.comma&&this.type!=I.braceR){(r||n||e)&&this.unexpected(),t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var o="get"===t.kind?0:1;if(t.value.params.length!==o){var c=t.value.start;"get"===t.kind?this.raiseRecoverable(c,"getter should have no params"):this.raiseRecoverable(c,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}else this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?((this.keywords.test(t.key.name)||(this.strict?this.reservedWordsStrict:this.reservedWords).test(t.key.name)||this.inGenerator&&"yield"==t.key.name||this.inAsync&&"await"==t.key.name)&&this.raiseRecoverable(t.key.start,"'"+t.key.name+"' can not be used as shorthand property"),t.kind="init",e?t.value=this.parseMaybeDefault(i,s,t.key):this.type===I.eq&&a?(a.shorthandAssign||(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(i,s,t.key)):t.value=t.key,t.shorthand=!0):this.unexpected()},Q.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(I.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(I.bracketR),t.key;t.computed=!1}return t.key=this.type===I.num||this.type===I.string?this.parseExprAtom():this.parseIdent(!0)},Q.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=!1,t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},Q.parseMethod=function(t,e){var r=this.startNode(),n=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=t),this.options.ecmaVersion>=8&&(r.async=!!e),this.inGenerator=r.generator,this.inAsync=r.async,this.yieldPos=0,this.awaitPos=0,this.expect(I.parenL),r.params=this.parseBindingList(I.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1),this.inGenerator=n,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.finishNode(r,"FunctionExpression")},Q.parseArrowExpression=function(t,e,r){var n=this.inGenerator,i=this.inAsync,s=this.yieldPos,a=this.awaitPos;return this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!r),this.inGenerator=!1,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0),this.inGenerator=n,this.inAsync=i,this.yieldPos=s,this.awaitPos=a,this.finishNode(t,"ArrowFunctionExpression")},Q.parseFunctionBody=function(t,e){var r=e&&this.type!==I.braceL;if(r)t.body=this.parseMaybeAssign(),t.expression=!0;else{var n=this.inFunction,i=this.labels;this.inFunction=!0,this.labels=[],t.body=this.parseBlock(!0),t.expression=!1,this.inFunction=n,this.labels=i}var s=!r&&t.body.body.length&&this.isUseStrict(t.body.body[0])?t.body.body[0]:null;if(s&&this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params)&&this.raiseRecoverable(s.start,"Illegal 'use strict' directive in function with non-simple parameter list"),this.strict||s){var a=this.strict;this.strict=!0,t.id&&this.checkLVal(t.id,!0),this.checkParams(t),this.strict=a}else!e&&this.isSimpleParamList(t.params)||this.checkParams(t)},Q.isSimpleParamList=function(t){for(var e=0;e=6||this.input.slice(this.start,this.end).indexOf("\\")==-1)&&this.raiseRecoverable(this.start,"The keyword '"+this.value+"' is reserved"),this.inGenerator&&"yield"===this.value&&this.raiseRecoverable(this.start,"Can not use 'yield' as identifier inside a generator"),this.inAsync&&"await"===this.value&&this.raiseRecoverable(this.start,"Can not use 'await' as identifier inside an async function"),e.name=this.value):t&&this.type.keyword?e.name=this.type.keyword:this.unexpected(),this.next(),this.finishNode(e,"Identifier")},Q.parseYield=function(){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type==I.semi||this.canInsertSemicolon()||this.type!=I.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(I.star),t.argument=this.parseMaybeAssign()),this.finishNode(t,"YieldExpression")},Q.parseAwait=function(){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0),this.finishNode(t,"AwaitExpression")};var X=U.prototype;X.raise=function(t,e){var r=u(this.input,t);e+=" ("+r.line+":"+r.column+")";var n=new SyntaxError(e);throw n.pos=t,n.loc=r,n.raisedAt=this.pos,n},X.raiseRecoverable=X.raise,X.curPosition=function(){if(this.options.locations)return new j(this.curLine,this.pos-this.lineStart)};var Z=function(t,e,r){this.type="",this.start=e,this.end=0,t.options.locations&&(this.loc=new Y(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[e,0])},tt=U.prototype;tt.startNode=function(){return new Z(this,this.start,this.startLoc)},tt.startNodeAt=function(t,e){return new Z(this,t,e)},tt.finishNode=function(t,e){return f.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)},tt.finishNodeAt=function(t,e,r,n){return f.call(this,t,e,r,n)};var et=function(t,e,r,n){this.token=t,this.isExpr=!!e,this.preserveSpace=!!r,this.override=n},rt={b_stat:new et("{",!1),b_expr:new et("{",!0),b_tmpl:new et("${",!0),p_stat:new et("(",!1),p_expr:new et("(",!0),q_tmpl:new et("`",!0,!0,function(t){return t.readTmplToken()}),f_expr:new et("function",!0)},nt=U.prototype;nt.initialContext=function(){return[rt.b_stat]},nt.braceIsBlock=function(t){if(t===I.colon){var e=this.curContext();if(e===rt.b_stat||e===rt.b_expr)return!e.isExpr}return t===I._return?O.test(this.input.slice(this.lastTokEnd,this.start)):t===I._else||t===I.semi||t===I.eof||t===I.parenR||(t==I.braceL?this.curContext()===rt.b_stat:!this.exprAllowed)},nt.updateContext=function(t){var e,r=this.type;r.keyword&&t==I.dot?this.exprAllowed=!1:(e=r.updateContext)?e.call(this,t):this.exprAllowed=r.beforeExpr},I.parenR.updateContext=I.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var t=this.context.pop();t===rt.b_stat&&this.curContext()===rt.f_expr?(this.context.pop(),this.exprAllowed=!1):t===rt.b_tmpl?this.exprAllowed=!0:this.exprAllowed=!t.isExpr},I.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?rt.b_stat:rt.b_expr),this.exprAllowed=!0},I.dollarBraceL.updateContext=function(){this.context.push(rt.b_tmpl),this.exprAllowed=!0},I.parenL.updateContext=function(t){var e=t===I._if||t===I._for||t===I._with||t===I._while;this.context.push(e?rt.p_stat:rt.p_expr),this.exprAllowed=!0},I.incDec.updateContext=function(){},I._function.updateContext=function(t){t.beforeExpr&&t!==I.semi&&t!==I._else&&(t!==I.colon&&t!==I.braceL||this.curContext()!==rt.b_stat)&&this.context.push(rt.f_expr),this.exprAllowed=!1},I.backQuote.updateContext=function(){this.curContext()===rt.q_tmpl?this.context.pop():this.context.push(rt.q_tmpl),this.exprAllowed=!1};var it=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new Y(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},st=U.prototype,at="object"==typeof Packages&&"[object JavaPackage]"==Object.prototype.toString.call(Packages);st.next=function(){this.options.onToken&&this.options.onToken(new it(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},st.getToken=function(){return this.next(),new it(this)},"undefined"!=typeof Symbol&&(st[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===I.eof,value:e}}}}),st.setStrict=function(t){var e=this;if(this.strict=t,this.type===I.num||this.type===I.string){if(this.pos=this.start,this.options.locations)for(;this.pos=this.input.length?this.finishToken(I.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},st.readToken=function(t){return r(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},st.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos); 3 | if(t<=55295||t>=57344)return t;var e=this.input.charCodeAt(this.pos+1);return(t<<10)+e-56613888},st.skipBlockComment=function(){var t=this,e=this.options.onComment&&this.curPosition(),r=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations){V.lastIndex=r;for(var i;(i=V.exec(this.input))&&i.index8&&e<14||e>=5760&&F.test(String.fromCharCode(e))))break t;++t.pos}}},st.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var r=this.type;this.type=t,this.value=e,this.updateContext(r)},st.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(I.ellipsis)):(++this.pos,this.finishToken(I.dot))},st.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(I.assign,2):this.finishOp(I.slash,1)},st.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),r=1,n=42===t?I.star:I.modulo;return this.options.ecmaVersion>=7&&42===e&&(++r,n=I.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(I.assign,r+1):this.finishOp(n,r)},st.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?this.finishOp(124===t?I.logicalOR:I.logicalAND,2):61===e?this.finishOp(I.assign,2):this.finishOp(124===t?I.bitwiseOR:I.bitwiseAND,1)},st.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(I.assign,2):this.finishOp(I.bitwiseXOR,1)},st.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45==e&&62==this.input.charCodeAt(this.pos+2)&&O.test(this.input.slice(this.lastTokEnd,this.pos))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(I.incDec,2):61===e?this.finishOp(I.assign,2):this.finishOp(I.plusMin,1)},st.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),r=1;return e===t?(r=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+r)?this.finishOp(I.assign,r+1):this.finishOp(I.bitShift,r)):33==e&&60==t&&45==this.input.charCodeAt(this.pos+2)&&45==this.input.charCodeAt(this.pos+3)?(this.inModule&&this.unexpected(),this.skipLineComment(4),this.skipSpace(),this.nextToken()):(61===e&&(r=2),this.finishOp(I.relational,r))},st.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(I.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(I.arrow)):this.finishOp(61===t?I.eq:I.prefix,1)},st.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(I.parenL);case 41:return++this.pos,this.finishToken(I.parenR);case 59:return++this.pos,this.finishToken(I.semi);case 44:return++this.pos,this.finishToken(I.comma);case 91:return++this.pos,this.finishToken(I.bracketL);case 93:return++this.pos,this.finishToken(I.bracketR);case 123:return++this.pos,this.finishToken(I.braceL);case 125:return++this.pos,this.finishToken(I.braceR);case 58:return++this.pos,this.finishToken(I.colon);case 63:return++this.pos,this.finishToken(I.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(I.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)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(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 126:return this.finishOp(I.prefix,1)}this.raise(this.pos,"Unexpected character '"+m(t)+"'")},st.finishOp=function(t,e){var r=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,r)};var ot=!!d("￿","u");st.readRegexp=function(){for(var t,e,r=this,n=this.pos;;){r.pos>=r.input.length&&r.raise(n,"Unterminated regular expression");var i=r.input.charAt(r.pos);if(O.test(i)&&r.raise(n,"Unterminated regular expression"),t)t=!1;else{if("["===i)e=!0;else if("]"===i&&e)e=!1;else if("/"===i&&!e)break;t="\\"===i}++r.pos}var s=this.input.slice(n,this.pos);++this.pos;var a=this.readWord1(),o=s,c="";if(a){var u=/^[gim]*$/;this.options.ecmaVersion>=6&&(u=/^[gimuy]*$/),u.test(a)||this.raise(n,"Invalid regular expression flag"),a.indexOf("u")>=0&&(ot?c="u":(o=o.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(t,e,i){return e=Number("0x"+e),e>1114111&&r.raise(n+i+3,"Code point out of bounds"),"x"}),o=o.replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"),c=c.replace("u","")))}var h=null;return at||(d(o,c,n,this),h=d(s,a)),this.finishToken(I.regexp,{pattern:s,flags:a,value:h})},st.readInt=function(t,e){for(var r=this,n=this.pos,i=0,s=0,a=null==e?1/0:e;s=97?c-97+10:c>=65?c-65+10:c>=48&&c<=57?c-48:1/0,o>=t)break;++r.pos,i=i*t+o}return this.pos===n||null!=e&&this.pos-n!==e?null:i},st.readRadixNumber=function(t){this.pos+=2;var e=this.readInt(t);return null==e&&this.raise(this.start+2,"Expected number in radix "+t),r(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(I.num,e)},st.readNumber=function(t){var e=this.pos,n=!1,i=48===this.input.charCodeAt(this.pos);t||null!==this.readInt(10)||this.raise(e,"Invalid number"),i&&this.pos==e+1&&(i=!1);var s=this.input.charCodeAt(this.pos);46!==s||i||(++this.pos,this.readInt(10),n=!0,s=this.input.charCodeAt(this.pos)),69!==s&&101!==s||i||(s=this.input.charCodeAt(++this.pos),43!==s&&45!==s||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number"),n=!0),r(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a,o=this.input.slice(e,this.pos);return n?a=parseFloat(o):i&&1!==o.length?/[89]/.test(o)||this.strict?this.raise(e,"Invalid number"):a=parseInt(o,8):a=parseInt(o,10),this.finishToken(I.num,a)},st.readCodePoint=function(){var t,e=this.input.charCodeAt(this.pos);if(123===e){this.options.ecmaVersion<6&&this.unexpected();var r=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.raise(r,"Code point out of bounds")}else t=this.readHexChar(4);return t},st.readString=function(t){for(var e=this,r="",n=++this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated string constant");var i=e.input.charCodeAt(e.pos);if(i===t)break;92===i?(r+=e.input.slice(n,e.pos),r+=e.readEscapedChar(!1),n=e.pos):(a(i)&&e.raise(e.start,"Unterminated string constant"),++e.pos)}return r+=this.input.slice(n,this.pos++),this.finishToken(I.string,r)},st.readTmplToken=function(){for(var t=this,e="",r=this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated template");var n=t.input.charCodeAt(t.pos);if(96===n||36===n&&123===t.input.charCodeAt(t.pos+1))return t.pos===t.start&&t.type===I.template?36===n?(t.pos+=2,t.finishToken(I.dollarBraceL)):(++t.pos,t.finishToken(I.backQuote)):(e+=t.input.slice(r,t.pos),t.finishToken(I.template,e));if(92===n)e+=t.input.slice(r,t.pos),e+=t.readEscapedChar(!0),r=t.pos;else if(a(n)){switch(e+=t.input.slice(r,t.pos),++t.pos,n){case 13:10===t.input.charCodeAt(t.pos)&&++t.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(n)}t.options.locations&&(++t.curLine,t.lineStart=t.pos),r=t.pos}else++t.pos}},st.readEscapedChar=function(t){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return m(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";default:if(e>=48&&e<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],n=parseInt(r,8);return n>255&&(r=r.slice(0,-1),n=parseInt(r,8)),"0"!==r&&(this.strict||t)&&this.raise(this.pos-2,"Octal literal in strict mode"),this.pos+=r.length-1,String.fromCharCode(n)}return String.fromCharCode(e)}},st.readHexChar=function(t){var e=this.pos,r=this.readInt(16,t);return null===r&&this.raise(e,"Bad character escape sequence"),r},st.readWord1=function(){var t=this;this.containsEsc=!1;for(var e="",i=!0,s=this.pos,a=this.options.ecmaVersion>=6;this.pos=6||!this.containsEsc)&&this.keywords.test(t)&&(e=T[t]),this.finishToken(e,t)};var ct="4.0.4";t.version=ct,t.parse=g,t.parseExpressionAt=y,t.tokenizer=v,t.addLooseExports=x,t.Parser=U,t.plugins=M,t.defaultOptions=B,t.Position=j,t.SourceLocation=Y,t.getLineInfo=u,t.Node=Z,t.TokenType=R,t.tokTypes=I,t.TokContext=et,t.tokContexts=rt,t.isIdentifierChar=n,t.isIdentifierStart=r,t.Token=it,t.isNewLine=a,t.lineBreak=O,t.lineBreakG=V,Object.defineProperty(t,"__esModule",{value:!0})})},{}],evaljs:[function(t,e,r){(function(n,i){function s(){}function a(t){var e=t();if(""+e=="null")return e;if(void 0!==e&&e.next){for(var r=e,n=r.next();!n.done;)n=r.next();return""+n.value=="null"?n.value:""+n.value=="undefined"?n.value:n.value}return e}function o(){}function c(t){this.value=t}function u(t){d.call(this),Array.isArray(t)||(t=[t]);var e;t.forEach(function(t){e=h(e,t)}),this._curVarStore=e,this._curDeclarations={},this._globalObj=t[0],this._curThis=this._globalObj,this._boundGen=this._gen.bind(this),this.DEBUG=!1,this.DELAY=0,this.STATE="running"}function h(t,e){return e=e||{},{parent:t,vars:e}}function p(t,e){for(var r in t)t.hasOwnProperty(r)&&!e.vars.hasOwnProperty(r)&&(e.vars[r]=t[r]())}!function(t){"use strict";function r(t,e,r,n){var i=e&&e.prototype instanceof s?e:s,a=Object.create(i.prototype),o=new f(n||[]);return a._invoke=h(t,r,o),a}function i(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function s(){}function a(){}function o(){}function c(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function u(t){function e(r,n,s,a){var o=i(t[r],t,n);if("throw"!==o.type){var c=o.arg,u=c.value;return u&&"object"==typeof u&&v.call(u,"__await")?Promise.resolve(u.__await).then(function(t){e("next",t,s,a)},function(t){e("throw",t,s,a)}):Promise.resolve(u).then(function(t){c.value=t,s(c)},a)}a(o.arg)}function r(t,r){function n(){return new Promise(function(n,i){e(t,r,n,i)})}return s=s?s.then(n,n):n()}"object"==typeof n&&n.domain&&(e=n.domain.bind(e));var s;this._invoke=r}function h(t,e,r){var n=E;return function(s,a){if(n===A)throw new Error("Generator is already running");if(n===L){if("throw"===s)throw a;return m()}for(;;){var o=r.delegate;if(o){if("return"===s||"throw"===s&&o.iterator[s]===g){r.delegate=null;var c=o.iterator.return;if(c){var u=i(c,o.iterator,a);if("throw"===u.type){s="throw",a=u.arg;continue}}if("return"===s)continue}var u=i(o.iterator[s],o.iterator,a);if("throw"===u.type){r.delegate=null,s="throw",a=u.arg;continue}s="next",a=g;var h=u.arg;if(!h.done)return n=S,h;r[o.resultName]=h.value,r.next=o.nextLoc,r.delegate=null}if("next"===s)r.sent=r._sent=a;else if("throw"===s){if(n===E)throw n=L,a;r.dispatchException(a)&&(s="next",a=g)}else"return"===s&&r.abrupt("return",a);n=A;var u=i(t,e,r);if("normal"===u.type){n=r.done?L:S;var h={value:u.arg,done:r.done};if(u.arg!==C)return h;r.delegate&&"next"===s&&(a=g)}else"throw"===u.type&&(n=L,s="throw",a=u.arg)}}}function p(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function l(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function f(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(p,this),this.reset(!0)}function d(t){if(t){var e=t[b];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r=0;--n){var i=this.tryEntries[n],s=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var a=v.call(i,"catchLoc"),o=v.call(i,"finallyLoc");if(a&&o){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&v.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),l(r),C}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;l(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:d(t),resultName:e,nextLoc:r},C}}}("object"==typeof i?i:"object"==typeof window?window:"object"==typeof self?self:this);var l=t("acorn").parse,f=t("util"),d=t("events").EventEmitter;o.prototype.toString=function(){return"[object Arguments]"};var m={},g={};f.inherits(u,d),u.prototype.gen=function(t){var e={locations:!0};"string"==typeof t&&(t=l(t,e));var r=this._gen(t);return p(this._curDeclarations,this._curVarStore),this._curDeclarations={},r},u.prototype._gen=function(t){var e=({BinaryExpression:this._genBinExpr,LogicalExpression:this._genBinExpr,UnaryExpression:this._genUnaryExpr,UpdateExpression:this._genUpdExpr,ObjectExpression:this._genObjExpr,ArrayExpression:this._genArrExpr,CallExpression:this._genCallExpr,NewExpression:this._genNewExpr,MemberExpression:this._genMemExpr,ThisExpression:this._genThisExpr,SequenceExpression:this._genSeqExpr,Literal:this._genLit,Identifier:this._genIdent,AssignmentExpression:this._genAssignExpr,FunctionDeclaration:this._genFuncDecl,VariableDeclaration:this._genVarDecl,BlockStatement:this._genProgram,Program:this._genProgram,ExpressionStatement:this._genExprStmt,EmptyStatement:this._genEmptyStmt,ReturnStatement:this._genRetStmt,FunctionExpression:this._genFuncExpr,IfStatement:this._genIfStmt,ConditionalExpression:this._genCondStmt,ForStatement:this._genLoopStmt,WhileStatement:this._genLoopStmt,DoWhileStatement:this._genDoWhileStmt,ForInStatement:this._genForInStmt,WithStatement:this._genWithStmt,ThrowStatement:this._genThrowStmt,TryStatement:this._genTryStmt,ContinueStatement:this._genContStmt,BreakStatement:this._genBreakStmt,SwitchStatement:this._genSwitchStmt}[t.type]||function(){return console.warn("Not implemented yet: "+t.type),s}).call(this,t);return this.DEBUG?function(){var r="closure for "+t.type+" called",n=((t.loc||{}).start||{}).line;n&&(r+=" while processing line "+n);var i=e();return r+=". Result:",console.log(r,i),i}:e},u.prototype._genBinExpr=function(t){function e(t){var e;return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("GeneratorFunction"!=t.constructor.name){r.next=5;break}return r.delegateYield(t(),"t0",2);case 2:e=r.t0,r.next=6;break;case 5:e=t();case 6:return r.abrupt("return",e);case 7:case"end":return r.stop()}},r[0],this)}var r=[e].map(regeneratorRuntime.mark),n=this._gen(t.left),i=this._gen(t.right),s={"==":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1==t.t3);case 5:case"end":return t.stop()}},t,this)}),"!=":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1!=t.t3);case 5:case"end":return t.stop()}},t,this)}),"===":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1===t.t3);case 5:case"end":return t.stop()}},t,this)}),"!==":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1!==t.t3);case 5:case"end":return t.stop()}},t,this)}),"<":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1>t.t3);case 5:case"end":return t.stop()}},t,this)}),">=":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1>=t.t3);case 5:case"end":return t.stop()}},t,this)}),"<<":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1<>":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1>>t.t3);case 5:case"end":return t.stop()}},t,this)}),">>>":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1>>>t.t3);case 5:case"end":return t.stop()}},t,this)}),"+":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1+t.t3);case 5:case"end":return t.stop()}},t,this)}),"-":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1-t.t3);case 5:case"end":return t.stop()}},t,this)}),"*":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1*t.t3);case 5:case"end":return t.stop()}},t,this)}),"/":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1/t.t3);case 5:case"end":return t.stop()}},t,this)}),"%":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1%t.t3);case 5:case"end":return t.stop()}},t,this)}),"|":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1|t.t3);case 5:case"end":return t.stop()}},t,this)}),"^":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1^t.t3);case 5:case"end":return t.stop()}},t,this)}),"&":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1&t.t3);case 5:case"end":return t.stop()}},t,this)}),in:regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1 in t.t3);case 5:case"end":return t.stop()}},t,this)}),instanceof:regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t0",1);case 1:return t.t1=t.t0,t.delegateYield(e(i),"t2",3);case 3:return t.t3=t.t2,t.abrupt("return",t.t1 instanceof t.t3);case 5:case"end":return t.stop()}},t,this)}),"||":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t1",1);case 1:if(t.t0=t.t1,t.t0){t.next=5;break}return t.delegateYield(e(i),"t2",4);case 4:t.t0=t.t2;case 5:return t.abrupt("return",t.t0);case 6:case"end":return t.stop()}},t,this)}),"&&":regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(e(n),"t1",1);case 1:if(t.t0=t.t1,!t.t0){t.next=5;break}return t.delegateYield(e(i),"t2",4);case 4:t.t0=t.t2;case 5:return t.abrupt("return",t.t0);case 6:case"end":return t.stop()}},t,this)})}[t.operator];return function(){for(var t=s(),e=t.next();!e.done;)e=t.next();return e.value}},u.prototype._genUnaryExpr=function(t){if("delete"===t.operator)return this._genDelete(t);var e=this._gen(t.argument),r={"-":function(){return-e()},"+":function(){return+e()},"!":function(){return!e()},"~":function(){return~e()},typeof:function(){return typeof e()},void:function(){return void e()}}[t.operator];return function(){return r()}},u.prototype._genDelete=function(t){var e=this._genObj(t.argument),r=this._genName(t.argument);return function(){return delete e()[r()]}},u.prototype._genObjExpr=function(t){var e=this,r=[];return t.properties.forEach(function(t){var n=e._objKey(t.key)();r.push({key:n,getVal:e._gen(t.value)})}),function(){var t={};return r.forEach(function(e){t[e.key]=e.getVal()}),t}},u.prototype._genArrExpr=function(t){var e=t.elements.map(this._boundGen);return function(){return e.map(a)}},u.prototype._objKey=function(t){var e;return e="Identifier"===t.type?t.name:this._gen(t)(),function(){return e}},u.prototype._genCallExpr=function(t){var e,r=this;if("MemberExpression"===t.callee.type){var n=r._genObj(t.callee),i=r._genName(t.callee);e=function(){var t=n();return t[i()].bind(t)}}else e=r._gen(t.callee);var s=t.arguments.map(r._gen.bind(r));return regeneratorRuntime.mark(function n(){var i,o,c;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(r.emit("line",t.loc.start.line),i=e(),void 0!==i){n.next=4;break}return n.abrupt("return",i);case 4:if(!i.next){n.next=10;break}return n.delegateYield(i,"t0",6);case 6:c=n.t0,o=c.apply(r._globalObj,s.map(a)),n.next=11;break;case 10:o=i.apply(r._globalObj,s.map(a));case 11:if(void 0===o){n.next=16;break}if(!o.next){n.next=16;break}return n.delegateYield(o,"t1",14);case 14:return c=n.t1,n.abrupt("return",c);case 16:return n.abrupt("return",o);case 17:case"end":return n.stop()}},n,this)})},u.prototype._genNewExpr=function(t){var e=this._gen(t.callee),r=t.arguments.map(this._boundGen),n=this;return regeneratorRuntime.mark(function i(){var s,o,c,u;return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return n.emit("line",t.loc.start.line),s=e(),o=r.map(a),c=Object.create(s.prototype),u=s.apply(c,o),i.delegateYield(u,"t0",6);case 6:return i.abrupt("return",c);case 7:case"end":return i.stop()}},i,this)})},u.prototype._genMemExpr=function(t){var e=this,r=this._gen(t.object),n=this._memExprProperty(t);return function(){return e.emit("line",t.loc.start.line),r()[n()]}},u.prototype._memExprProperty=function(t){return t.computed?this._gen(t.property):this._objKey(t.property)},u.prototype._genThisExpr=function(){var t=this;return function(){return t._curThis}},u.prototype._genSeqExpr=function(t){var e=t.expressions.map(this._boundGen);return function(){var t;return e.forEach(function(e){t=e()}),t}},u.prototype._genUpdExpr=function(t){var e=this,r={"--true":function(t,e){return--t[e]},"--false":function(t,e){return t[e]--},"++true":function(t,e){return++t[e]},"++false":function(t,e){return t[e]++}}[t.operator+t.prefix],n=this._genObj(t.argument),i=this._genName(t.argument);return regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return e.emit("line",t.loc.start.line),void(s.next=3);case 3:return s.abrupt("return",r(n(),i()));case 4:case"end":return s.stop()}},s,this)})},u.prototype._genObj=function(t){return"Identifier"===t.type?this._getVarStore.bind(this,t.name):"MemberExpression"===t.type?this._gen(t.object):(console.warn("Unknown _genObj() type: "+t.type),s)},u.prototype._genName=function(t){return"Identifier"===t.type?function(){return t.name}:"MemberExpression"===t.type?this._memExprProperty(t):(console.warn("Unknown _genName() type: "+t.type),s)},u.prototype._genLit=function(t){return function(){return t.value}},u.prototype._genIdent=function(t){var e=this;return function(){return e._getVarStore(t.name)[t.name]}},u.prototype._getVarStore=function(t){var e=this._curVarStore;do if(e.vars.hasOwnProperty(t))return e.vars;while(e=e.parent);return this._globalObj},u.prototype._genAssignExpr=function(t){var e=this,r={"=":function(t,e,r){return t[e]=r},"+=":function(t,e,r){return t[e]+=r},"-=":function(t,e,r){return t[e]-=r},"*=":function(t,e,r){return t[e]*=r},"/=":function(t,e,r){return t[e]/=r},"%=":function(t,e,r){return t[e]%=r},"<<=":function(t,e,r){return t[e]<<=r},">>=":function(t,e,r){return t[e]>>=r},">>>=":function(t,e,r){return t[e]>>>=r},"|=":function(t,e,r){return t[e]|=r},"^=":function(t,e,r){return t[e]^=r},"&=":function(t,e,r){return t[e]&=r}}[t.operator],n=this._genObj(t.left),i=this._genName(t.left),s=this._gen(t.right);return regeneratorRuntime.mark(function a(){var o;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.emit("line",t.left.loc.start.line),o=s(),void 0===o){a.next=6;break}if(!o.next){a.next=6;break}return a.delegateYield(o,"t0",5);case 5:o=a.t0;case 6:return a.abrupt("return",r(n(),i(),o));case 7:case"end":return a.stop()}},a,this)})},u.prototype._genFuncDecl=function(t){return this._curDeclarations[t.id.name]=this._genFuncExpr(t),regeneratorRuntime.mark(function t(){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",s); 4 | case 1:case"end":return t.stop()}},t,this)})},u.prototype._genVarDecl=function(t){for(var e=[],r=0;r