• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37485

pending completion
#37485

push

local

web-flow
print NamedTuple types using the macro format (#49117)

22 of 22 new or added lines in 1 file covered. (100.0%)

71725 of 82813 relevant lines covered (86.61%)

31876657.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.82
/stdlib/InteractiveUtils/src/codeview.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
# highlighting settings
4
const highlighting = Dict{Symbol, Bool}(
5
    :warntype => true,
6
    :llvm => true,
7
    :native => true,
8
)
9

10
const llstyle = Dict{Symbol, Tuple{Bool, Union{Symbol, Int}}}(
11
    :default     => (false, :normal), # e.g. comma, equal sign, unknown token
12
    :comment     => (false, :light_black),
13
    :label       => (false, :light_red),
14
    :instruction => ( true, :light_cyan),
15
    :type        => (false, :cyan),
16
    :number      => (false, :yellow),
17
    :bracket     => (false, :yellow),
18
    :variable    => (false, :normal), # e.g. variable, register
19
    :keyword     => (false, :light_magenta),
20
    :funcname    => (false, :light_yellow),
21
)
22

23
function printstyled_ll(io::IO, x, s::Symbol, trailing_spaces="")
×
24
    printstyled(io, x, bold=llstyle[s][1], color=llstyle[s][2])
×
25
    print(io, trailing_spaces)
×
26
end
27

28
# displaying type warnings
29

30
function warntype_type_printer(io::IO; @nospecialize(type), used::Bool, show_type::Bool=true, _...)
166✔
31
    (show_type && used) || return nothing
116✔
32
    str = "::$type"
50✔
33
    if !highlighting[:warntype]
50✔
34
        print(io, str)
×
35
    elseif type isa Union && is_expected_union(type)
50✔
36
        Base.emphasize(io, str, Base.warn_color()) # more mild user notification
4✔
37
    elseif type isa Type && (!Base.isdispatchelem(type) || type == Core.Box)
90✔
38
        Base.emphasize(io, str)
×
39
    else
40
        Base.printstyled(io, str, color=:cyan) # show the "good" type
46✔
41
    end
42
    return nothing
50✔
43
end
44

45
# True if one can be pretty certain that the compiler handles this union well,
46
# i.e. must be small with concrete types.
47
function is_expected_union(u::Union)
4✔
48
    Base.unionlen(u) < 4 || return false
4✔
49
    for x in Base.uniontypes(u)
4✔
50
        if !Base.isdispatchelem(x) || x == Core.Box
16✔
51
            return false
×
52
        end
53
    end
12✔
54
    return true
4✔
55
end
56

57
"""
58
    code_warntype([io::IO], f, types; debuginfo=:default)
59

60
Prints lowered and type-inferred ASTs for the methods matching the given generic function
61
and type signature to `io` which defaults to `stdout`. The ASTs are annotated in such a way
62
as to cause "non-leaf" types which may be problematic for performance to be emphasized
63
(if color is available, displayed in red). This serves as a warning of potential type instability.
64

65
Not all non-leaf types are particularly problematic for performance, and the performance
66
characteristics of a particular type is an implementation detail of the compiler.
67
`code_warntype` will err on the side of coloring types red if they might be a performance
68
concern, so some types may be colored red even if they do not impact performance.
69
Small unions of concrete types are usually not a concern, so these are highlighted in yellow.
70

71
Keyword argument `debuginfo` may be one of `:source` or `:none` (default), to specify the verbosity of code comments.
72

73
See [`@code_warntype`](@ref man-code-warntype) for more information.
74
"""
75
function code_warntype(io::IO, @nospecialize(f), @nospecialize(t=Base.default_tt(f));
4✔
76
                       debuginfo::Symbol=:default, optimize::Bool=false, kwargs...)
77
    debuginfo = Base.IRShow.debuginfo(debuginfo)
2✔
78
    lineprinter = Base.IRShow.__debuginfo[debuginfo]
2✔
79
    for (src, rettype) in code_typed(f, t; optimize, kwargs...)
2✔
80
        if !(src isa Core.CodeInfo)
2✔
81
            println(io, src)
×
82
            println(io, "  failed to infer")
×
83
            continue
×
84
        end
85
        lambda_io::IOContext = io
2✔
86
        p = src.parent
2✔
87
        nargs::Int = 0
2✔
88
        if p isa Core.MethodInstance
2✔
89
            println(io, p)
2✔
90
            print(io, "  from ")
2✔
91
            println(io, p.def)
2✔
92
            p.def isa Method && (nargs = p.def.nargs)
2✔
93
            if !isempty(p.sparam_vals)
2✔
94
                println(io, "Static Parameters")
×
95
                sig = p.def.sig
×
96
                warn_color = Base.warn_color() # more mild user notification
×
97
                for i = 1:length(p.sparam_vals)
×
98
                    sig = sig::UnionAll
×
99
                    name = sig.var.name
×
100
                    val = p.sparam_vals[i]
×
101
                    print_highlighted(io::IO, v::String, color::Symbol) =
×
102
                        if highlighting[:warntype]
103
                            Base.printstyled(io, v; color)
×
104
                        else
105
                            Base.print(io, v)
×
106
                        end
107
                    if val isa TypeVar
×
108
                        if val.lb === Union{}
×
109
                            print(io, "  ", name, " <: ")
×
110
                            print_highlighted(io, "$(val.ub)", warn_color)
×
111
                        elseif val.ub === Any
×
112
                            print(io, "  ", sig.var.name, " >: ")
×
113
                            print_highlighted(io, "$(val.lb)", warn_color)
×
114
                        else
115
                            print(io, "  ")
×
116
                            print_highlighted(io, "$(val.lb)", warn_color)
×
117
                            print(io, " <: ", sig.var.name, " <: ")
×
118
                            print_highlighted(io, "$(val.ub)", warn_color)
×
119
                        end
120
                    elseif val isa typeof(Vararg)
×
121
                        print(io, "  ", name, "::")
×
122
                        print_highlighted(io, "Int", warn_color)
×
123
                    else
124
                        print(io, "  ", sig.var.name, " = ")
×
125
                        print_highlighted(io, "$(val)", :cyan) # show the "good" type
×
126
                    end
127
                    println(io)
×
128
                    sig = sig.body
×
129
                end
×
130
            end
131
        end
132
        if src.slotnames !== nothing
2✔
133
            slotnames = Base.sourceinfo_slotnames(src)
2✔
134
            lambda_io = IOContext(lambda_io, :SOURCE_SLOTNAMES => slotnames)
2✔
135
            slottypes = src.slottypes
2✔
136
            nargs > 0 && println(io, "Arguments")
2✔
137
            for i = 1:length(slotnames)
4✔
138
                if i == nargs + 1
12✔
139
                    println(io, "Locals")
2✔
140
                end
141
                print(io, "  ", slotnames[i])
12✔
142
                if isa(slottypes, Vector{Any})
12✔
143
                    warntype_type_printer(io; type=slottypes[i], used=true)
12✔
144
                end
145
                println(io)
12✔
146
            end
22✔
147
        end
148
        print(io, "Body")
2✔
149
        warntype_type_printer(io; type=rettype, used=true)
2✔
150
        println(io)
2✔
151
        irshow_config = Base.IRShow.IRShowConfig(lineprinter(src), warntype_type_printer)
2✔
152
        Base.IRShow.show_ir(lambda_io, src, irshow_config)
2✔
153
        println(io)
2✔
154
    end
4✔
155
    nothing
2✔
156
end
157
code_warntype(@nospecialize(f), @nospecialize(t=Base.default_tt(f)); kwargs...) =
×
158
    code_warntype(stdout, f, t; kwargs...)
159

160
import Base.CodegenParams
161

162
const GENERIC_SIG_WARNING = "; WARNING: This code may not match what actually runs.\n"
163
const OC_MISMATCH_WARNING =
164
"""
165
; WARNING: The pre-inferred opaque closure is not callable with the given arguments
166
;          and will error on dispatch with this signature.
167
"""
168

169
# Printing code representations in IR and assembly
170
function _dump_function(@nospecialize(f), @nospecialize(t), native::Bool, wrapper::Bool,
107✔
171
                        strip_ir_metadata::Bool, dump_module::Bool, syntax::Symbol,
172
                        optimize::Bool, debuginfo::Symbol, binary::Bool,
173
                        params::CodegenParams=CodegenParams(debug_info_kind=Cint(0)))
174
    ccall(:jl_is_in_pure_context, Bool, ()) && error("code reflection cannot be used from generated functions")
107✔
175
    if isa(f, Core.Builtin)
69✔
176
        throw(ArgumentError("argument is not a generic function"))
×
177
    end
178
    warning = ""
69✔
179
    # get the MethodInstance for the method match
180
    if !isa(f, Core.OpaqueClosure)
69✔
181
        world = Base.get_world_counter()
69✔
182
        match = Base._which(signature_type(f, t); world)
69✔
183
        linfo = Core.Compiler.specialize_method(match)
69✔
184
        # TODO: use jl_is_cacheable_sig instead of isdispatchtuple
185
        isdispatchtuple(linfo.specTypes) || (warning = GENERIC_SIG_WARNING)
69✔
186
    else
187
        world = UInt64(f.world)
×
188
        if Core.Compiler.is_source_inferred(f.source.source)
×
189
            # OC was constructed from inferred source. There's only one
190
            # specialization and we can't infer anything more precise either.
191
            world = f.source.primary_world
×
192
            linfo = f.source.specializations::Core.MethodInstance
×
193
            Core.Compiler.hasintersect(typeof(f).parameters[1], t) || (warning = OC_MISMATCH_WARNING)
×
194
        else
195
            linfo = Core.Compiler.specialize_method(f.source, Tuple{typeof(f.captures), t.parameters...}, Core.svec())
×
196
            actual = isdispatchtuple(linfo.specTypes)
×
197
            isdispatchtuple(linfo.specTypes) || (warning = GENERIC_SIG_WARNING)
×
198
        end
199
    end
200
    # get the code for it
201
    if debuginfo === :default
69✔
202
        debuginfo = :source
30✔
203
    elseif debuginfo !== :source && debuginfo !== :none
39✔
204
        throw(ArgumentError("'debuginfo' must be either :source or :none"))
×
205
    end
206
    if native
69✔
207
        if syntax !== :att && syntax !== :intel
×
208
            throw(ArgumentError("'syntax' must be either :intel or :att"))
×
209
        end
210
        if dump_module
×
211
            str = _dump_function_linfo_native(linfo, world, wrapper, syntax, debuginfo, binary, params)
×
212
        else
213
            str = _dump_function_linfo_native(linfo, world, wrapper, syntax, debuginfo, binary)
×
214
        end
215
    else
216
        str = _dump_function_linfo_llvm(linfo, world, wrapper, strip_ir_metadata, dump_module, optimize, debuginfo, params)
69✔
217
    end
218
    str = warning * str
69✔
219
    return str
69✔
220
end
221

222
function _dump_function_linfo_native(linfo::Core.MethodInstance, world::UInt, wrapper::Bool, syntax::Symbol, debuginfo::Symbol, binary::Bool)
×
223
    str = ccall(:jl_dump_method_asm, Ref{String},
×
224
                (Any, UInt, Bool, Bool, Ptr{UInt8}, Ptr{UInt8}, Bool),
225
                linfo, world, false, wrapper, syntax, debuginfo, binary)
226
    return str
×
227
end
228

229
struct LLVMFDump
230
    tsm::Ptr{Cvoid} # opaque
231
    f::Ptr{Cvoid} # opaque
232
end
233

234
function _dump_function_linfo_native(linfo::Core.MethodInstance, world::UInt, wrapper::Bool, syntax::Symbol, debuginfo::Symbol, binary::Bool, params::CodegenParams)
×
235
    llvmf_dump = Ref{LLVMFDump}()
×
236
    ccall(:jl_get_llvmf_defn, Cvoid, (Ptr{LLVMFDump}, Any, UInt, Bool, Bool, CodegenParams), llvmf_dump, linfo, world, wrapper, true, params)
×
237
    llvmf_dump[].f == C_NULL && error("could not compile the specified method")
×
238
    str = ccall(:jl_dump_function_asm, Ref{String},
×
239
                (Ptr{LLVMFDump}, Bool, Ptr{UInt8}, Ptr{UInt8}, Bool),
240
                llvmf_dump, false, syntax, debuginfo, binary)
241
    return str
×
242
end
243

244
function _dump_function_linfo_llvm(
69✔
245
        linfo::Core.MethodInstance, world::UInt, wrapper::Bool,
246
        strip_ir_metadata::Bool, dump_module::Bool,
247
        optimize::Bool, debuginfo::Symbol,
248
        params::CodegenParams)
249
    llvmf_dump = Ref{LLVMFDump}()
69✔
250
    ccall(:jl_get_llvmf_defn, Cvoid, (Ptr{LLVMFDump}, Any, UInt, Bool, Bool, CodegenParams), llvmf_dump, linfo, world, wrapper, optimize, params)
69✔
251
    llvmf_dump[].f == C_NULL && error("could not compile the specified method")
69✔
252
    str = ccall(:jl_dump_function_ir, Ref{String},
69✔
253
                (Ptr{LLVMFDump}, Bool, Bool, Ptr{UInt8}),
254
                llvmf_dump, strip_ir_metadata, dump_module, debuginfo)
255
    return str
69✔
256
end
257

258
"""
259
    code_llvm([io=stdout,], f, types; raw=false, dump_module=false, optimize=true, debuginfo=:default)
260

261
Prints the LLVM bitcodes generated for running the method matching the given generic
262
function and type signature to `io`.
263

264
If the `optimize` keyword is unset, the code will be shown before LLVM optimizations.
265
All metadata and dbg.* calls are removed from the printed bitcode. For the full IR, set the `raw` keyword to true.
266
To dump the entire module that encapsulates the function (with declarations), set the `dump_module` keyword to true.
267
Keyword argument `debuginfo` may be one of source (default) or none, to specify the verbosity of code comments.
268
"""
269
function code_llvm(io::IO, @nospecialize(f), @nospecialize(types), raw::Bool,
32✔
270
                   dump_module::Bool=false, optimize::Bool=true, debuginfo::Symbol=:default)
271
    d = _dump_function(f, types, false, false, !raw, dump_module, :intel, optimize, debuginfo, false)
32✔
272
    if highlighting[:llvm] && get(io, :color, false)::Bool
30✔
273
        print_llvm(io, d)
×
274
    else
275
        print(io, d)
30✔
276
    end
277
end
278
code_llvm(io::IO, @nospecialize(f), @nospecialize(types=Base.default_tt(f)); raw::Bool=false, dump_module::Bool=false, optimize::Bool=true, debuginfo::Symbol=:default) =
64✔
279
    code_llvm(io, f, types, raw, dump_module, optimize, debuginfo)
280
code_llvm(@nospecialize(f), @nospecialize(types=Base.default_tt(f)); raw=false, dump_module=false, optimize=true, debuginfo::Symbol=:default) =
6✔
281
    code_llvm(stdout, f, types; raw, dump_module, optimize, debuginfo)
282

283
"""
284
    code_native([io=stdout,], f, types; syntax=:intel, debuginfo=:default, binary=false, dump_module=true)
285

286
Prints the native assembly instructions generated for running the method matching the given
287
generic function and type signature to `io`.
288

289
* Set assembly syntax by setting `syntax` to `:intel` (default) for intel syntax or `:att` for AT&T syntax.
290
* Specify verbosity of code comments by setting `debuginfo` to `:source` (default) or `:none`.
291
* If `binary` is `true`, also print the binary machine code for each instruction precedented by an abbreviated address.
292
* If `dump_module` is `false`, do not print metadata such as rodata or directives.
293

294
See also: [`@code_native`](@ref), [`code_llvm`](@ref), [`code_typed`](@ref) and [`code_lowered`](@ref)
295
"""
296
function code_native(io::IO, @nospecialize(f), @nospecialize(types=Base.default_tt(f));
4✔
297
                     dump_module::Bool=true, syntax::Symbol=:intel, debuginfo::Symbol=:default, binary::Bool=false)
298
    d = _dump_function(f, types, true, false, false, dump_module, syntax, true, debuginfo, binary)
2✔
299
    if highlighting[:native] && get(io, :color, false)::Bool
×
300
        print_native(io, d)
×
301
    else
302
        print(io, d)
×
303
    end
304
end
305
code_native(@nospecialize(f), @nospecialize(types=Base.default_tt(f)); dump_module::Bool=true, syntax::Symbol=:intel, debuginfo::Symbol=:default, binary::Bool=false) =
4✔
306
    code_native(stdout, f, types; dump_module, syntax, debuginfo, binary)
307
code_native(::IO, ::Any, ::Symbol) = error("invalid code_native call") # resolve ambiguous call
×
308

309
## colorized IR and assembly printing
310

311
const num_regex = r"^(?:\$?-?\d+|0x[0-9A-Fa-f]+|-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)$"
312

313
function print_llvm(io::IO, code::String)
×
314
    buf = IOBuffer(code)
×
315
    for line in eachline(buf)
×
316
        m = match(r"^(\s*)((?:[^;]|;\")*)(.*)$", line)
×
317
        m === nothing && continue
×
318
        indent, tokens, comment = m.captures
×
319
        print(io, indent)
×
320
        print_llvm_tokens(io, tokens)
×
321
        printstyled_ll(io, comment, :comment)
×
322
        println(io)
×
323
    end
×
324
end
325

326
const llvm_types =
327
    r"^(?:void|half|float|double|x86_\w+|ppc_\w+|label|metadata|type|opaque|token|i\d+)$"
328
const llvm_cond = r"^(?:[ou]?eq|[ou]?ne|[uso][gl][te]|ord|uno)$" # true|false
329

330
function print_llvm_tokens(io, tokens)
×
331
    m = match(r"^((?:[^\s:]+:)?)(\s*)(.*)", tokens)
×
332
    if m !== nothing
×
333
        label, spaces, tokens = m.captures
×
334
        printstyled_ll(io, label, :label, spaces)
×
335
    end
336
    m = match(r"^(%[^\s=]+)(\s*)=(\s*)(.*)", tokens)
×
337
    if m !== nothing
×
338
        result, spaces, spaces2, tokens = m.captures
×
339
        printstyled_ll(io, result, :variable, spaces)
×
340
        printstyled_ll(io, '=', :default, spaces2)
×
341
    end
342
    m = match(r"^([a-z]\w*)(\s*)(.*)", tokens)
×
343
    if m !== nothing
×
344
        inst, spaces, tokens = m.captures
×
345
        iskeyword = occursin(r"^(?:define|declare|type)$", inst) || occursin("=", tokens)
×
346
        printstyled_ll(io, inst, iskeyword ? :keyword : :instruction, spaces)
×
347
    end
348

349
    print_llvm_operands(io, tokens)
×
350
end
351

352
function print_llvm_operands(io, tokens)
×
353
    while !isempty(tokens)
×
354
        tokens = print_llvm_operand(io, tokens)
×
355
    end
×
356
    return tokens
×
357
end
358

359
function print_llvm_operand(io, tokens)
×
360
    islabel = false
×
361
    while !isempty(tokens)
×
362
        m = match(r"^,(\s*)(.*)", tokens)
×
363
        if m !== nothing
×
364
            spaces, tokens = m.captures
×
365
            printstyled_ll(io, ',', :default, spaces)
×
366
            break
×
367
        end
368
        m = match(r"^(\*+|=)(\s*)(.*)", tokens)
×
369
        if m !== nothing
×
370
            sym, spaces, tokens = m.captures
×
371
            printstyled_ll(io, sym, :default, spaces)
×
372
            continue
×
373
        end
374
        m = match(r"^(\"[^\"]*\")(\s*)(.*)", tokens)
×
375
        if m !== nothing
×
376
            str, spaces, tokens = m.captures
×
377
            printstyled_ll(io, str, :variable, spaces)
×
378
            continue
×
379
        end
380
        m = match(r"^([({\[<])(\s*)(.*)", tokens)
×
381
        if m !== nothing
×
382
            bracket, spaces, tokens = m.captures
×
383
            printstyled_ll(io, bracket, :bracket, spaces)
×
384
            tokens = print_llvm_operands(io, tokens) # enter
×
385
            continue
×
386
        end
387
        m = match(r"^([)}\]>])(\s*)(.*)", tokens)
×
388
        if m !== nothing
×
389
            bracket, spaces, tokens = m.captures
×
390
            printstyled_ll(io, bracket, :bracket, spaces)
×
391
            break # leave
×
392
        end
393

394
        m = match(r"^([^\s,*=(){}\[\]<>]+)(\s*)(.*)", tokens)
×
395
        m === nothing && break
×
396
        token, spaces, tokens = m.captures
×
397
        if occursin(llvm_types, token)
×
398
            printstyled_ll(io, token, :type)
×
399
            islabel = token == "label"
×
400
        elseif occursin(llvm_cond, token) # condition code is instruction-level
×
401
            printstyled_ll(io, token, :instruction)
×
402
        elseif occursin(num_regex, token)
×
403
            printstyled_ll(io, token, :number)
×
404
        elseif occursin(r"^@.+$", token)
×
405
            printstyled_ll(io, token, :funcname)
×
406
        elseif occursin(r"^%.+$", token)
×
407
            islabel |= occursin(r"^%[^\d].*$", token) & occursin(r"^\]", tokens)
×
408
            printstyled_ll(io, token, islabel ? :label : :variable)
×
409
            islabel = false
×
410
        elseif occursin(r"^[a-z]\w+$", token)
×
411
            printstyled_ll(io, token, :keyword)
×
412
        else
413
            printstyled_ll(io, token, :default)
×
414
        end
415
        print(io, spaces)
×
416
    end
×
417
    return tokens
×
418
end
419

420
function print_native(io::IO, code::String, arch::Symbol=sys_arch_category())
×
421
    archv = Val(arch)
×
422
    buf = IOBuffer(code)
×
423
    for line in eachline(buf)
×
424
        m = match(r"^(\s*)((?:[^;#/]|#\S|;\"|/[^/])*)(.*)$", line)
×
425
        m === nothing && continue
×
426
        indent, tokens, comment = m.captures
×
427
        print(io, indent)
×
428
        print_native_tokens(io, tokens, archv)
×
429
        printstyled_ll(io, comment, :comment)
×
430
        println(io)
×
431
    end
×
432
end
433

434
function sys_arch_category()
×
435
    if Sys.ARCH === :x86_64 || Sys.ARCH === :i686
×
436
        :x86
×
437
    elseif Sys.ARCH === :aarch64 || startswith(string(Sys.ARCH), "arm")
×
438
        :arm
×
439
    else
440
        :unsupported
×
441
    end
442
end
443

444
print_native_tokens(io, line, ::Val) = print(io, line)
×
445

446
const x86_ptr = r"^(?:(?:[xyz]mm|[dq])?word|byte|ptr|offset)$"
447
const avx512flags = r"^(?:z|r[nduz]-sae|sae|1to1?\d)$"
448
const arm_cond = r"^(?:eq|ne|cs|ho|cc|lo|mi|pl|vs|vc|hi|ls|[lg][te]|al|nv)$"
449
const arm_keywords = r"^(?:lsl|lsr|asr|ror|rrx|!|/[zm])$"
450

451
function print_native_tokens(io, tokens, arch::Union{Val{:x86}, Val{:arm}})
×
452
    x86 = arch isa Val{:x86}
×
453
    m = match(r"^((?:[^\s:]+:|\"[^\"]+\":)?)(\s*)(.*)", tokens)
×
454
    if m !== nothing
×
455
        label, spaces, tokens = m.captures
×
456
        printstyled_ll(io, label, :label, spaces)
×
457
    end
458
    haslabel = false
×
459
    m = match(r"^([a-z][\w.]*)(\s*)(.*)", tokens)
×
460
    if m !== nothing
×
461
        instruction, spaces, tokens = m.captures
×
462
        printstyled_ll(io, instruction, :instruction, spaces)
×
463
        haslabel = occursin(r"^(?:bl?|bl?\.\w{2,5}|[ct]bn?z)?$", instruction)
×
464
    end
465

466
    isfuncname = false
×
467
    while !isempty(tokens)
×
468
        m = match(r"^([,:*])(\s*)(.*)", tokens)
×
469
        if m !== nothing
×
470
            sym, spaces, tokens = m.captures
×
471
            printstyled_ll(io, sym, :default, spaces)
×
472
            isfuncname = false
×
473
            continue
×
474
        end
475
        m = match(r"^([(){}\[\]])(\s*)(.*)", tokens)
×
476
        if m !== nothing
×
477
            bracket, spaces, tokens = m.captures
×
478
            printstyled_ll(io, bracket, :bracket, spaces)
×
479
            continue
×
480
        end
481
        m = match(r"^#([0-9a-fx.-]+)(\s*)(.*)", tokens)
×
482
        if !x86 && m !== nothing && occursin(num_regex, m.captures[1])
×
483
            num, spaces, tokens = m.captures
×
484
            printstyled_ll(io, "#" * num, :number, spaces)
×
485
            continue
×
486
        end
487

488
        m = match(r"^([^\s,:*(){}\[\]][^\s,:*/(){}\[\]]*)(\s*)(.*)", tokens)
×
489
        m === nothing && break
×
490
        token, spaces, tokens = m.captures
×
491
        if occursin(num_regex, token)
×
492
            printstyled_ll(io, token, :number)
×
493
        elseif x86 && occursin(x86_ptr, token) || occursin(avx512flags, token)
×
494
            printstyled_ll(io, token, :keyword)
×
495
            isfuncname = token == "offset"
×
496
        elseif !x86 && (occursin(arm_keywords, token) || occursin(arm_cond, token))
×
497
            printstyled_ll(io, token, :keyword)
×
498
        elseif occursin(r"^L.+$", token)
×
499
            printstyled_ll(io, token, :label)
×
500
        elseif occursin(r"^\$.+$", token)
×
501
            printstyled_ll(io, token, :funcname)
×
502
        elseif occursin(r"^%?(?:[a-z][\w.]+|\"[^\"]+\")$", token)
×
503
            islabel = haslabel & !occursin(',', tokens)
×
504
            printstyled_ll(io, token, islabel ? :label : isfuncname ? :funcname : :variable)
×
505
            isfuncname = false
×
506
        else
507
            printstyled_ll(io, token, :default)
×
508
        end
509
        print(io, spaces)
×
510
    end
×
511
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc