summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2014-12-07 11:48:49 +0100
committerGubolin <gubolin@fantasymail.de>2014-12-07 11:48:49 +0100
commitb54db1deb957796e4fa224f11f19dfe32fe5721e (patch)
tree24e78d3907e990d160e866b418fc140352242e20
parent368daaeb7d9cebf8589df30267508fcbef1d7392 (diff)
parente974613563ef68e772ce31805a168003e84a21c0 (diff)
downloadsnap-b54db1deb957796e4fa224f11f19dfe32fe5721e.tar.gz
snap-b54db1deb957796e4fa224f11f19dfe32fe5721e.zip
Merge branch 'errorHandling_issue533' into development
-rw-r--r--threads.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/threads.js b/threads.js
index c21375e..54da3e8 100644
--- a/threads.js
+++ b/threads.js
@@ -733,6 +733,13 @@ Process.prototype.expectReport = function () {
// Process Exception Handling
+Process.prototype.checkIfList = function (maybeList) {
+ if (!(maybeList instanceof List)) {
+ maybeList = new List();
+ }
+ return maybeList;
+};
+
Process.prototype.handleError = function (error, element) {
var m = element;
this.stop();
@@ -1304,15 +1311,19 @@ Process.prototype.reportCONS = function (car, cdr) {
};
Process.prototype.reportCDR = function (list) {
+ list = this.checkIfList(list);
return list.cdr();
};
Process.prototype.doAddToList = function (element, list) {
+ list = this.checkIfList(list);
list.add(element);
};
Process.prototype.doDeleteFromList = function (index, list) {
var idx = index;
+ list = this.checkIfList(list);
+
if (this.inputOption(index) === 'all') {
return list.clear();
}
@@ -1327,6 +1338,8 @@ Process.prototype.doDeleteFromList = function (index, list) {
Process.prototype.doInsertInList = function (element, index, list) {
var idx = index;
+ list = this.checkIfList(list);
+
if (index === '') {
return null;
}
@@ -1341,6 +1354,8 @@ Process.prototype.doInsertInList = function (element, index, list) {
Process.prototype.doReplaceInList = function (index, list, element) {
var idx = index;
+ list = this.checkIfList(list);
+
if (index === '') {
return null;
}
@@ -1355,6 +1370,8 @@ Process.prototype.doReplaceInList = function (index, list, element) {
Process.prototype.reportListItem = function (index, list) {
var idx = index;
+ list = this.checkIfList(list);
+
if (index === '') {
return '';
}
@@ -1368,10 +1385,12 @@ Process.prototype.reportListItem = function (index, list) {
};
Process.prototype.reportListLength = function (list) {
+ list = this.checkIfList(list);
return list.length();
};
Process.prototype.reportListContainsItem = function (list, element) {
+ list = this.checkIfList(list);
return list.contains(element);
};
@@ -1630,6 +1649,8 @@ Process.prototype.reportMap = function (reporter, list) {
// documented in each of the variants' code (linked or arrayed) below
var next;
+ list = this.checkIfList(list);
+
if (list.isLinked) {
// this.context.inputs:
// [0] - reporter