Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi committed Jun 25, 2024
1 parent a0281e7 commit 412e9af
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/sandbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ Base.write(sandbox::Sandbox, code) = write(sandbox._codebuffer, code)
"""
abstract type AbstractValue end
Will be one of: [`AnsValue`](@ref), [`ExceptionValue`](@ref), or [`ParseErrorValue`](@ref).
Will either [`AnsValue`](@ref) if the code evaluated successfully, or [`ExceptionValue`](@ref)
if it did not.
"""
abstract type AbstractValue end

Expand All @@ -72,11 +73,6 @@ struct ExceptionValue <: AbstractValue
end
Base.getindex(v::ExceptionValue) = v.exception

struct ParseErrorValue <: AbstractValue
error::Any # TODO: use the correct error object?
end
Base.getindex(v::ParseErrorValue) = v.error

"""
struct Result
Expand Down Expand Up @@ -126,7 +122,7 @@ function evaluate!(sandbox::Sandbox, code::AbstractString; kwargs...)
return evaluate!(sandbox; kwargs...)
end

function evaluate!(sandbox::Sandbox; ansicolor::Bool=true, repl::Bool=false)
function evaluate!(sandbox::Sandbox; color::Bool=true, repl::Bool=false)
code = String(take!(sandbox._codebuffer))

# Evaluate the code block. We redirect stdout/stderr to `buffer`.
Expand All @@ -138,7 +134,7 @@ function evaluate!(sandbox::Sandbox; ansicolor::Bool=true, repl::Bool=false)
# if repl
# ex = REPL.softscope(ex)
# end
c = IOCapture.capture(rethrow=InterruptException, color=ansicolor) do
c = IOCapture.capture(; rethrow=InterruptException, color) do
cd(sandbox.pwd) do
Core.eval(sandbox.m, ex)
end
Expand Down

0 comments on commit 412e9af

Please sign in to comment.