Skip to content

Commit d1a99cf

Browse files
committed
Remove mod::Module parameter from to_lowered_expr
The module parameter was unused in the conversion process, so it has been removed from `to_lowered_expr`, `to_code_info`, and `_to_lowered_expr` functions along with all their call sites.
1 parent 2a76fa3 commit d1a99cf

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

JuliaLowering/src/eval.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ end
120120

121121
# Convert SyntaxTree to the CodeInfo+Expr data stuctures understood by the
122122
# Julia runtime
123-
function to_code_info(ex::SyntaxTree, mod::Module, slots::Vector{Slot})
123+
function to_code_info(ex::SyntaxTree, slots::Vector{Slot})
124124
stmts = Any[]
125125

126126
current_codelocs_stack = ir_debug_info_state(ex)
@@ -155,7 +155,7 @@ function to_code_info(ex::SyntaxTree, mod::Module, slots::Vector{Slot})
155155

156156
stmt_offset = length(stmts)
157157
for stmt in children(ex)
158-
push!(stmts, _to_lowered_expr(mod, stmt, stmt_offset))
158+
push!(stmts, _to_lowered_expr(stmt, stmt_offset))
159159
add_ir_debug_info!(current_codelocs_stack, stmt)
160160
end
161161

@@ -222,11 +222,11 @@ function to_code_info(ex::SyntaxTree, mod::Module, slots::Vector{Slot})
222222
)
223223
end
224224

225-
@fzone "JL: to_lowered_expr" function to_lowered_expr(mod::Module, ex::SyntaxTree)
226-
_to_lowered_expr(mod, ex, 0)
225+
@fzone "JL: to_lowered_expr" function to_lowered_expr(ex::SyntaxTree)
226+
_to_lowered_expr(ex, 0)
227227
end
228228

229-
function _to_lowered_expr(mod::Module, ex::SyntaxTree, stmt_offset::Int)
229+
function _to_lowered_expr(ex::SyntaxTree, stmt_offset::Int)
230230
k = kind(ex)
231231
if is_literal(k)
232232
ex.value
@@ -262,12 +262,12 @@ function _to_lowered_expr(mod::Module, ex::SyntaxTree, stmt_offset::Int)
262262
elseif k == K"SSAValue"
263263
Core.SSAValue(ex.var_id + stmt_offset)
264264
elseif k == K"return"
265-
Core.ReturnNode(_to_lowered_expr(mod, ex[1], stmt_offset))
265+
Core.ReturnNode(_to_lowered_expr(ex[1], stmt_offset))
266266
elseif k == K"inert"
267267
e1 = ex[1]
268268
getmeta(ex, :as_Expr, false) ? QuoteNode(Expr(e1)) : e1
269269
elseif k == K"code_info"
270-
ir = to_code_info(ex[1], mod, ex.slots)
270+
ir = to_code_info(ex[1], ex.slots)
271271
if ex.is_toplevel_thunk
272272
Expr(:thunk, ir)
273273
else
@@ -278,36 +278,36 @@ function _to_lowered_expr(mod::Module, ex::SyntaxTree, stmt_offset::Int)
278278
elseif k == K"goto"
279279
Core.GotoNode(ex[1].id + stmt_offset)
280280
elseif k == K"gotoifnot"
281-
Core.GotoIfNot(_to_lowered_expr(mod, ex[1], stmt_offset), ex[2].id + stmt_offset)
281+
Core.GotoIfNot(_to_lowered_expr(ex[1], stmt_offset), ex[2].id + stmt_offset)
282282
elseif k == K"enter"
283283
catch_idx = ex[1].id
284284
numchildren(ex) == 1 ?
285285
Core.EnterNode(catch_idx) :
286-
Core.EnterNode(catch_idx, _to_lowered_expr(mod, ex[2], stmt_offset))
286+
Core.EnterNode(catch_idx, _to_lowered_expr(ex[2], stmt_offset))
287287
elseif k == K"method"
288-
cs = map(e->_to_lowered_expr(mod, e, stmt_offset), children(ex))
288+
cs = map(e->_to_lowered_expr(e, stmt_offset), children(ex))
289289
# Ad-hoc unwrapping to satisfy `Expr(:method)` expectations
290290
c1 = cs[1] isa QuoteNode ? cs[1].value : cs[1]
291291
Expr(:method, c1, cs[2:end]...)
292292
elseif k == K"newvar"
293-
Core.NewvarNode(_to_lowered_expr(mod, ex[1], stmt_offset))
293+
Core.NewvarNode(_to_lowered_expr(ex[1], stmt_offset))
294294
elseif k == K"opaque_closure_method"
295-
args = map(e->_to_lowered_expr(mod, e, stmt_offset), children(ex))
295+
args = map(e->_to_lowered_expr(e, stmt_offset), children(ex))
296296
# opaque_closure_method has special non-evaluated semantics for the
297297
# `functionloc` line number node so we need to undo a level of quoting
298298
@assert args[4] isa QuoteNode
299299
args[4] = args[4].value
300300
Expr(:opaque_closure_method, args...)
301301
elseif k == K"meta"
302-
args = Any[_to_lowered_expr(mod, e, stmt_offset) for e in children(ex)]
302+
args = Any[_to_lowered_expr(e, stmt_offset) for e in children(ex)]
303303
# Unpack K"Symbol" QuoteNode as `Expr(:meta)` requires an identifier here.
304304
args[1] = args[1].value
305305
Expr(:meta, args...)
306306
elseif k == K"static_eval"
307307
@assert numchildren(ex) == 1
308-
_to_lowered_expr(mod, ex[1], stmt_offset)
308+
_to_lowered_expr(ex[1], stmt_offset)
309309
elseif k == K"cfunction"
310-
args = Any[_to_lowered_expr(mod, e, stmt_offset) for e in children(ex)]
310+
args = Any[_to_lowered_expr(e, stmt_offset) for e in children(ex)]
311311
if kind(ex[2]) == K"static_eval"
312312
args[2] = QuoteNode(args[2])
313313
end
@@ -339,7 +339,7 @@ function _to_lowered_expr(mod::Module, ex::SyntaxTree, stmt_offset::Int)
339339
if isnothing(head)
340340
throw(LoweringError(ex, "Unhandled form for kind $k"))
341341
end
342-
Expr(head, map(e->_to_lowered_expr(mod, e, stmt_offset), children(ex))...)
342+
Expr(head, map(e->_to_lowered_expr(e, stmt_offset), children(ex))...)
343343
end
344344
end
345345

@@ -355,7 +355,7 @@ end
355355
return x
356356
end
357357
linear_ir = lower(mod, ex; expr_compat_mode)
358-
thunk = to_lowered_expr(mod, linear_ir)
358+
thunk = to_lowered_expr(linear_ir)
359359
Core.eval(mod, thunk)
360360
end
361361

JuliaLowering/src/hooks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function core_lowering_hook(@nospecialize(code), mod::Module,
2222
ctx3, st3 = resolve_scopes( ctx2, st2)
2323
ctx4, st4 = convert_closures(ctx3, st3)
2424
ctx5, st5 = linearize_ir( ctx4, st4)
25-
ex = to_lowered_expr(mod, st5)
25+
ex = to_lowered_expr(st5)
2626
return Core.svec(ex, st5, ctx5)
2727
catch exc
2828
@info("JuliaLowering threw given input:", code=code, st0=st0, file=file, line=line, mod=mod)

JuliaLowering/src/macro_expansion.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function eval_macro_name(ctx::MacroExpansionContext, mctx::MacroContext, ex::Syn
147147
ctx4, ex4 = convert_closures(ctx3, ex3)
148148
ctx5, ex5 = linearize_ir(ctx4, ex4)
149149
mod = current_layer(ctx).mod
150-
expr_form = to_lowered_expr(mod, ex5)
150+
expr_form = to_lowered_expr(ex5)
151151
try
152152
Core.eval(mod, expr_form)
153153
catch err

JuliaLowering/src/precompile.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if Base.get_bool_env("JULIA_LOWERING_PRECOMPILE", true)
2121
JuliaSyntax.parse!(stream; rule=:all)
2222
st0 = JuliaSyntax.build_tree(SyntaxTree, stream; filename=@__FILE__)
2323
lwrst = lower(@__MODULE__, st0[1])
24-
lwr = to_lowered_expr(@__MODULE__, lwrst)
24+
lwr = to_lowered_expr(lwrst)
2525
@assert Meta.isexpr(lwr, :thunk) && only(lwr.args) isa Core.CodeInfo
2626
end
2727
end

JuliaLowering/src/runtime.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ function (g::GeneratedFunctionStub)(world::UInt, source::Method, @nospecialize a
399399
# Rest of lowering
400400
ctx4, ex4 = convert_closures(ctx3, ex3)
401401
ctx5, ex5 = linearize_ir(ctx4, ex4)
402-
ci = to_lowered_expr(__module__, ex5)
402+
ci = to_lowered_expr(ex5)
403403
@assert ci isa Core.CodeInfo
404404

405405
# See GeneratedFunctionStub code in base/expr.jl

JuliaLowering/test/demo.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function debug_lower(mod::Module, ex::SyntaxTree; expr_compat_mode::Bool=false,
4949
ctx5, ex_compiled = JuliaLowering.linearize_ir(ctx4, ex_converted)
5050
verbose && @info "Linear IR" formatsrc(ex_compiled, color_by=:var_id) Text(sprint(JuliaLowering.print_ir, ex_compiled))
5151

52-
ex_expr = JuliaLowering.to_lowered_expr(mod, ex_compiled)
52+
ex_expr = JuliaLowering.to_lowered_expr(ex_compiled)
5353
verbose && @info "CodeInfo" ex_expr
5454

5555
if do_eval

JuliaLowering/test/repl_mode.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function eval_ish(mod::Module, ex::SyntaxTree, do_eval::Bool, do_print_ir::Bool)
3434
end
3535
if do_eval
3636
println(stdout, "#----------------------")
37-
expr_form = JuliaLowering.to_lowered_expr(mod, linear_ir)
37+
expr_form = JuliaLowering.to_lowered_expr(linear_ir)
3838
Base.eval(mod, expr_form)
3939
end
4040
end

JuliaLowering/test/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ end
264264

265265
function lower_str(mod::Module, s::AbstractString)
266266
ex = parsestmt(JuliaLowering.SyntaxTree, s)
267-
return JuliaLowering.to_lowered_expr(mod, JuliaLowering.lower(mod, ex))
267+
return JuliaLowering.to_lowered_expr(JuliaLowering.lower(mod, ex))
268268
end
269269

270270
# See Julia Base tests in "test/docs.jl"
@@ -362,7 +362,7 @@ function reduce_any_failing_toplevel(mod::Module, filename::AbstractString; do_e
362362
for ex in children(ex0)
363363
try
364364
ex_compiled = JuliaLowering.lower(mod, ex)
365-
ex_expr = JuliaLowering.to_lowered_expr(mod, ex_compiled)
365+
ex_expr = JuliaLowering.to_lowered_expr(ex_compiled)
366366
if do_eval
367367
Base.eval(mod, ex_expr)
368368
end

0 commit comments

Comments
 (0)