Skip to content

update to JuliaInterpreter v0.10 #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
CodeTracking = "0.5.7, 1"
Crayons = "4.1"
Highlights = "0.4.3, 0.5"
JuliaInterpreter = "0.9"
JuliaInterpreter = "0.10"
julia = "1.6"

[extras]
Expand Down
8 changes: 4 additions & 4 deletions src/Debugger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ using REPL.LineEdit
using REPL.REPLCompletions

using CodeTracking
using JuliaInterpreter: JuliaInterpreter, Frame, @lookup, FrameCode, BreakpointRef, debug_command, leaf, root, BreakpointState,
finish_and_return!, Compiled
using JuliaInterpreter: JuliaInterpreter, Frame, lookup, FrameCode, BreakpointRef, debug_command, leaf, root, BreakpointState,
finish_and_return!, Interpreter, NonRecursiveInterpreter, RecursiveInterpreter

using JuliaInterpreter: pc_expr, moduleof, linenumber, extract_args, locals,
root, caller, whereis, get_return, nstatements, getargs
Expand Down Expand Up @@ -43,7 +43,7 @@ Base.@kwdef mutable struct DebuggerState
broke_on_error::Bool = false
watch_list::Vector = WATCH_LIST
lowered_status::Bool = false
mode = finish_and_return!
interp::Interpreter = RecursiveInterpreter()
repl = nothing
terminal = nothing
main_mode = nothing
Expand All @@ -53,7 +53,7 @@ Base.@kwdef mutable struct DebuggerState
end

function toggle_mode(state)
state.mode = (state.mode === finish_and_return! ? (state.mode = Compiled()) : (state.mode = finish_and_return!))
state.interp = (state.interp === RecursiveInterpreter() ? (state.interp = NonRecursiveInterpreter()) : (state.interp = RecursiveInterpreter()))
end

toggle_lowered(state) = state.lowered_status = !state.lowered_status
Expand Down
2 changes: 1 addition & 1 deletion src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function execute_command(state::DebuggerState, v::Union{Val{:c},Val{:nc},Val{:n}
assert_allow_step(state) || return false
cmd == "so" && (cmd = "finish")
cmd == "u" && (cmd = "until")
ret = debug_command(state.mode, state.frame, Symbol(cmd); kwargs...)
ret = debug_command(state.interp, state.frame, Symbol(cmd); kwargs...)
if ret === nothing
state.overall_result = get_return(root(state.frame))
state.frame = nothing
Expand Down
6 changes: 3 additions & 3 deletions src/printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function pattern_match_apply_call(expr, frame)
if !(isexpr(expr, :call) && expr.args[1] == Core._apply)
return expr
end
args = [@lookup(frame, expr.args[i+2]) for i in 1:(length(expr.args)-2)]
args = Any[lookup(frame, expr.args[i+2]) for i in 1:(length(expr.args)-2)]
new_expr = Expr(:call, expr.args[2])
argsflat = append_any(args...)
for x in argsflat
Expand Down Expand Up @@ -105,7 +105,7 @@ function print_next_expr(io::IO, frame::Frame)
if isexpr(expr, :call) || isexpr(expr, :return)
for i in 1:length(expr.args)
val = try
@lookup(frame, expr.args[i])
lookup(frame, expr.args[i])
catch err
err isa UndefVarError || rethrow(err)
expr.args[i]
Expand All @@ -116,7 +116,7 @@ function print_next_expr(io::IO, frame::Frame)
if isdefined(Core, :ReturnNode)
if expr isa Core.ReturnNode
val = try
@lookup(frame, expr.val)
lookup(frame, expr.val)
catch err
err isa UndefVarError || rethrow(err)
expr.val
Expand Down
2 changes: 1 addition & 1 deletion src/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function RunDebugger(frame, repl = nothing, terminal = nothing; initial_continue
normal_prefix = Sys.iswindows() ? "\e[33m" : "\e[38;5;166m"
compiled_prefix = "\e[96m"
panel = LineEdit.Prompt(promptname(state.level, "debug");
prompt_prefix = () -> state.mode == Compiled() ? compiled_prefix : normal_prefix,
prompt_prefix = () -> state.interp == NonRecursiveInterpreter() ? compiled_prefix : normal_prefix,
prompt_suffix = Base.text_colors[:normal],
on_enter = s->true)

Expand Down
5 changes: 3 additions & 2 deletions test/misc.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Issue #14

using Debugger: _iscall
using JuliaInterpreter: JuliaInterpreter, pc_expr, evaluate_call!, finish_and_return!, @lookup, enter_call_expr, breakpoints
runframe(frame::Frame, pc=frame.pc[]) = Some{Any}(finish_and_return!(Compiled(), frame))
using JuliaInterpreter
using JuliaInterpreter: pc_expr, evaluate_call!, finish_and_return!, enter_call_expr
runframe(frame::Frame, pc=frame.pc[]) = Some{Any}(finish_and_return!(NonRecursiveInterpreter(), frame))

frame = @make_frame map(x->2x, 1:10)
state = dummy_state(frame)
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Debugger: Debugger, @enter, execute_command, RunDebugger, @make_frame
import JuliaInterpreter: JuliaInterpreter, Frame, @lookup, Compiled, pc_expr
using JuliaInterpreter
import JuliaInterpreter: pc_expr
import CodeTracking
using InteractiveUtils

Expand Down
Loading