UNPKG

yzhanjsinterpreter

Version:

A JavaScript Interpreter Using JS itself. JavaScript 解释器,包含词法分析、语法解析和执行

1 lines 32.6 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.yzhanJSInterpreter=t():e.yzhanJSInterpreter=t()}(this,(function(){return e={449:function(e){e.exports=function e(){"use strict";var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"normal",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.type=t,this.value=n}},543:function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(){"use strict";function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.vars=new Map,this.parent=t}var n,r;return n=e,(r=[{key:"declare",value:function(e){this.vars.set(e,void 0)}},{key:"set",value:function(e,t){this.vars.has(e)||!this.parent?this.vars.set(e,t):this.parent.set(e,t)}},{key:"get",value:function(e){return this.vars.has(e)||!this.parent?this.vars.get(e):this.parent.get(e)}}])&&t(n.prototype,r),e}()},247:function(e,t,n){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r,o,s,u=i(e);if(t){var c=i(this).constructor;n=Reflect.construct(u,arguments,c)}else n=u.apply(this,arguments);return r=this,!(o=n)||"object"!=((s=o)&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)&&"function"!=typeof o?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r):o}}var u=n(285),c=n(543);e.exports=function(e){"use strict";!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(a,e);var t,n,i=s(a);function a(e,t,n,r){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(o=i.call(this)).functionBody=e,o.executor=t,o.env=n,o.parameters=r,o}return t=a,(n=[{key:"call",value:function(e,t){var n,r,i=this.executor,o=this.functionBody,s=new c(e);null===(r=this.parameters)||void 0===r||null===(n=r.forEach)||void 0===n||n.call(r,(function(e,n){s.set(e,t[n])})),i.envStack.push(s);var u=i[o.type](o);return i.envStack.pop(),u}},{key:"construct",value:function(e,t){var n,r,i=new u,o=this.call(e,t);return n=o,(null!=(r=u)&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?r[Symbol.hasInstance](n):n instanceof r)?o:i}}])&&r(t.prototype,n),a}(u)},285:function(e){function t(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var r,i;function o(e){return void 0!==e.value?e.value:"function"==typeof e.get?e.get():e}e.exports=(r=new WeakSet,i=function(){"use strict";function e(){var t,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(t=this,n=r),n.add(t),this.properties=new Map,this.prototype=null}var i,s;return i=e,s=[{key:"getProperty",value:function(e){for(var n=this;null!==n;){var i=n.properties.get(e);if(void 0!==i)return t(this,r,o).call(this,i);n=n.prototype}}},{key:"setProperty",value:function(e,t){var n=t.value,r=t.get,i=t.set,o=t.writable,s=void 0===o||o,u=t.enumerable,c=void 0===u||u,a=t.configurable,l=void 0===a||a;this.properties.set(e,{value:n,get:r,set:i,writable:s,enumerable:c,configurable:l})}}],s&&n(i.prototype,s),e}(),i)},286:function(e,t,n){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r,o,s,u=i(e);if(t){var c=i(this).constructor;n=Reflect.construct(u,arguments,c)}else n=u.apply(this,arguments);return r=this,!(o=n)||"object"!=((s=o)&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)&&"function"!=typeof o?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r):o}}var u=n(285),c=n(247),a=n(90),l=n(790),f=n(864);e.exports=function(e){"use strict";!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(c,e);var t,n,i=s(c);function c(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),i.call(this,null,e)}return t=c,(n=[{key:"call",value:function(){throw Error("Uncaught TypeError: Promise constructor cannot be invoked without 'new'")}},{key:"construct",value:function(e,t){var n=new u;n.setProperty("state",{value:"pending"});var r=new a(this.executor,n),i=new l(this.executor,n);try{t.call(e,[r,i])}catch(t){i.call(e,t)}var o=new f(this.executor,n,r,i);return n.setProperty("then",{value:o}),n}}])&&r(t.prototype,n),c}(c)},790:function(e,t,n){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r,o,s,u=i(e);if(t){var c=i(this).constructor;n=Reflect.construct(u,arguments,c)}else n=u.apply(this,arguments);return r=this,!(o=n)||"object"!=((s=o)&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)&&"function"!=typeof o?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r):o}}var u=n(247),c=n(187);e.exports=function(e){"use strict";!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(u,e);var t,n,i=s(u);function u(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(n=i.call(this,null,e)).promiseInstance=t,n.then=null,n}return t=u,(n=[{key:"call",value:function(e,t){var n=t[0],r=this,i=r.then,o=r.executor,s=r.promiseInstance;null!==i&&o.microTaskQueue.push(new c(e,i,[n])),s.setProperty("state",{value:"rejected"}),s.setProperty("rejectReason",{value:n})}}])&&r(t.prototype,n),u}(u)},90:function(e,t,n){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r,o,s,u=i(e);if(t){var c=i(this).constructor;n=Reflect.construct(u,arguments,c)}else n=u.apply(this,arguments);return r=this,!(o=n)||"object"!=((s=o)&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)&&"function"!=typeof o?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r):o}}var u=n(247),c=n(187);e.exports=function(e){"use strict";!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(u,e);var t,n,i=s(u);function u(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(n=i.call(this,null,e)).promiseInstance=t,n.then=null,n}return t=u,(n=[{key:"call",value:function(e,t){var n=t[0],r=this,i=r.then,o=r.executor,s=r.promiseInstance;null!==i&&o.microTaskQueue.push(new c(e,i,[n])),s.setProperty("state",{value:"fulfilled"}),s.setProperty("resolvedValue",{value:n})}}])&&r(t.prototype,n),u}(u)},864:function(e,t,n){function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r,o,s,u=i(e);if(t){var c=i(this).constructor;n=Reflect.construct(u,arguments,c)}else n=u.apply(this,arguments);return r=this,!(o=n)||"object"!=((s=o)&&"undefined"!=typeof Symbol&&s.constructor===Symbol?"symbol":typeof s)&&"function"!=typeof o?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r):o}}var u=n(247),c=n(187);e.exports=function(e){"use strict";!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(u,e);var t,n,i=s(u);function u(e,t,n,r){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(o=i.call(this,null,e)).promiseInstance=t,o.resolve=n,o.reject=r,o}return t=u,(n=[{key:"call",value:function(e,t){var n=t[0],r=this,i=r.executor,o=r.promiseInstance,s=r.resolve,u=r.reject;if("fulfilled"===o.getProperty("state")){var a=o.getProperty("resolvedValue");i.microTaskQueue.push(new c(e,n,[a]))}else if("rejected"===o.getProperty("state")){var l=o.getProperty("rejectReason");i.microTaskQueue.push(new c(e,n,[l]))}else s.then=n,u.then=n}}])&&r(t.prototype,n),u}(u)},253:function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(){"use strict";function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.object=t,this.property=n}var n,r;return n=e,(r=[{key:"set",value:function(e){this.object.set(this.property,e)}},{key:"get",value:function(){return this.object.get(this.property)}}])&&t(n.prototype,r),e}()},187:function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(){"use strict";function e(t,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.env=t,this.func=n,this.args=r}var n,r;return n=e,(r=[{key:"run",value:function(){this.func.call(this.env,this.args)}}])&&t(n.prototype,r),e}()},219:function(e,t){var n=new Map([["PropertyDefinition",[["StringLiteral",":","Expression"],["NumbericLiteral",":","Expression"]]],["PropertyDefinitionList",[["PropertyDefinition"],["PropertyDefinitionList",":","PropertyDefinition"]]],["ObjectLiteral",[["{","}"],["{","PropertyDefinitionList","}"],["{","PropertyDefinitionList",",","}"]]],["Literal",[["NumbericLiteral"],["StringLiteral"],["BooleanLiteral"],["NullLiteral"],["ObjectLiteral"]]],["Primary",[["(","Expression",")"],["Literal"],["Identifier"]]],["Arguments",[["(",")"],["(","ArgumentList",")"],["(","ArgumentList",",",")"]]],["ArgumentList",[["AssignmentExpression"],["ArgumentList",",","AssignmentExpression"]]],["MemberExpression",[["Primary"],["MemberExpression",".","Identifier"],["MemberExpression","[","Expression","]"],["new","MemberExpression","Arguments"]]],["NewExpression",[["MemberExpression"],["new","NewExpression"]]],["CallExpression",[["CoverCallExpressionAndAsyncArrowHead"],["CallExpression","Arguments"],["CallExpression","[","Expression","]"],["CallExpression",".","Identifier"]]],["CoverCallExpressionAndAsyncArrowHead",[["MemberExpression","Arguments"]]],["LeftHandSideExpression",[["MemberExpression"],["CallExpression"],["NewExpression"]]],["UpdateExpression",[["LeftHandSideExpression"],["LeftHandSideExpression","++"],["LeftHandSideExpression","--"],["++","LeftHandSideExpression"],["--","LeftHandSideExpression"]]],["MultiplicativeExpression",[["UpdateExpression"],["MultiplicativeExpression","*","UpdateExpression"],["MultiplicativeExpression","/","UpdateExpression"],["MultiplicativeExpression","%","UpdateExpression"]]],["AdditiveExpression",[["MultiplicativeExpression"],["AdditiveExpression","+","MultiplicativeExpression"],["AdditiveExpression","-","MultiplicativeExpression"]]],["RelationalExpression",[["AdditiveExpression"],["RelationalExpression",">","AdditiveExpression"],["RelationalExpression","<","AdditiveExpression"]]],["EqualityExpression",[["RelationalExpression"],["EqualityExpression","==","RelationalExpression"],["EqualityExpression","!=","RelationalExpression"],["EqualityExpression","===","RelationalExpression"],["EqualityExpression","!==","RelationalExpression"]]],["BitwiseANDExpression",[["EqualityExpression"],["BitwiseANDExpression","&","EqualityExpression"]]],["BitwiseXORExpression",[["BitwiseANDExpression"],["BitwiseXORExpression","^","BitwiseANDExpression"]]],["BitwiseORExpression",[["BitwiseXORExpression"],["BitwiseORExpression","|","BitwiseXORExpression"]]],["LogicalANDExpression",[["BitwiseORExpression"],["LogicalANDExpression","&&","BitwiseORExpression"]]],["LogicalORExpression",[["LogicalANDExpression"],["LogicalORExpression","||","LogicalANDExpression"]]],["CoalesceExpression",[["ShortCircuitExpression","??","BitwiseORExpression"]]],["ShortCircuitExpression",[["LogicalORExpression"],["CoalesceExpression"]]],["ConditionalExpression",[["ShortCircuitExpression"],["ShortCircuitExpression","?","AssignmentExpression",":","AssignmentExpression"]]],["AssignmentOperator",[["*="],["/="],["%="],["+="],["-="],["<<="],[">>="],[">>>="],["&="],["^="],["|="],["**="]]],["AssignmentExpression",[["ConditionalExpression"],["LeftHandSideExpression","=","AssignmentExpression"],["LeftHandSideExpression","AssignmentOperator","AssignmentExpression"],["LeftHandSideExpression","&&=","AssignmentExpression"],["LeftHandSideExpression","||=","AssignmentExpression"],["LeftHandSideExpression","??=","AssignmentExpression"]]],["Expression",[["AssignmentExpression"],["Expression",",","AssignmentExpression"]]],["Parameters",[["Identifier"],["Parameters",",","Identifier"]]],["FunctionDeclaration",[["function","Identifier","(",")","BlockStatement"],["function","Identifier","(","Parameters",")","BlockStatement"]]],["Declaration",[["FunctionDeclaration"],["var","Identifier","=","Expression",";"],["let","Identifier","=","Expression",";"],["const","Identifier","=","Expression",";"]]],["ExpressionStatement",[["Expression",";"]]],["BlockStatement",[["{","}"],["{","StatementList","}"]]],["IfStatement",[["if","(","Expression",")","Statement"],["if","(","Expression",")","else","Statement"]]],["ForStatement",[["for","(","let","Expression",";","Expression",";","Expression",")","Statement"],["for","(","var","Expression",";","Expression",";","Expression",")","Statement"],["for","(","Expression",";","Expression",";","Expression",")","Statement"]]],["BreakableStatement",[["ForStatement"]]],["BreakStatement",[["break",";"],["break","Identifier",";"]]],["ContinueStatement",[["continue",";"],["continue","Identifier",";"]]],["ReturnStatement",[["return",";"],["return","Expression",";"]]],["Statement",[["BlockStatement"],["ExpressionStatement"],["IfStatement"],["ForStatement"],["BreakableStatement"],["BreakStatement"],["ContinueStatement"],["ReturnStatement"],["Declaration"]]],["StatementListItem",[["Statement"],["Declaration"]]],["StatementList",[["StatementListItem"],["StatementList","StatementListItem"]]],["Program",[["StatementList"]]]]);t.regStr="\n(?<NumbericLiteral>(?:0[xX][0-9a-fA-F]*|\\.[0-9]+|(?:[1-9]+[0-9]*|0)(?:\\.[0-9]*|\\.)?)(?:[eE][+-]{0,1}[0-9]+)?(?![_$a-zA-Z0-9]))|\n(?<NulLiteral>null(?![_$a-zA-Z0-9]))|\n(?<BooleanLiteral>(?:true|false)(?![_$a-zA-Z0-9]))|\n(?<StringLiteral>\"(?:[^\"\\n\\\\\\r\\u2028\\u2029]|\\\\(?:['\"\\\\bfnrtv\\n\\r\\u2028\\u2029]|\\r\\n)|\\\\x[0-9a-fA-F]{2}|\\\\u[0-9a-fA-F]{4}|\\\\[^0-9ux'\"\\\\bfnrtv\\n\\\\\\r\\u2028\\u2029])*\"|'(?:[^'\\n\\\\\\r\\u2028\\u2029]|\\\\(?:['\"\\\\bfnrtv\\n\\r\\u2028\\u2029]|\\r\\n)|\\\\x[0-9a-fA-F]{2}|\\\\u[0-9a-fA-F]{4}|\\\\[^0-9ux'\"\\\\bfnrtv\\n\\\\\\r\\u2028\\u2029])*')|\n(?<Punctuator>>>>=|>>=|<<=|===|!==|>>>|<<|%=|\\*=|-=|\\+=|<=|>=|==|!=|/=|\\^=|\\|=|&&=|\\|\\|=|\\?\\?=|\\|\\||&&|\\?\\?|&=|>>|\\+\\+|--|\\:|}|\\*|&|\\||\\^|!|~|-|\\+|\\?|%|=|>|<|,|;|\\.(?![0-9])|\\]|\\[|\\)|\\(|{)|\n(?<Keywords>break(?![_$a-zA-Z0-9])|else(?![_$a-zA-Z0-9])|new(?![_$a-zA-Z0-9])|var(?![_$a-zA-Z0-9])|let(?![_$a-zA-Z0-9])|const(?![_$a-zA-Z0-9])|case(?![_$a-zA-Z0-9])|finally(?![_$a-zA-Z0-9])|return(?![_$a-zA-Z0-9])|void(?![_$a-zA-Z0-9])|catch(?![_$a-zA-Z0-9])|for(?![_$a-zA-Z0-9])|switch(?![_$a-zA-Z0-9])|while(?![_$a-zA-Z0-9])|continue(?![_$a-zA-Z0-9])|function(?![_$a-zA-Z0-9])|this(?![_$a-zA-Z0-9])|with(?![_$a-zA-Z0-9])|default(?![_$a-zA-Z0-9])|if(?![_$a-zA-Z0-9])|throw(?![_$a-zA-Z0-9])|delete(?![_$a-zA-Z0-9])|in(?![_$a-zA-Z0-9])|try(?![_$a-zA-Z0-9])|do(?![_$a-zA-Z0-9])|instanceof(?![_$a-zA-Z0-9])|typeof(?![_$a-zA-Z0-9]))|\n(?<LineTerminator>(?:\\n))|\n(?<Identifier>[_&A-Za-z][_&A-Za-z0-9\\\\u200C\\\\u200D]{0,})\n",t.rulesMap=n,t.initialState={Program:{EOF:{$end:!0}}}},214:function(e,t,n){function r(e,t,n,r,i,o,s){try{var u=e[o](s),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,i)}function i(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}var o=n(253),s=n(543),u=n(449),c=n(285),a=n(247),l=n(286),f=new s,h={envStack:[f],microTaskQueue:[],runTaskQueue:[],runTask:function(){return(e=function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}(this,(function(e){for(;this.microTaskQueue.length>0;)this.microTaskQueue.shift().run();return[2]}))},function(){var t=this,n=arguments;return new Promise((function(i,o){var s=e.apply(t,n);function u(e){r(s,i,o,u,c,"next",e)}function c(e){r(s,i,o,u,c,"throw",e)}u(void 0)}))}).apply(this);var e},execute:function(e){return"function"!=typeof this[e.type]&&console.log("ast.type",e.type,this[e.type]),this[e.type](e)},getValue:function(e){var t=this.execute(e);return i(t,o)?t.get():t},preProcesser:{},get currentEnv(){return this.envStack[this.envStack.length-1]},Identifier:function(e){return new o(this.currentEnv,e.value)},Parameters:function(e){if(1===e.children.length)return[e.children[0].value];var t,n=null!==(t=this.execute(e.children[0]))&&void 0!==t?t:[],r=e.children[2].value;return n.concat(r)},FunctionDeclaration:function(e){if(5===e.children.length){var t=e.children[1].value,n=e.children[4],r=new a(n,this,this.currentEnv);this.currentEnv.declare(t),this.currentEnv.set(t,r)}else if(6===e.children.length){var i=e.children[1].value,o=this.execute(e.children[3]),s=e.children[5],c=new a(s,this,this.currentEnv,o);this.currentEnv.declare(i),this.currentEnv.set(i,c)}return new u("normal")},Declaration:function(e){if(1===e.children.length)return this.execute(e.children[0]);this.currentEnv.declare(e.children[1].value),this.currentEnv.set(e.children[1].value,void 0),this.execute(e.children[1]).set(this.execute(e.children[3]))},NumbericLiteral:function(e){return 1*e.value},StringLiteral:function(e){return e.value.slice(1,-1)},BooleanLiteral:function(e){return"true"===e.value},NullLiteral:function(){return null},ObjectLiteral:function(e){var t=this,n=new c;return 3!==e.children.length&&4!==e.children.length||e.children[1].children.forEach((function(e){var r=e.children,o=t.execute(r[0]),s=t.execute(r[2]),u="object"!=typeof s||i(s,c)?{value:s}:s;n.setProperty(o,u)})),n},Literal:function(e){return this.execute(e.children[0])},Primary:function(e){return 1===e.children.length?this.execute(e.children[0]):this.execute(e.children[1])},Arguments:function(e){return 2===e.children.length?[]:3===e.children.length||4===e.children.length?this.execute(e.children[1]):void 0},ArgumentList:function(e){if(1===e.children.length)return[this.getValue(e.children[0])];var t,n=null!==(t=this.execute(e.children[0]))&&void 0!==t?t:[],r=this.getValue(e.children[2].value);return n.concat(r)},MemberExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);if(3===e.children.length){if("new"===e.children[0].value){var t=this.getValue(e.children[1]),n=this.getValue(e.children[2]);return t.construct(this.currentEnv,n[0])}return this.getValue(e.children[0]).getProperty(e.children[2].value)}return 4===e.children.length?new o(this.execute(e.children[0]),e.children[2]):void 0},NewExpression:function(e){return 1===e.children.length?this.execute(e.children[0]):this.execute(e.children[1])},CallExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);if(2===e.children.length){var t=this.execute(e.children[0]),n=this.execute(e.children[1]);return t.call(this.currentEnv,n)}},CoverCallExpressionAndAsyncArrowHead:function(e){if(2===e.children.length){var t=this.getValue(e.children[0]),n=this.execute(e.children[1]);return t.call(this.currentEnv,n)}},LeftHandSideExpression:function(e){return this.execute(e.children[0])},UpdateExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=void 0;if("++"===e.children[0].type){var n=this.execute(e.children[1]);n.set(t=n.get()+1)}else if("--"===e.children[0].type){var r=this.execute(e.children[1]);r.set(t=r.get()-1)}else if("++"===e.children[1].type){var i=this.execute(e.children[0]);i.set((t=i.get())+1)}else if("--"===e.children[1].type){var o=this.execute(e.children[0]);o.set((t=o.get())-1)}return t},MultiplicativeExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.getValue(e.children[0]),n=this.getValue(e.children[2]);return"*"===e.children[1].type?t*n:"/"===e.children[1].type?t/n:t%n},AdditiveExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.getValue(e.children[0]),n=this.getValue(e.children[2]);return"+"===e.children[1].type?t+n:t-n},RelationalExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.getValue(e.children[0]),n=this.getValue(e.children[2]);return">"===e.children[1].type?t>n:t<n},EqualityExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.getValue(e.children[0]),n=this.getValue(e.children[2]),r=e.children[1].type;return"=="===r?t==n:"!="===r?t!=n:"==="===r?t===n:"!=="===r?t!==n:void 0},BitwiseANDExpression:function(e){return 1===e.children.length?this.execute(e.children[0]):this.getValue(e.children[0])&this.getValue(e.children[2])},BitwiseXORExpression:function(e){return 1===e.children.length?this.execute(e.children[0]):this.getValue(e.children[0])^this.getValue(e.children[2])},BitwiseORExpression:function(e){return 1===e.children.length?this.execute(e.children[0]):this.getValue(e.children[0])|this.getValue(e.children[2])},LogicalANDExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.getValue(e.children[0]),n=this.getValue(e.children[2]);return t&&n},LogicalORExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.getValue(e.children[0]),n=this.getValue(e.children[2]);return t||n},CoalesceExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.getValue(e.children[0]),n=this.getValue(e.children[2]);return null!=t?t:n},CoalesceExpressionHead:function(e){if(1===e.children.length)return this.execute(e.children[0])},ShortCircuitExpression:function(e){if(1===e.children.length)return this.execute(e.children[0])},ConditionalExpression:function(e){return 1===e.children.length?this.execute(e.children[0]):this.execute(e.children[0])?this.execute(e.children[2]):this.execute(e.children[4])},AssignmentOperator:function(e){return e.children[0].type},AssignmentExpression:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.execute(e.children[0]),n=this.getValue(e.children[2]),r=void 0;if("="===e.children[1].type)t.set(r=n);else if("AssignmentOperator"===e.children[1].type){var i=this.execute(e.children[1]);"*="===i?t.set(r=t.get()*n):"/="===i?t.set(r=t.get()/n):"%="===i?t.set(r=t.get()%n):"+="===i?t.set(r=t.get()+n):"-="===i?t.set(r=t.get()-n):"<<="===i?t.set(r=t.get()<<n):">>="===i?t.set(r=t.get()>>n):">>>="===i?t.set(r=t.get()>>>n):"&="===i?t.set(r=t.get()&n):"^="===i?t.set(r=t.get()^n):"|="===i?t.set(r=t.get()|n):"**="===i&&t.set(r=Math.pow(t.get(),n))}else if("&&="===e.children[1].type)t.set(r=t.get()&&n);else if("||="===e.children[1].type)t.set(r=t.get()||n);else if("??="===e.children[1].type){var o;t.set(r=null!==(o=t.get())&&void 0!==o?o:n)}return r},Expression:function(e){return 1===e.children.length?this.execute(e.children[0]):(this.execute(e.children[0]),this.execute(e.children[2]))},ExpressionStatement:function(e){return new u("normal",this.execute(e.children[0]))},BlockStatement:function(e){if(3===e.children.length){this.envStack.push(new s(this.currentEnv));var t=this.execute(e.children[1]);return this.envStack.pop(),t}return new u("normal")},IfStatement:function(e){var t=this.execute(e.children[2]);return 5===e.children.length?t?this.execute(e.children[4]):new u("normal"):t?this.execute(e.children[4]):this.execute(e.children[6])},ForStatement:function(e){var t=2;10===e.children.length&&t++;var n=e.children[t],r=e.children[t+2],i=e.children[t+4],o=e.children[t+6];for(this.execute(n);this.execute(r);){var s=this.execute(o);if("break"===s.type||"return"===s.type)return new u("normal",s.value);this.execute(i)}},BreakableStatement:function(e){if(1===e.children.length)return this.execute(e.children[0])},BreakStatement:function(e){return new u("break")},ContinueStatement:function(e){return new u("continue")},ReturnStatement:function(e){if(2===e.children.length)return new u("return");if(3===e.children.length){var t=this.getValue(e.children[1]);return new u("return",t)}},Statement:function(e){return this.execute(e.children[0])},StatementListItem:function(e){var t,n=this.execute(e.children[0]);return(null===(t=n)||void 0===t?void 0:t.type)?n:new u("normal",n)},StatementList:function(e){if(1===e.children.length)return this.execute(e.children[0]);var t=this.execute(e.children[0]);return"normal"===t.type?this.execute(e.children[1]):t},Program:function(e){return this.execute(e.children[0])}};f.set("Promise",new l(h)),e.exports={executor:h,globalEnv:f}},638:function(e,t,n){var i=n(219).regStr;e.exports=function(e){for(var t=new RegExp(i.replace(/\s+/g,""),"g"),n=[];r=t.exec(e);){var o=Object.keys(r.groups),s=!0,u=!1,c=void 0;try{for(var a,l=o[Symbol.iterator]();!(s=(a=l.next()).done);s=!0){var f=a.value;void 0!==r.groups[f]&&n.push({type:"Punctuator"===f||"Keywords"===f?r.groups[f]:f,value:r.groups[f]})}}catch(e){u=!0,c=e}finally{try{s||null==l.return||l.return()}finally{if(u)throw c}}}return n.push({type:"EOF"}),n}},924:function(e,t,n){var r=n(219),i=r.rulesMap,o=r.initialState;function s(e,t,n){var r=new Set;return JSON.stringify(e,(function(e,n){if("object"==typeof n&&null!==n){if(r.has(n))return"[Circular]";r.add(n)}return t?t(e,n):n}),n)}var u=function(e,t){for(var n=function(){var e=i.shift();return!1===t.has(e)||!0===o.has(e)?"continue":(t.get(e).forEach((function(t){r.push({ruleBody:t,$reduce:e}),i.push(t[0])})),void o.add(e))},r=[],i=[e],o=new Set;0!==i.length;)n();return r},c=new Map,a=function(e,t){c.set(s(e),e);var n=!0,r=!1,i=void 0;try{for(var o,l=Object.keys(e)[Symbol.iterator]();!(n=(o=l.next()).done);n=!0){var f=o.value;f.startsWith("$")||u(f,t).forEach((function(t){var n=t.ruleBody,r=t.$reduce,i=e;n.forEach((function(e){void 0===i[e]&&(i[e]={}),i=i[e]})),i.$reduce=r,i.$count=n.length}))}}catch(e){r=!0,i=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw i}}var h=!0,p=!1,d=void 0;try{for(var v,y=Object.keys(e)[Symbol.iterator]();!(h=(v=y.next()).done);h=!0){var x=v.value;if(!x.startsWith("$")){var g=s(e[x]);c.has(g)?e[x]=c.get(g):a(e[x],t)}}}catch(e){p=!0,d=e}finally{try{h||null==y.return||y.return()}finally{if(p)throw d}}return e};e.exports=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;c.clear(),a(n,t);for(var r=[],s=[n],u=e.length,l=function(e){for(;void 0===s[s.length-1][e.type]&&s[s.length-1].$reduce;)f();if(void 0===s[s.length-1][e.type]){if("EOF"===e.type||"}"===e.type||h)return l({type:";",value:";"}),l(e);throw Error("syntax error type "+e.type)}r.push(e),s.push(s[s.length-1][e.type])},f=function(){for(var e=s[s.length-1],t={type:e.$reduce,children:[]},n=0;n<e.$count;n++)t.children.unshift(r.pop()),s.pop();l(t)},h=!1,p=0;p<u;p++){var d=e[p];"LineTerminator"===d.type?h=!0:(l(d),h=!1)}return r}},338:function(e,t,n){var r=n(638),i=n(924),o=n(214),s=o.executor,u=o.globalEnv;e.exports={lex:r,parse:i,executor:s,globalEnv:u,execute:function(e){return s.execute(e)},evaluate:function(e,t,n){var o=s.execute(i(r(e),t,n)[0]);return s.runTask(),o}}}},t={},function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}(338);var e,t}));