Skip to content

Commit

Permalink
remove some exports from Core and Base
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 31, 2018
1 parent d7200e7 commit bb0de2d
Show file tree
Hide file tree
Showing 47 changed files with 141 additions and 137 deletions.
18 changes: 13 additions & 5 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@
export
# key types
Any, DataType, Vararg, ANY, NTuple,
Tuple, Type, UnionAll, TypeName, TypeVar, Union, Nothing, Cvoid,
SimpleVector, AbstractArray, DenseArray, NamedTuple,
Tuple, Type, UnionAll, TypeVar, Union, Nothing, Cvoid,
AbstractArray, DenseArray, NamedTuple,
# special objects
Function, CodeInfo, Method, MethodTable, TypeMapEntry, TypeMapLevel,
Function, Method,
Module, Symbol, Task, Array, Uninitialized, uninitialized, WeakRef, VecElement,
# numeric types
Number, Real, Integer, Bool, Ref, Ptr,
Expand All @@ -140,8 +140,7 @@ export
OverflowError, StackOverflowError, SegmentationFault, UndefRefError, UndefVarError,
TypeError, ArgumentError, MethodError, AssertionError, LoadError, InitError,
# AST representation
Expr, GotoNode, LabelNode, LineNumberNode, QuoteNode,
GlobalRef, NewvarNode, SSAValue, Slot, SlotNumber, TypedSlot,
Expr, QuoteNode, LineNumberNode,
# object model functions
fieldtype, getfield, setfield!, nfields, throw, tuple, ===, isdefined, eval,
# sizeof # not exported, to avoid conflicting with Base.sizeof
Expand Down Expand Up @@ -403,6 +402,15 @@ function Symbol(a::Array{UInt8,1})
end
Symbol(s::Symbol) = s

# module providing the IR object model
module IR
export CodeInfo, MethodInstance, GotoNode, LabelNode,
GlobalRef, NewvarNode, SSAValue, Slot, SlotNumber, TypedSlot

import Core: CodeInfo, MethodInstance, GotoNode, LabelNode,
GlobalRef, NewvarNode, SSAValue, Slot, SlotNumber, TypedSlot
end

# docsystem basics
macro doc(x...)
atdoc(__source__, __module__, x...)
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

getfield(getfield(Main, :Core), :eval)(getfield(Main, :Core), :(baremodule Compiler

using Core.Intrinsics
using Core.Intrinsics, Core.IR

import Core: print, println, show, write, unsafe_write, STDOUT, STDERR,
_apply, svec, apply_type, Builtin, IntrinsicFunction, MethodInstance
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/inferencestate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function add_backedge!(li::MethodInstance, caller::InferenceState)
end

# used to temporarily accumulate our no method errors to later add as backedges in the callee method table
function add_mt_backedge!(mt::MethodTable, @nospecialize(typ), caller::InferenceState)
function add_mt_backedge!(mt::Core.MethodTable, @nospecialize(typ), caller::InferenceState)
isa(caller.linfo.def, Method) || return # don't add backedges to toplevel exprs
if caller.stmt_edges[caller.currpc] === ()
caller.stmt_edges[caller.currpc] = []
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ struct StructInfo
end

struct InvokeData
mt::MethodTable
entry::TypeMapEntry
mt::Core.MethodTable
entry::Core.TypeMapEntry
types0
fexpr
texpr
Expand Down
10 changes: 5 additions & 5 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const DATATYPE_TYPES_FIELDINDEX = fieldindex(DataType, :types)
const DATATYPE_SUPER_FIELDINDEX = fieldindex(DataType, :super)
const DATATYPE_MUTABLE_FIELDINDEX = fieldindex(DataType, :mutable)

const TYPENAME_NAME_FIELDINDEX = fieldindex(TypeName, :name)
const TYPENAME_MODULE_FIELDINDEX = fieldindex(TypeName, :module)
const TYPENAME_WRAPPER_FIELDINDEX = fieldindex(TypeName, :wrapper)
const TYPENAME_NAME_FIELDINDEX = fieldindex(Core.TypeName, :name)
const TYPENAME_MODULE_FIELDINDEX = fieldindex(Core.TypeName, :module)
const TYPENAME_WRAPPER_FIELDINDEX = fieldindex(Core.TypeName, :wrapper)

##########
# tfuncs #
Expand Down Expand Up @@ -463,8 +463,8 @@ function getfield_tfunc(@nospecialize(s00), @nospecialize(name))
t = const_datatype_getfield_tfunc(sv, isa(nv, Symbol) ?
fieldindex(DataType, nv, false) : nv)
t !== nothing && return t
elseif isa(sv, TypeName)
fld = isa(nv, Symbol) ? fieldindex(TypeName, nv, false) : nv
elseif isa(sv, Core.TypeName)
fld = isa(nv, Symbol) ? fieldindex(Core.TypeName, nv, false) : nv
if (fld == TYPENAME_NAME_FIELDINDEX ||
fld == TYPENAME_MODULE_FIELDINDEX ||
fld == TYPENAME_WRAPPER_FIELDINDEX)
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function finalize_backedges(frame::InferenceState)
ccall(:jl_method_instance_add_backedge, Cvoid, (Any, Any), to, caller)
i += 1
else
typeassert(to, MethodTable)
typeassert(to, Core.MethodTable)
typ = edges[i + 1]
ccall(:jl_method_table_add_backedge, Cvoid, (Any, Any, Any), to, typ, caller)
i += 2
Expand Down
1 change: 1 addition & 0 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ include("bindings.jl")
import Base.Meta: quot, isexpr
import Base: Callable, with_output_color
import ..CoreDocs: lazy_iterpolate
import Core: GlobalRef

export doc

Expand Down
2 changes: 1 addition & 1 deletion base/essentials.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Core: CodeInfo
using Core: CodeInfo, SimpleVector

const Callable = Union{Function,Type}

Expand Down
40 changes: 17 additions & 23 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export
BitArray,
BitMatrix,
BitVector,
BufferStream,
CartesianIndex,
CartesianIndices,
LinearIndices,
Expand All @@ -45,9 +44,7 @@ export
DevNull,
Dict,
Dims,
EachLine,
Enum,
Enumerate,
ExponentialBackOff,
IndexCartesian,
IndexLinear,
Expand All @@ -68,7 +65,6 @@ export
PartialQuickSort,
PermutedDimsArray,
QuickSort,
RangeIndex,
Rational,
Regex,
RegexMatch,
Expand Down Expand Up @@ -540,8 +536,6 @@ export
merge!,
merge,
pairs,
#pop!,
#push!,
reduce,
setdiff!,
setdiff,
Expand Down Expand Up @@ -570,7 +564,7 @@ export
,
,

# strings and text output
# strings
ascii,
base,
bin,
Expand All @@ -583,12 +577,10 @@ export
dec,
digits,
digits!,
dump,
escape_string,
hex,
hex2bytes,
hex2bytes!,
info,
isalpha,
isascii,
iscntrl,
Expand All @@ -604,18 +596,13 @@ export
lowercase,
isvalid,
join,
logging,
lpad,
lstrip,
ncodeunits,
ndigits,
nextind,
oct,
prevind,
print,
print_shortest,
println,
printstyled,
repeat,
replace,
replace!,
Expand All @@ -624,24 +611,33 @@ export
rpad,
rsplit,
rstrip,
show,
showcompact,
showerror,
split,
sprint,
string,
strip,
summary,
textwidth,
thisind,
titlecase,
transcode,
ucfirst,
unescape_string,
uppercase,
warn,

# logging frontend
# text output
dump,
print,
print_shortest,
println,
printstyled,
show,
showcompact,
showerror,
sprint,
summary,

# logging
info,
logging,
warn,
@debug,
@info,
@warn,
Expand Down Expand Up @@ -738,8 +734,6 @@ export
systemerror,

# stack traces
StackTrace,
StackFrame,
stacktrace,

# types
Expand Down
4 changes: 2 additions & 2 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function show_method_table(io::IO, ms::MethodList, max::Int=-1, header::Bool=tru
end

show(io::IO, ms::MethodList) = show_method_table(io, ms)
show(io::IO, mt::MethodTable) = show_method_table(io, MethodList(mt))
show(io::IO, mt::Core.MethodTable) = show_method_table(io, MethodList(mt))

function inbase(m::Module)
if m == Base
Expand Down Expand Up @@ -299,7 +299,7 @@ function show(io::IO, mime::MIME"text/html", ms::MethodList)
print(io, "</ul>")
end

show(io::IO, mime::MIME"text/html", mt::MethodTable) = show(io, mime, MethodList(mt))
show(io::IO, mime::MIME"text/html", mt::Core.MethodTable) = show(io, mime, MethodList(mt))

# pretty-printing of AbstractVector{Method}
function show(io::IO, mime::MIME"text/plain", mt::AbstractVector{Method})
Expand Down
2 changes: 1 addition & 1 deletion base/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ precompile(Tuple{typeof(Base.isassigned), Array{Symbol, 1}, Int64})
precompile(Tuple{typeof(Base.rehash!), Base.Dict{UInt64, Nothing}, Int64})
precompile(Tuple{typeof(Base.ht_keyindex2!), Base.Dict{UInt64, Nothing}, UInt64})
precompile(Tuple{typeof(Base._setindex!), Base.Dict{UInt64, Nothing}, Nothing, UInt64, Int64})
precompile(Tuple{typeof(Base.ht_keyindex), Base.Dict{WeakRef, Any}, TypeName})
precompile(Tuple{typeof(Base.ht_keyindex), Base.Dict{WeakRef, Any}, Core.TypeName})
precompile(Tuple{typeof(Base.isassigned), Array{Union{Tuple{Any, Int64}, Tuple{Tuple{}, Any, Bool}}, 1}, Int64})
precompile(Tuple{typeof(Base.uvfinalize), Base.TCPSocket})
precompile(Tuple{typeof(Base.close), Base.TCPSocket})
Expand Down
14 changes: 7 additions & 7 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ end
# type for reflecting and pretty-printing a subset of methods
mutable struct MethodList
ms::Array{Method,1}
mt::MethodTable
mt::Core.MethodTable
end

length(m::MethodList) = length(m.ms)
Expand All @@ -672,7 +672,7 @@ start(m::MethodList) = start(m.ms)
done(m::MethodList, s) = done(m.ms, s)
next(m::MethodList, s) = next(m.ms, s)

function MethodList(mt::MethodTable)
function MethodList(mt::Core.MethodTable)
ms = Method[]
visit(mt) do m
push!(ms, m)
Expand Down Expand Up @@ -711,11 +711,11 @@ function methods(@nospecialize(f))
return methods(f, Tuple{Vararg{Any}})
end

function visit(f, mt::MethodTable)
function visit(f, mt::Core.MethodTable)
mt.defs !== nothing && visit(f, mt.defs)
nothing
end
function visit(f, mc::TypeMapLevel)
function visit(f, mc::Core.TypeMapLevel)
if mc.targ !== nothing
e = mc.targ::Vector{Any}
for i in 1:length(e)
Expand All @@ -732,22 +732,22 @@ function visit(f, mc::TypeMapLevel)
mc.any !== nothing && visit(f, mc.any)
nothing
end
function visit(f, d::TypeMapEntry)
function visit(f, d::Core.TypeMapEntry)
while d !== nothing
f(d.func)
d = d.next
end
nothing
end

function length(mt::MethodTable)
function length(mt::Core.MethodTable)
n = 0
visit(mt) do m
n += 1
end
return n::Int
end
isempty(mt::MethodTable) = (mt.defs === nothing)
isempty(mt::Core.MethodTable) = (mt.defs === nothing)

uncompressed_ast(m::Method) = isdefined(m,:source) ? uncompressed_ast(m, m.source) :
isdefined(m,:generator) ? error("Method is @generated; try `code_lowered` instead.") :
Expand Down
4 changes: 2 additions & 2 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ isvisible(sym::Symbol, parent::Module, from::Module) =
isdefined(from, sym) && !isdeprecated(from, sym) && !isdeprecated(parent, sym) &&
getfield(from, sym) === getfield(parent, sym)

function show_type_name(io::IO, tn::TypeName)
function show_type_name(io::IO, tn::Core.TypeName)
if tn === UnionAll.name
# by coincidence, `typeof(Type)` is a valid representation of the UnionAll type.
# intercept this case and print `UnionAll` instead.
Expand Down Expand Up @@ -547,7 +547,7 @@ macro show(exs...)
return blk
end

function show(io::IO, tn::TypeName)
function show(io::IO, tn::Core.TypeName)
show_type_name(io, tn)
end

Expand Down
8 changes: 4 additions & 4 deletions base/stacktraces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct StackFrame # this type should be kept platform-agnostic so that profiles
"the line number in the file containing the execution context"
line::Int
"the MethodInstance or CodeInfo containing the execution context (if it could be found)"
linfo::Union{Core.MethodInstance, CodeInfo, Nothing}
linfo::Union{Core.MethodInstance, Core.CodeInfo, Nothing}
"true if the code is from C"
from_c::Bool
"true if the code is from an inlined frame"
Expand Down Expand Up @@ -133,7 +133,7 @@ function lookup(ip::Base.InterpreterIP)
# interpreted top-level expression with no CodeInfo
return [StackFrame(top_level_scope_sym, empty_sym, 0, nothing, false, false, 0)]
else
assert(ip.code isa CodeInfo)
assert(ip.code isa Core.CodeInfo)
codeinfo = ip.code
func = top_level_scope_sym
file = empty_sym
Expand Down Expand Up @@ -265,7 +265,7 @@ function remove_frames!(stack::StackTrace, m::Module)
return stack
end

is_top_level_frame(f::StackFrame) = f.linfo isa CodeInfo || (f.linfo === nothing && f.func === top_level_scope_sym)
is_top_level_frame(f::StackFrame) = f.linfo isa Core.CodeInfo || (f.linfo === nothing && f.func === top_level_scope_sym)

function show_spec_linfo(io::IO, frame::StackFrame)
if frame.linfo == nothing
Expand All @@ -285,7 +285,7 @@ function show_spec_linfo(io::IO, frame::StackFrame)
else
Base.show(io, frame.linfo)
end
elseif frame.linfo isa CodeInfo
elseif frame.linfo isa Core.CodeInfo
print(io, "top-level scope")
end
end
Expand Down
2 changes: 1 addition & 1 deletion base/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ function _quantilesort!(v::AbstractArray, sorted::Bool, minp::Real, maxp::Real)
hi = ceil(Int,1+maxp*(lv-1))

# only need to perform partial sort
sort!(v, 1, lv, PartialQuickSort(lo:hi), Base.Sort.Forward)
sort!(v, 1, lv, Sort.PartialQuickSort(lo:hi), Base.Sort.Forward)
end
isnan(v[end]) && throw(ArgumentError("quantiles are undefined in presence of NaNs"))
return v
Expand Down
Loading

0 comments on commit bb0de2d

Please sign in to comment.