Skip to content

Commit 38d9ab5

Browse files
committed
Add hook for testing JuliaLowering in core
Based on JuliaSyntax code. Intended to help with JETLS experimentation, which can't currently get info from e.g. Base, which is lowered by flisp
1 parent 5acbfcd commit 38d9ab5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/JuliaLowering.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ _include("syntax_macros.jl")
3333

3434
_include("eval.jl")
3535

36+
_include("hooks.jl")
37+
3638
function __init__()
3739
_register_kinds()
3840
end

src/hooks.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const _has_v1_13_hooks = isdefined(Core, :_setlowerer!)
2+
3+
function core_lowerer_hook(st::SyntaxTree, mod::Module, file, line)
4+
to_lowered_expr(mod, lower(mod, st))
5+
end
6+
7+
"""
8+
Use Julialowering in Core
9+
"""
10+
function activate!(enable=true)
11+
if !_has_v1_13_hooks
12+
error("Cannot use JuliaLowering in $VERSION < 1.13")
13+
end
14+
15+
if enable
16+
Core._setlowerer!(core_lowerer_hook)
17+
else
18+
Core._setlowerer!(nothing)
19+
end
20+
end

0 commit comments

Comments
 (0)