This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/fennel.lua b/fennel.lua | |
index d824823..f32873e 100644 | |
--- a/fennel.lua | |
+++ b/fennel.lua | |
@@ -2604,7 +2604,7 @@ SPECIALS['include'] = function(ast, scope, parent, opts) | |
-- splice in source and memoize it | |
-- so we can include it again without duplication | |
- local target = gensym(scope) | |
+ local target = gensym(rootScope, "module") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/debug.c b/src/core/debug.c | |
index f433869..2aa238d 100644 | |
--- a/src/core/debug.c | |
+++ b/src/core/debug.c | |
@@ -150,8 +150,44 @@ void janet_stacktrace(JanetFiber *fiber, Janet err) { | |
if (frame->func && frame->pc) { | |
int32_t off = (int32_t)(frame->pc - def->bytecode); | |
if (def->sourcemap) { | |
+ /* Try to get line and column information */ | |
JanetSourceMapping mapping = def->sourcemap[off]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/fennel.lua b/fennel.lua | |
index 8c79320..58341df 100644 | |
--- a/fennel.lua | |
+++ b/fennel.lua | |
@@ -2057,7 +2057,8 @@ local function traceback(msg, start) | |
local level = start or 2 -- Can be used to skip some frames | |
local lines = {} | |
if msg then | |
- table.insert(lines, msg) | |
+ local stripped = msg:gsub('^[^:]*:%d+:%s+', 'runtime error: ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/fennel.lua b/fennel.lua | |
index c079085..dd7252f 100644 | |
--- a/fennel.lua | |
+++ b/fennel.lua | |
@@ -825,7 +825,8 @@ local function keepSideEffects(exprs, chunk, start, ast) | |
if se.type == 'expression' and se[1] ~= 'nil' then | |
emit(chunk, ('do local _ = %s end'):format(tostring(se)), ast) | |
elseif se.type == 'statement' then | |
- emit(chunk, tostring(se), ast) | |
+ local code = tostring(se) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
core_modules = unpack_url( | |
url="https://github.com/buildpackagedeploy/hermes-core/archive/4f92d8aaa001406e58513929710027bc4b733cf2.tar.gz", | |
hash="sha256:db931edc4ddf71a8d749a09f14ed5d771f7099b898273176111452c4b9700983", | |
) | |
bootstrap_env = load_module(core_modules, "bootstrap.hpkg").bootstrap_env | |
janet_src = fetch_url( | |
url="https://github.com/janet-lang/janet/archive/v1.2.0.tar.gz", | |
hash="sha256:e824ee2da7dffab10bb7ce28917b57a82df82eebf713ad2bbb74ed7be36bd4f4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn http-get | |
"Get some HTTP using curl" | |
[url] | |
(with [f (file/popen (string "curl -s " url))] | |
(:read f :all))) | |
(http-get "https://www.google.com") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static JanetFunction *global_cb = NULL; | |
Janet register_callback(int32_t argc, Janet *argv) { | |
janet_fixarity(argc, 1); | |
JanetFunction *cb = janet_getfunciton(argv, 0); | |
global_cb = cb; | |
// Make sure the callback is not garbage collected while waiting | |
janet_gcroot(argv[0]); | |
return janet_wrap_nil(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/fennel.lua b/fennel.lua | |
index 56ee209..a951d5f 100644 | |
--- a/fennel.lua | |
+++ b/fennel.lua | |
@@ -422,6 +422,9 @@ local function makeScope(parent) | |
symmeta = setmetatable({}, { | |
__index = parent and parent.symmeta | |
}), | |
+ includes = setmetatable({}, { | |
+ __index = parent and parent.includes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import shlib) | |
(defn ansi | |
"Take a string made by concatenating xs and colorize it for an ANSI terminal." | |
[code & xs] | |
(string "\e[" code "m" ;xs "\e[0m")) | |
(defn cmd | |
"Run a quick command and strip trailing newline." | |
[s] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(fn line-iter [packets] | |
(var buf "") | |
(fn recur [] | |
(local (residual rest) (: buf :match "^(.*)\r\n(.*)$")) | |
(if residual | |
(do (set buf rest) residual) | |
(let [packet (packets)] | |
(when packet | |
(set buf (.. buf packet)) | |
(recur)))))) |