@@ -51,7 +51,7 @@ macro fixturedef(ex)
5151end
5252
5353"""
54- @analyze_toplevel [jetconfigs...] ex
54+ @analyze_toplevel [jetconfigs...] ex -> JET.VirtualProcessResult
5555
5656Enters JET analysis from toplevel expression `ex`, and returns the analysis result.
5757"""
@@ -63,6 +63,29 @@ macro analyze_toplevel(xs...)
6363 return _analyze_toplevel (ex, __source__, jetconfigs)
6464end
6565
66+ """
67+ @analyze_toplevel2 [jetconfigs...] ex -> (Module, JET.VirtualProcessResult)
68+
69+ Works similarly to `@analyze_toplevel`, but also creates a virtual module beforehand and
70+ returns that as well after the whole analysis for the later inspection.
71+ """
72+ macro analyze_toplevel2 (xs... )
73+ jetconfigs = filter (iskwarg, xs)
74+ xs′ = filter (! iskwarg, xs)
75+ @assert length (xs′) == 1
76+ ex = first (xs′)
77+
78+ vmod = gensym (:vmod )
79+ jetconfigs = (:(context = $ vmod), jetconfigs... ,)
80+ jetconfigs = (:(virtualize = false ), jetconfigs... ,)
81+ ex2 = _analyze_toplevel (ex, __source__, jetconfigs)
82+ return :(let
83+ $ (esc (vmod)) = $ gen_virtual_module ()
84+ ret2 = $ ex2
85+ $ (esc (vmod)), ret2
86+ end )
87+ end
88+
6689iskwarg (@nospecialize (x)) = isexpr (x, :(= ))
6790
6891function _analyze_toplevel (ex, lnn, jetconfigs)
0 commit comments