@@ -10,6 +10,7 @@ using UUIDs
10
10
# in Base and stdlib
11
11
using Random. DSFMT
12
12
using InteractiveUtils
13
+ using CodeTracking
13
14
14
15
export @interpret , Compiled, JuliaStackFrame,
15
16
Breakpoints, breakpoint, @breakpoint , breakpoints, enable, disable, remove
@@ -390,7 +391,7 @@ julia> framecode, frameargs, lenv, argtypes = JuliaInterpreter.prepare_call(myme
390
391
julia> framecode
391
392
JuliaInterpreter.JuliaFrameCode(mymethod(x::Array{T,1}) where T in Main at none:1, CodeInfo(
392
393
1 ─ return 1
393
- ), Core. TypeMapEntry[#undef], BitSet([]), false, false, true)
394
+ ), Union{Compiled, TypeMapEntry}[#undef], JuliaInterpreter.BreakpointState [#undef], BitSet([]), false, false, true)
394
395
395
396
julia> frameargs
396
397
2-element Array{Any,1}:
@@ -915,9 +916,9 @@ mymethod (generic function with 1 method)
915
916
916
917
julia> JuliaInterpreter.enter_call_expr(:(\$ mymethod(1)))
917
918
JuliaStackFrame(JuliaInterpreter.JuliaFrameCode(mymethod(x) in Main at none:1, CodeInfo(
918
- 1 ─ %1 = (\ $ (QuoteNode(+)))(x, 1)
919
+ 1 ─ %1 = ($(QuoteNode (+ )) )(x, 1)
919
920
└── return %1
920
- ), Core. TypeMapEntry[#undef, #undef], BitSet([1]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some(1)], Any[#undef, #undef], Any[], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict{ Symbol,Int64}( ), Any[])
921
+ ), Union{Compiled, TypeMapEntry} [#undef, #undef], JuliaInterpreter.BreakpointState[#undef, #undef], BitSet([1]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some(1)], Any[#undef, #undef], Any[], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict( Symbol("#self#")=>1,:x=>2 ), Any[])
921
922
922
923
julia> mymethod(x::Vector{T}) where T = 1
923
924
mymethod (generic function with 2 methods)
@@ -930,7 +931,7 @@ julia> a = [1.0, 2.0]
930
931
julia> JuliaInterpreter.enter_call_expr(:(\$ mymethod(\$ a)))
931
932
JuliaStackFrame(JuliaInterpreter.JuliaFrameCode(mymethod(x::Array{T,1}) where T in Main at none:1, CodeInfo(
932
933
1 ─ return 1
933
- ), Core. TypeMapEntry[#undef], BitSet([]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some([1.0, 2.0])], Any[#undef], Any[Float64], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict{ Symbol,Int64}( ), Any[])
934
+ ), Union{Compiled, TypeMapEntry} [#undef], JuliaInterpreter.BreakpointState[#undef], BitSet([]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some([1.0, 2.0])], Any[#undef], Any[Float64], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict( Symbol("#self#")=>1,:x=>2 ), Any[])
934
935
```
935
936
936
937
See [`enter_call`](@ref) for a similar approach not based on expressions.
@@ -958,15 +959,15 @@ julia> JuliaInterpreter.enter_call(mymethod, 1)
958
959
JuliaStackFrame(JuliaInterpreter.JuliaFrameCode(mymethod(x) in Main at none:1, CodeInfo(
959
960
1 ─ %1 = ($(QuoteNode (+ )) )(x, 1)
960
961
└── return %1
961
- ), Core. TypeMapEntry[#undef, #undef], BitSet([1]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some(1)], Any[#undef, #undef], Any[], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict{ Symbol,Int64}( ), Any[])
962
+ ), Union{Compiled, TypeMapEntry} [#undef, #undef], JuliaInterpreter.BreakpointState[#undef, #undef], BitSet([1]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some(1)], Any[#undef, #undef], Any[], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict( Symbol("#self#")=>1,:x=>2 ), Any[])
962
963
963
964
julia> mymethod(x::Vector{T}) where T = 1
964
965
mymethod (generic function with 2 methods)
965
966
966
967
julia> JuliaInterpreter.enter_call(mymethod, [1.0, 2.0])
967
968
JuliaStackFrame(JuliaInterpreter.JuliaFrameCode(mymethod(x::Array{T,1}) where T in Main at none:1, CodeInfo(
968
969
1 ─ return 1
969
- ), Core. TypeMapEntry[#undef], BitSet([]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some([1.0, 2.0])], Any[#undef], Any[Float64], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict{ Symbol,Int64}( ), Any[])
970
+ ), Union{Compiled, TypeMapEntry} [#undef], JuliaInterpreter.BreakpointState[#undef], BitSet([]), false, false, true), Union{Nothing, Some{Any}}[Some(mymethod), Some([1.0, 2.0])], Any[#undef], Any[Float64], Int64[], Base.RefValue{Any}(nothing), Base.RefValue{JuliaInterpreter.JuliaProgramCounter}(JuliaProgramCounter(1)), Dict( Symbol("#self#")=>1,:x=>2 ), Any[])
970
971
```
971
972
972
973
For a `@generated` function you can use `enter_call((f, true), args...; kwargs...)`
@@ -1084,7 +1085,8 @@ macro interpret(arg)
1084
1085
push! (stack, frame)
1085
1086
return stack, BreakpointRef (frame. code, 1 )
1086
1087
end
1087
- finish_and_return! (stack, frame)
1088
+ ret = finish_and_return! (stack, frame)
1089
+ isa (ret, BreakpointRef) ? (stack, ret) : ret
1088
1090
end
1089
1091
end
1090
1092
0 commit comments