From 5afc89c96caaa9680cbec7eda088829a5e73bce7 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Tue, 9 Aug 2022 18:32:09 +0900 Subject: [PATCH] IRShow: simplify `effectbits_[color|letter]` implementations (#46293) --- base/compiler/ssair/show.jl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/base/compiler/ssair/show.jl b/base/compiler/ssair/show.jl index aaea4169f29e8f..3ee16f5494e24c 100644 --- a/base/compiler/ssair/show.jl +++ b/base/compiler/ssair/show.jl @@ -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