Skip to content

Commit

Permalink
Merge pull request #15947 from JuliaLang/jn/typemap
Browse files Browse the repository at this point in the history
typemap cleanup
  • Loading branch information
vtjnash committed Apr 20, 2016
2 parents 59b57cc + 416217e commit c7643cd
Show file tree
Hide file tree
Showing 10 changed files with 1,169 additions and 1,126 deletions.
5 changes: 0 additions & 5 deletions base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ function edit(path::AbstractString, line::Integer=0)
nothing
end

function edit(m::TypeMapEntry)
tv, decls, file, line = arg_decl_parts(m)
edit(string(file), line)
end

edit(f) = edit(functionloc(f)...)
edit(f, t::ANY) = edit(functionloc(f,t)...)
edit(file, line::Integer) = error("could not find source file for function")
Expand Down
18 changes: 10 additions & 8 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,21 @@ end

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

code_lowered(f, t::ANY=Tuple) = map(m->m.func, methods(f, t))
function methods(f::ANY,t::ANY)
code_lowered(f, t::ANY=Tuple) = map(m -> (m.func::Method).lambda_template, methods(f, t))

function methods(f::ANY, t::ANY)
if isa(f,Builtin)
throw(ArgumentError("argument is not a generic function"))
end
t = to_tuple_type(t)
Any[m[3] for m in _methods(f,t,-1)]
return Any[m[3] for m in _methods(f,t,-1)]
end
function _methods(f::ANY,t::ANY,lim)
ft = isa(f,Type) ? Type{f} : typeof(f)
if isa(t,Type)
_methods_by_ftype(Tuple{ft, t.parameters...}, lim)
return _methods_by_ftype(Tuple{ft, t.parameters...}, lim)
else
_methods_by_ftype(Tuple{ft, t...}, lim)
return _methods_by_ftype(Tuple{ft, t...}, lim)
end
end
function _methods_by_ftype(t::ANY, lim)
Expand Down Expand Up @@ -219,17 +220,17 @@ function _methods(t::Array,i,lim::Integer,matching::Array{Any,1})
return _methods(t,i-1,lim,matching)
end
end
matching
return matching
end

function methods(f::ANY)
ft = typeof(f)
if ft <: Type || !isempty(ft.parameters)
# for these types of `f`, not every method in the table will necessarily
# match, so we need to filter based on its type.
methods(f, Tuple{Vararg{Any}})
return methods(f, Tuple{Vararg{Any}})
else
ft.name.mt
return ft.name.mt
end
end

Expand Down Expand Up @@ -368,6 +369,7 @@ function which_module(m::Module, s::Symbol)
end

functionloc(m::TypeMapEntry) = functionloc(m.func)
functionloc(m::LambdaInfo) = functionloc(m.def)
function functionloc(m::Method)
ln = m.line
if ln <= 0
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ endif


SRCS := \
jltypes gf ast builtins module interpreter \
jltypes gf typemap ast builtins module interpreter \
alloc dlload sys init task array dump toplevel jl_uv jlapi signal-handling \
simplevector APInt-C runtime_intrinsics runtime_ccall \
threadgroup threading stackwalk
Expand Down
11 changes: 0 additions & 11 deletions src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,17 +740,6 @@ jl_sym_t *jl_demangle_typename(jl_sym_t *s)
return jl_symbol_n(&n[1], len);
}

jl_typemap_level_t *jl_new_typemap_level(void)
{
jl_typemap_level_t *cache = (jl_typemap_level_t*)jl_gc_allocobj(sizeof(jl_typemap_level_t));
jl_set_typeof(cache, jl_typemap_level_type);
cache->key = NULL;
cache->linear = (jl_typemap_entry_t*)jl_nothing;
cache->arg1 = (jl_array_t*)jl_nothing;
cache->targ = (jl_array_t*)jl_nothing;
return cache;
}

JL_DLLEXPORT jl_methtable_t *jl_new_method_table(jl_sym_t *name, jl_module_t *module)
{
jl_methtable_t *mt = (jl_methtable_t*)jl_gc_allocobj(sizeof(jl_methtable_t));
Expand Down
Loading

0 comments on commit c7643cd

Please sign in to comment.