summaryrefslogtreecommitdiff
path: root/threads.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2013-06-18 18:43:15 +0200
committerjmoenig <jens@moenig.org>2013-06-18 18:43:15 +0200
commitacc40a6d2a06ab1fcfbd488030e091bd9215a1b2 (patch)
tree57374704c2b908df2c1d8721f8a055a0f1378d1e /threads.js
parenta7ebff7c5bb4a79b3a64441b50957e523fe686e0 (diff)
downloadsnap-byow-acc40a6d2a06ab1fcfbd488030e091bd9215a1b2.tar.gz
snap-byow-acc40a6d2a06ab1fcfbd488030e091bd9215a1b2.zip
Code mapping
generating text code from blocks, first experimental iteration
Diffstat (limited to 'threads.js')
-rw-r--r--threads.js49
1 files changed, 48 insertions, 1 deletions
diff --git a/threads.js b/threads.js
index 2a1802c..d98d2b5 100644
--- a/threads.js
+++ b/threads.js
@@ -83,7 +83,7 @@ ArgLabelMorph, localize*/
// Global stuff ////////////////////////////////////////////////////////
-modules.threads = '2013-May-14';
+modules.threads = '2013-June-18';
var ThreadManager;
var Process;
@@ -2284,6 +2284,53 @@ Process.prototype.reportTimer = function () {
return 0;
};
+// Process code mapping
+
+/*
+ for generating textual source code using
+ blocks - not needed to run or debug Snap
+*/
+
+Process.prototype.doMapCode = function (aContext, aString) {
+ if (aContext instanceof Context) {
+ if (aContext.expression instanceof SyntaxElementMorph) {
+ return aContext.expression.mapCode(aString || '');
+ }
+ }
+};
+
+Process.prototype.doMapStringCode = function (aString) {
+ StageMorph.prototype.codeMappings.string = aString || '<#1>';
+};
+
+Process.prototype.doMapListCode = function (part, kind, aString) {
+ var key1 = '',
+ key2 = 'delim';
+
+ if (this.inputOption(kind) === 'parameters') {
+ key1 = 'parms_';
+ } else if (this.inputOption(kind) === 'variables') {
+ key1 = 'tempvars_';
+ }
+
+ if (this.inputOption(part) === 'list') {
+ key2 = 'list';
+ } else if (this.inputOption(part) === 'item') {
+ key2 = 'item';
+ }
+
+ StageMorph.prototype.codeMappings[key1 + key2] = aString || '';
+};
+
+Process.prototype.reportMappedCode = function (aContext) {
+ if (aContext instanceof Context) {
+ if (aContext.expression instanceof SyntaxElementMorph) {
+ return aContext.expression.mappedCode();
+ }
+ }
+ return '';
+};
+
// Process music primitives
Process.prototype.doRest = function (beats) {