summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorportix <none@none>2013-02-25 16:43:26 +0100
committerportix <none@none>2013-02-25 16:43:26 +0100
commitcf51ec02bdb453a642e3a0a468dc67259d2aa904 (patch)
tree42c77712109084e06fa4c6201bf9bcd9980165c0 /scripts
parentb843d5c2abeee780ec3ef2d14c61e185986e9509 (diff)
downloaddwb-cf51ec02bdb453a642e3a0a468dc67259d2aa904.zip
Check script syntax before creating the script object; implementing Function.debug
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/dwb.js24
-rw-r--r--scripts/lib/io.js8
2 files changed, 29 insertions, 3 deletions
diff --git a/scripts/lib/dwb.js b/scripts/lib/dwb.js
index 584b04dd..ba5f2754 100644
--- a/scripts/lib/dwb.js
+++ b/scripts/lib/dwb.js
@@ -213,5 +213,29 @@
return callback(value);
}
});
+ if (!Function.prototype.debug)
+ {
+ Object.defineProperty(Function.prototype, "debug", {
+ value : function(scope)
+ {
+ var callee;
+ var self = this;
+ if (scope && scope.arguments && scope.arguments.callee)
+ callee = String(scope.arguments.callee);
+ return function() {
+ try
+ {
+ self.apply(self, arguments);
+ }
+ catch (e)
+ {
+ if (callee)
+ e.callee = callee;
+ io.debug(e);
+ }
+ };
+ }
+ });
+ }
})();
Object.preventExtensions(this);
diff --git a/scripts/lib/io.js b/scripts/lib/io.js
index e6f1c4de..77878198 100644
--- a/scripts/lib/io.js
+++ b/scripts/lib/io.js
@@ -10,7 +10,7 @@
var regHasDwb = new RegExp("[^]*/\\*<dwb\\*/([^]*)/\\*dwb>\\*/[^]*");
var formatLine = function(line, max)
{
- var size = max - Math.max(1, Math.ceil(Math.log(line+1)/Math.log(10))) + 1;
+ var size = max - Math.ceil(Math.log(line+1)/Math.log(10)) + 1;
return Array(size).join(" ") + line + " > ";
};
@@ -82,9 +82,9 @@
outMessage += prefixStack + stack;
}
- if (this.arguments && line >= 0)
+ if ((params.callee || this.arguments) && line >= 0)
{
- caller = String(this.arguments.callee).replace(regHasDwb, "$1", "");
+ caller = (params.callee || String(this.arguments.callee)).replace(regHasDwb, "$1", "");
source = caller.split("\n");
var length = source.length;
var max = Math.ceil(Math.log(source.length+1)/Math.log(10));
@@ -105,6 +105,8 @@
outMessage += formatLine(line+1, max) + source[line-1];
if (length > line + 1)
outMessage += "\n...";
+ else
+ outMessage += "\nEOF";
}
else
outMessage += "EOF";