|
| 1 | +const __bodyfunction__ = Dict{Method,Any}() |
| 2 | + |
| 3 | +# Find keyword "body functions" (the function that contains the body |
| 4 | +# as written by the developer, called after all missing keyword-arguments |
| 5 | +# have been assigned values), in a manner that doesn't depend on |
| 6 | +# gensymmed names. |
| 7 | +# `mnokw` is the method that gets called when you invoke it without |
| 8 | +# supplying any keywords. |
| 9 | +function __lookup_kwbody__(mnokw::Method) |
| 10 | + function getsym(arg) |
| 11 | + isa(arg, Symbol) && return arg |
| 12 | + @assert isa(arg, GlobalRef) |
| 13 | + return arg.name |
| 14 | + end |
| 15 | + |
| 16 | + f = get(__bodyfunction__, mnokw, nothing) |
| 17 | + if f === nothing |
| 18 | + fmod = mnokw.module |
| 19 | + # The lowered code for `mnokw` should look like |
| 20 | + # %1 = mkw(kwvalues..., #self#, args...) |
| 21 | + # return %1 |
| 22 | + # where `mkw` is the name of the "active" keyword body-function. |
| 23 | + ast = Base.uncompressed_ast(mnokw) |
| 24 | + if isa(ast, Core.CodeInfo) && length(ast.code) >= 2 |
| 25 | + callexpr = ast.code[end-1] |
| 26 | + if isa(callexpr, Expr) && callexpr.head == :call |
| 27 | + fsym = callexpr.args[1] |
| 28 | + if isa(fsym, Symbol) |
| 29 | + f = getfield(fmod, fsym) |
| 30 | + elseif isa(fsym, GlobalRef) |
| 31 | + if fsym.mod === Core && fsym.name === :_apply |
| 32 | + f = getfield(mnokw.module, getsym(callexpr.args[2])) |
| 33 | + elseif fsym.mod === Core && fsym.name === :_apply_iterate |
| 34 | + f = getfield(mnokw.module, getsym(callexpr.args[3])) |
| 35 | + else |
| 36 | + f = getfield(fsym.mod, fsym.name) |
| 37 | + end |
| 38 | + else |
| 39 | + f = missing |
| 40 | + end |
| 41 | + else |
| 42 | + f = missing |
| 43 | + end |
| 44 | + else |
| 45 | + f = missing |
| 46 | + end |
| 47 | + __bodyfunction__[mnokw] = f |
| 48 | + end |
| 49 | + return f |
| 50 | +end |
| 51 | + |
1 | 52 | function _precompile_()
|
2 | 53 | ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
|
3 |
| - isdefined(MatLang, Symbol("##sortperm#31")) && precompile(Tuple{getfield(MatLang, Symbol("##sortperm#31")),Int64,Bool,typeof(sortperm),Array{Int64,2}}) |
4 | 54 | isdefined(MatLang, Symbol("#32#33")) && precompile(Tuple{getfield(MatLang, Symbol("#32#33")),Array{Int64,1}})
|
| 55 | + let fbody = try __lookup_kwbody__(which(sortperm, (Array{Int64,2},))) catch missing end |
| 56 | + if !ismissing(fbody) |
| 57 | + precompile(fbody, (Int64,Bool,typeof(sortperm),Array{Int64,2},)) |
| 58 | + end |
| 59 | + end |
5 | 60 | precompile(Tuple{Core.kwftype(typeof(MatLang.eyeM)),NamedTuple{(:like,),Tuple{Array{Int8,2}}},typeof(eyeM),Int64,Int64})
|
6 | 61 | precompile(Tuple{Core.kwftype(typeof(MatLang.freqspaceM)),NamedTuple{(:dim,),Tuple{Int64}},typeof(freqspaceM),Int64})
|
7 | 62 | precompile(Tuple{Core.kwftype(typeof(MatLang.ndgridM)),NamedTuple{(:dim,),Tuple{Int64}},typeof(ndgridM),StepRange{Int64,Int64}})
|
@@ -29,9 +84,9 @@ function _precompile_()
|
29 | 84 | precompile(Tuple{typeof(eyeM),Int64,Int64})
|
30 | 85 | precompile(Tuple{typeof(eyeM),Int64})
|
31 | 86 | precompile(Tuple{typeof(eyeM),Tuple{Int64,Int64}})
|
32 |
| - precompile(Tuple{typeof(eyeM),Type,Array{Int64,1}}) |
33 |
| - precompile(Tuple{typeof(eyeM),Type,Int64,Int64}) |
34 |
| - precompile(Tuple{typeof(eyeM),Type,Tuple{Int64,Int64}}) |
| 87 | + precompile(Tuple{typeof(eyeM),Type{T} where T,Array{Int64,1}}) |
| 88 | + precompile(Tuple{typeof(eyeM),Type{T} where T,Int64,Int64}) |
| 89 | + precompile(Tuple{typeof(eyeM),Type{T} where T,Tuple{Int64,Int64}}) |
35 | 90 | precompile(Tuple{typeof(falseM),Array{Int64,1}})
|
36 | 91 | precompile(Tuple{typeof(falseM),Int64})
|
37 | 92 | precompile(Tuple{typeof(falseM),Symbol,Int64})
|
@@ -131,16 +186,16 @@ function _precompile_()
|
131 | 186 | precompile(Tuple{typeof(onesM),Int64})
|
132 | 187 | precompile(Tuple{typeof(onesM),Symbol,Int64})
|
133 | 188 | precompile(Tuple{typeof(onesM),Tuple{Int64,Int64}})
|
134 |
| - precompile(Tuple{typeof(onesM),Type,Int64,Int64}) |
135 |
| - precompile(Tuple{typeof(onesM),Type,Tuple{Int64,Int64}}) |
136 | 189 | precompile(Tuple{typeof(onesM),Type{Int32},Array{Int64,1}})
|
| 190 | + precompile(Tuple{typeof(onesM),Type{T} where T,Int64,Int64}) |
| 191 | + precompile(Tuple{typeof(onesM),Type{T} where T,Tuple{Int64,Int64}}) |
137 | 192 | precompile(Tuple{typeof(randM),Array{Int64,1}})
|
138 | 193 | precompile(Tuple{typeof(randM),Int64})
|
139 | 194 | precompile(Tuple{typeof(randM),Symbol,Int64})
|
140 | 195 | precompile(Tuple{typeof(randM),Tuple{Int64,Int64}})
|
141 |
| - precompile(Tuple{typeof(randM),Type,Int64,Int64}) |
142 |
| - precompile(Tuple{typeof(randM),Type,Tuple{Int64,Int64}}) |
143 | 196 | precompile(Tuple{typeof(randM),Type{Int32},Array{Int64,1}})
|
| 197 | + precompile(Tuple{typeof(randM),Type{T} where T,Int64,Int64}) |
| 198 | + precompile(Tuple{typeof(randM),Type{T} where T,Tuple{Int64,Int64}}) |
144 | 199 | precompile(Tuple{typeof(repelemM),Array{Int64,2},Int64})
|
145 | 200 | precompile(Tuple{typeof(repmatM),Array{Int64,1},Array{Int64,1}})
|
146 | 201 | precompile(Tuple{typeof(repmatM),Array{Int64,1},Int64,Int64})
|
@@ -171,8 +226,8 @@ function _precompile_()
|
171 | 226 | precompile(Tuple{typeof(zerosM),Int64})
|
172 | 227 | precompile(Tuple{typeof(zerosM),Symbol,Int64})
|
173 | 228 | precompile(Tuple{typeof(zerosM),Tuple{Int64,Int64}})
|
174 |
| - precompile(Tuple{typeof(zerosM),Type,Int64,Int64,Int64}) |
175 |
| - precompile(Tuple{typeof(zerosM),Type,Int64,Int64}) |
176 |
| - precompile(Tuple{typeof(zerosM),Type,Tuple{Int64,Int64}}) |
177 | 229 | precompile(Tuple{typeof(zerosM),Type{Int32},Array{Int64,1}})
|
| 230 | + precompile(Tuple{typeof(zerosM),Type{T} where T,Int64,Int64,Int64}) |
| 231 | + precompile(Tuple{typeof(zerosM),Type{T} where T,Int64,Int64}) |
| 232 | + precompile(Tuple{typeof(zerosM),Type{T} where T,Tuple{Int64,Int64}}) |
178 | 233 | end
|
0 commit comments