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