diff options
| author | jmoenig <jens@moenig.org> | 2013-10-08 16:59:55 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-10-08 16:59:55 +0200 |
| commit | 4d5dad807b629486aa0c4cbe5725a5bc1a61487d (patch) | |
| tree | b0067238b5a3bdc7bda9f7a6614424482ef1d459 | |
| parent | 39ea1d542d72194b887efd57e2ccde7174b9d17c (diff) | |
| download | snap-byow-4d5dad807b629486aa0c4cbe5725a5bc1a61487d.tar.gz snap-byow-4d5dad807b629486aa0c4cbe5725a5bc1a61487d.zip | |
experimental MAP primitive reporter
in lists category, visible in dev mode for now
| -rwxr-xr-x | history.txt | 1 | ||||
| -rw-r--r-- | objects.js | 41 | ||||
| -rw-r--r-- | threads.js | 16 |
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 @@ -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) { @@ -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) { |
