Skip to content

Commit

Permalink
Remove metadata entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox committed Jul 14, 2019
1 parent b9eed95 commit a8524f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/MagneticReadHead.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct UserAbortedException <: Exception end

function iron_debug(debugbody)
try
ctx = HandEvalCtx()
ctx = new_debug_ctx()
return Cassette.recurse(ctx, debugbody)
catch err
err isa UserAbortedException || rethrow()
Expand Down
13 changes: 7 additions & 6 deletions src/core_control.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ Cassette.@context HandEvalCtx
const GLOBAL_BREAKPOINT_RULES = BreakpointRules()
const GLOBAL_STEPPING_MODE = Ref(StepContinue)

function HandEvalCtx()

"""
new_debug_ctx()::HandEvalCtx
creates a debug context, with the pass set
and extranious hooks disabled.
"""
function new_debug_ctx()
ctx = HandEvalCtx(;pass=handeval_pass)
return Cassette.disablehooks(ctx)
end

function Cassette.overdub(::typeof(HandEvalCtx()), args...)
error("HandEvalCtx without any had an overdub called on it. This should never happen as HandEvalCtx should never be constructed without giving them their metadata.")
end


@inline function Cassette.overdub(ctx::HandEvalCtx, f, args...)
# This is basically the epicenter of all the logic
# We control the flow of stepping modes
Expand Down
14 changes: 7 additions & 7 deletions test/test_pass.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

using MagneticReadHead
using MagneticReadHead: HandEvalCtx, handeval_pass
using MagneticReadHead: new_debug_ctx
using Cassette
using Test

Expand All @@ -9,7 +9,7 @@ using InteractiveUtils
# This test we are keeping around just to demonstrate how to
# check on when things go wrong
@testset "_totuple" begin
ctx = HandEvalCtx()
ctx = new_debug_ctx()
ir = @code_lowered Cassette.recurse(ctx, Base._totuple, Tuple, 20)
#@show ir
#@show ir.codelocs
Expand All @@ -27,7 +27,7 @@ end
(fn = Base._totuple, args=(Tuple, 41)),
)
for code in normal_codes
ctx = HandEvalCtx()
ctx = new_debug_ctx()
expected = code.fn(code.args...)
direct_recurse = Cassette.recurse(ctx, code.fn, code.args...)
@test expected == direct_recurse
Expand All @@ -42,12 +42,12 @@ function boopa!(x,y)
end

@testset "basic mutating function" begin
ctx = HandEvalCtx()
ctx = new_debug_ctx()
res = Cassette.recurse(ctx, boopa!, [1,2], 3)
@test res == [3,2]

@testset "function calling a basic mutating function" begin
ctx = HandEvalCtx()
ctx = new_debug_ctx()
res = Cassette.recurse(ctx, ()->boopa!([1,2],4))
@test res == [4,2]
end
Expand All @@ -71,7 +71,7 @@ end
return x
end

ctx = HandEvalCtx()
ctx = new_debug_ctx()
res = Cassette.recurse(ctx, danger11, 1)
@test res == 1
end
Expand All @@ -87,7 +87,7 @@ end
inner()
end

ctx = HandEvalCtx()
ctx = new_debug_ctx()
res = Cassette.recurse(ctx, danger19)
@test res == 2
end

0 comments on commit a8524f5

Please sign in to comment.