Skip to content

Commit

Permalink
typo and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
arhik committed May 11, 2024
1 parent 1aeec87 commit b7becc5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
21 changes: 10 additions & 11 deletions base/compiler/ssair/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ function Base.show(io::IO, cfg::CFG)
end
end

# Forwarding for existing libraries
# TODO Not sure if this is necessary since I don't know if any library is using it.
# Forwarding print_stmt for existing libraries with empty unstable_ssa.
function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, maxlength_idx::Int, color::Bool, show_type::Bool)
print_stmt(io, idx, stmt, used, BitSet(), maxlength_idx, color, show_type)
print_stmt(io, idx, stmt, used, BitSet(), maxlength_idx, color, show_type)
end

function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, unstable_ssa::BitSet, maxlength_idx::Int, color::Bool, show_type::Bool)
Expand Down Expand Up @@ -87,7 +86,7 @@ function print_stmt(io::IO, idx::Int, @nospecialize(stmt), used::BitSet, unstabl
show_unquoted_gotoifnot(io, stmt, indent, "#")
# everything else in the IR, defer to the generic AST printer
elseif stmt isa Expr
show_unquoted(io, stmt, unstable_ssa, indent, show_type ? prec_decl : 0)
show_unquoted(io, stmt, unstable_ssa, indent, show_type ? prec_decl : 0)
else
show_unquoted(io, stmt, indent, show_type ? prec_decl : 0)
end
Expand Down Expand Up @@ -128,7 +127,6 @@ function show_unquoted(io::IO, stmt::PiNode, indent::Int, ::Int)
print(io, ", ")
printstyled(io, stmt.typ, color=:cyan)
print(io, ")")
end

function show_unquoted(io::IO, stmt::UpsilonNode, indent::Int, ::Int)
print(io, "ϒ (")
Expand Down Expand Up @@ -635,6 +633,8 @@ end
# may return a new node at the current index `idx`, which is printed before the statement
# at index `idx`. This function is repeatedly called until it returns `nothing`.
# to iterate nodes that are to be inserted after the statement, set `attach_after=true`.

# Forwarding function for compatibility with existing libraries like LoweredCodeUtils.jl
function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo, IncrementalCompact}, idx::Int, config::IRShowConfig,
used::BitSet, cfg::CFG, bb_idx::Int; pop_new_node! = Returns(nothing), only_after::Bool=false)
return show_ir_stmt(io, code, idx, config.line_info_preprinter, config.line_info_postprinter,
Expand All @@ -647,11 +647,10 @@ function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo, IncrementalCompact},
used, unstable_ssa, cfg, bb_idx; pop_new_node!, only_after, config.bb_color)
end

# Forwarding function for compability with existing libraries like LoweredCodeUtils.jl
function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo, IncrementalCompact}, idx::Int, line_info_preprinter::Function, line_info_postprinter::Function,
used::BitSet, cfg::CFG, bb_idx::Int; pop_new_node! = Returns(nothing), only_after::Bool=false, bb_color=:light_black)
return show_ir_stmt(io, code, idx, line_info_preprinter, line_info_postprinter,
used, BitSet(), cfg, bb_idx; pop_new_node!, only_after, bb_color)
return show_ir_stmt(io, code, idx, line_info_preprinter, line_info_postprinter,
used, BitSet(), cfg, bb_idx; pop_new_node!, only_after, bb_color)
end

function show_ir_stmt(io::IO, code::Union{IRCode, CodeInfo, IncrementalCompact}, idx::Int, line_info_preprinter, line_info_postprinter,
Expand Down Expand Up @@ -868,9 +867,9 @@ statementidx_lineinfo_printer(f, code::CodeInfo) = f(code.debuginfo, :var"unknow
statementidx_lineinfo_printer(code) = statementidx_lineinfo_printer(DILineInfoPrinter, code)

function is_unstable_ssa(code::CodeInfo, idx::Int64)
ssaType = _type(code, idx)
is_unstable = isa(ssaType, Type) & (!Base.isdispatchelem(ssaType) || ssaType == Core.Box)
return is_unstable
ssaType = _type(code, idx)
is_unstable = isa(ssaType, Type) & (!Base.isdispatchelem(ssaType) || ssaType == Core.Box)
return is_unstable
end

function stmts_used(io::IO, code::IRCode, warn_unset_entry=true)
Expand Down
8 changes: 4 additions & 4 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ end
# show an indented list

function show_list(io::IO, items, sep, indent::Int, prec::Int=0, quote_level::Int=0, enclose_operators::Bool=false, kw::Bool=false)
show_list(io, items, sep, BitSet(), indent, prec, quote_level, enclose_operators, kw)
show_list(io, items, sep, BitSet(), indent, prec, quote_level, enclose_operators, kw)
end

function show_list(io::IO, items, sep, unstable_ssa::BitSet, indent::Int, prec::Int=0, quote_level::Int=0, enclose_operators::Bool=false,
Expand Down Expand Up @@ -1763,7 +1763,7 @@ function show_list(io::IO, items, sep, unstable_ssa::BitSet, indent::Int, prec::
end
# show an indented list inside the parens (op, cl)
function show_enclosed_list(io::IO, op, items, sep, cl, indent, prec=0, quote_level=0, encl_ops=false, kw::Bool=false)
show_enclosed_list(io, op, items, sep, cl, BitSet(), indent, prec, quote_level, encl_ops, kw)
show_enclosed_list(io, op, items, sep, cl, BitSet(), indent, prec, quote_level, encl_ops, kw)
end

function show_enclosed_list(io::IO, op, items, sep, cl, unstable_ssa::BitSet, indent, prec=0, quote_level=0, encl_ops=false, kw::Bool=false)
Expand All @@ -1783,7 +1783,7 @@ end
# show a normal (non-operator) function call, e.g. f(x, y) or A[z]
# kw: `=` expressions are parsed with head `kw` in this context
function show_call(io::IO, head, func, func_args, indent, quote_level, kw::Bool)
show_call(io, head, func, func_args, BitSet(), indent, quote_level, kw)
show_call(io, head, func, func_args, BitSet(), indent, quote_level, kw)
end

function show_call(io::IO, head, func, func_args, unstable_ssa::BitSet, indent, quote_level, kw::Bool)
Expand Down Expand Up @@ -1994,7 +1994,7 @@ end

# TODO: implement interpolated strings
function show_unquoted(io::IO, ex::Expr, indent::Int, prev::Int, quote_level::Int=0)
show_unquoted(io, ex, BitSet(), indent, prev, quote_level)
show_unquoted(io, ex, BitSet(), indent, prev, quote_level)
end

function show_unquoted(io::IO, ex::Expr, unstable_ssa::BitSet, indent::Int, prec::Int, quote_level::Int)
Expand Down

0 comments on commit b7becc5

Please sign in to comment.