@@ -30,16 +30,18 @@ function tsn_and_mappings(@nospecialize(f), @nospecialize(t); kwargs...)
30
30
tsn_and_mappings (m, src, rt; kwargs... )
31
31
end
32
32
33
- function tsn_and_mappings (m:: Method , src:: CodeInfo , @nospecialize (rt); warn:: Bool = true , strip_macros:: Bool = false , kwargs... )
33
+ function tsn_and_mappings (mi:: MethodInstance , src:: CodeInfo , @nospecialize (rt); warn:: Bool = true , strip_macros:: Bool = false , kwargs... )
34
+ m = mi. def:: Method
34
35
def = definition (String, m)
35
36
if isnothing (def)
36
37
warn && @warn " couldn't retrieve source of $m "
37
38
return nothing , nothing
38
39
end
39
- return tsn_and_mappings (m , src, rt, def... ; warn, strip_macros, kwargs... )
40
+ return tsn_and_mappings (mi , src, rt, def... ; warn, strip_macros, kwargs... )
40
41
end
41
42
42
- function tsn_and_mappings (m:: Method , src:: CodeInfo , @nospecialize (rt), sourcetext:: AbstractString , lineno:: Integer ; warn:: Bool = true , strip_macros:: Bool = false , kwargs... )
43
+ function tsn_and_mappings (mi:: MethodInstance , src:: CodeInfo , @nospecialize (rt), sourcetext:: AbstractString , lineno:: Integer ; warn:: Bool = true , strip_macros:: Bool = false , kwargs... )
44
+ m = mi. def:: Method
43
45
filename = isnothing (functionloc (m)[1 ]) ? string (m. file) : functionloc (m)[1 ]
44
46
rootnode = JuliaSyntax. parsestmt (SyntaxNode, sourcetext; filename= filename, first_line= lineno, kwargs... )
45
47
if strip_macros
@@ -50,7 +52,7 @@ function tsn_and_mappings(m::Method, src::CodeInfo, @nospecialize(rt), sourcetex
50
52
end
51
53
end
52
54
Δline = lineno - m. line # offset from original line number (Revise)
53
- mappings, symtyps = map_ssas_to_source (src, rootnode, Δline)
55
+ mappings, symtyps = map_ssas_to_source (src, mi, rootnode, Δline)
54
56
node = TypedSyntaxNode (rootnode, src, mappings, symtyps)
55
57
node. typ = rt
56
58
return node, mappings
59
61
TypedSyntaxNode (@nospecialize (f), @nospecialize (t); kwargs... ) = tsn_and_mappings (f, t; kwargs... )[1 ]
60
62
61
63
function TypedSyntaxNode (mi:: MethodInstance ; kwargs... )
62
- m = mi. def:: Method
63
64
src, rt = getsrc (mi)
64
- tsn_and_mappings (m , src, rt; kwargs... )[1 ]
65
+ tsn_and_mappings (mi , src, rt; kwargs... )[1 ]
65
66
end
66
67
67
68
TypedSyntaxNode (rootnode:: SyntaxNode , src:: CodeInfo , Δline:: Integer = 0 ) =
397
398
# Main logic for mapping `src.code[i]` to node(s) in the SyntaxNode tree
398
399
# Success: when we map it to a unique node
399
400
# Δline is the (Revise) offset of the line number
400
- function map_ssas_to_source (src:: CodeInfo , rootnode:: SyntaxNode , Δline:: Int )
401
- mi = src. parent:: MethodInstance
401
+ function map_ssas_to_source (src:: CodeInfo , mi:: MethodInstance , rootnode:: SyntaxNode , Δline:: Int )
402
402
slottypes = src. slottypes:: Union{Nothing, Vector{Any}}
403
403
have_slottypes = slottypes != = nothing
404
404
ssavaluetypes = src. ssavaluetypes:: Vector{Any}
@@ -736,7 +736,7 @@ function map_ssas_to_source(src::CodeInfo, rootnode::SyntaxNode, Δline::Int)
736
736
end
737
737
return mappings, symtyps
738
738
end
739
- map_ssas_to_source (src:: CodeInfo , rootnode:: SyntaxNode , Δline:: Integer ) = map_ssas_to_source (src, rootnode, Int (Δline))
739
+ map_ssas_to_source (src:: CodeInfo , mi :: MethodInstance , rootnode:: SyntaxNode , Δline:: Integer ) = map_ssas_to_source (src, mi , rootnode, Int (Δline))
740
740
741
741
function follow_back (src, arg)
742
742
# Follow SSAValue backward to see if it maps back to a slot
0 commit comments