Skip to content

Commit

Permalink
display slotnames within print_with_code (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored May 16, 2024
1 parent ea6054b commit ae96514
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/codeedges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ function print_with_code(preprint, postprint, io::IO, src::CodeInfo)
if isdefined(JuliaInterpreter, :reverse_lookup_globalref!)
JuliaInterpreter.reverse_lookup_globalref!(src.code)
end
io = IOContext(io, :displaysize=>displaysize(io))
io = IOContext(io,
:displaysize=>displaysize(io),
:SOURCE_SLOTNAMES => Base.sourceinfo_slotnames(src))
used = BitSet()
cfg = Core.Compiler.compute_basic_blocks(src.code)
for stmt in src.code
Expand Down
15 changes: 15 additions & 0 deletions test/codeedges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,21 @@ module ModSelective end
else
@test occursin("No IR statement printer", str)
end

# display slot names
ex = :(let
s = 0.0
for i = 1:5
s += rand()
end
return s
end)
lwr = Meta.lower(Main, ex)
src = lwr.args[1]
LoweredCodeUtils.print_with_code(io, src, trues(length(src.code)))
str = String(take!(io))
@test count("s = ", str) == 2
@test count("i = ", str) == 1
end
end

Expand Down

0 comments on commit ae96514

Please sign in to comment.