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

JuliaLang / julia / #37641

03 Oct 2023 08:35PM UTC coverage: 86.293% (-0.06%) from 86.356%
#37641

push

local

web-flow
Revert "Don't mark nonlocal symbols as hidden" (#51571)

72863 of 84437 relevant lines covered (86.29%)

12901453.46 hits per line

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

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

161
using Base: CodegenParams
162

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

170
# Printing code representations in IR and assembly
171

172
function _dump_function(@nospecialize(f), @nospecialize(t), native::Bool, wrapper::Bool,
71✔
173
                        raw::Bool, dump_module::Bool, syntax::Symbol,
174
                        optimize::Bool, debuginfo::Symbol, binary::Bool,
175
                        params::CodegenParams=CodegenParams(debug_info_kind=Cint(0), safepoint_on_entry=raw, gcstack_arg=raw))
176
    ccall(:jl_is_in_pure_context, Bool, ()) && error("code reflection cannot be used from generated functions")
71✔
177
    if isa(f, Core.Builtin)
66✔
178
        throw(ArgumentError("argument is not a generic function"))
×
179
    end
180
    warning = ""
66✔
181
    # get the MethodInstance for the method match
182
    if !isa(f, Core.OpaqueClosure)
66✔
183
        world = Base.get_world_counter()
64✔
184
        match = Base._which(signature_type(f, t); world)
64✔
185
        mi = Core.Compiler.specialize_method(match)
64✔
186
        # TODO: use jl_is_cacheable_sig instead of isdispatchtuple
187
        isdispatchtuple(mi.specTypes) || (warning = GENERIC_SIG_WARNING)
64✔
188
    else
189
        world = UInt64(f.world)
2✔
190
        tt = Base.to_tuple_type(t)
2✔
191
        if Core.Compiler.is_source_inferred(f.source.source)
2✔
192
            # OC was constructed from inferred source. There's only one
193
            # specialization and we can't infer anything more precise either.
194
            world = f.source.primary_world
2✔
195
            mi = f.source.specializations::Core.MethodInstance
2✔
196
            Core.Compiler.hasintersect(typeof(f).parameters[1], tt) || (warning = OC_MISMATCH_WARNING)
2✔
197
        else
198
            mi = Core.Compiler.specialize_method(f.source, Tuple{typeof(f.captures), tt.parameters...}, Core.svec())
×
199
            actual = isdispatchtuple(mi.specTypes)
×
200
            isdispatchtuple(mi.specTypes) || (warning = GENERIC_SIG_WARNING)
×
201
        end
202
    end
203
    # get the code for it
204
    if debuginfo === :default
66✔
205
        debuginfo = :source
27✔
206
    elseif debuginfo !== :source && debuginfo !== :none
39✔
207
        throw(ArgumentError("'debuginfo' must be either :source or :none"))
×
208
    end
209
    if native
66✔
210
        if syntax !== :att && syntax !== :intel
×
211
            throw(ArgumentError("'syntax' must be either :intel or :att"))
×
212
        end
213
        if dump_module
×
214
            # we want module metadata, so use LLVM to generate assembly output
215
            str = _dump_function_native_assembly(mi, world, wrapper, syntax, debuginfo, binary, raw, params)
×
216
        else
217
            # if we don't want the module metadata, just disassemble what our JIT has
218
            str = _dump_function_native_disassembly(mi, world, wrapper, syntax, debuginfo, binary)
×
219
        end
220
    else
221
        str = _dump_function_llvm(mi, world, wrapper, !raw, dump_module, optimize, debuginfo, params)
66✔
222
    end
223
    str = warning * str
66✔
224
    return str
66✔
225
end
226

227
function _dump_function_native_disassembly(mi::Core.MethodInstance, world::UInt,
×
228
                                           wrapper::Bool, syntax::Symbol,
229
                                           debuginfo::Symbol, binary::Bool)
230
    str = @ccall jl_dump_method_asm(mi::Any, world::UInt, false::Bool, wrapper::Bool,
×
231
                                    syntax::Ptr{UInt8}, debuginfo::Ptr{UInt8},
232
                                    binary::Bool)::Ref{String}
233
    return str
×
234
end
235

236
struct LLVMFDump
237
    tsm::Ptr{Cvoid} # opaque
238
    f::Ptr{Cvoid} # opaque
239
end
240

241
function _dump_function_native_assembly(mi::Core.MethodInstance, world::UInt,
×
242
                                        wrapper::Bool, syntax::Symbol, debuginfo::Symbol,
243
                                        binary::Bool, raw::Bool, params::CodegenParams)
244
    llvmf_dump = Ref{LLVMFDump}()
×
245
    @ccall jl_get_llvmf_defn(llvmf_dump::Ptr{LLVMFDump},mi::Any, world::UInt, wrapper::Bool,
×
246
                             true::Bool, params::CodegenParams)::Cvoid
247
    llvmf_dump[].f == C_NULL && error("could not compile the specified method")
×
248
    str = @ccall jl_dump_function_asm(llvmf_dump::Ptr{LLVMFDump}, false::Bool,
×
249
                                      syntax::Ptr{UInt8}, debuginfo::Ptr{UInt8},
250
                                      binary::Bool, raw::Bool)::Ref{String}
251
    return str
×
252
end
253

254
function _dump_function_llvm(
66✔
255
        mi::Core.MethodInstance, world::UInt, wrapper::Bool,
256
        strip_ir_metadata::Bool, dump_module::Bool,
257
        optimize::Bool, debuginfo::Symbol,
258
        params::CodegenParams)
259
    llvmf_dump = Ref{LLVMFDump}()
66✔
260
    @ccall jl_get_llvmf_defn(llvmf_dump::Ptr{LLVMFDump}, mi::Any, world::UInt,
66✔
261
                             wrapper::Bool, optimize::Bool, params::CodegenParams)::Cvoid
262
    llvmf_dump[].f == C_NULL && error("could not compile the specified method")
66✔
263
    str = @ccall jl_dump_function_ir(llvmf_dump::Ptr{LLVMFDump}, strip_ir_metadata::Bool,
66✔
264
                                     dump_module::Bool, debuginfo::Ptr{UInt8})::Ref{String}
265
    return str
66✔
266
end
267

268
"""
269
    code_llvm([io=stdout,], f, types; raw=false, dump_module=false, optimize=true, debuginfo=:default)
270

271
Prints the LLVM bitcodes generated for running the method matching the given generic
272
function and type signature to `io`.
273

274
If the `optimize` keyword is unset, the code will be shown before LLVM optimizations.
275
All metadata and dbg.* calls are removed from the printed bitcode. For the full IR, set the `raw` keyword to true.
276
To dump the entire module that encapsulates the function (with declarations), set the `dump_module` keyword to true.
277
Keyword argument `debuginfo` may be one of source (default) or none, to specify the verbosity of code comments.
278

279
See also: [`@code_llvm`](@ref), [`code_warntype`](@ref), [`code_typed`](@ref), [`code_lowered`](@ref), [`code_native`](@ref).
280
"""
281
function code_llvm(io::IO, @nospecialize(f), @nospecialize(types=Base.default_tt(f));
60✔
282
                   raw::Bool=false, dump_module::Bool=false, optimize::Bool=true, debuginfo::Symbol=:default,
283
                   params::CodegenParams=CodegenParams(debug_info_kind=Cint(0), safepoint_on_entry=raw, gcstack_arg=raw))
284
    d = _dump_function(f, types, false, false, raw, dump_module, :intel, optimize, debuginfo, false, params)
30✔
285
    if highlighting[:llvm] && get(io, :color, false)::Bool
28✔
286
        print_llvm(io, d)
×
287
    else
288
        print(io, d)
28✔
289
    end
290
end
291
code_llvm(args...; kwargs...) = (@nospecialize; code_llvm(stdout, args...; kwargs...))
6✔
292

293
"""
294
    code_native([io=stdout,], f, types; syntax=:intel, debuginfo=:default, binary=false, dump_module=true)
295

296
Prints the native assembly instructions generated for running the method matching the given
297
generic function and type signature to `io`.
298

299
* Set assembly syntax by setting `syntax` to `:intel` (default) for intel syntax or `:att` for AT&T syntax.
300
* Specify verbosity of code comments by setting `debuginfo` to `:source` (default) or `:none`.
301
* If `binary` is `true`, also print the binary machine code for each instruction precedented by an abbreviated address.
302
* If `dump_module` is `false`, do not print metadata such as rodata or directives.
303
* If `raw` is `false`, uninteresting instructions (like the safepoint function prologue) are elided.
304

305
See also: [`@code_native`](@ref), [`code_warntype`](@ref), [`code_typed`](@ref), [`code_lowered`](@ref), [`code_llvm`](@ref).
306
"""
307
function code_native(io::IO, @nospecialize(f), @nospecialize(types=Base.default_tt(f));
4✔
308
                     dump_module::Bool=true, syntax::Symbol=:intel, raw::Bool=false,
309
                     debuginfo::Symbol=:default, binary::Bool=false,
310
                     params::CodegenParams=CodegenParams(debug_info_kind=Cint(0), safepoint_on_entry=raw, gcstack_arg=raw))
311
    d = _dump_function(f, types, true, false, raw, dump_module, syntax, true, debuginfo, binary, params)
2✔
312
    if highlighting[:native] && get(io, :color, false)::Bool
×
313
        print_native(io, d)
×
314
    else
315
        print(io, d)
×
316
    end
317
end
318
code_native(args...; kwargs...) = (@nospecialize; code_native(stdout, args...; kwargs...))
4✔
319

320
## colorized IR and assembly printing
321

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

324
function print_llvm(io::IO, code::String)
×
325
    buf = IOBuffer(code)
×
326
    for line in eachline(buf)
×
327
        m = match(r"^(\s*)((?:[^;]|;\")*)(.*)$", line)
×
328
        m === nothing && continue
×
329
        indent, tokens, comment = m.captures
×
330
        print(io, indent)
×
331
        print_llvm_tokens(io, tokens)
×
332
        printstyled_ll(io, comment, :comment)
×
333
        println(io)
×
334
    end
×
335
end
336

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

341
function print_llvm_tokens(io, tokens)
×
342
    m = match(r"^((?:[^\s:]+:)?)(\s*)(.*)", tokens)
×
343
    if m !== nothing
×
344
        label, spaces, tokens = m.captures
×
345
        printstyled_ll(io, label, :label, spaces)
×
346
    end
347
    m = match(r"^(%[^\s=]+)(\s*)=(\s*)(.*)", tokens)
×
348
    if m !== nothing
×
349
        result, spaces, spaces2, tokens = m.captures
×
350
        printstyled_ll(io, result, :variable, spaces)
×
351
        printstyled_ll(io, '=', :default, spaces2)
×
352
    end
353
    m = match(r"^([a-z]\w*)(\s*)(.*)", tokens)
×
354
    if m !== nothing
×
355
        inst, spaces, tokens = m.captures
×
356
        iskeyword = occursin(r"^(?:define|declare|type)$", inst) || occursin("=", tokens)
×
357
        printstyled_ll(io, inst, iskeyword ? :keyword : :instruction, spaces)
×
358
    end
359

360
    print_llvm_operands(io, tokens)
×
361
end
362

363
function print_llvm_operands(io, tokens)
×
364
    while !isempty(tokens)
×
365
        tokens = print_llvm_operand(io, tokens)
×
366
    end
×
367
    return tokens
×
368
end
369

370
function print_llvm_operand(io, tokens)
×
371
    islabel = false
×
372
    while !isempty(tokens)
×
373
        m = match(r"^,(\s*)(.*)", tokens)
×
374
        if m !== nothing
×
375
            spaces, tokens = m.captures
×
376
            printstyled_ll(io, ',', :default, spaces)
×
377
            break
×
378
        end
379
        m = match(r"^(\*+|=)(\s*)(.*)", tokens)
×
380
        if m !== nothing
×
381
            sym, spaces, tokens = m.captures
×
382
            printstyled_ll(io, sym, :default, spaces)
×
383
            continue
×
384
        end
385
        m = match(r"^(\"[^\"]*\")(\s*)(.*)", tokens)
×
386
        if m !== nothing
×
387
            str, spaces, tokens = m.captures
×
388
            printstyled_ll(io, str, :variable, spaces)
×
389
            continue
×
390
        end
391
        m = match(r"^([({\[<])(\s*)(.*)", tokens)
×
392
        if m !== nothing
×
393
            bracket, spaces, tokens = m.captures
×
394
            printstyled_ll(io, bracket, :bracket, spaces)
×
395
            tokens = print_llvm_operands(io, tokens) # enter
×
396
            continue
×
397
        end
398
        m = match(r"^([)}\]>])(\s*)(.*)", tokens)
×
399
        if m !== nothing
×
400
            bracket, spaces, tokens = m.captures
×
401
            printstyled_ll(io, bracket, :bracket, spaces)
×
402
            break # leave
×
403
        end
404

405
        m = match(r"^([^\s,*=(){}\[\]<>]+)(\s*)(.*)", tokens)
×
406
        m === nothing && break
×
407
        token, spaces, tokens = m.captures
×
408
        if occursin(llvm_types, token)
×
409
            printstyled_ll(io, token, :type)
×
410
            islabel = token == "label"
×
411
        elseif occursin(llvm_cond, token) # condition code is instruction-level
×
412
            printstyled_ll(io, token, :instruction)
×
413
        elseif occursin(num_regex, token)
×
414
            printstyled_ll(io, token, :number)
×
415
        elseif occursin(r"^@.+$", token)
×
416
            printstyled_ll(io, token, :funcname)
×
417
        elseif occursin(r"^%.+$", token)
×
418
            islabel |= occursin(r"^%[^\d].*$", token) & occursin(r"^\]", tokens)
×
419
            printstyled_ll(io, token, islabel ? :label : :variable)
×
420
            islabel = false
×
421
        elseif occursin(r"^[a-z]\w+$", token)
×
422
            printstyled_ll(io, token, :keyword)
×
423
        else
424
            printstyled_ll(io, token, :default)
×
425
        end
426
        print(io, spaces)
×
427
    end
×
428
    return tokens
×
429
end
430

431
function print_native(io::IO, code::String, arch::Symbol=sys_arch_category())
×
432
    archv = Val(arch)
×
433
    buf = IOBuffer(code)
×
434
    for line in eachline(buf)
×
435
        m = match(r"^(\s*)((?:[^;#/]|#\S|;\"|/[^/])*)(.*)$", line)
×
436
        m === nothing && continue
×
437
        indent, tokens, comment = m.captures
×
438
        print(io, indent)
×
439
        print_native_tokens(io, tokens, archv)
×
440
        printstyled_ll(io, comment, :comment)
×
441
        println(io)
×
442
    end
×
443
end
444

445
function sys_arch_category()
×
446
    if Sys.ARCH === :x86_64 || Sys.ARCH === :i686
×
447
        :x86
×
448
    elseif Sys.ARCH === :aarch64 || startswith(string(Sys.ARCH), "arm")
×
449
        :arm
×
450
    else
451
        :unsupported
×
452
    end
453
end
454

455
print_native_tokens(io, line, ::Val) = print(io, line)
×
456

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

462
function print_native_tokens(io, tokens, arch::Union{Val{:x86}, Val{:arm}})
×
463
    x86 = arch isa Val{:x86}
×
464
    m = match(r"^((?:[^\s:]+:|\"[^\"]+\":)?)(\s*)(.*)", tokens)
×
465
    if m !== nothing
×
466
        label, spaces, tokens = m.captures
×
467
        printstyled_ll(io, label, :label, spaces)
×
468
    end
469
    haslabel = false
×
470
    m = match(r"^([a-z][\w.]*)(\s*)(.*)", tokens)
×
471
    if m !== nothing
×
472
        instruction, spaces, tokens = m.captures
×
473
        printstyled_ll(io, instruction, :instruction, spaces)
×
474
        haslabel = occursin(r"^(?:bl?|bl?\.\w{2,5}|[ct]bn?z)?$", instruction)
×
475
    end
476

477
    isfuncname = false
×
478
    while !isempty(tokens)
×
479
        m = match(r"^([,:*])(\s*)(.*)", tokens)
×
480
        if m !== nothing
×
481
            sym, spaces, tokens = m.captures
×
482
            printstyled_ll(io, sym, :default, spaces)
×
483
            isfuncname = false
×
484
            continue
×
485
        end
486
        m = match(r"^([(){}\[\]])(\s*)(.*)", tokens)
×
487
        if m !== nothing
×
488
            bracket, spaces, tokens = m.captures
×
489
            printstyled_ll(io, bracket, :bracket, spaces)
×
490
            continue
×
491
        end
492
        m = match(r"^#([0-9a-fx.-]+)(\s*)(.*)", tokens)
×
493
        if !x86 && m !== nothing && occursin(num_regex, m.captures[1])
×
494
            num, spaces, tokens = m.captures
×
495
            printstyled_ll(io, "#" * num, :number, spaces)
×
496
            continue
×
497
        end
498

499
        m = match(r"^([^\s,:*(){}\[\]][^\s,:*/(){}\[\]]*)(\s*)(.*)", tokens)
×
500
        m === nothing && break
×
501
        token, spaces, tokens = m.captures
×
502
        if occursin(num_regex, token)
×
503
            printstyled_ll(io, token, :number)
×
504
        elseif x86 && occursin(x86_ptr, token) || occursin(avx512flags, token)
×
505
            printstyled_ll(io, token, :keyword)
×
506
            isfuncname = token == "offset"
×
507
        elseif !x86 && (occursin(arm_keywords, token) || occursin(arm_cond, token))
×
508
            printstyled_ll(io, token, :keyword)
×
509
        elseif occursin(r"^L.+$", token)
×
510
            printstyled_ll(io, token, :label)
×
511
        elseif occursin(r"^\$.+$", token)
×
512
            printstyled_ll(io, token, :funcname)
×
513
        elseif occursin(r"^%?(?:[a-z][\w.]+|\"[^\"]+\")$", token)
×
514
            islabel = haslabel & !occursin(',', tokens)
×
515
            printstyled_ll(io, token, islabel ? :label : isfuncname ? :funcname : :variable)
×
516
            isfuncname = false
×
517
        else
518
            printstyled_ll(io, token, :default)
×
519
        end
520
        print(io, spaces)
×
521
    end
×
522
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