Skip to content

Commit 4f3819c

Browse files
authored
Generalize the "method" for linetable_scopes (#138)
It could be a module, too.
1 parent 7f85b77 commit 4f3819c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CodeTracking"
22
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
33
authors = ["Tim Holy <[email protected]>"]
4-
version = "1.3.8"
4+
version = "1.3.9"
55

66
[deps]
77
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

src/utils.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,15 @@ fileline(lin::LineInfoNode) = String(lin.file), lin.line
195195
fileline(lnn::LineNumberNode) = String(lnn.file), lnn.line
196196

197197
if VERSION v"1.12.0-DEV.173" # https://github.com/JuliaLang/julia/pull/52415
198-
function linetable_scopes(m::Method)
199-
src = Base.uncompressed_ast(m)
198+
function linetable_scopes(src::Core.CodeInfo, m)
200199
lts = [Vector{Base.Compiler.IRShow.LineInfoNode}() for _ = eachindex(src.code)]
201200
for pc = eachindex(src.code)
202201
Base.IRShow.append_scopes!(lts[pc], pc, src.debuginfo, m)
203202
end
204203
return lts
205204
end
206205
else
207-
function linetable_scopes(m::Method)
208-
src = Base.uncompressed_ast(m)
206+
function linetable_scopes(src::Core.CodeInfo, _)
209207
lt, cl = src.linetable, src.codelocs
210208
lts = [Vector{Core.LineInfoNode}() for _ = eachindex(src.code)]
211209
for pc = eachindex(src.code)
@@ -222,7 +220,8 @@ else
222220
return lts
223221
end
224222
end
225-
@doc """
223+
224+
"""
226225
scopes = linetable_scopes(m::Method)
227226
228227
Return an array of "scopes" for each statement in the lowered code for `m`. If
@@ -237,7 +236,8 @@ The precise type of these entries varies with Julia version,
237236
`Base.Compiler.IRShow.LineInfoNode` objects on Julia 1.12 and up, and
238237
`Core.LineInfoNode` objects on earlier versions. These objects differ in some of
239238
their fields. `:method`, `:file`, and `:line` are common to both types.
240-
""" linetable_scopes
239+
"""
240+
linetable_scopes(m::Method) = linetable_scopes(Base.uncompressed_ast(m), m)
241241

242242
getmethod(m::Method) = m
243243
getmethod(mi::Core.MethodInstance) = getmethod(mi.def)

0 commit comments

Comments
 (0)