136136# Debug log file for dumping parsed code
137137const _debug_log = Ref {Union{Nothing,IO}} (nothing )
138138
139- function core_parser_hook (code, filename:: String , lineno:: Int , offset:: Int , options:: Symbol )
139+ function core_parser_hook_for_lowering (code, filename:: String , lineno:: Int , offset:: Int , options:: Symbol )
140+ core_parser_hook (code, filename:: String , lineno:: Int , offset:: Int , options:: Symbol , true )
141+ end
142+
143+ function core_parser_hook (code, filename:: String , lineno:: Int , offset:: Int , options:: Symbol , for_lowering= false )
140144 try
141145 # TODO : Check that we do all this input wrangling without copying the
142146 # code buffer
@@ -233,7 +237,7 @@ function core_parser_hook(code, filename::String, lineno::Int, offset::Int, opti
233237 #
234238 # show_diagnostics(stdout, stream.diagnostics, code)
235239 #
236- ex = build_tree (Expr, stream; filename= filename, first_line= lineno)
240+ ex = build_tree (for_lowering ? Tuple{Expr, SyntaxNode} : Expr, stream; filename= filename, first_line= lineno)
237241 end
238242
239243 # Note the next byte in 1-based indexing is `last_byte(stream) + 1` but
@@ -292,7 +296,7 @@ _default_system_parser = _has_v1_6_hooks ? Core._parse : nothing
292296
293297
294298# hook into InteractiveUtils.@activate
295- activate! () = enable_in_core! ()
299+ activate! (enable = true ) = enable_in_core! (enable )
296300
297301"""
298302 enable_in_core!([enable=true; freeze_world_age=true, debug_filename=nothing])
@@ -319,7 +323,10 @@ function enable_in_core!(enable=true; freeze_world_age = true,
319323 close (_debug_log[])
320324 _debug_log[] = nothing
321325 end
322- if enable
326+ if enable == :JuliaLowering
327+ world_age = freeze_world_age ? Base. get_world_counter () : typemax (UInt)
328+ _set_core_parse_hook (fix_world_age (core_parser_hook_for_lowering, world_age))
329+ elseif enable
323330 world_age = freeze_world_age ? Base. get_world_counter () : typemax (UInt)
324331 _set_core_parse_hook (fix_world_age (core_parser_hook, world_age))
325332 else
0 commit comments