diff options
| author | jmoenig <jens@moenig.org> | 2014-11-17 10:22:39 +0100 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2014-11-17 10:22:39 +0100 |
| commit | ea05f7859fe5a042f0c0dd49b189c594b9a798d3 (patch) | |
| tree | de4e5748aafed23ae41565ab580c43367f443883 | |
| parent | b36a358173fcf4f2a4a77a9c202d6dc0d6c1a7b8 (diff) | |
| download | snap-yow-ea05f7859fe5a042f0c0dd49b189c594b9a798d3.tar.gz snap-yow-ea05f7859fe5a042f0c0dd49b189c594b9a798d3.zip | |
Treat REPORT blocks inside custom command definitions as STOP THIS BLOCK / IGNORE INPUTS
this also enables all existing FINCH blocks and other hardware
extensions again, which used the REPORT (HTTP://) pattern
| -rw-r--r-- | blocks.js | 33 | ||||
| -rwxr-xr-x | history.txt | 4 | ||||
| -rw-r--r-- | threads.js | 12 |
3 files changed, 38 insertions, 11 deletions
@@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2014-October-01'; +modules.blocks = '2014-November-17'; var SyntaxElementMorph; @@ -394,10 +394,8 @@ SyntaxElementMorph.prototype.allInputs = function () { }; SyntaxElementMorph.prototype.allEmptySlots = function () { -/* - answer empty input slots of all children excluding myself, - but omit those in nested rings (lambdas) and JS-Function primitives -*/ + // answer empty input slots of all children excluding myself, + // but omit those in nested rings (lambdas) and JS-Function primitives var empty = []; if (!(this instanceof RingMorph) && (this.selector !== 'reportJSFunction')) { @@ -412,6 +410,21 @@ SyntaxElementMorph.prototype.allEmptySlots = function () { return empty; }; +SyntaxElementMorph.prototype.allReportBlocks = function () { + // answer report blocks of all children including myself, + // but omit those in nested rings (lambdas) + if (this.selector === 'doReport') {return [this]; } + var reports = []; + if (!(this instanceof RingMorph)) { + this.children.forEach(function (morph) { + if (morph.allReportBlocks) { + reports = reports.concat(morph.allReportBlocks()); + } + }); + } + return reports; +}; + SyntaxElementMorph.prototype.replaceInput = function (oldArg, newArg) { var scripts = this.parentThatIsA(ScriptsMorph), replacement = newArg, @@ -3169,9 +3182,13 @@ BlockMorph.prototype.snap = function () { I inherit from BlockMorph adding the following most important public accessors: - nextBlock() - set / get the block attached to my bottom - bottomBlock() - answer the bottom block of my stack - blockSequence() - answer an array of blocks starting with myself + nextBlock() - set / get the block attached to my bottom + bottomBlock() - answer the bottom block of my stack + blockSequence() - answer an array of blocks starting with myself + + and the following "lexical awareness" indicator: + + partOfCustomCommand - temporary bool set by the evaluator */ // CommandBlockMorph inherits from BlockMorph: diff --git a/history.txt b/history.txt index b3bc7da..88d7ca4 100755 --- a/history.txt +++ b/history.txt @@ -2317,3 +2317,7 @@ ______ 141114 ------ * Threads, Store: Fix reporting out of nested custom C-shaped blocks + +141117 +------ +* Threads, Blocks: Treat REPORT blocks inside custom command definitions as STOP THIS BLOCK / IGNORE INPUTS @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2014-November-15'; +modules.threads = '2014-November-17'; var ThreadManager; var Process; @@ -945,6 +945,9 @@ Process.prototype.fork = function (context, args) { }; Process.prototype.doReport = function (value) { + if (this.context.expression.partOfCustomCommand) { + return this.doStopBlock(); + } while (this.context && this.context.expression !== 'exitReporter') { if (this.context.expression === 'doStopWarping') { this.doStopWarping(); @@ -1042,8 +1045,6 @@ Process.prototype.evaluateCustomBlock = function () { } if (runnable.expression instanceof CommandBlockMorph) { - runnable.expression = runnable.expression.blockSequence(); - // insert a reporter exit tag for the // CALL SCRIPT primitive variant if (this.context.expression.definition.type !== 'command') { @@ -1054,7 +1055,12 @@ Process.prototype.evaluateCustomBlock = function () { outer.receiver ); runnable.parentContext = exit; + } else { // mark all REPORT blocks as being part of a custom command + runnable.expression.allReportBlocks().forEach(function (rb) { + rb.partOfCustomCommand = true; + }); } + runnable.expression = runnable.expression.blockSequence(); } }; |
