From acc40a6d2a06ab1fcfbd488030e091bd9215a1b2 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 18 Jun 2013 18:43:15 +0200 Subject: Code mapping generating text code from blocks, first experimental iteration --- objects.js | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 59a9d49..cdddb45 100644 --- a/objects.js +++ b/objects.js @@ -123,7 +123,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2013-June-05'; +modules.objects = '2013-June-18'; var SpriteMorph; var StageMorph; @@ -1016,6 +1016,29 @@ SpriteMorph.prototype.initBlocks = function () { category: 'lists', spec: 'replace item %idx of %l with %s', defaults: [1, null, localize('thing')] + }, + + // Code mapping - experimental + doMapCode: { // experimental + type: 'command', + category: 'other', + spec: 'map %cmdRing to code %s' + }, + doMapStringCode: { // experimental + type: 'command', + category: 'other', + spec: 'map String to code %s', + defaults: ['<#1>'] + }, + doMapListCode: { // experimental + type: 'command', + category: 'other', + spec: 'map %codeListPart of %codeListKind to code %s' + }, + reportMappedCode: { // experimental + type: 'reporter', + category: 'other', + spec: 'code of %cmdRing' } }; }; @@ -1771,6 +1794,15 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('='); + if (StageMorph.prototype.enableCodeMapping) { + blocks.push(block('doMapCode')); + blocks.push(block('doMapStringCode')); + blocks.push(block('doMapListCode')); + blocks.push('-'); + blocks.push(block('reportMappedCode')); + blocks.push('='); + } + button = new PushButtonMorph( null, function () { @@ -3189,6 +3221,8 @@ StageMorph.prototype.paletteTextColor = SpriteMorph.prototype.paletteTextColor; StageMorph.prototype.hiddenPrimitives = {}; +StageMorph.prototype.codeMappings = {}; +StageMorph.prototype.enableCodeMapping = false; // StageMorph instance creation @@ -4011,6 +4045,15 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('='); + if (StageMorph.prototype.enableCodeMapping) { + blocks.push(block('doMapCode')); + blocks.push(block('doMapStringCode')); + blocks.push(block('doMapListCode')); + blocks.push('-'); + blocks.push(block('reportMappedCode')); + blocks.push('='); + } + button = new PushButtonMorph( null, function () { -- cgit v1.3.1