Skip to content
Merged
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
@@ -1,6 +1,6 @@
name = "Infiltrator"
uuid = "5903a43b-9cc3-4c30-8d17-598619ec4e9b"
version = "1.8.6"
version = "1.8.7"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
18 changes: 12 additions & 6 deletions src/Infiltrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const REPL_HOOKED = Ref{Bool}(false)
const INFILTRATION_LOCK = Ref{ReentrantLock}()

function __init__()
clear_store!(store)
ccall(:jl_generating_output, Cint, ()) == 0 && clear_store!(store)
INFILTRATION_LOCK[] = ReentrantLock()
if VERSION >= v"1.5.0-DEV.282"
if isdefined(Base, :active_repl_backend) && !isnothing(Base.active_repl_backend)
Expand Down Expand Up @@ -104,7 +104,7 @@ macro exfiltrate()
quote
for (k, v) in Base.@locals
try
Core.eval(getfield(getfield($(@__MODULE__), :store), :store), Expr(:(=), k, QuoteNode(v)))
Core.eval(get_store(getfield($(@__MODULE__), :store)), Expr(:(=), k, QuoteNode(v)))
catch err
println(stderr, "Assignment to store variable failed.")
Base.display_error(stderr, err, catch_backtrace())
Expand Down Expand Up @@ -216,7 +216,7 @@ function Base.show(io::IO, ::MIME"text/plain", s::Session)
end
end
function Base.getproperty(sp::Session, s::Symbol)
m = getfield(sp, :store)
m = get_store(sp)
if isdefined(m, s)
getproperty(m, s)
else
Expand Down Expand Up @@ -294,6 +294,12 @@ function end_session!(s::Session = store)
return nothing
end

function get_store(s::Session = store)
isdefined(s, :store) && return getfield(s, :store)
ccall(:jl_generating_output, Cint, ()) == 1 && error("Functionality provided by this package should not be used during precompilation or other compilation modes")
error("The provided session does not have a module")
end

"""
clear_store!(s = safehouse)

Expand Down Expand Up @@ -499,7 +505,7 @@ function exfiltrate_locals(io, evalmod, locals, sline::AbstractString)
v = getfield(evalmod, k)
end
try
Core.eval(getfield(store, :store), Expr(:(=), k, QuoteNode(v)))
Core.eval(get_store(store), Expr(:(=), k, QuoteNode(v)))
catch err
println(io, "Assignment to store variable failed.")
Base.display_error(io, err, catch_backtrace())
Expand Down Expand Up @@ -758,7 +764,7 @@ function debugprompt(mod, locals, trace, terminal, repl, ex, bt; nostack = false
end
end

get_store_names(s = store) = get_module_names(getfield(s, :store), m -> names(m, all = true))
get_store_names(s = store) = get_module_names(get_store(s), m -> names(m, all = true))

function get_module_names(m::Module, get_names = all_names)
ns = get_names(m)
Expand Down Expand Up @@ -948,7 +954,7 @@ function completions(c::InfiltratorCompletionProvider, full, partial)
prepend!(ret, map(REPL.REPLCompletions.completion_text, comps))

# completions for safehouse variables
comps, range, should_complete = REPL.REPLCompletions.completions(full, lastindex(partial), getfield(store, :store))
comps, range, should_complete = REPL.REPLCompletions.completions(full, lastindex(partial), get_store(store))
prepend!(ret, map(REPL.REPLCompletions.completion_text, comps))

# Infiltrator commands completions
Expand Down
Loading