Commit c7dcd13
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- src
- test
5 files changed
+99
-94
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1022 | 1022 | | |
1023 | 1023 | | |
1024 | 1024 | | |
1025 | | - | |
| 1025 | + | |
1026 | 1026 | | |
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
1030 | 1030 | | |
1031 | 1031 | | |
1032 | 1032 | | |
1033 | | - | |
1034 | 1033 | | |
1035 | 1034 | | |
1036 | 1035 | | |
1037 | 1036 | | |
1038 | 1037 | | |
1039 | 1038 | | |
1040 | | - | |
| 1039 | + | |
1041 | 1040 | | |
1042 | 1041 | | |
1043 | 1042 | | |
1044 | | - | |
1045 | 1043 | | |
1046 | | - | |
1047 | | - | |
| 1044 | + | |
| 1045 | + | |
1048 | 1046 | | |
1049 | | - | |
| 1047 | + | |
1050 | 1048 | | |
1051 | 1049 | | |
1052 | 1050 | | |
| |||
1058 | 1056 | | |
1059 | 1057 | | |
1060 | 1058 | | |
1061 | | - | |
| 1059 | + | |
1062 | 1060 | | |
1063 | 1061 | | |
1064 | 1062 | | |
1065 | | - | |
| 1063 | + | |
1066 | 1064 | | |
1067 | 1065 | | |
1068 | 1066 | | |
1069 | | - | |
| 1067 | + | |
1070 | 1068 | | |
1071 | 1069 | | |
1072 | 1070 | | |
1073 | | - | |
| 1071 | + | |
1074 | 1072 | | |
1075 | 1073 | | |
1076 | | - | |
| 1074 | + | |
1077 | 1075 | | |
1078 | 1076 | | |
1079 | 1077 | | |
| |||
0 commit comments