summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-06-21 15:11:21 +0200
committerjmoenig <jens@moenig.org>2013-06-21 15:11:21 +0200
commit8ef095c7196e10bcfe533851a26d162a730947e9 (patch)
tree8d769e6d00c807129139ff278fbfaeba854e82e9
parentf2ec80b20c06da396dc8f445b3dcd9ab7f1ff1d6 (diff)
downloadsnap-8ef095c7196e10bcfe533851a26d162a730947e9.tar.gz
snap-8ef095c7196e10bcfe533851a26d162a730947e9.zip
code mapping: pretty printing support (work-in-progress)
commented out for now, not yet functional
-rw-r--r--blocks.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/blocks.js b/blocks.js
index 033af74..942eae4 100644
--- a/blocks.js
+++ b/blocks.js
@@ -2246,6 +2246,44 @@ BlockMorph.prototype.mappedCode = function () {
return code;
};
+/* // under construction - pretty printing
+BlockMorph.prototype.mappedCode = function () {
+ var key = this.selector.substr(0, 5) === 'reify' ?
+ 'reify' : this.selector,
+ code,
+ codeLines,
+ count = 1,
+ parts = [];
+ code = key === 'reportGetVar' ? this.blockSpec
+ : this.definition ? this.definition.codeMapping || ''
+ : StageMorph.prototype.codeMappings[key] || '';
+ codeLines = code.split('\n');
+ this.inputs().forEach(function (input) {
+ parts.push(input.mappedCode());
+ });
+ parts.forEach(function (part) {
+ var partLines = part.split('\n'),
+ placeHolder = '<#' + count + '>',
+ rx = new RegExp(placeHolder, 'g');
+ codeLines.forEach(function (codeLine) {
+ var prefix = '',
+ indent;
+ if (codeLine.trimLeft().startsWith(placeHolder)) {
+ indent = codeLine.indexOf(placeHolder);
+ prefix = codeLine.slice(0, indent);
+ }
+ code = codeLine.replace(new RexExp(placeHolder), part);
+ code = code.replace(rx, part);
+ });
+ count += 1;
+ });
+ if (this.nextBlock && this.nextBlock()) { // Command
+ code += this.nextBlock().mappedCode();
+ }
+ return code;
+};
+*/
+
BlockMorph.prototype.codeMappingHeader = function () {
var block = this.definition ? this.definition.blockInstance()
: SpriteMorph.prototype.blockForSelector(this.selector),