Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Compiler/src/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ being used for this purpose alone.
"""
module Timings

using ..Core
using ..Compiler: -, +, :, Vector, length, first, empty!, push!, pop!, @inline,
@inbounds, copy, backtrace

Expand Down
5 changes: 4 additions & 1 deletion base/Base_compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

baremodule Base

using Core
using Core.Intrinsics, Core.IR

# to start, we're going to use a very simple definition of `include`
Expand Down Expand Up @@ -135,14 +136,16 @@ include("coreio.jl")

import Core: @doc, @__doc__, WrappedException, @int128_str, @uint128_str, @big_str, @cmd

# Export list
include("exports.jl")

# core docsystem
include("docs/core.jl")
Core.atdoc!(CoreDocs.docm)

eval(x) = Core.eval(Base, x)
eval(m::Module, x) = Core.eval(m, x)

include("exports.jl")
include("public.jl")

if false
Expand Down
5 changes: 3 additions & 2 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ export
# method reflection
applicable, invoke,
# constants
nothing, Main
nothing, Main,
# backwards compatibility
arrayref, arrayset, arraysize, const_arrayref

const getproperty = getfield # TODO: use `getglobal` for modules instead
const setproperty! = setfield!
Expand Down Expand Up @@ -1040,7 +1042,6 @@ const_arrayref(inbounds::Bool, A::Array, i::Int...) = Main.Base.getindex(A, i...
arrayset(inbounds::Bool, A::Array{T}, x::Any, i::Int...) where {T} = Main.Base.setindex!(A, x::T, i...)
arraysize(a::Array) = a.size
arraysize(a::Array, i::Int) = sle_int(i, nfields(a.size)) ? getfield(a.size, i) : 1
export arrayref, arrayset, arraysize, const_arrayref
const check_top_bit = check_sign_bit

# For convenience
Expand Down
39 changes: 39 additions & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

# Re-exports from `Core`
export Core,
# key types
Any, DataType, Vararg, NTuple,
Tuple, Type, UnionAll, TypeVar, Union, Nothing, Cvoid,
AbstractArray, DenseArray, NamedTuple, Pair,
# special objects
Function, Method, Module, Symbol, Task, UndefInitializer, undef, WeakRef, VecElement,
Array, Memory, MemoryRef, AtomicMemory, AtomicMemoryRef, GenericMemory, GenericMemoryRef,
# numeric types
Number, Real, Integer, Bool, Ref, Ptr,
AbstractFloat, Float16, Float32, Float64,
Signed, Int, Int8, Int16, Int32, Int64, Int128,
Unsigned, UInt, UInt8, UInt16, UInt32, UInt64, UInt128,
# string types
AbstractChar, Char, AbstractString, String, IO,
# errors
ErrorException, BoundsError, DivideError, DomainError, Exception,
InterruptException, InexactError, OutOfMemoryError, ReadOnlyMemoryError,
OverflowError, StackOverflowError, SegmentationFault, UndefRefError, UndefVarError,
TypeError, ArgumentError, MethodError, AssertionError, LoadError, InitError,
UndefKeywordError, ConcurrencyViolationError, FieldError,
# AST representation
Expr, QuoteNode, LineNumberNode, GlobalRef,
# object model functions
fieldtype, getfield, setfield!, swapfield!, modifyfield!, replacefield!, setfieldonce!,
nfields, throw, tuple, ===, isdefined,
# access to globals
getglobal, setglobal!, swapglobal!, modifyglobal!, replaceglobal!, setglobalonce!, isdefinedglobal,
# ifelse, sizeof # not exported, to avoid conflicting with Base
# type reflection
<:, typeof, isa, typeassert,
# method reflection
applicable, invoke,
# constants
nothing, Main,
# backwards compatibility
arrayref, arrayset, arraysize, const_arrayref

export
# Modules
Meta,
Expand Down
2 changes: 1 addition & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ function make_typealias(@nospecialize(x::Type))
Any === x && return nothing
x <: Tuple && return nothing
mods = modulesof!(Set{Module}(), x)
Core in mods && push!(mods, Base)
replace!(mods, Core=>Base)
aliases = Tuple{GlobalRef,SimpleVector}[]
xenv = UnionAll[]
for p in uniontypes(unwrap_unionall(x))
Expand Down
1 change: 1 addition & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@ _Atomic(jl_value_t*) *jl_table_peek_bp(jl_genericmemory_t *a, jl_value_t *key) J

JL_DLLEXPORT jl_method_t *jl_new_method_uninit(jl_module_t*);

JL_DLLEXPORT jl_module_t *jl_new_module_(jl_sym_t *name, jl_module_t *parent, uint8_t default_using_core, uint8_t self_name);
JL_DLLEXPORT jl_methtable_t *jl_new_method_table(jl_sym_t *name, jl_module_t *module);
JL_DLLEXPORT jl_method_instance_t *jl_get_specialization1(jl_tupletype_t *types JL_PROPAGATES_ROOT, size_t world, int mt_cache);
jl_method_instance_t *jl_get_specialized(jl_method_t *m, jl_value_t *types, jl_svec_t *sp) JL_PROPAGATES_ROOT;
Expand Down
26 changes: 16 additions & 10 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jl_binding_partition_t *jl_get_binding_partition_all(jl_binding_t *b, size_t min
return bpart;
}

JL_DLLEXPORT jl_module_t *jl_new_module_(jl_sym_t *name, jl_module_t *parent, uint8_t default_names)
JL_DLLEXPORT jl_module_t *jl_new_module_(jl_sym_t *name, jl_module_t *parent, uint8_t default_using_core, uint8_t self_name)
{
jl_task_t *ct = jl_current_task;
const jl_uuid_t uuid_zero = {0, 0};
Expand Down Expand Up @@ -237,20 +237,26 @@ JL_DLLEXPORT jl_module_t *jl_new_module_(jl_sym_t *name, jl_module_t *parent, ui
jl_atomic_store_relaxed(&m->bindings, jl_emptysvec);
jl_atomic_store_relaxed(&m->bindingkeyset, (jl_genericmemory_t*)jl_an_empty_memory_any);
arraylist_new(&m->usings, 0);
if (jl_core_module && default_names) {
JL_GC_PUSH1(&m);
jl_module_using(m, jl_core_module);
// export own name, so "using Foo" makes "Foo" itself visible
jl_set_const(m, name, (jl_value_t*)m);
jl_module_public(m, name, 1);
JL_GC_POP();
JL_GC_PUSH1(&m);
if (jl_core_module) {
// Bootstrap: Before jl_core_module is defined, we don't have enough infrastructure
// for bindings, so Core itself gets special handling in jltypes.c
if (default_using_core) {
jl_module_using(m, jl_core_module);
}
if (self_name) {
// export own name, so "using Foo" makes "Foo" itself visible
jl_set_const(m, name, (jl_value_t*)m);
jl_module_public(m, name, 1);
}
}
JL_GC_POP();
return m;
}

JL_DLLEXPORT jl_module_t *jl_new_module(jl_sym_t *name, jl_module_t *parent)
{
return jl_new_module_(name, parent, 1);
return jl_new_module_(name, parent, 1, 1);
}

uint32_t jl_module_next_counter(jl_module_t *m)
Expand All @@ -262,7 +268,7 @@ JL_DLLEXPORT jl_value_t *jl_f_new_module(jl_sym_t *name, uint8_t std_imports, ui
{
// TODO: should we prohibit this during incremental compilation?
// TODO: the parent module is a lie
jl_module_t *m = jl_new_module_(name, jl_main_module, default_names);
jl_module_t *m = jl_new_module_(name, jl_main_module, default_names, default_names);
JL_GC_PUSH1(&m);
if (std_imports)
jl_add_standard_imports(m);
Expand Down
5 changes: 4 additions & 1 deletion src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ static jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex
}

int is_parent__toplevel__ = jl_is__toplevel__mod(parent_module);
jl_module_t *newm = jl_new_module(name, is_parent__toplevel__ ? NULL : parent_module);
// If we have `Base`, don't also try to import `Core` - the `Base` exports are a superset.
// While we allow multiple imports of the same binding from different modules, various error printing
// performs reflection on which module a binding came from and we'd prefer users see "Base" here.
jl_module_t *newm = jl_new_module_(name, is_parent__toplevel__ ? NULL : parent_module, std_imports && jl_base_module != NULL ? 0 : 1, 1);
jl_value_t *form = (jl_value_t*)newm;
JL_GC_PUSH1(&form);
JL_LOCK(&jl_modules_mutex);
Expand Down
7 changes: 6 additions & 1 deletion test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,12 @@ end
@testset "Base docstrings" begin
undoc = Docs.undocumented_names(Base)
@test_broken isempty(undoc)
@test undoc == [:BufferStream, :CanonicalIndexError, :CapturedException, :Filesystem, :IOServer, :InvalidStateException, :Order, :PipeEndpoint, :ScopedValues, :Sort, :TTY]
@test isempty(setdiff(undoc, [:BufferStream, :CanonicalIndexError, :CapturedException, :Filesystem, :IOServer, :InvalidStateException, :Order, :PipeEndpoint, :ScopedValues, :Sort, :TTY, :AtomicMemoryRef, :Exception, :GenericMemoryRef, :GlobalRef, :IO, :LineNumberNode, :MemoryRef, :Method, :SegmentationFault, :TypeVar, :arrayref, :arrayset, :arraysize, :const_arrayref]))
end

exported_names(m) = filter(s -> Base.isexported(m, s), names(m))
@testset "Base re-exports Core" begin
@test issubset(exported_names(Core), exported_names(Base))
end

@testset "Base.Libc docstrings" begin
Expand Down