mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
Update JS-Interpreter to latest version
And fix alerting falsy values.
This commit is contained in:
@@ -38,132 +38,104 @@ Pb=RegExp("[\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02c1\u02c6-\u02
|
||||
na=/[\n\r\u2028\u2029]/,Y=/\r\n|[\n\r\u2028\u2029]/g,la=a.isIdentifierStart=function(a){return 65>a?36===a:91>a?!0:97>a?95===a:123>a?!0:170<=a&&Za.test(String.fromCharCode(a))},ab=a.isIdentifierChar=function(a){return 48>a?36===a:58>a?!0:65>a?!1:91>a?!0:97>a?95===a:123>a?!0:170<=a&&Pb.test(String.fromCharCode(a))},ca,Ia={kind:"loop"},Ob={kind:"switch"}};
|
||||
"object"==typeof exports&&"object"==typeof module?mod$$inline_58(exports):"function"==typeof define&&define.amd?define(["exports"],mod$$inline_58):mod$$inline_58(this.acorn||(this.acorn={}));
|
||||
// JS-Interpreter: Copyright 2013 Google LLC, Apache 2.0
|
||||
var Interpreter=function(a,b){"string"==typeof a&&(a=acorn.parse(a,Interpreter.PARSE_OPTIONS));this.ast=a;this.initFunc_=b;this.paused_=!1;this.polyfills_=[];this.UNDEFINED=new Interpreter.Primitive(void 0,this);this.NULL=new Interpreter.Primitive(null,this);this.NAN=new Interpreter.Primitive(NaN,this);this.TRUE=new Interpreter.Primitive(!0,this);this.FALSE=new Interpreter.Primitive(!1,this);this.NUMBER_ZERO=new Interpreter.Primitive(0,this);this.NUMBER_ONE=new Interpreter.Primitive(1,this);this.STRING_EMPTY=
|
||||
new Interpreter.Primitive("",this);b=this.createScope(this.ast,null);this.NAN.parent=this.NUMBER;this.TRUE.parent=this.BOOLEAN;this.FALSE.parent=this.BOOLEAN;this.NUMBER_ZERO.parent=this.NUMBER;this.NUMBER_ONE.parent=this.NUMBER;this.STRING_EMPTY.parent=this.STRING;this.ast=acorn.parse(this.polyfills_.join("\n"),Interpreter.PARSE_OPTIONS);this.polyfills_=void 0;this.stripLocations_(this.ast);this.stateStack=[{node:this.ast,scope:b,thisExpression:b,done:!1}];this.run();this.value=this.UNDEFINED;this.ast=
|
||||
a;this.stateStack=[{node:this.ast,scope:b,thisExpression:b,done:!1}]};Interpreter.PARSE_OPTIONS={ecmaVersion:5};Interpreter.READONLY_DESCRIPTOR={configurable:!0,enumerable:!0,writable:!1};Interpreter.NONENUMERABLE_DESCRIPTOR={configurable:!0,enumerable:!1,writable:!0};Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR={configurable:!0,enumerable:!1,writable:!1};
|
||||
Interpreter.prototype.appendCode=function(a){var b=this.stateStack[this.stateStack.length-1];if(!b||"Program"!=b.node.type)throw Error("Expecting original AST to start with a Program node.");"string"==typeof a&&(a=acorn.parse(a,Interpreter.PARSE_OPTIONS));if(!a||"Program"!=a.type)throw Error("Expecting new AST to start with a Program node.");this.populateScope_(a,b.scope);for(var c=0,d;d=a.body[c];c++)b.node.body.push(d);b.done=!1};
|
||||
Interpreter.prototype.step=function(){var a=this.stateStack[0];if(!a||"Program"==a.node.type&&a.done)return!1;if(this.paused_)return!0;this["step"+a.node.type]();return a.node.end?!0:this.step()};Interpreter.prototype.run=function(){for(;!this.paused_&&this.step(););return this.paused_};
|
||||
Interpreter.prototype.initGlobalScope=function(a){this.setProperty(a,"Infinity",this.createPrimitive(Infinity),Interpreter.READONLY_DESCRIPTOR);this.setProperty(a,"NaN",this.NAN,Interpreter.READONLY_DESCRIPTOR);this.setProperty(a,"undefined",this.UNDEFINED,Interpreter.READONLY_DESCRIPTOR);this.setProperty(a,"window",a,Interpreter.READONLY_DESCRIPTOR);this.setProperty(a,"self",a);this.initFunction(a);this.initObject(a);a.parent=this.OBJECT;this.initArray(a);this.initNumber(a);this.initString(a);this.initBoolean(a);
|
||||
this.initDate(a);this.initMath(a);this.initRegExp(a);this.initJSON(a);this.initError(a);var b=this,c;c=function(a){a=a||b.UNDEFINED;return b.createPrimitive(isNaN(a.toNumber()))};this.setProperty(a,"isNaN",this.createNativeFunction(c));c=function(a){a=a||b.UNDEFINED;return b.createPrimitive(isFinite(a.toNumber()))};this.setProperty(a,"isFinite",this.createNativeFunction(c));this.setProperty(a,"parseFloat",this.getProperty(this.NUMBER,"parseFloat"));this.setProperty(a,"parseInt",this.getProperty(this.NUMBER,
|
||||
"parseInt"));c=this.createObject(this.FUNCTION);c.eval=!0;this.setProperty(c,"length",this.NUMBER_ONE,Interpreter.READONLY_DESCRIPTOR);this.setProperty(a,"eval",c);for(var d=[[escape,"escape"],[unescape,"unescape"],[decodeURI,"decodeURI"],[decodeURIComponent,"decodeURIComponent"],[encodeURI,"encodeURI"],[encodeURIComponent,"encodeURIComponent"]],h=0;h<d.length;h++)c=function(a){return function(c){c=(c||b.UNDEFINED).toString();try{c=a(c)}catch(r){b.throwException(b.URI_ERROR,r.message)}return b.createPrimitive(c)}}(d[h][0]),
|
||||
this.setProperty(a,d[h][1],this.createNativeFunction(c));this.initFunc_&&this.initFunc_(this,a)};
|
||||
Interpreter.prototype.initFunction=function(a){var b=this,c;c=function(a){for(var c=this.parent==b.FUNCTION?this:b.createObject(b.FUNCTION),d=arguments.length?arguments[arguments.length-1].toString():"",p=[],r=0;r<arguments.length-1;r++)p.push(arguments[r].toString());p=p.join(", ");if(-1!=p.indexOf(")"))throw SyntaxError("Function arg string contains parenthesis");c.parentScope=b.stateStack[b.stateStack.length-1].scope;d=acorn.parse("$ = function("+p+") {"+d+"};",Interpreter.PARSE_OPTIONS);c.node=
|
||||
d.body[0].expression.right;b.setProperty(c,"length",b.createPrimitive(c.node.length),Interpreter.READONLY_DESCRIPTOR);return c};this.FUNCTION=this.createObject(null);this.setProperty(a,"Function",this.FUNCTION);this.FUNCTION.type="function";this.setProperty(this.FUNCTION,"prototype",this.createObject(null));this.FUNCTION.nativeFunc=c;c=function(a,c){var d=b.stateStack[0];d.func_=this;d.funcThis_=a;d.arguments=[];if(c)if(b.isa(c,b.ARRAY))for(a=0;a<c.length;a++)d.arguments[a]=b.getProperty(c,a);else b.throwException(b.TYPE_ERROR,
|
||||
"CreateListFromArrayLike called on non-object");d.doneArgs_=!0;d.doneExec_=!1};this.setNativeFunctionPrototype(this.FUNCTION,"apply",c);c=function(a,c){var d=b.stateStack[0];d.func_=this;d.funcThis_=a;d.arguments=[];for(var h=1;h<arguments.length;h++)d.arguments.push(arguments[h]);d.doneArgs_=!0;d.doneExec_=!1};this.setNativeFunctionPrototype(this.FUNCTION,"call",c);c=function(a,c){var d=b.createFunction(this.node,this.parentScope);a&&(d.boundThis_=a);d.boundArgs_=[];for(var h=1;h<arguments.length;h++)d.boundArgs_.push(arguments[h]);
|
||||
return d};this.setNativeFunctionPrototype(this.FUNCTION,"bind",c);c=function(){return b.createPrimitive(this.toString())};this.setNativeFunctionPrototype(this.FUNCTION,"toString",c);this.setProperty(this.FUNCTION,"toString",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(){return b.createPrimitive(this.valueOf())};this.setNativeFunctionPrototype(this.FUNCTION,"valueOf",c);this.setProperty(this.FUNCTION,"valueOf",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR)};
|
||||
Interpreter.prototype.initObject=function(a){var b=this,c;c=function(a){if(!a||a==b.UNDEFINED||a==b.NULL)return this.parent==b.OBJECT?this:b.createObject(b.OBJECT);if(a.isPrimitive){var c=b.createObject(a.parent);c.data=a.data;return c}return a};this.OBJECT=this.createNativeFunction(c);this.setProperty(a,"Object",this.OBJECT);c=function(a){var c=b.createObject(b.ARRAY),d=0,p;for(p in a.properties)b.setProperty(c,d,b.createPrimitive(p)),d++;return c};this.setProperty(this.OBJECT,"getOwnPropertyNames",
|
||||
this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(a){var c=b.createObject(b.ARRAY),d=0,p;for(p in a.properties)a.notEnumerable[p]||(b.setProperty(c,d,b.createPrimitive(p)),d++);return c};this.setProperty(this.OBJECT,"keys",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(a,c,g){c=(c||b.UNDEFINED).toString();if(g instanceof Interpreter.Object)if(!a.properties[c]&&a.preventExtensions)b.throwException(b.TYPE_ERROR,"Can't define property "+c+", object is not extensible");
|
||||
else{var d=b.getProperty(g,"value");d==b.UNDEFINED&&(d=null);var h=b.getProperty(g,"get"),v=b.getProperty(g,"set");g={configurable:b.pseudoToNative(b.getProperty(g,"configurable")),enumerable:b.pseudoToNative(b.getProperty(g,"enumerable")),writable:b.pseudoToNative(b.getProperty(g,"writable")),get:h==b.UNDEFINED?void 0:h,set:v==b.UNDEFINED?void 0:v};b.setProperty(a,c,d,g);return a}else b.throwException(b.TYPE_ERROR,"Property description must be an object.")};this.setProperty(this.OBJECT,"defineProperty",
|
||||
this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);this.polyfills_.push("Object.defineProperty(Array.prototype, 'defineProperties', {configurable: true, value:","function(obj, props) {","var keys = Object.keys(props);","for (var i = 0; i < keys.length; i++) {","Object.defineProperty(obj, keys[i], props[keys[i]]);","}","return obj;","}","});","");c=function(a,c){c=(c||b.UNDEFINED).toString();if(!(c in a.properties))return b.UNDEFINED;var d=!a.notConfigurable[c],h=!a.notEnumerable[c],
|
||||
r=!a.notWritable[c],v=a.getter[c],w=a.setter[c],q=b.createObject(b.OBJECT);b.setProperty(q,"configurable",b.createPrimitive(d));b.setProperty(q,"enumerable",b.createPrimitive(h));v||w?(b.setProperty(q,"getter",v),b.setProperty(q,"setter",w)):(b.setProperty(q,"writable",b.createPrimitive(r)),b.setProperty(q,"value",b.getProperty(a,c)));return q};this.setProperty(this.OBJECT,"getOwnPropertyDescriptor",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(a){return a.parent&&
|
||||
a.parent.properties&&a.parent.properties.prototype?a.parent.properties.prototype:b.NULL};this.setProperty(this.OBJECT,"getPrototypeOf",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(a){return b.createPrimitive(!a.preventExtensions)};this.setProperty(this.OBJECT,"isExtensible",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(a){a.isPrimitive||(a.preventExtensions=!0);return a};this.setProperty(this.OBJECT,"preventExtensions",this.createNativeFunction(c),
|
||||
Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(){return b.createPrimitive(this.toString())};this.setNativeFunctionPrototype(this.OBJECT,"toString",c);c=function(){return b.createPrimitive(this.toString())};this.setNativeFunctionPrototype(this.OBJECT,"toLocaleString",c);c=function(){return b.createPrimitive(this.valueOf())};this.setNativeFunctionPrototype(this.OBJECT,"valueOf",c);c=function(a){if(this==b.NULL||this==b.UNDEFINED)b.throwException(b.TYPE_ERROR,"Cannot convert undefined or null to object");
|
||||
else return a=(a||b.UNDEFINED).toString(),a in this.properties?b.TRUE:b.FALSE};this.setNativeFunctionPrototype(this.OBJECT,"hasOwnProperty",c);c=function(a){a=(a||b.UNDEFINED).toString();a=a in this.properties&&!this.notEnumerable[a];return b.createPrimitive(a)};this.setNativeFunctionPrototype(this.OBJECT,"propertyIsEnumerable",c);c=function(a){for(;;)if(a.parent&&a.parent.properties&&a.parent.properties.prototype){if(a=a.parent.properties.prototype,a==this)return b.createPrimitive(!0)}else return b.createPrimitive(!1)};
|
||||
this.setNativeFunctionPrototype(this.OBJECT,"isPrototypeOf",c)};
|
||||
Interpreter.prototype.initArray=function(a){var b=this,c=function(a,b){a=a?Math.floor(a.toNumber()):b;isNaN(a)&&(a=b);return a},d;d=function(a){var c=this.parent==b.ARRAY?this:b.createObject(b.ARRAY),d=arguments[0];if(d&&"number"==d.type)isNaN(b.arrayIndex(d))&&b.throwException(b.RANGE_ERROR,"Invalid array length"),c.length=d.data;else{for(d=0;d<arguments.length;d++)c.properties[d]=arguments[d];c.length=d}return c};this.ARRAY=this.createNativeFunction(d);this.setProperty(a,"Array",this.ARRAY);d=function(a){return b.createPrimitive(b.isa(a,
|
||||
b.ARRAY))};this.setProperty(this.ARRAY,"isArray",this.createNativeFunction(d),Interpreter.NONENUMERABLE_DESCRIPTOR);d=function(){if(this.length){var a=this.properties[this.length-1];delete this.properties[this.length-1];this.length--}else a=b.UNDEFINED;return a};this.setNativeFunctionPrototype(this.ARRAY,"pop",d);d=function(a){for(var c=0;c<arguments.length;c++)this.properties[this.length]=arguments[c],this.length++;return b.createPrimitive(this.length)};this.setNativeFunctionPrototype(this.ARRAY,
|
||||
"push",d);d=function(){if(this.length){for(var a=this.properties[0],c=1;c<this.length;c++)this.properties[c-1]=this.properties[c];this.length--;delete this.properties[this.length]}else a=b.UNDEFINED;return a};this.setNativeFunctionPrototype(this.ARRAY,"shift",d);d=function(a){for(var c=this.length-1;0<=c;c--)this.properties[c+arguments.length]=this.properties[c];this.length+=arguments.length;for(c=0;c<arguments.length;c++)this.properties[c]=arguments[c];return b.createPrimitive(this.length)};this.setNativeFunctionPrototype(this.ARRAY,
|
||||
"unshift",d);d=function(){for(var a=0;a<this.length/2;a++){var b=this.properties[this.length-a-1];this.properties[this.length-a-1]=this.properties[a];this.properties[a]=b}return this};this.setNativeFunctionPrototype(this.ARRAY,"reverse",d);d=function(a,d,p){a=c(a,0);a=0>a?Math.max(this.length+a,0):Math.min(a,this.length);d=c(d,Infinity);d=Math.min(d,this.length-a);for(var g=b.createObject(b.ARRAY),h=a;h<a+d;h++)g.properties[g.length++]=this.properties[h],this.properties[h]=this.properties[h+d];for(h=
|
||||
a+d;h<this.length-d;h++)this.properties[h]=this.properties[h+d];for(h=this.length-d;h<this.length;h++)delete this.properties[h];this.length-=d;for(h=this.length-1;h>=a;h--)this.properties[h+arguments.length-2]=this.properties[h];this.length+=arguments.length-2;for(h=2;h<arguments.length;h++)this.properties[a+h-2]=arguments[h];return g};this.setNativeFunctionPrototype(this.ARRAY,"splice",d);d=function(a,d){var g=b.createObject(b.ARRAY),h=c(a,0);0>h&&(h=this.length+h);h=Math.max(0,Math.min(h,this.length));
|
||||
d=c(d,this.length);0>d&&(d=this.length+d);d=Math.max(0,Math.min(d,this.length));for(a=0;h<d;h++){var v=b.getProperty(this,h);b.setProperty(g,a++,v)}return g};this.setNativeFunctionPrototype(this.ARRAY,"slice",d);d=function(a){a=a&&void 0!==a.data?a.toString():void 0;for(var c=[],d=0;d<this.length;d++)c[d]=this.properties[d];return b.createPrimitive(c.join(a))};this.setNativeFunctionPrototype(this.ARRAY,"join",d);d=function(a){for(var c=b.createObject(b.ARRAY),d=0,h=0;h<this.length;h++){var v=b.getProperty(this,
|
||||
h);b.setProperty(c,d++,v)}for(h=0;h<arguments.length;h++){var w=arguments[h];if(b.isa(w,b.ARRAY))for(var q=0;q<w.length;q++)v=b.getProperty(w,q),b.setProperty(c,d++,v);else b.setProperty(c,d++,w)}return c};this.setNativeFunctionPrototype(this.ARRAY,"concat",d);d=function(a,d){a=a||b.UNDEFINED;d=c(d,0);0>d&&(d=this.length+d);for(d=Math.max(0,d);d<this.length;d++){var h=b.getProperty(this,d);if(h.isPrimitive&&a.isPrimitive?h.data===a.data:h===a)return b.createPrimitive(d)}return b.createPrimitive(-1)};
|
||||
this.setNativeFunctionPrototype(this.ARRAY,"indexOf",d);d=function(a,d){a=a||b.UNDEFINED;d=c(d,this.length);0>d&&(d=this.length+d);for(d=Math.min(d,this.length-1);0<=d;d--){var h=b.getProperty(this,d);if(h.isPrimitive&&a.isPrimitive?h.data===a.data:h===a)return b.createPrimitive(d)}return b.createPrimitive(-1)};this.setNativeFunctionPrototype(this.ARRAY,"lastIndexOf",d);this.polyfills_.push("Object.defineProperty(Array.prototype, 'every', {configurable: true, value:","function(callbackfn, thisArg) {",
|
||||
"if (this == null || typeof callbackfn !== 'function') throw new TypeError;","var T, k;","var O = Object(this);","var len = O.length >>> 0;","if (arguments.length > 1) T = thisArg;","k = 0;","while (k < len) {","if (k in O && !callbackfn.call(T, O[k], k, O)) return false;","k++;","}","return true;","}","});","Object.defineProperty(Array.prototype, 'filter', {configurable: true, value:","function(fun/*, thisArg*/) {","if (this === void 0 || this === null || typeof fun !== 'function') throw new TypeError;",
|
||||
"var t = Object(this);","var len = t.length >>> 0;","var res = [];","var thisArg = arguments.length >= 2 ? arguments[1] : void 0;","for (var i = 0; i < len; i++) {","if (i in t) {","var val = t[i];","if (fun.call(thisArg, val, i, t)) res.push(val);","}","}","return res;","}","});","Object.defineProperty(Array.prototype, 'forEach', {configurable: true, value:","function(callback, thisArg) {","if (this == null || typeof callback !== 'function') throw new TypeError;","var T, k;","var O = Object(this);",
|
||||
"var len = O.length >>> 0;","if (arguments.length > 1) T = thisArg;","k = 0;","while (k < len) {","if (k in O) callback.call(T, O[k], k, O);","k++;","}","}","});","Object.defineProperty(Array.prototype, 'map', {configurable: true, value:","function(callback, thisArg) {","if (this == null || typeof callback !== 'function') new TypeError;","var T, A, k;","var O = Object(this);","var len = O.length >>> 0;","if (arguments.length > 1) T = thisArg;","A = new Array(len);","k = 0;","while (k < len) {","if (k in O) A[k] = callback.call(T, O[k], k, O);",
|
||||
"k++;","}","return A;","}","});","Object.defineProperty(Array.prototype, 'reduce', {configurable: true, value:","function(callback /*, initialValue*/) {","if (this == null || typeof callback !== 'function') throw new TypeError;","var t = Object(this), len = t.length >>> 0, k = 0, value;","if (arguments.length == 2) {","value = arguments[1];","} else {","while (k < len && !(k in t)) k++;","if (k >= len) {","throw new TypeError('Reduce of empty array with no initial value');","}","value = t[k++];",
|
||||
"}","for (; k < len; k++) {","if (k in t) value = callback(value, t[k], k, t);","}","return value;","}","});","Object.defineProperty(Array.prototype, 'reduceRight', {configurable: true, value:","function(callback /*, initialValue*/) {","if (null === this || 'undefined' === typeof this || 'function' !== typeof callback) throw new TypeError;","var t = Object(this), len = t.length >>> 0, k = len - 1, value;","if (arguments.length >= 2) {","value = arguments[1];","} else {","while (k >= 0 && !(k in t)) k--;",
|
||||
"if (k < 0) {","throw new TypeError('Reduce of empty array with no initial value');","}","value = t[k--];","}","for (; k >= 0; k--) {","if (k in t) value = callback(value, t[k], k, t);","}","return value;","}","});","Object.defineProperty(Array.prototype, 'some', {configurable: true, value:","function(fun/*, thisArg*/) {","if (this == null || typeof fun !== 'function') throw new TypeError;","var t = Object(this);","var len = t.length >>> 0;","var thisArg = arguments.length >= 2 ? arguments[1] : void 0;",
|
||||
"for (var i = 0; i < len; i++) {","if (i in t && fun.call(thisArg, t[i], i, t)) {","return true;","}","}","return false;","}","});","Object.defineProperty(Array.prototype, 'sort', {configurable: true, value:","function(opt_comp) {","for (var i = 0; i < this.length; i++) {","var changes = 0;","for (var j = 0; j < this.length - i - 1; j++) {","if (opt_comp ?opt_comp(this[j], this[j + 1]) > 0 : this[j] > this[j + 1]) {","var swap = this[j];","this[j] = this[j + 1];","this[j + 1] = swap;","changes++;",
|
||||
"}","}","if (changes <= 1) break;","}","return this;","}","});","Object.defineProperty(Array.prototype, 'toLocaleString', {configurable: true, value:","function() {","var out = [];","for (var i = 0; i < this.length; i++) {","out[i] = (this[i] === null || this[i] === undefined) ? '' : this[i].toLocaleString();","}","return out.join(',');","}","});","")};
|
||||
Interpreter.prototype.initNumber=function(a){var b=this,c;c=function(a){a=a?a.toNumber():0;if(this.parent!=b.NUMBER)return b.createPrimitive(a);this.data=a;return this};this.NUMBER=this.createNativeFunction(c);this.setProperty(a,"Number",this.NUMBER);a=["MAX_VALUE","MIN_VALUE","NaN","NEGATIVE_INFINITY","POSITIVE_INFINITY"];for(c=0;c<a.length;c++)this.setProperty(this.NUMBER,a[c],this.createPrimitive(Number[a[c]]));c=function(a){a=a||b.UNDEFINED;return b.createPrimitive(parseFloat(a.toString()))};
|
||||
this.setProperty(this.NUMBER,"parseFloat",this.createNativeFunction(c));c=function(a,c){a=a||b.UNDEFINED;c=c||b.UNDEFINED;return b.createPrimitive(parseInt(a.toString(),c.toNumber()))};this.setProperty(this.NUMBER,"parseInt",this.createNativeFunction(c));c=function(a){a=a?a.toNumber():void 0;var c=this.toNumber();return b.createPrimitive(c.toExponential(a))};this.setNativeFunctionPrototype(this.NUMBER,"toExponential",c);c=function(a){a=a?a.toNumber():void 0;var c=this.toNumber();return b.createPrimitive(c.toFixed(a))};
|
||||
this.setNativeFunctionPrototype(this.NUMBER,"toFixed",c);c=function(a){a=a?a.toNumber():void 0;var c=this.toNumber();return b.createPrimitive(c.toPrecision(a))};this.setNativeFunctionPrototype(this.NUMBER,"toPrecision",c);c=function(a){a=a?a.toNumber():10;var c=this.toNumber();return b.createPrimitive(c.toString(a))};this.setNativeFunctionPrototype(this.NUMBER,"toString",c);c=function(a,c){a=a?b.pseudoToNative(a):void 0;c=c?b.pseudoToNative(c):void 0;return b.createPrimitive(this.toNumber().toLocaleString(a,
|
||||
c))};this.setNativeFunctionPrototype(this.NUMBER,"toLocaleString",c)};
|
||||
Interpreter.prototype.initString=function(a){var b=this,c;c=function(a){a=a?a.toString():"";if(this.parent!=b.STRING)return b.createPrimitive(a);this.data=a;return this};this.STRING=this.createNativeFunction(c);this.setProperty(a,"String",this.STRING);c=function(a){for(var c=0;c<arguments.length;c++)arguments[c]=arguments[c].toNumber();return b.createPrimitive(String.fromCharCode.apply(String,arguments))};this.setProperty(this.STRING,"fromCharCode",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);
|
||||
a=["toLowerCase","toUpperCase","toLocaleLowerCase","toLocaleUpperCase"];for(var d=0;d<a.length;d++)c=function(a){return function(){return b.createPrimitive(a.apply(this))}}(String.prototype[a[d]]),this.setNativeFunctionPrototype(this.STRING,a[d],c);c=function(){var a=this.toString();return b.createPrimitive(a.replace(/^\s+|\s+$/g,""))};this.setNativeFunctionPrototype(this.STRING,"trim",c);c=function(){var a=this.toString();return b.createPrimitive(a.replace(/^\s+/g,""))};this.setNativeFunctionPrototype(this.STRING,
|
||||
"trimLeft",c);c=function(){var a=this.toString();return b.createPrimitive(a.replace(/\s+$/g,""))};this.setNativeFunctionPrototype(this.STRING,"trimRight",c);a=["charAt","charCodeAt","substring","slice","substr"];for(d=0;d<a.length;d++)c=function(a){return function(){for(var c=0;c<arguments.length;c++)arguments[c]=arguments[c].toNumber();return b.createPrimitive(a.apply(this,arguments))}}(String.prototype[a[d]]),this.setNativeFunctionPrototype(this.STRING,a[d],c);c=function(a,c){var d=this.toString();
|
||||
a=(a||b.UNDEFINED).toString();c=c?c.toNumber():void 0;return b.createPrimitive(d.indexOf(a,c))};this.setNativeFunctionPrototype(this.STRING,"indexOf",c);c=function(a,c){var d=this.toString();a=(a||b.UNDEFINED).toString();c=c?c.toNumber():void 0;return b.createPrimitive(d.lastIndexOf(a,c))};this.setNativeFunctionPrototype(this.STRING,"lastIndexOf",c);c=function(a,c,d){a=(a||b.UNDEFINED).toString();c=c?b.pseudoToNative(c):void 0;d=d?b.pseudoToNative(d):void 0;return b.createPrimitive(this.toString().localeCompare(a,
|
||||
c,d))};this.setNativeFunctionPrototype(this.STRING,"localeCompare",c);c=function(a,c){var d=this.toString();a=a?b.isa(a,b.REGEXP)?a.data:a.toString():void 0;c=c?c.toNumber():void 0;a=d.split(a,c);c=b.createObject(b.ARRAY);for(d=0;d<a.length;d++)b.setProperty(c,d,b.createPrimitive(a[d]));return c};this.setNativeFunctionPrototype(this.STRING,"split",c);c=function(a){for(var c=this.toString(),d=0;d<arguments.length;d++)c+=arguments[d].toString();return b.createPrimitive(c)};this.setNativeFunctionPrototype(this.STRING,
|
||||
"concat",c);c=function(a){var c=this.toString();a=a?a.data:void 0;a=c.match(a);if(null===a)return b.NULL;for(var c=b.createObject(b.ARRAY),d=0;d<a.length;d++)b.setProperty(c,d,b.createPrimitive(a[d]));return c};this.setNativeFunctionPrototype(this.STRING,"match",c);c=function(a){var c=this.toString();a=a?a.data:void 0;return b.createPrimitive(c.search(a))};this.setNativeFunctionPrototype(this.STRING,"search",c);c=function(a,c){var d=this.toString();a=(a||b.UNDEFINED).valueOf();c=(c||b.UNDEFINED).toString();
|
||||
return b.createPrimitive(d.replace(a,c))};this.setNativeFunctionPrototype(this.STRING,"replace",c)};Interpreter.prototype.initBoolean=function(a){var b=this,c;c=function(a){a=a?a.toBoolean():!1;if(this.parent!=b.BOOLEAN)return b.createPrimitive(a);this.data=a;return this};this.BOOLEAN=this.createNativeFunction(c);this.setProperty(a,"Boolean",this.BOOLEAN)};
|
||||
Interpreter.prototype.initDate=function(a){var b=this,c;c=function(a,c,d,r,v,w,q){if(this.parent==b.DATE)var g=this;else return b.createPrimitive(Date());if(arguments.length)if(1!=arguments.length||"string"!=a.type&&!b.isa(a,b.STRING)){for(var h=[null],p=0;p<arguments.length;p++)h[p+1]=arguments[p]?arguments[p].toNumber():void 0;g.data=new (Function.prototype.bind.apply(Date,h))}else g.data=new Date(a.toString());else g.data=new Date;return g};this.DATE=this.createNativeFunction(c);this.setProperty(a,
|
||||
"Date",this.DATE);c=function(){return b.createPrimitive((new Date).getTime())};this.setProperty(this.DATE,"now",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(a){a=a?a.toString():void 0;return b.createPrimitive(Date.parse(a))};this.setProperty(this.DATE,"parse",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);c=function(a,c,d,r,v,w,q){for(var g=[],h=0;h<arguments.length;h++)g[h]=arguments[h]?arguments[h].toNumber():void 0;return b.createPrimitive(Date.UTC.apply(Date,
|
||||
g))};this.setProperty(this.DATE,"UTC",this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR);a="getDate getDay getFullYear getHours getMilliseconds getMinutes getMonth getSeconds getTime getTimezoneOffset getUTCDate getUTCDay getUTCFullYear getUTCHours getUTCMilliseconds getUTCMinutes getUTCMonth getUTCSeconds getYear setDate setFullYear setHours setMilliseconds setMinutes setMonth setSeconds setTime setUTCDate setUTCFullYear setUTCHours setUTCMilliseconds setUTCMinutes setUTCMonth setUTCSeconds setYear toDateString toISOString toJSON toGMTString toLocaleDateString toLocaleString toLocaleTimeString toTimeString toUTCString".split(" ");
|
||||
for(var d=0;d<a.length;d++)c=function(a){return function(c){for(var d=[],g=0;g<arguments.length;g++)d[g]=b.pseudoToNative(arguments[g]);return b.createPrimitive(this.data[a].apply(this.data,d))}}(a[d]),this.setNativeFunctionPrototype(this.DATE,a[d],c)};
|
||||
Interpreter.prototype.initMath=function(a){var b=this,c=this.createObject(this.OBJECT);this.setProperty(a,"Math",c);var d="E LN2 LN10 LOG2E LOG10E PI SQRT1_2 SQRT2".split(" ");for(a=0;a<d.length;a++)this.setProperty(c,d[a],this.createPrimitive(Math[d[a]]),Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);d="abs acos asin atan atan2 ceil cos exp floor log max min pow random round sin sqrt tan".split(" ");for(a=0;a<d.length;a++){var h=function(a){return function(){for(var c=0;c<arguments.length;c++)arguments[c]=
|
||||
arguments[c].toNumber();return b.createPrimitive(a.apply(Math,arguments))}}(Math[d[a]]);this.setProperty(c,d[a],this.createNativeFunction(h),Interpreter.NONENUMERABLE_DESCRIPTOR)}};
|
||||
Interpreter.prototype.initRegExp=function(a){var b=this,c;c=function(a,c){var d=this.parent==b.REGEXP?this:b.createObject(b.REGEXP);a=a?a.toString():"";c=c?c.toString():"";return b.populateRegExp_(d,new RegExp(a,c))};this.REGEXP=this.createNativeFunction(c);this.setProperty(a,"RegExp",this.REGEXP);this.setProperty(this.REGEXP.properties.prototype,"global",this.UNDEFINED,Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);this.setProperty(this.REGEXP.properties.prototype,"ignoreCase",this.UNDEFINED,Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);
|
||||
this.setProperty(this.REGEXP.properties.prototype,"multiline",this.UNDEFINED,Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);this.setProperty(this.REGEXP.properties.prototype,"source",this.createPrimitive("(?:)"),Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);c=function(a){a=a.toString();return b.createPrimitive(this.data.test(a))};this.setNativeFunctionPrototype(this.REGEXP,"test",c);c=function(a){a=a.toString();this.data.lastIndex=b.getProperty(this,"lastIndex").toNumber();a=this.data.exec(a);b.setProperty(this,
|
||||
"lastIndex",b.createPrimitive(this.data.lastIndex));if(a){for(var c=b.createObject(b.ARRAY),d=0;d<a.length;d++)b.setProperty(c,d,b.createPrimitive(a[d]));b.setProperty(c,"index",b.createPrimitive(a.index));b.setProperty(c,"input",b.createPrimitive(a.input));return c}return b.NULL};this.setNativeFunctionPrototype(this.REGEXP,"exec",c)};
|
||||
Interpreter.prototype.initJSON=function(a){var b=this,c=b.createObject(this.OBJECT);this.setProperty(a,"JSON",c);a=function(a){try{var c=JSON.parse(a.toString())}catch(g){b.throwException(b.SYNTAX_ERROR,g.message);return}return b.nativeToPseudo(c)};this.setProperty(c,"parse",this.createNativeFunction(a));a=function(a){a=b.pseudoToNative(a);return b.createPrimitive(JSON.stringify(a))};this.setProperty(c,"stringify",this.createNativeFunction(a))};
|
||||
Interpreter.prototype.initError=function(a){var b=this;this.ERROR=this.createNativeFunction(function(a){var c=this.parent==b.ERROR?this:b.createObject(b.ERROR);a&&b.setProperty(c,"message",b.createPrimitive(String(a)),Interpreter.NONENUMERABLE_DESCRIPTOR);return c});this.setProperty(a,"Error",this.ERROR);this.setProperty(this.ERROR.properties.prototype,"message",this.STRING_EMPTY,Interpreter.NONENUMERABLE_DESCRIPTOR);this.setProperty(this.ERROR.properties.prototype,"name",this.createPrimitive("Error"),
|
||||
Interpreter.NONENUMERABLE_DESCRIPTOR);var c=function(c){var d=b.createNativeFunction(function(a){var c=b.isa(this.parent,b.ERROR)?this:b.createObject(d);a&&b.setProperty(c,"message",b.createPrimitive(String(a)),Interpreter.NONENUMERABLE_DESCRIPTOR);return c});b.setProperty(d,"prototype",b.createObject(b.ERROR));b.setProperty(d.properties.prototype,"name",b.createPrimitive(c),Interpreter.NONENUMERABLE_DESCRIPTOR);b.setProperty(a,c,d);return d};c("EvalError");this.RANGE_ERROR=c("RangeError");this.REFERENCE_ERROR=
|
||||
c("ReferenceError");this.SYNTAX_ERROR=c("SyntaxError");this.TYPE_ERROR=c("TypeError");this.URI_ERROR=c("URIError")};Interpreter.prototype.isa=function(a,b){if(!a||!b)return!1;for(;a.parent!=b;){if(!a.parent||!a.parent.properties.prototype)return!1;a=a.parent.properties.prototype}return!0};
|
||||
Interpreter.prototype.comp=function(a,b){if(a.isPrimitive&&isNaN(a.data)||b.isPrimitive&&isNaN(b.data))return NaN;if(a===b)return 0;a=a.isPrimitive?a.data:a.toString();b=b.isPrimitive?b.data:b.toString();return a<b?-1:a>b?1:0};Interpreter.prototype.arrayIndex=function(a){a=Number(a);return!isFinite(a)||a!=Math.floor(a)||0>a?NaN:a};
|
||||
Interpreter.Primitive=function(a,b){var c=typeof a;this.data=a;this.type=c;"number"==c?this.parent=b.NUMBER:"string"==c?this.parent=b.STRING:"boolean"==c&&(this.parent=b.BOOLEAN)};Interpreter.Primitive.prototype.data=void 0;Interpreter.Primitive.prototype.type="undefined";Interpreter.Primitive.prototype.parent=null;Interpreter.Primitive.prototype.isPrimitive=!0;Interpreter.Primitive.prototype.toBoolean=function(){return!!this.data};Interpreter.Primitive.prototype.toNumber=function(){return Number(this.data)};
|
||||
Interpreter.Primitive.prototype.toString=function(){return String(this.data)};Interpreter.Primitive.prototype.valueOf=function(){return this.data};Interpreter.prototype.createPrimitive=function(a){return void 0===a?this.UNDEFINED:null===a?this.NULL:!0===a?this.TRUE:!1===a?this.FALSE:0===a?this.NUMBER_ZERO:1===a?this.NUMBER_ONE:""===a?this.STRING_EMPTY:a instanceof RegExp?this.populateRegExp_(this.createObject(this.REGEXP),a):new Interpreter.Primitive(a,this)};
|
||||
Interpreter.Object=function(a){this.notConfigurable=Object.create(null);this.notEnumerable=Object.create(null);this.notWritable=Object.create(null);this.getter=Object.create(null);this.setter=Object.create(null);this.properties=Object.create(null);this.parent=a};Interpreter.Object.prototype.type="object";Interpreter.Object.prototype.parent=null;Interpreter.Object.prototype.isPrimitive=!1;Interpreter.Object.prototype.data=void 0;Interpreter.Object.prototype.toBoolean=function(){return!0};
|
||||
Interpreter.Object.prototype.toNumber=function(){return Number(void 0===this.data?this.toString():this.data)};Interpreter.Object.prototype.toString=function(){return void 0===this.data?"["+this.type+"]":String(this.data)};Interpreter.Object.prototype.valueOf=function(){return void 0===this.data?this:this.data};
|
||||
Interpreter.prototype.createObject=function(a){a=new Interpreter.Object(a);this.isa(a,this.FUNCTION)&&(a.type="function",this.setProperty(a,"prototype",this.createObject(this.OBJECT||null)));this.isa(a,this.ARRAY)&&(a.length=0,a.toString=function(){for(var a=[],c=0;c<this.length;c++){var d=this.properties[c];a[c]=!d||d.isPrimitive&&(null===d.data||void 0===d.data)?"":d.toString()}return a.join(",")});return a};
|
||||
Interpreter.prototype.populateRegExp_=function(a,b){a.data=b;this.setProperty(a,"lastIndex",this.createPrimitive(b.lastIndex),Interpreter.NONENUMERABLE_DESCRIPTOR);this.setProperty(a,"source",this.createPrimitive(b.source),Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);this.setProperty(a,"global",this.createPrimitive(b.global),Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);this.setProperty(a,"ignoreCase",this.createPrimitive(b.ignoreCase),Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);this.setProperty(a,
|
||||
"multiline",this.createPrimitive(b.multiline),Interpreter.READONLY_NONENUMERABLE_DESCRIPTOR);a.toString=function(){return String(this.data)};a.valueOf=function(){return this.data};return a};Interpreter.prototype.createFunction=function(a,b){var c=this.createObject(this.FUNCTION);c.parentScope=b||this.getScope();c.node=a;this.setProperty(c,"length",this.createPrimitive(c.node.params.length),Interpreter.READONLY_DESCRIPTOR);return c};
|
||||
Interpreter.prototype.createNativeFunction=function(a){var b=this.createObject(this.FUNCTION);b.nativeFunc=a;this.setProperty(b,"length",this.createPrimitive(a.length),Interpreter.READONLY_DESCRIPTOR);return b};Interpreter.prototype.createAsyncFunction=function(a){var b=this.createObject(this.FUNCTION);b.asyncFunc=a;this.setProperty(b,"length",this.createPrimitive(a.length),Interpreter.READONLY_DESCRIPTOR);return b};
|
||||
Interpreter.prototype.nativeToPseudo=function(a){if("boolean"==typeof a||"number"==typeof a||"string"==typeof a||null===a||void 0===a||a instanceof RegExp)return this.createPrimitive(a);var b;if(a instanceof Array){b=this.createObject(this.ARRAY);for(var c=0;c<a.length;c++)this.setProperty(b,c,this.nativeToPseudo(a[c]))}else for(c in b=this.createObject(this.OBJECT),a)this.setProperty(b,c,this.nativeToPseudo(a[c]));return b};
|
||||
Interpreter.prototype.pseudoToNative=function(a){if(a.isPrimitive||this.isa(a,this.NUMBER)||this.isa(a,this.STRING)||this.isa(a,this.BOOLEAN))return a.data;var b;if(this.isa(a,this.ARRAY)){b=[];for(var c=0;c<a.length;c++)b[c]=this.pseudoToNative(a.properties[c])}else for(c in b={},a.properties)b[c]=this.pseudoToNative(a.properties[c]);return b};
|
||||
Interpreter.prototype.getProperty=function(a,b){b=b.toString();if(a==this.UNDEFINED||a==this.NULL)return this.throwException(this.TYPE_ERROR,"Cannot read property '"+b+"' of "+a),null;if(this.isa(a,this.STRING)){if("length"==b)return this.createPrimitive(a.data.length);var c=this.arrayIndex(b);if(!isNaN(c)&&c<a.data.length)return this.createPrimitive(a.data[c])}else if(this.isa(a,this.ARRAY)&&"length"==b)return this.createPrimitive(a.length);for(;;){if(a.properties&&b in a.properties)return(c=a.getter[b])?
|
||||
(c.isGetter=!0,c):a.properties[b];if(a.parent&&a.parent.properties&&a.parent.properties.prototype)a=a.parent.properties.prototype;else break}return this.UNDEFINED};
|
||||
Interpreter.prototype.hasProperty=function(a,b){b=b.toString();if(a.isPrimitive)throw TypeError("Primitive data type has no properties");if("length"==b&&(this.isa(a,this.STRING)||this.isa(a,this.ARRAY)))return!0;if(this.isa(a,this.STRING)){var c=this.arrayIndex(b);if(!isNaN(c)&&c<a.data.length)return!0}for(;;){if(a.properties&&b in a.properties)return!0;if(a.parent&&a.parent.properties&&a.parent.properties.prototype)a=a.parent.properties.prototype;else break}return!1};
|
||||
Interpreter.prototype.setProperty=function(a,b,c,d){b=b.toString();d&&a.notConfigurable[b]&&this.throwException(this.TYPE_ERROR,"Cannot redefine property: "+b);if("object"!=typeof c)throw Error("Failure to wrap a value: "+c);a!=this.UNDEFINED&&a!=this.NULL||this.throwException(this.TYPE_ERROR,"Cannot set property '"+b+"' of "+a);d&&(d.get||d.set)&&(c||void 0!==d.writable)&&this.throwException(this.TYPE_ERROR,"Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");
|
||||
if(!a.isPrimitive){if(this.isa(a,this.STRING)){var h=this.arrayIndex(b);if("length"==b||!isNaN(h)&&h<a.data.length)return}if(this.isa(a,this.ARRAY)){var g;if("length"==b){b=this.arrayIndex(c.toNumber());isNaN(b)&&this.throwException(this.RANGE_ERROR,"Invalid array length");if(b<a.length)for(g in a.properties)g=this.arrayIndex(g),!isNaN(g)&&b<=g&&delete a.properties[g];a.length=b;return}isNaN(g=this.arrayIndex(b))||(a.length=Math.max(a.length,g+1))}if(!a.properties[b]&&a.preventExtensions)a=this.getScope(),
|
||||
a.strict&&this.throwException(this.TYPE_ERROR,"Can't add property "+b+", object is not extensible");else if(d)a.properties[b]=c,d.configurable||(a.notConfigurable[b]=!0),(c=d.get)?a.getter[b]=c:delete a.getter[b],(g=d.set)?a.setter[b]=g:delete a.setter[b],(h=d.enumerable||!1)?delete a.notEnumerable[b]:a.notEnumerable[b]=!0,c||g?(delete a.notWritable[b],a.properties[b]=this.UNDEFINED):(d=d.writable||!1)?delete a.notWritable[b]:a.notWritable[b]=!0;else{for(d=a;;){if(d.setter&&d.setter[b])return d.setter[b];
|
||||
if(d.parent&&d.parent.properties&&d.parent.properties.prototype)d=d.parent.properties.prototype;else break}a.notWritable[b]||(a.properties[b]=c)}}};Interpreter.prototype.setNativeFunctionPrototype=function(a,b,c){this.setProperty(a.properties.prototype,b,this.createNativeFunction(c),Interpreter.NONENUMERABLE_DESCRIPTOR)};Interpreter.prototype.deleteProperty=function(a,b){b=b.toString();return a.isPrimitive||a.notWritable[b]||"length"==b&&this.isa(a,this.ARRAY)?!1:delete a.properties[b]};
|
||||
Interpreter.prototype.getScope=function(){for(var a=0;a<this.stateStack.length;a++)if(this.stateStack[a].scope)return this.stateStack[a].scope;throw Error("No scope found.");};Interpreter.prototype.createScope=function(a,b){var c=this.createObject(null);(c.parentScope=b)||this.initGlobalScope(c);this.populateScope_(a,c);c.strict=!1;b&&b.strict?c.strict=!0:(a=a.body&&a.body[0])&&a.expression&&"Literal"==a.expression.type&&"use strict"==a.expression.value&&(c.strict=!0);return c};
|
||||
Interpreter.prototype.createSpecialScope=function(a,b){if(!a)throw Error("parentScope required");b=b||this.createObject(null);b.parentScope=a;b.strict=a.strict;return b};Interpreter.prototype.getValueFromScope=function(a){var b=this.getScope();for(a=a.toString();b;){if(a in b.properties)return b.properties[a];b=b.parentScope}this.throwException(this.REFERENCE_ERROR,a+" is not defined");return null};
|
||||
Interpreter.prototype.setValueToScope=function(a,b){var c=this.getScope(),d=c.strict;for(a=a.toString();c;){if(a in c.properties||!d&&!c.parentScope){c.notWritable[a]||(c.properties[a]=b);return}c=c.parentScope}this.throwException(this.REFERENCE_ERROR,a+" is not defined")};
|
||||
Interpreter.prototype.populateScope_=function(a,b){if("VariableDeclaration"==a.type)for(var c=0;c<a.declarations.length;c++)this.setProperty(b,a.declarations[c].id.name,this.UNDEFINED);else{if("FunctionDeclaration"==a.type){this.setProperty(b,a.id.name,this.createFunction(a,b));return}if("FunctionExpression"==a.type)return}var d=a.constructor,h;for(h in a){var g=a[h];if(g&&"object"==typeof g)if(g instanceof Array)for(c=0;c<g.length;c++)g[c]&&g[c].constructor==d&&this.populateScope_(g[c],b);else g.constructor==
|
||||
d&&this.populateScope_(g,b)}};Interpreter.prototype.stripLocations_=function(a){delete a.start;delete a.end;for(var b in a)if(a.hasOwnProperty(b)){var c=a[b];c&&"object"==typeof c&&this.stripLocations_(c)}};Interpreter.prototype.getValue=function(a){if(a instanceof Array){var b=a[0];a=a[1];return this.getProperty(b,a)}return this.getValueFromScope(a)};Interpreter.prototype.setValue=function(a,b){if(a instanceof Array){var c=a[0];a=a[1];return this.setProperty(c,a,b)}this.setValueToScope(a,b)};
|
||||
Interpreter.prototype.throwException=function(a,b){if(this.stateStack[0].interpreter)try{this.stateStack[0].interpreter.throwException(a,b);return}catch(c){}void 0!==b&&(a=this.createObject(a),this.setProperty(a,"message",this.createPrimitive(b),Interpreter.NONENUMERABLE_DESCRIPTOR));this.executeException(a)};
|
||||
Interpreter.prototype.executeException=function(a){do{this.stateStack.shift();var b=this.stateStack[0];if("TryStatement"==b.node.type){b.throwValue=a;return}}while(b&&"Program"!=b.node.type);if(this.isa(a,this.ERROR)){var b={EvalError:EvalError,RangeError:RangeError,ReferenceError:ReferenceError,SyntaxError:SyntaxError,TypeError:TypeError,URIError:URIError},c=this.getProperty(a,"name").toString();a=this.getProperty(a,"message").valueOf();b=b[c]||Error;a=b(a)}else a=a.toString();throw a;};
|
||||
Interpreter.prototype.stepArrayExpression=function(){var a=this.stateStack[0],b=a.node,c=a.n||0;a.array?a.value&&this.setProperty(a.array,c-1,a.value):a.array=this.createObject(this.ARRAY);c<b.elements.length?(a.n=c+1,b.elements[c]?this.stateStack.unshift({node:b.elements[c]}):a.value=void 0):(a.array.length=a.n||0,this.stateStack.shift(),this.stateStack[0].value=a.array)};
|
||||
Interpreter.prototype.stepAssignmentExpression=function(){var a=this.stateStack[0],b=a.node;if(a.doneLeft)if(a.doneRight)if(a.doneSetter_)this.stateStack.shift(),this.stateStack[0].value=a.doneSetter_;else{var c=a.value;if("="==b.operator)b=c;else{var d=a.leftValue.toNumber(),h=c.toNumber();if("+="==b.operator)"string"==a.leftValue.type||"string"==c.type?(b=a.leftValue.toString(),c=c.toString()):(b=d,c=h),b+=c;else if("-="==b.operator)b=d-h;else if("*="==b.operator)b=d*h;else if("/="==b.operator)b=
|
||||
d/h;else if("%="==b.operator)b=d%h;else if("<<="==b.operator)b=d<<h;else if(">>="==b.operator)b=d>>h;else if(">>>="==b.operator)b=d>>>h;else if("&="==b.operator)b=d&h;else if("^="==b.operator)b=d^h;else if("|="==b.operator)b=d|h;else throw SyntaxError("Unknown assignment expression: "+b.operator);b=this.createPrimitive(b)}(c=this.setValue(a.leftSide,b))?(a.doneSetter_=b,this.stateStack.unshift({node:{type:"CallExpression"},doneCallee_:!0,funcThis_:a.leftSide[0],func_:c,doneArgs_:!0,arguments:[b]})):
|
||||
(this.stateStack.shift(),this.stateStack[0].value=b)}else{a.leftSide||(a.leftSide=a.value);a.doneGetter_&&(a.leftValue=a.value);if(!a.doneGetter_&&"="!=b.operator&&(a.leftValue=this.getValue(a.leftSide),a.leftValue.isGetter)){a.leftValue.isGetter=!1;a.doneGetter_=!0;this.stateStack.unshift({node:{type:"CallExpression"},doneCallee_:!0,funcThis_:a.leftSide[0],func_:a.leftValue,doneArgs_:!0,arguments:[]});return}a.doneRight=!0;this.stateStack.unshift({node:b.right})}else a.doneLeft=!0,this.stateStack.unshift({node:b.left,
|
||||
components:!0})};
|
||||
Interpreter.prototype.stepBinaryExpression=function(){var a=this.stateStack[0],b=a.node;if(a.doneLeft)if(a.doneRight){this.stateStack.shift();var c=a.leftValue,a=a.value,d=this.comp(c,a);if("=="==b.operator||"!="==b.operator)c=c.isPrimitive&&a.isPrimitive?c.data==a.data:0===d,"!="==b.operator&&(c=!c);else if("==="==b.operator||"!=="==b.operator)c=c.isPrimitive&&a.isPrimitive?c.data===a.data:c===a,"!=="==b.operator&&(c=!c);else if(">"==b.operator)c=1==d;else if(">="==b.operator)c=1==d||0===d;else if("<"==
|
||||
b.operator)c=-1==d;else if("<="==b.operator)c=-1==d||0===d;else if("+"==b.operator)c=c.isPrimitive?c.data:c.toString(),a=a.isPrimitive?a.data:a.toString(),c+=a;else if("in"==b.operator)c=this.hasProperty(a,c);else if("instanceof"==b.operator)this.isa(a,this.FUNCTION)||this.throwException(this.TYPE_ERROR,"Expecting a function in instanceof check"),c=this.isa(c,a);else if(c=c.toNumber(),a=a.toNumber(),"-"==b.operator)c-=a;else if("*"==b.operator)c*=a;else if("/"==b.operator)c/=a;else if("%"==b.operator)c%=
|
||||
a;else if("&"==b.operator)c&=a;else if("|"==b.operator)c|=a;else if("^"==b.operator)c^=a;else if("<<"==b.operator)c<<=a;else if(">>"==b.operator)c>>=a;else if(">>>"==b.operator)c>>>=a;else throw SyntaxError("Unknown binary operator: "+b.operator);this.stateStack[0].value=this.createPrimitive(c)}else a.doneRight=!0,a.leftValue=a.value,this.stateStack.unshift({node:b.right});else a.doneLeft=!0,this.stateStack.unshift({node:b.left})};
|
||||
Interpreter.prototype.stepBlockStatement=function(){var a=this.stateStack[0],b=a.node,c=a.n_||0;b.body[c]?(a.done=!1,a.n_=c+1,this.stateStack.unshift({node:b.body[c]})):(a.done=!0,"Program"!=a.node.type&&this.stateStack.shift())};
|
||||
Interpreter.prototype.stepBreakStatement=function(){var a=this.stateStack.shift(),a=a.node,b=null;a.label&&(b=a.label.name);for(a=this.stateStack.shift();a&&"CallExpression"!=a.node.type&&"NewExpression"!=a.node.type;){if(b?b==a.label:a.isLoop||a.isSwitch)return;a=this.stateStack.shift()}throw SyntaxError("Illegal break statement");};
|
||||
Interpreter.prototype.stepCallExpression=function(){var a=this.stateStack[0],b=a.node;if(a.doneCallee_){if(!a.func_){if("function"==a.value.type)a.func_=a.value;else{a.value.length&&(a.member_=a.value[0]);a.func_=this.getValue(a.value);if(!a.func_)return;if("function"!=a.func_.type){this.throwException(this.TYPE_ERROR,(a.value&&a.value.type)+" is not a function");return}}"NewExpression"==a.node.type?(a.funcThis_=this.createObject(a.func_),a.isConstructor_=!0):a.funcThis_=a.func_.boundThis_?a.func_.boundThis_:
|
||||
a.value.length?a.value[0]:this.stateStack[this.stateStack.length-1].thisExpression;a.arguments=a.func_.boundArgs_?a.func_.boundArgs_.concat():[];a.n_=0}if(!a.doneArgs_){0!=a.n_&&a.arguments.push(a.value);if(b.arguments[a.n_]){this.stateStack.unshift({node:b.arguments[a.n_]});a.n_++;return}a.doneArgs_=!0}if(a.doneExec_)this.stateStack.shift(),this.stateStack[0].value=a.isConstructor_&&"object"!==a.value.type?a.funcThis_:a.value;else if(a.doneExec_=!0,a.func_.node){for(var b=this.createScope(a.func_.node.body,
|
||||
a.func_.parentScope),c=0;c<a.func_.node.params.length;c++){var d=this.createPrimitive(a.func_.node.params[c].name),h=a.arguments.length>c?a.arguments[c]:this.UNDEFINED;this.setProperty(b,d,h)}d=this.createObject(this.ARRAY);for(c=0;c<a.arguments.length;c++)this.setProperty(d,this.createPrimitive(c),a.arguments[c]);this.setProperty(b,"arguments",d);b={node:a.func_.node.body,scope:b,thisExpression:a.funcThis_};this.stateStack.unshift(b);a.value=this.UNDEFINED}else if(a.func_.nativeFunc)a.value=a.func_.nativeFunc.apply(a.funcThis_,
|
||||
a.arguments);else if(a.func_.asyncFunc){var g=this,b=function(b){a.value=b||g.UNDEFINED;g.paused_=!1},b=a.arguments.concat(b);a.func_.asyncFunc.apply(a.funcThis_,b);this.paused_=!0}else if(a.func_.eval)(b=a.arguments[0])?b.isPrimitive?(b=new Interpreter(b.toString()),b.stateStack[0].scope=this.getScope(),a={node:{type:"Eval_"},interpreter:b},this.stateStack.unshift(a)):a.value=b:a.value=this.UNDEFINED;else throw TypeError("function not a function (huh?)");}else a.doneCallee_=!0,this.stateStack.unshift({node:b.callee,
|
||||
components:!0})};Interpreter.prototype.stepCatchClause=function(){var a=this.stateStack[0],b=a.node;if(a.doneBody)this.stateStack.shift();else{a.doneBody=!0;var c;if(b.param){c=this.createSpecialScope(this.getScope());var d=this.createPrimitive(b.param.name);this.setProperty(c,d,a.throwValue)}this.stateStack.unshift({node:b.body,scope:c})}};
|
||||
Interpreter.prototype.stepConditionalExpression=function(){var a=this.stateStack[0];a.done?(this.stateStack.shift(),"ConditionalExpression"==a.node.type&&(this.stateStack[0].value=a.value)):a.test?(a.done=!0,a.value.toBoolean()&&a.node.consequent?this.stateStack.unshift({node:a.node.consequent}):!a.value.toBoolean()&&a.node.alternate&&this.stateStack.unshift({node:a.node.alternate})):(a.test=!0,this.stateStack.unshift({node:a.node.test}))};
|
||||
Interpreter.prototype.stepContinueStatement=function(){var a=this.stateStack[0].node,b=null;a.label&&(b=a.label.name);for(a=this.stateStack[0];a&&"CallExpression"!=a.node.type&&"NewExpression"!=a.node.type;){if(a.isLoop&&(!b||b==a.label))return;this.stateStack.shift();a=this.stateStack[0]}throw SyntaxError("Illegal continue statement");};
|
||||
Interpreter.prototype.stepDoWhileStatement=function(){var a=this.stateStack[0];a.isLoop=!0;"DoWhileStatement"==a.node.type&&void 0===a.test&&(a.value=this.TRUE,a.test=!0);a.test?(a.test=!1,a.value.toBoolean()?a.node.body&&this.stateStack.unshift({node:a.node.body}):this.stateStack.shift()):(a.test=!0,this.stateStack.unshift({node:a.node.test}))};Interpreter.prototype.stepEmptyStatement=function(){this.stateStack.shift()};
|
||||
Interpreter.prototype.stepEval_=function(){var a=this.stateStack[0];a.interpreter.step()||(this.stateStack.shift(),this.stateStack[0].value=a.interpreter.value||this.UNDEFINED)};Interpreter.prototype.stepExpressionStatement=function(){var a=this.stateStack[0];a.done?(this.stateStack.shift(),this.value=a.value):(a.done=!0,this.stateStack.unshift({node:a.node.expression}))};
|
||||
Interpreter.prototype.stepForInStatement=function(){var a=this.stateStack[0];a.isLoop=!0;var b=a.node;if(a.doneVariable_)if(a.doneObject_){"undefined"==typeof a.iterator&&(a.object=a.value,a.iterator=0);var c=null;a:do{var d=a.iterator,h;for(h in a.object.properties)if(!a.object.notEnumerable[h]){if(0==d){c=h;break a}d--}a.object=a.object.parent&&a.object.parent.properties.prototype;a.iterator=0}while(a.object);a.iterator++;null===c?this.stateStack.shift():(this.setValueToScope(a.variable,this.createPrimitive(c)),
|
||||
b.body&&this.stateStack.unshift({node:b.body}))}else a.doneObject_=!0,a.variable=a.value,this.stateStack.unshift({node:b.right});else a.doneVariable_=!0,a=b.left,"VariableDeclaration"==a.type&&(a=a.declarations[0].id),this.stateStack.unshift({node:a,components:!0})};
|
||||
Interpreter.prototype.stepForStatement=function(){var a=this.stateStack[0];a.isLoop=!0;var b=a.node,c=a.mode||0;0==c?(a.mode=1,b.init&&this.stateStack.unshift({node:b.init})):1==c?(a.mode=2,b.test&&this.stateStack.unshift({node:b.test})):2==c?(a.mode=3,b.test&&a.value&&!a.value.toBoolean()?this.stateStack.shift():b.body&&this.stateStack.unshift({node:b.body})):3==c&&(a.mode=1,b.update&&this.stateStack.unshift({node:b.update}))};Interpreter.prototype.stepFunctionDeclaration=function(){this.stateStack.shift()};
|
||||
Interpreter.prototype.stepFunctionExpression=function(){var a=this.stateStack.shift();this.stateStack[0].value=this.createFunction(a.node)};Interpreter.prototype.stepIdentifier=function(){var a=this.stateStack.shift(),b=this.createPrimitive(a.node.name);this.stateStack[0].value=a.components?b:this.getValueFromScope(b)};Interpreter.prototype.stepIfStatement=Interpreter.prototype.stepConditionalExpression;
|
||||
Interpreter.prototype.stepLabeledStatement=function(){var a=this.stateStack.shift();this.stateStack.unshift({node:a.node.body,label:a.node.label.name})};Interpreter.prototype.stepLiteral=function(){var a=this.stateStack.shift();this.stateStack[0].value=this.createPrimitive(a.node.value)};
|
||||
Interpreter.prototype.stepLogicalExpression=function(){var a=this.stateStack[0],b=a.node;if("&&"!=b.operator&&"||"!=b.operator)throw SyntaxError("Unknown logical operator: "+b.operator);a.doneLeft_?a.doneRight_?(this.stateStack.shift(),this.stateStack[0].value=a.value):"&&"==b.operator&&!a.value.toBoolean()||"||"==b.operator&&a.value.toBoolean()?(this.stateStack.shift(),this.stateStack[0].value=a.value):(a.doneRight_=!0,this.stateStack.unshift({node:b.right})):(a.doneLeft_=!0,this.stateStack.unshift({node:b.left}))};
|
||||
Interpreter.prototype.stepMemberExpression=function(){var a=this.stateStack[0],b=a.node;a.doneObject_?a.doneProperty_?(this.stateStack.shift(),a.components?this.stateStack[0].value=[a.object,a.value]:(b=this.getProperty(a.object,a.value))?b.isGetter?(b.isGetter=!1,this.stateStack.unshift({node:{type:"CallExpression"},doneCallee_:!0,funcThis_:a.object,func_:b,doneArgs_:!0,arguments:[]})):this.stateStack[0].value=b:(this.stateStack.unshift({}),this.throwException(this.TYPE_ERROR,"Cannot read property '"+
|
||||
a.value+"' of "+a.object.toString()))):(a.doneProperty_=!0,a.object=a.value,this.stateStack.unshift({node:b.property,components:!b.computed})):(a.doneObject_=!0,this.stateStack.unshift({node:b.object}))};Interpreter.prototype.stepNewExpression=Interpreter.prototype.stepCallExpression;
|
||||
Interpreter.prototype.stepObjectExpression=function(){var a=this.stateStack[0],b=a.node,c=a.valueToggle,d=a.n||0;a.object?c?a.key=a.value:(a.properties[a.key]||(a.properties[a.key]={}),a.properties[a.key][a.kind]=a.value):(a.object=this.createObject(this.OBJECT),a.properties=Object.create(null));if(b.properties[d])c?(a.n=d+1,this.stateStack.unshift({node:b.properties[d].value})):(a.kind=b.properties[d].kind,this.stateStack.unshift({node:b.properties[d].key,components:!0})),a.valueToggle=!c;else{for(var h in a.properties)b=
|
||||
a.properties[h],"get"in b||"set"in b?(b={configurable:!0,enumerable:!0,get:b.get,set:b.set},this.setProperty(a.object,h,null,b)):this.setProperty(a.object,h,b.init);this.stateStack.shift();this.stateStack[0].value=a.object}};Interpreter.prototype.stepProgram=Interpreter.prototype.stepBlockStatement;
|
||||
Interpreter.prototype.stepReturnStatement=function(){var a=this.stateStack[0],b=a.node;if(b.argument&&!a.done)a.done=!0,this.stateStack.unshift({node:b.argument});else{b=a.value||this.UNDEFINED;do{this.stateStack.shift();if(0==this.stateStack.length)throw SyntaxError("Illegal return statement");a=this.stateStack[0]}while("CallExpression"!=a.node.type&&"NewExpression"!=a.node.type);a.value=b}};
|
||||
Interpreter.prototype.stepSequenceExpression=function(){var a=this.stateStack[0],b=a.node,c=a.n||0;b.expressions[c]?(a.n=c+1,this.stateStack.unshift({node:b.expressions[c]})):(this.stateStack.shift(),this.stateStack[0].value=a.value)};
|
||||
Interpreter.prototype.stepSwitchStatement=function(){var a=this.stateStack[0];a.checked=a.checked||[];a.isSwitch=!0;if(a.test){a.switchValue||(a.switchValue=a.value);var b=a.index||0,c=a.node.cases[b];if(c)if(a.done||a.checked[b]||!c.test){if(a.done||!c.test||0==this.comp(a.value,a.switchValue)){a.done=!0;var d=a.n||0;if(c.consequent[d]){this.stateStack.unshift({node:c.consequent[d]});a.n=d+1;return}}a.n=0;a.index=b+1}else a.checked[b]=!0,this.stateStack.unshift({node:c.test});else this.stateStack.shift()}else a.test=
|
||||
!0,this.stateStack.unshift({node:a.node.discriminant})};Interpreter.prototype.stepThisExpression=function(){this.stateStack.shift();for(var a=0;a<this.stateStack.length;a++)if(this.stateStack[a].thisExpression){this.stateStack[0].value=this.stateStack[a].thisExpression;return}throw Error("No this expression found.");};Interpreter.prototype.stepThrowStatement=function(){var a=this.stateStack[0],b=a.node;a.argument?this.throwException(a.value):(a.argument=!0,this.stateStack.unshift({node:b.argument}))};
|
||||
Interpreter.prototype.stepTryStatement=function(){var a=this.stateStack[0],b=a.node;a.doneBlock?a.throwValue&&!a.doneHandler&&b.handler?(a.doneHandler=!0,this.stateStack.unshift({node:b.handler,throwValue:a.throwValue}),a.throwValue=null):!a.doneFinalizer&&b.finalizer?(a.doneFinalizer=!0,this.stateStack.unshift({node:b.finalizer})):a.throwValue?this.executeException(a.throwValue):this.stateStack.shift():(a.doneBlock=!0,this.stateStack.unshift({node:b.block}))};
|
||||
Interpreter.prototype.stepUnaryExpression=function(){var a=this.stateStack[0],b=a.node;if(a.done){this.stateStack.shift();if("-"==b.operator)b=-a.value.toNumber();else if("+"==b.operator)b=a.value.toNumber();else if("!"==b.operator)b=!a.value.toBoolean();else if("~"==b.operator)b=~a.value.toNumber();else if("delete"==b.operator||"typeof"==b.operator){if(a.value.length)var c=a.value[0],a=a.value[1];else c=this.getScope(),a=a.value;b="delete"==b.operator?this.deleteProperty(c,a):this.getProperty(c,
|
||||
a).type}else if("void"==b.operator)b=void 0;else throw SyntaxError("Unknown unary operator: "+b.operator);this.stateStack[0].value=this.createPrimitive(b)}else{a.done=!0;c={node:b.argument};if("delete"==b.operator||"typeof"==b.operator)c.components=!0;this.stateStack.unshift(c)}};
|
||||
Interpreter.prototype.stepUpdateExpression=function(){var a=this.stateStack[0],b=a.node;if(a.doneLeft){a.leftSide||(a.leftSide=a.value);a.doneGetter_&&(a.leftValue=a.value);if(!a.doneGetter_){a.leftValue=this.getValue(a.leftSide);if(!a.leftValue)return;if(a.leftValue.isGetter){a.leftValue.isGetter=!1;a.doneGetter_=!0;this.stateStack.unshift({node:{type:"CallExpression"},doneCallee_:!0,funcThis_:a.leftSide[0],func_:a.leftValue,doneArgs_:!0,arguments:[]});return}}if(a.doneSetter_)this.stateStack.shift(),
|
||||
this.stateStack[0].value=a.doneSetter_;else{var c=a.leftValue.toNumber(),d;if("++"==b.operator)d=this.createPrimitive(c+1);else if("--"==b.operator)d=this.createPrimitive(c-1);else throw SyntaxError("Unknown update expression: "+b.operator);b=b.prefix?d:this.createPrimitive(c);(c=this.setValue(a.leftSide,d))?(a.doneSetter_=b,this.stateStack.unshift({node:{type:"CallExpression"},doneCallee_:!0,funcThis_:a.leftSide[0],func_:c,doneArgs_:!0,arguments:[d]})):(this.stateStack.shift(),this.stateStack[0].value=
|
||||
b)}}else a.doneLeft=!0,this.stateStack.unshift({node:b.argument,components:!0})};Interpreter.prototype.stepVariableDeclaration=function(){var a=this.stateStack[0],b=a.node,c=a.n||0;b.declarations[c]?(a.n=c+1,this.stateStack.unshift({node:b.declarations[c]})):this.stateStack.shift()};
|
||||
Interpreter.prototype.stepVariableDeclarator=function(){var a=this.stateStack[0],b=a.node;b.init&&!a.done?(a.done=!0,this.stateStack.unshift({node:b.init})):(b.init&&this.setValue(this.createPrimitive(b.id.name),a.value),this.stateStack.shift())};
|
||||
Interpreter.prototype.stepWithStatement=function(){var a=this.stateStack[0],b=a.node;a.doneObject?a.doneBody?this.stateStack.shift():(a.doneBody=!0,a=this.createSpecialScope(this.getScope(),a.value),this.stateStack.unshift({node:b.body,scope:a})):(a.doneObject=!0,this.stateStack.unshift({node:b.object}))};Interpreter.prototype.stepWhileStatement=Interpreter.prototype.stepDoWhileStatement;this.Interpreter=Interpreter;Interpreter.prototype.appendCode=Interpreter.prototype.appendCode;
|
||||
Interpreter.prototype.createAsyncFunction=Interpreter.prototype.createAsyncFunction;Interpreter.prototype.step=Interpreter.prototype.step;Interpreter.prototype.run=Interpreter.prototype.run;
|
||||
function u(a,b){"string"===typeof a&&(a=acorn.parse(a,ha));this.ha=a;this.ib=b;this.ya=!1;this.V=[];this.Da=0;this.nb=Object.create(null);var c=/^step([A-Z]\w*)$/,d,e;for(e in this)"function"===typeof this[e]&&(d=e.match(c))&&(this.nb[d[1]]=this[e].bind(this));this.global=ia(this,this.ha,null);this.ha=acorn.parse(this.V.join("\n"),ha);this.V=void 0;ra(this,this.ha,void 0,void 0);c=new y(this.ha,this.global);c.done=!1;this.j=[c];this.lb();this.value=void 0;this.ha=a;c=new y(this.ha,this.global);c.done=
|
||||
!1;this.j.length=0;this.j[0]=c;this.Ra=c.node.constructor;this.stateStack=this.j}
|
||||
var ha={Ca:5},sa={configurable:!0,enumerable:!0,writable:!1},A={configurable:!0,enumerable:!1,writable:!0},E={configurable:!0,enumerable:!1,writable:!1},za={configurable:!1,enumerable:!0,writable:!0},Aa={STEP_ERROR:!0},Ba={SCOPE_REFERENCE:!0},Ha={VALUE_IN_DESCRIPTOR:!0},Ia={REGEXP_TIMEOUT:!0},Ja=[],Ka=null,La=["onmessage = function(e) {","var result;","var data = e.data;","switch (data[0]) {","case 'split':","result = data[1].split(data[2], data[3]);","break;","case 'match':","result = data[1].match(data[2]);",
|
||||
"break;","case 'search':","result = data[1].search(data[2]);","break;","case 'replace':","result = data[1].replace(data[2], data[3]);","break;","case 'exec':","var regexp = data[1];","regexp.lastIndex = data[2];","result = [regexp.exec(data[3]), data[1].lastIndex];","break;","default:","throw 'Unknown RegExp operation: ' + data[0];","}","postMessage(result);","};"];u.prototype.REGEXP_MODE=2;u.prototype.REGEXP_THREAD_TIMEOUT=1E3;
|
||||
u.prototype.sb=function(a){var b=this.j[0];if(!b||"Program"!==b.node.type)throw Error("Expecting original AST to start with a Program node.");"string"===typeof a&&(a=acorn.parse(a,ha));if(!a||"Program"!==a.type)throw Error("Expecting new AST to start with a Program node.");Ma(this,a,b.scope);for(var c=0,d;d=a.body[c];c++)b.node.body.push(d);b.done=!1};
|
||||
u.prototype.step=function(){var a=this.j,b=a[a.length-1];if(!b)return!1;var c=b.node,d=c.type;if("Program"===d&&b.done)return!1;if(this.ya)return!0;try{var e=this.nb[d](a,b,c)}catch(g){if(g!==Aa)throw g;}e&&a.push(e);return c.end?!0:this.step()};u.prototype.lb=function(){for(;!this.ya&&this.step(););return this.ya};
|
||||
function Na(a,b){a.setProperty(b,"NaN",NaN,sa);a.setProperty(b,"Infinity",Infinity,sa);a.setProperty(b,"undefined",void 0,sa);a.setProperty(b,"window",b,sa);a.setProperty(b,"this",b,sa);a.setProperty(b,"self",b);a.G=new Oa(null);a.I=new Oa(a.G);Pa(a,b);cb(a,b);b.oa=a.G;a.setProperty(b,"constructor",a.m,A);db(a,b);Eb(a,b);Fb(a,b);Gb(a,b);Hb(a,b);Ib(a,b);Jb(a,b);Kb(a,b);Lb(a,b);var c=a.b(function(){throw EvalError("Can't happen");},!1);c.eval=!0;a.setProperty(b,"eval",c);a.setProperty(b,"parseInt",
|
||||
a.b(parseInt,!1));a.setProperty(b,"parseFloat",a.b(parseFloat,!1));a.setProperty(b,"isNaN",a.b(isNaN,!1));a.setProperty(b,"isFinite",a.b(isFinite,!1));c=[[escape,"escape"],[unescape,"unescape"],[decodeURI,"decodeURI"],[decodeURIComponent,"decodeURIComponent"],[encodeURI,"encodeURI"],[encodeURIComponent,"encodeURIComponent"]];for(var d=0;d<c.length;d++)a.setProperty(b,c[d][1],a.b(function(e){return function(g){try{return e(g)}catch(l){J(a,a.pb,l.message)}}}(c[d][0]),!1),A);a.OBJECT=a.m;a.OBJECT_PROTO=
|
||||
a.G;a.FUNCTION=a.C;a.FUNCTION_PROTO=a.I;a.ARRAY=a.l;a.ARRAY_PROTO=a.ea;a.REGEXP=a.D;a.REGEXP_PROTO=a.Aa;a.DATE=a.S;a.DATE_PROTO=a.Xa;a.UNDEFINED=void 0;a.NULL=null;a.NAN=NaN;a.TRUE=!0;a.FALSE=!1;a.STRING_EMPTY="";a.NUMBER_ZERO=0;a.NUMBER_ONE=1;a.ib&&a.ib(a,b)}
|
||||
function Pa(a,b){function c(g){if(!(g&&g.o||Mb(a).H))if(void 0===g||null===g)g=a.global;else{var l=a.g(uc(a,g));l.data=g;g=l}return g}var d=/^[A-Za-z_$][\w$]*$/;var e=function(g){var l=vc(a)?this:a.g(a.I),q=arguments.length?String(arguments[arguments.length-1]):"",v=Array.prototype.slice.call(arguments,0,-1).join(",").trim();if(v){v=v.split(/\s*,\s*/);for(var D=0;D<v.length;D++){var B=v[D];d.test(B)||J(a,a.fa,"Invalid function argument: "+B)}v=v.join(", ")}l.ca=a.global;try{var ca=acorn.parse("(function("+
|
||||
v+") {"+q+"})",ha)}catch(na){J(a,a.fa,"Invalid code: "+na.message)}1!==ca.body.length&&J(a,a.fa,"Invalid code in function body.");l.node=ca.body[0].expression;a.setProperty(l,"length",l.node.length,E);return l};e.id=a.Da++;a.C=a.g(a.I);a.setProperty(b,"Function",a.C);a.setProperty(a.C,"prototype",a.I,A);a.C.xa=e;a.setProperty(a.I,"constructor",a.C,A);a.I.xa=function(){};a.I.xa.id=a.Da++;a.setProperty(a.I,"length",0,E);e=function(g,l){var q=a.j[a.j.length-1];q.Z=this;q.J=c(g);q.B=[];if(null!==l&&void 0!==
|
||||
l)if(l.o){var v=[],D;for(D in l.a)v[D]=a.v(l,D);v.length=wc(a.v(l,"length"))||0;q.B=v}else J(a,a.h,"CreateListFromArrayLike called on non-object");q.Pa=!1};M(a,a.C,"apply",e);e=function(g){var l=a.j[a.j.length-1];l.Z=this;l.J=c(g);l.B=[];for(var q=1;q<arguments.length;q++)l.B.push(arguments[q]);l.Pa=!1};M(a,a.C,"call",e);a.V.push("Object.defineProperty(Function.prototype, 'bind',","{configurable: true, writable: true, value:","function(oThis) {","if (typeof this !== 'function') {","throw TypeError('What is trying to be bound is not callable');",
|
||||
"}","var aArgs = Array.prototype.slice.call(arguments, 1),","fToBind = this,","fNOP = function() {},","fBound = function() {","return fToBind.apply(this instanceof fNOP","? this",": oThis,","aArgs.concat(Array.prototype.slice.call(arguments)));","};","if (this.prototype) {","fNOP.prototype = this.prototype;","}","fBound.prototype = new fNOP();","return fBound;","}","});","");e=function(){return String(this)};M(a,a.C,"toString",e);a.setProperty(a.C,"toString",a.b(e,!1),A);e=function(){return this.valueOf()};
|
||||
M(a,a.C,"valueOf",e);a.setProperty(a.C,"valueOf",a.b(e,!1),A)}
|
||||
function cb(a,b){function c(e){void 0!==e&&null!==e||J(a,a.h,"Cannot convert '"+e+"' to object")}var d=function(e){if(void 0===e||null===e)return vc(a)?this:a.g(a.G);if(!e.o){var g=a.g(uc(a,e));g.data=e;return g}return e};a.m=a.b(d,!0);a.setProperty(a.m,"prototype",a.G,A);a.setProperty(a.G,"constructor",a.m,A);a.setProperty(b,"Object",a.m);d=function(e){c(e);return P(a,Object.getOwnPropertyNames(e.o?e.a:e))};a.setProperty(a.m,"getOwnPropertyNames",a.b(d,!1),A);d=function(e){c(e);e.o&&(e=e.a);return P(a,
|
||||
Object.keys(e))};a.setProperty(a.m,"keys",a.b(d,!1),A);d=function(e){if(null===e)return a.g(null);void 0!==e&&e.o||J(a,a.h,"Object prototype may only be an Object or null");return a.g(e)};a.setProperty(a.m,"create",a.b(d,!1),A);a.V.push("(function() {","var create_ = Object.create;","Object.create = function(proto, props) {","var obj = create_(proto);","props && Object.defineProperties(obj, props);","return obj;","};","})();","");d=function(e,g,l){g=String(g);e&&e.o||J(a,a.h,"Object.defineProperty called on non-object");
|
||||
l&&l.o||J(a,a.h,"Property description must be an object");!e.a[g]&&e.preventExtensions&&J(a,a.h,"Can't define property '"+g+"', object is not extensible");a.setProperty(e,g,Ha,l.a);return e};a.setProperty(a.m,"defineProperty",a.b(d,!1),A);a.V.push("(function() {","var defineProperty_ = Object.defineProperty;","Object.defineProperty = function(obj, prop, d1) {","var d2 = {};","if ('configurable' in d1) d2.configurable = d1.configurable;","if ('enumerable' in d1) d2.enumerable = d1.enumerable;","if ('writable' in d1) d2.writable = d1.writable;",
|
||||
"if ('value' in d1) d2.value = d1.value;","if ('get' in d1) d2.get = d1.get;","if ('set' in d1) d2.set = d1.set;","return defineProperty_(obj, prop, d2);","};","})();","Object.defineProperty(Object, 'defineProperties',","{configurable: true, writable: true, value:","function(obj, props) {","var keys = Object.keys(props);","for (var i = 0; i < keys.length; i++) {","Object.defineProperty(obj, keys[i], props[keys[i]]);","}","return obj;","}","});","");d=function(e,g){e&&e.o||J(a,a.h,"Object.getOwnPropertyDescriptor called on non-object");
|
||||
g=String(g);if(g in e.a){var l=Object.getOwnPropertyDescriptor(e.a,g),q=e.O[g],v=e.R[g];if(q||v)l.get=q,l.set=v,delete l.value,delete l.writable;q=l.value;v="value"in l;delete l.value;l=a.la(l);v&&a.setProperty(l,"value",q);return l}};a.setProperty(a.m,"getOwnPropertyDescriptor",a.b(d,!1),A);d=function(e){c(e);return uc(a,e)};a.setProperty(a.m,"getPrototypeOf",a.b(d,!1),A);d=function(e){return!!e&&!e.preventExtensions};a.setProperty(a.m,"isExtensible",a.b(d,!1),A);d=function(e){e&&e.o&&(e.preventExtensions=
|
||||
!0);return e};a.setProperty(a.m,"preventExtensions",a.b(d,!1),A);M(a,a.m,"toString",Oa.prototype.toString);M(a,a.m,"toLocaleString",Oa.prototype.toString);M(a,a.m,"valueOf",Oa.prototype.valueOf);d=function(e){c(this);return this.o?String(e)in this.a:this.hasOwnProperty(e)};M(a,a.m,"hasOwnProperty",d);d=function(e){c(this);return this.o?Object.prototype.propertyIsEnumerable.call(this.a,e):this.propertyIsEnumerable(e)};M(a,a.m,"propertyIsEnumerable",d);d=function(e){for(;;){e=uc(a,e);if(!e)return!1;
|
||||
if(e===this)return!0}};M(a,a.m,"isPrototypeOf",d)}
|
||||
function db(a,b){var c=function(d){var e=vc(a)?this:a.g(a.ea),g=arguments[0];if(1===arguments.length&&"number"===typeof g)isNaN(wc(g))&&J(a,a.Ya,"Invalid array length"),e.a.length=g;else{for(g=0;g<arguments.length;g++)e.a[g]=arguments[g];e.a.length=g}return e};a.l=a.b(c,!0);a.ea=a.l.a.prototype;a.setProperty(b,"Array",a.l);c=function(d){return d&&"Array"===d.K};a.setProperty(a.l,"isArray",a.b(c,!1),A);M(a,a.l,"pop",function(){return Array.prototype.pop.call(this.a)});c=function(d){return Array.prototype.push.apply(this.a,
|
||||
arguments)};M(a,a.l,"push",c);M(a,a.l,"shift",function(){return Array.prototype.shift.call(this.a)});c=function(d){return Array.prototype.unshift.apply(this.a,arguments)};M(a,a.l,"unshift",c);M(a,a.l,"reverse",function(){Array.prototype.reverse.call(this.a);return this});c=function(d,e){var g=Array.prototype.splice.apply(this.a,arguments);return P(a,g)};M(a,a.l,"splice",c);c=function(d,e){return P(a,Array.prototype.slice.call(this.a,d,e))};M(a,a.l,"slice",c);c=function(d){return Array.prototype.join.call(this.a,
|
||||
d)};M(a,a.l,"join",c);c=function(d){for(var e=[],g=0,l=a.v(this,"length"),q=0;q<l;q++){if(xc(a,this,q)){var v=a.v(this,q);e[g]=v}g++}for(q=0;q<arguments.length;q++)if(l=arguments[q],T(a,l,a.l)){v=a.v(l,"length");for(var D=0;D<v;D++)xc(a,l,D)&&(e[g]=a.v(l,D)),g++}else e[g]=l;return P(a,e)};M(a,a.l,"concat",c);c=function(d,e){return Array.prototype.indexOf.apply(this.a,arguments)};M(a,a.l,"indexOf",c);c=function(d,e){return Array.prototype.lastIndexOf.apply(this.a,arguments)};M(a,a.l,"lastIndexOf",
|
||||
c);M(a,a.l,"sort",function(){Array.prototype.sort.call(this.a);return this});a.V.push("Object.defineProperty(Array.prototype, 'every',","{configurable: true, writable: true, value:","function(callbackfn, thisArg) {","if (!this || typeof callbackfn !== 'function') throw TypeError();","var T, k;","var O = Object(this);","var len = O.length >>> 0;","if (arguments.length > 1) T = thisArg;","k = 0;","while (k < len) {","if (k in O && !callbackfn.call(T, O[k], k, O)) return false;","k++;","}","return true;",
|
||||
"}","});","Object.defineProperty(Array.prototype, 'filter',","{configurable: true, writable: true, value:","function(fun/*, thisArg*/) {","if (this === void 0 || this === null || typeof fun !== 'function') throw TypeError();","var t = Object(this);","var len = t.length >>> 0;","var res = [];","var thisArg = arguments.length >= 2 ? arguments[1] : void 0;","for (var i = 0; i < len; i++) {","if (i in t) {","var val = t[i];","if (fun.call(thisArg, val, i, t)) res.push(val);","}","}","return res;","}",
|
||||
"});","Object.defineProperty(Array.prototype, 'forEach',","{configurable: true, writable: true, value:","function(callback, thisArg) {","if (!this || typeof callback !== 'function') throw TypeError();","var T, k;","var O = Object(this);","var len = O.length >>> 0;","if (arguments.length > 1) T = thisArg;","k = 0;","while (k < len) {","if (k in O) callback.call(T, O[k], k, O);","k++;","}","}","});","Object.defineProperty(Array.prototype, 'map',","{configurable: true, writable: true, value:","function(callback, thisArg) {",
|
||||
"if (!this || typeof callback !== 'function') new TypeError;","var T, A, k;","var O = Object(this);","var len = O.length >>> 0;","if (arguments.length > 1) T = thisArg;","A = new Array(len);","k = 0;","while (k < len) {","if (k in O) A[k] = callback.call(T, O[k], k, O);","k++;","}","return A;","}","});","Object.defineProperty(Array.prototype, 'reduce',","{configurable: true, writable: true, value:","function(callback /*, initialValue*/) {","if (!this || typeof callback !== 'function') throw TypeError();",
|
||||
"var t = Object(this), len = t.length >>> 0, k = 0, value;","if (arguments.length === 2) {","value = arguments[1];","} else {","while (k < len && !(k in t)) k++;","if (k >= len) {","throw TypeError('Reduce of empty array with no initial value');","}","value = t[k++];","}","for (; k < len; k++) {","if (k in t) value = callback(value, t[k], k, t);","}","return value;","}","});","Object.defineProperty(Array.prototype, 'reduceRight',","{configurable: true, writable: true, value:","function(callback /*, initialValue*/) {",
|
||||
"if (null === this || 'undefined' === typeof this || 'function' !== typeof callback) throw TypeError();","var t = Object(this), len = t.length >>> 0, k = len - 1, value;","if (arguments.length >= 2) {","value = arguments[1];","} else {","while (k >= 0 && !(k in t)) k--;","if (k < 0) {","throw TypeError('Reduce of empty array with no initial value');","}","value = t[k--];","}","for (; k >= 0; k--) {","if (k in t) value = callback(value, t[k], k, t);","}","return value;","}","});","Object.defineProperty(Array.prototype, 'some',",
|
||||
"{configurable: true, writable: true, value:","function(fun/*, thisArg*/) {","if (!this || typeof fun !== 'function') throw TypeError();","var t = Object(this);","var len = t.length >>> 0;","var thisArg = arguments.length >= 2 ? arguments[1] : void 0;","for (var i = 0; i < len; i++) {","if (i in t && fun.call(thisArg, t[i], i, t)) {","return true;","}","}","return false;","}","});","(function() {","var sort_ = Array.prototype.sort;","Array.prototype.sort = function(opt_comp) {","if (typeof opt_comp !== 'function') {",
|
||||
"return sort_.call(this);","}","for (var i = 0; i < this.length; i++) {","var changes = 0;","for (var j = 0; j < this.length - i - 1; j++) {","if (opt_comp(this[j], this[j + 1]) > 0) {","var swap = this[j];","this[j] = this[j + 1];","this[j + 1] = swap;","changes++;","}","}","if (!changes) break;","}","return this;","};","})();","Object.defineProperty(Array.prototype, 'toLocaleString',","{configurable: true, writable: true, value:","function() {","var out = [];","for (var i = 0; i < this.length; i++) {",
|
||||
"out[i] = (this[i] === null || this[i] === undefined) ? '' : this[i].toLocaleString();","}","return out.join(',');","}","});","")}
|
||||
function Eb(a,b){var c=function(e){e=String(e);return vc(a)?(this.data=e,this):e};a.A=a.b(c,!0);a.setProperty(b,"String",a.A);a.setProperty(a.A,"fromCharCode",a.b(String.fromCharCode,!1),A);c="charAt charCodeAt concat indexOf lastIndexOf slice substr substring toLocaleLowerCase toLocaleUpperCase toLowerCase toUpperCase trim".split(" ");for(var d=0;d<c.length;d++)M(a,a.A,c[d],String.prototype[c[d]]);c=function(e,g,l){g=g?a.M(g):void 0;l=l?a.M(l):void 0;return String(this).localeCompare(e,g,l)};M(a,
|
||||
a.A,"localeCompare",c);c=function(e,g,l){var q=String(this);g=g?Number(g):void 0;if(T(a,e,a.D)&&(e=e.data,yc(a,e,l),2===a.REGEXP_MODE)){if(Ka)e=zc(a,"string.split(separator, limit)",{string:q,separator:e,limit:g},e,l),e!==Ia&&l(P(a,e));else{var v=a.X(),D=Qc(a,e,v,l);v.onmessage=function(B){clearTimeout(D);l(P(a,B.data))};v.postMessage(["split",q,e,g])}return}e=q.split(e,g);l(P(a,e))};Rc(a,a.A,"split",c);c=function(e,g){var l=String(this);e=T(a,e,a.D)?e.data:new RegExp(e);yc(a,e,g);if(2===a.REGEXP_MODE)if(Ka)l=
|
||||
zc(a,"string.match(regexp)",{string:l,regexp:e},e,g),l!==Ia&&g(l&&P(a,l));else{var q=a.X(),v=Qc(a,e,q,g);q.onmessage=function(D){clearTimeout(v);g(D.data&&P(a,D.data))};q.postMessage(["match",l,e])}else l=l.match(e),g(l&&P(a,l))};Rc(a,a.A,"match",c);c=function(e,g){var l=String(this);e=T(a,e,a.D)?e.data:new RegExp(e);yc(a,e,g);if(2===a.REGEXP_MODE)if(Ka)l=zc(a,"string.search(regexp)",{string:l,regexp:e},e,g),l!==Ia&&g(l);else{var q=a.X(),v=Qc(a,e,q,g);q.onmessage=function(D){clearTimeout(v);g(D.data)};
|
||||
q.postMessage(["search",l,e])}else g(l.search(e))};Rc(a,a.A,"search",c);c=function(e,g,l){var q=String(this);g=String(g);if(T(a,e,a.D)&&(e=e.data,yc(a,e,l),2===a.REGEXP_MODE)){if(Ka)e=zc(a,"string.replace(substr, newSubstr)",{string:q,substr:e,newSubstr:g},e,l),e!==Ia&&l(e);else{var v=a.X(),D=Qc(a,e,v,l);v.onmessage=function(B){clearTimeout(D);l(B.data)};v.postMessage(["replace",q,e,g])}return}l(q.replace(e,g))};Rc(a,a.A,"replace",c);a.V.push("(function() {","var replace_ = String.prototype.replace;",
|
||||
"String.prototype.replace = function(substr, newSubstr) {","if (typeof newSubstr !== 'function') {","return replace_.call(this, substr, newSubstr);","}","var str = this;","if (substr instanceof RegExp) {","var subs = [];","var m = substr.exec(str);","while (m) {","m.push(m.index, str);","var inject = newSubstr.apply(null, m);","subs.push([m.index, m[0].length, inject]);","m = substr.global ? substr.exec(str) : null;","}","for (var i = subs.length - 1; i >= 0; i--) {","str = str.substring(0, subs[i][0]) + subs[i][2] + str.substring(subs[i][0] + subs[i][1]);",
|
||||
"}","} else {","var i = str.indexOf(substr);","if (i !== -1) {","var inject = newSubstr(str.substr(i, substr.length), i, str);","str = str.substring(0, i) + inject + str.substring(i + substr.length);","}","}","return str;","};","})();","")}function Fb(a,b){a.Wa=a.b(function(c){c=!!c;return vc(a)?(this.data=c,this):c},!0);a.setProperty(b,"Boolean",a.Wa)}
|
||||
function Gb(a,b){var c=function(e){e=Number(e);return vc(a)?(this.data=e,this):e};a.T=a.b(c,!0);a.setProperty(b,"Number",a.T);c=["MAX_VALUE","MIN_VALUE","NaN","NEGATIVE_INFINITY","POSITIVE_INFINITY"];for(var d=0;d<c.length;d++)a.setProperty(a.T,c[d],Number[c[d]],E);c=function(e){try{return Number(this).toExponential(e)}catch(g){J(a,a.w,g.message)}};M(a,a.T,"toExponential",c);c=function(e){try{return Number(this).toFixed(e)}catch(g){J(a,a.w,g.message)}};M(a,a.T,"toFixed",c);c=function(e){try{return Number(this).toPrecision(e)}catch(g){J(a,
|
||||
a.w,g.message)}};M(a,a.T,"toPrecision",c);c=function(e){try{return Number(this).toString(e)}catch(g){J(a,a.w,g.message)}};M(a,a.T,"toString",c);c=function(e,g){e=e?a.M(e):void 0;g=g?a.M(g):void 0;return Number(this).toLocaleString(e,g)};M(a,a.T,"toLocaleString",c)}
|
||||
function Hb(a,b){var c=function(g,l){if(!vc(a))return Date();var q=[null].concat(Array.from(arguments));this.data=new (Function.prototype.bind.apply(Date,q));return this};a.S=a.b(c,!0);a.Xa=a.S.a.prototype;a.setProperty(b,"Date",a.S);a.setProperty(a.S,"now",a.b(Date.now,!1),A);a.setProperty(a.S,"parse",a.b(Date.parse,!1),A);a.setProperty(a.S,"UTC",a.b(Date.UTC,!1),A);for(var d="getDate getDay getFullYear getHours getMilliseconds getMinutes getMonth getSeconds getTime getTimezoneOffset getUTCDate getUTCDay getUTCFullYear getUTCHours getUTCMilliseconds getUTCMinutes getUTCMonth getUTCSeconds getYear setDate setFullYear setHours setMilliseconds setMinutes setMonth setSeconds setTime setUTCDate setUTCFullYear setUTCHours setUTCMilliseconds setUTCMinutes setUTCMonth setUTCSeconds setYear toDateString toISOString toJSON toGMTString toLocaleDateString toLocaleString toLocaleTimeString toTimeString toUTCString".split(" "),
|
||||
e=0;e<d.length;e++)c=function(g){return function(l){for(var q=[],v=0;v<arguments.length;v++)q[v]=a.M(arguments[v]);return this.data[g].apply(this.data,q)}}(d[e]),M(a,a.S,d[e],c)}
|
||||
function Ib(a,b){var c=function(d,e){var g=vc(a)?this:a.g(a.Aa);d=d?String(d):"";e=e?String(e):"";Sc(a,g,new RegExp(d,e));return g};a.D=a.b(c,!0);a.Aa=a.D.a.prototype;a.setProperty(b,"RegExp",a.D);a.setProperty(a.D.a.prototype,"global",void 0,E);a.setProperty(a.D.a.prototype,"ignoreCase",void 0,E);a.setProperty(a.D.a.prototype,"multiline",void 0,E);a.setProperty(a.D.a.prototype,"source","(?:)",E);a.V.push("Object.defineProperty(RegExp.prototype, 'test',","{configurable: true, writable: true, value:",
|
||||
"function(str) {","return String(str).search(this) !== -1","}","});");c=function(d,e){function g(B){if(B){var ca=P(a,B);a.setProperty(ca,"index",B.index);a.setProperty(ca,"input",B.input);return ca}return null}var l=this,q=l.data;d=String(d);q.lastIndex=Number(a.v(this,"lastIndex"));yc(a,q,e);if(2===a.REGEXP_MODE)if(Ka){var v=zc(a,"regexp.exec(string)",{string:d,regexp:q},q,e);v!==Ia&&(a.setProperty(l,"lastIndex",q.lastIndex),e(g(v)))}else{v=a.X();var D=Qc(a,q,v,e);v.onmessage=function(B){clearTimeout(D);
|
||||
a.setProperty(l,"lastIndex",B.data[1]);e(g(B.data[0]))};v.postMessage(["exec",q,q.lastIndex,d])}else v=q.exec(d),a.setProperty(l,"lastIndex",q.lastIndex),e(g(v))};Rc(a,a.D,"exec",c)}
|
||||
function Jb(a,b){function c(d){var e=a.b(function(g){var l=vc(a)?this:a.pa(e);g&&a.setProperty(l,"message",String(g),A);return l},!0);a.setProperty(e,"prototype",a.pa(a.w),A);a.setProperty(e.a.prototype,"name",d,A);a.setProperty(b,d,e);return e}a.w=a.b(function(d){var e=vc(a)?this:a.pa(a.w);d&&a.setProperty(e,"message",String(d),A);return e},!0);a.setProperty(b,"Error",a.w);a.setProperty(a.w.a.prototype,"message","",A);a.setProperty(a.w.a.prototype,"name","Error",A);c("EvalError");a.Ya=c("RangeError");
|
||||
a.Za=c("ReferenceError");a.fa=c("SyntaxError");a.h=c("TypeError");a.pb=c("URIError")}function Kb(a,b){var c=a.g(a.G);a.setProperty(b,"Math",c);for(var d="E LN2 LN10 LOG2E LOG10E PI SQRT1_2 SQRT2".split(" "),e=0;e<d.length;e++)a.setProperty(c,d[e],Math[d[e]],E);d="abs acos asin atan atan2 ceil cos exp floor log max min pow random round sin sqrt tan".split(" ");for(e=0;e<d.length;e++)a.setProperty(c,d[e],a.b(Math[d[e]],!1),A)}
|
||||
function Lb(a,b){function c(e){try{var g=JSON.parse(String(e))}catch(l){J(a,a.fa,l.message)}return a.la(g)}var d=a.g(a.G);a.setProperty(b,"JSON",d);a.setProperty(d,"parse",a.b(c,!1));c=function(e){e=a.M(e);try{var g=JSON.stringify(e)}catch(l){J(a,a.h,l.message)}return g};a.setProperty(d,"stringify",a.b(c,!1))}function T(a,b,c){if(null===b||void 0===b||!c)return!1;c=c.a.prototype;if(b===c)return!0;for(b=uc(a,b);b;){if(b===c)return!0;b=b.oa}return!1}
|
||||
function Sc(a,b,c){b.data=c;a.setProperty(b,"lastIndex",c.lastIndex,A);a.setProperty(b,"source",c.source,E);a.setProperty(b,"global",c.global,E);a.setProperty(b,"ignoreCase",c.ignoreCase,E);a.setProperty(b,"multiline",c.multiline,E)}u.prototype.X=function(){var a=this.X.tb;a||(a=new Blob([La.join("\n")],{type:"application/javascript"}),this.X.tb=a);return new Worker(URL.createObjectURL(a))};
|
||||
function zc(a,b,c,d,e){var g={timeout:a.REGEXP_THREAD_TIMEOUT};try{return Ka.runInNewContext(b,c,g)}catch(l){e(null),J(a,a.w,"RegExp Timeout: "+d)}return Ia}function yc(a,b,c){if(0===a.REGEXP_MODE)var d=!1;else if(1===a.REGEXP_MODE)d=!0;else if(Ka)d=!0;else if("function"===typeof Worker&&"function"===typeof URL)d=!0;else if("function"===typeof require){try{Ka=require("vm")}catch(e){}d=!!Ka}else d=!1;d||(c(null),J(a,a.w,"Regular expressions not supported: "+b))}
|
||||
function Qc(a,b,c,d){return setTimeout(function(){c.terminate();d(null);try{J(a,a.w,"RegExp Timeout: "+b)}catch(e){}},a.REGEXP_THREAD_TIMEOUT)}function wc(a){var b=a>>>0;return b===Number(a)?b:NaN}function Tc(a){var b=a>>>0;return String(b)===String(a)&&4294967295!==b?b:NaN}function Oa(a){this.O=Object.create(null);this.R=Object.create(null);this.a=Object.create(null);this.oa=a}p=Oa.prototype;p.oa=null;p.o=!0;p.K="Object";p.data=null;
|
||||
p.toString=function(){if("Array"===this.K){var a=Ja;a.push(this);try{for(var b=[],c=0;c<this.a.length;c++){var d=this.a[c];b[c]=d&&d.o&&-1!==a.indexOf(d)?"...":d}}finally{a.pop()}return b.join(",")}if("Error"===this.K){a=Ja;if(-1!==a.indexOf(this))return"[object Error]";d=this;do if("name"in d.a){b=d.a.name;break}while(d=d.oa);d=this;do if("message"in d.a){c=d.a.message;break}while(d=d.oa);a.push(this);try{b=b&&String(b),c=c&&String(c)}finally{a.pop()}return c?b+": "+c:String(b)}return null!==this.data?
|
||||
String(this.data):"[object "+this.K+"]"};p.valueOf=function(){return void 0===this.data||null===this.data||this.data instanceof RegExp?this:this.data instanceof Date?this.data.valueOf():this.data};p=u.prototype;p.pa=function(a){return this.g(a&&a.a.prototype)};
|
||||
p.g=function(a){if("object"!==typeof a)throw Error("Non object prototype");a=new Oa(a);T(this,a,this.C)&&(this.setProperty(a,"prototype",this.g(this.G||null),A),a.K="Function");T(this,a,this.l)&&(this.setProperty(a,"length",0,{configurable:!1,enumerable:!1,writable:!0}),a.K="Array");T(this,a,this.w)&&(a.K="Error");return a};function Uc(a,b,c){var d=a.g(a.I);d.ca=c;d.node=b;a.setProperty(d,"length",d.node.params.length,E);return d}
|
||||
p.b=function(a,b){var c=this.g(this.I);c.xa=a;a.id=this.Da++;this.setProperty(c,"length",a.length,E);b?this.setProperty(c.a.prototype,"constructor",c,A):!1===b&&(c.Fb=!0,this.setProperty(c,"prototype",void 0,A));return c};p.bb=function(a){var b=this.g(this.I);b.Ka=a;a.id=this.Da++;this.setProperty(b,"length",a.length,E);return b};
|
||||
p.la=function(a){if("object"!==typeof a&&"function"!==typeof a||null===a)return a;if(a instanceof RegExp){var b=this.g(this.Aa);Sc(this,b,a);return b}if(a instanceof Date)return b=this.g(this.Xa),b.data=a,b;if(a instanceof Function){var c=this;return this.b(function(){return c.la(a.apply(c,Array.prototype.slice.call(arguments).map(function(e){return c.M(e)})))},void 0)}if(Array.isArray(a)){b=this.g(this.ea);for(var d=0;d<a.length;d++)d in a&&this.setProperty(b,d,this.la(a[d]))}else for(d in b=this.g(this.G),
|
||||
a)this.setProperty(b,d,this.la(a[d]));return b};p.M=function(a,b){if("object"!==typeof a&&"function"!==typeof a||null===a)return a;if(T(this,a,this.D)||T(this,a,this.S))return a.data;var c=b||{Ta:[],Fa:[]},d=c.Ta.indexOf(a);if(-1!==d)return c.Fa[d];c.Ta.push(a);if(T(this,a,this.l)){var e=[];c.Fa.push(e);var g=this.v(a,"length");for(d=0;d<g;d++)xc(this,a,d)&&(e[d]=this.M(this.v(a,d),c))}else for(g in e={},c.Fa.push(e),a.a)d=a.a[g],e[g]=this.M(d,c);c.Ta.pop();c.Fa.pop();return e};
|
||||
function P(a,b){for(var c=a.g(a.ea),d=Object.getOwnPropertyNames(b),e=0;e<d.length;e++)a.setProperty(c,d[e],b[d[e]]);return c}function uc(a,b){switch(typeof b){case "number":return a.T.a.prototype;case "boolean":return a.Wa.a.prototype;case "string":return a.A.a.prototype}return b?b.oa:null}
|
||||
p.v=function(a,b){b=String(b);void 0!==a&&null!==a||J(this,this.h,"Cannot read property '"+b+"' of "+a);if("length"===b){if(T(this,a,this.A))return String(a).length}else if(64>b.charCodeAt(0)&&T(this,a,this.A)){var c=Tc(b);if(!isNaN(c)&&c<String(a).length)return String(a)[c]}do if(a.a&&b in a.a)return(c=a.O[b])?(c.L=!0,c):a.a[b];while(a=uc(this,a))};
|
||||
function xc(a,b,c){if(!b.o)throw TypeError("Primitive data type has no properties");c=String(c);if("length"===c&&T(a,b,a.A))return!0;if(T(a,b,a.A)){var d=Tc(c);if(!isNaN(d)&&d<String(b).length)return!0}do if(b.a&&c in b.a)return!0;while(b=uc(a,b));return!1}
|
||||
p.setProperty=function(a,b,c,d){b=String(b);void 0!==a&&null!==a||J(this,this.h,"Cannot set property '"+b+"' of "+a);d&&("get"in d||"set"in d)&&("value"in d||"writable"in d)&&J(this,this.h,"Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");var e=!this.j||Mb(this).H;if(a.o){if(T(this,a,this.A)){var g=Tc(b);if("length"===b||!isNaN(g)&&g<String(a).length){e&&J(this,this.h,"Cannot assign to read only property '"+b+"' of String '"+a.data+"'");return}}if("Array"===
|
||||
a.K)if(g=a.a.length,"length"===b){if(d){if(!("value"in d))return;c=d.value}c=wc(c);isNaN(c)&&J(this,this.Ya,"Invalid array length");if(c<g)for(l in a.a){var l=Tc(l);!isNaN(l)&&c<=l&&delete a.a[l]}}else isNaN(l=Tc(b))||(a.a.length=Math.max(g,l+1));if(!a.preventExtensions||b in a.a)if(d){"get"in d&&(d.get?a.O[b]=d.get:delete a.O[b]);"set"in d&&(d.set?a.R[b]=d.set:delete a.R[b]);e={};"configurable"in d&&(e.configurable=d.configurable);"enumerable"in d&&(e.enumerable=d.enumerable);"writable"in d&&(e.writable=
|
||||
d.writable,delete a.O[b],delete a.R[b]);"value"in d?(e.value=d.value,delete a.O[b],delete a.R[b]):c!==Ha&&(e.value=c,delete a.O[b],delete a.R[b]);try{Object.defineProperty(a.a,b,e)}catch(q){J(this,this.h,"Cannot redefine property: "+b)}}else{if(c===Ha)throw ReferenceError("Value not specified.");for(d=a;!(b in d.a);)if(d=uc(this,d),!d){d=a;break}if(d.R&&d.R[b])return d.R[b];if(d.O&&d.O[b])e&&J(this,this.h,"Cannot set property '"+b+"' of object '"+a+"' which only has a getter");else try{a.a[b]=c}catch(q){e&&
|
||||
J(this,this.h,"Cannot assign to read only property '"+b+"' of object '"+a+"'")}}else e&&J(this,this.h,"Can't add property '"+b+"', object is not extensible")}else e&&J(this,this.h,"Can't create property '"+b+"' on '"+a+"'")};function M(a,b,c,d){a.setProperty(b.a.prototype,c,a.b(d,!1),A)}function Rc(a,b,c,d){a.setProperty(b.a.prototype,c,a.bb(d),A)}function Mb(a){a=a.j[a.j.length-1].scope;if(!a)throw Error("No scope found.");return a}
|
||||
function ia(a,b,c){var d=a.g(null);(d.ca=c)||Na(a,d);Ma(a,b,d);d.H=!1;c&&c.H?d.H=!0:(a=b.body&&b.body[0])&&a.ta&&"Literal"===a.ta.type&&"use strict"===a.ta.value&&(d.H=!0);return d}function Vc(a,b,c){if(!b)throw Error("parentScope required");a=c||a.g(null);a.ca=b;a.H=b.H;return a}
|
||||
function Wc(a,b){for(var c=Mb(a);c&&c!==a.global;){if(b in c.a)return c.a[b];c=c.ca}if(c===a.global&&xc(a,c,b))return a.v(c,b);c=a.j[a.j.length-1].node;"UnaryExpression"===c.type&&"typeof"===c.operator||J(a,a.Za,b+" is not defined")}function Xc(a,b,c){for(var d=Mb(a),e=d.H;d&&d!==a.global;){if(b in d.a){d.a[b]=c;return}d=d.ca}if(d===a.global&&(!e||xc(a,d,b)))return a.setProperty(d,b,c);J(a,a.Za,b+" is not defined")}
|
||||
function Ma(a,b,c){if("VariableDeclaration"===b.type)for(var d=0;d<b.declarations.length;d++)a.setProperty(c,b.declarations[d].id.name,void 0,za);else{if("FunctionDeclaration"===b.type){a.setProperty(c,b.id.name,Uc(a,b,c),za);return}if("FunctionExpression"===b.type||"ExpressionStatement"===b.type)return}var e=b.constructor,g;for(g in b){var l=b[g];if(l&&"object"===typeof l)if(Array.isArray(l))for(d=0;d<l.length;d++)l[d]&&l[d].constructor===e&&Ma(a,l[d],c);else l.constructor===e&&Ma(a,l,c)}}
|
||||
function ra(a,b,c,d){c?b.start=c:delete b.start;d?b.end=d:delete b.end;for(var e in b)if(b.hasOwnProperty(e)){var g=b[e];g&&"object"===typeof g&&ra(a,g,c,d)}}function vc(a){return a.j[a.j.length-1].isConstructor}function Yc(a,b){return b[0]===Ba?Wc(a,b[1]):a.v(b[0],b[1])}function Zc(a,b,c){return b[0]===Ba?Xc(a,b[1],c):a.setProperty(b[0],b[1],c)}function J(a,b,c){void 0!==c&&(b=a.pa(b),a.setProperty(b,"message",c,A));$c(a,4,b,void 0);throw Aa;}
|
||||
function $c(a,b,c,d){if(0===b)throw TypeError("Should not unwind for NORMAL completions");var e=a.j;a:for(;0<e.length;e.pop()){var g=e[e.length-1];switch(g.node.type){case "TryStatement":g.U={type:b,value:c,label:d};return;case "CallExpression":case "NewExpression":if(3===b){g.value=c;return}if(4!==b)throw Error("Unsynatctic break/continue not rejected by Acorn");break;case "Program":g.done=!0;break a}if(1===b){if(d?g.labels&&-1!==g.labels.indexOf(d):g.P||g.Hb){e.pop();return}}else if(2===b&&(d?g.labels&&
|
||||
-1!==g.labels.indexOf(d):g.P))return}T(a,c,a.w)?(b={EvalError:EvalError,RangeError:RangeError,ReferenceError:ReferenceError,SyntaxError:SyntaxError,TypeError:TypeError,URIError:URIError},d=String(a.v(c,"name")),a=a.v(c,"message").valueOf(),a=(b[d]||Error)(a)):a=String(c);throw a;}function ad(a,b,c){c=Array.isArray(c)?c[0]:c;var d=new a.Ra({options:{}});d.type="CallExpression";a=new y(d,a.j[a.j.length-1].scope);a.ja=!0;a.J=c;a.Z=b;a.Oa=!0;a.B=[];return a}
|
||||
function bd(a,b,c,d){c=Array.isArray(c)?c[0]:a.global;var e=new a.Ra({options:{}});e.type="CallExpression";a=new y(e,a.j[a.j.length-1].scope);a.ja=!0;a.J=c;a.Z=b;a.Oa=!0;a.B=[d];return a}function y(a,b){this.node=a;this.scope=b}u.prototype.stepArrayExpression=function(a,b,c){c=c.elements;var d=b.s||0;b.Ba?(this.setProperty(b.Ba,d,b.value),d++):(b.Ba=this.g(this.ea),b.Ba.a.length=c.length);for(;d<c.length;){if(c[d])return b.s=d,new y(c[d],b.scope);d++}a.pop();a[a.length-1].value=b.Ba};
|
||||
u.prototype.stepAssignmentExpression=function(a,b,c){if(!b.Y)return b.Y=!0,b=new y(c.left,b.scope),b.ia=!0,b;if(!b.sa){b.ua||(b.ua=b.value);b.qa&&(b.$=b.value);if(!b.qa&&"="!==c.operator&&(a=Yc(this,b.ua),(b.$=a)&&"object"===typeof a&&a.L))return a.L=!1,b.qa=!0,ad(this,a,b.ua);b.sa=!0;return new y(c.right,b.scope)}if(b.ka)a.pop(),a[a.length-1].value=b.Ua;else{var d=b.$,e=b.value;switch(c.operator){case "=":d=e;break;case "+=":d+=e;break;case "-=":d-=e;break;case "*=":d*=e;break;case "/=":d/=e;break;
|
||||
case "%=":d%=e;break;case "<<=":d<<=e;break;case ">>=":d>>=e;break;case ">>>=":d>>>=e;break;case "&=":d&=e;break;case "^=":d^=e;break;case "|=":d|=e;break;default:throw SyntaxError("Unknown assignment expression: "+c.operator);}if(c=Zc(this,b.ua,d))return b.ka=!0,b.Ua=d,bd(this,c,b.ua,d);a.pop();a[a.length-1].value=d}};
|
||||
u.prototype.stepBinaryExpression=function(a,b,c){if(!b.Y)return b.Y=!0,new y(c.left,b.scope);if(!b.sa)return b.sa=!0,b.$=b.value,new y(c.right,b.scope);a.pop();var d=b.$;b=b.value;switch(c.operator){case "==":c=d==b;break;case "!=":c=d!=b;break;case "===":c=d===b;break;case "!==":c=d!==b;break;case ">":c=d>b;break;case ">=":c=d>=b;break;case "<":c=d<b;break;case "<=":c=d<=b;break;case "+":c=d+b;break;case "-":c=d-b;break;case "*":c=d*b;break;case "/":c=d/b;break;case "%":c=d%b;break;case "&":c=d&
|
||||
b;break;case "|":c=d|b;break;case "^":c=d^b;break;case "<<":c=d<<b;break;case ">>":c=d>>b;break;case ">>>":c=d>>>b;break;case "in":b&&b.o||J(this,this.h,"'in' expects an object, not '"+b+"'");c=xc(this,b,d);break;case "instanceof":T(this,b,this.C)||J(this,this.h,"Right-hand side of instanceof is not an object");c=d.o?T(this,d,b):!1;break;default:throw SyntaxError("Unknown binary operator: "+c.operator);}a[a.length-1].value=c};
|
||||
u.prototype.stepBlockStatement=function(a,b,c){var d=b.s||0;if(c=c.body[d])return b.s=d+1,new y(c,b.scope);a.pop()};u.prototype.stepBreakStatement=function(a,b,c){$c(this,1,void 0,c.label&&c.label.name)};
|
||||
u.prototype.stepCallExpression=function(a,b,c){if(!b.ja){b.ja=1;var d=new y(c.callee,b.scope);d.ia=!0;return d}if(1===b.ja){b.ja=2;d=b.value;if(Array.isArray(d)){if(b.Z=Yc(this,d),d[0]===Ba?b.wb="eval"===d[1]:b.J=d[0],(d=b.Z)&&"object"===typeof d&&d.L)return d.L=!1,b.ja=1,ad(this,d,b.value)}else b.Z=d;b.B=[];b.s=0}d=b.Z;if(!b.Oa){0!==b.s&&b.B.push(b.value);if(c.arguments[b.s])return new y(c.arguments[b.s++],b.scope);if("NewExpression"===c.type){d.Fb&&J(this,this.h,d+" is not a constructor");var e=
|
||||
d.a.prototype;if("object"!==typeof e||null===e)e=this.G;b.J=this.g(e);b.isConstructor=!0}else void 0===b.J&&(b.J=b.scope.H?void 0:this.global);b.Oa=!0}if(b.Pa)a.pop(),a[a.length-1].value=b.isConstructor&&"object"!==typeof b.value?b.J:b.value;else{b.Pa=!0;d&&d.o||J(this,this.h,d+" is not a function");if(a=d.node){c=ia(this,a.body,d.ca);for(var g=0;g<a.params.length;g++)this.setProperty(c,a.params[g].name,b.B.length>g?b.B[g]:void 0);e=this.g(this.ea);for(g=0;g<b.B.length;g++)this.setProperty(e,g,b.B[g]);
|
||||
this.setProperty(c,"arguments",e);(g=a.id&&a.id.name)&&this.setProperty(c,g,d);this.setProperty(c,"this",b.J,sa);b.value=void 0;return new y(a.body,c)}if(d.eval)if(d=b.B[0],"string"!==typeof d)b.value=d;else{try{g=acorn.parse(String(d),ha)}catch(q){J(this,this.fa,"Invalid code: "+q.message)}d=new this.Ra({options:{}});d.type="EvalProgram_";d.body=g.body;ra(this,d,c.start,c.end);c=b.wb?b.scope:this.global;c.H?c=ia(this,g,c):Ma(this,g,c);this.value=void 0;return new y(d,c)}else if(d.xa)b.value=d.xa.apply(b.J,
|
||||
b.B);else if(d.Ka){var l=this;g=d.Ka.length-1;g=b.B.concat(Array(g)).slice(0,g);g.push(function(q){b.value=q;l.ya=!1});this.ya=!0;d.Ka.apply(b.J,g)}else J(this,this.h,d.K+" is not a function")}};u.prototype.stepCatchClause=function(a,b,c){if(b.N)a.pop();else return b.N=!0,a=Vc(this,b.scope),this.setProperty(a,c.param.name,b.Ob),new y(c.body,a)};
|
||||
u.prototype.stepConditionalExpression=function(a,b,c){var d=b.ba||0;if(0===d)return b.ba=1,new y(c.test,b.scope);if(1===d){b.ba=2;if((d=!!b.value)&&c.consequent)return new y(c.consequent,b.scope);if(!d&&c.alternate)return new y(c.alternate,b.scope);this.value=void 0}a.pop();"ConditionalExpression"===c.type&&(a[a.length-1].value=b.value)};u.prototype.stepContinueStatement=function(a,b,c){$c(this,2,void 0,c.label&&c.label.name)};u.prototype.stepDebuggerStatement=function(a){a.pop()};
|
||||
u.prototype.stepDoWhileStatement=function(a,b,c){"DoWhileStatement"===c.type&&void 0===b.W&&(b.value=!0,b.W=!0);if(!b.W)return b.W=!0,new y(c.test,b.scope);if(!b.value)a.pop();else if(c.body)return b.W=!1,b.P=!0,new y(c.body,b.scope)};u.prototype.stepEmptyStatement=function(a){a.pop()};u.prototype.stepEvalProgram_=function(a,b,c){var d=b.s||0;if(c=c.body[d])return b.s=d+1,new y(c,b.scope);a.pop();a[a.length-1].value=this.value};
|
||||
u.prototype.stepExpressionStatement=function(a,b,c){if(!b.N)return b.N=!0,new y(c.expression,b.scope);a.pop();this.value=b.value};
|
||||
u.prototype.stepForInStatement=function(a,b,c){if(!b.Bb&&(b.Bb=!0,c.left.declarations&&c.left.declarations[0].init))return b.scope.H&&J(this,this.fa,"for-in loop variable declaration may not have an initializer."),new y(c.left,b.scope);if(!b.ra)return b.ra=!0,b.da||(b.da=b.value),new y(c.right,b.scope);b.P||(b.P=!0,b.i=b.value,b.Va=Object.create(null));if(void 0===b.Ea)a:for(;;){if(b.i&&b.i.o)for(b.na||(b.na=Object.getOwnPropertyNames(b.i.a));;){var d=b.na.shift();if(void 0===d)break;if(Object.prototype.hasOwnProperty.call(b.i.a,
|
||||
d)&&!b.Va[d]&&(b.Va[d]=!0,Object.prototype.propertyIsEnumerable.call(b.i.a,d))){b.Ea=d;break a}}else if(null!==b.i&&void 0!==b.i)for(b.na||(b.na=Object.getOwnPropertyNames(b.i));;){d=b.na.shift();if(void 0===d)break;b.Va[d]=!0;if(Object.prototype.propertyIsEnumerable.call(b.i,d)){b.Ea=d;break a}}b.i=uc(this,b.i);b.na=null;if(null===b.i){a.pop();return}}if(!b.fb)if(b.fb=!0,a=c.left,"VariableDeclaration"===a.type)b.da=[Ba,a.declarations[0].id.name];else return b.da=null,b=new y(a,b.scope),b.ia=!0,b;
|
||||
b.da||(b.da=b.value);if(!b.ka&&(b.ka=!0,a=b.Ea,d=Zc(this,b.da,a)))return bd(this,d,b.da,a);b.Ea=void 0;b.fb=!1;b.ka=!1;if(c.body)return new y(c.body,b.scope)};u.prototype.stepForStatement=function(a,b,c){var d=b.ba||0;if(0===d){if(b.ba=1,c.init)return new y(c.init,b.scope)}else if(1===d){if(b.ba=2,c.test)return new y(c.test,b.scope)}else if(2===d)if(b.ba=3,c.test&&!b.value)a.pop();else return b.P=!0,new y(c.body,b.scope);else if(3===d&&(b.ba=1,c.update))return new y(c.update,b.scope)};
|
||||
u.prototype.stepFunctionDeclaration=function(a){a.pop()};u.prototype.stepFunctionExpression=function(a,b,c){a.pop();a[a.length-1].value=Uc(this,c,b.scope)};u.prototype.stepIdentifier=function(a,b,c){a.pop();if(b.ia)a[a.length-1].value=[Ba,c.name];else{var d=Wc(this,c.name);if(d&&"object"===typeof d&&d.L){d.L=!1;for(a=b.scope;!xc(this,a,c.name);)a=a.ca;return ad(this,d,this.global)}a[a.length-1].value=d}};u.prototype.stepIfStatement=u.prototype.stepConditionalExpression;
|
||||
u.prototype.stepLabeledStatement=function(a,b,c){a.pop();a=b.labels||[];a.push(c.label.name);b=new y(c.body,b.scope);b.labels=a;return b};u.prototype.stepLiteral=function(a,b,c){a.pop();b=c.value;b instanceof RegExp&&(c=this.g(this.Aa),Sc(this,c,b),b=c);a[a.length-1].value=b};
|
||||
u.prototype.stepLogicalExpression=function(a,b,c){if("&&"!==c.operator&&"||"!==c.operator)throw SyntaxError("Unknown logical operator: "+c.operator);if(!b.Y)return b.Y=!0,new y(c.left,b.scope);if(b.sa)a.pop(),a[a.length-1].value=b.value;else if("&&"===c.operator&&!b.value||"||"===c.operator&&b.value)a.pop(),a[a.length-1].value=b.value;else return b.sa=!0,new y(c.right,b.scope)};
|
||||
u.prototype.stepMemberExpression=function(a,b,c){if(!b.ra)return b.ra=!0,new y(c.object,b.scope);if(c.computed)if(b.Cb)c=b.value;else return b.i=b.value,b.Cb=!0,new y(c.property,b.scope);else b.i=b.value,c=c.property.name;a.pop();if(b.ia)a[a.length-1].value=[b.i,c];else{if((c=this.v(b.i,c))&&"object"===typeof c&&c.L)return c.L=!1,ad(this,c,b.i);a[a.length-1].value=c}};u.prototype.stepNewExpression=u.prototype.stepCallExpression;
|
||||
u.prototype.stepObjectExpression=function(a,b,c){var d=b.s||0,e=c.properties[d];if(b.i){var g=e.key;if("Identifier"===g.type)var l=g.name;else if("Literal"===g.type)l=g.value;else throw SyntaxError("Unknown object structure: "+g.type);b.za[l]||(b.za[l]={});b.za[l][e.kind]=b.value;b.s=++d;e=c.properties[d]}else b.i=this.g(this.G),b.za=Object.create(null);if(e)return new y(e.value,b.scope);for(g in b.za)c=b.za[g],"get"in c||"set"in c?this.setProperty(b.i,g,Ha,{configurable:!0,enumerable:!0,get:c.get,
|
||||
set:c.set}):this.setProperty(b.i,g,c.init);a.pop();a[a.length-1].value=b.i};u.prototype.stepProgram=function(a,b,c){if(a=c.body.shift())return b.done=!1,new y(a,b.scope);b.done=!0};u.prototype.stepReturnStatement=function(a,b,c){if(c.argument&&!b.N)return b.N=!0,new y(c.argument,b.scope);$c(this,3,b.value,void 0)};u.prototype.stepSequenceExpression=function(a,b,c){var d=b.s||0;if(c=c.expressions[d])return b.s=d+1,new y(c,b.scope);a.pop();a[a.length-1].value=b.value};
|
||||
u.prototype.stepSwitchStatement=function(a,b,c){if(!b.W)return b.W=1,new y(c.discriminant,b.scope);1===b.W&&(b.W=2,b.Nb=b.value,b.Na=-1);for(;;){var d=b.Qa||0,e=c.cases[d];if(b.wa||!e||e.test)if(e||b.wa||-1===b.Na)if(e){if(!b.wa&&!b.ob&&e.test)return b.ob=!0,new y(e.test,b.scope);if(b.wa||b.value===b.Nb){b.wa=!0;var g=b.s||0;if(e.consequent[g])return b.Hb=!0,b.s=g+1,new y(e.consequent[g],b.scope)}b.ob=!1;b.s=0;b.Qa=d+1}else{a.pop();break}else b.wa=!0,b.Qa=b.Na;else b.Na=d,b.Qa=d+1}};
|
||||
u.prototype.stepThisExpression=function(a){a.pop();a[a.length-1].value=Wc(this,"this")};u.prototype.stepThrowStatement=function(a,b,c){if(b.N)J(this,b.value);else return b.N=!0,new y(c.argument,b.scope)};
|
||||
u.prototype.stepTryStatement=function(a,b,c){if(!b.xb)return b.xb=!0,new y(c.block,b.scope);if(b.U&&4===b.U.type&&!b.Ab&&c.handler)return b.Ab=!0,a=new y(c.handler,b.scope),a.Ob=b.U.value,b.U=void 0,a;if(!b.zb&&c.finalizer)return b.zb=!0,new y(c.finalizer,b.scope);a.pop();b.U&&$c(this,b.U.type,b.U.value,b.U.label)};
|
||||
u.prototype.stepUnaryExpression=function(a,b,c){if(!b.N)return b.N=!0,a=new y(c.argument,b.scope),a.ia="delete"===c.operator,a;a.pop();var d=b.value;if("-"===c.operator)d=-d;else if("+"===c.operator)d=+d;else if("!"===c.operator)d=!d;else if("~"===c.operator)d=~d;else if("delete"===c.operator){c=!0;if(Array.isArray(d)){var e=d[0];e===Ba&&(e=b.scope);d=String(d[1]);try{delete e.a[d]}catch(g){b.scope.H?J(this,this.h,"Cannot delete property '"+d+"' of '"+e+"'"):c=!1}}d=c}else if("typeof"===c.operator)d=
|
||||
d&&"Function"===d.K?"function":typeof d;else if("void"===c.operator)d=void 0;else throw SyntaxError("Unknown unary operator: "+c.operator);a[a.length-1].value=d};
|
||||
u.prototype.stepUpdateExpression=function(a,b,c){if(!b.Y)return b.Y=!0,a=new y(c.argument,b.scope),a.ia=!0,a;b.va||(b.va=b.value);b.qa&&(b.$=b.value);if(!b.qa){var d=Yc(this,b.va);if((b.$=d)&&"object"===typeof d&&d.L)return d.L=!1,b.qa=!0,ad(this,d,b.va)}if(b.ka)a.pop(),a[a.length-1].value=b.Ua;else{d=Number(b.$);if("++"===c.operator)var e=d+1;else if("--"===c.operator)e=d-1;else throw SyntaxError("Unknown update expression: "+c.operator);c=c.prefix?e:d;if(d=Zc(this,b.va,e))return b.ka=!0,b.Ua=c,
|
||||
bd(this,d,b.va,e);a.pop();a[a.length-1].value=c}};u.prototype.stepVariableDeclaration=function(a,b,c){c=c.declarations;var d=b.s||0,e=c[d];b.jb&&e&&(Xc(this,e.id.name,b.value),b.jb=!1,e=c[++d]);for(;e;){if(e.init)return b.s=d,b.jb=!0,new y(e.init,b.scope);e=c[++d]}a.pop()};u.prototype.stepWithStatement=function(a,b,c){if(b.ra)if(b.yb)a.pop();else return b.yb=!0,a=Vc(this,b.scope,b.value),new y(c.body,a);else return b.ra=!0,new y(c.object,b.scope)};u.prototype.stepWhileStatement=u.prototype.stepDoWhileStatement;
|
||||
this.Interpreter=u;u.prototype.step=u.prototype.step;u.prototype.run=u.prototype.lb;u.prototype.appendCode=u.prototype.sb;u.prototype.createObject=u.prototype.pa;u.prototype.createObjectProto=u.prototype.g;u.prototype.createAsyncFunction=u.prototype.bb;u.prototype.createNativeFunction=u.prototype.b;u.prototype.getProperty=u.prototype.v;u.prototype.setProperty=u.prototype.setProperty;u.prototype.nativeToPseudo=u.prototype.la;u.prototype.pseudoToNative=u.prototype.M;u.prototype.createPrimitive=function(a){return a};
|
||||
|
||||
@@ -153,13 +153,12 @@
|
||||
// Add an API function for the alert() block, generated for "text_print" blocks.
|
||||
interpreter.setProperty(scope, 'alert',
|
||||
interpreter.createNativeFunction(function(text) {
|
||||
text = text ? text.toString() : '';
|
||||
text = arguments.length ? text : '';
|
||||
outputArea.value += '\n' + text;
|
||||
}));
|
||||
|
||||
// Add an API function for the prompt() block.
|
||||
var wrapper = function(text) {
|
||||
text = text ? text.toString() : '';
|
||||
return interpreter.createPrimitive(prompt(text));
|
||||
};
|
||||
interpreter.setProperty(scope, 'prompt',
|
||||
@@ -167,7 +166,7 @@
|
||||
|
||||
// Add an API function for highlighting blocks.
|
||||
var wrapper = function(id) {
|
||||
id = id ? id.toString() : '';
|
||||
id = String(id || '');
|
||||
return interpreter.createPrimitive(highlightBlock(id));
|
||||
};
|
||||
interpreter.setProperty(scope, 'highlightBlock',
|
||||
|
||||
Reference in New Issue
Block a user