Skip to content

Commit c7643cd

Browse files
committed
Merge pull request #15947 from JuliaLang/jn/typemap
typemap cleanup
2 parents 59b57cc + 416217e commit c7643cd

10 files changed

+1169
-1126
lines changed

base/interactiveutil.jl

-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ function edit(path::AbstractString, line::Integer=0)
6464
nothing
6565
end
6666

67-
function edit(m::TypeMapEntry)
68-
tv, decls, file, line = arg_decl_parts(m)
69-
edit(string(file), line)
70-
end
71-
7267
edit(f) = edit(functionloc(f)...)
7368
edit(f, t::ANY) = edit(functionloc(f,t)...)
7469
edit(file, line::Integer) = error("could not find source file for function")

base/reflection.jl

+10-8
Original file line numberDiff line numberDiff line change
@@ -170,20 +170,21 @@ end
170170

171171
tt_cons(t::ANY, tup::ANY) = (@_pure_meta; Tuple{t, (isa(tup, Type) ? tup.parameters : tup)...})
172172

173-
code_lowered(f, t::ANY=Tuple) = map(m->m.func, methods(f, t))
174-
function methods(f::ANY,t::ANY)
173+
code_lowered(f, t::ANY=Tuple) = map(m -> (m.func::Method).lambda_template, methods(f, t))
174+
175+
function methods(f::ANY, t::ANY)
175176
if isa(f,Builtin)
176177
throw(ArgumentError("argument is not a generic function"))
177178
end
178179
t = to_tuple_type(t)
179-
Any[m[3] for m in _methods(f,t,-1)]
180+
return Any[m[3] for m in _methods(f,t,-1)]
180181
end
181182
function _methods(f::ANY,t::ANY,lim)
182183
ft = isa(f,Type) ? Type{f} : typeof(f)
183184
if isa(t,Type)
184-
_methods_by_ftype(Tuple{ft, t.parameters...}, lim)
185+
return _methods_by_ftype(Tuple{ft, t.parameters...}, lim)
185186
else
186-
_methods_by_ftype(Tuple{ft, t...}, lim)
187+
return _methods_by_ftype(Tuple{ft, t...}, lim)
187188
end
188189
end
189190
function _methods_by_ftype(t::ANY, lim)
@@ -219,17 +220,17 @@ function _methods(t::Array,i,lim::Integer,matching::Array{Any,1})
219220
return _methods(t,i-1,lim,matching)
220221
end
221222
end
222-
matching
223+
return matching
223224
end
224225

225226
function methods(f::ANY)
226227
ft = typeof(f)
227228
if ft <: Type || !isempty(ft.parameters)
228229
# for these types of `f`, not every method in the table will necessarily
229230
# match, so we need to filter based on its type.
230-
methods(f, Tuple{Vararg{Any}})
231+
return methods(f, Tuple{Vararg{Any}})
231232
else
232-
ft.name.mt
233+
return ft.name.mt
233234
end
234235
end
235236

@@ -368,6 +369,7 @@ function which_module(m::Module, s::Symbol)
368369
end
369370

370371
functionloc(m::TypeMapEntry) = functionloc(m.func)
372+
functionloc(m::LambdaInfo) = functionloc(m.def)
371373
function functionloc(m::Method)
372374
ln = m.line
373375
if ln <= 0

src/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ endif
2626

2727

2828
SRCS := \
29-
jltypes gf ast builtins module interpreter \
29+
jltypes gf typemap ast builtins module interpreter \
3030
alloc dlload sys init task array dump toplevel jl_uv jlapi signal-handling \
3131
simplevector APInt-C runtime_intrinsics runtime_ccall \
3232
threadgroup threading stackwalk

src/alloc.c

-11
Original file line numberDiff line numberDiff line change
@@ -740,17 +740,6 @@ jl_sym_t *jl_demangle_typename(jl_sym_t *s)
740740
return jl_symbol_n(&n[1], len);
741741
}
742742

743-
jl_typemap_level_t *jl_new_typemap_level(void)
744-
{
745-
jl_typemap_level_t *cache = (jl_typemap_level_t*)jl_gc_allocobj(sizeof(jl_typemap_level_t));
746-
jl_set_typeof(cache, jl_typemap_level_type);
747-
cache->key = NULL;
748-
cache->linear = (jl_typemap_entry_t*)jl_nothing;
749-
cache->arg1 = (jl_array_t*)jl_nothing;
750-
cache->targ = (jl_array_t*)jl_nothing;
751-
return cache;
752-
}
753-
754743
JL_DLLEXPORT jl_methtable_t *jl_new_method_table(jl_sym_t *name, jl_module_t *module)
755744
{
756745
jl_methtable_t *mt = (jl_methtable_t*)jl_gc_allocobj(sizeof(jl_methtable_t));

0 commit comments

Comments
 (0)