Skip to content

Instantly share code, notes, and snippets.

@dawbarton
Last active August 28, 2018 22:55
Show Gist options
  • Save dawbarton/0388715fb56fb5cd05e0e4b12c322815 to your computer and use it in GitHub Desktop.
Save dawbarton/0388715fb56fb5cd05e0e4b12c322815 to your computer and use it in GitHub Desktop.
using SoftGlobalScope
import REPL
const USE_REVISE = false
function replace_active_backend()
backend = Base.active_repl_backend
# Kill the existing REPL backend
put!(backend.repl_channel, (nothing, -1))
# Copied from REPL/src/REPL.jl: start_repl_backend
backend.backend_task = @async begin
# include looks at this to determine the relative include path
# nothing means cwd
while true
tls = task_local_storage()
tls[:SOURCE_PATH] = nothing
ast, show_value = take!(backend.repl_channel)
if show_value == -1
# exit flag
break
end
# Softscope the AST (beginning of changes)
if USE_REVISE
revise(backend)
end
REPL.eval_user_input(softscope(Main, ast), backend)
# Softscope the AST (end of changes)
end
end
nothing
end
replace_active_backend()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment