julia> @descend_code_warntype Base.print_matrix(stdout, rand(2,2))
[ Info: tracking Base
print_matrix(io::IO, X::AbstractVecOrMat) @ Base ~/packages/julias/julia-1.9/share/julia/base/arrayshow.jl:163
[ Info: This method only fills in default arguments; descend into the body method to see the full source.
163 function print_matrix(io::Base.TTY::IO, X::Matrix{Float64}::AbstractVecOrMat,
164 pre::AbstractString = " ", # pre-matrix string
165 sep::AbstractString = " ", # separator between elements
166 post::AbstractString = "", # post-matrix string
167 hdots::AbstractString = " \u2026 ",
168 vdots::AbstractString = "\u22ee",
169 ddots::AbstractString = " \u22f1 ",
170 hmod::Integer = 5, vmod::Integer = 5)::Core.Const(nothing)
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
• %1 = print_matrix(::Base.TTY,::Matrix{Float64},::String,::String,::String,::String,::String,::String,::Int64,::Int64)::Core.Const(nothing)
↩
print_matrix(io::IO, X::AbstractVecOrMat, pre::AbstractString, sep::AbstractString, post::AbstractString, hdots::AbstractString, vdots::AbstractString, ddots::AbstractString, hmod::Integer, vmod::Integer) @ Base ~/packages/julias/julia-1.9/share/julia/base/arrayshow.jl:163
163 function print_matrix(io::Base.TTY::IO, X::Matrix{Float64}::AbstractVecOrMat,
164 pre::String::AbstractString = " ", # pre-matrix string
165 sep::String::AbstractString = " ", # separator between elements
166 post::String::AbstractString = "", # post-matrix string
167 hdots::String::AbstractString = " \u2026 ",
168 vdots::String::AbstractString = "\u22ee",
169 ddots::String::AbstractString = " \u22f1 ",
170 hmod::Int64::Integer = 5, vmod::Int64::Integer = 5)::Core.Const(nothing)
171 _print_matrix(io::Base.TTY, inferencebarrier(X::Matrix{Float64})::Any, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, unitrange(axes(X::Matrix{Float64},1)::Base.OneTo{Int64})::UnitRange{Int64}, unitrange(axes(X::Matrix{Float64},2)::Base.OneTo{Int64})::UnitRange{Int64})::Nothing
172 end
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
inferencebarrier(X::Matrix{Float64})
axes(X::Matrix{Float64},1)
unitrange(axes(X::Matrix{Float64},1)::Base.OneTo{Int64})
axes(X::Matrix{Float64},2)
unitrange(axes(X::Matrix{Float64},2)::Base.OneTo{Int64})
• _print_matrix(io::Base.TTY, inferencebarrier(X::Matrix{Float64})::Any, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmo…
↩
_print_matrix(io, X::AbstractVecOrMat, pre, sep, post, hdots, vdots, ddots, hmod, vmod, rowsA, colsA) @ Base ~/packages/julias/julia-1.9/share/julia/base/arrayshow.jl:174
174 function _print_matrix(io::Base.TTY, @nospecialize(X::AbstractVecOrMat::AbstractVecOrMat), pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::UnitRange{Int64}, colsA::UnitRange{Int64})::Core.Const(nothing)
175 hmod::Int64, vmod::Int64 = (Int::Type{Int64}(hmod::Int64)::Int64::Int::Type{Int64})::Int64, (Int::Type{Int64}(vmod::Int64)::Int64::Int::Type{Int64})::Int64
176 ncols::Int64, idxlast::Int64 = length(colsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64, last(colsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64
177 if !((get(io::Base.TTY, :limit, false)::Bool::Bool)::Bool)
178 screenheight::Int64 = screenwidth::Int64 = typemax(Int::Type{Int64})::Int64
179 else
180 sz = displaysize(io)::Tuple{Int::Type{Int64},Int::Type{Int64}}
181 screenheight, screenwidth = sz[1] - 4, sz[2]
182 end
183 (screenwidth::Int64 -= ((length(pre::String)::Int64::Int::Type{Int64})::Int64 + (length(post::String)::Int64::Int::Type{Int64})::Int64)::Int64)::Int64
184 presp::String = repeat(" ", (length(pre::String)::Int64::Int::Type{Int64})::Int64)::String # indent each row to match pre string
185 postsp::String = "::String"
186 @assert (textwidth(hdots::String)::Int64 == textwidth(ddots::String)::Int64)::Bool
187 sepsize::Int64 = (length(sep::String)::Int64::Int::Type{Int64})::Int64
188 m::Int64, n::Int64 = length(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64, length(colsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64
189 # To figure out alignments, only need to look at as many rows as could
190 # fit down screen. If screen has at least as many rows as A, look at A.
191 # If not, then we only need to look at the first and last chunks of A,
192 # each half a screen height in size.
193 halfheight::Core.Const(4611686018427387903) = div(screenheight::Int64,2)::Int64
194 if (m::Int64 > screenheight::Int64)::Bool
195 rowsA::Vector{Int64} = [rowsA[(((0:(halfheight::Int64-1)::Int64)::UnitRange{Int64}) .+ firstindex(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::UnitRange{Int64}]::UnitRange{Int64}; rowsA[(((end-div((screenheight::Int64-1)::Int64,2)::Int64)::Int64+1)::Int64):end]]::Vector{Int64}
196 else
197 rowsA = [rowsA;]
198 end
199 # Similarly for columns, only necessary to get alignments for as many
200 # columns as could conceivably fit across the screen
201 maxpossiblecols::Int64 = div(screenwidth::Int64, (1+sepsize::Int64)::Int64)::Int64
202 if (n::Int64 > maxpossiblecols::Int64)::Bool
203 colsA::Vector{Int64} = [colsA[(((0:(maxpossiblecols::Int64-1)::Int64)::UnitRange{Int64}) .+ firstindex(colsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::UnitRange{Int64}]::UnitRange{Int64}; colsA[((end-maxpossiblecols+1)::Int64):end]]::Vector{Int64}
204 else
205 colsA = [colsA;]
206 end
207 A::Vector{Tuple{Int64, Int64}} = alignment(io::Base.TTY, X::AbstractVecOrMat, rowsA::Union{UnitRange{Int64}, Vector{Int64}}, colsA::Union{UnitRange{Int64}, Vector{Int64}}, screenwidth::Int64, screenwidth::Int64, sepsize::Int64, ncols::Int64)::Vector{Tuple{Int64, Int64}}
208 # Nine-slicing is accomplished using print_matrix_row repeatedly
209 if (m::Int64 <= screenheight::Int64)::Bool # rows fit vertically on screen
210 if (n::Int64 <= length(A::Vector{Tuple{Int64, Int64}})::Int64)::Bool # rows and cols fit so just print whole matrix in one piece
211 for i::Int64 in rowsA::Vector{Int64}::Union{Nothing, Tuple{Int64, Int64}}
212 print(io::Base.TTY, (i::Int64 == first(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? pre::String : presp::String)
213 print_matrix_row(io::Base.TTY, X::AbstractVecOrMat,A::Vector{Tuple{Int64, Int64}},i::Int64,colsA::Union{UnitRange{Int64}, Vector{Int64}},sep::String,idxlast::Int64)
214 print(io::Base.TTY, (i::Int64 == last(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? post::String : postsp::String)
215 if i != last(rowsA); println(io::Base.TTY); end
216 end
217 else # rows fit down screen but cols don't, so need horizontal ellipsis
218 c::Int64 = (div(((screenwidth::Int64-(length(hdots::String)::Int64::Int::Type{Int64})::Int64)::Int64+1)::Int64,2)::Int64+1)::Int64 # what goes to right of ellipsis
219 Ralign::Vector{Tuple{Int64, Int64}} = reverse(alignment(io::Base.TTY, X::AbstractVecOrMat, rowsA::Vector{Int64}, reverse(colsA::Union{UnitRange{Int64}, Vector{Int64}})::Vector{Int64}, c, c, sepsize::Int64, ncols::Int64)::Vector{Tuple{Int64, Int64}})::Vector{Tuple{Int64, Int64}} # alignments for right
220 c::Int64 = (((screenwidth::Int64 - sum(map(sum,Ralign::Vector{Tuple{Int64, Int64}})::Vector{Int64})::Int64)::Int64 - (((length(Ralign::Vector{Tuple{Int64, Int64}})::Int64-1)::Int64)*sepsize::Int64)::Int64)::Int64 - (length(hdots::String)::Int64::Int::Type{Int64})::Int64)::Int64
221 Lalign::Vector{Tuple{Int64, Int64}} = alignment(io::Base.TTY, X::AbstractVecOrMat, rowsA::Union{UnitRange{Int64}, Vector{Int64}}, colsA::Union{UnitRange{Int64}, Vector{Int64}}, c::Int64, c::Int64, sepsize::Int64, ncols::Int64)::Vector{Tuple{Int64, Int64}} # alignments for left of ellipsis
222 for i::Int64 in rowsA::Vector{Int64}::Union{Nothing, Tuple{Int64, Int64}}
223 print(io::Base.TTY, (i::Int64 == first(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? pre::String : presp::String)
224 print_matrix_row(io::Base.TTY, X::AbstractVecOrMat,Lalign,i::Int64,colsA::Vector{Int64}[(1:length(Lalign::Vector{Tuple{Int64, Int64}})::Int64)::UnitRange{Int64}]::Vector{Int64},sep::String,idxlast::Int64)
225 print(io::Base.TTY,( (((i::Int64 - first(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Int64) % hmod::Int64)::Int64 == 0)::Bool ? hdots : repeat(" ", (length(hdots::String)::Int64::Int::Type{Int64})::Int64)::String)
226 print_matrix_row(io::Base.TTY, X::AbstractVecOrMat, Ralign, i::Int64, (((n::Int64 - length(Ralign::Vector{Tuple{Int64, Int64}})::Int64)::Int64) .+ colsA::Union{UnitRange{Int64}, Vector{Int64}})::Vector{Int64}, sep::String, idxlast::Int64)
227 print(io::Base.TTY, (i::Int64 == last(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? post::String : postsp::String)
228 if i != last(rowsA); println(io::Base.TTY); end
229 end
230 end
231 else # rows don't fit so will need vertical ellipsis
232 if (n::Int64 <= length(A::Vector{Tuple{Int64, Int64}})::Int64)::Bool # rows don't fit, cols do, so only vertical ellipsis
233 for i::Int64 in rowsA::Vector{Int64}::Union{Nothing, Tuple{Int64, Int64}}
234 print(io::Base.TTY, (i::Int64 == first(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? pre::String : presp::String)
235 print_matrix_row(io::Base.TTY, X::AbstractVecOrMat,A::Vector{Tuple{Int64, Int64}},i::Int64,colsA::Union{UnitRange{Int64}, Vector{Int64}},sep::String,idxlast::Int64)
236 print(io::Base.TTY, (i::Int64 == last(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? post::String : postsp::String)
237 if i != rowsA[end] || i == rowsA[halfheight]; println(io::Base.TTY); end
238 if (i::Int64 == rowsA::Union{UnitRange{Int64}, Vector{Int64}}[halfheight::Int64]::Int64)::Bool
239 print(io::Base.TTY, (i::Int64 == first(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? pre::String : presp::String)
240 print_matrix_vdots(io::Base.TTY, vdots::String, A::Vector{Tuple{Int64, Int64}}, sep::String, vmod::Int64, 1, false)
241 print(io::Base.TTY, (i::Int64 == last(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? post::String : postsp * '\n')
242 end
243 end
244 else # neither rows nor cols fit, so use all 3 kinds of dots
245 c::Int64 = (div(((screenwidth::Int64-(length(hdots::String)::Int64::Int::Type{Int64})::Int64)::Int64+1)::Int64,2)::Int64+1)::Int64
246 Ralign::Vector{Tuple{Int64, Int64}} = reverse(alignment(io::Base.TTY, X::AbstractVecOrMat, rowsA::Vector{Int64}, reverse(colsA::Union{UnitRange{Int64}, Vector{Int64}})::Vector{Int64}, c, c, sepsize::Int64, ncols::Int64)::Vector{Tuple{Int64, Int64}})::Vector{Tuple{Int64, Int64}}
247 c::Int64 = (((screenwidth::Int64 - sum(map(sum,Ralign::Vector{Tuple{Int64, Int64}})::Vector{Int64})::Int64)::Int64 - (((length(Ralign::Vector{Tuple{Int64, Int64}})::Int64-1)::Int64)*sepsize::Int64)::Int64)::Int64 - (length(hdots::String)::Int64::Int::Type{Int64})::Int64)::Int64
248 Lalign::Vector{Tuple{Int64, Int64}} = alignment(io::Base.TTY, X::AbstractVecOrMat, rowsA::Union{UnitRange{Int64}, Vector{Int64}}, colsA::Union{UnitRange{Int64}, Vector{Int64}}, c::Int64, c::Int64, sepsize::Int64, ncols::Int64)::Vector{Tuple{Int64, Int64}}
249 r::Int64 = mod((((length(Ralign::Vector{Tuple{Int64, Int64}})::Int64-n::Int64)::Int64+1)::Int64),vmod::Int64)::Int64 # where to put dots on right half
250 for i::Int64 in rowsA::Vector{Int64}::Union{Nothing, Tuple{Int64, Int64}}
251 print(io::Base.TTY, (i::Int64 == first(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? pre::String : presp::String)
252 print_matrix_row(io::Base.TTY, X::AbstractVecOrMat,Lalign,i::Int64,colsA::Vector{Int64}[(1:length(Lalign::Vector{Tuple{Int64, Int64}})::Int64)::UnitRange{Int64}]::Vector{Int64},sep::String,idxlast::Int64)
253 print(io::Base.TTY,( (((i::Int64 - first(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Int64) % hmod::Int64)::Int64 == 0)::Bool ? hdots : repeat(" ", (length(hdots::String)::Int64::Int::Type{Int64})::Int64)::String)
254 print_matrix_row(io::Base.TTY, X::AbstractVecOrMat,Ralign,i::Int64,(((n::Int64-length(Ralign::Vector{Tuple{Int64, Int64}})::Int64)::Int64).+colsA::Union{UnitRange{Int64}, Vector{Int64}})::Vector{Int64},sep::String,idxlast::Int64)
255 print(io::Base.TTY, (i::Int64 == last(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? post::String : postsp::String)
256 if i != rowsA[end] || i == rowsA[halfheight]; println(io::Base.TTY); end
257 if (i::Int64 == rowsA::Union{UnitRange{Int64}, Vector{Int64}}[halfheight::Int64]::Int64)::Bool
258 print(io::Base.TTY, (i::Int64 == first(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? pre::String : presp::String)
259 print_matrix_vdots(io::Base.TTY, vdots::String, Lalign::Vector{Tuple{Int64, Int64}}, sep::String, vmod::Int64, 1, true)
260 print(io::Base.TTY, ddots::String)
261 print_matrix_vdots(io::Base.TTY, vdots::String, Ralign::Vector{Tuple{Int64, Int64}}, sep::String, vmod::Int64, r::Int64, false)
262 print(io::Base.TTY, (i::Int64 == last(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64)::Bool ? post::String : postsp * '\n')
263 end
264 end
265 end
266 if isempty(rowsA::Union{UnitRange{Int64}, Vector{Int64}})::Bool
267 print(io::Base.TTY, pre::String)
268 print(io::Base.TTY, vdots::String)
269 (length(colsA::Union{UnitRange{Int64}, Vector{Int64}})::Int64 > 1)::Bool && print(io::Base.TTY, " ", ddots::String)
270 print(io::Base.TTY, post::String)::Nothing
271 end
272 end
273 end
Select a call to descend into or ↩ to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
• Int::Type{Int64}(hmod::Int64)
Int::Type{Int64}(vmod::Int64)
length(colsA)
last(colsA)
get(io::Base.TTY, :limit, false)
%37 = < concrete eval > !(::Core.Const(false))::Core.Const(true)
typemax(Int)
length(pre::String)
length(post::String)
v (length(pre::String)::Int64::Int::Type{Int64})::Int64 + (length(post::String)::Int64::Int::Type{Int64})::Int64
On line 185, we see postsp::String = "::String", whereas this should probably read postsp::String = ""::String. The line reads postsp = "".
versions:
(@v1.9) pkg> st -m Cthulhu
Status `~/.julia/environments/v1.9/Manifest.toml`
[f68482b8] Cthulhu v2.10.0
(@v1.9) pkg> st -m TypedSyntax
Status `~/.julia/environments/v1.9/Manifest.toml`
[d265eb64] TypedSyntax v1.2.3
julia> VERSION
v"1.9.4"
On line 185, we see
postsp::String = "::String"
, whereas this should probably readpostsp::String = ""::String
. The line readspostsp = ""
.versions: