|
29 | 29 | function breadcrumbs(io, file::AbstractString, line_num; nbefore=2, nafter=2) |
30 | 30 | @assert(nbefore >= 0) |
31 | 31 | @assert(nafter >= 0) |
32 | | - |
| 32 | + |
33 | 33 | all_lines = loc_for_file(file) |
34 | 34 | first_line_num = max(1, line_num - nbefore) |
35 | 35 | last_line_num = min(length(all_lines), line_num + nafter) |
36 | | - |
| 36 | + |
37 | 37 | for ln in first_line_num:last_line_num |
38 | 38 | line = all_lines[ln] |
39 | 39 | if ln == line_num |
|
54 | 54 | # this function exists only for mocking so we can test it. |
55 | 55 | breakpoint_hit(meth, statement_ind) = nothing |
56 | 56 |
|
57 | | -function iron_repl(metadata::HandEvalMeta, meth, statement_ind) |
| 57 | +function iron_repl(metadata::HandEvalMeta, meth, statement_ind, variables) |
58 | 58 | breakpoint_hit(meth, statement_ind) |
59 | 59 | breadcrumbs(meth, statement_ind) |
60 | | - |
| 60 | + |
61 | 61 | printstyled("Vars: "; color=:light_yellow) |
62 | | - println(join(keys(metadata.variables), ", ")) |
| 62 | + println(join(keys(variables), ", ")) |
63 | 63 | print_commands() |
64 | | - |
65 | | - run_repl(metadata.variables, metadata.eval_module) |
66 | | -end |
67 | 64 |
|
| 65 | + run_repl(variables, metadata.eval_module) |
| 66 | +end |
68 | 67 |
|
69 | 68 | """ |
70 | | - break_action(metadata, meth, statement_ind) |
| 69 | + should_breakon |
| 70 | +Determines if we should actualy break at a potential breakpoint |
| 71 | +""" |
| 72 | +function should_break(ctx, meth, statement_ind) |
| 73 | + return ctx.metadata.stepping_mode isa StepNext || |
| 74 | + should_breakon(ctx.metadata.breakpoint_rules, meth, statement_ind) |
| 75 | +end |
| 76 | + |
71 | 77 |
|
72 | | -This determines what we should do when we hit a potential point to break at. |
73 | | -We check if we should actually break here, |
74 | | -and if so open up a REPL. |
75 | | -if not, then we continue. |
76 | 78 | """ |
77 | | -function break_action(metadata, meth, statement_ind) |
78 | | - if !(metadata.stepping_mode isa StepNext |
79 | | - || should_breakon(metadata.breakpoint_rules, meth, statement_ind) |
80 | | - ) |
81 | | - # Only break on StepNext and actual breakpoints |
82 | | - return |
83 | | - end |
| 79 | + break_action |
84 | 80 |
|
85 | | - code_word = iron_repl(metadata, meth, statement_ind) |
| 81 | +What to do when a breakpoint is hit |
| 82 | +""" |
| 83 | +function break_action(ctx, meth, statement_ind, slotnames, slotvals) |
| 84 | + metadata = ctx.metadata |
| 85 | + # TODO we probably need to drop the first few slots as they will contain various metadata |
| 86 | + variables = LittleDict(slotnames, slotvals) |
| 87 | + code_word = iron_repl(metadata, meth, statement_ind, variables) |
86 | 88 | actions[code_word].act(metadata) |
87 | 89 | end |
0 commit comments