1
1
"""
2
- ret = finish!(recurse, frame, istoplevel=false)
3
- ret = finish!(frame, istoplevel=false)
2
+ pc = finish!(recurse, frame, istoplevel=false)
3
+ pc = finish!(frame, istoplevel=false)
4
4
5
- Run `frame` until execution terminates. `ret ` is either `nothing` (if execution terminates
5
+ Run `frame` until execution terminates. `pc ` is either `nothing` (if execution terminates
6
6
when it hits a `return` statement) or a reference to a breakpoint.
7
7
In the latter case, `leaf(frame)` returns the frame in which it hit the breakpoint.
8
8
@@ -22,8 +22,8 @@ finish!(frame::Frame, istoplevel::Bool=false) = finish!(finish_and_return!, fram
22
22
ret = finish_and_return!(recurse, frame, istoplevel::Bool=false)
23
23
ret = finish_and_return!(frame, istoplevel::Bool=false)
24
24
25
- Call [`JuliaInterpreter.finish!`](@ref) and pass back the return value. If execution
26
- pauses at a breakpoint, the reference to the breakpoint is returned .
25
+ Call [`JuliaInterpreter.finish!`](@ref) and pass back the return value `ret` . If execution
26
+ pauses at a breakpoint, `ret` is the reference to the breakpoint.
27
27
"""
28
28
function finish_and_return! (@nospecialize (recurse), frame:: Frame , istoplevel:: Bool = false )
29
29
pc = finish! (recurse, frame, istoplevel)
33
33
finish_and_return! (frame:: Frame , istoplevel:: Bool = false ) = finish_and_return! (finish_and_return!, frame, istoplevel)
34
34
35
35
"""
36
- bpref = dummy_breakpoint(recurse, frame::Frame)
36
+ bpref = dummy_breakpoint(recurse, frame::Frame, istoplevel )
37
37
38
- Return a fake breakpoint. This can be useful as the `recurse` argument to `evaluate_call!`
39
- (or any of the higher-order commands) to ensure that you return immediately after stepping
40
- into a call.
38
+ Return a fake breakpoint. `dummy_breakpoint` can be useful as the `recurse` argument to
39
+ `evaluate_call!` (or any of the higher-order commands) to ensure that you return immediately
40
+ after stepping into a call.
41
41
"""
42
- dummy_breakpoint (@nospecialize (recurse), frame:: Frame ) = BreakpointRef (frame. framecode, 0 )
42
+ dummy_breakpoint (@nospecialize (recurse), frame:: Frame , istoplevel ) = BreakpointRef (frame. framecode, 0 )
43
43
44
44
"""
45
- ret = finish_stack!(recurse, frame, istoplevel =false)
46
- ret = finish_stack!(frame, istoplevel =false)
45
+ ret = finish_stack!(recurse, frame, rootistoplevel =false)
46
+ ret = finish_stack!(frame, rootistoplevel =false)
47
47
48
48
Unwind the callees of `frame`, finishing each before returning to the caller.
49
- `frame` itself is also finished
50
- If execution hits a breakpoint, `ret` will be a reference to the breakpoint.
49
+ `frame` itself is also finished. `rootistoplevel` should be true if the root frame is top-level.
50
+
51
+ `ret` is typically the returned value. If execution hits a breakpoint, `ret` will be a
52
+ reference to the breakpoint.
51
53
"""
52
- function finish_stack! (@nospecialize (recurse), frame:: Frame , istoplevel :: Bool = false )
54
+ function finish_stack! (@nospecialize (recurse), frame:: Frame , rootistoplevel :: Bool = false )
53
55
frame0 = frame
54
56
frame = leaf (frame)
55
57
while true
58
+ istoplevel = rootistoplevel && frame. caller === nothing
56
59
ret = finish_and_return! (recurse, frame, istoplevel)
57
60
isa (ret, BreakpointRef) && return ret
58
61
frame === frame0 && return ret
93
96
next_until! (predicate, frame:: Frame , istoplevel:: Bool = false ) =
94
97
next_until! (predicate, finish_and_return!, frame, istoplevel)
95
98
99
+ """
100
+ pc = next_call!(recurse, frame, istoplevel=false)
101
+ pc = next_call!(frame, istoplevel=false)
102
+
103
+ Execute the current statement. Continue stepping through `frame` until the next
104
+ `:return` or `:call` expression.
105
+ """
96
106
next_call! (@nospecialize (recurse), frame:: Frame , istoplevel:: Bool = false ) =
97
107
next_until! (is_call_or_return, recurse, frame, istoplevel)
98
108
next_call! (frame:: Frame , istoplevel:: Bool = false ) = next_call! (finish_and_return!, frame, istoplevel)
99
109
100
110
"""
101
- maybe_next_call!(predicate, frame, istoplevel=false)
111
+ pc = maybe_next_call!(recurse, frame, istoplevel=false)
112
+ pc = maybe_next_call!(frame, istoplevel=false)
102
113
103
- Return the current statement of `frame` if it is a `:return` or `:call` expression.
114
+ Return the current program counter of `frame` if it is a `:return` or `:call` expression.
104
115
Otherwise, step through the statements of `frame` until the next `:return` or `:call` expression.
105
116
"""
106
117
function maybe_next_call! (@nospecialize (recurse), frame:: Frame , istoplevel:: Bool = false )
@@ -112,8 +123,8 @@ maybe_next_call!(frame::Frame, istoplevel::Bool=false) =
112
123
maybe_next_call! (finish_and_return!, frame, istoplevel)
113
124
114
125
"""
115
- through_methoddef_or_done!(recurse, frame)
116
- through_methoddef_or_done!(frame)
126
+ pc = through_methoddef_or_done!(recurse, frame)
127
+ pc = through_methoddef_or_done!(frame)
117
128
118
129
Runs `frame` at top level until it either finishes (e.g., hits a `return` statement)
119
130
or defines a new method.
@@ -144,6 +155,15 @@ function changed_line!(expr, line, fls)
144
155
end
145
156
end
146
157
158
+ """
159
+ pc = next_line!(recurse, frame, istoplevel=false)
160
+ pc = next_line!(frame, istoplevel=false)
161
+
162
+ Execute until reaching the first call of the next line of the source code.
163
+ Upon return, `pc` is either the new program counter, `nothing` if a `return` is reached,
164
+ or a `BreakpointRef` if it encountered a wrapper call. In the latter case, call `leaf(frame)`
165
+ to obtain the new execution frame.
166
+ """
147
167
function next_line! (@nospecialize (recurse), frame:: Frame , istoplevel:: Bool = false )
148
168
initial = linenumber (frame)
149
169
first = true
0 commit comments