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 )
223223end
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 )
227227end
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
344344end
345345
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)
360360end
361361
0 commit comments