11# This file is a part of Julia. License is MIT: https://julialang.org/license
22
3- baremodule Base
3+ module Base
44
5- using Core
6- using Core. Intrinsics, Core. IR
5+ using . Core. Intrinsics, . Core. IR
76
87# to start, we're going to use a very simple definition of `include`
98# that doesn't require any function (except what we can get from the `Core` top-module)
@@ -158,6 +157,31 @@ if false
158157 println (io:: IO , x... ) = Core. println (io, x... )
159158end
160159
160+ # # Load essential files and libraries
161+ include (" essentials.jl" )
162+
163+ # Because lowering inserts direct references, it is mandatory for this binding
164+ # to exist before we start inferring code.
165+ function string end
166+ import Core: String
167+
168+ # For OS specific stuff
169+ # We need to strcat things here, before strings are really defined
170+ function strcat (x:: String , y:: String )
171+ out = ccall (:jl_alloc_string , Ref{String}, (Int,), Core. sizeof (x) + Core. sizeof (y))
172+ gc_x = @_gc_preserve_begin (x)
173+ gc_y = @_gc_preserve_begin (y)
174+ gc_out = @_gc_preserve_begin (out)
175+ out_ptr = unsafe_convert (Ptr{UInt8}, out)
176+ unsafe_copyto! (out_ptr, unsafe_convert (Ptr{UInt8}, x), Core. sizeof (x))
177+ unsafe_copyto! (out_ptr + Core. sizeof (x), unsafe_convert (Ptr{UInt8}, y), Core. sizeof (y))
178+ @_gc_preserve_end (gc_x)
179+ @_gc_preserve_end (gc_y)
180+ @_gc_preserve_end (gc_out)
181+ return out
182+ end
183+
184+
161185"""
162186 time_ns() -> UInt64
163187
@@ -172,8 +196,6 @@ const _DOCS_ALIASING_WARNING = """
172196 Behavior can be unexpected when any mutated argument shares memory with any other argument.
173197"""
174198
175- # # Load essential files and libraries
176- include (" essentials.jl" )
177199include (" ctypes.jl" )
178200include (" gcutils.jl" )
179201include (" generator.jl" )
@@ -284,7 +306,6 @@ include("rounding.jl")
284306include (" float.jl" )
285307
286308# Lazy strings
287- import Core: String
288309include (" strings/lazy.jl" )
289310
290311function cld end
@@ -321,22 +342,6 @@ using .Order
321342include (" coreir.jl" )
322343include (" invalidation.jl" )
323344
324- # Because lowering inserts direct references, it is mandatory for this binding
325- # to exist before we start inferring code.
326- function string end
327-
328- # For OS specific stuff
329- # We need to strcat things here, before strings are really defined
330- function strcat (x:: String , y:: String )
331- out = ccall (:jl_alloc_string , Ref{String}, (Csize_t,), Core. sizeof (x) + Core. sizeof (y))
332- GC. @preserve x y out begin
333- out_ptr = unsafe_convert (Ptr{UInt8}, out)
334- unsafe_copyto! (out_ptr, unsafe_convert (Ptr{UInt8}, x), Core. sizeof (x))
335- unsafe_copyto! (out_ptr + Core. sizeof (x), unsafe_convert (Ptr{UInt8}, y), Core. sizeof (y))
336- end
337- return out
338- end
339-
340345BUILDROOT:: String = " "
341346DATAROOT:: String = " "
342347const DL_LOAD_PATH = String[]
@@ -375,5 +380,5 @@ Core._setparser!(fl_parse)
375380
376381# Further definition of Base will happen in Base.jl if loaded.
377382
378- end # baremodule Base
383+ end # module Base
379384using . Base
0 commit comments