|
1 | 1 | module LoweredCodeUtils
|
2 | 2 |
|
3 |
| -if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@optlevel")) |
4 |
| - @eval Base.Experimental.@optlevel 1 |
5 |
| -end |
| 3 | +# We use a code structure where all `using` and `import` |
| 4 | +# statements in the package that load anything other than |
| 5 | +# a Julia base or stdlib package are located in this file here. |
| 6 | +# Nothing else should appear in this file here, apart from |
| 7 | +# the `include("packagedef.jl")` statement, which loads what |
| 8 | +# we would normally consider the bulk of the package code. |
| 9 | +# This somewhat unusual structure is in place to support |
| 10 | +# the VS Code extension integration. |
6 | 11 |
|
7 |
| -using Core: SimpleVector, CodeInfo, NewvarNode, GotoNode |
8 |
| -using Base.Meta: isexpr |
9 | 12 | using JuliaInterpreter
|
10 | 13 | using JuliaInterpreter: SSAValue, SlotNumber, Frame
|
11 | 14 | using JuliaInterpreter: @lookup, moduleof, pc_expr, step_expr!, is_global_ref, is_quotenode, whichtt,
|
12 | 15 | next_until!, finish_and_return!, get_return, nstatements, codelocation, linetable
|
13 | 16 |
|
14 |
| -const SSAValues = Union{Core.Compiler.SSAValue, JuliaInterpreter.SSAValue} |
15 |
| - |
16 |
| -const structheads = VERSION >= v"1.5.0-DEV.702" ? () : (:struct_type, :abstract_type, :primitive_type) |
17 |
| -const trackedheads = (:method, structheads...) |
18 |
| - |
19 |
| -export signature, rename_framemethods!, methoddef!, methoddefs!, bodymethod |
20 |
| -export CodeEdges, lines_required, lines_required!, selective_eval!, selective_eval_fromstart! |
21 |
| - |
22 |
| -include("utils.jl") |
23 |
| -include("signatures.jl") |
24 |
| -include("codeedges.jl") |
25 |
| - |
26 |
| -# precompilation |
27 |
| - |
28 |
| -if ccall(:jl_generating_output, Cint, ()) == 1 |
29 |
| - kwdefine = NamedTuple{(:define,),Tuple{Bool}} |
30 |
| - for ct in (Vector{Any}, Set{Any}) |
31 |
| - f = methoddef! |
32 |
| - m = which(f, Tuple{Function, ct, Frame, Expr, Int}) |
33 |
| - @assert precompile(Tuple{typeof(f), Function, ct, Frame, Expr, Int}) |
34 |
| - mbody = bodymethod(m) |
35 |
| - # @assert precompile(Tuple{mbody.sig.parameters[1], Bool, typeof(f), Function, ct, Frame, Expr, Int}) |
36 |
| - @assert precompile(Tuple{Core.kwftype(typeof(f)), kwdefine, typeof(f), Function, ct, Frame, Expr, Int}) |
37 |
| - f = methoddefs! |
38 |
| - @assert precompile(Tuple{typeof(f), Any, ct, Frame}) |
39 |
| - @assert precompile(Tuple{Core.kwftype(typeof(f)), kwdefine, typeof(f), Function, ct, Frame}) |
40 |
| - end |
41 |
| - @assert precompile(Tuple{typeof(rename_framemethods!), Any, Frame, Dict{Symbol,MethodInfo}, |
42 |
| - Vector{NamedTuple{(:linetop, :linebody, :callee, :caller),Tuple{Int64,Int64,Symbol,Union{Bool, Symbol}}}}, |
43 |
| - Dict{Symbol,Union{Bool, Symbol}}}) |
44 |
| - @assert precompile(Tuple{typeof(identify_framemethod_calls), Frame}) |
45 |
| - @assert precompile(Tuple{typeof(callchain), Vector{NamedTuple{(:linetop, :linebody, :callee, :caller),Tuple{Int64,Int64,Symbol,Union{Bool, Symbol}}}}}) |
46 |
| - |
47 |
| - @assert precompile(CodeEdges, (CodeInfo,)) |
48 |
| - @assert precompile(add_links!, (Pair{Union{SSAValue,SlotNumber,NamedVar},Links}, Any, CodeLinks)) |
49 |
| - @assert precompile(lines_required!, (Vector{Bool}, Set{NamedVar}, CodeInfo, CodeEdges)) |
50 |
| - |
51 |
| - precompile(Tuple{typeof(setindex!),Dict{Union{GlobalRef, Symbol},Links},Links,Symbol}) |
52 |
| - precompile(Tuple{typeof(setindex!),Dict{Union{GlobalRef, Symbol},Variable},Variable,Symbol}) |
53 |
| -end |
| 17 | +include("packagedef.jl") |
54 | 18 |
|
55 | 19 | end # module
|
0 commit comments