Skip to content

Commit c7dcd13

Browse files
committed
update to JuliaInterpreter 0.10
This commit implements the migration to the new JuliaInterpreter interface proposed in JuliaDebug/JuliaInterpreter.jl#683. It purely performs the migration to the new interface and does not include any refactoring based on it. `selective_eval!` could now be rewritten as follows using the new interface, that change is not made in this commit for minimizing the diff: ```diff diff --git a/src/codeedges.jl b/src/codeedges.jl index 3cf2a17..5eba604 100644 --- a/src/codeedges.jl +++ b/src/codeedges.jl @@ -1021,6 +1021,33 @@ function add_inplace!(isrequired, src, edges, norequire) return changed end +struct SelectiveInterpreter{S<:Interpreter,T<:AbstractVector{Bool}} <: Interpreter + inner::S + isrequired::T +end +function JuliaInterpreter.step_expr!(interp::SelectiveInterpreter, frame::Frame, istoplevel::Bool) + pc = frame.pc + if interp.isrequired[pc] + step_expr!(interp.inner, frame::Frame, istoplevel::Bool) + else + next_or_nothing!(interp, frame) + end +end +function JuliaInterpreter.get_return(interp::SelectiveInterpreter, frame::Frame) + pc = frame.pc + node = pc_expr(frame, pc) + if is_return(node) + if interp.isrequired[pc] + return lookup_return(frame, node) + end + else + if isassigned(frame.framedata.ssavalues, pc) + return frame.framedata.ssavalues[pcexec] + end + end + return nothing +end + """ selective_eval!([interp::Interpreter=RecursiveInterpreter()], frame::Frame, isrequired::AbstractVector{Bool}, istoplevel=false) @@ -1037,27 +1064,10 @@ This will return either a `BreakpointRef`, the value obtained from the last exec Typically, assignment to a variable binding does not result in an ssa store by JuliaInterpreter. """ function selective_eval!(interp::Interpreter, frame::Frame, isrequired::AbstractVector{Bool}, istoplevel::Bool=false) - pc = pcexec = pclast = frame.pc - while isa(pc, Int) - frame.pc = pc - pclast = pcexec::Int - if isrequired[pc] - pcexec = pc = step_expr!(interp, frame, istoplevel) - else - pc = next_or_nothing!(interp, frame) - end - end - isa(pc, BreakpointRef) && return pc - pcexec = (pcexec === nothing ? pclast : pcexec)::Int - frame.pc = pcexec - node = pc_expr(frame) - is_return(node) && return isrequired[pcexec] ? lookup_return(frame, node) : nothing - isassigned(frame.framedata.ssavalues, pcexec) && return frame.framedata.ssavalues[pcexec] - return nothing + return JuliaInterpreter.finish_and_return!(SelectiveInterpreter(interp, isrequired), frame, istoplevel) end -function selective_eval!(frame::Frame, isrequired::AbstractVector{Bool}, istoplevel::Bool=false) +selective_eval!(frame::Frame, isrequired::AbstractVector{Bool}, istoplevel::Bool=false) = selective_eval!(RecursiveInterpreter(), frame, isrequired, istoplevel) -end """ selective_eval_fromstart!([interp::Interpreter=RecursiveInterpreter()], frame, isrequired, istoplevel=false) ```
1 parent c3ee610 commit c7dcd13

File tree

5 files changed

+99
-94
lines changed

5 files changed

+99
-94
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name = "LoweredCodeUtils"
22
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
33
authors = ["Tim Holy <[email protected]>"]
4-
version = "3.2.1"
4+
version = "3.3.0"
55

66
[deps]
77
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
88

99
[compat]
10-
JuliaInterpreter = "0.9.44"
10+
JuliaInterpreter = "0.10"
1111
julia = "1.10"
1212

1313
[extras]

src/LoweredCodeUtils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ module LoweredCodeUtils
1010
# the VS Code extension integration.
1111

1212
using JuliaInterpreter
13-
using JuliaInterpreter: SSAValue, SlotNumber, Frame
13+
using JuliaInterpreter: SSAValue, SlotNumber, Frame, Interpreter, RecursiveInterpreter
1414
using JuliaInterpreter: @lookup, moduleof, pc_expr, step_expr!, is_global_ref, is_global_ref_egal, is_quotenode_egal, whichtt,
15-
next_until!, finish_and_return!, get_return, nstatements, codelocation, linetable,
15+
next_until!, nstatements, codelocation, linetable,
1616
is_return, lookup_return
1717

1818
include("packagedef.jl")

src/codeedges.jl

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,31 +1022,29 @@ function add_inplace!(isrequired, src, edges, norequire)
10221022
end
10231023

10241024
"""
1025-
selective_eval!([recurse], frame::Frame, isrequired::AbstractVector{Bool}, istoplevel=false)
1025+
selective_eval!([interp::Interpreter=RecursiveInterpreter()], frame::Frame, isrequired::AbstractVector{Bool}, istoplevel=false)
10261026
10271027
Execute the code in `frame` in the manner of `JuliaInterpreter.finish_and_return!`,
10281028
but skipping all statements that are marked `false` in `isrequired`.
10291029
See [`lines_required`](@ref). Upon entry, if needed the caller must ensure that `frame.pc` is
10301030
set to the correct statement, typically `findfirst(isrequired)`.
10311031
See [`selective_eval_fromstart!`](@ref) to have that performed automatically.
10321032
1033-
The default value for `recurse` is `JuliaInterpreter.finish_and_return!`.
10341033
`isrequired` pertains only to `frame` itself, not any of its callees.
10351034
10361035
This will return either a `BreakpointRef`, the value obtained from the last executed statement
10371036
(if stored to `frame.framedata.ssavlues`), or `nothing`.
10381037
Typically, assignment to a variable binding does not result in an ssa store by JuliaInterpreter.
10391038
"""
1040-
function selective_eval!(@nospecialize(recurse), frame::Frame, isrequired::AbstractVector{Bool}, istoplevel::Bool=false)
1039+
function selective_eval!(interp::Interpreter, frame::Frame, isrequired::AbstractVector{Bool}, istoplevel::Bool=false)
10411040
pc = pcexec = pclast = frame.pc
10421041
while isa(pc, Int)
10431042
frame.pc = pc
1044-
te = isrequired[pc]
10451043
pclast = pcexec::Int
1046-
if te
1047-
pcexec = pc = step_expr!(recurse, frame, istoplevel)
1044+
if isrequired[pc]
1045+
pcexec = pc = step_expr!(interp, frame, istoplevel)
10481046
else
1049-
pc = next_or_nothing!(recurse, frame)
1047+
pc = next_or_nothing!(interp, frame)
10501048
end
10511049
end
10521050
isa(pc, BreakpointRef) && return pc
@@ -1058,22 +1056,22 @@ function selective_eval!(@nospecialize(recurse), frame::Frame, isrequired::Abstr
10581056
return nothing
10591057
end
10601058
function selective_eval!(frame::Frame, isrequired::AbstractVector{Bool}, istoplevel::Bool=false)
1061-
selective_eval!(finish_and_return!, frame, isrequired, istoplevel)
1059+
selective_eval!(RecursiveInterpreter(), frame, isrequired, istoplevel)
10621060
end
10631061

10641062
"""
1065-
selective_eval_fromstart!([recurse], frame, isrequired, istoplevel=false)
1063+
selective_eval_fromstart!([interp::Interpreter=RecursiveInterpreter()], frame, isrequired, istoplevel=false)
10661064
10671065
Like [`selective_eval!`](@ref), except it sets `frame.pc` to the first `true` statement in `isrequired`.
10681066
"""
1069-
function selective_eval_fromstart!(@nospecialize(recurse), frame, isrequired, istoplevel::Bool=false)
1067+
function selective_eval_fromstart!(interp::Interpreter, frame, isrequired, istoplevel::Bool=false)
10701068
pc = findfirst(isrequired)
10711069
pc === nothing && return nothing
10721070
frame.pc = pc
1073-
return selective_eval!(recurse, frame, isrequired, istoplevel)
1071+
return selective_eval!(interp, frame, isrequired, istoplevel)
10741072
end
10751073
function selective_eval_fromstart!(frame::Frame, isrequired::AbstractVector{Bool}, istoplevel::Bool=false)
1076-
selective_eval_fromstart!(finish_and_return!, frame, isrequired, istoplevel)
1074+
selective_eval_fromstart!(RecursiveInterpreter(), frame, isrequired, istoplevel)
10771075
end
10781076

10791077
"""

0 commit comments

Comments
 (0)