summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhistory.txt1
-rw-r--r--objects.js41
-rw-r--r--threads.js16
3 files changed, 55 insertions, 3 deletions
diff --git a/history.txt b/history.txt
index 2ef91cb..135ee7f 100755
--- a/history.txt
+++ b/history.txt
@@ -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
diff --git a/objects.js b/objects.js
index dfdd826..74ea20c 100644
--- a/objects.js
+++ b/objects.js
@@ -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) {
diff --git a/threads.js b/threads.js
index a705f28..ee28e59 100644
--- a/threads.js
+++ b/threads.js
@@ -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) {