summaryrefslogtreecommitdiff
path: root/src/loadlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-09-27 23:05:03 +1000
committerdaurnimator <quae@daurnimator.com>2017-09-27 23:07:32 +1000
commitfcfa9dafbd6cc57c9259d0f0ae5f3aaa32ddd8d1 (patch)
tree6f105b9def5ff89b501249939b413ea90750b505 /src/loadlib.js
parentfbdcb3e7172e31346d66dc8c4385a2d43c40a58a (diff)
downloadfengari-fcfa9dafbd6cc57c9259d0f0ae5f3aaa32ddd8d1.tar.gz
fengari-fcfa9dafbd6cc57c9259d0f0ae5f3aaa32ddd8d1.tar.bz2
fengari-fcfa9dafbd6cc57c9259d0f0ae5f3aaa32ddd8d1.zip
src/loadlib.js: Use sourceURL to get path in debugger+tracebacks
Diffstat (limited to 'src/loadlib.js')
-rw-r--r--src/loadlib.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index a7b27af..e7626ab 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -38,14 +38,19 @@ const AUXMARK = [1];
let lsys_load;
if (WEB) {
lsys_load = function(L, path, seeglb) {
+ path = lua.to_jsstring(path);
let xhr = new XMLHttpRequest();
- xhr.open("GET", lua.to_jsstring(path), false);
+ xhr.open("GET", path, false);
xhr.send();
if (xhr.status >= 200 && xhr.status <= 299) {
+ let code = xhr.response;
+ /* Add sourceURL comment to get path in debugger+tracebacks */
+ if (!/\/\/[#@] sourceURL=/.test(code))
+ code += " //# sourceURL=" + path;
let func;
try {
- func = Function("fengari", xhr.response);
+ func = Function("fengari", code);
} catch (e) {
lua.lua_pushstring(L, lua.to_luastring(`${e.name}: ${e.message}`));
return null;