summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-11-17 10:22:39 +0100
committerjmoenig <jens@moenig.org>2014-11-17 10:22:39 +0100
commitea05f7859fe5a042f0c0dd49b189c594b9a798d3 (patch)
treede4e5748aafed23ae41565ab580c43367f443883
parentb36a358173fcf4f2a4a77a9c202d6dc0d6c1a7b8 (diff)
downloadsnap-byow-ea05f7859fe5a042f0c0dd49b189c594b9a798d3.tar.gz
snap-byow-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.js33
-rwxr-xr-xhistory.txt4
-rw-r--r--threads.js12
3 files changed, 38 insertions, 11 deletions
diff --git a/blocks.js b/blocks.js
index 73ef884..82ef601 100644
--- a/blocks.js
+++ b/blocks.js
@@ -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
diff --git a/threads.js b/threads.js
index dfa335e..cf97362 100644
--- a/threads.js
+++ b/threads.js
@@ -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();
}
};