diff --git a/.travis.yml b/.travis.yml index 048c18197..040ebc9ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ os: julia: - 0.7 - 1.0 + - 1.2 # first version supporting @snoopi - 1.3 - nightly notifications: diff --git a/appveyor.yml b/appveyor.yml index c2588f1d8..55e5cd886 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,8 @@ environment: matrix: - julia_version: 0.7 + - julia_version: 1.0 + - julia_version: 1.2 # first version supporting @snoopi - julia_version: 1 - julia_version: nightly diff --git a/src/SnoopCompile.jl b/src/SnoopCompile.jl index 7a841a077..f50b929e6 100644 --- a/src/SnoopCompile.jl +++ b/src/SnoopCompile.jl @@ -177,7 +177,8 @@ function extract_topmod(e) return :unknown end -const anonrex = r"#{1,2}\d+#{1,2}\d+" # detect anonymous functions +const anonrex = r"#{1,2}\d+#{1,2}\d+" # detect anonymous functions +const kwrex = r"^#kw##(.*)$|#([^#]*)##kw$" # detect keyword-supplying functions function parse_call(line; subst=Vector{Pair{String, String}}(), blacklist=String[]) match(anonrex, line) === nothing || return false, line, :unknown, "" @@ -294,7 +295,17 @@ function parcel(tinf::AbstractVector{Tuple{Float64,Core.MethodInstance}}; subst= ok || continue topmod = topmodule(mods) topmod === nothing && continue - ttrepr = repr(tt) + paramrepr = map(tt.parameters) do p + mkw = match(kwrex, String(p.name.name)) + if mkw !== nothing + fname = mkw.captures[1] === nothing ? mkw.captures[2] : mkw.captures[1] + thismod = p.name.module + "Core.kwftype(typeof($thismod.$fname))" + else + repr(p) + end + end + ttrepr = "Tuple{" * join(paramrepr, ',') * '}' ttexpr = Meta.parse(ttrepr) try Core.eval(topmod, ttexpr) @@ -305,7 +316,7 @@ function parcel(tinf::AbstractVector{Tuple{Float64,Core.MethodInstance}}; subst= if !haskey(pc, topmodname) pc[topmodname] = String[] end - push!(pc[topmodname], "precompile(" * repr(tt) * ')') + push!(pc[topmodname], "precompile(" * ttrepr * ')') end return pc end diff --git a/test/runtests.jl b/test/runtests.jl index 416be7426..5353a5f01 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -42,6 +42,11 @@ if VERSION >= v"1.2.0-DEV.573" directive = pc[:A][1] @test occursin("C.CT", directive) @test !occursin("E.ET", directive) + + # Identify kwfuncs, whose naming depends on the Julia version (issue #46) + tinf = @snoopi sortperm(rand(5); rev=true) + pc = SnoopCompile.parcel(tinf) + @test any(str->occursin("kwftype", str), pc[:Base]) end """)