Skip to content

Commit a335cf6

Browse files
authored
remove no longer used DocExpr (#920)
1 parent 4e51d12 commit a335cf6

File tree

5 files changed

+28
-43
lines changed

5 files changed

+28
-43
lines changed

src/lowered.jl

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
## Analyzing lowered code
22

3-
function add_docexpr!(docexprs::AbstractDict{Module,V}, mod::Module, ex) where V
4-
docexs = get(docexprs, mod, nothing)
5-
if docexs === nothing
6-
docexs = docexprs[mod] = V()
7-
end
8-
push!(docexs, ex)
9-
return docexprs
10-
end
11-
123
function assign_this!(frame, value)
134
frame.framedata.ssavalues[frame.pc] = value
145
end
@@ -199,13 +190,12 @@ end
199190

200191
function methods_by_execution(mod::Module, ex::Expr; kwargs...)
201192
methodinfo = MethodInfo()
202-
docexprs = DocExprs()
203-
value, thk = methods_by_execution!(JuliaInterpreter.Compiled(), methodinfo, docexprs, mod, ex; kwargs...)
204-
return methodinfo, docexprs, thk
193+
value, thk = methods_by_execution!(JuliaInterpreter.Compiled(), methodinfo, mod, ex; kwargs...)
194+
return methodinfo, thk
205195
end
206196

207197
"""
208-
methods_by_execution!([interp::Interpreter=JuliaInterpreter.Compiled(),] methodinfo, docexprs::DocExprs, mod::Module, ex::Expr;
198+
methods_by_execution!([interp::Interpreter=JuliaInterpreter.Compiled(),] methodinfo, mod::Module, ex::Expr;
209199
mode=:eval, disablebp=true, skip_include=mode!==:eval, always_rethrow=false)
210200
211201
Evaluate or analyze `ex` in the context of `mod`.
@@ -214,19 +204,18 @@ evaluation needed to extract method signatures.
214204
`interp` controls JuliaInterpreter's evaluation of any non-intercepted statement;
215205
likely choices are `JuliaInterpreter.Compiled()` or `JuliaInterpreter.RecursiveInterpreter()`.
216206
`methodinfo` is a cache for storing information about any method definitions (see [`CodeTrackingMethodInfo`](@ref)).
217-
`docexprs` is a cache for storing documentation expressions; obtain an empty one with `Revise.DocExprs()`.
218207
219208
# Extended help
220209
221210
The action depends on `mode`:
222211
223-
- `:eval` evaluates the expression in `mod`, similar to `Core.eval(mod, ex)` except that `methodinfo` and `docexprs`
224-
will be populated with information about any signatures or docstrings. This mode is used to implement `includet`.
225-
- `:sigs` analyzes `ex` and extracts signatures of methods and docstrings (specifically, statements flagged by
212+
- `:eval` evaluates the expression in `mod`, similar to `Core.eval(mod, ex)` except that `methodinfo`
213+
will be populated with information about any signatures. This mode is used to implement `includet`.
214+
- `:sigs` analyzes `ex` and extracts signatures of methods (specifically, statements flagged by
226215
[`Revise.minimal_evaluation!`](@ref)), but does not evaluate `ex` in the traditional sense.
227216
It will selectively execute statements needed to form the signatures of defined methods.
228217
It will also expand any `@eval`ed expressions, since these might contain method definitions.
229-
- `:evalmeth` analyzes `ex` and extracts signatures and docstrings like `:sigs`, but takes the additional step of
218+
- `:evalmeth` analyzes `ex` and extracts signatures like `:sigs`, but takes the additional step of
230219
evaluating any `:method` statements.
231220
- `:evalassign` acts similarly to `:evalmeth`, and also evaluates assignment statements.
232221
@@ -248,7 +237,7 @@ The other keyword arguments are more straightforward:
248237
If false, the error is logged with `@error`. `InterruptException`s are always rethrown.
249238
This is primarily useful for debugging.
250239
"""
251-
function methods_by_execution!(interp::Interpreter, methodinfo, docexprs::DocExprs, mod::Module, ex::Expr;
240+
function methods_by_execution!(interp::Interpreter, methodinfo, mod::Module, ex::Expr;
252241
mode::Symbol=:eval, disablebp::Bool=true, always_rethrow::Bool=false, kwargs...)
253242
mode (:sigs, :eval, :evalmeth, :evalassign) || error("unsupported mode ", mode)
254243
lwr = Meta.lower(mod, ex)
@@ -292,7 +281,7 @@ function methods_by_execution!(interp::Interpreter, methodinfo, docexprs::DocExp
292281
foreach(disable, active_bp_refs)
293282
end
294283
ret = try
295-
_methods_by_execution!(interp, methodinfo, docexprs, frame, isrequired; mode, kwargs...)
284+
_methods_by_execution!(interp, methodinfo, frame, isrequired; mode, kwargs...)
296285
catch err
297286
(always_rethrow || isa(err, InterruptException)) && (disablebp && foreach(enable, active_bp_refs); rethrow(err))
298287
loc = location_string(whereis(frame))
@@ -310,10 +299,10 @@ function methods_by_execution!(interp::Interpreter, methodinfo, docexprs::DocExp
310299
end
311300
return Pair{Any,Union{Nothing,Expr}}(ret, lwr)
312301
end
313-
methods_by_execution!(methodinfo, docexprs::DocExprs, mod::Module, ex::Expr; kwargs...) =
314-
methods_by_execution!(Compiled(), methodinfo, docexprs, mod, ex; kwargs...)
302+
methods_by_execution!(methodinfo, mod::Module, ex::Expr; kwargs...) =
303+
methods_by_execution!(Compiled(), methodinfo, mod, ex; kwargs...)
315304

316-
function _methods_by_execution!(interp::Interpreter, methodinfo, docexprs::DocExprs, frame::Frame, isrequired::AbstractVector{Bool};
305+
function _methods_by_execution!(interp::Interpreter, methodinfo, frame::Frame, isrequired::AbstractVector{Bool};
317306
mode::Symbol=:eval, skip_include::Bool=true)
318307
isok(lnn::LineTypes) = !iszero(lnn.line) || lnn.file !== :none # might fail either one, but accept anything
319308

@@ -336,7 +325,7 @@ function _methods_by_execution!(interp::Interpreter, methodinfo, docexprs::DocEx
336325
local value
337326
for ex in stmt.args
338327
ex isa Expr || continue
339-
value, _ = methods_by_execution!(interp, methodinfo, docexprs, mod, ex; mode, disablebp=false, skip_include)
328+
value, _ = methods_by_execution!(interp, methodinfo, mod, ex; mode, disablebp=false, skip_include)
340329
end
341330
isassign(frame, pc) && assign_this!(frame, value)
342331
pc = next_or_nothing!(frame)
@@ -491,12 +480,11 @@ function _methods_by_execution!(interp::Interpreter, methodinfo, docexprs::DocEx
491480
value = nothing
492481
for (newmod, newex) in ExprSplitter(evalmod, evalex)
493482
if is_doc_expr(newex)
494-
add_docexpr!(docexprs, newmod, newex)
495483
newex = newex.args[4]
496484
end
497485
newex = unwrap(newex)
498486
push_expr!(methodinfo, newmod, newex)
499-
value, _ = methods_by_execution!(interp, methodinfo, docexprs, newmod, newex; mode, skip_include, disablebp=false)
487+
value, _ = methods_by_execution!(interp, methodinfo, newmod, newex; mode, skip_include, disablebp=false)
500488
pop_expr!(methodinfo)
501489
end
502490
assign_this!(frame, value)

src/packagedef.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ end
466466
# Eval and insert into CodeTracking data
467467
function eval_with_signatures(mod, ex::Expr; mode=:eval, kwargs...)
468468
methodinfo = CodeTrackingMethodInfo(ex)
469-
docexprs = DocExprs()
470-
_, thk = methods_by_execution!(methodinfo, docexprs, mod, ex; mode, kwargs...)
469+
_, thk = methods_by_execution!(methodinfo, mod, ex; mode=mode, kwargs...)
471470
return methodinfo.allsigs, methodinfo.includes, thk
472471
end
473472

src/precompile.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,32 @@ function _precompile_()
4040

4141
MI = CodeTrackingMethodInfo
4242
@warnpcfail precompile(Tuple{typeof(minimal_evaluation!), Any, MI, Module, Core.CodeInfo, Symbol})
43-
@warnpcfail precompile(Tuple{typeof(methods_by_execution!), Compiled, MI, DocExprs, Module, Expr})
44-
@warnpcfail precompile(Tuple{typeof(_methods_by_execution!), Compiled, MI, DocExprs, Frame, Vector{Bool}})
43+
@warnpcfail precompile(Tuple{typeof(methods_by_execution!), Compiled, MI, Module, Expr})
44+
@warnpcfail precompile(Tuple{typeof(_methods_by_execution!), Compiled, MI, Frame, Vector{Bool}})
4545
@warnpcfail precompile(Tuple{typeof(Core.kwfunc(methods_by_execution!)),
4646
NamedTuple{(:mode,),Tuple{Symbol}},
47-
typeof(methods_by_execution!), Compiled, MI, DocExprs, Module, Expr})
47+
typeof(methods_by_execution!), Compiled, MI, Module, Expr})
4848
@warnpcfail precompile(Tuple{typeof(Core.kwfunc(methods_by_execution!)),
4949
NamedTuple{(:skip_include,),Tuple{Bool}},
50-
typeof(methods_by_execution!), Compiled, MI, DocExprs, Module, Expr})
50+
typeof(methods_by_execution!), Compiled, MI, Module, Expr})
5151
@warnpcfail precompile(Tuple{typeof(Core.kwfunc(methods_by_execution!)),
5252
NamedTuple{(:mode, :skip_include),Tuple{Symbol,Bool}},
53-
typeof(methods_by_execution!), Compiled, MI, DocExprs, Module, Expr})
53+
typeof(methods_by_execution!), Compiled, MI, Module, Expr})
5454
@warnpcfail precompile(Tuple{typeof(Core.kwfunc(_methods_by_execution!)),
5555
NamedTuple{(:mode,),Tuple{Symbol}},
56-
typeof(_methods_by_execution!), Compiled, MI, DocExprs, Frame, Vector{Bool}})
56+
typeof(_methods_by_execution!), Compiled, MI, Frame, Vector{Bool}})
5757
@warnpcfail precompile(Tuple{typeof(Core.kwfunc(_methods_by_execution!)),
5858
NamedTuple{(:mode, :skip_include),Tuple{Symbol,Bool}},
59-
typeof(_methods_by_execution!), Compiled, MI, DocExprs, Frame, Vector{Bool}})
59+
typeof(_methods_by_execution!), Compiled, MI, Frame, Vector{Bool}})
6060

61-
mex = which(methods_by_execution!, (Compiled, MI, DocExprs, Module, Expr))
61+
mex = which(methods_by_execution!, (Compiled, MI, Module, Expr))
6262
mbody = bodymethod(mex)
6363
# use `typeof(pairs(NamedTuple()))` here since it actually differs between Julia versions
64-
@warnpcfail precompile(Tuple{mbody.sig.parameters[1], Symbol, Bool, Bool, typeof(pairs(NamedTuple())), typeof(methods_by_execution!), Compiled, MI, DocExprs, Module, Expr})
65-
@warnpcfail precompile(Tuple{mbody.sig.parameters[1], Symbol, Bool, Bool, Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:skip_include,),Tuple{Bool}}}, typeof(methods_by_execution!), Compiled, MI, DocExprs, Module, Expr})
66-
mfr = which(_methods_by_execution!, (Compiled, MI, DocExprs, Frame, Vector{Bool}))
64+
@warnpcfail precompile(Tuple{mbody.sig.parameters[1], Symbol, Bool, Bool, typeof(pairs(NamedTuple())), typeof(methods_by_execution!), Compiled, MI, Module, Expr})
65+
@warnpcfail precompile(Tuple{mbody.sig.parameters[1], Symbol, Bool, Bool, Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:skip_include,),Tuple{Bool}}}, typeof(methods_by_execution!), Compiled, MI, Module, Expr})
66+
mfr = which(_methods_by_execution!, (Compiled, MI, Frame, Vector{Bool}))
6767
mbody = bodymethod(mfr)
68-
@warnpcfail precompile(Tuple{mbody.sig.parameters[1], Symbol, Bool, typeof(_methods_by_execution!), Compiled, MI, DocExprs, Frame, Vector{Bool}})
68+
@warnpcfail precompile(Tuple{mbody.sig.parameters[1], Symbol, Bool, typeof(_methods_by_execution!), Compiled, MI, Frame, Vector{Bool}})
6969

7070
@warnpcfail precompile(Tuple{typeof(hastrackedexpr), Expr, Vector{Any}})
7171
@warnpcfail precompile(Tuple{typeof(get_def), Method})

src/types.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ mutable struct WatchList
1515
trackedfiles::Dict{String,PkgId}
1616
end
1717

18-
const DocExprs = Dict{Module,Vector{Expr}}
1918
const ExprsSigs = OrderedDict{RelocatableExpr,Union{Nothing,Vector{Any}}}
2019

2120
function Base.show(io::IO, exsigs::ExprsSigs)

test/runtests.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,9 +1131,8 @@ const issue639report = []
11311131
lwr = Meta.lower(ChangeDocstring, ex)
11321132
frame = Frame(ChangeDocstring, lwr.args[1])
11331133
methodinfo = Revise.MethodInfo()
1134-
docexprs = Revise.DocExprs()
11351134
ret = Revise._methods_by_execution!(JuliaInterpreter.RecursiveInterpreter(), methodinfo,
1136-
docexprs, frame, trues(length(frame.framecode.src.code)); mode=:sigs)
1135+
frame, trues(length(frame.framecode.src.code)); mode=:sigs)
11371136
ds = @doc(ChangeDocstring.f)
11381137
@test get_docstring(ds) == "g"
11391138

0 commit comments

Comments
 (0)