@@ -105,10 +105,24 @@ isgeneric(f::ANY) = (isa(f,Function) && isa(f.env,MethodTable))
105
105
106
106
function_name (f:: Function ) = isgeneric (f) ? f. env. name : (:anonymous )
107
107
108
+ function to_tuple_type (t:: ANY )
109
+ if isa (t,Tuple) || isa (t,AbstractArray) || isa (t,SimpleVector)
110
+ t = Tuple{t... }
111
+ end
112
+ if isa (t,Type) && t<: Tuple
113
+ if ! all (p-> (isa (p,Type)|| isa (p,TypeVar)), t. parameters)
114
+ error (" argument tuple type must contain only types" )
115
+ end
116
+ else
117
+ error (" expected tuple type" )
118
+ end
119
+ t
120
+ end
121
+
108
122
tt_cons (t:: ANY , tup:: ANY ) = Tuple{t, (isa (tup, Type) ? tup. parameters : tup). .. }
109
123
110
124
code_lowered (f, t:: ANY ) = map (m-> uncompressed_ast (m. func. code), methods (f, t))
111
- methods (f:: Function ,t:: ANY ) = Any[m[3 ] for m in _methods (f,t,- 1 )]
125
+ methods (f:: Function ,t:: ANY ) = (t = to_tuple_type (t); Any[m[3 ] for m in _methods (f,t,- 1 )])
112
126
methods (f:: ANY ,t:: ANY ) = methods (call, tt_cons (isa (f,Type) ? Type{f} : typeof (f), t))
113
127
function _methods (f:: ANY ,t:: ANY ,lim)
114
128
if isa (t,Type)
@@ -170,9 +184,8 @@ uncompressed_ast(l::LambdaStaticData) =
170
184
isa (l. ast,Expr) ? l. ast : ccall (:jl_uncompress_ast , Any, (Any,Any), l, l. ast)
171
185
172
186
# Printing code representations in IR and assembly
173
- _dump_function (f, t:: Tuple{Vararg{Type}} , native, wrapper, strip_ir_metadata) =
174
- _dump_function (f, Tuple{t... }, native, wrapper, strip_ir_metadata)
175
187
function _dump_function (f, t:: ANY , native, wrapper, strip_ir_metadata)
188
+ t = to_tuple_type (t)
176
189
llvmf = ccall (:jl_get_llvmf , Ptr{Void}, (Any, Any, Bool), f, t, wrapper)
177
190
178
191
if llvmf == C_NULL
@@ -183,7 +196,7 @@ function _dump_function(f, t::ANY, native, wrapper, strip_ir_metadata)
183
196
str = ccall (:jl_dump_function_asm , Any, (Ptr{Void},), llvmf):: ByteString
184
197
else
185
198
str = ccall (:jl_dump_function_ir , Any,
186
- (Ptr{Void}, Bool), llvmf, strip_ir_metadata):: ByteString
199
+ (Ptr{Void}, Bool), llvmf, strip_ir_metadata):: ByteString
187
200
end
188
201
189
202
return str
@@ -208,8 +221,8 @@ if isdefined(Core, :Inference) && not_int(is(current_module(), Core.Inference))
208
221
return_types (args... ;kwargs... ) = Core. Inference. return_types (args... ;kwargs... )
209
222
end
210
223
211
- which (f:: ANY , t:: Tuple{Vararg{Type}} ) = which (f, Tuple{t... })
212
224
function which (f:: ANY , t:: ANY )
225
+ t = to_tuple_type (t)
213
226
if isleaftype (t)
214
227
ms = methods (f, t)
215
228
isempty (ms) && error (" no method found for the specified argument types" )
0 commit comments