diff --git a/base/essentials.jl b/base/essentials.jl index fdc66e94d1a00..4e8a22fd229a9 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -180,22 +180,11 @@ macro isdefined(s::Symbol) return Expr(:escape, Expr(:isdefined, s)) end -""" - nameof(m::Module) -> Symbol - -Get the name of a `Module` as a [`Symbol`](@ref). - -# Examples -```jldoctest -julia> nameof(Base.Broadcast) -:Broadcast -``` -""" -nameof(m::Module) = ccall(:jl_module_name, Ref{Symbol}, (Any,), m) +_nameof(m::Module) = ccall(:jl_module_name, Ref{Symbol}, (Any,), m) function _is_internal(__module__) if ccall(:jl_base_relative_to, Any, (Any,), __module__)::Module === Core.Compiler || - nameof(__module__) === :Base + _nameof(__module__) === :Base return true end return false @@ -375,6 +364,19 @@ getindex(A::GenericMemory, i::Int) = (@_noub_if_noinbounds_meta; memoryrefget(memoryref(memoryref(A), i, @_boundscheck), default_access_order(A), false)) getindex(A::GenericMemoryRef) = memoryrefget(A, default_access_order(A), @_boundscheck) +""" + nameof(m::Module) -> Symbol + +Get the name of a `Module` as a [`Symbol`](@ref). + +# Examples +```jldoctest +julia> nameof(Base.Broadcast) +:Broadcast +``` +""" +nameof(m::Module) = (@_total_meta; ccall(:jl_module_name, Ref{Symbol}, (Any,), m)) + function iterate end """ diff --git a/base/reflection.jl b/base/reflection.jl index 2df713a531fae..f27da6d4df32e 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -18,7 +18,7 @@ julia> parentmodule(Base.Broadcast) Base ``` """ -parentmodule(m::Module) = ccall(:jl_module_parent, Ref{Module}, (Any,), m) +parentmodule(m::Module) = (@_total_meta; ccall(:jl_module_parent, Ref{Module}, (Any,), m)) is_root_module(m::Module) = parentmodule(m) === m || (isdefined(Main, :Base) && m === Main.Base) @@ -30,6 +30,7 @@ parent modules of `m` which is either a registered root module or which is its own parent module. """ function moduleroot(m::Module) + @_total_meta while true is_root_module(m) && return m p = parentmodule(m) @@ -63,6 +64,7 @@ julia> fullname(Main) ``` """ function fullname(m::Module) + @_total_meta mn = nameof(m) if m === Main || m === Base || m === Core return (mn,)