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-
123function assign_this! (frame, value)
134 frame. framedata. ssavalues[frame. pc] = value
145end
@@ -199,13 +190,12 @@ end
199190
200191function 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
205195end
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
211201Evaluate 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;
215205likely 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
221210The 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)
312301end
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)
0 commit comments