Skip to content

Commit

Permalink
Merge pull request #24 from julia-vscode/avi/juliainterpreter0.8
Browse files Browse the repository at this point in the history
update to JuliaInterpreter@0.8
  • Loading branch information
pfitzseb authored Dec 2, 2020
2 parents 4e0e64c + 54bde09 commit e8f7718
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
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
24 changes: 13 additions & 11 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::Union{JuliaInterpreter.ExprSplitter,Nothing}
frame
not_yet_set_function_breakpoints::Set{Any}
debug_mode::Symbol
Expand All @@ -17,7 +16,7 @@ mutable struct DebuggerState
next_cmd::Channel{Any}

function DebuggerState()
return new(nothing, [], 0, nothing, Set{String}(), :unknown, JuliaInterpreter.finish_and_return!, Dict{Int,String}(), 1, VariableReference[], Channel{Any}(Inf))
return new(nothing, nothing, nothing, Set{String}(), :unknown, JuliaInterpreter.finish_and_return!, Dict{Int,String}(), 1, VariableReference[], Channel{Any}(Inf))
end
end

Expand Down Expand Up @@ -46,15 +45,18 @@ 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
state.expr_splitter === nothing && return nothing
x = iterate(state.expr_splitter)
x === nothing && return nothing

(mod, ex), _ = x
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 ?

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

0 comments on commit e8f7718

Please sign in to comment.