summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-07-08 13:12:45 +0200
committerjmoenig <jens@moenig.org>2014-07-08 13:12:45 +0200
commite0289f8c411491a08bc077d938767c1cd6e478c4 (patch)
tree5519b3f795b660d52679a506da469f2652ded606
parent17ea18f05733d5f6962266316a6ffa8ca6b0808a (diff)
downloadsnap-e0289f8c411491a08bc077d938767c1cd6e478c4.tar.gz
snap-e0289f8c411491a08bc077d938767c1cd6e478c4.zip
show error messages for custom blocks (sorta)
(propagating to the script’s top block) Also adjust to Doug Crockford’s latest infuriating nitpickings (“unexpected ‘[‘) in JSLint
-rwxr-xr-xhistory.txt10
-rw-r--r--threads.js23
2 files changed, 23 insertions, 10 deletions
diff --git a/history.txt b/history.txt
index 8a519e9..c519516 100755
--- a/history.txt
+++ b/history.txt
@@ -2172,6 +2172,12 @@ ______
* Morphic: Inspector enhancements (dynamic property update, keyboard shortcuts)
* GUI: update visibility of share/unshare buttons, Thanks, Kunal!
-* 140706
---------
+140706
+------
* Blocks: add “ringify” to every context menu that already has “unringify”
+
+
+140708
+------
+* Threads: show error messages for custom blocks (propagating to the script’s top block)
+* Threads: adjust to Doug Crockford’s latest infuriating nitpickings in JSLint
diff --git a/threads.js b/threads.js
index d489441..1ad18b9 100644
--- a/threads.js
+++ b/threads.js
@@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/
// Global stuff ////////////////////////////////////////////////////////
-modules.threads = '2014-Jun-05';
+modules.threads = '2014-July-08';
var ThreadManager;
var Process;
@@ -673,11 +673,13 @@ Process.prototype.doYield = function () {
// Process Exception Handling
Process.prototype.handleError = function (error, element) {
+ var m = element;
this.stop();
this.errorFlag = true;
this.topBlock.addErrorHighlight();
- (element || this.topBlock).showBubble(
- (element ? '' : 'Inside: ')
+ if (isNil(m) || isNil(m.world())) {m = this.topBlock; }
+ m.showBubble(
+ (m === element ? '' : 'Inside: ')
+ error.name
+ '\n'
+ error.message
@@ -996,6 +998,8 @@ Process.prototype.evaluateCustomBlock = function () {
runnable,
extra,
i,
+ inp,
+ decs,
value,
upvars,
outer;
@@ -1029,17 +1033,19 @@ Process.prototype.evaluateCustomBlock = function () {
if (!isNil(parms[i])) {
value = parms[i];
}
- outer.variables.addVar(context.inputs[i], value);
+ inp = context.inputs[i];
+ outer.variables.addVar(inp, value);
// if the parameter is an upvar,
// create an UpvarReference to it
- if (declarations[context.inputs[i]][0] === '%upvar') {
+ decs = declarations[inp];
+ if (decs[0] === '%upvar') {
if (!upvars) { // lazy initialization
upvars = new UpvarReference(this.context.upvars);
}
upvars.addReference(
value,
- context.inputs[i],
+ inp,
outer.variables
);
}
@@ -3156,8 +3162,9 @@ UpvarReference.prototype.find = function (name) {
};
UpvarReference.prototype.getVar = function (name) {
- var varName = this.vars[name][0],
- varFrame = this.vars[name][1],
+ var tuple = this.vars[name],
+ varName = tuple[0],
+ varFrame = tuple[1],
value = varFrame.vars[varName];
return (value === 0 ? 0 : value || 0); // don't return null
};