Skip to content

Commit 4b12ab1

Browse files
committed
Enhanced pretty printing of bindings
1 parent 5c439d7 commit 4b12ab1

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/bindings.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,44 @@ function BindingInfo(id::IdTag, name::AbstractString, kind::Symbol, node_id::Int
3434
is_internal, is_ambiguous_local, is_nospecialize)
3535
end
3636

37+
function Base.show(io::IO, binfo::BindingInfo)
38+
print(io, "BindingInfo(", binfo.id, ", ",
39+
repr(binfo.name), ", ",
40+
repr(binfo.kind), ", ",
41+
binfo.node_id)
42+
if !isnothing(binfo.mod)
43+
print(io, ", mod=", binfo.mod)
44+
end
45+
if !isnothing(binfo.type)
46+
print(io, ", type=", binfo.type)
47+
end
48+
if binfo.n_assigned != 0
49+
print(io, ", n_assigned=", binfo.n_assigned)
50+
end
51+
if binfo.is_const
52+
print(io, ", is_const=", binfo.is_const)
53+
end
54+
if binfo.is_ssa
55+
print(io, ", is_ssa=", binfo.is_ssa)
56+
end
57+
if binfo.is_captured
58+
print(io, ", is_captured=", binfo.is_captured)
59+
end
60+
if binfo.is_always_defined != binfo.is_ssa
61+
print(io, ", is_always_defined=", binfo.is_always_defined)
62+
end
63+
if binfo.is_internal
64+
print(io, ", is_internal=", binfo.is_internal)
65+
end
66+
if binfo.is_ambiguous_local
67+
print(io, ", is_ambiguous_local=", binfo.is_ambiguous_local)
68+
end
69+
if binfo.is_nospecialize
70+
print(io, ", is_nospecialize=", binfo.is_nospecialize)
71+
end
72+
print(io, ")")
73+
end
74+
3775
"""
3876
Metadata about "entities" (variables, constants, etc) in the program. Each
3977
entity is associated to a unique integer id, the BindingId. A binding will be

0 commit comments

Comments
 (0)