Skip to content

Commit

Permalink
allow overload for next_or_nothing! (#115)
Browse files Browse the repository at this point in the history
I am writing a solution for #99 by
overloading `next_or_nothing!`. This PR serves as a preparation for
that, while the basic usage of LCU remains unchanged.
  • Loading branch information
aviatesk committed Sep 10, 2024
1 parent 5277734 commit 54f6697
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/codeedges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ function selective_eval!(@nospecialize(recurse), frame::Frame, isrequired::Abstr
if te
pcexec = pc = step_expr!(recurse, frame, istoplevel)
else
pc = next_or_nothing!(frame)
pc = next_or_nothing!(recurse, frame)
end
end
isa(pc, BreakpointRef) && return pc
Expand Down
6 changes: 3 additions & 3 deletions src/signatures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
sigt, pc = signature(recurse, frame, stmt, pc)
meth = whichtt(sigt)
if isa(meth, Method) && (meth.sig <: sigt && sigt <: meth.sig)
pc = define ? step_expr!(recurse, frame, stmt, true) : next_or_nothing!(frame)
pc = define ? step_expr!(recurse, frame, stmt, true) : next_or_nothing!(recurse, frame)
elseif define
pc = step_expr!(recurse, frame, stmt, true)
meth = whichtt(sigt)
Expand All @@ -517,7 +517,7 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
@warn "file $(loc.file), line $(loc.line): no method found for $sigt"
end
if pc == pc3
pc = next_or_nothing!(frame)
pc = next_or_nothing!(recurse, frame)
end
end
end
Expand Down Expand Up @@ -560,7 +560,7 @@ function methoddef!(@nospecialize(recurse), signatures, frame::Frame, @nospecial
# Methods like f(x::Ref{<:Real}) that use gensymmed typevars will not have the *exact*
# signature of the active method. So let's get the active signature.
frame.pc = pc
pc = define ? step_expr!(recurse, frame, stmt, true) : next_or_nothing!(frame)
pc = define ? step_expr!(recurse, frame, stmt, true) : next_or_nothing!(recurse, frame)
meth = whichtt(sigt)
isa(meth, Method) && push!(signatures, meth.sig) # inner methods are not visible
name === name3 && return pc, pc3 # if this was an inner method we should keep going
Expand Down
6 changes: 3 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ Advance the program counter without executing the corresponding line.
If `frame` is finished, `nextpc` will be `nothing`.
"""
next_or_nothing(frame, pc) = pc < nstatements(frame.framecode) ? pc+1 : nothing
function next_or_nothing!(frame)
next_or_nothing!(frame) = next_or_nothing(finish_and_return!, frame)
function next_or_nothing!(@nospecialize(recurse), frame)
pc = frame.pc
if pc < nstatements(frame.framecode)
frame.pc = pc = pc + 1
return pc
return frame.pc = pc + 1
end
return nothing
end
Expand Down

0 comments on commit 54f6697

Please sign in to comment.