kopia lustrzana https://github.com/backface/turtlestitch
new "if then else" reporter primitive in Control category
rodzic
335519f877
commit
6c3571a967
|
@ -26,7 +26,7 @@
|
|||
* new "get pen attribute" reporter
|
||||
* new "write" command in pen category (used to be "label" in tools)
|
||||
* new "map","keep", "combine" and "for each" primitives in list category
|
||||
* new "for" loop primitive in the Control category
|
||||
* new "for" loop and "if then else" reporter primitives in the Control category
|
||||
* added "neg", "lg" (log2) and "2^" selectors to monadic function reporter in Operators
|
||||
* added "^" reporter (power of) in the Operators category
|
||||
* added "width" and "height" as attribute selectors of the OF primitive for the stage
|
||||
|
@ -73,6 +73,7 @@
|
|||
* Threads, Objects: new "combine" primitive in list category
|
||||
* Threads: added type-assertions for the new HOF prims
|
||||
* Threads, Objects: new "for" loop primitive in Control category
|
||||
* Threads, Objects: new "if then else" reporter primitive in Control category
|
||||
|
||||
### 2019-04-23
|
||||
* Threads: fixed JS stack overflow issue for MAP primitive
|
||||
|
|
|
@ -752,6 +752,11 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
category: 'control',
|
||||
spec: 'if %b %c else %c'
|
||||
},
|
||||
reportIfElse: {
|
||||
type: 'reporter',
|
||||
category: 'control',
|
||||
spec: 'if %b then %s else %s'
|
||||
},
|
||||
doStopThis: {
|
||||
type: 'command',
|
||||
category: 'control',
|
||||
|
@ -2182,6 +2187,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push('-');
|
||||
blocks.push(block('doIf'));
|
||||
blocks.push(block('doIfElse'));
|
||||
blocks.push(block('reportIfElse'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doReport'));
|
||||
blocks.push(block('doStopThis'));
|
||||
|
@ -7758,6 +7764,7 @@ StageMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push('-');
|
||||
blocks.push(block('doIf'));
|
||||
blocks.push(block('doIfElse'));
|
||||
blocks.push(block('reportIfElse'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doReport'));
|
||||
blocks.push(block('doStopThis'));
|
||||
|
|
|
@ -716,6 +716,7 @@ Process.prototype.evaluateBlock = function (block, argCount) {
|
|||
// check for special forms
|
||||
if (selector === 'reportOr' ||
|
||||
selector === 'reportAnd' ||
|
||||
selector === 'reportIfElse' ||
|
||||
selector === 'doReport') {
|
||||
return this[selector](block);
|
||||
}
|
||||
|
@ -1837,6 +1838,23 @@ Process.prototype.doIfElse = function () {
|
|||
this.pushContext();
|
||||
};
|
||||
|
||||
Process.prototype.reportIfElse = function (block) {
|
||||
var inputs = this.context.inputs;
|
||||
|
||||
if (inputs.length < 1) {
|
||||
this.evaluateNextInput(block);
|
||||
} else if (inputs.length > 1) {
|
||||
if (this.flashContext()) {return; }
|
||||
this.returnValueToParentContext(inputs.pop());
|
||||
this.popContext();
|
||||
} else if (inputs[0]) {
|
||||
this.evaluateNextInput(block);
|
||||
} else {
|
||||
inputs.push(null);
|
||||
this.evaluateNextInput(block);
|
||||
}
|
||||
};
|
||||
|
||||
// Process process related primitives
|
||||
|
||||
Process.prototype.doStop = function () {
|
||||
|
|
Ładowanie…
Reference in New Issue