Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - js3 - die() shows stack trace
  • Loading branch information
fglock committed Sep 29, 2012
1 parent 4bb1644 commit 2144d48
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions perlito5.pl

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src5/lib/Perlito5/Javascript3/CORE.pm
Expand Up @@ -51,11 +51,16 @@ CORE.say = function(List__) {
};
CORE.die = function(List__) {
var o = List__[0]._array_; // prototype is '@'
var i;
var s = "";
for (i = 0; i < List__.length; i++) {
s = s + p5str(List__[i]);
for (i = 0; i < o.length; i++) {
s = s + p5str(o[i]);
}
try {
s = s + "\n" + new Error().stack;
}
catch(err) { }
p5pkg["main"]["v_@"].assign("Died: " + s);
throw(new p5_error("die", "Died: " + s));
};
Expand Down
7 changes: 7 additions & 0 deletions src5/lib/Perlito5/Javascript3/IO.pm
Expand Up @@ -30,6 +30,7 @@ if (isNode) {
var fs = require("fs");
p5atime = function(s) {
s = p5str(s);
try {
var stat = fs.statSync(s); return stat["atime"];
}
Expand All @@ -38,6 +39,7 @@ if (isNode) {
}
};
p5mtime = function(s) {
s = p5str(s);
try {
var stat = fs.statSync(s); return stat["mtime"];
}
Expand All @@ -46,6 +48,7 @@ if (isNode) {
}
};
p5ctime = function(s) {
s = p5str(s);
try {
var stat = fs.statSync(s); return stat["ctime"];
}
Expand All @@ -54,6 +57,7 @@ if (isNode) {
}
};
p5size = function(s) {
s = p5str(s);
try {
var stat = fs.statSync(s); return stat["size"];
}
Expand All @@ -62,6 +66,7 @@ if (isNode) {
}
};
p5is_file = function(s) {
s = p5str(s);
try {
var stat = fs.statSync(s); return stat.isFile() ? 1 : 0;
}
Expand All @@ -70,6 +75,7 @@ if (isNode) {
}
};
p5is_directory = function(s) {
s = p5str(s);
try {
var stat = fs.statSync(s); return stat.isDirectory() ? 1 : 0;
}
Expand All @@ -78,6 +84,7 @@ if (isNode) {
}
};
p5file_exists = function(s) {
s = p5str(s);
return p5is_file(s) || p5is_directory(s);
};
Expand Down
6 changes: 3 additions & 3 deletions src5/lib/Perlito5/Javascript3/Runtime.pm
Expand Up @@ -1078,11 +1078,11 @@ p5sort = function(namespace, func, args) {
perl5_to_js = function( source, namespace, var_env_js, p5want ) {
// CORE.say(["source: [" + source + "]"]);
var strict_old = p5pkg["Perlito5"].v_STRICT.FETCH();
var var_env_js_old = p5pkg["Perlito5"].v_VAR.FETCH();
var strict_old = p5global("$", "Perlito5", "STRICT").FETCH();
var var_env_js_old = p5global("$", "Perlito5", "VAR").FETCH();
p5pkg["Perlito5"].v_VAR.assign(var_env_js);
var namespace_old = p5pkg["Perlito5"].v_PKG_NAME.FETCH();
var namespace_old = p5global("$", "Perlito5", "PKG_NAME").FETCH();
p5pkg["Perlito5"].v_PKG_NAME.assign(namespace);
match = p5call(p5pkg["Perlito5::Grammar"], "exp_stmts", [source, 0]);
Expand Down

0 comments on commit 2144d48

Please sign in to comment.