@@ -237,7 +237,7 @@ tupletype_tail(t::ANY, n) = Tuple{t.parameters[n:end]...}
237
237
238
238
# ### type-functions for builtins / intrinsics ####
239
239
240
- cmp_tfunc = (sv ,x,y)-> Bool
240
+ cmp_tfunc = (params ,x,y)-> Bool
241
241
242
242
isType (t:: ANY ) = isa (t,DataType) && is ((t:: DataType ). name,Type. name)
243
243
@@ -253,8 +253,8 @@ function add_tfunc(f::Function, minarg::Int, maxarg::Int, tfunc::ANY)
253
253
push! (t_ffunc_key, f)
254
254
push! (t_ffunc_val, (minarg, maxarg, tfunc))
255
255
end
256
- add_tfunc (throw, 1 , 1 , (sv ,x)-> Bottom)
257
- add_tfunc (box, 2 , 2 , (sv ,t,v)-> (isType (t) ? t. parameters[1 ] : Any))
256
+ add_tfunc (throw, 1 , 1 , (params ,x)-> Bottom)
257
+ add_tfunc (box, 2 , 2 , (params ,t,v)-> (isType (t) ? t. parameters[1 ] : Any))
258
258
add_tfunc (eq_int, 2 , 2 , cmp_tfunc)
259
259
add_tfunc (ne_int, 2 , 2 , cmp_tfunc)
260
260
add_tfunc (slt_int, 2 , 2 , cmp_tfunc)
@@ -268,7 +268,7 @@ add_tfunc(le_float, 2, 2, cmp_tfunc)
268
268
add_tfunc (fpiseq, 2 , 2 , cmp_tfunc)
269
269
add_tfunc (fpislt, 2 , 2 , cmp_tfunc)
270
270
add_tfunc (Core. Intrinsics. ccall, 3 , IInf,
271
- function (sv , fptr, rt, at, a... )
271
+ function (params , fptr, rt, at, a... )
272
272
if ! isType (rt)
273
273
return Any
274
274
end
@@ -283,12 +283,12 @@ add_tfunc(Core.Intrinsics.ccall, 3, IInf,
283
283
return t
284
284
end )
285
285
add_tfunc (Core. Intrinsics. llvmcall, 3 , IInf,
286
- (sv , fptr, rt, at, a... )-> (isType (rt) ? rt. parameters[1 ] : Any))
286
+ (params , fptr, rt, at, a... )-> (isType (rt) ? rt. parameters[1 ] : Any))
287
287
add_tfunc (Core. Intrinsics. cglobal, 1 , 2 ,
288
- (sv , fptr, t... )-> (isempty (t) ? Ptr{Void} :
288
+ (params , fptr, t... )-> (isempty (t) ? Ptr{Void} :
289
289
isType (t[1 ]) ? Ptr{t[1 ]. parameters[1 ]} : Ptr))
290
290
add_tfunc (Core. Intrinsics. select_value, 3 , 3 ,
291
- function (sv , cnd, x, y)
291
+ function (params , cnd, x, y)
292
292
if isa (cnd, Const)
293
293
if cnd. val === true
294
294
return x
@@ -302,7 +302,7 @@ add_tfunc(Core.Intrinsics.select_value, 3, 3,
302
302
tmerge (x, y)
303
303
end )
304
304
add_tfunc (is, 2 , 2 ,
305
- function (sv , x:: ANY , y:: ANY )
305
+ function (params , x:: ANY , y:: ANY )
306
306
if isa (x,Const) && isa (y,Const)
307
307
return Const (x. val=== y. val)
308
308
elseif isType (x) && isType (y) && isleaftype (x) && isleaftype (y)
@@ -316,23 +316,23 @@ add_tfunc(is, 2, 2,
316
316
return Bool
317
317
end
318
318
end )
319
- add_tfunc (isdefined, 1 , IInf, (sv , args... )-> Bool)
320
- add_tfunc (Core. sizeof, 1 , 1 , (sv ,x)-> Int)
321
- add_tfunc (nfields, 1 , 1 , (sv ,x)-> (isa (x,Const) ? Const (nfields (x. val)) :
319
+ add_tfunc (isdefined, 1 , IInf, (params , args... )-> Bool)
320
+ add_tfunc (Core. sizeof, 1 , 1 , (params ,x)-> Int)
321
+ add_tfunc (nfields, 1 , 1 , (params ,x)-> (isa (x,Const) ? Const (nfields (x. val)) :
322
322
isType (x) && isleaftype (x. parameters[1 ]) ? Const (nfields (x. parameters[1 ])) :
323
323
Int))
324
- add_tfunc (Core. _expr, 1 , IInf, (sv , args... )-> Expr)
325
- add_tfunc (applicable, 1 , IInf, (sv , f, args... )-> Bool)
326
- add_tfunc (Core. Intrinsics. arraylen, 1 , 1 , (sv ,x)-> Int)
327
- add_tfunc (arraysize, 2 , 2 , (sv ,a,d)-> Int)
324
+ add_tfunc (Core. _expr, 1 , IInf, (params , args... )-> Expr)
325
+ add_tfunc (applicable, 1 , IInf, (params , f, args... )-> Bool)
326
+ add_tfunc (Core. Intrinsics. arraylen, 1 , 1 , (params ,x)-> Int)
327
+ add_tfunc (arraysize, 2 , 2 , (params ,a,d)-> Int)
328
328
add_tfunc (pointerref, 3 , 3 ,
329
- function (sv ,a,i,align)
329
+ function (params ,a,i,align)
330
330
a = widenconst (a)
331
331
isa (a,DataType) && a<: Ptr && isa (a. parameters[1 ],Union{Type,TypeVar}) ? a. parameters[1 ] : Any
332
332
end )
333
- add_tfunc (pointerset, 4 , 4 , (sv ,a,v,i,align)-> a)
333
+ add_tfunc (pointerset, 4 , 4 , (params ,a,v,i,align)-> a)
334
334
335
- function typeof_tfunc (sv , t:: ANY )
335
+ function typeof_tfunc (params , t:: ANY )
336
336
if isa (t,Const)
337
337
return Type{typeof (t. val)}
338
338
elseif isType (t)
@@ -351,7 +351,7 @@ function typeof_tfunc(sv, t::ANY)
351
351
Type{TypeVar (:_ ,t)}
352
352
end
353
353
elseif isa (t,Union)
354
- Union{map (t -> typeof_tfunc (sv ,t), t. types)... }
354
+ Union{map (t -> typeof_tfunc (params ,t), t. types)... }
355
355
elseif isa (t,TypeVar) && ! (Any <: t.ub )
356
356
Type{t}
357
357
else
@@ -360,7 +360,7 @@ function typeof_tfunc(sv, t::ANY)
360
360
end
361
361
add_tfunc (typeof, 1 , 1 , typeof_tfunc)
362
362
add_tfunc (typeassert, 2 , 2 ,
363
- function (sv , v, t)
363
+ function (params , v, t)
364
364
if isType (t)
365
365
if isa (v,Const)
366
366
if isleaftype (t) && ! isa (v. val, t. parameters[1 ])
@@ -373,7 +373,7 @@ add_tfunc(typeassert, 2, 2,
373
373
return v
374
374
end )
375
375
add_tfunc (isa, 2 , 2 ,
376
- function (sv , v, t)
376
+ function (params , v, t)
377
377
if isType (t) && isleaftype (t)
378
378
if v ⊑ t. parameters[1 ]
379
379
return Const (true )
@@ -384,7 +384,7 @@ add_tfunc(isa, 2, 2,
384
384
return Bool
385
385
end )
386
386
add_tfunc (issubtype, 2 , 2 ,
387
- function (sv , a, b)
387
+ function (params , a, b)
388
388
if isType (a) && isType (b) && isleaftype (a) && isleaftype (b)
389
389
return Const (issubtype (a. parameters[1 ], b. parameters[1 ]))
390
390
end
@@ -401,26 +401,26 @@ function type_depth(t::ANY)
401
401
return 0
402
402
end
403
403
404
- function limit_type_depth (t:: ANY , d:: Int , cov:: Bool , vars, sv :: InferenceState )
404
+ function limit_type_depth (t:: ANY , d:: Int , cov:: Bool , vars, params :: InferenceParams )
405
405
if isa (t,TypeVar) || isa (t,TypeConstructor)
406
406
return t
407
407
end
408
- inexact = ! cov && d > sv . params. MAX_TYPE_DEPTH
408
+ inexact = ! cov && d > params. MAX_TYPE_DEPTH
409
409
if isa (t,Union)
410
410
t === Bottom && return t
411
- if d > sv . params. MAX_TYPE_DEPTH
411
+ if d > params. MAX_TYPE_DEPTH
412
412
R = Any
413
413
else
414
- R = Union{map (x-> limit_type_depth (x, d+ 1 , cov, vars, sv ), t. types)... }
414
+ R = Union{map (x-> limit_type_depth (x, d+ 1 , cov, vars, params ), t. types)... }
415
415
end
416
416
elseif isa (t,DataType)
417
417
P = t. parameters
418
418
isempty (P) && return t
419
- if d > sv . params. MAX_TYPE_DEPTH
419
+ if d > params. MAX_TYPE_DEPTH
420
420
R = t. name. primary
421
421
else
422
422
stillcov = cov && (t. name === Tuple. name)
423
- Q = map (x-> limit_type_depth (x, d+ 1 , stillcov, vars, sv ), P)
423
+ Q = map (x-> limit_type_depth (x, d+ 1 , stillcov, vars, params ), P)
424
424
if ! cov && _any (p-> contains_is (vars,p), Q)
425
425
R = t. name. primary
426
426
inexact = true
@@ -439,7 +439,7 @@ function limit_type_depth(t::ANY, d::Int, cov::Bool, vars, sv::InferenceState)
439
439
end
440
440
441
441
# returns (type, isexact)
442
- function getfield_tfunc (sv :: InferenceState , s0:: ANY , name)
442
+ function getfield_tfunc (params :: InferenceParams , s0:: ANY , name)
443
443
if isa (s0, TypeVar)
444
444
s0 = s0. ub
445
445
end
@@ -459,7 +459,7 @@ function getfield_tfunc(sv::InferenceState, s0::ANY, name)
459
459
s = typeof (s. val)
460
460
end
461
461
if isa (s,Union)
462
- return reduce (tmerge, Bottom, map (t-> getfield_tfunc (sv , t, name)[1 ], s. types)), false
462
+ return reduce (tmerge, Bottom, map (t-> getfield_tfunc (params , t, name)[1 ], s. types)), false
463
463
end
464
464
if isa (s,DataType)
465
465
if s. abstract
@@ -501,7 +501,7 @@ function getfield_tfunc(sv::InferenceState, s0::ANY, name)
501
501
# in the current type system
502
502
typ = limit_type_depth (R, 0 , true ,
503
503
filter! (x-> isa (x,TypeVar), Any[s. parameters... ]),
504
- sv )
504
+ params )
505
505
return typ, isleaftype (s) && isa (R, Type) && typeof (R) === typeof (typ) && typeseq (R, typ)
506
506
end
507
507
end
@@ -533,20 +533,20 @@ function getfield_tfunc(sv::InferenceState, s0::ANY, name)
533
533
else
534
534
typ = limit_type_depth (R, 0 , true ,
535
535
filter! (x-> isa (x,TypeVar), Any[s. parameters... ]),
536
- sv )
536
+ params )
537
537
return typ, alleq && isleaftype (s) && typeof (R) === typeof (typ) && typeseq (R, typ)
538
538
end
539
539
end
540
540
end
541
- add_tfunc (getfield, 2 , 2 , (sv ,s,name)-> getfield_tfunc (sv ,s,name)[1 ])
542
- add_tfunc (setfield!, 3 , 3 , (sv , o, f, v)-> v)
543
- function fieldtype_tfunc (sv , s:: ANY , name)
541
+ add_tfunc (getfield, 2 , 2 , (params ,s,name)-> getfield_tfunc (params ,s,name)[1 ])
542
+ add_tfunc (setfield!, 3 , 3 , (params , o, f, v)-> v)
543
+ function fieldtype_tfunc (params , s:: ANY , name)
544
544
if isType (s)
545
545
s = s. parameters[1 ]
546
546
else
547
547
return Type
548
548
end
549
- t, exact = getfield_tfunc (sv , s, name)
549
+ t, exact = getfield_tfunc (params , s, name)
550
550
if is (t,Bottom)
551
551
return t
552
552
end
567
567
has_typevars (t:: ANY , all= false ) = ccall (:jl_has_typevars_ , Cint, (Any,Cint), t, all)!= 0
568
568
569
569
# TODO : handle e.g. apply_type(T, R::Union{Type{Int32},Type{Float64}})
570
- function apply_type_tfunc (sv :: InferenceState , args... )
570
+ function apply_type_tfunc (params :: InferenceParams , args... )
571
571
if ! isType (args[1 ])
572
572
return Any
573
573
end
@@ -627,7 +627,7 @@ function apply_type_tfunc(sv::InferenceState, args...)
627
627
uncertain = true
628
628
end
629
629
! uncertain && return Type{appl}
630
- if type_too_complex (appl, 0 , sv )
630
+ if type_too_complex (appl, 0 , params )
631
631
return Type{TypeVar (:_ ,headtype)}
632
632
end
633
633
! (isa (appl,TypeVar) || isvarargtype (appl)) ? Type{TypeVar (:_ ,appl)} : Type{appl}
@@ -645,7 +645,7 @@ function invoke_tfunc(f::ANY, types::ANY, argtype::ANY, sv::InferenceState)
645
645
if ! isleaftype (Type{types})
646
646
return Any
647
647
end
648
- argtype = typeintersect (types,limit_tuple_type (argtype, sv))
648
+ argtype = typeintersect (types,limit_tuple_type (argtype, sv. params ))
649
649
if is (argtype,Bottom)
650
650
return Bottom
651
651
end
@@ -736,7 +736,7 @@ function builtin_tfunction(f::ANY, argtypes::Array{Any,1}, sv::InferenceState)
736
736
# wrong # of args
737
737
return Bottom
738
738
end
739
- return tf[3 ](sv, argtypes... )
739
+ return tf[3 ](sv. params , argtypes... )
740
740
end
741
741
742
742
limit_tuple_depth (params:: InferenceParams , t:: ANY ) = limit_tuple_depth_ (params,t,0 )
@@ -760,9 +760,9 @@ function limit_tuple_depth_(params::InferenceParams, t::ANY, d::Int)
760
760
Tuple{p... }
761
761
end
762
762
763
- limit_tuple_type = (t:: ANY , sv :: InferenceState ) -> limit_tuple_type_n (t, sv . params. MAX_TUPLETYPE_LEN, sv )
763
+ limit_tuple_type = (t:: ANY , params :: InferenceParams ) -> limit_tuple_type_n (t, params. MAX_TUPLETYPE_LEN)
764
764
765
- function limit_tuple_type_n (t:: ANY , lim:: Int , sv :: InferenceState )
765
+ function limit_tuple_type_n (t:: ANY , lim:: Int )
766
766
p = t. parameters
767
767
n = length (p)
768
768
if n > lim
@@ -784,7 +784,7 @@ function abstract_call_gf_by_type(f::ANY, argtype::ANY, sv::InferenceState)
784
784
# It is important for N to be >= the number of methods in the error()
785
785
# function, so we can still know that error() is always Bottom.
786
786
# here I picked 4.
787
- argtype = limit_tuple_type (argtype, sv)
787
+ argtype = limit_tuple_type (argtype, sv. params )
788
788
argtypes = argtype. parameters
789
789
applicable = _methods_by_ftype (argtype, 4 )
790
790
rettype = Bottom
@@ -830,7 +830,7 @@ function abstract_call_gf_by_type(f::ANY, argtype::ANY, sv::InferenceState)
830
830
if td > type_depth (infstate. linfo. specTypes)
831
831
# impose limit if we recur and the argument types grow beyond MAX_TYPE_DEPTH
832
832
if td > sv. params. MAX_TYPE_DEPTH
833
- sig = limit_type_depth (sig, 0 , true , [], sv)
833
+ sig = limit_type_depth (sig, 0 , true , [], sv. params )
834
834
break
835
835
else
836
836
p1, p2 = sig. parameters, infstate. linfo. specTypes. parameters
@@ -846,7 +846,7 @@ function abstract_call_gf_by_type(f::ANY, argtype::ANY, sv::InferenceState)
846
846
newsig[i] = p1[i]. name. primary
847
847
limitdepth = true
848
848
else
849
- newsig[i] = limit_type_depth (p1[i], 1 , true , [], sv)
849
+ newsig[i] = limit_type_depth (p1[i], 1 , true , [], sv. params )
850
850
end
851
851
end
852
852
if limitdepth
@@ -862,7 +862,7 @@ function abstract_call_gf_by_type(f::ANY, argtype::ANY, sv::InferenceState)
862
862
# # limit argument type size growth
863
863
# tdepth = type_depth(sig)
864
864
# if tdepth > sv.params.MAX_TYPE_DEPTH
865
- # sig = limit_type_depth(sig, 0, true, [], sv)
865
+ # sig = limit_type_depth(sig, 0, true, [], sv.params )
866
866
# end
867
867
868
868
# limit length based on size of definition signature.
@@ -882,7 +882,7 @@ function abstract_call_gf_by_type(f::ANY, argtype::ANY, sv::InferenceState)
882
882
end
883
883
end
884
884
if ! allsame
885
- sig = limit_tuple_type_n (sig, lsig+ 1 , sv )
885
+ sig = limit_tuple_type_n (sig, lsig+ 1 )
886
886
end
887
887
end
888
888
end
@@ -1068,12 +1068,12 @@ function abstract_call(f::ANY, fargs, argtypes::Vector{Any}, vtypes::VarTable, s
1068
1068
# allow tuple indexing functions to take advantage of constant
1069
1069
# index arguments.
1070
1070
if istopfunction (tm, f, :getindex )
1071
- return getfield_tfunc (sv, argtypes[2 ], argtypes[3 ])[1 ]
1071
+ return getfield_tfunc (sv. params , argtypes[2 ], argtypes[3 ])[1 ]
1072
1072
elseif istopfunction (tm, f, :next )
1073
- t1 = getfield_tfunc (sv, argtypes[2 ], argtypes[3 ])[1 ]
1073
+ t1 = getfield_tfunc (sv. params , argtypes[2 ], argtypes[3 ])[1 ]
1074
1074
return t1=== Bottom ? Bottom : Tuple{t1, Int}
1075
1075
elseif istopfunction (tm, f, :indexed_next )
1076
- t1 = getfield_tfunc (sv, argtypes[2 ], argtypes[3 ])[1 ]
1076
+ t1 = getfield_tfunc (sv. params , argtypes[2 ], argtypes[3 ])[1 ]
1077
1077
return t1=== Bottom ? Bottom : Tuple{t1, Int}
1078
1078
end
1079
1079
end
@@ -1268,21 +1268,21 @@ function abstract_interpret(e::ANY, vtypes::VarTable, sv::InferenceState)
1268
1268
return vtypes
1269
1269
end
1270
1270
1271
- function type_too_complex (t:: ANY , d, sv :: InferenceState )
1272
- if d > sv . params. MAX_TYPE_DEPTH
1271
+ function type_too_complex (t:: ANY , d, params :: InferenceParams )
1272
+ if d > params. MAX_TYPE_DEPTH
1273
1273
return true
1274
1274
end
1275
1275
if isa (t,Union)
1276
1276
p = t. types
1277
1277
elseif isa (t,DataType)
1278
1278
p = t. parameters
1279
1279
elseif isa (t,TypeVar)
1280
- return type_too_complex (t. lb, d+ 1 , sv ) || type_too_complex (t. ub, d+ 1 , sv )
1280
+ return type_too_complex (t. lb, d+ 1 , params ) || type_too_complex (t. ub, d+ 1 , params )
1281
1281
else
1282
1282
return false
1283
1283
end
1284
1284
for x in (p:: SimpleVector )
1285
- if type_too_complex (x, d+ 1 , sv )
1285
+ if type_too_complex (x, d+ 1 , params )
1286
1286
return true
1287
1287
end
1288
1288
end
@@ -1340,7 +1340,7 @@ function tmerge(typea::ANY, typeb::ANY)
1340
1340
end
1341
1341
end
1342
1342
u = Union{typea, typeb}
1343
- if length (u. types) > global_sv. params. MAX_TYPEUNION_LEN || type_too_complex (u, 0 , global_sv)
1343
+ if length (u. types) > global_sv. params. MAX_TYPEUNION_LEN || type_too_complex (u, 0 , global_sv. params )
1344
1344
# don't let type unions get too big
1345
1345
# TODO : something smarter, like a common supertype
1346
1346
return Any
@@ -2535,7 +2535,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2535
2535
end
2536
2536
2537
2537
if length (atype_unlimited. parameters) - 1 > sv. params. MAX_TUPLETYPE_LEN
2538
- atype = limit_tuple_type (atype_unlimited, sv)
2538
+ atype = limit_tuple_type (atype_unlimited, sv. params )
2539
2539
else
2540
2540
atype = atype_unlimited
2541
2541
end
0 commit comments