From 3ba6fec6a1d7e69541065330aa1057e25f258020 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Tue, 18 Feb 2020 12:03:05 -0800 Subject: [PATCH] Security update to JS-Interpreter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The past week has been ‘exciting’ over in the JS-Interpreter repo. --- demos/interpreter/acorn_interpreter.js | 202 +++++++++++++------------ demos/interpreter/async-execution.html | 10 +- demos/interpreter/index.html | 2 +- demos/interpreter/step-execution.html | 8 +- demos/interpreter/wait_block.js | 6 +- 5 files changed, 115 insertions(+), 113 deletions(-) diff --git a/demos/interpreter/acorn_interpreter.js b/demos/interpreter/acorn_interpreter.js index 249bc6cdd..19db1c3ef 100644 --- a/demos/interpreter/acorn_interpreter.js +++ b/demos/interpreter/acorn_interpreter.js @@ -38,104 +38,106 @@ 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 -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>> 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>>0;return b===Number(a)?b:NaN}function Oa(a){var b=a>>>0;return String(b)===String(a)&&4294967295!==b?b:NaN} +function ra(a,b,c){b?a.start=b:delete a.start;c?a.end=c:delete a.end;for(var d in a)if(a.hasOwnProperty(d)){var e=a[d];e&&"object"===typeof e&&ra(e,b,c)}}u.prototype.REGEXP_MODE=2;u.prototype.REGEXP_THREAD_TIMEOUT=1E3;q=u.prototype;q.I=!1;q.ya=!1; +q.ub=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.");Pa(this,a,b.scope);Array.prototype.push.apply(b.node.body,a.body);b.done=!1}; +q.step=function(){var a=this.j;do{var 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.wa)break;try{var e=this.pb[d](a,b,c)}catch(g){if(g!==Aa)throw g;}e&&a.push(e);if(this.I)throw Error("Getter not supported in this context");if(this.ya)throw Error("Setter not supported in this context");}while(!c.end);return!0};q.nb=function(){for(;!this.wa&&this.step(););return this.wa}; +function Qa(a,b){a.setProperty(b,"NaN",NaN,ya);a.setProperty(b,"Infinity",Infinity,ya);a.setProperty(b,"undefined",void 0,ya);a.setProperty(b,"window",b,ya);a.setProperty(b,"this",b,ya);a.setProperty(b,"self",b);a.B=new F(null);a.W=new F(a.B);db(a,b);eb(a,b);b.la=a.B;a.setProperty(b,"constructor",a.m,B);Fb(a,b);Gb(a,b);Hb(a,b);Ib(a,b);Jb(a,b);Kb(a,b);Lb(a,b);Mb(a,b);Nb(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>> 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 Gb(a,b){var c=function(e){e=arguments.length?String(e):"";return zc(a)?(this.data=e,this):e};a.w=a.b(c,!0);a.setProperty(b,"String",a.w);a.setProperty(a.w,"fromCharCode",a.b(String.fromCharCode,!1),B);c="charAt charCodeAt concat indexOf lastIndexOf slice substr substring toLocaleLowerCase toLocaleUpperCase toLowerCase toUpperCase trim".split(" ");for(var d=0;d= 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>>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;cb.charCodeAt(0)&&T(this,a,this.A)){var c=Tc(b);if(!isNaN(c)&&c>=":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>":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;gg?b.B[g]:void 0);e=this.g(this.ea);for(g=0;gb.charCodeAt(0)&&U(this,a,this.w)){var c=Oa(b);if(!isNaN(c)&&c>=":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=cd(this,b.ra,d))return b.ia=!0,b.Wa=d,fd(this,c,b.ra,d);a.pop();a[a.length-1].value=d}}; +u.prototype.stepBinaryExpression=function(a,b,c){if(!b.Y)return b.Y=!0,new v(c.left,b.scope);if(!b.pa)return b.pa=!0,b.$=b.value,new v(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>":c=d>>b;break;case ">>>":c=d>>>b;break;case "in":b instanceof F||I(this,this.g,"'in' expects an object, not '"+b+"'");c=Bc(this,b,d);break;case "instanceof":U(this,b,this.H)||I(this,this.g,"Right-hand side of instanceof is not an object");c=d instanceof F?U(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.o||0;if(c=c.body[d])return b.o=d+1,new v(c,b.scope);a.pop()};u.prototype.stepBreakStatement=function(a,b,c){dd(this,1,void 0,c.label&&c.label.name)}; +u.prototype.stepCallExpression=function(a,b,c){if(!b.ha){b.ha=1;var d=new v(c.callee,b.scope);d.ga=!0;return d}if(1===b.ha){b.ha=2;d=b.value;if(Array.isArray(d)){if(b.Z=bd(this,d),d[0]===Ba?b.yb="eval"===d[1]:b.G=d[0],d=b.Z,this.I)return b.ha=1,ed(this,d,b.value)}else b.Z=d;b.A=[];b.o=0}d=b.Z;if(!b.Qa){0!==b.o&&b.A.push(b.value);if(c.arguments[b.o])return new v(c.arguments[b.o++],b.scope);if("NewExpression"===c.type){d.Hb&&I(this,this.g,d+" is not a constructor");if(d===this.l)b.G=Ac(this);else{var e= +d.a.prototype;if("object"!==typeof e||null===e)e=this.B;b.G=this.h(e)}b.isConstructor=!0}else void 0===b.G&&(b.G=b.scope.P?void 0:this.Da);b.Qa=!0}if(b.Ra)a.pop(),a[a.length-1].value=b.isConstructor&&"object"!==typeof b.value?b.G:b.value;else{b.Ra=!0;d instanceof F||I(this,this.g,d+" is not a function");if(a=d.node){c=ia(this,a.body,d.va);for(var g=0;gg?b.A[g]:void 0);e=Ac(this);for(g=0;g -Redirecting to step execution jsinterpreter demo. +Redirecting to step execution JS-Interpreter demo. diff --git a/demos/interpreter/step-execution.html b/demos/interpreter/step-execution.html index f3f411947..03e62aed6 100644 --- a/demos/interpreter/step-execution.html +++ b/demos/interpreter/step-execution.html @@ -149,9 +149,9 @@ var stepButton = document.getElementById('stepButton'); var myInterpreter = null; - function initApi(interpreter, scope) { + function initApi(interpreter, globalObject) { // Add an API function for the alert() block, generated for "text_print" blocks. - interpreter.setProperty(scope, 'alert', + interpreter.setProperty(globalObject, 'alert', interpreter.createNativeFunction(function(text) { text = arguments.length ? text : ''; outputArea.value += '\n' + text; @@ -161,7 +161,7 @@ var wrapper = function(text) { return interpreter.createPrimitive(prompt(text)); }; - interpreter.setProperty(scope, 'prompt', + interpreter.setProperty(globalObject, 'prompt', interpreter.createNativeFunction(wrapper)); // Add an API function for highlighting blocks. @@ -169,7 +169,7 @@ id = String(id || ''); return interpreter.createPrimitive(highlightBlock(id)); }; - interpreter.setProperty(scope, 'highlightBlock', + interpreter.setProperty(globalObject, 'highlightBlock', interpreter.createNativeFunction(wrapper)); } diff --git a/demos/interpreter/wait_block.js b/demos/interpreter/wait_block.js index e355925c1..10a57b482 100644 --- a/demos/interpreter/wait_block.js +++ b/demos/interpreter/wait_block.js @@ -40,7 +40,7 @@ Blockly.JavaScript['wait_seconds'] = function(block) { * Register the interpreter asynchronous function * waitForSeconds(). */ -function initInterpreterWaitForSeconds(interpreter, scope) { +function initInterpreterWaitForSeconds(interpreter, globalObject) { // Ensure function name does not conflict with variable names. Blockly.JavaScript.addReservedWords('waitForSeconds'); @@ -49,5 +49,5 @@ function initInterpreterWaitForSeconds(interpreter, scope) { // Delay the call to the callback. setTimeout(callback, timeInSeconds * 1000); }); - interpreter.setProperty(scope, 'waitForSeconds', wrapper); -} \ No newline at end of file + interpreter.setProperty(globalObject, 'waitForSeconds', wrapper); +}