Skip to content

Commit 8d7cce6

Browse files
committed
Pass enter_generated settings through to recursive frame creation
1 parent 3fa687f commit 8d7cce6

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/construct.jl

+7-3
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

+1-1
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

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ end
1818
function step_through_frame(frame_creator)
1919
rets = []
2020
for cmd in ALL_COMMANDS
21-
frame = frame_creator()
21+
frame = frame_creator()
2222
ret = step_through_command(frame, cmd)
2323
push!(rets, ret)
2424
end
@@ -28,8 +28,8 @@ end
2828
step_through(f, args...; kwargs...) = step_through_frame(() -> enter_call(f, args...; kwargs...))
2929
step_through(expr::Expr) = step_through_frame(() -> enter_call_expr(expr))
3030

31-
@generated function generatedfoo(T)
32-
:(return $T)
31+
@generated function generatedfoo(x)
32+
:(return x)
3333
end
3434
callgenerated() = generatedfoo(1)
3535
@generated function generatedparams(a::Array{T,N}) where {T,N}
@@ -91,23 +91,23 @@ struct B{T} end
9191
@test isa(pc, BreakpointRef)
9292
@test JuliaInterpreter.scopeof(f).name == :generatedfoo
9393
stmt = JuliaInterpreter.pc_expr(f)
94-
@test stmt.head == :return && stmt.args[1] === Int
94+
@test stmt.head == :return
9595
@test debug_command(frame, :c) === nothing
9696
@test frame.callee === nothing
97-
@test get_return(frame) === Int
97+
@test get_return(frame) === 1
9898
# This time, step into the generated function itself
9999
frame = enter_call_expr(:($(callgenerated)()))
100100
f, pc = debug_command(frame, :sg)
101101
@test isa(pc, BreakpointRef)
102102
@test JuliaInterpreter.scopeof(f).name == :generatedfoo
103103
stmt = JuliaInterpreter.pc_expr(f)
104-
@test stmt.head == :return && @lookup(f, stmt.args[1]) === 1
104+
@test stmt.head == :return
105105
f2, pc = debug_command(f, :finish)
106106
@test JuliaInterpreter.scopeof(f2).name == :callgenerated
107107
# Now finish the regular function
108108
@test debug_command(frame, :finish) === nothing
109109
@test frame.callee === nothing
110-
@test get_return(frame) === 1
110+
@test get_return(frame) === Int
111111

112112
# Parametric generated function (see #157)
113113
frame = fr = JuliaInterpreter.enter_call(callgeneratedparams)

0 commit comments

Comments
 (0)