Skip to content

Commit 46e5452

Browse files
committed
Pass enter_generated settings through to recursive frame creation
1 parent cb6ed25 commit 46e5452

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/construct.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,11 @@ end
292292
Construct a new `Frame` for `framecode`, given lowered-code arguments `frameargs` and
293293
static parameters `lenv`. See [`JuliaInterpreter.prepare_call`](@ref) for information about how to prepare the inputs.
294294
"""
295-
function prepare_frame(framecode::FrameCode, args::Vector{Any}, lenv::SimpleVector)
295+
function prepare_frame(framecode::FrameCode, args::Vector{Any}, lenv::SimpleVector; enter_generated=false)
296+
s = scopeof(framecode)
297+
if isa(s, Method) && is_generated(s) && enter_generated
298+
args = Any[_Typeof(a) for a in args]
299+
end
296300
framedata = prepare_framedata(framecode, args)
297301
resize!(framedata.sparams, length(lenv))
298302
# Add static parameters to environment
@@ -304,8 +308,8 @@ function prepare_frame(framecode::FrameCode, args::Vector{Any}, lenv::SimpleVect
304308
return Frame(framecode, framedata)
305309
end
306310

307-
function prepare_frame_caller(caller::Frame, framecode::FrameCode, args::Vector{Any}, lenv::SimpleVector)
308-
caller.callee = frame = prepare_frame(framecode, args, lenv)
311+
function prepare_frame_caller(caller::Frame, framecode::FrameCode, args::Vector{Any}, lenv::SimpleVector; enter_generated=false)
312+
caller.callee = frame = prepare_frame(framecode, args, lenv; enter_generated=enter_generated)
309313
frame.caller = caller
310314
return frame
311315
end

src/interpret.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function evaluate_call_recurse!(@nospecialize(recurse), frame::Frame, call_expr:
208208
end
209209
return framecode # this was a Builtin
210210
end
211-
newframe = prepare_frame_caller(frame, framecode, fargs, lenv)
211+
newframe = prepare_frame_caller(frame, framecode, fargs, lenv; enter_generated=enter_generated)
212212
npc = newframe.pc
213213
shouldbreak(newframe, npc) && return BreakpointRef(newframe.framecode, npc)
214214
# if the following errors, handle_err will pop the stack and recycle newframe

test/debug.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ function step_through_function(f, args...)
2121
return JuliaInterpreter.get_return(frame)
2222
end
2323

24-
@generated function generatedfoo(T)
25-
:(return $T)
24+
@generated function generatedfoo(x)
25+
:(return x)
2626
end
2727
callgenerated() = generatedfoo(1)
2828
@generated function generatedparams(a::Array{T,N}) where {T,N}
@@ -87,23 +87,23 @@ struct B{T} end
8787
@test isa(pc, BreakpointRef)
8888
@test JuliaInterpreter.scopeof(f).name == :generatedfoo
8989
stmt = JuliaInterpreter.pc_expr(f)
90-
@test stmt.head == :return && stmt.args[1] === Int
90+
@test stmt.head == :return
9191
@test debug_command(frame, "c") === nothing
9292
@test frame.callee === nothing
93-
@test get_return(frame) === Int
93+
@test get_return(frame) === 1
9494
# This time, step into the generated function itself
9595
frame = enter_call_expr(:($(callgenerated)()))
9696
f, pc = debug_command(frame, "sg")
9797
@test isa(pc, BreakpointRef)
9898
@test JuliaInterpreter.scopeof(f).name == :generatedfoo
9999
stmt = JuliaInterpreter.pc_expr(f)
100-
@test stmt.head == :return && @lookup(f, stmt.args[1]) === 1
100+
@test stmt.head == :return
101101
f2, pc = debug_command(f, "finish")
102102
@test JuliaInterpreter.scopeof(f2).name == :callgenerated
103103
# Now finish the regular function
104104
@test debug_command(frame, "finish") === nothing
105105
@test frame.callee === nothing
106-
@test get_return(frame) === 1
106+
@test get_return(frame) === Int
107107

108108
# Parametric generated function (see #157)
109109
frame = fr = JuliaInterpreter.enter_call(callgeneratedparams)

0 commit comments

Comments
 (0)