Skip to content

Commit d4e0278

Browse files
authored
Documentation fixes (#19)
1 parent 7477b8b commit d4e0278

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MethodAnalysis"
22
uuid = "85b6ec6f-f7df-4429-9514-a64bcd9ee824"
33
authors = ["Tim Holy <[email protected]>"]
4-
version = "0.4.2"
4+
version = "0.4.3"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

docs/src/index.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ julia> foo(::AbstractVector) = 1
5252
foo (generic function with 1 method)
5353
5454
julia> methodinstance(foo, (Vector{Int},)) # we haven't called it yet, so it's not compiled
55-
MethodInstance for foo(::Vector{Int64})
55+
5656
5757
julia> foo([1,2])
5858
1
@@ -82,7 +82,7 @@ We checked that the length was 2, rather than 1, because the first parameter is
8282

8383
```jldoctest findfirst
8484
julia> mis[1].specTypes
85-
Tuple{typeof(findfirst),BitVector}
85+
Tuple{typeof(findfirst), BitVector}
8686
```
8787

8888
There's also a convenience shortcut:
@@ -97,10 +97,13 @@ Let's see all the compiled instances of `Base.setdiff` and their immediate calle
9797

9898
```jldoctest; setup=(using MethodAnalysis)
9999
julia> direct_backedges(setdiff)
100-
3-element Vector{Any}:
101-
MethodInstance for setdiff(::Base.KeySet{Any,Dict{Any,Any}}, ::Base.KeySet{Any,Dict{Any,Any}}) => MethodInstance for keymap_merge(::Dict{Char,Any}, ::Dict{Any,Any})
102-
MethodInstance for setdiff(::Base.KeySet{Any,Dict{Any,Any}}, ::Base.KeySet{Any,Dict{Any,Any}}) => MethodInstance for keymap_merge(::Any, ::Dict{Any,Any})
103-
MethodInstance for setdiff(::Vector{Base.UUID}, ::Vector{Base.UUID}) => MethodInstance for deps_graph(::Pkg.Types.Context, ::Dict{Base.UUID,String}, ::Dict{Base.UUID,Pkg.Types.VersionSpec}, ::Dict{Base.UUID,Pkg.Resolve.Fixed})
100+
6-element Vector{Any}:
101+
MethodInstance for setdiff(::Base.KeySet{Any, Dict{Any, Any}}, ::Base.KeySet{Any, Dict{Any, Any}}) => MethodInstance for keymap_merge(::Dict{Char, Any}, ::Dict{Any, Any})
102+
MethodInstance for setdiff(::Base.KeySet{Any, Dict{Any, Any}}, ::Base.KeySet{Any, Dict{Any, Any}}) => MethodInstance for keymap_merge(::Dict{Char, Any}, ::Union{Dict{Any, Any}, Dict{Char, Any}})
103+
MethodInstance for setdiff(::Base.KeySet{Char, Dict{Char, Any}}, ::Base.KeySet{Any, Dict{Any, Any}}) => MethodInstance for keymap_merge(::Dict{Char, Any}, ::Union{Dict{Any, Any}, Dict{Char, Any}})
104+
MethodInstance for setdiff(::Base.KeySet{Any, Dict{Any, Any}}, ::Base.KeySet{Char, Dict{Char, Any}}) => MethodInstance for keymap_merge(::Dict{Char, Any}, ::Union{Dict{Any, Any}, Dict{Char, Any}})
105+
MethodInstance for setdiff(::Base.KeySet{Char, Dict{Char, Any}}, ::Base.KeySet{Char, Dict{Char, Any}}) => MethodInstance for keymap_merge(::Dict{Char, Any}, ::Union{Dict{Any, Any}, Dict{Char, Any}})
106+
MethodInstance for setdiff(::Vector{Base.UUID}, ::Vector{Base.UUID}) => MethodInstance for deps_graph(::Pkg.Types.Context, ::Dict{Base.UUID, String}, ::Dict{Base.UUID, Pkg.Types.VersionSpec}, ::Dict{Base.UUID, Pkg.Resolve.Fixed})
104107
```
105108

106109
### Printing backedges as a tree
@@ -114,9 +117,12 @@ MethodInstance for findfirst(::BitVector)
114117
julia> MethodAnalysis.print_tree(mi)
115118
MethodInstance for findfirst(::BitVector)
116119
├─ MethodInstance for prune_graph!(::Graph)
117-
│ └─ MethodInstance for #simplify_graph!#111(::Bool, ::typeof(simplify_graph!), ::Graph, ::Set{Int64})
120+
│ └─ MethodInstance for var"#simplify_graph!#111"(::Bool, ::typeof(simplify_graph!), ::Graph, ::Set{Int64})
118121
│ └─ MethodInstance for simplify_graph!(::Graph, ::Set{Int64})
119122
│ └─ MethodInstance for simplify_graph!(::Graph)
123+
│ ├─ MethodInstance for trigger_failure!(::Graph, ::Vector{Int64}, ::Tuple{Int64, Int64})
124+
│ │ ⋮
125+
│ │
120126
│ └─ MethodInstance for resolve_versions!(::Context, ::Vector{PackageSpec})
121127
│ ⋮
122128
@@ -136,7 +142,7 @@ MethodInstance for findfirst(::BitVector)
136142
137143
└─ MethodInstance for maxsum(::Graph)
138144
└─ MethodInstance for resolve(::Graph)
139-
├─ MethodInstance for trigger_failure!(::Graph, ::Vector{Int64}, ::Tuple{Int64,Int64})
145+
├─ MethodInstance for trigger_failure!(::Graph, ::Vector{Int64}, ::Tuple{Int64, Int64})
140146
│ ⋮
141147
142148
└─ MethodInstance for resolve_versions!(::Context, ::Vector{PackageSpec})
@@ -185,3 +191,9 @@ call_type
185191
findcallers
186192
worlds
187193
```
194+
195+
### types
196+
197+
```@docs
198+
MethodAnalysis.CallMatch
199+
```

src/findcallers.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ function get_typed_instances(@nospecialize(tt), method::Method; world=typemax(UI
2929
return get_typed_instances!(Tuple{CodeInfo,Core.SimpleVector}[], tt, method, world, interp)
3030
end
3131

32+
"""
33+
CallMatch
34+
35+
A structure to summarize a "matching" caller/callee pair. The fields are:
36+
37+
- `mi`: the `MethodInstance` for the caller
38+
- `src`: its corresponding `CodeInfo`
39+
- `sparams`: the type parameters for the caller, given `mi`'s signature (alternatively use `mi.sparam_vals`)
40+
- `line`: the statement number (in SSAValue sense) on which the call occurs
41+
- `argtypes`: the caller's inferred types passed as arguments to the callee
42+
"""
3243
struct CallMatch
3344
mi::MethodInstance
3445
src::CodeInfo
@@ -50,8 +61,7 @@ Optionally pass `nothing` for `argmatch` to allow any calls to `f`.
5061
5162
`callhead` controls whether you're looking for an ordinary (`:call`) or a splatted (varargs) call (`:iterate`).
5263
53-
`callers` is a vector of tuples `t`, where `t[1]` is the `MethodInstance`, `t[2]` is the corresponding `CodeInfo`,
54-
`t[3]` is the statement number on which the call occurs, and `t[4]` holds the inferred argument types.
64+
`callers` is a vector of [`CallMatch`](@ref) objects.
5565
5666
# Examples
5767
@@ -76,6 +86,7 @@ callers2 = findcallers(f, argtyps->length(argtyps) == 1 && argtyps[1] === Intege
7686
7787
# Get the splat call
7888
callers3 = findcallers(f, argtyps->length(argtyps) == 1 && argtyps[1] === Vector{Any}, mis; callhead=:iterate)
89+
```
7990
8091
!!! compat
8192
`findcallers` is available on Julia 1.6 and higher

0 commit comments

Comments
 (0)