diff --git a/HISTORY.md b/HISTORY.md index 947460cf..a20ded63 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -21,6 +21,7 @@ * new "define block" primitive, experimental * new "delete block" primitive, experimental * new "this script" primitive, experimental + * added support to the OF reporter for binding a ring to another one, e.g. THIS SCRIPT, to access its local variables * new localization extension primitives in the "ide" category, hyperized * new extension primitive for importing a costume from a url * new extension primitive for querying all variable names accessible from a specified scope (global, sprite, script) @@ -58,7 +59,7 @@ ### 2022-07-11 * extensions: fixed #3065 - +* threads: added support to the OF reporter for binding a ring to another one, e.g. THIS SCRIPT to access its local variables ### 2022-07-04 * blocks, gui: directly import embedded blocks from a smart pic if the pic is dragged and dropped onto a scripting area or palette - otherwise import the pic as costume (with embedded blocks) * gui: import smart pic as costume via "Import..." item in the project menu diff --git a/snap.html b/snap.html index 552bff0a..beb8f033 100755 --- a/snap.html +++ b/snap.html @@ -17,7 +17,7 @@ - + diff --git a/src/threads.js b/src/threads.js index 9f1030d8..85d572c9 100644 --- a/src/threads.js +++ b/src/threads.js @@ -1553,11 +1553,17 @@ Process.prototype.initializeFor = function (context, args) { Process.prototype.reportThisContext = function () { var sym = Symbol.for('self'), - frame = this.context.variables.silentFind(sym); + frame = this.context.variables.silentFind(sym), + ctx; if (frame) { return frame.vars[sym].value; } - return this.topBlock.reify(); + ctx = this.topBlock.reify(); + ctx.outerContext = this.context.outerContext; + if (ctx.outerContext) { + ctx.variables.parentFrame = ctx.outerContext.variables; + } + return ctx; }; // Process stopping blocks primitives @@ -5616,6 +5622,9 @@ Process.prototype.reportBasicAttributeOf = function (attribute, name) { thatObj, stage; + if (name instanceof Context && attribute instanceof Context) { + return this.reportContextFor(attribute, name); + } if (thisObj) { this.assertAlive(thisObj); stage = thisObj.parentThatIsA(StageMorph); @@ -6009,6 +6018,13 @@ Process.prototype.reportContextFor = function (context, otherObj) { receiverVars, rootVars; + if (otherObj instanceof Context) { + result.outerContext = otherObj.outerContext; + result.variables.parentFrame = otherObj.outerContext.variables; + result.receiver = otherObj.receiver; + return result; + } + result.receiver = otherObj; if (!result.outerContext) { result.outerContext = new Context();