2
2
3
3
# Note: to avoid dynamic dispatch, many of these are coded as a single method using isa statements
4
4
5
- function scopeof (x ):: Union{Method,Module}
5
+ function scopeof (@nospecialize (x) ):: Union{Method,Module}
6
6
(isa (x, Method) || isa (x, Module)) && return x
7
7
isa (x, FrameCode) && return x. scope
8
8
isa (x, Frame) && return x. framecode. scope
9
9
error (" unknown scope for " , x)
10
10
end
11
11
12
- function moduleof (x )
12
+ function moduleof (@nospecialize (x) )
13
13
s = scopeof (x)
14
14
return isa (s, Module) ? s : s. module
15
15
end
21
21
22
22
_Typeof (x) = isa (x,Type) ? Type{x} : typeof (x)
23
23
24
- function to_function (x )
24
+ function to_function (@nospecialize (x) )
25
25
isa (x, GlobalRef) ? getfield (x. mod, x. name) : x
26
26
end
27
27
28
- function whichtt (tt )
28
+ function whichtt (@nospecialize (tt) )
29
29
m = ccall (:jl_gf_invoke_lookup , Any, (Any, UInt), tt, typemax (UInt))
30
30
m === nothing && return nothing
31
31
return m. func:: Method
@@ -48,8 +48,8 @@ separate_kwargs(args...; kwargs...) = (args, kwargs.data)
48
48
49
49
pc_expr (src:: CodeInfo , pc) = src. code[pc]
50
50
pc_expr (framecode:: FrameCode , pc) = pc_expr (framecode. src, pc)
51
- pc_expr (frame, pc) = pc_expr (frame. framecode, pc)
52
- pc_expr (frame) = pc_expr (frame, frame. pc)
51
+ pc_expr (frame:: Frame , pc) = pc_expr (frame. framecode, pc)
52
+ pc_expr (frame:: Frame ) = pc_expr (frame, frame. pc)
53
53
54
54
function find_used (code:: CodeInfo )
55
55
used = BitSet ()
67
67
68
68
# # Predicates
69
69
70
- is_goto_node (node) = isa (node, GotoNode) || isexpr (node, :gotoifnot )
70
+ is_goto_node (@nospecialize ( node) ) = isa (node, GotoNode) || isexpr (node, :gotoifnot )
71
71
72
- is_loc_meta (expr, kind) = isexpr (expr, :meta ) && length (expr. args) >= 1 && expr. args[1 ] === kind
72
+ is_loc_meta (@nospecialize ( expr), @nospecialize ( kind) ) = isexpr (expr, :meta ) && length (expr. args) >= 1 && expr. args[1 ] === kind
73
73
74
74
"""
75
75
is_global_ref(g, mod, name)
76
76
77
77
Tests whether `g` is equal to `GlobalRef(mod, name)`.
78
78
"""
79
- is_global_ref (g , mod, name) = isa (g, GlobalRef) && g. mod === mod && g. name == name
79
+ is_global_ref (@nospecialize (g) , mod:: Module , name:: Symbol ) = isa (g, GlobalRef) && g. mod === mod && g. name == name
80
80
81
- function is_function_def (ex )
81
+ function is_function_def (@nospecialize (ex) )
82
82
(isexpr (ex, :(= )) && isexpr (ex. args[1 ], :call )) ||
83
83
isexpr (ex,:function )
84
84
end
85
85
86
- function is_call (node)
86
+ function is_call (@nospecialize ( node) )
87
87
isexpr (node, :call ) ||
88
88
(isexpr (node, :(= )) && (isexpr (node. args[2 ], :call )))
89
89
end
90
90
91
- is_call_or_return (node) = is_call (node) || isexpr (node, :return )
91
+ is_call_or_return (@nospecialize ( node) ) = is_call (node) || isexpr (node, :return )
92
92
93
93
is_dummy (bpref:: BreakpointRef ) = bpref. stmtidx == 0 && bpref. err === nothing
94
94
95
95
"""
96
96
Determine whether we are calling a function for which the current function
97
97
is a wrapper (either because of optional arguments or because of keyword arguments).
98
98
"""
99
- function is_wrapper_call (expr)
99
+ function is_wrapper_call (@nospecialize ( expr) )
100
100
isexpr (expr, :(= )) && (expr = expr. args[2 ])
101
101
isexpr (expr, :call ) && any (x-> x== SlotNumber (1 ), expr. args)
102
102
end
103
103
104
- function is_generated (meth)
104
+ function is_generated (meth:: Method )
105
105
isdefined (meth, :generator )
106
106
end
107
107
110
110
111
111
Test whether expression `ex` is a `@doc` expression.
112
112
"""
113
- function is_doc_expr (ex )
113
+ function is_doc_expr (@nospecialize (ex) )
114
114
docsym = Symbol (" @doc" )
115
115
if isexpr (ex, :macrocall )
116
116
a = ex. args[1 ]
@@ -124,7 +124,7 @@ function is_doc_expr(ex)
124
124
return false
125
125
end
126
126
127
- is_leaf (frame) = frame. callee === nothing
127
+ is_leaf (frame:: Frame ) = frame. callee === nothing
128
128
129
129
# # Location info
130
130
0 commit comments