experimental MAP primitive reporter

in lists category, visible in dev mode for now
pull/3/merge
jmoenig 2013-10-08 16:59:55 +02:00
rodzic 39ea1d542d
commit 4d5dad807b
3 zmienionych plików z 55 dodań i 3 usunięć

Wyświetl plik

@ -1944,3 +1944,4 @@ ______
131008
------
* Lists: fixed type-issue for linked list indices (thanks, Nate, for reporting it!)
* Threads, Objects: experimental MAP primitive reporter in lists category, visible in dev mode

Wyświetl plik

@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
modules.objects = '2013-October-04';
modules.objects = '2013-October-08';
var SpriteMorph;
var StageMorph;
@ -1045,6 +1045,13 @@ SpriteMorph.prototype.initBlocks = function () {
defaults: [1, null, localize('thing')]
},
// MAP - experimental
reportMap: {
type: 'reporter',
category: 'lists',
spec: 'map %repRing over %l'
},
// Code mapping - experimental
doMapCodeOrHeader: { // experimental
type: 'command',
@ -1850,6 +1857,22 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('doInsertInList'));
blocks.push(block('doReplaceInList'));
// for debugging: ///////////////
if (this.world().isDevMode) {
blocks.push('-');
txt = new TextMorph(localize(
'development mode \ndebugging primitives:'
));
txt.fontSize = 9;
txt.setColor(this.paletteTextColor);
blocks.push(txt);
blocks.push('-');
blocks.push(block('reportMap'));
}
/////////////////////////////////
blocks.push('=');
if (StageMorph.prototype.enableCodeMapping) {
@ -4485,6 +4508,22 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push(block('doInsertInList'));
blocks.push(block('doReplaceInList'));
// for debugging: ///////////////
if (this.world().isDevMode) {
blocks.push('-');
txt = new TextMorph(localize(
'development mode \ndebugging primitives:'
));
txt.fontSize = 9;
txt.setColor(this.paletteTextColor);
blocks.push(txt);
blocks.push('-');
blocks.push(block('reportMap'));
}
/////////////////////////////////
blocks.push('=');
if (StageMorph.prototype.enableCodeMapping) {

Wyświetl plik

@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/
// Global stuff ////////////////////////////////////////////////////////
modules.threads = '2013-October-04';
modules.threads = '2013-October-08';
var ThreadManager;
var Process;
@ -778,7 +778,7 @@ Process.prototype.evaluate = function (
runnable.isImplicitLambda = context.isImplicitLambda;
runnable.isCustomBlock = false;
// assing parameters if any were passed
// assign parameters if any were passed
if (parms.length > 0) {
// assign formal parameters
@ -1515,6 +1515,18 @@ Process.prototype.doWaitUntil = function (goalCondition) {
this.pushContext();
};
Process.prototype.reportMap = function (reporter, list) {
if (this.context.inputs.length - 2 === list.length()) {
this.returnValueToParentContext(
new List(this.context.inputs.slice(2))
);
return;
}
var next = list.at(this.context.inputs.length - 1);
this.pushContext();
this.evaluate(reporter, new List([next]));
};
// Process interpolated primitives
Process.prototype.doWait = function (secs) {