2
2
3
3
abstract type MethodTableView; end
4
4
5
- struct MethodLookupResult
6
- # Really Vector{Core.MethodMatch}, but it's easier to represent this as
7
- # and work with Vector{Any} on the C side.
8
- matches:: Vector{Any}
9
- valid_worlds:: WorldRange
10
- ambig:: Bool
11
- end
12
- length (result:: MethodLookupResult ) = length (result. matches)
13
- function iterate (result:: MethodLookupResult , args... )
14
- r = iterate (result. matches, args... )
15
- r === nothing && return nothing
16
- match, state = r
17
- return (match:: MethodMatch , state)
18
- end
19
- getindex (result:: MethodLookupResult , idx:: Int ) = getindex (result. matches, idx):: MethodMatch
20
-
21
5
"""
22
6
struct InternalMethodTable <: MethodTableView
23
7
@@ -39,19 +23,21 @@ struct OverlayMethodTable <: MethodTableView
39
23
mt:: Core.MethodTable
40
24
end
41
25
42
- """
43
- struct CachedMethodTable <: MethodTableView
44
-
45
- Overlays another method table view with an additional local fast path cache that
46
- can respond to repeated, identical queries faster than the original method table.
47
- """
48
- struct CachedMethodTable{T} <: MethodTableView
49
- cache:: IdDict{Any, Union{Missing, MethodLookupResult}}
50
- table:: T
26
+ struct MethodLookupResult
27
+ # Really Vector{Core.MethodMatch}, but it's easier to represent this as
28
+ # and work with Vector{Any} on the C side.
29
+ matches:: Vector{Any}
30
+ valid_worlds:: WorldRange
31
+ ambig:: Bool
32
+ end
33
+ length (result:: MethodLookupResult ) = length (result. matches)
34
+ function iterate (result:: MethodLookupResult , args... )
35
+ r = iterate (result. matches, args... )
36
+ r === nothing && return nothing
37
+ match, state = r
38
+ return (match:: MethodMatch , state)
51
39
end
52
- CachedMethodTable (table:: T ) where T =
53
- CachedMethodTable {T} (IdDict {Any, Union{Missing, MethodLookupResult}} (),
54
- table)
40
+ getindex (result:: MethodLookupResult , idx:: Int ) = getindex (result. matches, idx):: MethodMatch
55
41
56
42
"""
57
43
findall(sig::Type, view::MethodTableView; limit=typemax(Int))
@@ -91,13 +77,6 @@ function findall(@nospecialize(sig::Type), table::OverlayMethodTable; limit::Int
91
77
return MethodLookupResult (ms:: Vector{Any} , WorldRange (_min_val[], _max_val[]), _ambig[] != 0 )
92
78
end
93
79
94
- function findall (@nospecialize (sig:: Type ), table:: CachedMethodTable ; limit:: Int = typemax (Int))
95
- box = Core. Box (sig)
96
- return get! (table. cache, sig) do
97
- findall (box. contents, table. table; limit= limit)
98
- end
99
- end
100
-
101
80
"""
102
81
findsup(sig::Type, view::MethodTableView)::Union{Tuple{MethodMatch, WorldRange}, Nothing}
103
82
@@ -121,10 +100,6 @@ function findsup(@nospecialize(sig::Type), table::InternalMethodTable)
121
100
(result. method, WorldRange (min_valid[], max_valid[]))
122
101
end
123
102
124
- # This query is not cached
125
- findsup (@nospecialize (sig:: Type ), table:: CachedMethodTable ) = findsup (sig, table. table)
126
-
127
103
isoverlayed (:: MethodTableView ) = error (" unsatisfied MethodTableView interface" )
128
104
isoverlayed (:: InternalMethodTable ) = false
129
105
isoverlayed (:: OverlayMethodTable ) = true
130
- isoverlayed (mt:: CachedMethodTable ) = isoverlayed (mt. table)
0 commit comments