Skip to content

Commit

Permalink
IRShow: simplify effectbits_[color|letter] implementations (JuliaLa…
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored and pcjentsch committed Aug 18, 2022
1 parent 930b209 commit 5afc89c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions base/compiler/ssair/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -791,21 +791,27 @@ function show_ir(io::IO, code::Union{IRCode, CodeInfo}, config::IRShowConfig=def
end

function effectbits_letter(effects::Effects, name::Symbol, suffix::Char)
if name === :consistent || name === :effect_free || name === :inaccessiblememonly
ft = fieldtype(Effects, name)
if ft === UInt8
prefix = getfield(effects, name) === ALWAYS_TRUE ? '+' :
getfield(effects, name) === ALWAYS_FALSE ? '!' : '?'
else
elseif ft === Bool
prefix = getfield(effects, name) ? '+' : '!'
else
error("unsupported effectbits type given")
end
return string(prefix, suffix)
end

function effectbits_color(effects::Effects, name::Symbol)
if name === :consistent || name === :effect_free || name === :inaccessiblememonly
ft = fieldtype(Effects, name)
if ft === UInt8
color = getfield(effects, name) === ALWAYS_TRUE ? :green :
getfield(effects, name) === ALWAYS_FALSE ? :red : :yellow
else
elseif ft === Bool
color = getfield(effects, name) ? :green : :red
else
error("unsupported effectbits type given")
end
return color
end
Expand Down

0 comments on commit 5afc89c

Please sign in to comment.