Skip to content
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

update to JuliaInterpreter@0.8 #24

Merged
merged 4 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -16,7 +16,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[compat]
JSON = "0.20, 0.21"
julia = "1"
JuliaInterpreter = "0.7.22"
JuliaInterpreter = "0.8"
JSONRPC = "1.1"

[targets]
Expand Down
21 changes: 11 additions & 10 deletions src/debugger_core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ end

mutable struct DebuggerState
last_exception
top_level_expressions::Vector{Any}
current_top_level_expression::Int
expr_splitter::JuliaInterpreter.ExprSplitter
frame
not_yet_set_function_breakpoints::Set{Any}
debug_mode::Symbol
Expand Down Expand Up @@ -46,15 +45,17 @@ function attempt_to_set_f_breakpoints!(bps)
end

function get_next_top_level_frame(state)
state.current_top_level_expression += 1

if state.current_top_level_expression > length(state.top_level_expressions)
return nothing
else
next_top_level = state.top_level_expressions[state.current_top_level_expression]
next_frame = JuliaInterpreter.prepare_thunk(next_top_level)
return next_frame
x = iterate(state.expr_splitter)
x === nothing && return nothing

mod, ex = x
aviatesk marked this conversation as resolved.
Show resolved Hide resolved
if Meta.isexpr(ex, :global, 1)
# global assignment can be lowered, but global declaration can't,
# let's just evaluate and iterate to next
Core.eval(mod, ex)
return get_next_top_level_frame(state)
end
return JuliaInterpreter.Frame(mod, ex)
end

function our_debug_command(cmd, state)
Expand Down
8 changes: 2 additions & 6 deletions src/debugger_requests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ function debug_notification(conn, state::DebuggerState, params::DebugArguments)
return
end

state.top_level_expressions, _ = JuliaInterpreter.split_expressions(Main, ex)
state.current_top_level_expression = 0
state.expr_splitter = JuliaInterpreter.ExprSplitter(Main, ex)

state.frame = get_next_top_level_frame(state)

Expand All @@ -65,8 +64,7 @@ function exec_notification(conn, state::DebuggerState, params::ExecArguments)

ex = Meta.parse(params.code)

state.top_level_expressions, _ = JuliaInterpreter.split_expressions(Main, ex)
state.current_top_level_expression = 0
state.expr_splitter = JuliaInterpreter.ExprSplitter(Main, ex) # TODO: line numbers ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want the line number, the actual statement should always be ex.args[2].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that we may need to fix line numbers for this code block (params.code) like what we did for Juno. It's actually not related to the update of JuliaInterpreter, and we can improve this later.


state.frame = get_next_top_level_frame(state)

Expand Down Expand Up @@ -739,8 +737,6 @@ function restart_frame_request(conn, state::DebuggerState, params::RestartFrameA
if curr_fr.caller === nothing
# We are in the top level

state.current_top_level_expression = 0

state.frame = get_next_top_level_frame(state)
else
curr_fr.pc = 1
Expand Down