New upstream version 1.0.1
Mo Zhou
5 years ago
79 | 79 | BUILDOPTS="$BUILDOPTS USE_BINARYBUILDER_LLVM=1 LLVM_CONFIG=$TRAVIS_BUILD_DIR/usr/tools/llvm-config LLVM_SIZE=$TRAVIS_BUILD_DIR/usr/tools/llvm-size"; |
80 | 80 | BUILDOPTS="$BUILDOPTS VERBOSE=1 USE_BLAS64=0 SUITESPARSE_INC=-I$(brew --prefix suite-sparse-julia)/include FORCE_ASSERTIONS=1"; |
81 | 81 | BUILDOPTS="$BUILDOPTS LIBBLAS=-lopenblas LIBBLASNAME=libopenblas LIBLAPACK=-lopenblas LIBLAPACKNAME=libopenblas"; |
82 | for lib in SUITESPARSE BLAS LAPACK GMP MPFR PCRE LIBUNWIND; do | |
82 | for lib in SUITESPARSE BLAS LAPACK GMP MPFR LIBUNWIND; do | |
83 | 83 | BUILDOPTS="$BUILDOPTS USE_SYSTEM_$lib=1"; |
84 | 84 | done; |
85 | 85 | export LDFLAGS="-L$(brew --prefix openblas-julia)/lib -L$(brew --prefix suite-sparse-julia)/lib"; |
205 | 205 | $$(build_private_libdir)/sys$1-o.a $$(build_private_libdir)/sys$1-bc.a : $$(build_private_libdir)/sys$1-%.a : $$(build_private_libdir)/sys.ji |
206 | 206 | @$$(call PRINT_JULIA, cd $$(JULIAHOME)/base && \ |
207 | 207 | if ! $$(call spawn,$3) $2 -C "$$(JULIA_CPU_TARGET)" --output-$$* $$(call cygpath_w,$$@).tmp $$(JULIA_SYSIMG_BUILD_FLAGS) \ |
208 | --startup-file=no --warn-overwrite=yes --sysimage $$(call cygpath_w,$$<) $$(call cygpath_w,$$(JULIAHOME)/contrib/generate_precompile.jl) $$(call cygpath_w,$$<); then \ | |
208 | --startup-file=no --warn-overwrite=yes --sysimage $$(call cygpath_w,$$<) $$(call cygpath_w,$$(JULIAHOME)/contrib/generate_precompile.jl); then \ | |
209 | 209 | echo '*** This error is usually fixed by running `make clean`. If the error persists$$(COMMA) try `make cleanall`. ***'; \ |
210 | 210 | false; \ |
211 | 211 | fi ) |
22 | 22 | |
23 | 23 | Additionally, rather than sticking with the default command prompt, you may want |
24 | 24 | to use a different terminal emulator program, such as |
25 | [Conemu](https://code.google.com/p/conemu-maximus5/) or [Mintty]( | |
25 | [Conemu](https://conemu.github.io/) or [Mintty]( | |
26 | 26 | https://github.com/mintty/mintty) (note that running Julia on Mintty needs a |
27 | 27 | copy of `stty.exe` in your `%PATH%` to work properly). Alternatively, you may |
28 | 28 | prefer the features of a more full-function IDE, such as [Juno](http://junolab.org), |
43 | 43 | |
44 | 44 | julia> f(apple) |
45 | 45 | "I'm a Fruit with value: 1" |
46 | ||
47 | julia> Fruit(1) | |
48 | apple::Fruit = 1 | |
46 | 49 | ``` |
47 | 50 | |
48 | 51 | Values can also be specified inside a `begin` block, e.g. |
99 | 102 | length(s.args) == 2 && isa(s.args[1], Symbol) |
100 | 103 | i = Core.eval(__module__, s.args[2]) # allow exprs, e.g. uint128"1" |
101 | 104 | if !isa(i, Integer) |
102 | throw(ArgumentError("invalid value for Enum $typename, $s=$i; values must be integers")) | |
105 | throw(ArgumentError("invalid value for Enum $typename, $s; values must be integers")) | |
103 | 106 | end |
104 | 107 | i = convert(basetype, i) |
105 | 108 | s = s.args[1] |
225 | 225 | <=(l::AbstractSet, r::AbstractSet) = l ⊆ r |
226 | 226 | |
227 | 227 | function issubset(l, r) |
228 | ||
229 | rlen = length(r) | |
230 | #This threshold was empirically determined by repeatedly | |
231 | #sampling using these two methods. | |
232 | lenthresh = 70 | |
233 | ||
234 | if rlen > lenthresh && !isa(r, AbstractSet) | |
235 | return issubset(l, Set(r)) | |
228 | if haslength(r) | |
229 | rlen = length(r) | |
230 | #This threshold was empirically determined by repeatedly | |
231 | #sampling using these two methods (see #26198) | |
232 | lenthresh = 70 | |
233 | ||
234 | if rlen > lenthresh && !isa(r, AbstractSet) | |
235 | return issubset(l, Set(r)) | |
236 | end | |
236 | 237 | end |
237 | 238 | |
238 | 239 | for elt in l |
190 | 190 | accumulate(op, A; dims::Integer, [init]) |
191 | 191 | |
192 | 192 | Cumulative operation `op` along the dimension `dims` of `A` (providing `dims` is optional |
193 | for vectors). An inital value `init` may optionally be privided by a keyword argument. See | |
193 | for vectors). An initial value `init` may optionally be provided by a keyword argument. See | |
194 | 194 | also [`accumulate!`](@ref) to use a preallocated output array, both for performance and |
195 | 195 | to control the precision of the output (e.g. to avoid overflow). For common operations |
196 | 196 | there are specialized variants of `accumulate`, see: [`cumsum`](@ref), [`cumprod`](@ref) |
887 | 887 | ``` |
888 | 888 | |
889 | 889 | Use [`push!`](@ref) to add individual items to `collection` which are not already |
890 | themselves in another collection. The result is of the preceding example is equivalent to | |
890 | themselves in another collection. The result of the preceding example is equivalent to | |
891 | 891 | `push!([1, 2, 3], 4, 5, 6)`. |
892 | 892 | """ |
893 | 893 | function append!(a::Array{<:Any,1}, items::AbstractVector) |
712 | 712 | Note that `dest` is only used to store the result, and does not supply |
713 | 713 | arguments to `f` unless it is also listed in the `As`, |
714 | 714 | as in `broadcast!(f, A, A, B)` to perform `A[:] = broadcast(f, A, B)`. |
715 | ||
716 | # Examples | |
717 | ```jldoctest | |
718 | julia> A = [1.0; 0.0]; B = [0.0; 0.0]; | |
719 | ||
720 | julia> broadcast!(+, B, A, (0, -2.0)); | |
721 | ||
722 | julia> B | |
723 | 2-element Array{Float64,1}: | |
724 | 1.0 | |
725 | -2.0 | |
726 | ||
727 | julia> A | |
728 | 2-element Array{Float64,1}: | |
729 | 1.0 | |
730 | 0.0 | |
731 | ||
732 | julia> broadcast!(+, A, A, (0, -2.0)); | |
733 | ||
734 | julia> A | |
735 | 2-element Array{Float64,1}: | |
736 | 1.0 | |
737 | -2.0 | |
738 | ``` | |
715 | 739 | """ |
716 | 740 | broadcast!(f::Tf, dest, As::Vararg{Any,N}) where {Tf,N} = (materialize!(dest, broadcasted(f, As...)); dest) |
717 | 741 |
31 | 31 | end |
32 | 32 | end |
33 | 33 | |
34 | If you want just a post-expression, supply `nothing` for the pre-expression. Using | |
34 | If you want just a post-expression, supply [`nothing`](@ref) for the pre-expression. Using | |
35 | 35 | parentheses and semicolons, you can supply multi-statement expressions. |
36 | 36 | """ |
37 | 37 | macro nloops(N, itersym, rangeexpr, args...) |
55 | 55 | # If it's intended to simulate `cd`, it should instead be doing |
56 | 56 | # more nearly `cd $dir && printf %s \$PWD` (with appropriate quoting), |
57 | 57 | # since shell `cd` does more than just `echo` the result. |
58 | dir = read(`$shell -c "printf %s $(shell_escape_posixly(dir))"`, String) | |
58 | dir = read(`$shell -c "printf '%s' $(shell_escape_posixly(dir))"`, String) | |
59 | 59 | end |
60 | 60 | cd(dir) |
61 | 61 | end |
54 | 54 | rettype = Bottom |
55 | 55 | edgecycle = false |
56 | 56 | edges = Any[] |
57 | nonbot = 0 # the index of the only non-Bottom inference result if > 0 | |
58 | seen = 0 # number of signatures actually inferred | |
57 | 59 | for i in 1:napplicable |
58 | 60 | match = applicable[i]::SimpleVector |
59 | 61 | method = match[3]::Method |
60 | 62 | sig = match[1] |
61 | 63 | sigtuple = unwrap_unionall(sig)::DataType |
62 | 64 | splitunions = false |
65 | this_rt = Bottom | |
63 | 66 | # TODO: splitunions = 1 < countunionsplit(sigtuple.parameters) * napplicable <= sv.params.MAX_UNION_SPLITTING |
64 | 67 | # currently this triggers a bug in inference recursion detection |
65 | 68 | if splitunions |
70 | 73 | push!(edges, edge) |
71 | 74 | end |
72 | 75 | edgecycle |= edgecycle1::Bool |
73 | rettype = tmerge(rettype, rt) | |
74 | rettype === Any && break | |
75 | end | |
76 | rettype === Any && break | |
76 | this_rt = tmerge(this_rt, rt) | |
77 | this_rt === Any && break | |
78 | end | |
77 | 79 | else |
78 | rt, edgecycle, edge = abstract_call_method(method, sig, match[2]::SimpleVector, sv) | |
80 | this_rt, edgecycle, edge = abstract_call_method(method, sig, match[2]::SimpleVector, sv) | |
79 | 81 | if edge !== nothing |
80 | 82 | push!(edges, edge) |
81 | 83 | end |
82 | rettype = tmerge(rettype, rt) | |
83 | rettype === Any && break | |
84 | end | |
85 | end | |
86 | if napplicable == 1 && !edgecycle && isa(rettype, Type) && sv.params.ipo_constant_propagation | |
84 | end | |
85 | if this_rt !== Bottom | |
86 | if nonbot === 0 | |
87 | nonbot = i | |
88 | else | |
89 | nonbot = -1 | |
90 | end | |
91 | end | |
92 | seen += 1 | |
93 | rettype = tmerge(rettype, this_rt) | |
94 | rettype === Any && break | |
95 | end | |
96 | # try constant propagation if only 1 method is inferred to non-Bottom | |
97 | if nonbot > 0 && seen == napplicable && !edgecycle && isa(rettype, Type) && sv.params.ipo_constant_propagation | |
87 | 98 | # if there's a possibility we could constant-propagate a better result |
88 | 99 | # (hopefully without doing too much work), try to do that now |
89 | 100 | # TODO: it feels like this could be better integrated into abstract_call_method / typeinf_edge |
90 | const_rettype = abstract_call_method_with_const_args(f, argtypes, applicable[1]::SimpleVector, sv) | |
101 | const_rettype = abstract_call_method_with_const_args(f, argtypes, applicable[nonbot]::SimpleVector, sv) | |
91 | 102 | if const_rettype ⊑ rettype |
92 | 103 | # use the better result, if it's a refinement of rettype |
93 | 104 | rettype = const_rettype |
326 | 326 | bb_idx = 1 |
327 | 327 | new_nodes = code.new_nodes |
328 | 328 | if any(i -> !isassigned(code.new_nodes, i), 1:length(code.new_nodes)) |
329 | printstyled(io, :red, "ERROR: New node array has unset entry\n") | |
329 | printstyled(io, "ERROR: New node array has unset entry\n", color=:red) | |
330 | 330 | new_nodes = new_nodes[filter(i -> isassigned(code.new_nodes, i), 1:length(code.new_nodes))] |
331 | 331 | end |
332 | 332 | for nn in new_nodes |
353 | 353 | if !isassigned(stmts, idx) |
354 | 354 | # This is invalid, but do something useful rather |
355 | 355 | # than erroring, to make debugging easier |
356 | printstyled(io, :red, "#UNDEF\n") | |
356 | printstyled(io, "#UNDEF\n", color=:red) | |
357 | 357 | continue |
358 | 358 | end |
359 | 359 | stmt = stmts[idx] |
494 | 494 | if !isassigned(stmts, idx) |
495 | 495 | # This is invalid, but do something useful rather |
496 | 496 | # than erroring, to make debugging easier |
497 | printstyled(io, :red, "#UNDEF\n") | |
497 | printstyled(io, "#UNDEF\n", color=:red) | |
498 | 498 | continue |
499 | 499 | end |
500 | 500 | stmt = stmts[idx] |
536 | 536 | sv = s00.val |
537 | 537 | end |
538 | 538 | if isa(name, Const) |
539 | (isa(sv, Module) && isa(name.val, Symbol)) || return false | |
540 | (isa(name.val, Symbol) || isa(name.val, Int)) || return false | |
539 | if !isa(name.val, Symbol) | |
540 | isa(sv, Module) && return false | |
541 | isa(name.val, Int) || return false | |
542 | end | |
541 | 543 | return isdefined(sv, name.val) |
542 | 544 | end |
543 | 545 | if bounds_check_disabled && !isa(sv, Module) |
1055 | 1057 | length(argtypes) == 1 || return false |
1056 | 1058 | return sizeof_nothrow(argtypes[1]) |
1057 | 1059 | elseif f === Core.kwfunc |
1058 | length(argtypes) == 2 || return false | |
1060 | length(argtypes) == 1 || return false | |
1059 | 1061 | return isa(rt, Const) |
1060 | 1062 | end |
1061 | 1063 | return false |
411 | 411 | for loop_b = (false, true) |
412 | 412 | for i = (lt + 1):(loop_b ? lbr : lar) |
413 | 413 | ti = unwrapva(loop_b ? bp[i] : ap[i]) |
414 | while ti isa TypeVar | |
415 | ti = ti.ub | |
416 | end | |
414 | 417 | # compare (ti <-> tail), (wrapper ti <-> tail), (ti <-> wrapper tail), then (wrapper ti <-> wrapper tail) |
415 | 418 | # until we find the first element that contains the other in the pair |
416 | 419 | # TODO: this result would be more stable (and more associative and more commutative) |
121 | 121 | end |
122 | 122 | |
123 | 123 | function code_for_method(method::Method, @nospecialize(atypes), sparams::SimpleVector, world::UInt, preexisting::Bool=false) |
124 | if world < min_world(method) | |
124 | if world < min_world(method) || world > max_world(method) | |
125 | 125 | return nothing |
126 | 126 | end |
127 | 127 | if isdefined(method, :generator) && !isdispatchtuple(atypes) |
280 | 280 | ismacro ? macroname(x) : x |
281 | 281 | # Call overloading, e.g. `(a::A)(b) = b` or `function (a::A)(b) b end` should document `A(b)` |
282 | 282 | elseif (isexpr(x, :function) || isexpr(x, :(=))) && isexpr(x.args[1], :call) && isexpr(x.args[1].args[1], :(::)) |
283 | return astname(x.args[1].args[1].args[2], ismacro) | |
283 | return astname(x.args[1].args[1].args[end], ismacro) | |
284 | 284 | else |
285 | 285 | n = isexpr(x, (:module, :struct)) ? 2 : 1 |
286 | 286 | astname(x.args[n], ismacro) |
259 | 259 | """ |
260 | 260 | const |
261 | 261 | |
262 | `const` is used to declare global variables which are also constant. In almost all code | |
262 | `const` is used to declare global variables whose values will not change. In almost all code | |
263 | 263 | (and particularly performance sensitive code) global variables should be declared |
264 | 264 | constant in this way. |
265 | 265 | |
274 | 274 | |
275 | 275 | Note that `const` only applies to one `=` operation, therefore `const x = y = 1` |
276 | 276 | declares `x` to be constant but not `y`. On the other hand, `const x = const y = 1` |
277 | declares both `x` and `y` as constants. | |
278 | ||
279 | Note that "constant-ness" is not enforced inside containers, so if `x` is an array or | |
280 | dictionary (for example) you can still add and remove elements. | |
281 | ||
282 | Technically, you can even redefine `const` variables, although this will generate a | |
283 | warning from the compiler. The only strict requirement is that the *type* of the | |
284 | variable does not change, which is why `const` variables are much faster than regular | |
285 | globals. | |
277 | declares both `x` and `y` constant. | |
278 | ||
279 | Note that "constant-ness" does not extend into mutable containers; only the | |
280 | association between a variable and its value is constant. | |
281 | If `x` is an array or dictionary (for example) you can still modify, add, or remove elements. | |
282 | ||
283 | In some cases changing the value of a `const` variable gives a warning instead of | |
284 | an error. | |
285 | However, this can produce unpredictable behavior or corrupt the state of your program, | |
286 | and so should be avoided. | |
287 | This feature is intended only for convenience during interactive use. | |
286 | 288 | """ |
287 | 289 | kw"const" |
288 | 290 | |
854 | 856 | WrappedException(msg) |
855 | 857 | |
856 | 858 | Generic type for `Exception`s wrapping another `Exception`, such as `LoadError` and |
857 | `InitError`. Those exceptions contain information about the the root cause of an | |
859 | `InitError`. Those exceptions contain information about the root cause of an | |
858 | 860 | exception. Subtypes define a field `error` containing the causing `Exception`. |
859 | 861 | """ |
860 | 862 | Core.WrappedException |
1081 | 1083 | applicable(f, args...) -> Bool |
1082 | 1084 | |
1083 | 1085 | Determine whether the given generic function has a method applicable to the given arguments. |
1086 | ||
1087 | See also [`hasmethod`](@ref). | |
1084 | 1088 | |
1085 | 1089 | # Examples |
1086 | 1090 | ```jldoctest |
1 | 1 | |
2 | 2 | # file downloading |
3 | 3 | |
4 | downloadcmd = nothing | |
5 | 4 | if Sys.iswindows() |
6 | downloadcmd = "powershell" | |
7 | 5 | function download(url::AbstractString, filename::AbstractString) |
8 | 6 | ps = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" |
9 | 7 | tls12 = "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12" |
24 | 22 | end |
25 | 23 | else |
26 | 24 | function download(url::AbstractString, filename::AbstractString) |
27 | global downloadcmd | |
28 | if downloadcmd === nothing | |
29 | for checkcmd in ("curl", "wget", "fetch") | |
30 | try | |
31 | # Sys.which() will throw() if it can't find `checkcmd` | |
32 | Sys.which(checkcmd) | |
33 | downloadcmd = checkcmd | |
34 | break | |
35 | catch | |
36 | end | |
37 | end | |
38 | end | |
39 | if downloadcmd == "wget" | |
25 | if Sys.which("curl") !== nothing | |
26 | run(`curl -g -L -f -o $filename $url`) | |
27 | elseif Sys.which("wget") !== nothing | |
40 | 28 | try |
41 | 29 | run(`wget -O $filename $url`) |
42 | 30 | catch |
43 | rm(filename) # wget always creates a file | |
31 | rm(filename, force=true) # wget always creates a file | |
44 | 32 | rethrow() |
45 | 33 | end |
46 | elseif downloadcmd == "curl" | |
47 | run(`curl -g -L -f -o $filename $url`) | |
48 | elseif downloadcmd == "fetch" | |
34 | elseif Sys.which("fetch") !== nothing | |
49 | 35 | run(`fetch -f $filename $url`) |
50 | 36 | else |
51 | 37 | error("no download agent available; install curl, wget, or fetch") |
431 | 431 | end |
432 | 432 | if ex.world < min_world(method) |
433 | 433 | print(iob, " (method too new to be called from this world context.)") |
434 | elseif ex.world > max_world(method) | |
435 | print(iob, " (method deleted before this world age.)") | |
434 | 436 | end |
435 | 437 | # TODO: indicate if it's in the wrong world |
436 | 438 | push!(lines, (buf, right_matches)) |
78 | 78 | @specialize |
79 | 79 | |
80 | 80 | Reset the specialization hint for an argument back to the default. |
81 | For details, see [`@specialize`](@ref). | |
81 | For details, see [`@nospecialize`](@ref). | |
82 | 82 | """ |
83 | 83 | macro specialize(vars...) |
84 | 84 | if nfields(vars) === 1 |
263 | 263 | end |
264 | 264 | typename(union::UnionAll) = typename(union.body) |
265 | 265 | |
266 | convert(::Type{T}, x::T) where {T<:Tuple{Any, Vararg{Any}}} = x | |
267 | convert(::Type{Tuple{}}, x::Tuple{Any, Vararg{Any}}) = throw(MethodError(convert, (Tuple{}, x))) | |
268 | convert(::Type{T}, x::Tuple{Any, Vararg{Any}}) where {T<:Tuple} = | |
266 | const AtLeast1 = Tuple{Any, Vararg{Any}} | |
267 | ||
268 | # converting to empty tuple type | |
269 | convert(::Type{Tuple{}}, ::Tuple{}) = () | |
270 | convert(::Type{Tuple{}}, x::AtLeast1) = throw(MethodError(convert, (Tuple{}, x))) | |
271 | ||
272 | # converting to tuple types with at least one element | |
273 | convert(::Type{T}, x::T) where {T<:AtLeast1} = x | |
274 | convert(::Type{T}, x::AtLeast1) where {T<:AtLeast1} = | |
269 | 275 | (convert(tuple_type_head(T), x[1]), convert(tuple_type_tail(T), tail(x))...) |
276 | ||
277 | # converting to Vararg tuple types | |
278 | convert(::Type{Tuple{Vararg{V}}}, x::Tuple{Vararg{V}}) where {V} = x | |
279 | convert(T::Type{Tuple{Vararg{V}}}, x::Tuple) where {V} = | |
280 | (convert(tuple_type_head(T), x[1]), convert(T, tail(x))...) | |
270 | 281 | |
271 | 282 | # TODO: the following definitions are equivalent (behaviorally) to the above method |
272 | 283 | # I think they may be faster / more efficient for inference, |
794 | 805 | iterate(iter [, state]) -> Union{Nothing, Tuple{Any, Any}} |
795 | 806 | |
796 | 807 | Advance the iterator to obtain the next element. If no elements |
797 | remain, nothing should be returned. Otherwise, a 2-tuple of the | |
808 | remain, `nothing` should be returned. Otherwise, a 2-tuple of the | |
798 | 809 | next element and the new iteration state should be returned. |
799 | 810 | """ |
800 | 811 | function iterate end |
316 | 316 | """ |
317 | 317 | cp(src::AbstractString, dst::AbstractString; force::Bool=false, follow_symlinks::Bool=false) |
318 | 318 | |
319 | Copy the file, link, or directory from `src` to `dest`. | |
319 | Copy the file, link, or directory from `src` to `dst`. | |
320 | 320 | `force=true` will first remove an existing `dst`. |
321 | 321 | |
322 | 322 | If `follow_symlinks=false`, and `src` is a symbolic link, `dst` will be created as a |
125 | 125 | IteratorEltype(::Type{Generator{I,T}}) where {I,T} = EltypeUnknown() |
126 | 126 | |
127 | 127 | IteratorEltype(::Type{Any}) = EltypeUnknown() |
128 | IteratorEltype(::Type{Union{}}) = EltypeUnknown() |
486 | 486 | |
487 | 487 | divrem(x::BigInt, y::BigInt) = MPZ.tdiv_qr(x, y) |
488 | 488 | |
489 | cmp(x::BigInt, y::BigInt) = MPZ.cmp(x, y) | |
490 | cmp(x::BigInt, y::ClongMax) = MPZ.cmp_si(x, y) | |
491 | cmp(x::BigInt, y::CulongMax) = MPZ.cmp_ui(x, y) | |
489 | cmp(x::BigInt, y::BigInt) = sign(MPZ.cmp(x, y)) | |
490 | cmp(x::BigInt, y::ClongMax) = sign(MPZ.cmp_si(x, y)) | |
491 | cmp(x::BigInt, y::CulongMax) = sign(MPZ.cmp_ui(x, y)) | |
492 | 492 | cmp(x::BigInt, y::Integer) = cmp(x, big(y)) |
493 | 493 | cmp(x::Integer, y::BigInt) = -cmp(y, x) |
494 | 494 | |
495 | cmp(x::BigInt, y::CdoubleMax) = isnan(y) ? -1 : MPZ.cmp_d(x, y) | |
495 | cmp(x::BigInt, y::CdoubleMax) = isnan(y) ? -1 : sign(MPZ.cmp_d(x, y)) | |
496 | 496 | cmp(x::CdoubleMax, y::BigInt) = -cmp(y, x) |
497 | 497 | |
498 | 498 | isqrt(x::BigInt) = MPZ.sqrt(x) |
12 | 12 | ## Traits for array types ## |
13 | 13 | |
14 | 14 | abstract type IndexStyle end |
15 | """ | |
16 | IndexLinear() | |
17 | ||
18 | Subtype of [`IndexStyle`](@ref) used to describe arrays which | |
19 | are optimally indexed by one linear index. | |
20 | ||
21 | A linear indexing style uses one integer to describe the position in the array | |
22 | (even if it's a multidimensional array) and column-major | |
23 | ordering is used to access the elements. For example, | |
24 | if `A` were a `(2, 3)` custom matrix type with linear indexing, | |
25 | and we referenced `A[5]` (using linear style), this would | |
26 | be equivalent to referencing `A[1, 3]` (since `2*1 + 3 = 5`). | |
27 | See also [`IndexCartesian`](@ref). | |
28 | """ | |
15 | 29 | struct IndexLinear <: IndexStyle end |
30 | """ | |
31 | IndexCartesian() | |
32 | ||
33 | Subtype of [`IndexStyle`](@ref) used to describe arrays which | |
34 | are optimally indexed by a Cartesian index. | |
35 | ||
36 | A cartesian indexing style uses multiple integers/indices to describe the position in the array. | |
37 | For example, if `A` were a `(2, 3, 4)` custom matrix type with cartesian indexing, | |
38 | we could reference `A[2, 1, 3]` and Julia would automatically convert this into the | |
39 | correct location in the underlying memory. See also [`IndexLinear`](@ref). | |
40 | """ | |
16 | 41 | struct IndexCartesian <: IndexStyle end |
17 | 42 | |
18 | 43 | """ |
20 | 45 | IndexStyle(typeof(A)) |
21 | 46 | |
22 | 47 | `IndexStyle` specifies the "native indexing style" for array `A`. When |
23 | you define a new `AbstractArray` type, you can choose to implement | |
24 | either linear indexing or cartesian indexing. If you decide to | |
25 | implement linear indexing, then you must set this trait for your array | |
48 | you define a new [`AbstractArray`](@ref) type, you can choose to implement | |
49 | either linear indexing (with [`IndexLinear`](@ref)) or cartesian indexing. | |
50 | If you decide to implement linear indexing, then you must set this trait for your array | |
26 | 51 | type: |
27 | 52 | |
28 | 53 | Base.IndexStyle(::Type{<:MyArray}) = IndexLinear() |
29 | 54 | |
30 | The default is `IndexCartesian()`. | |
55 | The default is [`IndexCartesian()`](@ref). | |
31 | 56 | |
32 | 57 | Julia's internal indexing machinery will automatically (and invisibly) |
33 | 58 | convert all indexing operations into the preferred style. This allows users |
329 | 354 | |
330 | 355 | LinearIndices(inds::CartesianIndices) -> R |
331 | 356 | LinearIndices(sz::Dims) -> R |
332 | LinearIndices(istart:istop, jstart:jstop, ...) -> R | |
357 | LinearIndices((istart:istop, jstart:jstop, ...)) -> R | |
333 | 358 | |
334 | 359 | Return a `LinearIndices` array with the specified shape or [`axes`](@ref). |
335 | 360 |
137 | 137 | unsafe_string(Base.JLOptions().project) : |
138 | 138 | get(ENV, "JULIA_PROJECT", nothing)) |
139 | 139 | HOME_PROJECT[] = |
140 | project == nothing ? nothing : | |
140 | 141 | project == "" ? nothing : |
141 | project == "@." ? current_project() : project | |
142 | project == "@." ? current_project() : abspath(project) | |
142 | 143 | append!(empty!(LOAD_PATH), paths) |
143 | 144 | end |
144 | 145 |
578 | 578 | @big_str str |
579 | 579 | @big_str(str) |
580 | 580 | |
581 | `@big_str` parses a string into a BigInt | |
582 | Throws an `ArgumentError` if the string is not a valid integer | |
583 | Removes all underscores `_` from the string | |
581 | Parse a string into a [`BigInt`](@ref) or [`BigFloat`](@ref), | |
582 | and throw an `ArgumentError` if the string is not a valid number. | |
583 | For integers `_` is allowed in the string as a separator. | |
584 | ||
585 | # Examples | |
586 | ```jldoctest | |
587 | julia> big"123_456" | |
588 | 123456 | |
589 | ||
590 | julia> big"7891.5" | |
591 | 7.8915e+03 | |
592 | ``` | |
584 | 593 | """ |
585 | 594 | macro big_str(s) |
586 | 595 | if '_' in s |
439 | 439 | return d |
440 | 440 | end |
441 | 441 | |
442 | ndigits0znb(x::Unsigned, b::Integer) = ndigits0znb(signed(x), b) | |
442 | # do first division before conversion with signed here, which can otherwise overflow | |
443 | ndigits0znb(x::Unsigned, b::Integer) = ndigits0znb(-signed(fld(x, -b)), b) + (x != 0) | |
443 | 444 | ndigits0znb(x::Bool, b::Integer) = x % Int |
444 | 445 | |
445 | 446 | # The suffix "pb" stands for "positive base" |
542 | 543 | i = neg + max(pad,sizeof(x)<<3-leading_zeros(x)) |
543 | 544 | a = StringVector(i) |
544 | 545 | while i > neg |
545 | a[i] = '0'+(x&0x1) | |
546 | @inbounds a[i] = 48+(x&0x1) | |
546 | 547 | x >>= 1 |
547 | 548 | i -= 1 |
548 | 549 | end |
549 | if neg; a[1]='-'; end | |
550 | if neg; @inbounds a[1]=0x2d; end | |
550 | 551 | String(a) |
551 | 552 | end |
552 | 553 | |
554 | 555 | i = neg + max(pad,div((sizeof(x)<<3)-leading_zeros(x)+2,3)) |
555 | 556 | a = StringVector(i) |
556 | 557 | while i > neg |
557 | a[i] = '0'+(x&0x7) | |
558 | @inbounds a[i] = 48+(x&0x7) | |
558 | 559 | x >>= 3 |
559 | 560 | i -= 1 |
560 | 561 | end |
561 | if neg; a[1]='-'; end | |
562 | if neg; @inbounds a[1]=0x2d; end | |
562 | 563 | String(a) |
563 | 564 | end |
564 | 565 | |
566 | 567 | i = neg + ndigits(x, base=10, pad=pad) |
567 | 568 | a = StringVector(i) |
568 | 569 | while i > neg |
569 | a[i] = '0'+rem(x,10) | |
570 | @inbounds a[i] = 48+rem(x,10) | |
570 | 571 | x = oftype(x,div(x,10)) |
571 | 572 | i -= 1 |
572 | 573 | end |
573 | if neg; a[1]='-'; end | |
574 | if neg; @inbounds a[1]=0x2d; end | |
574 | 575 | String(a) |
575 | 576 | end |
576 | 577 | |
579 | 580 | a = StringVector(i) |
580 | 581 | while i > neg |
581 | 582 | d = x & 0xf |
582 | a[i] = '0'+d+39*(d>9) | |
583 | @inbounds a[i] = 48+d+39*(d>9) | |
583 | 584 | x >>= 4 |
584 | 585 | i -= 1 |
585 | 586 | end |
586 | if neg; a[1]='-'; end | |
587 | if neg; @inbounds a[1]=0x2d; end | |
587 | 588 | String(a) |
588 | 589 | end |
589 | 590 |
164 | 164 | throw(EOFError()) |
165 | 165 | end |
166 | 166 | nothing |
167 | end | |
168 | ||
169 | function read(from::GenericIOBuffer, T::Union{Type{Int16},Type{UInt16},Type{Int32},Type{UInt32},Type{Int64},Type{UInt64},Type{Int128},Type{UInt128},Type{Float16},Type{Float32},Type{Float64}}) | |
170 | from.readable || throw(ArgumentError("read failed, IOBuffer is not readable")) | |
171 | avail = bytesavailable(from) | |
172 | nb = sizeof(T) | |
173 | if nb > avail | |
174 | throw(EOFError()) | |
175 | end | |
176 | GC.@preserve from begin | |
177 | ptr::Ptr{T} = pointer(from.data, from.ptr) | |
178 | x = unsafe_load(ptr) | |
179 | end | |
180 | from.ptr += nb | |
181 | return x | |
167 | 182 | end |
168 | 183 | |
169 | 184 | function read_sub(from::GenericIOBuffer, a::AbstractArray{T}, offs, nel) where T |
400 | 400 | function read(s::IOStream, T::Union{Type{Int16},Type{UInt16},Type{Int32},Type{UInt32},Type{Int64},Type{UInt64}}) |
401 | 401 | return ccall(:jl_ios_get_nbyte_int, UInt64, (Ptr{Cvoid}, Csize_t), s.ios, sizeof(T)) % T |
402 | 402 | end |
403 | ||
404 | read(s::IOStream, ::Type{Float16}) = reinterpret(Float16, read(s, Int16)) | |
405 | read(s::IOStream, ::Type{Float32}) = reinterpret(Float32, read(s, Int32)) | |
406 | read(s::IOStream, ::Type{Float64}) = reinterpret(Float64, read(s, Int64)) | |
403 | 407 | end |
404 | 408 | |
405 | 409 | function unsafe_read(s::IOStream, p::Ptr{UInt8}, nb::UInt) |
180 | 180 | for `A`, while `enumerate` always counts from 1 regardless of the indices |
181 | 181 | of `A`. |
182 | 182 | |
183 | Specifying `IndexLinear()` ensures that `i` will be an integer; | |
184 | specifying `IndexCartesian()` ensures that `i` will be a | |
185 | `CartesianIndex`; specifying `IndexStyle(A)` chooses whichever has | |
183 | Specifying [`IndexLinear()`](@ref) ensures that `i` will be an integer; | |
184 | specifying [`IndexCartesian()`](@ref) ensures that `i` will be a | |
185 | [`CartesianIndex`](@ref); specifying `IndexStyle(A)` chooses whichever has | |
186 | 186 | been defined as the native indexing style for array `A`. |
187 | 187 | |
188 | 188 | Mutation of the bounds of the underlying array will invalidate this iterator. |
879 | 879 | flatten_iteratorsize(::Union{HasShape, HasLength}, ::Type{<:NTuple{N,Any}}) where {N} = HasLength() |
880 | 880 | flatten_iteratorsize(::Union{HasShape, HasLength}, ::Type{<:Tuple}) = SizeUnknown() |
881 | 881 | flatten_iteratorsize(::Union{HasShape, HasLength}, ::Type{<:Number}) = HasLength() |
882 | flatten_iteratorsize(::Union{HasShape, HasLength}, ::Type{Union{}}) = SizeUnknown() | |
882 | 883 | flatten_iteratorsize(a, b) = SizeUnknown() |
883 | 884 | |
884 | 885 | _flatten_iteratorsize(sz, ::EltypeUnknown, I) = SizeUnknown() |
253 | 253 | |
254 | 254 | Return the path of `m.jl` file that was used to `import` module `m`, |
255 | 255 | or `nothing` if `m` was not imported from a package. |
256 | ||
257 | Use [`dirname`](@ref) to get the directory part and [`basename`](@ref) | |
258 | to get the file name part of the path. | |
256 | 259 | """ |
257 | 260 | function pathof(m::Module) |
258 | 261 | pkgid = get(Base.module_keys, m, nothing) |
815 | 818 | if where.uuid === nothing |
816 | 819 | throw(ArgumentError(""" |
817 | 820 | Package $mod not found in current path: |
818 | - Run `Pkg.add($(repr(String(mod))))` to install the $mod package. | |
821 | - Run `import Pkg; Pkg.add($(repr(String(mod))))` to install the $mod package. | |
819 | 822 | """)) |
820 | 823 | else |
821 | 824 | s = """ |
495 | 495 | current_logger() |
496 | 496 | |
497 | 497 | Return the logger for the current task, or the global logger if none is |
498 | is attached to the task. | |
498 | attached to the task. | |
499 | 499 | """ |
500 | 500 | current_logger() = current_logstate().logger |
501 | 501 |
26 | 26 | |
27 | 27 | using .Base: IEEEFloat |
28 | 28 | |
29 | @noinline function throw_complex_domainerror(f, x) | |
29 | @noinline function throw_complex_domainerror(f::Symbol, x) | |
30 | 30 | throw(DomainError(x, string("$f will only return a complex result if called with a ", |
31 | 31 | "complex argument. Try $f(Complex(x))."))) |
32 | 32 | end |
197 | 197 | 0.5 |
198 | 198 | |
199 | 199 | julia> log(-2, 3) |
200 | ERROR: DomainError with log: | |
201 | -2.0 will only return a complex result if called with a complex argument. Try -2.0(Complex(x)). | |
200 | ERROR: DomainError with -2.0: | |
201 | log will only return a complex result if called with a complex argument. Try log(Complex(x)). | |
202 | 202 | Stacktrace: |
203 | [1] throw_complex_domainerror(::Float64, ::Symbol) at ./math.jl:31 | |
203 | [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31 | |
204 | 204 | [...] |
205 | 205 | |
206 | 206 | julia> log(2, -3) |
207 | ERROR: DomainError with log: | |
208 | -3.0 will only return a complex result if called with a complex argument. Try -3.0(Complex(x)). | |
207 | ERROR: DomainError with -3.0: | |
208 | log will only return a complex result if called with a complex argument. Try log(Complex(x)). | |
209 | 209 | Stacktrace: |
210 | [1] throw_complex_domainerror(::Float64, ::Symbol) at ./math.jl:31 | |
210 | [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31 | |
211 | 211 | [...] |
212 | 212 | ``` |
213 | 213 | |
392 | 392 | |
393 | 393 | Compute the natural logarithm of `x`. Throws [`DomainError`](@ref) for negative |
394 | 394 | [`Real`](@ref) arguments. Use complex negative arguments to obtain complex results. |
395 | ||
396 | # Examples | |
397 | ```jldoctest; filter = r"Stacktrace:(\\n \\[[0-9]+\\].*)*" | |
398 | julia> log(2) | |
399 | 0.6931471805599453 | |
400 | ||
401 | julia> log(-3) | |
402 | ERROR: DomainError with -3.0: | |
403 | log will only return a complex result if called with a complex argument. Try log(Complex(x)). | |
404 | Stacktrace: | |
405 | [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31 | |
406 | [...] | |
407 | ``` | |
395 | 408 | """ |
396 | 409 | log(x::Number) |
397 | 410 | |
458 | 471 | 0.0 |
459 | 472 | |
460 | 473 | julia> log1p(-2) |
461 | ERROR: DomainError with log1p: | |
462 | -2.0 will only return a complex result if called with a complex argument. Try -2.0(Complex(x)). | |
474 | ERROR: DomainError with -2.0: | |
475 | log1p will only return a complex result if called with a complex argument. Try log1p(Complex(x)). | |
463 | 476 | Stacktrace: |
464 | [1] throw_complex_domainerror(::Float64, ::Symbol) at ./math.jl:31 | |
477 | [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31 | |
465 | 478 | [...] |
466 | 479 | ``` |
467 | 480 | """ |
708 | 721 | without any intermediate rounding. |
709 | 722 | |
710 | 723 | - if `r == RoundNearest`, then the result is exact, and in the interval |
711 | ``[-|y|/2, |y|/2]``. | |
724 | ``[-|y|/2, |y|/2]``. See also [`RoundNearest`](@ref). | |
712 | 725 | |
713 | 726 | - if `r == RoundToZero` (default), then the result is exact, and in the interval |
714 | ``[0, |y|)`` if `x` is positive, or ``(-|y|, 0]`` otherwise. | |
727 | ``[0, |y|)`` if `x` is positive, or ``(-|y|, 0]`` otherwise. See also [`RoundToZero`](@ref). | |
715 | 728 | |
716 | 729 | - if `r == RoundDown`, then the result is in the interval ``[0, y)`` if `y` is positive, or |
717 | 730 | ``(y, 0]`` otherwise. The result may not be exact if `x` and `y` have different signs, and |
718 | `abs(x) < abs(y)`. | |
731 | `abs(x) < abs(y)`. See also[`RoundDown`](@ref). | |
719 | 732 | |
720 | 733 | - if `r == RoundUp`, then the result is in the interval `(-y,0]` if `y` is positive, or |
721 | 734 | `[0,-y)` otherwise. The result may not be exact if `x` and `y` have the same sign, and |
722 | `abs(x) < abs(y)`. | |
735 | `abs(x) < abs(y)`. See also [`RoundUp`](@ref). | |
723 | 736 | |
724 | 737 | """ |
725 | 738 | rem(x, y, ::RoundingMode{:ToZero}) = rem(x,y) |
819 | 832 | 2π, and so will give a more accurate result than `rem(x,2π,r)` |
820 | 833 | |
821 | 834 | - if `r == RoundNearest`, then the result is in the interval ``[-π, π]``. This will generally |
822 | be the most accurate result. | |
835 | be the most accurate result. See also [`RoundNearest`](@ref). | |
823 | 836 | |
824 | 837 | - if `r == RoundToZero`, then the result is in the interval ``[0, 2π]`` if `x` is positive,. |
825 | or ``[-2π, 0]`` otherwise. | |
838 | or ``[-2π, 0]`` otherwise. See also [`RoundToZero`](@ref). | |
826 | 839 | |
827 | 840 | - if `r == RoundDown`, then the result is in the interval ``[0, 2π]``. |
828 | ||
841 | See also [`RoundDown`](@ref). | |
829 | 842 | - if `r == RoundUp`, then the result is in the interval ``[-2π, 0]``. |
843 | See also [`RoundUp`](@ref). | |
830 | 844 | |
831 | 845 | # Examples |
832 | 846 | ```jldoctest |
75 | 75 | |
76 | 76 | function kwarg_decl(m::Method, kwtype::DataType) |
77 | 77 | sig = rewrap_unionall(Tuple{kwtype, Any, unwrap_unionall(m.sig).parameters...}, m.sig) |
78 | kwli = ccall(:jl_methtable_lookup, Any, (Any, Any, UInt), kwtype.name.mt, sig, typemax(UInt)) | |
78 | kwli = ccall(:jl_methtable_lookup, Any, (Any, Any, UInt), kwtype.name.mt, sig, max_world(m)) | |
79 | 79 | if kwli !== nothing |
80 | 80 | kwli = kwli::Method |
81 | 81 | src = uncompressed_ast(kwli) |
155 | 155 | # Iteration |
156 | 156 | """ |
157 | 157 | CartesianIndices(sz::Dims) -> R |
158 | CartesianIndices(istart:istop, jstart:jstop, ...) -> R | |
158 | CartesianIndices((istart:istop, jstart:jstop, ...)) -> R | |
159 | 159 | |
160 | 160 | Define a region `R` spanning a multidimensional rectangular range |
161 | 161 | of integer indices. These are most commonly encountered in the |
42 | 42 | false |
43 | 43 | ``` |
44 | 44 | """ |
45 | showable(::MIME{mime}, x) where {mime} = hasmethod(show, Tuple{IO, MIME{mime}, typeof(x)}) | |
46 | showable(m::AbstractString, x) = showable(MIME(m), x) | |
45 | showable(::MIME{mime}, @nospecialize x) where {mime} = hasmethod(show, Tuple{IO, MIME{mime}, typeof(x)}) | |
46 | showable(m::AbstractString, @nospecialize x) = showable(MIME(m), x) | |
47 | 47 | |
48 | 48 | """ |
49 | 49 | show(io, mime, x) |
174 | 174 | abstract type AbstractDisplay end |
175 | 175 | |
176 | 176 | # it is convenient to accept strings instead of ::MIME |
177 | display(d::AbstractDisplay, mime::AbstractString, x) = display(d, MIME(mime), x) | |
178 | display(mime::AbstractString, x) = display(MIME(mime), x) | |
177 | display(d::AbstractDisplay, mime::AbstractString, @nospecialize x) = display(d, MIME(mime), x) | |
178 | display(mime::AbstractString, @nospecialize x) = display(MIME(mime), x) | |
179 | 179 | |
180 | 180 | """ |
181 | 181 | displayable(mime) -> Bool |
200 | 200 | struct TextDisplay <: AbstractDisplay |
201 | 201 | io::IO |
202 | 202 | end |
203 | display(d::TextDisplay, M::MIME"text/plain", x) = show(d.io, M, x) | |
204 | display(d::TextDisplay, x) = display(d, MIME"text/plain"(), x) | |
203 | display(d::TextDisplay, M::MIME"text/plain", @nospecialize x) = show(d.io, M, x) | |
204 | display(d::TextDisplay, @nospecialize x) = display(d, MIME"text/plain"(), x) | |
205 | 205 | |
206 | 206 | # if you explicitly call display("text/foo", x), it should work on a TextDisplay: |
207 | 207 | displayable(d::TextDisplay, M::MIME) = istextmime(M) |
208 | function display(d::TextDisplay, M::MIME, x) | |
208 | function display(d::TextDisplay, M::MIME, @nospecialize x) | |
209 | 209 | displayable(d, M) || throw(MethodError(display, (d, M, x))) |
210 | 210 | show(d.io, M, x) |
211 | 211 | end |
253 | 253 | pushdisplay(TextDisplay(stdout)) |
254 | 254 | end |
255 | 255 | |
256 | xdisplayable(D::AbstractDisplay, args...) = applicable(display, D, args...) | |
256 | xdisplayable(D::AbstractDisplay, @nospecialize args...) = applicable(display, D, args...) | |
257 | 257 | |
258 | 258 | """ |
259 | 259 | display(x) |
279 | 279 | `x::AbstractString` (for MIME types with text-based storage, such as text/html or |
280 | 280 | application/postscript) or `x::Vector{UInt8}` (for binary MIME types). |
281 | 281 | """ |
282 | function display(x) | |
282 | function display(@nospecialize x) | |
283 | 283 | for i = length(displays):-1:1 |
284 | 284 | if xdisplayable(displays[i], x) |
285 | 285 | try |
293 | 293 | throw(MethodError(display, (x,))) |
294 | 294 | end |
295 | 295 | |
296 | function display(m::MIME, x) | |
296 | function display(m::MIME, @nospecialize x) | |
297 | 297 | for i = length(displays):-1:1 |
298 | 298 | if xdisplayable(displays[i], m, x) |
299 | 299 | try |
338 | 338 | several times, and the backend may choose to defer the display until |
339 | 339 | (for example) the next interactive prompt. |
340 | 340 | """ |
341 | function redisplay(x) | |
341 | function redisplay(@nospecialize x) | |
342 | 342 | for i = length(displays):-1:1 |
343 | 343 | if xdisplayable(displays[i], x) |
344 | 344 | try |
352 | 352 | throw(MethodError(redisplay, (x,))) |
353 | 353 | end |
354 | 354 | |
355 | function redisplay(m::Union{MIME,AbstractString}, x) | |
355 | function redisplay(m::Union{MIME,AbstractString}, @nospecialize x) | |
356 | 356 | for i = length(displays):-1:1 |
357 | 357 | if xdisplayable(displays[i], m, x) |
358 | 358 | try |
367 | 367 | end |
368 | 368 | |
369 | 369 | # default redisplay is simply to call display |
370 | redisplay(d::AbstractDisplay, x) = display(d, x) | |
371 | redisplay(d::AbstractDisplay, m::Union{MIME,AbstractString}, x) = display(d, m, x) | |
370 | redisplay(d::AbstractDisplay, @nospecialize x) = display(d, x) | |
371 | redisplay(d::AbstractDisplay, m::Union{MIME,AbstractString}, @nospecialize x) = display(d, m, x) | |
372 | 372 | |
373 | 373 | ########################################################################### |
374 | 374 |
105 | 105 | return nothing |
106 | 106 | end |
107 | 107 | |
108 | base = convert(T,base) | |
109 | m::T = div(typemax(T)-base+1,base) | |
108 | base = convert(T, base) | |
109 | m::T = div(typemax(T) - base + 1, base) | |
110 | 110 | n::T = 0 |
111 | 111 | a::Int = base <= 36 ? 10 : 36 |
112 | _0 = UInt32('0') | |
113 | _9 = UInt32('9') | |
114 | _A = UInt32('A') | |
115 | _a = UInt32('a') | |
116 | _Z = UInt32('Z') | |
117 | _z = UInt32('z') | |
112 | 118 | while n <= m |
113 | d::T = '0' <= c <= '9' ? c-'0' : | |
114 | 'A' <= c <= 'Z' ? c-'A'+10 : | |
115 | 'a' <= c <= 'z' ? c-'a'+a : base | |
119 | _c = UInt32(c) | |
120 | d::T = _0 <= _c <= _9 ? _c-_0 : | |
121 | _A <= _c <= _Z ? _c-_A+ UInt32(10) : | |
122 | _a <= _c <= _z ? _c-_a+a : base | |
116 | 123 | if d >= base |
117 | 124 | raise && throw(ArgumentError("invalid base $base digit $(repr(c)) in $(repr(SubString(s,startpos,endpos)))")) |
118 | 125 | return nothing |
128 | 135 | end |
129 | 136 | (T <: Signed) && (n *= sgn) |
130 | 137 | while !isspace(c) |
131 | d::T = '0' <= c <= '9' ? c-'0' : | |
132 | 'A' <= c <= 'Z' ? c-'A'+10 : | |
133 | 'a' <= c <= 'z' ? c-'a'+a : base | |
138 | _c = UInt32(c) | |
139 | d::T = _0 <= _c <= _9 ? _c-_0 : | |
140 | _A <= _c <= _Z ? _c-_A+ UInt32(10) : | |
141 | _a <= _c <= _z ? _c-_a+a : base | |
134 | 142 | if d >= base |
135 | 143 | raise && throw(ArgumentError("invalid base $base digit $(repr(c)) in $(repr(SubString(s,startpos,endpos)))")) |
136 | 144 | return nothing |
862 | 862 | @handle_zero x digits |
863 | 863 | pt = i = div((sizeof(x)<<3)-leading_zeros(x)+2,3) |
864 | 864 | while i > 0 |
865 | digits[i] = '0'+(x&0x7) | |
865 | digits[i] = 48+(x&0x7) | |
866 | 866 | x >>= 3 |
867 | 867 | i -= 1 |
868 | 868 | end |
875 | 875 | pt = i = div((sizeof(x)<<3)-leading_zeros(x)+5,3) |
876 | 876 | digits = DIGITSs[Threads.threadid()] |
877 | 877 | while i > 0 |
878 | digits[i] = '0'+(x&0x7) | |
878 | digits[i] = 48+(x&0x7) | |
879 | 879 | x >>= 3 |
880 | 880 | i -= 1 |
881 | 881 | end |
888 | 888 | @handle_zero x digits |
889 | 889 | pt = i = Base.ndigits0z(x) |
890 | 890 | while i > 0 |
891 | digits[i] = '0'+rem(x,10) | |
891 | digits[i] = 48+rem(x,10) | |
892 | 892 | x = div(x,10) |
893 | 893 | i -= 1 |
894 | 894 | end |
624 | 624 | return ret |
625 | 625 | end |
626 | 626 | |
627 | """ | |
628 | read(command::Cmd) | |
629 | ||
630 | Run `command` and return the resulting output as an array of bytes. | |
631 | """ | |
627 | 632 | function read(cmd::AbstractCmd) |
628 | 633 | procs = open(cmd, "r", devnull) |
629 | 634 | bytes = read(procs.out) |
631 | 636 | return bytes |
632 | 637 | end |
633 | 638 | |
639 | """ | |
640 | read(command::Cmd, String) | |
641 | ||
642 | Run `command` and return the resulting output as a `String`. | |
643 | """ | |
634 | 644 | read(cmd::AbstractCmd, ::Type{String}) = String(read(cmd)) |
635 | 645 | |
636 | 646 | """ |
13 | 13 | typejoin(@nospecialize(t), ts...) = (@_pure_meta; typejoin(t, typejoin(ts...))) |
14 | 14 | function typejoin(@nospecialize(a), @nospecialize(b)) |
15 | 15 | @_pure_meta |
16 | if a <: b | |
16 | if isa(a, TypeVar) | |
17 | return typejoin(a.ub, b) | |
18 | elseif isa(b, TypeVar) | |
19 | return typejoin(a, b.ub) | |
20 | elseif a <: b | |
17 | 21 | return b |
18 | 22 | elseif b <: a |
19 | 23 | return a |
21 | 25 | return UnionAll(a.var, typejoin(a.body, b)) |
22 | 26 | elseif isa(b, UnionAll) |
23 | 27 | return UnionAll(b.var, typejoin(a, b.body)) |
24 | elseif isa(a, TypeVar) | |
25 | return typejoin(a.ub, b) | |
26 | elseif isa(b, TypeVar) | |
27 | return typejoin(a, b.ub) | |
28 | 28 | elseif isa(a, Union) |
29 | 29 | return typejoin(typejoin(a.a, a.b), b) |
30 | 30 | elseif isa(b, Union) |
179 | 179 | mapreduce(f, op, itr; [init]) |
180 | 180 | |
181 | 181 | Apply function `f` to each element in `itr`, and then reduce the result using the binary |
182 | function `op`. If provided, `init` must be a neutral element for `op` that will be returne | |
182 | function `op`. If provided, `init` must be a neutral element for `op` that will be returned | |
183 | 183 | for empty collections. It is unspecified whether `init` is used for non-empty collections. |
184 | 184 | In general, it will be necessary to provide `init` to work with empty collections. |
185 | 185 |
1007 | 1007 | Determine whether the given generic function has a method matching the given |
1008 | 1008 | `Tuple` of argument types with the upper bound of world age given by `world`. |
1009 | 1009 | |
1010 | See also [`applicable`](@ref). | |
1011 | ||
1010 | 1012 | # Examples |
1011 | 1013 | ```jldoctest |
1012 | 1014 | julia> hasmethod(length, Tuple{Array}) |
1100 | 1102 | has_bottom_parameter(::Any) = false |
1101 | 1103 | |
1102 | 1104 | min_world(m::Method) = reinterpret(UInt, m.min_world) |
1103 | max_world(m::Method) = typemax(UInt) | |
1105 | max_world(m::Method) = reinterpret(UInt, m.max_world) | |
1104 | 1106 | min_world(m::Core.MethodInstance) = reinterpret(UInt, m.min_world) |
1105 | 1107 | max_world(m::Core.MethodInstance) = reinterpret(UInt, m.max_world) |
1106 | 1108 |
6 | 6 | const DEFAULT_COMPILER_OPTS = PCRE.UTF | PCRE.NO_UTF_CHECK | PCRE.ALT_BSUX | PCRE.UCP |
7 | 7 | const DEFAULT_MATCH_OPTS = PCRE.NO_UTF_CHECK |
8 | 8 | |
9 | """ | |
10 | Regex(pattern[, flags]) | |
11 | ||
12 | A type representing a regular expression. `Regex` objects can be used to match strings | |
13 | with [`match`](@ref). | |
14 | ||
15 | `Regex` objects can be created using the [`@r_str`](@ref) string macro. The | |
16 | `Regex(pattern[, flags])` constructor is usually used if the `pattern` string needs | |
17 | to be interpolated. See the documentation of the string macro for details on flags. | |
18 | """ | |
9 | 19 | mutable struct Regex |
10 | 20 | pattern::String |
11 | 21 | compile_options::UInt32 |
79 | 89 | - `a` disables `UCP` mode (enables ASCII mode). By default `\\B`, `\\b`, `\\D`, `\\d`, `\\S`, |
80 | 90 | `\\s`, `\\W`, `\\w`, etc. match based on Unicode character properties. With this option, |
81 | 91 | these sequences only match ASCII characters. |
92 | ||
93 | See `Regex` if interpolation is needed. | |
82 | 94 | |
83 | 95 | # Examples |
84 | 96 | ```jldoctest |
102 | 102 | inds = _to_subscript_indices(a, i) |
103 | 103 | _getindex_ra(a, inds[1], tail(inds)) |
104 | 104 | end |
105 | ||
106 | @inline _memcpy!(dst, src, n) = ccall(:memcpy, Cvoid, (Ptr{UInt8}, Ptr{UInt8}, Csize_t), dst, src, n) | |
105 | 107 | |
106 | 108 | @inline @propagate_inbounds function _getindex_ra(a::ReinterpretArray{T,N,S}, i1::Int, tailinds::TT) where {T,N,S,TT} |
107 | 109 | # Make sure to match the scalar reinterpret if that is applicable |
122 | 124 | # once it knows the data layout |
123 | 125 | while nbytes_copied < sizeof(T) |
124 | 126 | s[] = a.parent[ind_start + i, tailinds...] |
125 | while nbytes_copied < sizeof(T) && sidx < sizeof(S) | |
126 | unsafe_store!(tptr, unsafe_load(sptr, sidx + 1), nbytes_copied + 1) | |
127 | sidx += 1 | |
128 | nbytes_copied += 1 | |
129 | end | |
127 | nb = min(sizeof(S) - sidx, sizeof(T)-nbytes_copied) | |
128 | _memcpy!(tptr + nbytes_copied, sptr + sidx, nb) | |
129 | nbytes_copied += nb | |
130 | 130 | sidx = 0 |
131 | 131 | i += 1 |
132 | 132 | end |
172 | 172 | # element from the original array and overwrite the relevant parts |
173 | 173 | if sidx != 0 |
174 | 174 | s[] = a.parent[ind_start + i, tailinds...] |
175 | while nbytes_copied < sizeof(T) && sidx < sizeof(S) | |
176 | unsafe_store!(sptr, unsafe_load(tptr, nbytes_copied + 1), sidx + 1) | |
177 | sidx += 1 | |
178 | nbytes_copied += 1 | |
179 | end | |
175 | nb = min(sizeof(S) - sidx, sizeof(T)) | |
176 | _memcpy!(sptr + sidx, tptr, nb) | |
177 | nbytes_copied += nb | |
180 | 178 | a.parent[ind_start + i, tailinds...] = s[] |
181 | 179 | i += 1 |
182 | 180 | sidx = 0 |
183 | 181 | end |
184 | 182 | # Deal with the main body of elements |
185 | 183 | while nbytes_copied < sizeof(T) && (sizeof(T) - nbytes_copied) > sizeof(S) |
186 | while nbytes_copied < sizeof(T) && sidx < sizeof(S) | |
187 | unsafe_store!(sptr, unsafe_load(tptr, nbytes_copied + 1), sidx + 1) | |
188 | sidx += 1 | |
189 | nbytes_copied += 1 | |
190 | end | |
184 | nb = min(sizeof(S), sizeof(T) - nbytes_copied) | |
185 | _memcpy!(sptr, tptr + nbytes_copied, nb) | |
186 | nbytes_copied += nb | |
191 | 187 | a.parent[ind_start + i, tailinds...] = s[] |
192 | 188 | i += 1 |
193 | sidx = 0 | |
194 | 189 | end |
195 | 190 | # Deal with trailing partial elements |
196 | 191 | if nbytes_copied < sizeof(T) |
197 | 192 | s[] = a.parent[ind_start + i, tailinds...] |
198 | while nbytes_copied < sizeof(T) && sidx < sizeof(S) | |
199 | unsafe_store!(sptr, unsafe_load(tptr, nbytes_copied + 1), sidx + 1) | |
200 | sidx += 1 | |
201 | nbytes_copied += 1 | |
202 | end | |
193 | nb = min(sizeof(S), sizeof(T) - nbytes_copied) | |
194 | _memcpy!(sptr, tptr + nbytes_copied, nb) | |
203 | 195 | a.parent[ind_start + i, tailinds...] = s[] |
204 | 196 | end |
205 | 197 | end |
221 | 221 | I = ind2sub_rs(axes(A.parent), A.mi, i) |
222 | 222 | _unsafe_getindex_rs(parent(A), I) |
223 | 223 | end |
224 | _unsafe_getindex_rs(A, i::Integer) = (@inbounds ret = A[i]; ret) | |
224 | @inline _unsafe_getindex_rs(A, i::Integer) = (@inbounds ret = A[i]; ret) | |
225 | 225 | @inline _unsafe_getindex_rs(A, I) = (@inbounds ret = A[I...]; ret) |
226 | 226 | |
227 | 227 | @inline function setindex!(A::ReshapedArrayLF, val, index::Int) |
65 | 65 | rehash!(s::Set) = (rehash!(s.dict); s) |
66 | 66 | |
67 | 67 | iterate(s::Set, i...) = iterate(KeySet(s.dict), i...) |
68 | ||
69 | # In case the size(s) is smaller than size(t) its more efficient to iterate through | |
70 | # elements of s instead and only delete the ones also contained in t. | |
71 | # The threshold for this decision boils down to a tradeoff between | |
72 | # size(s) * cost(in() + delete!()) ≶ size(t) * cost(delete!()) | |
73 | # Empirical observations on Ints point towards a threshold of 0.8. | |
74 | # To be on the safe side (e.g. cost(in) >>> cost(delete!) ) a | |
75 | # conservative threshold of 0.5 was chosen. | |
76 | function setdiff!(s::Set, t::Set) | |
77 | if 2 * length(s) < length(t) | |
78 | for x in s | |
79 | x in t && delete!(s, x) | |
80 | end | |
81 | else | |
82 | for x in t | |
83 | delete!(s, x) | |
84 | end | |
85 | end | |
86 | return s | |
87 | end | |
68 | 88 | |
69 | 89 | """ |
70 | 90 | unique(itr) |
369 | 369 | struct QuickSortAlg <: Algorithm end |
370 | 370 | struct MergeSortAlg <: Algorithm end |
371 | 371 | |
372 | """ | |
373 | PartialQuickSort{T <: Union{Int,OrdinalRange}} | |
374 | ||
375 | Indicate that a sorting function should use the partial quick sort | |
376 | algorithm. Partial quick sort returns the smallest `k` elements sorted from smallest | |
377 | to largest, finding them and sorting them using [`QuickSort`](@ref). | |
378 | ||
379 | Characteristics: | |
380 | * *not stable*: does not preserve the ordering of elements which | |
381 | compare equal (e.g. "a" and "A" in a sort of letters which | |
382 | ignores case). | |
383 | * *in-place* in memory. | |
384 | * *divide-and-conquer*: sort strategy similar to [`MergeSort`](@ref). | |
385 | """ | |
372 | 386 | struct PartialQuickSort{T <: Union{Int,OrdinalRange}} <: Algorithm |
373 | 387 | k::T |
374 | 388 | end |
378 | 392 | Base.first(a::PartialQuickSort) = first(a.k) |
379 | 393 | Base.last(a::PartialQuickSort) = last(a.k) |
380 | 394 | |
395 | """ | |
396 | InsertionSort | |
397 | ||
398 | Indicate that a sorting function should use the insertion sort | |
399 | algorithm. Insertion sort traverses the collection one element | |
400 | at a time, inserting each element into its correct, sorted position in | |
401 | the output list. | |
402 | ||
403 | Characteristics: | |
404 | * *stable*: preserves the ordering of elements which | |
405 | compare equal (e.g. "a" and "A" in a sort of letters | |
406 | which ignores case). | |
407 | * *in-place* in memory. | |
408 | * *quadratic performance* in the number of elements to be sorted: | |
409 | it is well-suited to small collections but should not be used for large ones. | |
410 | """ | |
381 | 411 | const InsertionSort = InsertionSortAlg() |
412 | """ | |
413 | QuickSort | |
414 | ||
415 | Indicate that a sorting function should use the quick sort | |
416 | algorithm, which is *not* stable. | |
417 | ||
418 | Characteristics: | |
419 | * *not stable*: does not preserve the ordering of elements which | |
420 | compare equal (e.g. "a" and "A" in a sort of letters which | |
421 | ignores case). | |
422 | * *in-place* in memory. | |
423 | * *divide-and-conquer*: sort strategy similar to [`MergeSort`](@ref). | |
424 | * *good performance* for large collections. | |
425 | """ | |
382 | 426 | const QuickSort = QuickSortAlg() |
427 | """ | |
428 | MergeSort | |
429 | ||
430 | Indicate that a sorting function should use the merge sort | |
431 | algorithm. Merge sort divides the collection into | |
432 | subcollections and repeatedly merges them, sorting each | |
433 | subcollection at each step, until the entire | |
434 | collection has been recombined in sorted form. | |
435 | ||
436 | Characteristics: | |
437 | * *stable*: preserves the ordering of elements which compare | |
438 | equal (e.g. "a" and "A" in a sort of letters which ignores | |
439 | case). | |
440 | * *not in-place* in memory. | |
441 | * *divide-and-conquer* sort strategy. | |
442 | """ | |
383 | 443 | const MergeSort = MergeSortAlg() |
384 | 444 | |
385 | 445 | const DEFAULT_UNSTABLE = QuickSort |
281 | 281 | elseif isnan(x) |
282 | 282 | NaN |
283 | 283 | else |
284 | throw_complex_domainerror(x, :log) | |
284 | throw_complex_domainerror(:log, x) | |
285 | 285 | end |
286 | 286 | end |
287 | 287 | |
317 | 317 | elseif isnan(x) |
318 | 318 | NaN32 |
319 | 319 | else |
320 | throw_complex_domainerror(x, :log) | |
320 | throw_complex_domainerror(:log, x) | |
321 | 321 | end |
322 | 322 | end |
323 | 323 | |
352 | 352 | elseif isnan(x) |
353 | 353 | NaN |
354 | 354 | else |
355 | throw_complex_domainerror(x, :log1p) | |
355 | throw_complex_domainerror(:log1p, x) | |
356 | 356 | end |
357 | 357 | end |
358 | 358 | |
385 | 385 | elseif isnan(x) |
386 | 386 | NaN32 |
387 | 387 | else |
388 | throw_complex_domainerror(x, :log1p) | |
388 | throw_complex_domainerror(:log1p, x) | |
389 | 389 | end |
390 | 390 | end |
391 | 391 |
207 | 207 | end |
208 | 208 | |
209 | 209 | """ |
210 | rem_pio2_kernel(x, xhp) | |
210 | rem_pio2_kernel(x) | |
211 | 211 | |
212 | 212 | Return the remainder of `x` modulo π/2 as a double-double pair, along with a `k` |
213 | 213 | such that ``k \\mod 3 == K \\mod 3`` where ``K*π/2 = x - rem``. Note, that it is |
10 | 10 | The representation used by `print` includes minimal formatting and tries to |
11 | 11 | avoid Julia-specific details. |
12 | 12 | |
13 | Printing `nothing` is deprecated and will throw an error in the future. | |
13 | Printing `nothing` is not allowed and throws an error. | |
14 | 14 | |
15 | 15 | # Examples |
16 | 16 | ```jldoctest |
80 | 80 | |
81 | 81 | The optional keyword argument `context` can be set to `:key=>value` pair |
82 | 82 | or an `IO` or [`IOContext`](@ref) object whose attributes are used for the I/O |
83 | stream passed to `f`. The optional `sizehint` is a suggersted (in bytes) | |
83 | stream passed to `f`. The optional `sizehint` is a suggested size (in bytes) | |
84 | 84 | to allocate for the buffer used to write the string. |
85 | 85 | |
86 | 86 | # Examples |
102 | 102 | String(resize!(s.data, s.size)) |
103 | 103 | end |
104 | 104 | |
105 | tostr_sizehint(x) = 0 | |
105 | tostr_sizehint(x) = 8 | |
106 | 106 | tostr_sizehint(x::AbstractString) = lastindex(x) |
107 | 107 | tostr_sizehint(x::Float64) = 20 |
108 | 108 | tostr_sizehint(x::Float32) = 12 |
109 | 109 | |
110 | function print_to_string(xs...; env=nothing) | |
110 | function print_to_string(xs...) | |
111 | 111 | if isempty(xs) |
112 | 112 | return "" |
113 | 113 | end |
114 | siz = 0 | |
115 | for x in xs | |
116 | siz += tostr_sizehint(x) | |
117 | end | |
114 | 118 | # specialized for performance reasons |
115 | s = IOBuffer(sizehint=tostr_sizehint(xs[1])) | |
116 | if env !== nothing | |
117 | env_io = IOContext(s, env) | |
118 | for x in xs | |
119 | print(env_io, x) | |
120 | end | |
121 | else | |
122 | for x in xs | |
123 | print(s, x) | |
124 | end | |
119 | s = IOBuffer(sizehint=siz) | |
120 | for x in xs | |
121 | print(s, x) | |
125 | 122 | end |
126 | 123 | String(resize!(s.data, s.size)) |
127 | 124 | end |
128 | 125 | |
129 | string_with_env(env, xs...) = print_to_string(xs...; env=env) | |
126 | function string_with_env(env, xs...) | |
127 | if isempty(xs) | |
128 | return "" | |
129 | end | |
130 | siz = 0 | |
131 | for x in xs | |
132 | siz += tostr_sizehint(x) | |
133 | end | |
134 | # specialized for performance reasons | |
135 | s = IOBuffer(sizehint=siz) | |
136 | env_io = IOContext(s, env) | |
137 | for x in xs | |
138 | print(env_io, x) | |
139 | end | |
140 | String(resize!(s.data, s.size)) | |
141 | end | |
130 | 142 | |
131 | 143 | """ |
132 | 144 | string(xs...) |
133 | 145 | |
134 | Create a string from any values using the [`print`](@ref) function. | |
146 | Create a string from any values, except `nothing`, using the [`print`](@ref) function. | |
135 | 147 | |
136 | 148 | # Examples |
137 | 149 | ```jldoctest |
222 | 234 | Join an array of `strings` into a single string, inserting the given delimiter between |
223 | 235 | adjacent strings. If `last` is given, it will be used instead of `delim` between the last |
224 | 236 | two strings. If `io` is given, the result is written to `io` rather than returned as |
225 | as a `String`. For example, | |
237 | as a `String`. | |
226 | 238 | |
227 | 239 | # Examples |
228 | 240 | ```jldoctest |
141 | 141 | end |
142 | 142 | end |
143 | 143 | |
144 | function string(a::Union{String, SubString{String}}...) | |
145 | if length(a) == 1 | |
146 | return String(a[1]) | |
147 | end | |
144 | string(a::String) = String(a) | |
145 | string(a::SubString{String}) = String(a) | |
146 | ||
147 | function string(a::Union{Char, String, SubString{String}}...) | |
148 | 148 | n = 0 |
149 | for str in a | |
150 | n += sizeof(str) | |
149 | for v in a | |
150 | if v isa Char | |
151 | n += codelen(v) | |
152 | else | |
153 | n += sizeof(v) | |
154 | end | |
151 | 155 | end |
152 | 156 | out = _string_n(n) |
153 | 157 | offs = 1 |
154 | for str in a | |
155 | unsafe_copyto!(pointer(out,offs), pointer(str), sizeof(str)) | |
156 | offs += sizeof(str) | |
158 | for v in a | |
159 | if v isa Char | |
160 | x = bswap(reinterpret(UInt32, v)) | |
161 | for j in 1:codelen(v) | |
162 | unsafe_store!(pointer(out, offs), x % UInt8) | |
163 | offs += 1 | |
164 | x >>= 8 | |
165 | end | |
166 | else | |
167 | unsafe_copyto!(pointer(out,offs), pointer(v), sizeof(v)) | |
168 | offs += sizeof(v) | |
169 | end | |
157 | 170 | end |
158 | 171 | return out |
159 | 172 | end |
65 | 65 | """ |
66 | 66 | parentindices(A) |
67 | 67 | |
68 | From an array view `A`, returns the corresponding indices in the parent. | |
68 | Return the indices in the [`parent`](@ref) which correspond to the array view `A`. | |
69 | ||
70 | # Examples | |
71 | ```jldoctest | |
72 | julia> A = [1 2; 3 4]; | |
73 | ||
74 | julia> V = view(A, 1, :) | |
75 | 2-element view(::Array{Int64,2}, 1, :) with eltype Int64: | |
76 | 1 | |
77 | 2 | |
78 | ||
79 | julia> parentindices(V) | |
80 | (1, Base.Slice(Base.OneTo(2))) | |
81 | ``` | |
69 | 82 | """ |
70 | 83 | parentindices(a::AbstractArray) = map(OneTo, size(a)) |
71 | 84 |
37 | 37 | |
38 | 38 | ## iterating ## |
39 | 39 | |
40 | iterate(t::Tuple, i::Int=1) = length(t) < i ? nothing : (t[i], i+1) | |
40 | iterate(t::Tuple, i::Int=1) = 1 <= i <= length(t) ? (@inbounds t[i], i+1) : nothing | |
41 | 41 | |
42 | 42 | keys(@nospecialize t::Tuple) = OneTo(length(t)) |
43 | 43 | |
56 | 56 | |
57 | 57 | # this allows partial evaluation of bounded sequences of next() calls on tuples, |
58 | 58 | # while reducing to plain next() for arbitrary iterables. |
59 | indexed_iterate(t::Tuple, i::Int, state=1) = (@_inline_meta; (t[i], i+1)) | |
59 | indexed_iterate(t::Tuple, i::Int, state=1) = (@_inline_meta; (getfield(t, i), i+1)) | |
60 | 60 | indexed_iterate(a::Array, i::Int, state=1) = (@_inline_meta; (a[i], i+1)) |
61 | 61 | function indexed_iterate(I, i) |
62 | 62 | x = iterate(I) |
331 | 331 | asF64(x::AbstractFloat) = Float64(x) |
332 | 332 | asF64(x::Tuple{AbstractFloat,AbstractFloat}) = Float64(x[1]) + Float64(x[2]) |
333 | 333 | |
334 | # Defined to prevent splatting in the function below which here has a performance impact | |
335 | _TP(x) = TwicePrecision{Float64}(x) | |
336 | _TP(x::Tuple{Any, Any}) = TwicePrecision{Float64}(x[1], x[2]) | |
334 | 337 | function steprangelen_hp(::Type{Float64}, ref::F_or_FF, |
335 | 338 | step::F_or_FF, nb::Integer, |
336 | 339 | len::Integer, offset::Integer) |
337 | StepRangeLen(TwicePrecision{Float64}(ref...), | |
338 | twiceprecision(TwicePrecision{Float64}(step...), nb), Int(len), offset) | |
340 | StepRangeLen(_TP(ref), | |
341 | twiceprecision(_TP(step), nb), Int(len), offset) | |
339 | 342 | end |
340 | 343 | |
341 | 344 | function steprangelen_hp(::Type{T}, ref::F_or_FF, |
353 | 356 | |
354 | 357 | # Construct range for rational start=start_n/den, step=step_n/den |
355 | 358 | function floatrange(::Type{T}, start_n::Integer, step_n::Integer, len::Integer, den::Integer) where T |
356 | if len < 2 | |
359 | if len < 2 || step_n == 0 | |
357 | 360 | return steprangelen_hp(T, (start_n, den), (step_n, den), 0, Int(len), 1) |
358 | 361 | end |
359 | 362 | # index of smallest-magnitude value |
475 | 475 | write(s, c) |
476 | 476 | end |
477 | 477 | end |
478 | return s | |
478 | return seekstart(s) | |
479 | 479 | end |
480 | 480 | else |
481 | 481 | function getpass(input::TTY, output::IO, prompt::AbstractString) |
0 | 0 | # This file is a part of Julia. License is MIT: https://julialang.org/license |
1 | 1 | |
2 | """ | |
3 | Represents a Universally Unique Identifier (UUID). | |
4 | Can be built from one `UInt128` (all byte values), two `UInt64`, or four `UInt32`. | |
5 | Conversion from a string will check the UUID validity. | |
6 | """ | |
2 | 7 | struct UUID |
3 | 8 | value::UInt128 |
4 | 9 | end |
7 | 12 | (UInt128(u[3]) << 32) | UInt128(u[4])) |
8 | 13 | |
9 | 14 | function convert(::Type{NTuple{2, UInt64}}, uuid::UUID) |
10 | uuid = uuid.value | |
11 | hi = UInt64((uuid >> 64) & 0xffffffffffffffff) | |
12 | lo = UInt64(uuid & 0xffffffffffffffff) | |
15 | bytes = uuid.value | |
16 | hi = UInt64((bytes >> 64) & 0xffffffffffffffff) | |
17 | lo = UInt64(bytes & 0xffffffffffffffff) | |
13 | 18 | return (hi, lo) |
14 | 19 | end |
15 | 20 | |
16 | 21 | function convert(::Type{NTuple{4, UInt32}}, uuid::UUID) |
17 | uuid = uuid.value | |
18 | hh = UInt32((uuid >> 96) & 0xffffffff) | |
19 | hl = UInt32((uuid >> 64) & 0xffffffff) | |
20 | lh = UInt32((uuid >> 32) & 0xffffffff) | |
21 | ll = UInt32(uuid & 0xffffffff) | |
22 | bytes = uuid.value | |
23 | hh = UInt32((bytes >> 96) & 0xffffffff) | |
24 | hl = UInt32((bytes >> 64) & 0xffffffff) | |
25 | lh = UInt32((bytes >> 32) & 0xffffffff) | |
26 | ll = UInt32(bytes & 0xffffffff) | |
22 | 27 | return (hh, hl, lh, ll) |
23 | 28 | end |
24 | 29 |
7 | 7 | Base.reinit_stdio() |
8 | 8 | end |
9 | 9 | Base.include(@__MODULE__, joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testhelpers", "FakePTYs.jl")) |
10 | import .FakePTYs: with_fake_pty | |
10 | import .FakePTYs: open_fake_pty | |
11 | 11 | |
12 | 12 | CTRL_C = '\x03' |
13 | 13 | UP_ARROW = "\e[A" |
42 | 42 | precompile_script *= Pkg.precompile_script |
43 | 43 | end |
44 | 44 | |
45 | push!(LOAD_PATH, Sys.STDLIB) | |
46 | using Sockets | |
47 | Sockets.__init__() | |
48 | using Libdl | |
49 | empty!(LOAD_PATH) | |
50 | ||
45 | 51 | function generate_precompile_statements() |
46 | 52 | start_time = time() |
47 | 53 | |
61 | 67 | empty!(DEPOT_PATH) |
62 | 68 | end |
63 | 69 | |
64 | # Create a staging area where all the loaded packages are available | |
65 | PrecompileStagingArea = Module() | |
66 | for (_pkgid, _mod) in Base.loaded_modules | |
67 | if !(_pkgid.name in ("Main", "Core", "Base")) | |
68 | eval(PrecompileStagingArea, :($(Symbol(_mod)) = $_mod)) | |
70 | print("Generating precompile statements...") | |
71 | sysimg = Base.unsafe_string(Base.JLOptions().image_file) | |
72 | mktemp() do precompile_file, _ | |
73 | # Run a repl process and replay our script | |
74 | repl_output_buffer = IOBuffer() | |
75 | @static if Sys.iswindows() | |
76 | # Fake being cygwin | |
77 | pipename = """\\\\?\\pipe\\cygwin-$("0"^16)-pty10-abcdef""" | |
78 | server = listen(pipename) | |
79 | slave = connect(pipename) | |
80 | @assert ccall(:jl_ispty, Cint, (Ptr{Cvoid},), slave.handle) == 1 | |
81 | master = accept(server) | |
82 | else | |
83 | slave, master = open_fake_pty() | |
69 | 84 | end |
70 | end | |
71 | ||
72 | # TODO: Implement REPL replayer for Windows | |
73 | @static if !Sys.iswindows() | |
74 | print("Generating precompile statements...") | |
75 | sysimg = isempty(ARGS) ? joinpath(dirname(Sys.BINDIR), "lib", "julia", "sys.ji") : ARGS[1] | |
76 | ||
77 | mktemp() do precompile_file, _ | |
78 | # Run a repl process and replay our script | |
79 | stdout_accumulator, stderr_accumulator = IOBuffer(), IOBuffer() | |
80 | with_fake_pty() do slave, master | |
81 | with_fake_pty() do slave_err, master_err | |
82 | done = false | |
83 | withenv("JULIA_HISTORY" => tempname(), "JULIA_PROJECT" => nothing, | |
84 | "TERM" => "") do | |
85 | p = run(`$(julia_cmd()) -O0 --trace-compile=$precompile_file --sysimage $sysimg | |
86 | --startup-file=no --color=yes`, | |
87 | slave, slave, slave_err; wait=false) | |
88 | readuntil(master, "julia>", keep=true) | |
89 | for (tty, accumulator) in (master => stdout_accumulator, | |
90 | master_err => stderr_accumulator) | |
91 | @async begin | |
92 | while true | |
93 | done && break | |
94 | write(accumulator, readavailable(tty)) | |
95 | end | |
96 | end | |
85 | done = false | |
86 | withenv("JULIA_HISTORY" => tempname(), "JULIA_PROJECT" => nothing, | |
87 | "TERM" => "") do | |
88 | if have_repl | |
89 | p = run(`$(julia_cmd()) -O0 --trace-compile=$precompile_file --sysimage $sysimg | |
90 | --compile=all --startup-file=no --color=yes | |
91 | -e 'import REPL; REPL.Terminals.is_precompiling[] = true' | |
92 | -i`, | |
93 | slave, slave, slave; wait=false) | |
94 | readuntil(master, "julia>", keep=true) | |
95 | t = @async begin | |
96 | while true | |
97 | sleep(0.5) | |
98 | s = String(readavailable(master)) | |
99 | write(repl_output_buffer, s) | |
100 | if occursin("__PRECOMPILE_END__", s) | |
101 | break | |
97 | 102 | end |
98 | if have_repl | |
99 | for l in split(precompile_script, '\n'; keepempty=false) | |
100 | write(master, l, '\n') | |
101 | end | |
102 | end | |
103 | write(master, "exit()\n") | |
104 | wait(p) | |
105 | done = true | |
106 | 103 | end |
107 | 104 | end |
105 | if have_repl | |
106 | for l in split(precompile_script, '\n'; keepempty=false) | |
107 | write(master, l, '\n') | |
108 | end | |
109 | end | |
110 | write(master, "print(\"__PRECOMPILE\", \"_END__\")", '\n') | |
111 | wait(t) | |
112 | ||
113 | # TODO Figure out why exit() on Windows doesn't exit the process | |
114 | if Sys.iswindows() | |
115 | print(master, "ccall(:_exit, Cvoid, (Cint,), 0)\n") | |
116 | else | |
117 | write(master, "exit()\n") | |
118 | readuntil(master, "exit()\r\e[13C\r\n") | |
119 | # @assert bytesavailable(master) == 0 | |
120 | end | |
121 | wait(p) | |
122 | else | |
123 | # Is this even needed or is this already recorded just from starting this process? | |
124 | p = run(`$(julia_cmd()) -O0 --trace-compile=$precompile_file --sysimage $sysimg | |
125 | --compile=all --startup-file=no | |
126 | -e0`) | |
108 | 127 | end |
128 | end | |
129 | close(master) | |
109 | 130 | |
110 | # Check what the REPL displayed | |
111 | # stdout_output = String(take!(stdout_accumulator)) | |
112 | # println(stdout_output) | |
131 | # Check what the REPL displayed | |
132 | # repl_output = String(take!(repl_output_buffer)) | |
133 | # println(repl_output) | |
113 | 134 | |
114 | # Extract the precompile statements from stderr | |
115 | statements = Set{String}() | |
116 | for statement in split(read(precompile_file, String), '\n') | |
117 | occursin("Main.", statement) && continue | |
118 | push!(statements, statement) | |
135 | # Extract the precompile statements from stderr | |
136 | statements = Set{String}() | |
137 | for statement in split(read(precompile_file, String), '\n') | |
138 | occursin("Main.", statement) && continue | |
139 | push!(statements, statement) | |
140 | end | |
141 | ||
142 | if have_repl | |
143 | # Seems like a reasonable number right now, adjust as needed | |
144 | # comment out if debugging script | |
145 | @assert length(statements) > 700 | |
146 | end | |
147 | ||
148 | # Create a staging area where all the loaded packages are available | |
149 | PrecompileStagingArea = Module() | |
150 | for (_pkgid, _mod) in Base.loaded_modules | |
151 | if !(_pkgid.name in ("Main", "Core", "Base")) | |
152 | eval(PrecompileStagingArea, :($(Symbol(_mod)) = $_mod)) | |
119 | 153 | end |
154 | end | |
120 | 155 | |
121 | # Load the precompile statements | |
122 | statements_ordered = join(sort(collect(statements)), '\n') | |
123 | # println(statements_ordered) | |
124 | if have_repl | |
125 | # Seems like a reasonable number right now, adjust as needed | |
126 | @assert length(statements) > 700 | |
156 | # Execute the collected precompile statements | |
157 | include_time = @elapsed for statement in sort(collect(statements)) | |
158 | # println(statement) | |
159 | # Work around #28808 | |
160 | occursin("\"YYYY-mm-dd\\THH:MM:SS\"", statement) && continue | |
161 | try | |
162 | Base.include_string(PrecompileStagingArea, statement) | |
163 | catch ex | |
164 | @error "Failed to precompile $statement" | |
165 | rethrow(ex) | |
127 | 166 | end |
128 | ||
129 | Base.include_string(PrecompileStagingArea, statements_ordered) | |
130 | print(" $(length(statements)) generated in ") | |
131 | Base.time_print((time() - start_time) * 10^9) | |
132 | println() | |
133 | 167 | end |
168 | print(" $(length(statements)) generated in ") | |
169 | tot_time = time() - start_time | |
170 | Base.time_print(tot_time * 10^9) | |
171 | print(" (overhead "); Base.time_print((tot_time - include_time) * 10^9); println(")") | |
134 | 172 | end |
135 | ||
136 | # Fall back to explicit list on Windows, might as well include them | |
137 | # for everyone though | |
138 | Base.include(PrecompileStagingArea, "precompile_explicit.jl") | |
139 | 173 | |
140 | 174 | return |
141 | 175 | end |
0 | # This file is a part of Julia. License is MIT: https://julialang.org/license | |
1 | ||
2 | # Steps to regenerate this file: | |
3 | # 1. Remove all `precompile` calls | |
4 | # 2. Rebuild system image | |
5 | # 3. Start julia with `--trace-compile=precompiles.txt and do some stuff | |
6 | # 5. Run `grep -v '#[0-9]' precompiles.txt >> contrib/precompile_explicit.jl` | |
7 | # (filters out closures, which might have different generated names in different environments) | |
8 | # This list is only used on Windows, otherwise precompile statements are generated dynamically. | |
9 | ||
10 | precompile(Tuple{Type{Array{Base.StackTraces.StackFrame, 1}}, UndefInitializer, Int64}) | |
11 | precompile(Tuple{Type{Array{Union{Nothing, String}, 1}}, UndefInitializer, Int64}) | |
12 | precompile(Tuple{Type{Base.CoreLogging.LogState}, Logging.ConsoleLogger}) | |
13 | precompile(Tuple{Type{Base.Dict{Any, Any}}}) | |
14 | precompile(Tuple{Type{Base.Dict{Any, Int64}}}) | |
15 | precompile(Tuple{Type{Base.Dict{Char, Any}}}) | |
16 | precompile(Tuple{Type{Base.Dict{Symbol, Any}}, Base.Pair{Symbol, REPL.LineEdit.Prompt}, Base.Pair{Symbol, REPL.LineEdit.Prompt}, Base.Pair{Symbol, REPL.LineEdit.Prompt}}) | |
17 | precompile(Tuple{Type{Base.Dict{Symbol, Any}}, Base.Pair{Symbol, REPL.LineEdit.Prompt}, Vararg{Base.Pair{Symbol, REPL.LineEdit.Prompt}, N} where N}) | |
18 | precompile(Tuple{Type{Base.Dict{Symbol, Any}}}) | |
19 | precompile(Tuple{Type{Base.GC_Diff}, Base.GC_Num, Base.GC_Num}) | |
20 | precompile(Tuple{Type{Base.Generator{I, F} where F where I}, typeof(Base.names), Array{Any, 1}}) | |
21 | precompile(Tuple{Type{Base.IOContext{IO_t} where IO_t<:IO}, Base.GenericIOBuffer{Array{UInt8, 1}}, Base.IOStream}) | |
22 | precompile(Tuple{Type{Base.IOContext{IO_t} where IO_t<:IO}, REPL.Terminals.TTYTerminal, Base.Pair{Symbol, Bool}}) | |
23 | precompile(Tuple{Type{Base.InterpreterIP}, Core.CodeInfo, Ptr{Nothing}}) | |
24 | precompile(Tuple{Type{Base.IteratorSize}, Array{Any, 1}}) | |
25 | precompile(Tuple{Type{Base.LinearIndices{N, R} where R<:Tuple{Vararg{Base.AbstractUnitRange{Int64}, N}} where N}, Array{Method, 1}}) | |
26 | precompile(Tuple{Type{Base.MIME{Symbol("text/plain")}}}) | |
27 | precompile(Tuple{Type{Base.Multimedia.TextDisplay}, Base.TTY}) | |
28 | precompile(Tuple{Type{Base.Order.Perm{O, V} where V<:(AbstractArray{T, 1} where T) where O<:Base.Order.Ordering}, Base.Order.ForwardOrdering, Array{Tuple{Float64, Int64}, 1}}) | |
29 | precompile(Tuple{Type{Base.Pair{A, B} where B where A}, Base.PkgId, UInt64}) | |
30 | precompile(Tuple{Type{Base.Pair{A, B} where B where A}, Int64, Int64}) | |
31 | precompile(Tuple{Type{Base.PkgId}, String}) | |
32 | precompile(Tuple{Type{Base.StackTraces.StackFrame}, Symbol, Symbol, Int64, Core.CodeInfo, Bool, Bool, Int64}) | |
33 | precompile(Tuple{Type{Base.StackTraces.StackFrame}, Symbol, Symbol, Int64, Core.MethodInstance, Bool, Bool, Ptr{Nothing}}) | |
34 | precompile(Tuple{Type{Base.StackTraces.StackFrame}, Symbol, Symbol, Int64, Nothing, Bool, Bool, Ptr{Nothing}}) | |
35 | precompile(Tuple{Type{Base.SubString{T} where T<:AbstractString}, String, Int64}) | |
36 | precompile(Tuple{Type{Base.Val{2}}}) | |
37 | precompile(Tuple{Type{Base.Val{3}}}) | |
38 | precompile(Tuple{Type{Logging.ConsoleLogger}, Base.IOStream}) | |
39 | precompile(Tuple{Type{Logging.ConsoleLogger}, Base.TTY}) | |
40 | precompile(Tuple{Type{Markdown.Header{1}}, Array{Any, 1}}) | |
41 | precompile(Tuple{Type{Markdown.MD}, Markdown.MD, Markdown.MD}) | |
42 | precompile(Tuple{Type{NamedTuple{(), T} where T<:Tuple}, Tuple{}}) | |
43 | precompile(Tuple{Type{NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}}, Tuple{Bool, Symbol}}) | |
44 | precompile(Tuple{Type{NamedTuple{(:bold, :color), T} where T<:Tuple}, Tuple{Bool, Symbol}}) | |
45 | precompile(Tuple{Type{NamedTuple{(:create,), T} where T<:Tuple}, Tuple{Bool}}) | |
46 | precompile(Tuple{Type{NamedTuple{(:merge,), T} where T<:Tuple}, Tuple{Bool}}) | |
47 | precompile(Tuple{Type{NamedTuple{(:prompt_prefix, :prompt_suffix, :complete, :sticky), Tuple{String, String, Pkg.REPLMode.PkgCompletionProvider, Bool}}}, Tuple{String, String, Pkg.REPLMode.PkgCompletionProvider, Bool}}) | |
48 | precompile(Tuple{Type{NamedTuple{(:prompt_prefix, :prompt_suffix, :complete, :sticky), T} where T<:Tuple}, Tuple{String, String, Pkg.REPLMode.PkgCompletionProvider, Bool}}) | |
49 | precompile(Tuple{Type{NamedTuple{(:prompt_prefix, :prompt_suffix, :repl, :complete, :on_enter), Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}}, Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}) | |
50 | precompile(Tuple{Type{NamedTuple{(:prompt_prefix, :prompt_suffix, :repl, :complete, :on_enter), T} where T<:Tuple}, Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}) | |
51 | precompile(Tuple{Type{NamedTuple{(:stderr,), Tuple{Base.IOStream}}}, Tuple{Base.IOStream}}) | |
52 | precompile(Tuple{Type{REPL.LineEditREPL}, REPL.Terminals.TTYTerminal, Bool, Bool}) | |
53 | precompile(Tuple{Type{REPL.LineEditREPL}, REPL.Terminals.TTYTerminal, Bool, String, String, String, String, String, Bool, Bool, Bool, Bool}) | |
54 | precompile(Tuple{Type{REPL.REPLDisplay{R} where R<:REPL.AbstractREPL}, REPL.LineEditREPL}) | |
55 | precompile(Tuple{Type{REPL.Terminals.TTYTerminal}, String, Base.PipeEndpoint, Base.TTY, Base.IOStream}) | |
56 | precompile(Tuple{Type{REPL.Terminals.TTYTerminal}, String, Base.TTY, Base.TTY, Base.IOStream}) | |
57 | precompile(Tuple{Type{REPL.Terminals.TTYTerminal}, String, Base.TTY, Base.TTY, Base.TTY}) | |
58 | precompile(Tuple{Type{String}, Array{UInt8, 1}}) | |
59 | precompile(Tuple{Type{UInt32}, UInt8}) | |
60 | precompile(Tuple{Type{UnionAll}, TypeVar, Any}) | |
61 | precompile(Tuple{getfield(Base, Symbol("#@time")), LineNumberNode, Module, Expr}) | |
62 | precompile(Tuple{getfield(Base, Symbol("#kw##_spawn")), NamedTuple{(:chain,), Tuple{Nothing}}, typeof(Base._spawn), Base.Cmd, Tuple{Base.Pipe, Base.TTY, Base.IOStream}}) | |
63 | precompile(Tuple{getfield(Base, Symbol("#kw##pipeline")), NamedTuple{(:stderr,), Tuple{Base.IOStream}}, typeof(Base.pipeline), Base.Cmd}) | |
64 | precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String, String}) | |
65 | precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String}) | |
66 | precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), REPL.Terminals.TTYTerminal, String}) | |
67 | precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:color,), Tuple{Symbol}}, typeof(Base.printstyled), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String}) | |
68 | precompile(Tuple{getfield(Base, Symbol("#kw##show_trace_entry")), NamedTuple{(:prefix,), Tuple{String}}, typeof(Base.show_trace_entry), Base.IOContext{REPL.Terminals.TTYTerminal}, Base.StackTraces.StackFrame, Int64}) | |
69 | precompile(Tuple{getfield(Base, Symbol("#kw##sort!")), NamedTuple{(:by,), Tuple{typeof(REPL.REPLCompletions.completion_text)}}, typeof(Base.sort!), Array{REPL.REPLCompletions.Completion, 1}}) | |
70 | precompile(Tuple{getfield(Base, Symbol("#kw##with_output_color")), NamedTuple{(:bold,), Tuple{Bool}}, typeof(Base.with_output_color), typeof(Base.print), Symbol, Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String, String}) | |
71 | precompile(Tuple{getfield(Base.Cartesian, Symbol("#@ncall")), LineNumberNode, Module, Int64, Symbol, Symbol, Expr}) | |
72 | precompile(Tuple{getfield(Base.Cartesian, Symbol("#@nexprs")), LineNumberNode, Module, Int64, Expr}) | |
73 | precompile(Tuple{getfield(Base.Meta, Symbol("#kw##parse")), NamedTuple{(:raise, :depwarn), Tuple{Bool, Bool}}, typeof(Base.Meta.parse), String, Int64}) | |
74 | precompile(Tuple{getfield(Core, Symbol("#@doc")), LineNumberNode, Module, Symbol}) | |
75 | precompile(Tuple{getfield(Core, Symbol("#kw#Type")), NamedTuple{(:prompt_prefix, :prompt_suffix, :complete, :sticky), Tuple{String, String, Pkg.REPLMode.PkgCompletionProvider, Bool}}, Type{REPL.LineEdit.Prompt}, typeof(Pkg.REPLMode.promptf)}) | |
76 | precompile(Tuple{getfield(Core, Symbol("#kw#Type")), NamedTuple{(:prompt_prefix, :prompt_suffix, :repl, :complete, :on_enter), Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}, Type{REPL.LineEdit.Prompt}, String}) | |
77 | precompile(Tuple{getfield(REPL, Symbol("#@repl")), LineNumberNode, Module, Base.TTY, Symbol}) | |
78 | precompile(Tuple{getfield(REPL, Symbol("#kw##printmatches")), NamedTuple{(:cols,), Tuple{Int64}}, typeof(REPL.printmatches), Base.TTY, String, Array{String, 1}}) | |
79 | precompile(Tuple{getfield(REPL.LineEdit, Symbol("#kw##add_nested_key!")), NamedTuple{(:override,), Tuple{Bool}}, typeof(REPL.LineEdit.add_nested_key!), Base.Dict{Char, Any}, Char, Function}) | |
80 | precompile(Tuple{getfield(REPL.LineEdit, Symbol("#kw##refresh_multi_line")), NamedTuple{(:beeping,), Tuple{Bool}}, typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TTYTerminal, REPL.LineEdit.PromptState}) | |
81 | precompile(Tuple{typeof(Base.:(!=)), Char, Char}) | |
82 | precompile(Tuple{typeof(Base.:(!=)), Int64, Int64}) | |
83 | precompile(Tuple{typeof(Base.:(!=)), Int8, Int64}) | |
84 | precompile(Tuple{typeof(Base.:(!=)), Nothing, Nothing}) | |
85 | precompile(Tuple{typeof(Base.:(!=)), REPL.LineEdit.Prompt, Nothing}) | |
86 | precompile(Tuple{typeof(Base.:(!=)), String, Nothing}) | |
87 | precompile(Tuple{typeof(Base.:(!=)), String, String}) | |
88 | precompile(Tuple{typeof(Base.:(!=)), UInt8, UInt8}) | |
89 | precompile(Tuple{typeof(Base.:(*)), Base.SubString{String}, String}) | |
90 | precompile(Tuple{typeof(Base.:(+)), Int64, Bool}) | |
91 | precompile(Tuple{typeof(Base.:(<<)), UInt32, Int64}) | |
92 | precompile(Tuple{typeof(Base.:(<=)), Int64, Int64}) | |
93 | precompile(Tuple{typeof(Base.:(==)), Base.Multimedia.TextDisplay, REPL.REPLDisplay{REPL.LineEditREPL}}) | |
94 | precompile(Tuple{typeof(Base.:(==)), Int8, Int64}) | |
95 | precompile(Tuple{typeof(Base.:(==)), Module, Module}) | |
96 | precompile(Tuple{typeof(Base.:(==)), Nothing, String}) | |
97 | precompile(Tuple{typeof(Base.:(==)), REPL.REPLDisplay{REPL.LineEditREPL}, REPL.REPLDisplay{REPL.LineEditREPL}}) | |
98 | precompile(Tuple{typeof(Base.:(>)), UInt64, Int64}) | |
99 | precompile(Tuple{typeof(Base.:(^)), Char, Int64}) | |
100 | precompile(Tuple{typeof(Base.:(|>)), Array{Any, 1}, typeof(Base.unique)}) | |
101 | precompile(Tuple{typeof(Base.:(|>)), Array{Any, 1}, typeof(REPL.filtervalid)}) | |
102 | precompile(Tuple{typeof(Base.CoreLogging.global_logger), Logging.ConsoleLogger}) | |
103 | precompile(Tuple{typeof(Base.CoreLogging.global_logger)}) | |
104 | precompile(Tuple{typeof(Base.CoreLogging.logmsg_shim), Int64, String, Nothing, Symbol, Symbol, Symbol, Int64, Array{Any, 1}}) | |
105 | precompile(Tuple{typeof(Base.Docs.catdoc), Markdown.MD, Markdown.MD}) | |
106 | precompile(Tuple{typeof(Base.Docs.doc), Base.Docs.Binding, Type{Union{}}}) | |
107 | precompile(Tuple{typeof(Base.Docs.doc), Base.Docs.Binding}) | |
108 | precompile(Tuple{typeof(Base.Docs.docm), LineNumberNode, Module, Symbol}) | |
109 | precompile(Tuple{typeof(Base.Docs.formatdoc), Base.GenericIOBuffer{Array{UInt8, 1}}, Base.Docs.DocStr, String}) | |
110 | precompile(Tuple{typeof(Base.Filesystem.basename), String}) | |
111 | precompile(Tuple{typeof(Base.Filesystem.isdir), String}) | |
112 | precompile(Tuple{typeof(Base.Filesystem.pwd)}) | |
113 | precompile(Tuple{typeof(Base.Filesystem.splitdir), String}) | |
114 | precompile(Tuple{typeof(Base.Filesystem.splitext), String}) | |
115 | precompile(Tuple{typeof(Base.Meta.isexpr), Symbol, Symbol, Int64}) | |
116 | precompile(Tuple{typeof(Base.Meta.parse), String}) | |
117 | precompile(Tuple{typeof(Base.Multimedia.display), Int64}) | |
118 | precompile(Tuple{typeof(Base.Multimedia.display), Markdown.MD}) | |
119 | precompile(Tuple{typeof(Base.Multimedia.display), REPL.REPLDisplay{REPL.LineEditREPL}, Array{Float64, 1}}) | |
120 | precompile(Tuple{typeof(Base.Multimedia.display), REPL.REPLDisplay{REPL.LineEditREPL}, Array{Float64, 2}}) | |
121 | precompile(Tuple{typeof(Base.Multimedia.display), REPL.REPLDisplay{REPL.LineEditREPL}, Array{Int64, 1}}) | |
122 | precompile(Tuple{typeof(Base.Multimedia.display), REPL.REPLDisplay{REPL.LineEditREPL}, Float64}) | |
123 | precompile(Tuple{typeof(Base.Multimedia.display), REPL.REPLDisplay{REPL.LineEditREPL}, Int64}) | |
124 | precompile(Tuple{typeof(Base.Multimedia.display), REPL.REPLDisplay{REPL.LineEditREPL}, Markdown.MD}) | |
125 | precompile(Tuple{typeof(Base.Multimedia.display), REPL.REPLDisplay{REPL.LineEditREPL}, String}) | |
126 | precompile(Tuple{typeof(Base.Multimedia.pushdisplay), REPL.REPLDisplay{REPL.LineEditREPL}}) | |
127 | precompile(Tuple{typeof(Base.Order.ord), typeof(Base.isless), typeof(Base.identity), Nothing, Base.Order.ForwardOrdering}) | |
128 | precompile(Tuple{typeof(Base.Printf.decode_dec), Base.TTY, Float64, String, Int64, Int64, Char}) | |
129 | precompile(Tuple{typeof(Base.StackTraces.lookup), Base.InterpreterIP}) | |
130 | precompile(Tuple{typeof(Base.Unicode.textwidth), String}) | |
131 | precompile(Tuple{typeof(Base.__atreplinit), REPL.LineEditREPL}) | |
132 | precompile(Tuple{typeof(Base.__precompile__)}) | |
133 | precompile(Tuple{typeof(Base._atexit)}) | |
134 | precompile(Tuple{typeof(Base._compute_eltype), Type{Tuple{Int64, String}}}) | |
135 | precompile(Tuple{typeof(Base._iterate), Base.Dict{Symbol, Any}, Int64}) | |
136 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Int64}, Type{String}}) | |
137 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Nothing}, Type{String}}) | |
138 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Union{}}, Type{Int64}}) | |
139 | precompile(Tuple{typeof(Base._reformat_bt), Array{Ptr{Nothing}, 1}, Array{Any, 1}}) | |
140 | precompile(Tuple{typeof(Base._similar_for), Array{Any, 1}, Type{String}, Base.Generator{Array{Any, 1}, typeof(Base.string)}, Base.HasShape{1}}) | |
141 | precompile(Tuple{typeof(Base._similar_for), Array{Base.Docs.DocStr, 1}, Type{Markdown.MD}, Base.Generator{Array{Base.Docs.DocStr, 1}, typeof(Base.Docs.parsedoc)}, Base.HasShape{1}}) | |
142 | precompile(Tuple{typeof(Base._similar_for), Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}, Type{Array{Base.StackTraces.StackFrame, 1}}, Base.Generator{Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}, typeof(Base.StackTraces.lookup)}, Base.HasShape{1}}) | |
143 | precompile(Tuple{typeof(Base._spawn), Base.CmdRedirect, Tuple{Base.Pipe, Base.TTY, Base.IOStream}}) | |
144 | precompile(Tuple{typeof(Base._start)}) | |
145 | precompile(Tuple{typeof(Base._typed_vcat), Type{Any}, Tuple{Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{String, 1}}}) | |
146 | precompile(Tuple{typeof(Base._uv_hook_close), Base.PipeEndpoint}) | |
147 | precompile(Tuple{typeof(Base._uv_hook_close), Base.Process}) | |
148 | precompile(Tuple{typeof(Base._uv_hook_close), Base.Timer}) | |
149 | precompile(Tuple{typeof(Base.alignment), Base.IOContext{REPL.Terminals.TTYTerminal}, Array{Float64, 1}, Base.OneTo{Int64}, Base.OneTo{Int64}, Int64, Int64, Int64}) | |
150 | precompile(Tuple{typeof(Base.alignment), Base.IOContext{REPL.Terminals.TTYTerminal}, Array{Float64, 2}, Base.OneTo{Int64}, Base.OneTo{Int64}, Int64, Int64, Int64}) | |
151 | precompile(Tuple{typeof(Base.alignment), Base.IOContext{REPL.Terminals.TTYTerminal}, Array{Int64, 1}, Base.OneTo{Int64}, Base.OneTo{Int64}, Int64, Int64, Int64}) | |
152 | precompile(Tuple{typeof(Base.alloc_buf_hook), Base.PipeEndpoint, UInt64}) | |
153 | precompile(Tuple{typeof(Base.alloc_buf_hook), Base.TTY, UInt64}) | |
154 | precompile(Tuple{typeof(Base.append!), Array{String, 1}, Array{String, 1}}) | |
155 | precompile(Tuple{typeof(Base.arg_gen), Base.Cmd}) | |
156 | precompile(Tuple{typeof(Base.arg_gen), String}) | |
157 | precompile(Tuple{typeof(Base.axes), Array{Any, 1}}) | |
158 | precompile(Tuple{typeof(Base.bytesavailable), Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
159 | precompile(Tuple{typeof(Base.catch_backtrace)}) | |
160 | precompile(Tuple{typeof(Base.check_open), Base.TTY}) | |
161 | precompile(Tuple{typeof(Base.close), Base.Pipe}) | |
162 | precompile(Tuple{typeof(Base.collect_similar), Array{Any, 1}, Base.Generator{Array{Any, 1}, typeof(Base.names)}}) | |
163 | precompile(Tuple{typeof(Base.collect_to_with_first!), Array{Array{Base.StackTraces.StackFrame, 1}, 1}, Array{Base.StackTraces.StackFrame, 1}, Base.Generator{Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}, typeof(Base.StackTraces.lookup)}, Int64}) | |
164 | precompile(Tuple{typeof(Base.collect_to_with_first!), Array{Markdown.MD, 1}, Markdown.MD, Base.Generator{Array{Base.Docs.DocStr, 1}, typeof(Base.Docs.parsedoc)}, Int64}) | |
165 | precompile(Tuple{typeof(Base.collect_to_with_first!), Array{String, 1}, String, Base.Generator{Array{Any, 1}, typeof(Base.string)}, Int64}) | |
166 | precompile(Tuple{typeof(Base.collect_to_with_first!), Array{String, 1}, String, Base.Generator{Array{REPL.REPLCompletions.Completion, 1}, typeof(REPL.REPLCompletions.completion_text)}, Int64}) | |
167 | precompile(Tuple{typeof(Base.convert), Type{Array{String, 1}}, Array{Any, 1}}) | |
168 | precompile(Tuple{typeof(Base.convert), Type{Base.Dict{Char, V} where V}, Base.Dict{Char, Any}}) | |
169 | precompile(Tuple{typeof(Base.convert), Type{Base.Dict{K, V} where V where K}, Base.Dict{String, Any}}) | |
170 | precompile(Tuple{typeof(Base.convert), Type{Base.GenericIOBuffer{Array{UInt8, 1}}}, Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
171 | precompile(Tuple{typeof(Base.convert), Type{Bool}, Bool}) | |
172 | precompile(Tuple{typeof(Base.convert), Type{Int64}, Int64}) | |
173 | precompile(Tuple{typeof(Base.convert), Type{Ptr{Nothing}}, Ptr{Nothing}}) | |
174 | precompile(Tuple{typeof(Base.convert), Type{Ptr{Nothing}}, Ptr{UInt8}}) | |
175 | precompile(Tuple{typeof(Base.convert), Type{REPL.LineEdit.InputAreaState}, REPL.LineEdit.InputAreaState}) | |
176 | precompile(Tuple{typeof(Base.convert), Type{REPL.LineEdit.MIState}, REPL.LineEdit.MIState}) | |
177 | precompile(Tuple{typeof(Base.convert), Type{REPL.LineEdit.Prompt}, REPL.LineEdit.Prompt}) | |
178 | precompile(Tuple{typeof(Base.convert), Type{Union{Base.UUID, Bool}}, Bool}) | |
179 | precompile(Tuple{typeof(Base.convert), Type{Union{Function, String}}, String}) | |
180 | precompile(Tuple{typeof(Base.convert), Type{Union{Nothing, REPL.LineEdit.Prompt}}, REPL.LineEdit.Prompt}) | |
181 | precompile(Tuple{typeof(Base.convert), Type{Union{Nothing, Type{T} where T}}, Nothing}) | |
182 | precompile(Tuple{typeof(Base.copy), Array{Any, 1}}) | |
183 | precompile(Tuple{typeof(Base.copy), Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
184 | precompile(Tuple{typeof(Base.copymutable), Array{String, 1}}) | |
185 | precompile(Tuple{typeof(Base.copyto!), Array{Union{Nothing, String}, 1}, Int64, Array{Nothing, 1}, Int64, Int64}) | |
186 | precompile(Tuple{typeof(Base.delete!), Base.Set{Any}, Char}) | |
187 | precompile(Tuple{typeof(Base.diff_names), Tuple{Symbol, Symbol, Symbol, Symbol, Symbol}, Tuple{Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol}}) | |
188 | precompile(Tuple{typeof(Base.diff_names), Tuple{Symbol, Symbol, Symbol}, Tuple{Symbol, Symbol, Symbol, Symbol, Symbol}}) | |
189 | precompile(Tuple{typeof(Base.diff_names), Tuple{Symbol}, Tuple{Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol}}) | |
190 | precompile(Tuple{typeof(Base.diff_names), Tuple{Symbol}, Tuple{Symbol}}) | |
191 | precompile(Tuple{typeof(Base.display_error), REPL.Terminals.TTYTerminal, ErrorException, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) | |
192 | precompile(Tuple{typeof(Base.display_error), REPL.Terminals.TTYTerminal, MethodError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) | |
193 | precompile(Tuple{typeof(Base.display_error), REPL.Terminals.TTYTerminal, UndefVarError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) | |
194 | precompile(Tuple{typeof(Base.displaysize), Base.IOStream}) | |
195 | precompile(Tuple{typeof(Base.displaysize), Base.TTY}) | |
196 | precompile(Tuple{typeof(Base.displaysize), REPL.Terminals.TTYTerminal}) | |
197 | precompile(Tuple{typeof(Base.divrem), Int64, Int64}) | |
198 | precompile(Tuple{typeof(Base.eachline), String}) | |
199 | precompile(Tuple{typeof(Base.empty!), Array{Base.Pair{Base.PkgId, UInt64}, 1}}) | |
200 | precompile(Tuple{typeof(Base.ensure_rescheduled), Task}) | |
201 | precompile(Tuple{typeof(Base.eof), Base.PipeEndpoint}) | |
202 | precompile(Tuple{typeof(Base.eof), Base.TTY}) | |
203 | precompile(Tuple{typeof(Base.error), String}) | |
204 | precompile(Tuple{typeof(Base.findlast), String, String}) | |
205 | precompile(Tuple{typeof(Base.findprev), Base.Fix2{typeof(Base.in), Array{Char, 1}}, String, Int64}) | |
206 | precompile(Tuple{typeof(Base.findprev), String, String, Int64}) | |
207 | precompile(Tuple{typeof(Base.first), Base.OneTo{Int64}}) | |
208 | precompile(Tuple{typeof(Base.first), Base.UnitRange{Int64}}) | |
209 | precompile(Tuple{typeof(Base.firstindex), String}) | |
210 | precompile(Tuple{typeof(Base.flush), Base.IOStream}) | |
211 | precompile(Tuple{typeof(Base.gc_alloc_count), Base.GC_Diff}) | |
212 | precompile(Tuple{typeof(Base.gc_num)}) | |
213 | precompile(Tuple{typeof(Base.get), Base.Dict{Char, Any}, Char, Nothing}) | |
214 | precompile(Tuple{typeof(Base.getindex), Array{AbstractString, 1}, Base.UnitRange{Int64}}) | |
215 | precompile(Tuple{typeof(Base.getindex), Array{AbstractString, 1}, Int64}) | |
216 | precompile(Tuple{typeof(Base.getindex), Array{Any, 1}, Int32}) | |
217 | precompile(Tuple{typeof(Base.getindex), Array{Int32, 1}, UInt64}) | |
218 | precompile(Tuple{typeof(Base.getindex), Array{String, 1}, Int64}) | |
219 | precompile(Tuple{typeof(Base.getindex), Array{UInt8, 1}, Int64}) | |
220 | precompile(Tuple{typeof(Base.getindex), Base.Dict{Any, Any}, Char}) | |
221 | precompile(Tuple{typeof(Base.getindex), Base.Dict{String, Any}, String}) | |
222 | precompile(Tuple{typeof(Base.getindex), Base.Dict{Symbol, Any}, Symbol}) | |
223 | precompile(Tuple{typeof(Base.getindex), Core.SimpleVector, Base.UnitRange{Int64}}) | |
224 | precompile(Tuple{typeof(Base.getindex), String, Base.UnitRange{Int64}}) | |
225 | precompile(Tuple{typeof(Base.getindex), Tuple{Base.GenericIOBuffer{Array{UInt8, 1}}, Int64}, Int64}) | |
226 | precompile(Tuple{typeof(Base.getindex), Tuple{Base.StackTraces.StackFrame, Int64}, Int64}) | |
227 | precompile(Tuple{typeof(Base.getindex), Tuple{Int64, Int64}, Int64}) | |
228 | precompile(Tuple{typeof(Base.getindex), Tuple{Symbol, Symbol, Symbol}, Base.UnitRange{Int64}}) | |
229 | precompile(Tuple{typeof(Base.getindex), Tuple{Symbol}, Base.UnitRange{Int64}}) | |
230 | precompile(Tuple{typeof(Base.getindex), Tuple{Symbol}, Int64}) | |
231 | precompile(Tuple{typeof(Base.getproperty), Base.CoreLogging.LogState, Symbol}) | |
232 | precompile(Tuple{typeof(Base.getproperty), Base.GC_Diff, Symbol}) | |
233 | precompile(Tuple{typeof(Base.getproperty), Base.GenericIOBuffer{Array{UInt8, 1}}, Symbol}) | |
234 | precompile(Tuple{typeof(Base.getproperty), Base.Process, Symbol}) | |
235 | precompile(Tuple{typeof(Base.getproperty), Base.StackTraces.StackFrame, Symbol}) | |
236 | precompile(Tuple{typeof(Base.getproperty), Core.CodeInfo, Symbol}) | |
237 | precompile(Tuple{typeof(Base.getproperty), Core.LineInfoNode, Symbol}) | |
238 | precompile(Tuple{typeof(Base.getproperty), Core.MethodTable, Symbol}) | |
239 | precompile(Tuple{typeof(Base.getproperty), Method, Symbol}) | |
240 | precompile(Tuple{typeof(Base.getproperty), REPL.LineEdit.HistoryPrompt, Symbol}) | |
241 | precompile(Tuple{typeof(Base.getproperty), REPL.LineEdit.ModalInterface, Symbol}) | |
242 | precompile(Tuple{typeof(Base.getproperty), REPL.LineEdit.PrefixHistoryPrompt, Symbol}) | |
243 | precompile(Tuple{typeof(Base.getproperty), REPL.LineEdit.PrefixSearchState, Symbol}) | |
244 | precompile(Tuple{typeof(Base.getproperty), REPL.LineEdit.Prompt, Symbol}) | |
245 | precompile(Tuple{typeof(Base.getproperty), REPL.LineEdit.PromptState, Symbol}) | |
246 | precompile(Tuple{typeof(Base.getproperty), REPL.LineEdit.SearchState, Symbol}) | |
247 | precompile(Tuple{typeof(Base.getproperty), REPL.LineEditREPL, Symbol}) | |
248 | precompile(Tuple{typeof(Base.getproperty), REPL.Options, Symbol}) | |
249 | precompile(Tuple{typeof(Base.getproperty), REPL.REPLHistoryProvider, Symbol}) | |
250 | precompile(Tuple{typeof(Base.getproperty), REPL.Terminals.TTYTerminal, Symbol}) | |
251 | precompile(Tuple{typeof(Base.haskey), Base.Dict{String, Any}, String}) | |
252 | precompile(Tuple{typeof(Base.haskey), Base.Dict{Symbol, Any}, Symbol}) | |
253 | precompile(Tuple{typeof(Base.haskey), Base.Dict{Symbol, Function}, Symbol}) | |
254 | precompile(Tuple{typeof(Base.haskey), Base.IdDict{Any, Any}, Base.Docs.Binding}) | |
255 | precompile(Tuple{typeof(Base.hvcat), Tuple{Int64, Int64}, Float64, Float64, Float64, Float64}) | |
256 | precompile(Tuple{typeof(Base.identity), Char}) | |
257 | precompile(Tuple{typeof(Base.in), Char, Tuple{Char, Char, Char}}) | |
258 | precompile(Tuple{typeof(Base.in), String, Base.Set{Any}}) | |
259 | precompile(Tuple{typeof(Base.in), String, Tuple{String, String}}) | |
260 | precompile(Tuple{typeof(Base.in), Symbol, Base.Set{Any}}) | |
261 | precompile(Tuple{typeof(Base.incomplete_tag), Symbol}) | |
262 | precompile(Tuple{typeof(Base.indexed_iterate), Base.Pair{String, String}, Int64, Int64}) | |
263 | precompile(Tuple{typeof(Base.indexed_iterate), Base.Pair{String, String}, Int64}) | |
264 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{ArgumentError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}, Int64, Int64}) | |
265 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{ArgumentError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}, Int64}) | |
266 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Float64, 1}, Nothing}, Int64, Int64}) | |
267 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Float64, 1}, Nothing}, Int64}) | |
268 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Float64, 2}, Nothing}, Int64, Int64}) | |
269 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Float64, 2}, Nothing}, Int64}) | |
270 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Int64, 1}, Nothing}, Int64, Int64}) | |
271 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{Int64, 1}, Nothing}, Int64}) | |
272 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{String, 1}, String, Bool}, Int64, Int64}) | |
273 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Array{String, 1}, String, Bool}, Int64}) | |
274 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Base.GenericIOBuffer{Array{UInt8, 1}}, Bool, Bool}, Int64, Int64}) | |
275 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Base.GenericIOBuffer{Array{UInt8, 1}}, Bool, Bool}, Int64}) | |
276 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Base.StackTraces.StackFrame, Int64}, Int64, Int64}) | |
277 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Base.StackTraces.StackFrame, Int64}, Int64}) | |
278 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{ErrorException, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}, Int64, Int64}) | |
279 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{ErrorException, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}, Int64}) | |
280 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Expr, Int64}, Int64, Int64}) | |
281 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Expr, Int64}, Int64}) | |
282 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Float64, Nothing}, Int64, Int64}) | |
283 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Float64, Nothing}, Int64}) | |
284 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Int64, Nothing}, Int64, Int64}) | |
285 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Int64, Nothing}, Int64}) | |
286 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Markdown.MD, Nothing}, Int64, Int64}) | |
287 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Markdown.MD, Nothing}, Int64}) | |
288 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{MethodError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}, Int64, Int64}) | |
289 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{MethodError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}, Int64}) | |
290 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Nothing, Nothing}, Int64, Int64}) | |
291 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Nothing, Nothing}, Int64}) | |
292 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{String, Nothing}, Int64, Int64}) | |
293 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{String, Nothing}, Int64}) | |
294 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Symbol, String, String}, Int64, Int64}) | |
295 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Symbol, String, String}, Int64}) | |
296 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{UndefVarError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}, Int64, Int64}) | |
297 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{UndefVarError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}, Int64}) | |
298 | precompile(Tuple{typeof(Base.init_stdio), Ptr{Nothing}}) | |
299 | precompile(Tuple{typeof(Base.isempty), Array{Base.Docs.DocStr, 1}}) | |
300 | precompile(Tuple{typeof(Base.isempty), Array{String, 1}}) | |
301 | precompile(Tuple{typeof(Base.isempty), Core.SimpleVector}) | |
302 | precompile(Tuple{typeof(Base.isempty), NamedTuple{(), Tuple{}}}) | |
303 | precompile(Tuple{typeof(Base.isempty), Nothing}) | |
304 | precompile(Tuple{typeof(Base.isempty), REPL.LineEdit.PromptState}) | |
305 | precompile(Tuple{typeof(Base.isempty), String}) | |
306 | precompile(Tuple{typeof(Base.isequal), REPL.LineEdit.Prompt, REPL.LineEdit.Prompt}) | |
307 | precompile(Tuple{typeof(Base.isequal), String, Symbol}) | |
308 | precompile(Tuple{typeof(Base.issingletontype), Type{Base.Regex}}) | |
309 | precompile(Tuple{typeof(Base.iterate), Array{AbstractString, 1}, Int64}) | |
310 | precompile(Tuple{typeof(Base.iterate), Array{AbstractString, 1}}) | |
311 | precompile(Tuple{typeof(Base.iterate), Array{Base.StackTraces.StackFrame, 1}, Int64}) | |
312 | precompile(Tuple{typeof(Base.iterate), Array{Base.StackTraces.StackFrame, 1}}) | |
313 | precompile(Tuple{typeof(Base.iterate), Array{REPL.LineEdit.TextInterface, 1}, Int64}) | |
314 | precompile(Tuple{typeof(Base.iterate), Array{REPL.LineEdit.TextInterface, 1}}) | |
315 | precompile(Tuple{typeof(Base.iterate), Base.Dict{String, String}, Int64}) | |
316 | precompile(Tuple{typeof(Base.iterate), Base.Dict{String, String}}) | |
317 | precompile(Tuple{typeof(Base.iterate), Base.OneTo{Int64}, Int64}) | |
318 | precompile(Tuple{typeof(Base.iterate), Base.OneTo{Int64}}) | |
319 | precompile(Tuple{typeof(Base.iterate), Nothing}) | |
320 | precompile(Tuple{typeof(Base.iterate), Tuple{Int64, Int64}, Int64}) | |
321 | precompile(Tuple{typeof(Base.iterate), Tuple{Int64, Int64}}) | |
322 | precompile(Tuple{typeof(Base.last), Base.OneTo{Int64}}) | |
323 | precompile(Tuple{typeof(Base.lastindex), Array{AbstractString, 1}}) | |
324 | precompile(Tuple{typeof(Base.lastindex), Array{String, 1}}) | |
325 | precompile(Tuple{typeof(Base.lastindex), Core.SimpleVector}) | |
326 | precompile(Tuple{typeof(Base.lastindex), String}) | |
327 | precompile(Tuple{typeof(Base.lastindex), Tuple{Symbol}}) | |
328 | precompile(Tuple{typeof(Base.leading_ones), UInt8}) | |
329 | precompile(Tuple{typeof(Base.length), Array{AbstractString, 1}}) | |
330 | precompile(Tuple{typeof(Base.length), Array{Int32, 1}}) | |
331 | precompile(Tuple{typeof(Base.length), Array{Symbol, 1}}) | |
332 | precompile(Tuple{typeof(Base.length), Tuple{DataType, DataType}}) | |
333 | precompile(Tuple{typeof(Base.map), typeof(Base.names), Array{Any, 1}}) | |
334 | precompile(Tuple{typeof(Base.merge), Base.Dict{String, Any}, Base.Dict{String, Any}}) | |
335 | precompile(Tuple{typeof(Base.merge), NamedTuple{(), Tuple{}}, NamedTuple{(), Tuple{}}}) | |
336 | precompile(Tuple{typeof(Base.min), Int64, Int64}) | |
337 | precompile(Tuple{typeof(Base.nextind), String, Int64}) | |
338 | precompile(Tuple{typeof(Base.occursin), Base.Regex, Base.SubString{String}}) | |
339 | precompile(Tuple{typeof(Base.occursin), String, String}) | |
340 | precompile(Tuple{typeof(Base.open), Base.CmdRedirect, String, Base.TTY}) | |
341 | precompile(Tuple{typeof(Base.open), String, String}) | |
342 | precompile(Tuple{typeof(Base.poptask)}) | |
343 | precompile(Tuple{typeof(Base.position), Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
344 | precompile(Tuple{typeof(Base.precompilableerror), LoadError, Bool}) | |
345 | precompile(Tuple{typeof(Base.preserve_handle), Base.Timer}) | |
346 | precompile(Tuple{typeof(Base.prevind), String, Int64}) | |
347 | precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, Base.UUID}) | |
348 | precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, String, Base.SubString{String}, String}) | |
349 | precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, String, String, String, String, String, String, String}) | |
350 | precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, Type{Int64}}) | |
351 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Base.SubString{String}}) | |
352 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Char, String, String}) | |
353 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Char}) | |
354 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Module, String, Symbol}) | |
355 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String, String}) | |
356 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String, Symbol, String, Int32}) | |
357 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String, Symbol}) | |
358 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String}) | |
359 | precompile(Tuple{typeof(Base.print), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Symbol}) | |
360 | precompile(Tuple{typeof(Base.print), Base.IOContext{REPL.Terminals.TTYTerminal}, Char, String, String}) | |
361 | precompile(Tuple{typeof(Base.print), Base.IOContext{REPL.Terminals.TTYTerminal}, Char}) | |
362 | precompile(Tuple{typeof(Base.print), Base.IOContext{REPL.Terminals.TTYTerminal}, String, String, String, String}) | |
363 | precompile(Tuple{typeof(Base.print), Base.IOContext{REPL.Terminals.TTYTerminal}, String, Type{Module}}) | |
364 | precompile(Tuple{typeof(Base.print), Base.IOContext{REPL.Terminals.TTYTerminal}, String}) | |
365 | precompile(Tuple{typeof(Base.print), Base.IOContext{REPL.Terminals.TTYTerminal}, Type{Module}}) | |
366 | precompile(Tuple{typeof(Base.print), Base.IOStream, Char}) | |
367 | precompile(Tuple{typeof(Base.print), Base.IOStream, String}) | |
368 | precompile(Tuple{typeof(Base.print), Base.TTY, Char}) | |
369 | precompile(Tuple{typeof(Base.print), Base.TTY, String}) | |
370 | precompile(Tuple{typeof(Base.print), REPL.Terminals.TTYTerminal, String}) | |
371 | precompile(Tuple{typeof(Base.print_matrix_row), Base.IOContext{REPL.Terminals.TTYTerminal}, Array{Float64, 1}, Array{Tuple{Int64, Int64}, 1}, Int64, Base.OneTo{Int64}, String}) | |
372 | precompile(Tuple{typeof(Base.print_matrix_row), Base.IOContext{REPL.Terminals.TTYTerminal}, Array{Float64, 2}, Array{Tuple{Int64, Int64}, 1}, Int64, Base.OneTo{Int64}, String}) | |
373 | precompile(Tuple{typeof(Base.print_matrix_row), Base.IOContext{REPL.Terminals.TTYTerminal}, Array{Int64, 1}, Array{Tuple{Int64, Int64}, 1}, Int64, Base.OneTo{Int64}, String}) | |
374 | precompile(Tuple{typeof(Base.print_to_string), Type{Any}}) | |
375 | precompile(Tuple{typeof(Base.println), Base.TTY}) | |
376 | precompile(Tuple{typeof(Base.println), REPL.Terminals.TTYTerminal}) | |
377 | precompile(Tuple{typeof(Base.println), String}) | |
378 | precompile(Tuple{typeof(Base.promote_eltype), Array{Symbol, 1}, Array{String, 1}}) | |
379 | precompile(Tuple{typeof(Base.promote_eltype), Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{String, 1}}) | |
380 | precompile(Tuple{typeof(Base.push!), Array{Base.Docs.DocStr, 1}, Base.Docs.DocStr}) | |
381 | precompile(Tuple{typeof(Base.push!), Array{Base.Docs.MultiDoc, 1}, Base.Docs.MultiDoc}) | |
382 | precompile(Tuple{typeof(Base.push!), Array{Base.Pair{Base.PkgId, UInt64}, 1}, Base.Pair{Base.PkgId, UInt64}}) | |
383 | precompile(Tuple{typeof(Base.push!), Array{Char, 1}, Char}) | |
384 | precompile(Tuple{typeof(Base.push!), Array{Symbol, 1}, Symbol}) | |
385 | precompile(Tuple{typeof(Base.push!), Array{Tuple{String, Int64}, 1}, Tuple{String, Int64}}) | |
386 | precompile(Tuple{typeof(Base.push!), Base.Set{Any}, Char}) | |
387 | precompile(Tuple{typeof(Base.push!), Base.Set{Any}, Tuple{Module, String, Float64}}) | |
388 | precompile(Tuple{typeof(Base.push!), Base.Set{REPL.REPLCompletions.Completion}, REPL.REPLCompletions.PackageCompletion}) | |
389 | precompile(Tuple{typeof(Base.push!), Base.Set{String}, Base.SubString{String}}) | |
390 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{ArgumentError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}}) | |
391 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{Array{Float64, 1}, Nothing}}) | |
392 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{Array{Float64, 2}, Nothing}}) | |
393 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{Array{Int64, 1}, Nothing}}) | |
394 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{ErrorException, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}}) | |
395 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{Float64, Nothing}}) | |
396 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{Int64, Nothing}}) | |
397 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{Markdown.MD, Nothing}}) | |
398 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{MethodError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}}) | |
399 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{Nothing, Nothing}}) | |
400 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{String, Nothing}}) | |
401 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{UndefVarError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}}) | |
402 | precompile(Tuple{typeof(Base.rand), Int64, Int64}) | |
403 | precompile(Tuple{typeof(Base.rand), Int64}) | |
404 | precompile(Tuple{typeof(Base.rand), Random.RandomDevice, Type{UInt32}, Int64}) | |
405 | precompile(Tuple{typeof(Base.rand)}) | |
406 | precompile(Tuple{typeof(Base.read!), Base.GenericIOBuffer{Array{UInt8, 1}}, Array{UInt8, 1}}) | |
407 | precompile(Tuple{typeof(Base.read), Base.TTY, Type{UInt8}}) | |
408 | precompile(Tuple{typeof(Base.readuntil), Base.PipeEndpoint, Char}) | |
409 | precompile(Tuple{typeof(Base.readuntil), Base.TTY, String}) | |
410 | precompile(Tuple{typeof(Base.readuntil), REPL.Terminals.TTYTerminal, String}) | |
411 | precompile(Tuple{typeof(Base.reinterpret), Type{Char}, UInt32}) | |
412 | precompile(Tuple{typeof(Base.replace), Base.SubString{String}, Base.Pair{Base.Regex, String}}) | |
413 | precompile(Tuple{typeof(Base.resize!), Array{Tuple{String, Int64}, 1}, Int64}) | |
414 | precompile(Tuple{typeof(Base.rethrow)}) | |
415 | precompile(Tuple{typeof(Base.seek), Base.GenericIOBuffer{Array{UInt8, 1}}, Int64}) | |
416 | precompile(Tuple{typeof(Base.setindex!), Array{Any, 1}, Array{String, 1}, Base.UnitRange{Int64}}) | |
417 | precompile(Tuple{typeof(Base.setindex!), Array{Any, 1}, Array{Symbol, 1}, Base.UnitRange{Int64}}) | |
418 | precompile(Tuple{typeof(Base.setindex!), Array{Base.StackTraces.StackFrame, 1}, Base.StackTraces.StackFrame, Int64}) | |
419 | precompile(Tuple{typeof(Base.setindex!), Array{Method, 1}, Method, Int64}) | |
420 | precompile(Tuple{typeof(Base.setindex!), Array{String, 1}, String, Int64}) | |
421 | precompile(Tuple{typeof(Base.setindex!), Array{Symbol, 1}, Symbol, Int64}) | |
422 | precompile(Tuple{typeof(Base.setindex!), Array{Union{Nothing, String}, 1}, String, Int64}) | |
423 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Any, Any}, Char, Char}) | |
424 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Any, Any}, Char, String}) | |
425 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Any, Any}, Module, Symbol}) | |
426 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Any, Any}, Type{Union{}}, Symbol}) | |
427 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Symbol, Any}, REPL.LineEdit.Prompt, Symbol}) | |
428 | precompile(Tuple{typeof(Base.setindex!), Base.RefValue{Bool}, Bool}) | |
429 | precompile(Tuple{typeof(Base.setproperty!), Base.Iterators.Stateful{Tuple{String, String}, Any}, Symbol, Tuple{String, Int64}}) | |
430 | precompile(Tuple{typeof(Base.setproperty!), Base.Process, Symbol, Ptr{Nothing}}) | |
431 | precompile(Tuple{typeof(Base.setproperty!), Base.Process, Symbol, Symbol}) | |
432 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.MIState, Symbol, Symbol}) | |
433 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.PrefixHistoryPrompt, Symbol, REPL.LineEdit.Prompt}) | |
434 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.PrefixSearchState, Symbol, Int64}) | |
435 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.PrefixSearchState, Symbol, REPL.LineEdit.MIState}) | |
436 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.PrefixSearchState, Symbol, REPL.LineEdit.Prompt}) | |
437 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.PrefixSearchState, Symbol, String}) | |
438 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.Prompt, Symbol, Base.Dict{Char, Any}}) | |
439 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.PromptState, Symbol, Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
440 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.PromptState, Symbol, REPL.LineEdit.InputAreaState}) | |
441 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.SearchState, Symbol, Bool}) | |
442 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEdit.SearchState, Symbol, REPL.LineEdit.Prompt}) | |
443 | precompile(Tuple{typeof(Base.setproperty!), REPL.LineEditREPL, Symbol, Bool}) | |
444 | precompile(Tuple{typeof(Base.setproperty!), REPL.REPLHistoryProvider, Symbol, Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
445 | precompile(Tuple{typeof(Base.setproperty!), REPL.REPLHistoryProvider, Symbol, REPL.LineEdit.Prompt}) | |
446 | precompile(Tuple{typeof(Base.show), Base.GenericIOBuffer{Array{UInt8, 1}}, Array{String, 1}}) | |
447 | precompile(Tuple{typeof(Base.show), Base.GenericIOBuffer{Array{UInt8, 1}}, String}) | |
448 | precompile(Tuple{typeof(Base.show), Base.GenericIOBuffer{Array{UInt8, 1}}, Type{Any}}) | |
449 | precompile(Tuple{typeof(Base.show), Base.GenericIOBuffer{Array{UInt8, 1}}, UInt64}) | |
450 | precompile(Tuple{typeof(Base.show), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Array{Any, 1}}) | |
451 | precompile(Tuple{typeof(Base.show), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Int64}) | |
452 | precompile(Tuple{typeof(Base.show), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String}) | |
453 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Base.MIME{Symbol("text/plain")}, Array{Float64, 1}}) | |
454 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Base.MIME{Symbol("text/plain")}, Array{Float64, 2}}) | |
455 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Base.MIME{Symbol("text/plain")}, Array{Int64, 1}}) | |
456 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Base.MIME{Symbol("text/plain")}, Float64}) | |
457 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Base.MIME{Symbol("text/plain")}, Int64}) | |
458 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Base.MIME{Symbol("text/plain")}, Markdown.MD}) | |
459 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Base.MIME{Symbol("text/plain")}, String}) | |
460 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Int64}) | |
461 | precompile(Tuple{typeof(Base.show), Base.IOContext{REPL.Terminals.TTYTerminal}, Type{Module}}) | |
462 | precompile(Tuple{typeof(Base.show_datatype), Base.IOContext{REPL.Terminals.TTYTerminal}, Type{Module}}) | |
463 | precompile(Tuple{typeof(Base.show_tuple_as_call), Base.IOContext{REPL.Terminals.TTYTerminal}, Symbol, Type{Tuple{typeof(Base.require), Module, Symbol}}}) | |
464 | precompile(Tuple{typeof(Base.showerror), Base.IOContext{REPL.Terminals.TTYTerminal}, ArgumentError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) | |
465 | precompile(Tuple{typeof(Base.showerror), Base.IOContext{REPL.Terminals.TTYTerminal}, ErrorException, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) | |
466 | precompile(Tuple{typeof(Base.showerror), Base.IOContext{REPL.Terminals.TTYTerminal}, MethodError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) | |
467 | precompile(Tuple{typeof(Base.showerror), Base.IOContext{REPL.Terminals.TTYTerminal}, UndefVarError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) | |
468 | precompile(Tuple{typeof(Base.similar), Array{Any, 1}, Type{Nothing}, Tuple{Base.OneTo{Int64}}}) | |
469 | precompile(Tuple{typeof(Base.similar), Array{Base.Docs.DocStr, 1}, Type{Markdown.MD}, Tuple{Base.OneTo{Int64}}}) | |
470 | precompile(Tuple{typeof(Base.similar), Array{REPL.REPLCompletions.Completion, 1}, Type{String}, Tuple{Base.OneTo{Int64}}}) | |
471 | precompile(Tuple{typeof(Base.similar), Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}, Type{Array{Base.StackTraces.StackFrame, 1}}, Tuple{Base.OneTo{Int64}}}) | |
472 | precompile(Tuple{typeof(Base.similar), Type{Array{Method, N} where N}, Tuple{Base.OneTo{Int64}}}) | |
473 | precompile(Tuple{typeof(Base.sizeof), String}) | |
474 | precompile(Tuple{typeof(Base.skip_deleted_floor!), Base.Dict{Symbol, Any}}) | |
475 | precompile(Tuple{typeof(Base.sort!), Array{Int64, 1}, Base.Sort.QuickSortAlg, Base.Order.Perm{Base.Order.ForwardOrdering, Array{Tuple{Float64, Int64}, 1}}}) | |
476 | precompile(Tuple{typeof(Base.startswith), Base.SubString{String}, String}) | |
477 | precompile(Tuple{typeof(Base.startswith), String, Char}) | |
478 | precompile(Tuple{typeof(Base.stream_wait), Base.Timer, Base.Condition}) | |
479 | precompile(Tuple{typeof(Base.string), String, Nothing, String, String, String, Int64}) | |
480 | precompile(Tuple{typeof(Base.string), String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, Base.VersionNumber, String, String, String, String, String, String, String, String, String, String, String, String, String, String}) | |
481 | precompile(Tuple{typeof(Base.string), String, Type{Int64}}) | |
482 | precompile(Tuple{typeof(Base.string), Type{Any}}) | |
483 | precompile(Tuple{typeof(Base.strip), String}) | |
484 | precompile(Tuple{typeof(Base.take!), Base.Channel{Any}}) | |
485 | precompile(Tuple{typeof(Base.take!), Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
486 | precompile(Tuple{typeof(Base.task_done_hook), Task}) | |
487 | precompile(Tuple{typeof(Base.time_print), UInt64, Int64, Int64, Int64}) | |
488 | precompile(Tuple{typeof(Base.truncate), Base.GenericIOBuffer{Array{UInt8, 1}}, Int64}) | |
489 | precompile(Tuple{typeof(Base.try_yieldto), typeof(Base.ensure_rescheduled), Base.RefValue{Task}}) | |
490 | precompile(Tuple{typeof(Base.tuple_type_head), Type{Tuple{Vararg{Int64, N}} where N}}) | |
491 | precompile(Tuple{typeof(Base.tuple_type_tail), Type{Tuple{Vararg{Int64, N}} where N}}) | |
492 | precompile(Tuple{typeof(Base.typed_vcat), Type{Any}, Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{String, 1}}) | |
493 | precompile(Tuple{typeof(Base.typeinfo_eltype), Type{Any}}) | |
494 | precompile(Tuple{typeof(Base.typesof), Int64, Int64}) | |
495 | precompile(Tuple{typeof(Base.unique), Array{Any, 1}}) | |
496 | precompile(Tuple{typeof(Base.unlock), Base.Threads.RecursiveTatasLock}) | |
497 | precompile(Tuple{typeof(Base.unpreserve_handle), Base.Timer}) | |
498 | precompile(Tuple{typeof(Base.unsafe_convert), Type{Ptr{Int64}}, Base.Threads.Atomic{Int64}}) | |
499 | precompile(Tuple{typeof(Base.unsafe_convert), Type{Ptr{Nothing}}, Ptr{Nothing}}) | |
500 | precompile(Tuple{typeof(Base.unsafe_convert), Type{Ptr{UInt64}}, Base.Threads.Atomic{UInt64}}) | |
501 | precompile(Tuple{typeof(Base.unsafe_write), Base.Pipe, Ptr{UInt8}, UInt64}) | |
502 | precompile(Tuple{typeof(Base.unsafe_write), Base.TTY, Ptr{UInt8}, Int32}) | |
503 | precompile(Tuple{typeof(Base.unsafe_write), Base.TTY, Ptr{UInt8}, UInt64}) | |
504 | precompile(Tuple{typeof(Base.uvfinalize), Base.PipeEndpoint}) | |
505 | precompile(Tuple{typeof(Base.uvfinalize), Base.Process}) | |
506 | precompile(Tuple{typeof(Base.uvfinalize), Base.TTY}) | |
507 | precompile(Tuple{typeof(Base.uvfinalize), Base.Timer}) | |
508 | precompile(Tuple{typeof(Base.vcat), Array{Any, 1}, String, String}) | |
509 | precompile(Tuple{typeof(Base.vcat), Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}, Array{Base.StackTraces.StackFrame, 1}}) | |
510 | precompile(Tuple{typeof(Base.vcat), Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{Symbol, 1}, Array{String, 1}}) | |
511 | precompile(Tuple{typeof(Base.vcat), Markdown.MD, Markdown.MD}) | |
512 | precompile(Tuple{typeof(Base.vcat), Markdown.MD}) | |
513 | precompile(Tuple{typeof(Base.vect), Symbol, Vararg{Symbol, N} where N}) | |
514 | precompile(Tuple{typeof(Base.wait), Base.Condition}) | |
515 | precompile(Tuple{typeof(Base.wait), Base.Timer}) | |
516 | precompile(Tuple{typeof(Base.wait)}) | |
517 | precompile(Tuple{typeof(Base.write), Base.GenericIOBuffer{Array{UInt8, 1}}, String}) | |
518 | precompile(Tuple{typeof(Base.write), Base.IOStream, Array{UInt8, 1}}) | |
519 | precompile(Tuple{typeof(Base.write), Base.Pipe, String}) | |
520 | precompile(Tuple{typeof(Base.write), Base.Process, String}) | |
521 | precompile(Tuple{typeof(Base.write), Base.TTY, Char}) | |
522 | precompile(Tuple{typeof(Base.write), Base.TTY, String}) | |
523 | precompile(Tuple{typeof(Base.write), Base.TTY, UInt8}) | |
524 | precompile(Tuple{typeof(Base.write), REPL.Terminals.TTYTerminal, String}) | |
525 | precompile(Tuple{typeof(Base.write), REPL.Terminals.TerminalBuffer, Base.Missing}) | |
526 | precompile(Tuple{typeof(Base.write), REPL.Terminals.TerminalBuffer, String}) | |
527 | precompile(Tuple{typeof(Core.Compiler.:(!=)), Type{Any}, Core.Compiler.Const}) | |
528 | precompile(Tuple{typeof(Core.Compiler.getindex), Array{DataType, 1}, Int64}) | |
529 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Array{Bool, 0}}, Int64}) | |
530 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Array{String, 1}}, Int64}) | |
531 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Broadcast.DefaultArrayStyle{0}, typeof(Base.identity), Int64}, Int64}) | |
532 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Colon}, Int64}) | |
533 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Base.Multimedia.display)}, Int64}) | |
534 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Base.__atreplinit)}, Int64}) | |
535 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Base.display_error)}, Int64}) | |
536 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Base.show)}, Int64}) | |
537 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(REPL.helpmode)}, Int64}) | |
538 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Val{1}, Union}, Int64}) | |
539 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Char, Char}, Int64}) | |
540 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Core.Compiler.IndexLinear, Array{Bool, 0}}, Int64}) | |
541 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Nothing, Nothing}, Int64}) | |
542 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Nothing, typeof(Base.replace), Nothing}, Int64}) | |
543 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{QuoteNode, Int64}, Int64}) | |
544 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{String, Int64}, Int64}) | |
545 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Symbol, Bool}, Int64}) | |
546 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Symbol, GlobalRef}, Int64}) | |
547 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.:(*)), Int64}, Int64}) | |
548 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.Multimedia.display), Int64}, Int64}) | |
549 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.convert), Int64}, Int64}) | |
550 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.convert), typeof(Base.getindex), typeof(Base.setindex!)}, Int64}) | |
551 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.getindex), typeof(Base.setindex!)}, Int64}) | |
552 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.open_flags)}, Int64}) | |
553 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.setindex!)}, Int64}) | |
554 | precompile(Tuple{typeof(Core.Compiler.getindex), Type{Any}, Core.SSAValue, Char, Core.SSAValue}) | |
555 | precompile(Tuple{typeof(Core.Compiler.getindex), Type{Any}, Core.SSAValue, Core.Compiler.Argument, Core.Compiler.Argument, Core.SSAValue, Core.SSAValue}) | |
556 | precompile(Tuple{typeof(Core.Compiler.getindex), Type{Any}, Core.SSAValue, Core.SSAValue, Int64, Core.SSAValue, Core.SSAValue}) | |
557 | precompile(Tuple{typeof(Core.Compiler.getindex), Type{Any}, Core.SSAValue, Core.SSAValue, String, Core.SSAValue}) | |
558 | precompile(Tuple{typeof(Core.Compiler.getindex), Type{Any}, Core.SSAValue, Int64, Core.SSAValue}) | |
559 | precompile(Tuple{typeof(Core.Compiler.getindex), Type{Any}, Core.SSAValue, UInt8, Core.SSAValue}) | |
560 | precompile(Tuple{typeof(Core.Compiler.getindex), Type{Any}, Tuple{Symbol}, Tuple{Symbol, Symbol, Symbol, Symbol, Symbol, Symbol, Symbol}}) | |
561 | precompile(Tuple{typeof(Core.Compiler.getindex), Type{Any}, getfield(Markdown, Symbol("#kw##print_wrapped")), Core.SSAValue, Core.SSAValue, Core.SSAValue, Core.Compiler.Argument, Core.SSAValue}) | |
562 | precompile(Tuple{typeof(Core.Compiler.instanceof_tfunc), Any}) | |
563 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Array{Bool, 0}}}) | |
564 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Array{String, 1}}}) | |
565 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Base.Broadcast.DefaultArrayStyle{0}, typeof(Base.identity), Int64}}) | |
566 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Base.Colon}}) | |
567 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Base.Multimedia.display)}}) | |
568 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Base.__atreplinit)}}) | |
569 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Base.display_error)}}) | |
570 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Base.show)}}) | |
571 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(REPL.helpmode)}}) | |
572 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Base.Val{1}, Union}}) | |
573 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Char, Char}}) | |
574 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Core.Compiler.IndexLinear, Array{Bool, 0}}}) | |
575 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Nothing, Nothing}}) | |
576 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Nothing, typeof(Base.replace), Nothing}}) | |
577 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Symbol, Bool}}) | |
578 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{Symbol, GlobalRef}}) | |
579 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{typeof(Base.:(*)), Int64}}) | |
580 | precompile(Tuple{typeof(Core.Compiler.length), Tuple{typeof(Base.open_flags)}}) | |
581 | precompile(Tuple{typeof(Core.Compiler.rewrap_unionall), Any, Any}) | |
582 | precompile(Tuple{typeof(Core.Compiler.vect), Type{typeof(typeassert)}}) | |
583 | precompile(Tuple{typeof(Distributed.flush_gc_msgs), Distributed.Worker}) | |
584 | precompile(Tuple{typeof(Distributed.flush_gc_msgs)}) | |
585 | precompile(Tuple{typeof(Distributed.terminate_all_workers)}) | |
586 | precompile(Tuple{typeof(LibGit2.ensure_initialized)}) | |
587 | precompile(Tuple{typeof(LibGit2.initialize)}) | |
588 | precompile(Tuple{typeof(Logging.__init__)}) | |
589 | precompile(Tuple{typeof(Logging.default_metafmt), Base.CoreLogging.LogLevel, Module, Symbol, Symbol, String, Int64}) | |
590 | precompile(Tuple{typeof(Logging.default_metafmt), Base.CoreLogging.LogLevel, Nothing, Symbol, Symbol, String, Int64}) | |
591 | precompile(Tuple{typeof(Markdown.ansi_length), Base.SubString{String}}) | |
592 | precompile(Tuple{typeof(Markdown.ansi_length), String}) | |
593 | precompile(Tuple{typeof(Markdown.footnote_link), Base.GenericIOBuffer{Array{UInt8, 1}}, Markdown.MD}) | |
594 | precompile(Tuple{typeof(Markdown.link), Base.GenericIOBuffer{Array{UInt8, 1}}, Markdown.MD}) | |
595 | precompile(Tuple{typeof(Markdown.term), Base.IOContext{REPL.Terminals.TTYTerminal}, Markdown.Code, Int64}) | |
596 | precompile(Tuple{typeof(Markdown.term), Base.IOContext{REPL.Terminals.TTYTerminal}, Markdown.Header{1}, Int64}) | |
597 | precompile(Tuple{typeof(Markdown.term), Base.IOContext{REPL.Terminals.TTYTerminal}, Markdown.HorizontalRule, Int64}) | |
598 | precompile(Tuple{typeof(Markdown.term), Base.IOContext{REPL.Terminals.TTYTerminal}, Markdown.MD, Int64}) | |
599 | precompile(Tuple{typeof(Markdown.term), Base.IOContext{REPL.Terminals.TTYTerminal}, Markdown.Paragraph, Int64}) | |
600 | precompile(Tuple{typeof(Markdown.terminline), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Array{Any, 1}}) | |
601 | precompile(Tuple{typeof(Markdown.terminline), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Markdown.Code}) | |
602 | precompile(Tuple{typeof(Markdown.terminline), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Markdown.Link}) | |
603 | precompile(Tuple{typeof(Markdown.terminline), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, String}) | |
604 | precompile(Tuple{typeof(Markdown.terminline_string), Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}}, Array{Any, 1}}) | |
605 | precompile(Tuple{typeof(Markdown.terminline_string), Base.IOContext{REPL.Terminals.TTYTerminal}, Array{Any, 1}}) | |
606 | precompile(Tuple{typeof(Pkg.REPLMode.create_mode), REPL.LineEditREPL, REPL.LineEdit.Prompt}) | |
607 | precompile(Tuple{typeof(Pkg.REPLMode.repl_init), REPL.LineEditREPL}) | |
608 | precompile(Tuple{typeof(REPL.LineEdit.accept_result), REPL.LineEdit.MIState, REPL.LineEdit.PrefixHistoryPrompt}) | |
609 | precompile(Tuple{typeof(REPL.LineEdit.activate), REPL.LineEdit.HistoryPrompt, REPL.LineEdit.SearchState, REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal}) | |
610 | precompile(Tuple{typeof(REPL.LineEdit.activate), REPL.LineEdit.PrefixHistoryPrompt, REPL.LineEdit.PrefixSearchState, REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal}) | |
611 | precompile(Tuple{typeof(REPL.LineEdit.activate), REPL.LineEdit.Prompt, REPL.LineEdit.MIState, REPL.Terminals.TTYTerminal, REPL.Terminals.TTYTerminal}) | |
612 | precompile(Tuple{typeof(REPL.LineEdit.activate), REPL.LineEdit.Prompt, REPL.LineEdit.PromptState, REPL.Terminals.TTYTerminal, REPL.Terminals.TTYTerminal}) | |
613 | precompile(Tuple{typeof(REPL.LineEdit.activate), REPL.LineEdit.Prompt, REPL.LineEdit.PromptState, REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal}) | |
614 | precompile(Tuple{typeof(REPL.LineEdit.activate_region), REPL.LineEdit.MIState, Symbol}) | |
615 | precompile(Tuple{typeof(REPL.LineEdit.buffer), REPL.LineEdit.MIState}) | |
616 | precompile(Tuple{typeof(REPL.LineEdit.buffer), REPL.LineEdit.PromptState}) | |
617 | precompile(Tuple{typeof(REPL.LineEdit.cancel_beep), REPL.LineEdit.MIState}) | |
618 | precompile(Tuple{typeof(REPL.LineEdit.cancel_beep), REPL.LineEdit.PrefixSearchState}) | |
619 | precompile(Tuple{typeof(REPL.LineEdit.cancel_beep), REPL.LineEdit.PromptState}) | |
620 | precompile(Tuple{typeof(REPL.LineEdit.cancel_beep), REPL.LineEdit.SearchState}) | |
621 | precompile(Tuple{typeof(REPL.LineEdit.commit_changes), REPL.Terminals.TTYTerminal, REPL.Terminals.TerminalBuffer}) | |
622 | precompile(Tuple{typeof(REPL.LineEdit.common_prefix), Array{String, 1}}) | |
623 | precompile(Tuple{typeof(REPL.LineEdit.complete_line), REPL.LineEdit.PromptState, Int64}) | |
624 | precompile(Tuple{typeof(REPL.LineEdit.complete_line), REPL.REPLCompletionProvider, REPL.LineEdit.PromptState}) | |
625 | precompile(Tuple{typeof(REPL.LineEdit.deactivate), REPL.LineEdit.HistoryPrompt, REPL.LineEdit.SearchState, REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal}) | |
626 | precompile(Tuple{typeof(REPL.LineEdit.deactivate), REPL.LineEdit.PrefixHistoryPrompt, REPL.LineEdit.PrefixSearchState, REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal}) | |
627 | precompile(Tuple{typeof(REPL.LineEdit.deactivate), REPL.LineEdit.Prompt, REPL.LineEdit.PromptState, REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal}) | |
628 | precompile(Tuple{typeof(REPL.LineEdit.deactivate_region), REPL.LineEdit.MIState}) | |
629 | precompile(Tuple{typeof(REPL.LineEdit.deactivate_region), REPL.LineEdit.PromptState}) | |
630 | precompile(Tuple{typeof(REPL.LineEdit.default_enter_cb), REPL.LineEdit.PromptState}) | |
631 | precompile(Tuple{typeof(REPL.LineEdit.edit_abort), REPL.LineEdit.MIState}) | |
632 | precompile(Tuple{typeof(REPL.LineEdit.edit_backspace), REPL.LineEdit.PromptState, Bool, Bool}) | |
633 | precompile(Tuple{typeof(REPL.LineEdit.edit_delete), Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
634 | precompile(Tuple{typeof(REPL.LineEdit.edit_delete), REPL.LineEdit.MIState}) | |
635 | precompile(Tuple{typeof(REPL.LineEdit.edit_insert), Base.GenericIOBuffer{Array{UInt8, 1}}, Base.SubString{String}}) | |
636 | precompile(Tuple{typeof(REPL.LineEdit.edit_splice!), REPL.LineEdit.PromptState, Base.Pair{Int64, Int64}, String}) | |
637 | precompile(Tuple{typeof(REPL.LineEdit.eval), Module, Expr}) | |
638 | precompile(Tuple{typeof(REPL.LineEdit.history_next_prefix), REPL.LineEdit.PrefixSearchState, REPL.REPLHistoryProvider, String}) | |
639 | precompile(Tuple{typeof(REPL.LineEdit.history_prev_prefix), REPL.LineEdit.PrefixSearchState, REPL.REPLHistoryProvider, String}) | |
640 | precompile(Tuple{typeof(REPL.LineEdit.init_state), REPL.Terminals.TTYTerminal, REPL.LineEdit.HistoryPrompt}) | |
641 | precompile(Tuple{typeof(REPL.LineEdit.init_state), REPL.Terminals.TTYTerminal, REPL.LineEdit.ModalInterface}) | |
642 | precompile(Tuple{typeof(REPL.LineEdit.init_state), REPL.Terminals.TTYTerminal, REPL.LineEdit.PrefixHistoryPrompt}) | |
643 | precompile(Tuple{typeof(REPL.LineEdit.is_region_active), REPL.LineEdit.MIState}) | |
644 | precompile(Tuple{typeof(REPL.LineEdit.keymap), REPL.LineEdit.PrefixSearchState, REPL.LineEdit.PrefixHistoryPrompt}) | |
645 | precompile(Tuple{typeof(REPL.LineEdit.keymap), REPL.LineEdit.SearchState, REPL.LineEdit.HistoryPrompt}) | |
646 | precompile(Tuple{typeof(REPL.LineEdit.keymap_data), REPL.LineEdit.PrefixSearchState, REPL.LineEdit.PrefixHistoryPrompt}) | |
647 | precompile(Tuple{typeof(REPL.LineEdit.keymap_data), REPL.LineEdit.SearchState, REPL.LineEdit.HistoryPrompt}) | |
648 | precompile(Tuple{typeof(REPL.LineEdit.match_input), Base.Dict{Char, Any}, REPL.LineEdit.MIState, Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
649 | precompile(Tuple{typeof(REPL.LineEdit.match_input), Base.Dict{Char, Any}, REPL.LineEdit.MIState, REPL.Terminals.TTYTerminal, Array{Char, 1}, Base.Dict{Char, Any}}) | |
650 | precompile(Tuple{typeof(REPL.LineEdit.match_input), Base.Dict{Char, Any}, REPL.LineEdit.MIState}) | |
651 | precompile(Tuple{typeof(REPL.LineEdit.match_input), Function, REPL.LineEdit.MIState, REPL.Terminals.TTYTerminal, Array{Char, 1}, Base.Dict{Char, Any}}) | |
652 | precompile(Tuple{typeof(REPL.LineEdit.mode), REPL.LineEdit.PromptState}) | |
653 | precompile(Tuple{typeof(REPL.LineEdit.options), REPL.LineEdit.MIState}) | |
654 | precompile(Tuple{typeof(REPL.LineEdit.options), REPL.LineEdit.PromptState}) | |
655 | precompile(Tuple{typeof(REPL.LineEdit.pop_undo), REPL.LineEdit.MIState}) | |
656 | precompile(Tuple{typeof(REPL.LineEdit.prompt_string), typeof(Base.input_color)}) | |
657 | precompile(Tuple{typeof(REPL.LineEdit.push_undo), REPL.LineEdit.MIState}) | |
658 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.LineEdit.MIState}) | |
659 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.LineEdit.PromptState}) | |
660 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TTYTerminal, REPL.LineEdit.PrefixSearchState}) | |
661 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TTYTerminal, REPL.LineEdit.PromptState}) | |
662 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TTYTerminal, REPL.LineEdit.SearchState}) | |
663 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal, Base.GenericIOBuffer{Array{UInt8, 1}}, REPL.LineEdit.InputAreaState, String}) | |
664 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal, REPL.LineEdit.PrefixSearchState}) | |
665 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal, REPL.LineEdit.PromptState}) | |
666 | precompile(Tuple{typeof(REPL.LineEdit.region_active), REPL.LineEdit.MIState}) | |
667 | precompile(Tuple{typeof(REPL.LineEdit.replace_line), REPL.LineEdit.MIState, String}) | |
668 | precompile(Tuple{typeof(REPL.LineEdit.replace_line), REPL.LineEdit.PromptState, Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
669 | precompile(Tuple{typeof(REPL.LineEdit.reset_state), REPL.LineEdit.MIState}) | |
670 | precompile(Tuple{typeof(REPL.LineEdit.reset_state), REPL.LineEdit.PrefixSearchState}) | |
671 | precompile(Tuple{typeof(REPL.LineEdit.reset_state), REPL.LineEdit.PromptState}) | |
672 | precompile(Tuple{typeof(REPL.LineEdit.reset_state), REPL.LineEdit.SearchState}) | |
673 | precompile(Tuple{typeof(REPL.LineEdit.reset_state), REPL.REPLHistoryProvider}) | |
674 | precompile(Tuple{typeof(REPL.LineEdit.run_interface), REPL.Terminals.TTYTerminal, REPL.LineEdit.ModalInterface, REPL.LineEdit.MIState}) | |
675 | precompile(Tuple{typeof(REPL.LineEdit.set_action!), REPL.LineEdit.MIState, Symbol}) | |
676 | precompile(Tuple{typeof(REPL.LineEdit.setmark), REPL.LineEdit.MIState, Bool}) | |
677 | precompile(Tuple{typeof(REPL.LineEdit.setup_prefix_keymap), REPL.REPLHistoryProvider, REPL.LineEdit.Prompt}) | |
678 | precompile(Tuple{typeof(REPL.LineEdit.setup_search_keymap), REPL.REPLHistoryProvider}) | |
679 | precompile(Tuple{typeof(REPL.LineEdit.show_completions), REPL.LineEdit.PromptState, Array{String, 1}}) | |
680 | precompile(Tuple{typeof(REPL.LineEdit.terminal), REPL.LineEdit.MIState}) | |
681 | precompile(Tuple{typeof(REPL.LineEdit.terminal), REPL.LineEdit.PrefixSearchState}) | |
682 | precompile(Tuple{typeof(REPL.LineEdit.terminal), REPL.LineEdit.PromptState}) | |
683 | precompile(Tuple{typeof(REPL.LineEdit.terminal), REPL.LineEdit.SearchState}) | |
684 | precompile(Tuple{typeof(REPL.REPLCompletions.completion_text), REPL.REPLCompletions.PackageCompletion}) | |
685 | precompile(Tuple{typeof(REPL.REPLCompletions.completions), String, Int64, Module}) | |
686 | precompile(Tuple{typeof(REPL.REPLCompletions.get_type), Symbol, Module}) | |
687 | precompile(Tuple{typeof(REPL.REPLCompletions.get_value), Symbol, Module}) | |
688 | precompile(Tuple{typeof(REPL.Terminals.beep), REPL.LineEdit.MIState}) | |
689 | precompile(Tuple{typeof(REPL.Terminals.beep), REPL.LineEdit.PromptState, Float64, Float64, Float64}) | |
690 | precompile(Tuple{typeof(REPL.Terminals.beep), REPL.LineEdit.SearchState}) | |
691 | precompile(Tuple{typeof(REPL.Terminals.cmove_col), REPL.Terminals.TTYTerminal, Int64}) | |
692 | precompile(Tuple{typeof(REPL.Terminals.cmove_down), REPL.Terminals.TTYTerminal, Int64}) | |
693 | precompile(Tuple{typeof(REPL.Terminals.hascolor), REPL.Terminals.TTYTerminal}) | |
694 | precompile(Tuple{typeof(REPL.Terminals.width), REPL.Terminals.TTYTerminal}) | |
695 | precompile(Tuple{typeof(Base.banner), REPL.Terminals.TTYTerminal}) | |
696 | precompile(Tuple{typeof(REPL.ends_with_semicolon), String}) | |
697 | precompile(Tuple{typeof(REPL.eval), Module, Expr}) | |
698 | precompile(Tuple{typeof(REPL.eval), Module, String}) | |
699 | precompile(Tuple{typeof(REPL.eval_user_input), Any, REPL.REPLBackend}) | |
700 | precompile(Tuple{typeof(REPL.eval_user_input), Expr, REPL.REPLBackend}) | |
701 | precompile(Tuple{typeof(REPL.filtervalid), Array{Any, 1}}) | |
702 | precompile(Tuple{typeof(REPL.fuzzysort), String, Array{String, 1}}) | |
703 | precompile(Tuple{typeof(REPL.helpmode), Base.TTY, String}) | |
704 | precompile(Tuple{typeof(REPL.helpmode), String}) | |
705 | precompile(Tuple{typeof(REPL.hist_from_file), REPL.REPLHistoryProvider, Base.IOStream, String}) | |
706 | precompile(Tuple{typeof(REPL.insert_hlines), Base.TTY, Markdown.MD}) | |
707 | precompile(Tuple{typeof(REPL.lookup_doc), Symbol}) | |
708 | precompile(Tuple{typeof(REPL.mode_idx), REPL.REPLHistoryProvider, REPL.LineEdit.Prompt}) | |
709 | precompile(Tuple{typeof(REPL.prepare_next), REPL.LineEditREPL}) | |
710 | precompile(Tuple{typeof(REPL.print_response), REPL.LineEditREPL, ArgumentError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}, Bool, Bool}) | |
711 | precompile(Tuple{typeof(REPL.print_response), REPL.LineEditREPL, Markdown.MD, Nothing, Bool, Bool}) | |
712 | precompile(Tuple{typeof(REPL.print_response), REPL.Terminals.TTYTerminal, ArgumentError, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}, Bool, Bool, Nothing}) | |
713 | precompile(Tuple{typeof(REPL.print_response), REPL.Terminals.TTYTerminal, Markdown.MD, Nothing, Bool, Bool, Nothing}) | |
714 | precompile(Tuple{typeof(REPL.repl), Base.TTY, Symbol}) | |
715 | precompile(Tuple{typeof(REPL.repl_latex), Base.TTY, String}) | |
716 | precompile(Tuple{typeof(REPL.repl_search), Base.TTY, String}) | |
717 | precompile(Tuple{typeof(REPL.reset), REPL.LineEditREPL}) | |
718 | precompile(Tuple{typeof(REPL.return_callback), REPL.LineEdit.PromptState}) | |
719 | precompile(Tuple{typeof(REPL.run_repl), REPL.LineEditREPL, typeof(x->nothing)}) | |
720 | precompile(Tuple{typeof(REPL.send_to_backend), Expr, Base.Channel{Any}, Base.Channel{Any}}) | |
721 | precompile(Tuple{typeof(REPL.send_to_backend), Expr, REPL.REPLBackendRef}) | |
722 | precompile(Tuple{typeof(REPL.send_to_backend), String, Base.Channel{Any}, Base.Channel{Any}}) | |
723 | precompile(Tuple{typeof(REPL.send_to_backend), String, REPL.REPLBackendRef}) | |
724 | precompile(Tuple{typeof(REPL.send_to_backend), Symbol, Base.Channel{Any}, Base.Channel{Any}}) | |
725 | precompile(Tuple{typeof(REPL.send_to_backend), Symbol, REPL.REPLBackendRef}) | |
726 | precompile(Tuple{typeof(REPL.setup_interface), REPL.LineEditREPL, Bool, Array{Base.Dict{Any, Any}, 1}}) | |
727 | precompile(Tuple{typeof(REPL.setup_interface), REPL.LineEditREPL, Bool, Base.Dict{Any, Any}}) | |
728 | precompile(Tuple{typeof(REPL.setup_interface), REPL.LineEditREPL}) | |
729 | precompile(Tuple{typeof(REPL.start_repl_backend), Base.Channel{Any}, Base.Channel{Any}}) | |
730 | precompile(Tuple{typeof(Random.__init__)}) | |
731 | precompile(Tuple{typeof(eval), Module, Expr}) |
506 | 506 | $(eval $(call LLVM_PATCH,llvm-D50010-VNCoercion-ni)) |
507 | 507 | $(eval $(call LLVM_PATCH,llvm-D50167-scev-umin)) |
508 | 508 | $(eval $(call LLVM_PATCH,llvm-windows-race)) |
509 | $(eval $(call LLVM_PATCH,llvm-rL326967-aligned-load)) # remove for 7.0 | |
509 | 510 | endif # LLVM_VER |
510 | 511 | |
511 | 512 | # Remove hardcoded OS X requirements in compilter-rt cmake build |
0 | commit b398d8e1fa5a5a914957fa22d0a64db97f6c265e | |
1 | Author: Craig Topper <craig.topper@intel.com> | |
2 | Date: Thu Mar 8 00:21:17 2018 +0000 | |
3 | ||
4 | [X86] Fix some isel patterns that used aligned vector load instructions with unaligned predicates. | |
5 | ||
6 | These patterns weren't checking the alignment of the load, but were using the aligned instructions. This will cause a GP fault if the data isn't aligned. | |
7 | ||
8 | I believe these were introduced in r312450. | |
9 | ||
10 | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326967 91177308-0d34-0410-b5e6-96231b3b80d8 | |
11 | ||
12 | diff --git a/lib/Target/X86/X86InstrVecCompiler.td b/lib/Target/X86/X86InstrVecCompiler.td | |
13 | index db3dfe56531..50c7763a2c3 100644 | |
14 | --- a/lib/Target/X86/X86InstrVecCompiler.td | |
15 | +++ b/lib/Target/X86/X86InstrVecCompiler.td | |
16 | @@ -261,10 +261,10 @@ let Predicates = [HasVLX] in { | |
17 | // will zero the upper bits. | |
18 | // TODO: Is there a safe way to detect whether the producing instruction | |
19 | // already zeroed the upper bits? | |
20 | -multiclass subvector_zero_lowering<string MoveStr, RegisterClass RC, | |
21 | - ValueType DstTy, ValueType SrcTy, | |
22 | - ValueType ZeroTy, PatFrag memop, | |
23 | - SubRegIndex SubIdx> { | |
24 | +multiclass subvector_zero_lowering<string MoveStr, string LoadStr, | |
25 | + RegisterClass RC, ValueType DstTy, | |
26 | + ValueType SrcTy, ValueType ZeroTy, | |
27 | + PatFrag memop, SubRegIndex SubIdx> { | |
28 | def : Pat<(DstTy (insert_subvector (bitconvert (ZeroTy immAllZerosV)), | |
29 | (SrcTy RC:$src), (iPTR 0))), | |
30 | (SUBREG_TO_REG (i64 0), | |
31 | @@ -274,91 +274,91 @@ multiclass subvector_zero_lowering<string MoveStr, RegisterClass RC, | |
32 | (SrcTy (bitconvert (memop addr:$src))), | |
33 | (iPTR 0))), | |
34 | (SUBREG_TO_REG (i64 0), | |
35 | - (!cast<Instruction>("VMOV"#MoveStr#"rm") addr:$src), SubIdx)>; | |
36 | + (!cast<Instruction>("VMOV"#LoadStr#"rm") addr:$src), SubIdx)>; | |
37 | } | |
38 | ||
39 | let Predicates = [HasAVX, NoVLX] in { | |
40 | - defm : subvector_zero_lowering<"APD", VR128, v4f64, v2f64, v8i32, loadv2f64, | |
41 | - sub_xmm>; | |
42 | - defm : subvector_zero_lowering<"APS", VR128, v8f32, v4f32, v8i32, loadv4f32, | |
43 | - sub_xmm>; | |
44 | - defm : subvector_zero_lowering<"DQA", VR128, v4i64, v2i64, v8i32, loadv2i64, | |
45 | - sub_xmm>; | |
46 | - defm : subvector_zero_lowering<"DQA", VR128, v8i32, v4i32, v8i32, loadv2i64, | |
47 | - sub_xmm>; | |
48 | - defm : subvector_zero_lowering<"DQA", VR128, v16i16, v8i16, v8i32, loadv2i64, | |
49 | - sub_xmm>; | |
50 | - defm : subvector_zero_lowering<"DQA", VR128, v32i8, v16i8, v8i32, loadv2i64, | |
51 | - sub_xmm>; | |
52 | -} | |
53 | - | |
54 | -let Predicates = [HasVLX] in { | |
55 | - defm : subvector_zero_lowering<"APDZ128", VR128X, v4f64, v2f64, v8i32, | |
56 | + defm : subvector_zero_lowering<"APD", "UPD", VR128, v4f64, v2f64, v8i32, | |
57 | loadv2f64, sub_xmm>; | |
58 | - defm : subvector_zero_lowering<"APSZ128", VR128X, v8f32, v4f32, v8i32, | |
59 | + defm : subvector_zero_lowering<"APS", "UPS", VR128, v8f32, v4f32, v8i32, | |
60 | loadv4f32, sub_xmm>; | |
61 | - defm : subvector_zero_lowering<"DQA64Z128", VR128X, v4i64, v2i64, v8i32, | |
62 | + defm : subvector_zero_lowering<"DQA", "DQU", VR128, v4i64, v2i64, v8i32, | |
63 | loadv2i64, sub_xmm>; | |
64 | - defm : subvector_zero_lowering<"DQA64Z128", VR128X, v8i32, v4i32, v8i32, | |
65 | + defm : subvector_zero_lowering<"DQA", "DQU", VR128, v8i32, v4i32, v8i32, | |
66 | loadv2i64, sub_xmm>; | |
67 | - defm : subvector_zero_lowering<"DQA64Z128", VR128X, v16i16, v8i16, v8i32, | |
68 | + defm : subvector_zero_lowering<"DQA", "DQU", VR128, v16i16, v8i16, v8i32, | |
69 | loadv2i64, sub_xmm>; | |
70 | - defm : subvector_zero_lowering<"DQA64Z128", VR128X, v32i8, v16i8, v8i32, | |
71 | - loadv2i64, sub_xmm>; | |
72 | - | |
73 | - defm : subvector_zero_lowering<"APDZ128", VR128X, v8f64, v2f64, v16i32, | |
74 | - loadv2f64, sub_xmm>; | |
75 | - defm : subvector_zero_lowering<"APSZ128", VR128X, v16f32, v4f32, v16i32, | |
76 | - loadv4f32, sub_xmm>; | |
77 | - defm : subvector_zero_lowering<"DQA64Z128", VR128X, v8i64, v2i64, v16i32, | |
78 | - loadv2i64, sub_xmm>; | |
79 | - defm : subvector_zero_lowering<"DQA64Z128", VR128X, v16i32, v4i32, v16i32, | |
80 | - loadv2i64, sub_xmm>; | |
81 | - defm : subvector_zero_lowering<"DQA64Z128", VR128X, v32i16, v8i16, v16i32, | |
82 | - loadv2i64, sub_xmm>; | |
83 | - defm : subvector_zero_lowering<"DQA64Z128", VR128X, v64i8, v16i8, v16i32, | |
84 | + defm : subvector_zero_lowering<"DQA", "DQU", VR128, v32i8, v16i8, v8i32, | |
85 | loadv2i64, sub_xmm>; | |
86 | +} | |
87 | ||
88 | - defm : subvector_zero_lowering<"APDZ256", VR256X, v8f64, v4f64, v16i32, | |
89 | - loadv4f64, sub_ymm>; | |
90 | - defm : subvector_zero_lowering<"APSZ256", VR256X, v16f32, v8f32, v16i32, | |
91 | - loadv8f32, sub_ymm>; | |
92 | - defm : subvector_zero_lowering<"DQA64Z256", VR256X, v8i64, v4i64, v16i32, | |
93 | - loadv4i64, sub_ymm>; | |
94 | - defm : subvector_zero_lowering<"DQA64Z256", VR256X, v16i32, v8i32, v16i32, | |
95 | - loadv4i64, sub_ymm>; | |
96 | - defm : subvector_zero_lowering<"DQA64Z256", VR256X, v32i16, v16i16, v16i32, | |
97 | - loadv4i64, sub_ymm>; | |
98 | - defm : subvector_zero_lowering<"DQA64Z256", VR256X, v64i8, v32i8, v16i32, | |
99 | - loadv4i64, sub_ymm>; | |
100 | +let Predicates = [HasVLX] in { | |
101 | + defm : subvector_zero_lowering<"APDZ128", "UPDZ128", VR128X, v4f64, | |
102 | + v2f64, v8i32, loadv2f64, sub_xmm>; | |
103 | + defm : subvector_zero_lowering<"APSZ128", "UPSZ128", VR128X, v8f32, | |
104 | + v4f32, v8i32, loadv4f32, sub_xmm>; | |
105 | + defm : subvector_zero_lowering<"DQA64Z128", "DQU64Z128", VR128X, v4i64, | |
106 | + v2i64, v8i32, loadv2i64, sub_xmm>; | |
107 | + defm : subvector_zero_lowering<"DQA64Z128", "DQU64Z128", VR128X, v8i32, | |
108 | + v4i32, v8i32, loadv2i64, sub_xmm>; | |
109 | + defm : subvector_zero_lowering<"DQA64Z128", "DQU64Z128", VR128X, v16i16, | |
110 | + v8i16, v8i32, loadv2i64, sub_xmm>; | |
111 | + defm : subvector_zero_lowering<"DQA64Z128", "DQU64Z128", VR128X, v32i8, | |
112 | + v16i8, v8i32, loadv2i64, sub_xmm>; | |
113 | + | |
114 | + defm : subvector_zero_lowering<"APDZ128", "UPDZ128", VR128X, v8f64, | |
115 | + v2f64, v16i32, loadv2f64, sub_xmm>; | |
116 | + defm : subvector_zero_lowering<"APSZ128", "UPSZ128", VR128X, v16f32, | |
117 | + v4f32, v16i32, loadv4f32, sub_xmm>; | |
118 | + defm : subvector_zero_lowering<"DQA64Z128", "DQU64Z128", VR128X, v8i64, | |
119 | + v2i64, v16i32, loadv2i64, sub_xmm>; | |
120 | + defm : subvector_zero_lowering<"DQA64Z128", "DQU64Z128", VR128X, v16i32, | |
121 | + v4i32, v16i32, loadv2i64, sub_xmm>; | |
122 | + defm : subvector_zero_lowering<"DQA64Z128", "DQU64Z128", VR128X, v32i16, | |
123 | + v8i16, v16i32, loadv2i64, sub_xmm>; | |
124 | + defm : subvector_zero_lowering<"DQA64Z128", "DQU64Z128", VR128X, v64i8, | |
125 | + v16i8, v16i32, loadv2i64, sub_xmm>; | |
126 | + | |
127 | + defm : subvector_zero_lowering<"APDZ256", "UPDZ256", VR256X, v8f64, | |
128 | + v4f64, v16i32, loadv4f64, sub_ymm>; | |
129 | + defm : subvector_zero_lowering<"APSZ256", "UPDZ256", VR256X, v16f32, | |
130 | + v8f32, v16i32, loadv8f32, sub_ymm>; | |
131 | + defm : subvector_zero_lowering<"DQA64Z256", "DQU64Z256", VR256X, v8i64, | |
132 | + v4i64, v16i32, loadv4i64, sub_ymm>; | |
133 | + defm : subvector_zero_lowering<"DQA64Z256", "DQU64Z256", VR256X, v16i32, | |
134 | + v8i32, v16i32, loadv4i64, sub_ymm>; | |
135 | + defm : subvector_zero_lowering<"DQA64Z256", "DQU64Z256", VR256X, v32i16, | |
136 | + v16i16, v16i32, loadv4i64, sub_ymm>; | |
137 | + defm : subvector_zero_lowering<"DQA64Z256", "DQU64Z256", VR256X, v64i8, | |
138 | + v32i8, v16i32, loadv4i64, sub_ymm>; | |
139 | } | |
140 | ||
141 | let Predicates = [HasAVX512, NoVLX] in { | |
142 | - defm : subvector_zero_lowering<"APD", VR128, v8f64, v2f64, v16i32, loadv2f64, | |
143 | - sub_xmm>; | |
144 | - defm : subvector_zero_lowering<"APS", VR128, v16f32, v4f32, v16i32, loadv4f32, | |
145 | - sub_xmm>; | |
146 | - defm : subvector_zero_lowering<"DQA", VR128, v8i64, v2i64, v16i32, loadv2i64, | |
147 | - sub_xmm>; | |
148 | - defm : subvector_zero_lowering<"DQA", VR128, v16i32, v4i32, v16i32, loadv2i64, | |
149 | - sub_xmm>; | |
150 | - defm : subvector_zero_lowering<"DQA", VR128, v32i16, v8i16, v16i32, loadv2i64, | |
151 | - sub_xmm>; | |
152 | - defm : subvector_zero_lowering<"DQA", VR128, v64i8, v16i8, v16i32, loadv2i64, | |
153 | - sub_xmm>; | |
154 | - | |
155 | - defm : subvector_zero_lowering<"APDY", VR256, v8f64, v4f64, v16i32, | |
156 | - loadv4f64, sub_ymm>; | |
157 | - defm : subvector_zero_lowering<"APSY", VR256, v16f32, v8f32, v16i32, | |
158 | - loadv8f32, sub_ymm>; | |
159 | - defm : subvector_zero_lowering<"DQAY", VR256, v8i64, v4i64, v16i32, | |
160 | - loadv4i64, sub_ymm>; | |
161 | - defm : subvector_zero_lowering<"DQAY", VR256, v16i32, v8i32, v16i32, | |
162 | - loadv4i64, sub_ymm>; | |
163 | - defm : subvector_zero_lowering<"DQAY", VR256, v32i16, v16i16, v16i32, | |
164 | - loadv4i64, sub_ymm>; | |
165 | - defm : subvector_zero_lowering<"DQAY", VR256, v64i8, v32i8, v16i32, | |
166 | - loadv4i64, sub_ymm>; | |
167 | + defm : subvector_zero_lowering<"APD", "UPD", VR128, v8f64, v2f64, | |
168 | + v16i32,loadv2f64, sub_xmm>; | |
169 | + defm : subvector_zero_lowering<"APS", "UPS", VR128, v16f32, v4f32, | |
170 | + v16i32, loadv4f32, sub_xmm>; | |
171 | + defm : subvector_zero_lowering<"DQA", "DQU", VR128, v8i64, v2i64, | |
172 | + v16i32, loadv2i64, sub_xmm>; | |
173 | + defm : subvector_zero_lowering<"DQA", "DQU", VR128, v16i32, v4i32, | |
174 | + v16i32, loadv2i64, sub_xmm>; | |
175 | + defm : subvector_zero_lowering<"DQA", "DQU", VR128, v32i16, v8i16, | |
176 | + v16i32, loadv2i64, sub_xmm>; | |
177 | + defm : subvector_zero_lowering<"DQA", "DQU", VR128, v64i8, v16i8, | |
178 | + v16i32, loadv2i64, sub_xmm>; | |
179 | + | |
180 | + defm : subvector_zero_lowering<"APDY", "UPDY", VR256, v8f64, v4f64, | |
181 | + v16i32, loadv4f64, sub_ymm>; | |
182 | + defm : subvector_zero_lowering<"APSY", "UPSY", VR256, v16f32, v8f32, | |
183 | + v16i32, loadv8f32, sub_ymm>; | |
184 | + defm : subvector_zero_lowering<"DQAY", "DQUY", VR256, v8i64, v4i64, | |
185 | + v16i32, loadv4i64, sub_ymm>; | |
186 | + defm : subvector_zero_lowering<"DQAY", "DQUY", VR256, v16i32, v8i32, | |
187 | + v16i32, loadv4i64, sub_ymm>; | |
188 | + defm : subvector_zero_lowering<"DQAY", "DQUY", VR256, v32i16, v16i16, | |
189 | + v16i32, loadv4i64, sub_ymm>; | |
190 | + defm : subvector_zero_lowering<"DQAY", "DQUY", VR256, v64i8, v32i8, | |
191 | + v16i32, loadv4i64, sub_ymm>; | |
192 | } | |
193 | ||
194 | // List of opcodes that guaranteed to zero the upper elements of vector regs. | |
195 | diff --git a/test/CodeGen/X86/merge-consecutive-loads-256.ll b/test/CodeGen/X86/merge-consecutive-loads-256.ll | |
196 | index 6ecd8116443..0f2cf594b1c 100644 | |
197 | --- a/test/CodeGen/X86/merge-consecutive-loads-256.ll | |
198 | +++ b/test/CodeGen/X86/merge-consecutive-loads-256.ll | |
199 | @@ -28,13 +28,13 @@ define <4 x double> @merge_4f64_2f64_23(<2 x double>* %ptr) nounwind uwtable noi | |
200 | define <4 x double> @merge_4f64_2f64_2z(<2 x double>* %ptr) nounwind uwtable noinline ssp { | |
201 | ; AVX-LABEL: merge_4f64_2f64_2z: | |
202 | ; AVX: # %bb.0: | |
203 | -; AVX-NEXT: vmovaps 32(%rdi), %xmm0 | |
204 | +; AVX-NEXT: vmovups 32(%rdi), %xmm0 | |
205 | ; AVX-NEXT: retq | |
206 | ; | |
207 | ; X32-AVX-LABEL: merge_4f64_2f64_2z: | |
208 | ; X32-AVX: # %bb.0: | |
209 | ; X32-AVX-NEXT: movl {{[0-9]+}}(%esp), %eax | |
210 | -; X32-AVX-NEXT: vmovaps 32(%eax), %xmm0 | |
211 | +; X32-AVX-NEXT: vmovups 32(%eax), %xmm0 | |
212 | ; X32-AVX-NEXT: retl | |
213 | %ptr0 = getelementptr inbounds <2 x double>, <2 x double>* %ptr, i64 2 | |
214 | %val0 = load <2 x double>, <2 x double>* %ptr0 | |
215 | @@ -109,13 +109,13 @@ define <4 x double> @merge_4f64_f64_34uu(double* %ptr) nounwind uwtable noinline | |
216 | define <4 x double> @merge_4f64_f64_45zz(double* %ptr) nounwind uwtable noinline ssp { | |
217 | ; AVX-LABEL: merge_4f64_f64_45zz: | |
218 | ; AVX: # %bb.0: | |
219 | -; AVX-NEXT: vmovaps 32(%rdi), %xmm0 | |
220 | +; AVX-NEXT: vmovups 32(%rdi), %xmm0 | |
221 | ; AVX-NEXT: retq | |
222 | ; | |
223 | ; X32-AVX-LABEL: merge_4f64_f64_45zz: | |
224 | ; X32-AVX: # %bb.0: | |
225 | ; X32-AVX-NEXT: movl {{[0-9]+}}(%esp), %eax | |
226 | -; X32-AVX-NEXT: vmovaps 32(%eax), %xmm0 | |
227 | +; X32-AVX-NEXT: vmovups 32(%eax), %xmm0 | |
228 | ; X32-AVX-NEXT: retl | |
229 | %ptr0 = getelementptr inbounds double, double* %ptr, i64 4 | |
230 | %ptr1 = getelementptr inbounds double, double* %ptr, i64 5 | |
231 | @@ -155,13 +155,13 @@ define <4 x double> @merge_4f64_f64_34z6(double* %ptr) nounwind uwtable noinline | |
232 | define <4 x i64> @merge_4i64_2i64_3z(<2 x i64>* %ptr) nounwind uwtable noinline ssp { | |
233 | ; AVX-LABEL: merge_4i64_2i64_3z: | |
234 | ; AVX: # %bb.0: | |
235 | -; AVX-NEXT: vmovaps 48(%rdi), %xmm0 | |
236 | +; AVX-NEXT: vmovups 48(%rdi), %xmm0 | |
237 | ; AVX-NEXT: retq | |
238 | ; | |
239 | ; X32-AVX-LABEL: merge_4i64_2i64_3z: | |
240 | ; X32-AVX: # %bb.0: | |
241 | ; X32-AVX-NEXT: movl {{[0-9]+}}(%esp), %eax | |
242 | -; X32-AVX-NEXT: vmovaps 48(%eax), %xmm0 | |
243 | +; X32-AVX-NEXT: vmovups 48(%eax), %xmm0 | |
244 | ; X32-AVX-NEXT: retl | |
245 | %ptr0 = getelementptr inbounds <2 x i64>, <2 x i64>* %ptr, i64 3 | |
246 | %val0 = load <2 x i64>, <2 x i64>* %ptr0 | |
247 | @@ -217,13 +217,13 @@ define <4 x i64> @merge_4i64_i64_1zzu(i64* %ptr) nounwind uwtable noinline ssp { | |
248 | define <4 x i64> @merge_4i64_i64_23zz(i64* %ptr) nounwind uwtable noinline ssp { | |
249 | ; AVX-LABEL: merge_4i64_i64_23zz: | |
250 | ; AVX: # %bb.0: | |
251 | -; AVX-NEXT: vmovaps 16(%rdi), %xmm0 | |
252 | +; AVX-NEXT: vmovups 16(%rdi), %xmm0 | |
253 | ; AVX-NEXT: retq | |
254 | ; | |
255 | ; X32-AVX-LABEL: merge_4i64_i64_23zz: | |
256 | ; X32-AVX: # %bb.0: | |
257 | ; X32-AVX-NEXT: movl {{[0-9]+}}(%esp), %eax | |
258 | -; X32-AVX-NEXT: vmovaps 16(%eax), %xmm0 | |
259 | +; X32-AVX-NEXT: vmovups 16(%eax), %xmm0 | |
260 | ; X32-AVX-NEXT: retl | |
261 | %ptr0 = getelementptr inbounds i64, i64* %ptr, i64 2 | |
262 | %ptr1 = getelementptr inbounds i64, i64* %ptr, i64 3 | |
263 | diff --git a/test/CodeGen/X86/merge-consecutive-loads-512.ll b/test/CodeGen/X86/merge-consecutive-loads-512.ll | |
264 | index 62102eb382c..3c6eaf65292 100644 | |
265 | --- a/test/CodeGen/X86/merge-consecutive-loads-512.ll | |
266 | +++ b/test/CodeGen/X86/merge-consecutive-loads-512.ll | |
267 | @@ -106,13 +106,13 @@ define <8 x double> @merge_8f64_f64_23uuuuu9(double* %ptr) nounwind uwtable noin | |
268 | define <8 x double> @merge_8f64_f64_12zzuuzz(double* %ptr) nounwind uwtable noinline ssp { | |
269 | ; ALL-LABEL: merge_8f64_f64_12zzuuzz: | |
270 | ; ALL: # %bb.0: | |
271 | -; ALL-NEXT: vmovaps 8(%rdi), %xmm0 | |
272 | +; ALL-NEXT: vmovups 8(%rdi), %xmm0 | |
273 | ; ALL-NEXT: retq | |
274 | ; | |
275 | ; X32-AVX512F-LABEL: merge_8f64_f64_12zzuuzz: | |
276 | ; X32-AVX512F: # %bb.0: | |
277 | ; X32-AVX512F-NEXT: movl {{[0-9]+}}(%esp), %eax | |
278 | -; X32-AVX512F-NEXT: vmovaps 8(%eax), %xmm0 | |
279 | +; X32-AVX512F-NEXT: vmovups 8(%eax), %xmm0 | |
280 | ; X32-AVX512F-NEXT: retl | |
281 | %ptr0 = getelementptr inbounds double, double* %ptr, i64 1 | |
282 | %ptr1 = getelementptr inbounds double, double* %ptr, i64 2 | |
283 | @@ -190,7 +190,7 @@ define <8 x i64> @merge_8i64_4i64_z3(<4 x i64>* %ptr) nounwind uwtable noinline | |
284 | define <8 x i64> @merge_8i64_i64_56zz9uzz(i64* %ptr) nounwind uwtable noinline ssp { | |
285 | ; ALL-LABEL: merge_8i64_i64_56zz9uzz: | |
286 | ; ALL: # %bb.0: | |
287 | -; ALL-NEXT: vmovaps 40(%rdi), %xmm0 | |
288 | +; ALL-NEXT: vmovups 40(%rdi), %xmm0 | |
289 | ; ALL-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero | |
290 | ; ALL-NEXT: vinsertf64x4 $1, %ymm1, %zmm0, %zmm0 | |
291 | ; ALL-NEXT: retq | |
292 | @@ -198,7 +198,7 @@ define <8 x i64> @merge_8i64_i64_56zz9uzz(i64* %ptr) nounwind uwtable noinline s | |
293 | ; X32-AVX512F-LABEL: merge_8i64_i64_56zz9uzz: | |
294 | ; X32-AVX512F: # %bb.0: | |
295 | ; X32-AVX512F-NEXT: movl {{[0-9]+}}(%esp), %eax | |
296 | -; X32-AVX512F-NEXT: vmovaps 40(%eax), %xmm0 | |
297 | +; X32-AVX512F-NEXT: vmovups 40(%eax), %xmm0 | |
298 | ; X32-AVX512F-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero | |
299 | ; X32-AVX512F-NEXT: vinsertf64x4 $1, %ymm1, %zmm0, %zmm0 | |
300 | ; X32-AVX512F-NEXT: retl |
39 | 39 | end |
40 | 40 | end |
41 | 41 | |
42 | # Generate a suitable markdown file from NEWS.md and put it in src | |
43 | str = read(joinpath(@__DIR__, "..", "NEWS.md"), String) | |
44 | splitted = split(str, "<!--- generated by NEWS-update.jl: -->") | |
45 | @assert length(splitted) == 2 | |
46 | replaced_links = replace(splitted[1], r"\[\#([0-9]*?)\]" => s"[#\g<1>](https://github.com/JuliaLang/julia/issues/\g<1>)") | |
47 | write(joinpath(@__DIR__, "src", "NEWS.md"), replaced_links) | |
42 | # # Generate a suitable markdown file from NEWS.md and put it in src | |
43 | # str = read(joinpath(@__DIR__, "..", "NEWS.md"), String) | |
44 | # splitted = split(str, "<!--- generated by NEWS-update.jl: -->") | |
45 | # @assert length(splitted) == 2 | |
46 | # replaced_links = replace(splitted[1], r"\[\#([0-9]*?)\]" => s"[#\g<1>](https://github.com/JuliaLang/julia/issues/\g<1>)") | |
47 | # write(joinpath(@__DIR__, "src", "NEWS.md"), replaced_links) | |
48 | 48 | |
49 | 49 | const PAGES = [ |
50 | 50 | "Home" => "index.md", |
51 | hide("NEWS.md"), | |
51 | # hide("NEWS.md"), | |
52 | 52 | "Manual" => [ |
53 | 53 | "manual/getting-started.md", |
54 | 54 | "manual/variables.md", |
161 | 161 | analytics = "UA-28835595-6", |
162 | 162 | pages = PAGES, |
163 | 163 | html_prettyurls = ("deploy" in ARGS), |
164 | html_canonical = ("deploy" in ARGS) ? "https://docs.julialang.org/en/stable/" : nothing, | |
164 | html_canonical = ("deploy" in ARGS) ? "https://docs.julialang.org/en/v1/" : nothing, | |
165 | 165 | assets = ["assets/julia-manual.css", ] |
166 | 166 | ) |
167 | ||
168 | # This overloads the function in Documenter that generates versions.js, to include | |
169 | # v1/ in the version selector, instead of stable/. | |
170 | # | |
171 | # The function is identical to the version found in Documenter v0.19.6, except that | |
172 | # it includes "v1" instead of "stable". | |
173 | # | |
174 | # Original: | |
175 | # https://github.com/JuliaDocs/Documenter.jl/blob/v0.19.6/src/Writers/HTMLWriter.jl#L481-L506 | |
176 | # | |
177 | import Documenter.Writers.HTMLWriter: generate_version_file | |
178 | function generate_version_file(dir::AbstractString) | |
179 | named_folders = ["v1", "latest"] | |
180 | tag_folders = [] | |
181 | for each in readdir(dir) | |
182 | each == "v1" && continue # skip the v1 symlink | |
183 | occursin(Base.VERSION_REGEX, each) && push!(tag_folders, each) | |
184 | end | |
185 | # sort tags by version number | |
186 | sort!(tag_folders, lt = (x, y) -> VersionNumber(x) < VersionNumber(y), rev = true) | |
187 | open(joinpath(dir, "versions.js"), "w") do buf | |
188 | println(buf, "var DOC_VERSIONS = [") | |
189 | for group in (named_folders, tag_folders) | |
190 | for folder in group | |
191 | println(buf, " \"", folder, "\",") | |
192 | end | |
193 | end | |
194 | println(buf, "];") | |
195 | end | |
196 | end | |
167 | 197 | |
168 | 198 | # Only deploy docs from 64bit Linux to avoid committing multiple versions of the same |
169 | 199 | # docs from different workers. |
52 | 52 | Base.length(::AbstractArray) |
53 | 53 | Base.eachindex |
54 | 54 | Base.IndexStyle |
55 | Base.IndexLinear | |
56 | Base.IndexCartesian | |
55 | 57 | Base.conj! |
56 | 58 | Base.stride |
57 | 59 | Base.strides |
88 | 88 | Base.isreal |
89 | 89 | Core.Float32(::Any) |
90 | 90 | Core.Float64(::Any) |
91 | Base.GMP.BigInt(::Any) | |
92 | Base.MPFR.BigFloat(::Any) | |
93 | 91 | Base.Rounding.rounding |
94 | 92 | Base.Rounding.setrounding(::Type, ::Any) |
95 | 93 | Base.Rounding.setrounding(::Function, ::Type, ::RoundingMode) |
112 | 110 | Base.@uint128_str |
113 | 111 | ``` |
114 | 112 | |
115 | ## BigFloats | |
113 | ## BigFloats and BigInts | |
116 | 114 | |
117 | The [`BigFloat`](@ref) type implements arbitrary-precision floating-point arithmetic using | |
118 | the [GNU MPFR library](http://www.mpfr.org/). | |
115 | The [`BigFloat`](@ref) and [`BigInt`](@ref) types implements | |
116 | arbitrary-precision floating point and integer arithmetic, respectively. For | |
117 | [`BigFloat`](@ref) the [GNU MPFR library](http://www.mpfr.org/) is used, | |
118 | and for [`BigInt`](@ref) the [GNU Multiple Precision Arithmetic Library (GMP)] | |
119 | (https://gmplib.org) is used. | |
119 | 120 | |
120 | 121 | ```@docs |
122 | Base.MPFR.BigFloat(::Any) | |
121 | 123 | Base.precision |
122 | 124 | Base.MPFR.precision(::Type{BigFloat}) |
123 | 125 | Base.MPFR.setprecision |
124 | 126 | Base.MPFR.BigFloat(x, prec::Int) |
125 | BigFloat(x::Union{Integer, AbstractFloat, String}, rounding::RoundingMode) | |
127 | Base.MPFR.BigFloat(x::Union{Integer, AbstractFloat, String}, rounding::RoundingMode) | |
126 | 128 | Base.MPFR.BigFloat(x, prec::Int, rounding::RoundingMode) |
127 | Base.MPFR.BigFloat(x::String) | |
129 | Base.GMP.BigInt(::Any) | |
128 | 130 | Base.@big_str |
129 | 131 | ``` |
109 | 109 | Base.sort! |
110 | 110 | Base.sort |
111 | 111 | Base.sortperm |
112 | Base.InsertionSort | |
113 | Base.MergeSort | |
114 | Base.QuickSort | |
115 | Base.PartialQuickSort | |
112 | 116 | Base.Sort.sortperm! |
113 | 117 | Base.Sort.sortslices |
114 | 118 | ``` |
130 | 134 | |
131 | 135 | There are currently four sorting algorithms available in base Julia: |
132 | 136 | |
133 | * `InsertionSort` | |
134 | * `QuickSort` | |
135 | * `PartialQuickSort(k)` | |
136 | * `MergeSort` | |
137 | * [`InsertionSort`](@ref) | |
138 | * [`QuickSort`](@ref) | |
139 | * [`PartialQuickSort(k)`](@ref) | |
140 | * [`MergeSort`](@ref) | |
137 | 141 | |
138 | 142 | `InsertionSort` is an O(n^2) stable sorting algorithm. It is efficient for very small `n`, and |
139 | 143 | is used internally by `QuickSort`. |
14 | 14 | ## [Version/Environment info](@id dev-version-info) |
15 | 15 | |
16 | 16 | No matter the error, we will always need to know what version of Julia you are running. When Julia |
17 | first starts up, a header is printed out with a version number and date. Please also include the | |
18 | output of `versioninfo()` in any report you create: | |
17 | first starts up, a header is printed out with a version number and date. Please also include the output of `versioninfo()` (exported from the [`InteractiveUtils`](@ref InteractiveUtils.versioninfo) standard library) in any report you create: | |
19 | 18 | |
20 | 19 | ```@repl |
20 | using InteractiveUtils | |
21 | 21 | versioninfo() |
22 | 22 | ``` |
23 | 23 |
0 | 0 | # Memory layout of Julia Objects |
1 | 1 | |
2 | ## Object layout (jl_value_t) | |
2 | ## Object layout (`jl_value_t`) | |
3 | 3 | |
4 | 4 | The `jl_value_t` struct is the name for a block of memory owned by the Julia Garbage Collector, |
5 | 5 | representing the data associated with a Julia object in memory. Absent any type information, it |
0 | # Julia 0.7 Documentation | |
0 | # Julia 1.0 Documentation | |
1 | 1 | |
2 | Welcome to the documentation for Julia 0.7. | |
2 | Welcome to the documentation for Julia 1.0. | |
3 | 3 | |
4 | Please read the [release notes](NEWS.md) to see what has changed since the last release. | |
4 | Please read the [release blog post](https://julialang.org/blog/2018/08/one-point-zero) for a general overview of the language and | |
5 | many of the changes since Julia v0.6. Note that version 0.7 was released alongside | |
6 | 1.0 to provide an upgrade path for packages and code that predates the 1.0 release. | |
7 | The only difference between 0.7 and 1.0 is the removal of deprecation warnings. | |
8 | For a complete list of all the changes since 0.6, see the [release notes for version 0.7](https://docs.julialang.org/en/v0.7.0/NEWS/) | |
5 | 9 | |
6 | 10 | ### [Introduction](@id man-introduction) |
7 | 11 |
691 | 691 | 2. Binary arithmetic -- `-`, `+`, `*`, `/`, `\`, `^` |
692 | 692 | 3. Comparison -- `==`, `!=`, `≈` ([`isapprox`](@ref)), `≉` |
693 | 693 | |
694 | Most of the binary arithmetic operators listed above also operate elementwise | |
695 | when one argument is scalar: `-`, `+`, and `*` when either argument is scalar, | |
696 | and `/` and `\` when the denominator is scalar. For example, `[1, 2] + 3 == [4, 5]` | |
697 | and `[6, 4] / 2 == [3, 2]`. | |
698 | ||
699 | Additionally, to enable convenient vectorization of mathematical and other operations, | |
694 | To enable convenient vectorization of mathematical and other operations, | |
700 | 695 | Julia [provides the dot syntax](@ref man-vectorized) `f.(args...)`, e.g. `sin.(x)` |
701 | 696 | or `min.(x,y)`, for elementwise operations over arrays or mixtures of arrays and |
702 | 697 | scalars (a [Broadcasting](@ref) operation); these have the additional advantage of |
781 | 776 | |
782 | 777 | ## Implementation |
783 | 778 | |
784 | The base array type in Julia is the abstract type [`AbstractArray{T,N}`](@ref). It is parametrized by | |
779 | The base array type in Julia is the abstract type [`AbstractArray{T,N}`](@ref). It is parameterized by | |
785 | 780 | the number of dimensions `N` and the element type `T`. [`AbstractVector`](@ref) and [`AbstractMatrix`](@ref) are |
786 | 781 | aliases for the 1-d and 2-d cases. Operations on `AbstractArray` objects are defined using higher |
787 | 782 | level operators and functions, in a way that is independent of the underlying storage. These operations |
832 | 827 | [`stride(A,k)`](@ref). If a pointer conversion method [`Base.unsafe_convert(Ptr{T}, A)`](@ref) is |
833 | 828 | provided, the memory layout must correspond in the same way to these strides. `DenseArray` is a |
834 | 829 | very specific example of a strided array where the elements are arranged contiguously, thus it |
835 | provides its subtypes with the approporiate definition of `strides`. More concrete examples | |
830 | provides its subtypes with the appropriate definition of `strides`. More concrete examples | |
836 | 831 | can be found within the [interface guide for strided arrays](@ref man-interface-strided-arrays). |
837 | 832 | [`StridedVector`](@ref) and [`StridedMatrix`](@ref) are convenient aliases for many of the builtin array types that |
838 | 833 | are considered strided arrays, allowing them to dispatch to select specialized implementations that |
129 | 129 | |
130 | 130 | ```julia |
131 | 131 | function gethostname() |
132 | hostname = Vector{UInt8}(128) | |
132 | hostname = Vector{UInt8}(undef, 128) | |
133 | 133 | ccall((:gethostname, "libc"), Int32, |
134 | 134 | (Ptr{UInt8}, Csize_t), |
135 | 135 | hostname, sizeof(hostname)) |
819 | 819 | if nmax < nmin |
820 | 820 | throw(DomainError()) |
821 | 821 | end |
822 | result_array = Vector{Cdouble}(nmax - nmin + 1) | |
822 | result_array = Vector{Cdouble}(undef, nmax - nmin + 1) | |
823 | 823 | errorcode = ccall( |
824 | 824 | (:gsl_sf_bessel_Jn_array, :libgsl), # name of C function and library |
825 | 825 | Cint, # output type |
972 | 972 | signature for Windows: |
973 | 973 | |
974 | 974 | ```julia |
975 | hn = Vector{UInt8}(256) | |
975 | hn = Vector{UInt8}(undef, 256) | |
976 | 976 | err = ccall(:gethostname, stdcall, Int32, (Ptr{UInt8}, UInt32), hn, length(hn)) |
977 | 977 | ``` |
978 | 978 |
180 | 180 | 9. Respect the line length limit used in the surrounding code. |
181 | 181 | |
182 | 182 | Docstrings are edited using the same tools as code. Therefore, the same conventions should apply. |
183 | It it advised to add line breaks after 92 characters. | |
183 | It is advised to add line breaks after 92 characters. | |
184 | 184 | 6. Provide information allowing custom types to implement the function in an |
185 | 185 | `# Implementation` section. These implementation details intended for developers |
186 | 186 | rather than users, explaining e.g. which functions should be overridden and which functions |
567 | 567 | Surround words with one asterisk, `*`, to display the enclosed text in italics. |
568 | 568 | |
569 | 569 | ``` |
570 | A paragraph containing an *emphasised* word. | |
570 | A paragraph containing an *emphasized* word. | |
571 | 571 | ``` |
572 | 572 | |
573 | 573 | #### Literals |
620 | 620 | |
621 | 621 | ```julia |
622 | 622 | """ |
623 | accumulate!(op, y, x) | |
624 | ||
625 | Cumulative operation `op` on a vector `x`, storing the result in `y`. See also [`accumulate`](@ref). | |
623 | tryparse(type, str; base) | |
624 | ||
625 | Like [`parse`](@ref), but returns either a value of the requested type, | |
626 | or [`nothing`](@ref) if the string does not contain a valid number. | |
626 | 627 | """ |
627 | 628 | ``` |
628 | 629 | |
629 | This will create a link in the generated docs to the `accumulate` documentation | |
630 | (which has more information about what this function actually does). It's good to include | |
631 | cross references to mutating/non-mutating versions of a function, or to highlight a difference | |
632 | between two similar-seeming functions. | |
630 | This will create a link in the generated docs to the [`parse`](@ref) documentation | |
631 | (which has more information about what this function actually does), and to the | |
632 | [`nothing`](@ref) documentation. It's good to include cross references to mutating/non-mutating | |
633 | versions of a function, or to highlight a difference between two similar-seeming functions. | |
633 | 634 | |
634 | 635 | !!! note |
635 | 636 | The above cross referencing is *not* a Markdown feature, and relies on |
663 | 664 | ``` |
664 | 665 | This is a paragraph. |
665 | 666 | |
666 | And this is *another* one containing some emphasised text. | |
667 | And this is *another* one containing some emphasized text. | |
667 | 668 | A new line, but still part of the same paragraph. |
668 | 669 | ``` |
669 | 670 |
63 | 63 | ``` |
64 | 64 | /etc/julia/startup.jl |
65 | 65 | ``` |
66 | ||
67 | ### `JULIA_PROJECT` | |
68 | ||
69 | A directory path that points to the current Julia project. Setting this | |
70 | environment variable has the same effect as specifying the `--project` start-up | |
71 | option, but `--project` has higher precedence. If the variable is set to `@.`, | |
72 | Julia tries to find a project directory that contains `Project.toml` or | |
73 | `JuliaProject.toml` file from the current directory and its parents. See also | |
74 | the chapter on [Code Loading](@ref). | |
66 | 75 | |
67 | 76 | ### `JULIA_LOAD_PATH` |
68 | 77 |
39 | 39 | obj3 = MyModule.someotherfunction(obj2, c) |
40 | 40 | ... |
41 | 41 | ``` |
42 | ||
43 | ### How do I check if the current file is being run as the main script? | |
44 | ||
45 | When a file is run as the main script using `julia file.jl` one might want to activate extra | |
46 | functionality like command line argument handling. A way to determine that a file is run in | |
47 | this fashion is to check if `abspath(PROGRAM_FILE) == @__FILE__` is `true`. | |
42 | 48 | |
43 | 49 | ## Functions |
44 | 50 | |
644 | 650 | The empty (or "bottom") type, written as `Union{}` (an empty union type), is a type with |
645 | 651 | no values and no subtypes (except itself). You will generally not need to use this type. |
646 | 652 | |
647 | ||
648 | ### How do I check if the current file is being run as the main script? | |
649 | ||
650 | When a file is run as the main script using `julia file.jl` one might want to activate extra | |
651 | functionality like command line argument handling. A way to determine that a file is run in | |
652 | this fashion is to check if `abspath(PROGRAM_FILE) == @__FILE__` is `true`. | |
653 | ||
654 | 653 | ## Memory |
655 | 654 | |
656 | 655 | ### Why does `x += y` allocate memory when `x` and `y` are arrays? |
540 | 540 | end |
541 | 541 | ``` |
542 | 542 | |
543 | Inside `f`, `kwargs` will be a key-value iterator over a named tuple. Named | |
544 | tuples (as well as dictionaries with keys of `Symbol`) can be passed as keyword | |
545 | arguments using a semicolon in a call, e.g. `f(x, z=1; kwargs...)`. | |
546 | ||
543 | 547 | If a keyword argument is not assigned a default value in the method definition, |
544 | 548 | then it is *required*: an [`UndefKeywordError`](@ref) exception will be thrown |
545 | 549 | if the caller does not assign it a value: |
550 | 554 | f(3, y=5) # ok, y is assigned |
551 | 555 | f(3) # throws UndefKeywordError(:y) |
552 | 556 | ``` |
553 | ||
554 | Inside `f`, `kwargs` will be a named tuple. Named tuples (as well as dictionaries) can be passed as | |
555 | keyword arguments using a semicolon in a call, e.g. `f(x, z=1; kwargs...)`. | |
556 | 557 | |
557 | 558 | One can also pass `key => value` expressions after a semicolon. For example, `plot(x, y; :width => 2)` |
558 | 559 | is equivalent to `plot(x, y, width=2)`. This is useful in situations where the keyword name is computed |
110 | 110 | |`--history-file={yes\|no}` |Load or save history| |
111 | 111 | |`--depwarn={yes\|no\|error}` |Enable or disable syntax and method deprecation warnings (`error` turns warnings into errors)| |
112 | 112 | |`--warn-overwrite={yes\|no}` |Enable or disable method overwrite warnings| |
113 | |`-C`, `--cpu-target <target>` |Limit usage of cpu features up to <target>; set to `help` to see the available options| | |
113 | |`-C`, `--cpu-target <target>` |Limit usage of CPU features up to `<target>`; set to `help` to see the available options| | |
114 | 114 | |`-O`, `--optimize={0,1,2,3}` |Set the optimization level (default level is 2 if unspecified or 3 if used without a level)| |
115 | 115 | |`-g`, `-g <level>` |Enable / Set the level of debug info generation (default level is 1 if unspecified or 2 if used without a level)| |
116 | 116 | |`--inline={yes\|no}` |Control whether inlining is permitted, including overriding `@inline` declarations| |
0 | # The Julia Manual | |
1 | ||
2 | * [Introduction](@ref man-introduction) | |
3 | * [Getting Started](@ref man-getting-started) | |
4 | * [Variables](@ref) | |
5 | * [Integers and Floating-Point Numbers](@ref) | |
6 | * [Mathematical Operations and Elementary Functions](@ref) | |
7 | * [Complex and Rational Numbers](@ref) | |
8 | * [Strings](@ref) | |
9 | * [Functions](@ref) | |
10 | * [Control Flow](@ref) | |
11 | * [Scope of Variables](@ref scope-of-variables) | |
12 | * [Types](@ref man-types) | |
13 | * [Methods](@ref) | |
14 | * [Constructors](@ref man-constructors) | |
15 | * [Conversion and Promotion](@ref conversion-and-promotion) | |
16 | * [Interfaces](@ref) | |
17 | * [Modules](@ref) | |
18 | * [Documentation](@ref) | |
19 | * [Metaprogramming](@ref) | |
20 | * [Multi-dimensional Arrays](@ref man-multi-dim-arrays) | |
21 | * [Missing Values](@ref missing) | |
22 | * [Networking and Streams](@ref) | |
23 | * [Parallel Computing](@ref) | |
24 | * [Dates](@ref) | |
25 | * [Running External Programs](@ref) | |
26 | * [Calling C and Fortran Code](@ref) | |
27 | * [Handling Operating System Variation](@ref) | |
28 | * [Environment Variables](@ref) | |
29 | * [Embedding Julia](@ref) | |
30 | * [Profiling](@ref) | |
31 | * [Memory allocation analysis](@ref) | |
32 | * [Stack Traces](@ref) | |
33 | * [Performance Tips](@ref man-performance-tips) | |
34 | * [Workflow Tips](@ref man-workflow-tips) | |
35 | * [Style Guide](@ref) | |
36 | * [Frequently Asked Questions](@ref) | |
37 | * [Noteworthy Differences from other Languages](@ref) | |
38 | * [Unicode Input](@ref) |
177 | 177 | `0`. In the case of leading zeros, the size is determined by the minimal needed size for a |
178 | 178 | literal, which has the same length but leading digit `1`. That allows the user to control |
179 | 179 | the size. |
180 | Values, which cannot be stored in `UInt128` cannot be written as such literals. | |
180 | Values which cannot be stored in `UInt128` cannot be written as such literals. | |
181 | 181 | |
182 | 182 | Binary, octal, and hexadecimal literals may be signed by a `-` immediately preceding the |
183 | 183 | unsigned literal. They produce an unsigned integer of the same size as the unsigned literal |
214 | 214 | ``` |
215 | 215 | |
216 | 216 | The values returned by [`typemin`](@ref) and [`typemax`](@ref) are always of the given argument |
217 | type. (The above expression uses several features we have yet to introduce, including [for loops](@ref man-loops), | |
217 | type. (The above expression uses several features that have yet to be introduced, including [for loops](@ref man-loops), | |
218 | 218 | [Strings](@ref man-strings), and [Interpolation](@ref), but should be easy enough to understand for users |
219 | 219 | with some existing programming experience.) |
220 | 220 | |
677 | 677 | * The 32-bit floating-point literal expression `1.5f22` could be interpreted as the numeric literal |
678 | 678 | `1.5` multiplied by the variable `f22`. |
679 | 679 | |
680 | In all cases, we resolve the ambiguity in favor of interpretation as numeric literals: | |
680 | In all cases the ambiguity is resolved in favor of interpretation as numeric literals: | |
681 | 681 | |
682 | 682 | * Expressions starting with `0x` are always hexadecimal literals. |
683 | 683 | * Expressions starting with a numeric literal followed by `e` or `E` are always floating-point literals. |
15 | 15 | | `IteratorEltype(IterType)` | `HasEltype()` | Either `EltypeUnknown()` or `HasEltype()` as appropriate | |
16 | 16 | | `eltype(IterType)` | `Any` | The type of the first entry of the tuple returned by `iterate()` | |
17 | 17 | | `length(iter)` | (*undefined*) | The number of items, if known | |
18 | | `size(iter, [dim...])` | (*undefined*) | The number of items in each dimension, if known | | |
18 | | `size(iter, [dim])` | (*undefined*) | The number of items in each dimension, if known | | |
19 | 19 | |
20 | 20 | | Value returned by `IteratorSize(IterType)` | Required Methods | |
21 | 21 | |:------------------------------------------ |:------------------------------------------ | |
22 | 22 | | `HasLength()` | [`length(iter)`](@ref) | |
23 | | `HasShape{N}()` | `length(iter)` and `size(iter, [dim...])` | | |
23 | | `HasShape{N}()` | `length(iter)` and `size(iter, [dim])` | | |
24 | 24 | | `IsInfinite()` | (*none*) | |
25 | 25 | | `SizeUnknown()` | (*none*) | |
26 | 26 | |
230 | 230 | | `length(A)` | `prod(size(A))` | Number of elements | |
231 | 231 | | `similar(A)` | `similar(A, eltype(A), size(A))` | Return a mutable array with the same shape and element type | |
232 | 232 | | `similar(A, ::Type{S})` | `similar(A, S, size(A))` | Return a mutable array with the same shape and the specified element type | |
233 | | `similar(A, dims::NTuple{Int})` | `similar(A, eltype(A), dims)` | Return a mutable array with the same element type and size *dims* | | |
234 | | `similar(A, ::Type{S}, dims::NTuple{Int})` | `Array{S}(undef, dims)` | Return a mutable array with the specified element type and size | | |
233 | | `similar(A, dims::Dims)` | `similar(A, eltype(A), dims)` | Return a mutable array with the same element type and size *dims* | | |
234 | | `similar(A, ::Type{S}, dims::Dims)` | `Array{S}(undef, dims)` | Return a mutable array with the specified element type and size | | |
235 | 235 | | **Non-traditional indices** | **Default definition** | **Brief description** | |
236 | 236 | | `axes(A)` | `map(OneTo, size(A))` | Return the `AbstractUnitRange` of valid indices | |
237 | | `Base.similar(A, ::Type{S}, inds::NTuple{Ind})` | `similar(A, S, Base.to_shape(inds))` | Return a mutable array with the specified indices `inds` (see below) | | |
237 | | `Base.similar(A, ::Type{S}, inds)` | `similar(A, S, Base.to_shape(inds))` | Return a mutable array with the specified indices `inds` (see below) | | |
238 | 238 | | `Base.similar(T::Union{Type,Function}, inds)` | `T(Base.to_shape(inds))` | Return an array similar to `T` with the specified indices `inds` (see below) | |
239 | 239 | |
240 | 240 | If a type is defined as a subtype of `AbstractArray`, it inherits a very large set of rich behaviors |
231 | 231 | of each file loaded by `include` or added explicitly by `include_dependency` is unchanged, or equal |
232 | 232 | to the modification time truncated to the nearest second (to accommodate systems that can't copy |
233 | 233 | mtime with sub-second accuracy). It also takes into account whether the path to the file chosen |
234 | by the search logic in `require` matches the path that had created the precompile file. | |
235 | ||
236 | It also takes into account the set of dependencies already loaded into the current process and | |
237 | won't recompile those modules, even if their files change or disappear, in order to avoid creating | |
238 | incompatibilities between the running system and the precompile cache. If you want to have changes | |
239 | to the source reflected in the running system, you should call `reload("Module")` on the module | |
240 | you changed, and any module that depended on it in which you want to see the change reflected. | |
234 | by the search logic in `require` matches the path that had created the precompile file. It also takes | |
235 | into account the set of dependencies already loaded into the current process and won't recompile those | |
236 | modules, even if their files change or disappear, in order to avoid creating incompatibilities between | |
237 | the running system and the precompile cache. | |
241 | 238 | |
242 | 239 | If you know that a module is *not* safe to precompile your module |
243 | 240 | (for example, for one of the reasons described below), you should |
252 | 252 | Floating point literals are closer in behavior to C/C++. Octal (prefixed with `0o`) and binary |
253 | 253 | (prefixed with `0b`) literals are also treated as unsigned. |
254 | 254 | * String literals can be delimited with either `"` or `"""`, `"""` delimited literals can contain |
255 | `"` characters without quoting it like `"\""` String literals can have values of other variables | |
255 | `"` characters without quoting it like `"\""`. String literals can have values of other variables | |
256 | 256 | or expressions interpolated into them, indicated by `$variablename` or `$(expression)`, which |
257 | 257 | evaluates the variable name or the expression in the context of the function. |
258 | 258 | * `//` indicates a [`Rational`](@ref) number, and not a single-line comment (which is `#` in Julia) |
6 | 6 | 2. Multi-Threading |
7 | 7 | 3. Multi-Core or Distributed Processing |
8 | 8 | |
9 | We will first consider Julia [Tasks (aka Coroutines)](@ref man-tasks) and other modules that rely on the Julia runtime library, that allow to suspend and resume computations with full control of inter-`Tasks` communication without having to manually interface with the operative system's scheduler. | |
10 | Julia also allows to communicate between `Tasks` through operations like [`wait`](@ref) and [`fetch`](@ref). | |
11 | Communication and data synchronization is managed through [`Channel`](@ref)s, which are the conduit | |
12 | that allows inter-`Tasks` communication. | |
9 | We will first consider Julia [Tasks (aka Coroutines)](@ref man-tasks) and other modules that rely on the Julia runtime library, that allow us to suspend and resume computations with full control of inter-`Tasks` communication without having to manually interface with the operating system's scheduler. | |
10 | Julia also supports communication between `Tasks` through operations like [`wait`](@ref) and [`fetch`](@ref). | |
11 | Communication and data synchronization is managed through [`Channel`](@ref)s, which are the conduits | |
12 | that provide inter-`Tasks` communication. | |
13 | 13 | |
14 | 14 | Julia also supports experimental multi-threading, where execution is forked and an anonymous function is run across all |
15 | 15 | threads. |
16 | Described as a fork-join approach, parallel threads are branched off and they all have to join the Julia main thread to make serial execution continue. | |
16 | Known as the fork-join approach, parallel threads execute independently, and must ultimately be joined in Julia's main thread to allow serial execution to continue. | |
17 | 17 | Multi-threading is supported using the `Base.Threads` module that is still considered experimental, as Julia is |
18 | not fully thread-safe yet. In particular segfaults seem to emerge for I\O operations and task switching. | |
19 | As an un up-to-date reference, keep an eye on [the issue tracker](https://github.com/JuliaLang/julia/issues?q=is%3Aopen+is%3Aissue+label%3Amultithreading). | |
18 | not yet fully thread-safe. In particular segfaults seem to occur during I\O operations and task switching. | |
19 | As an up-to-date reference, keep an eye on [the issue tracker](https://github.com/JuliaLang/julia/issues?q=is%3Aopen+is%3Aissue+label%3Amultithreading). | |
20 | 20 | Multi-Threading should only be used if you take into consideration global variables, locks and |
21 | atomics, so we will explain it later. | |
22 | ||
23 | In the end we will present Julia's way to distributed and parallel computing. With scientific computing | |
24 | in mind, Julia natively implements interfaces to distribute a process through multiple cores or machines. | |
21 | atomics, all of which are explained later. | |
22 | ||
23 | In the end we will present Julia's approach to distributed and parallel computing. With scientific computing | |
24 | in mind, Julia natively implements interfaces to distribute a process across multiple cores or machines. | |
25 | 25 | Also we will mention useful external packages for distributed programming like `MPI.jl` and `DistributedArrays.jl`. |
26 | 26 | |
27 | 27 | # Coroutines |
76 | 76 | |
77 | 77 | # we can schedule `n` instances of `foo` to be active concurrently. |
78 | 78 | for _ in 1:n |
79 | @schedule foo() | |
79 | @async foo() | |
80 | 80 | end |
81 | 81 | ``` |
82 | 82 | * Channels are created via the `Channel{T}(sz)` constructor. The channel will only hold objects |
183 | 183 | |
184 | 184 | julia> n = 12; |
185 | 185 | |
186 | julia> @schedule make_jobs(n); # feed the jobs channel with "n" jobs | |
186 | julia> @async make_jobs(n); # feed the jobs channel with "n" jobs | |
187 | 187 | |
188 | 188 | julia> for i in 1:4 # start 4 tasks to process requests in parallel |
189 | @schedule do_work() | |
189 | @async do_work() | |
190 | 190 | end |
191 | 191 | |
192 | 192 | julia> @elapsed while n > 0 # print out results |
193 | 193 | job_id, exec_time = take!(results) |
194 | println("$job_id finished in $(round(exec_time,2)) seconds") | |
195 | n = n - 1 | |
194 | println("$job_id finished in $(round(exec_time; digits=2)) seconds") | |
195 | global n = n - 1 | |
196 | 196 | end |
197 | 197 | 4 finished in 0.22 seconds |
198 | 198 | 3 finished in 0.45 seconds |
464 | 464 | g_fix (generic function with 1 method) |
465 | 465 | |
466 | 466 | julia> r = let m = MersenneTwister(1) |
467 | [m; accumulate(Future.randjump, m, fill(big(10)^20, nthreads()-1))] | |
467 | [m; accumulate(Future.randjump, fill(big(10)^20, nthreads()-1), init=m)] | |
468 | 468 | end; |
469 | 469 | |
470 | 470 | julia> g_fix(r) |
1085 | 1085 | |
1086 | 1086 | julia> @elapsed while n > 0 # print out results |
1087 | 1087 | job_id, exec_time, where = take!(results) |
1088 | println("$job_id finished in $(round(exec_time,2)) seconds on worker $where") | |
1088 | println("$job_id finished in $(round(exec_time; digits=2)) seconds on worker $where") | |
1089 | 1089 | n = n - 1 |
1090 | 1090 | end |
1091 | 1091 | 1 finished in 0.18 seconds on worker 4 |
1594 | 1594 | running the Julia REPL (i.e., the master) with the rest of the cluster on the cloud, say on Amazon |
1595 | 1595 | EC2. In this case only port 22 needs to be opened at the remote cluster coupled with SSH client |
1596 | 1596 | authenticated via public key infrastructure (PKI). Authentication credentials can be supplied |
1597 | via `sshflags`, for example ```sshflags=`-e <keyfile>` ```. | |
1597 | via `sshflags`, for example ```sshflags=`-i <keyfile>` ```. | |
1598 | 1598 | |
1599 | 1599 | In an all-to-all topology (the default), all workers connect to each other via plain TCP sockets. |
1600 | 1600 | The security policy on the cluster nodes must thus ensure free connectivity between workers for |
466 | 466 | ``` |
467 | 467 | |
468 | 468 | the annotation of `c` harms performance. To write performant code involving types constructed at |
469 | run-time, use the [function-barrier technique](@ref kernal-functions) discussed below, and ensure | |
469 | run-time, use the [function-barrier technique](@ref kernel-functions) discussed below, and ensure | |
470 | 470 | that the constructed type appears among the argument types of the kernel function so that the kernel |
471 | 471 | operations are properly specialized by the compiler. For example, in the above snippet, as soon as |
472 | 472 | `b` is constructed, it can be passed to another function `k`, the kernel. If, for example, function |
575 | 575 | * Use an explicit conversion: `x = oneunit(Float64)` |
576 | 576 | * Initialize with the first loop iteration, to `x = 1 / rand()`, then loop `for i = 2:10` |
577 | 577 | |
578 | ## [Separate kernel functions (aka, function barriers)](@id kernal-functions) | |
578 | ## [Separate kernel functions (aka, function barriers)](@id kernel-functions) | |
579 | 579 | |
580 | 580 | Many functions follow a pattern of performing some set-up work, and then running many iterations |
581 | 581 | to perform a core computation. Where possible, it is a good idea to put these core computations |
674 | 674 | function has to be conservative, checking the type on each access of `A`; such code will be very |
675 | 675 | slow. |
676 | 676 | |
677 | Now, one very good way to solve such problems is by using the [function-barrier technique](@ref kernal-functions). | |
677 | Now, one very good way to solve such problems is by using the [function-barrier technique](@ref kernel-functions). | |
678 | 678 | However, in some cases you might want to eliminate the type-instability altogether. In such cases, |
679 | 679 | one approach is to pass the dimensionality as a parameter, for example through `Val{T}()` (see |
680 | 680 | ["Value types"](@ref)): |
1150 | 1150 | and may cause a segmentation fault if bounds checking is turned off. Use `LinearIndices(x)` or `eachindex(x)` |
1151 | 1151 | instead (see also [offset-arrays](https://docs.julialang.org/en/latest/devdocs/offset-arrays)). |
1152 | 1152 | |
1153 | !!!note | |
1153 | !!! note | |
1154 | 1154 | While `@simd` needs to be placed directly in front of an innermost `for` loop, both `@inbounds` and `@fastmath` |
1155 | 1155 | can be applied to either single expressions or all the expressions that appear within nested blocks of code, e.g., |
1156 | 1156 | using `@inbounds begin` or `@inbounds for ...`. |
1230 | 1230 | @fastmath @inbounds @simd for i in 1:n |
1231 | 1231 | s += u[i]^2 |
1232 | 1232 | end |
1233 | @fastmath @inbounds return sqrt(s/n) | |
1233 | @fastmath @inbounds return sqrt(s) | |
1234 | 1234 | end |
1235 | 1235 | |
1236 | 1236 | function main() |
129 | 129 | In this case `Vector{Any}(undef, n)` is better. It is also more helpful to the compiler to annotate specific |
130 | 130 | uses (e.g. `a[i]::Int`) than to try to pack many alternatives into one type. |
131 | 131 | |
132 | ## Use naming conventions consistent with Julia's `base/` | |
132 | ## Use naming conventions consistent with Julia `base/` | |
133 | 133 | |
134 | 134 | * modules and type names use capitalization and camel case: `module SparseArrays`, `struct UnitRange`. |
135 | 135 | * functions are lowercase ([`maximum`](@ref), [`convert`](@ref)) and, when readable, with multiple |
142 | 142 | If a function name requires multiple words, consider whether it might represent more than one |
143 | 143 | concept and might be better split into pieces. |
144 | 144 | |
145 | ## Write functions with argument ordering similar to Julia's Base | |
145 | ## Write functions with argument ordering similar to Julia Base | |
146 | 146 | |
147 | 147 | As a general rule, the Base library uses the following order of arguments to functions, |
148 | 148 | as applicable: |
448 | 448 | 0 |
449 | 449 | ``` |
450 | 450 | |
451 | However, it is occasionally useful to reuse an existing variable as the iteration variable. | |
451 | However, it is occasionally useful to reuse an existing local variable as the iteration variable. | |
452 | 452 | This can be done conveniently by adding the keyword `outer`: |
453 | 453 | |
454 | 454 | ```jldoctest |
494 | 494 | |
495 | 495 | Note that `const` only affects the variable binding; the variable may be bound to a mutable |
496 | 496 | object (such as an array), and that object may still be modified. Additionally when one tries |
497 | to assign a value a variable that is declared constant the following scenarios are possible: | |
497 | to assign a value to a variable that is declared constant the following scenarios are possible: | |
498 | 498 | |
499 | 499 | * if a new value has a different type than the type of the constant then an error is thrown: |
500 | 500 | ```jldoctest |
521 | 521 | julia> z = 100 |
522 | 522 | 100 |
523 | 523 | ``` |
524 | The last rule applies for immutable objects even if the vairable binding would change, e.g.: | |
524 | The last rule applies for immutable objects even if the variable binding would change, e.g.: | |
525 | 525 | ```julia-repl |
526 | 526 | julia> const s1 = "1" |
527 | 527 | "1" |
554 | 554 | 1 |
555 | 555 | ``` |
556 | 556 | |
557 | Note that although possible, changing the value of a variable that is declared as constant | |
558 | is strongly discouraged. For instance, if a method references a constant and is already | |
557 | Note that although sometimes possible, changing the value of a `const` variable | |
558 | is strongly discouraged, and is intended only for convenience during | |
559 | interactive use. | |
560 | Changing constants can cause various problems or unexpected behaviors. | |
561 | For instance, if a method references a constant and is already | |
559 | 562 | compiled before the constant is changed then it might keep using the old value: |
560 | 563 | ```jldoctest |
561 | 564 | julia> const x = 1 |
52 | 52 | #define MAXINTVAL (((size_t)-1)>>1) |
53 | 53 | |
54 | 54 | static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims, |
55 | int isunboxed, int elsz) | |
55 | int isunboxed, int isunion, int elsz) | |
56 | 56 | { |
57 | 57 | jl_ptls_t ptls = jl_get_ptls_states(); |
58 | 58 | size_t i, tot, nel=1; |
60 | 60 | jl_array_t *a; |
61 | 61 | |
62 | 62 | for(i=0; i < ndims; i++) { |
63 | wideint_t prod = (wideint_t)nel * (wideint_t)dims[i]; | |
64 | if (prod > (wideint_t) MAXINTVAL) | |
63 | size_t di = dims[i]; | |
64 | wideint_t prod = (wideint_t)nel * (wideint_t)di; | |
65 | if (prod > (wideint_t) MAXINTVAL || di > MAXINTVAL) | |
65 | 66 | jl_error("invalid Array dimensions"); |
66 | 67 | nel = prod; |
67 | 68 | } |
68 | int isunion = atype != NULL && jl_is_uniontype(jl_tparam0(atype)); | |
69 | assert(atype == NULL || isunion == jl_is_uniontype(jl_tparam0(atype))); | |
69 | 70 | if (isunboxed) { |
70 | 71 | wideint_t prod = (wideint_t)elsz * (wideint_t)nel; |
71 | 72 | if (prod > (wideint_t) MAXINTVAL) |
147 | 148 | jl_value_t *eltype = jl_tparam0(atype); |
148 | 149 | size_t elsz = 0, al = 0; |
149 | 150 | int isunboxed = jl_islayout_inline(eltype, &elsz, &al); |
151 | int isunion = jl_is_uniontype(eltype); | |
150 | 152 | if (!isunboxed) { |
151 | 153 | elsz = sizeof(void*); |
152 | 154 | al = elsz; |
153 | 155 | } |
154 | 156 | |
155 | return _new_array_(atype, ndims, dims, isunboxed, elsz); | |
157 | return _new_array_(atype, ndims, dims, isunboxed, isunion, elsz); | |
156 | 158 | } |
157 | 159 | |
158 | 160 | jl_array_t *jl_new_array_for_deserialization(jl_value_t *atype, uint32_t ndims, size_t *dims, |
159 | int isunboxed, int elsz) | |
160 | { | |
161 | return _new_array_(atype, ndims, dims, isunboxed, elsz); | |
161 | int isunboxed, int isunion, int elsz) | |
162 | { | |
163 | return _new_array_(atype, ndims, dims, isunboxed, isunion, elsz); | |
162 | 164 | } |
163 | 165 | |
164 | 166 | #ifndef JL_NDEBUG |
1111 | 1113 | { |
1112 | 1114 | size_t elsz = ary->elsize; |
1113 | 1115 | size_t len = jl_array_len(ary); |
1116 | int isunion = jl_is_uniontype(jl_tparam0(jl_typeof(ary))); | |
1114 | 1117 | jl_array_t *new_ary = _new_array_(jl_typeof(ary), jl_array_ndims(ary), |
1115 | &ary->nrows, !ary->flags.ptrarray, elsz); | |
1118 | &ary->nrows, !ary->flags.ptrarray, | |
1119 | isunion, elsz); | |
1116 | 1120 | memcpy(new_ary->data, ary->data, len * elsz); |
1117 | 1121 | // ensure isbits union arrays copy their selector bytes correctly |
1118 | 1122 | if (jl_array_isbitsunion(ary)) |
1819 | 1819 | JL_GC_POP(); |
1820 | 1820 | return mark_or_box_ccall_result(ctx, strp, retboxed, rt, unionall, static_rt); |
1821 | 1821 | } |
1822 | else if (is_libjulia_func(memcpy)) { | |
1823 | const jl_cgval_t &dst = argv[0]; | |
1824 | const jl_cgval_t &src = argv[1]; | |
1825 | const jl_cgval_t &n = argv[2]; | |
1826 | ctx.builder.CreateMemCpy( | |
1827 | ctx.builder.CreateIntToPtr( | |
1828 | emit_unbox(ctx, T_size, dst, (jl_value_t*)jl_voidpointer_type), T_pint8), | |
1829 | ctx.builder.CreateIntToPtr( | |
1830 | emit_unbox(ctx, T_size, src, (jl_value_t*)jl_voidpointer_type), T_pint8), | |
1831 | emit_unbox(ctx, T_size, n, (jl_value_t*)jl_ulong_type), 1, | |
1832 | false); | |
1833 | JL_GC_POP(); | |
1834 | return ghostValue(jl_void_type); | |
1835 | } | |
1822 | 1836 | |
1823 | 1837 | jl_cgval_t retval = sig.emit_a_ccall( |
1824 | 1838 | ctx, |
769 | 769 | uint32_t na) |
770 | 770 | { |
771 | 771 | jl_ptls_t ptls = jl_get_ptls_states(); |
772 | if (type->instance != NULL) return type->instance; | |
772 | if (type->instance != NULL) { | |
773 | for (size_t i = 0; i < na; i++) { | |
774 | jl_value_t *ft = jl_field_type(type, i); | |
775 | if (!jl_isa(args[i], ft)) | |
776 | jl_type_error("new", ft, args[i]); | |
777 | } | |
778 | return type->instance; | |
779 | } | |
780 | if (type->layout == NULL) | |
781 | jl_type_error("new", (jl_value_t*)jl_datatype_type, (jl_value_t*)type); | |
773 | 782 | size_t nf = jl_datatype_nfields(type); |
774 | 783 | jl_value_t *jv = jl_gc_alloc(ptls, jl_datatype_size(type), type); |
775 | 784 | JL_GC_PUSH1(&jv); |
782 | 791 | for(size_t i=na; i < nf; i++) { |
783 | 792 | if (jl_field_isptr(type, i)) { |
784 | 793 | *(jl_value_t**)((char*)jl_data_ptr(jv)+jl_field_offset(type,i)) = NULL; |
785 | ||
786 | } else { | |
794 | } | |
795 | else { | |
787 | 796 | jl_value_t *ft = jl_field_type(type, i); |
788 | 797 | if (jl_is_uniontype(ft)) { |
789 | 798 | uint8_t *psel = &((uint8_t *)jv)[jl_field_offset(type, i) + jl_field_size(type, i) - 1]; |
637 | 637 | } |
638 | 638 | else if (jl_is_array(v)) { |
639 | 639 | jl_array_t *ar = (jl_array_t*)v; |
640 | if (ar->flags.ndims == 1 && ar->elsize < 128) { | |
640 | int isunion = jl_is_uniontype(jl_tparam0(jl_typeof(ar))); | |
641 | if (ar->flags.ndims == 1 && ar->elsize <= 0x3f) { | |
641 | 642 | write_uint8(s->s, TAG_ARRAY1D); |
642 | write_uint8(s->s, (ar->flags.ptrarray<<7) | (ar->elsize & 0x7f)); | |
643 | write_uint8(s->s, (ar->flags.ptrarray<<7) | (isunion << 6) | (ar->elsize & 0x3f)); | |
643 | 644 | } |
644 | 645 | else { |
645 | 646 | write_uint8(s->s, TAG_ARRAY); |
646 | 647 | write_uint16(s->s, ar->flags.ndims); |
647 | write_uint16(s->s, (ar->flags.ptrarray<<15) | (ar->elsize & 0x7fff)); | |
648 | write_uint16(s->s, (ar->flags.ptrarray << 15) | (isunion << 14) | (ar->elsize & 0x3fff)); | |
648 | 649 | } |
649 | 650 | for (i = 0; i < ar->flags.ndims; i++) |
650 | 651 | jl_serialize_value(s, jl_box_long(jl_array_dim(ar,i))); |
1209 | 1210 | } |
1210 | 1211 | |
1211 | 1212 | // "magic" string and version header of .ji file |
1212 | static const int JI_FORMAT_VERSION = 6; | |
1213 | static const int JI_FORMAT_VERSION = 7; | |
1213 | 1214 | static const char JI_MAGIC[] = "\373jli\r\n\032\n"; // based on PNG signature |
1214 | 1215 | static const uint16_t BOM = 0xFEFF; // byte-order marker |
1215 | 1216 | static void write_header(ios_t *s) |
1494 | 1495 | { |
1495 | 1496 | int usetable = (s->mode != MODE_IR); |
1496 | 1497 | int16_t i, ndims; |
1497 | int isunboxed, elsize; | |
1498 | int isunboxed, isunion, elsize; | |
1498 | 1499 | if (tag == TAG_ARRAY1D) { |
1499 | 1500 | ndims = 1; |
1500 | 1501 | elsize = read_uint8(s->s); |
1501 | 1502 | isunboxed = !(elsize >> 7); |
1502 | elsize = elsize & 0x7f; | |
1503 | isunion = elsize >> 6; | |
1504 | elsize = elsize & 0x3f; | |
1503 | 1505 | } |
1504 | 1506 | else { |
1505 | 1507 | ndims = read_uint16(s->s); |
1506 | 1508 | elsize = read_uint16(s->s); |
1507 | 1509 | isunboxed = !(elsize >> 15); |
1508 | elsize = elsize & 0x7fff; | |
1510 | isunion = elsize >> 14; | |
1511 | elsize = elsize & 0x3fff; | |
1509 | 1512 | } |
1510 | 1513 | uintptr_t pos = backref_list.len; |
1511 | 1514 | if (usetable) |
1514 | 1517 | for (i = 0; i < ndims; i++) { |
1515 | 1518 | dims[i] = jl_unbox_long(jl_deserialize_value(s, NULL)); |
1516 | 1519 | } |
1517 | jl_array_t *a = jl_new_array_for_deserialization((jl_value_t*)NULL, ndims, dims, isunboxed, elsize); | |
1520 | jl_array_t *a = jl_new_array_for_deserialization( | |
1521 | (jl_value_t*)NULL, ndims, dims, isunboxed, isunion, elsize); | |
1518 | 1522 | if (usetable) |
1519 | 1523 | backref_list.items[pos] = a; |
1520 | 1524 | jl_value_t *aty = jl_deserialize_value(s, &jl_astaggedvalue(a)->type); |
1642 | 1646 | m->file = (jl_sym_t*)jl_deserialize_value(s, NULL); |
1643 | 1647 | m->line = read_int32(s->s); |
1644 | 1648 | m->min_world = jl_world_counter; |
1649 | m->max_world = ~(size_t)0; | |
1645 | 1650 | m->ambig = jl_deserialize_value(s, (jl_value_t**)&m->ambig); |
1646 | 1651 | jl_gc_wb(m, m->ambig); |
1647 | 1652 | m->called = read_int32(s->s); |
2987 | 2992 | //assert(ti != jl_bottom_type); (void)ti; |
2988 | 2993 | if (ti == jl_bottom_type) |
2989 | 2994 | env = jl_emptysvec; // the intersection may fail now if the type system had made an incorrect subtype env in the past |
2990 | jl_method_instance_t *_new = jl_specializations_get_linfo(m, (jl_value_t*)argtypes, env, jl_world_counter); | |
2995 | jl_method_instance_t *_new = jl_specializations_get_linfo(m, (jl_value_t*)argtypes, env, jl_world_counter < max_world ? jl_world_counter : max_world); | |
2991 | 2996 | _new->max_world = max_world; |
2992 | 2997 | jl_update_backref_list((jl_value_t*)li, (jl_value_t*)_new, start); |
2993 | 2998 | return _new; |
147 | 147 | // get or create the MethodInstance for a specialization |
148 | 148 | JL_DLLEXPORT jl_method_instance_t *jl_specializations_get_linfo(jl_method_t *m, jl_value_t *type, jl_svec_t *sparams, size_t world) |
149 | 149 | { |
150 | assert(world >= m->min_world && "typemap lookup is corrupted"); | |
150 | assert(world >= m->min_world && world <= m->max_world && "typemap lookup is corrupted"); | |
151 | 151 | JL_LOCK(&m->writelock); |
152 | 152 | jl_typemap_entry_t *sf = |
153 | 153 | jl_typemap_assoc_by_type(m->specializations, type, NULL, /*subtype*/0, /*offs*/0, world, /*max_world_mask*/0); |
168 | 168 | li->min_world = world; |
169 | 169 | } |
170 | 170 | if (world == jl_world_counter) { |
171 | li->max_world = ~(size_t)0; | |
171 | li->max_world = m->max_world; | |
172 | 172 | } |
173 | 173 | else { |
174 | 174 | li->max_world = world; |
357 | 357 | else { |
358 | 358 | JL_LOCK(&li->def.method->writelock); |
359 | 359 | assert(min_world >= li->def.method->min_world); |
360 | assert(max_world <= li->def.method->max_world); | |
360 | 361 | int isinferred = jl_is_rettype_inferred(li); |
361 | 362 | if (!isinferred && li->min_world >= min_world && li->max_world <= max_world) { |
362 | 363 | // expand the current (uninferred) entry to cover the full inferred range |
954 | 955 | jl_tupletype_t *cachett = tt; |
955 | 956 | jl_svec_t* guardsigs = jl_emptysvec; |
956 | 957 | size_t min_valid = definition->min_world; |
957 | size_t max_valid = ~(size_t)0; | |
958 | size_t max_valid = definition->max_world; | |
958 | 959 | if (!cache_with_orig) { |
959 | 960 | // now examine what will happen if we chose to use this sig in the cache |
960 | 961 | temp = ml_matches(mt->defs, 0, compilationsig, -1, 0, world, &min_valid, &max_valid); // TODO: use MAX_UNSPECIALIZED_CONFLICTS? |
1500 | 1501 | jl_error("method not in method table"); |
1501 | 1502 | JL_LOCK(&mt->writelock); |
1502 | 1503 | // Narrow the world age on the method to make it uncallable |
1504 | method->max_world = jl_world_counter; | |
1503 | 1505 | methodentry->max_world = jl_world_counter++; |
1504 | 1506 | // Recompute ambiguities (deleting a more specific method might reveal ambiguities that it previously resolved) |
1505 | 1507 | check_ambiguous_matches(mt->defs, methodentry, check_disabled_ambiguous_visitor); // TODO: decrease repeated work? |
1524 | 1526 | JL_LOCK(&mt->writelock); |
1525 | 1527 | jl_typemap_entry_t *newentry = jl_typemap_insert(&mt->defs, (jl_value_t*)mt, |
1526 | 1528 | (jl_tupletype_t*)type, simpletype, jl_emptysvec, (jl_value_t*)method, 0, &method_defs, |
1527 | method->min_world, ~(size_t)0, &oldvalue); | |
1529 | method->min_world, method->max_world, &oldvalue); | |
1528 | 1530 | if (oldvalue) { |
1529 | 1531 | if (oldvalue == (jl_value_t*)method) { |
1530 | 1532 | // redundant add of same method; no need to do anything |
1981 | 1983 | return 0; |
1982 | 1984 | for (size_t i = 0; i < jl_array_len(m->ambig); i++) { |
1983 | 1985 | jl_method_t *mambig = (jl_method_t*)jl_array_ptr_ref(m->ambig, i); |
1984 | if (jl_subtype((jl_value_t*)types, (jl_value_t*)mambig->sig)) | |
1986 | if (mambig->min_world <= jl_world_counter && jl_world_counter <= mambig->max_world && jl_subtype((jl_value_t*)types, (jl_value_t*)mambig->sig)) | |
1985 | 1987 | return 1; |
1986 | 1988 | } |
1987 | 1989 | return 0; |
1995 | 1997 | return 0; |
1996 | 1998 | for (size_t i = 0; i < jl_array_len(m->ambig); i++) { |
1997 | 1999 | jl_method_t *mambig = (jl_method_t*)jl_array_ptr_ref(m->ambig, i); |
1998 | if (!jl_has_empty_intersection(mambig->sig, types)) | |
2000 | if (mambig->min_world <= jl_world_counter && jl_world_counter <= mambig->max_world && !jl_has_empty_intersection(mambig->sig, types)) | |
1999 | 2001 | return 1; |
2000 | 2002 | } |
2001 | 2003 | return 0; |
591 | 591 | jl_options.outputbc = abspath(jl_options.outputbc, 0); |
592 | 592 | if (jl_options.machine_file) |
593 | 593 | jl_options.machine_file = abspath(jl_options.machine_file, 0); |
594 | if (jl_options.project && strncmp(jl_options.project, "@.", strlen(jl_options.project)) != 0) | |
595 | jl_options.project = abspath(jl_options.project, 0); | |
594 | 596 | |
595 | 597 | const char **cmdp = jl_options.cmds; |
596 | 598 | if (cmdp) { |
396 | 396 | if (jl_is_pinode(e)) { |
397 | 397 | jl_value_t *val = eval_value(jl_fieldref_noalloc(e, 0), s); |
398 | 398 | #ifndef JL_NDEBUG |
399 | JL_GC_PUSH1(&val); | |
399 | 400 | jl_typeassert(val, jl_fieldref_noalloc(e, 1)); |
401 | JL_GC_POP(); | |
400 | 402 | #endif |
401 | 403 | return val; |
402 | 404 | } |
474 | 476 | return jl_nothing; |
475 | 477 | } |
476 | 478 | else if (head == new_sym) { |
477 | jl_value_t *thetype = eval_value(args[0], s); | |
478 | jl_value_t *v=NULL, *fldv=NULL; | |
479 | JL_GC_PUSH3(&thetype, &v, &fldv); | |
480 | assert(jl_is_structtype(thetype)); | |
481 | v = jl_new_struct_uninit((jl_datatype_t*)thetype); | |
482 | for (size_t i = 1; i < nargs; i++) { | |
483 | jl_value_t *ft = jl_field_type(thetype, i - 1); | |
484 | fldv = eval_value(args[i], s); | |
485 | if (!jl_isa(fldv, ft)) | |
486 | jl_type_error("new", ft, fldv); | |
487 | jl_set_nth_field(v, i - 1, fldv); | |
488 | } | |
479 | jl_value_t **argv; | |
480 | JL_GC_PUSHARGS(argv, nargs); | |
481 | for (size_t i = 0; i < nargs; i++) | |
482 | argv[i] = eval_value(args[i], s); | |
483 | assert(jl_is_structtype(argv[0])); | |
484 | jl_value_t *v = jl_new_structv((jl_datatype_t*)argv[0], &argv[1], nargs - 1); | |
489 | 485 | JL_GC_POP(); |
490 | 486 | return v; |
491 | 487 | } |
132 | 132 | (jl-expand-to-thunk |
133 | 133 | (let* ((name (caddr e)) |
134 | 134 | (body (cadddr e)) |
135 | (loc (cadr body)) | |
136 | (x (if (eq? name 'x) 'y 'x))) | |
135 | (loc (cadr body)) | |
136 | (loc (if (and (pair? loc) (eq? (car loc) 'line)) | |
137 | (list loc) | |
138 | '())) | |
139 | (x (if (eq? name 'x) 'y 'x))) | |
137 | 140 | `(block |
138 | 141 | (= (call eval ,x) |
139 | 142 | (block |
140 | ,loc | |
143 | ,@loc | |
141 | 144 | (call (core eval) ,name ,x))) |
142 | 145 | (= (call include ,x) |
143 | 146 | (block |
144 | ,loc | |
147 | ,@loc | |
145 | 148 | (call (top include) ,name ,x))))))) |
146 | 149 | |
147 | 150 | ;; parse only, returning end position, no expansion. |
109 | 109 | |
110 | 110 | // code generation options |
111 | 111 | //" --compile={yes|no|all|min}Enable or disable JIT compiler, or request exhaustive compilation\n" |
112 | " -C, --cpu-target <target> Limit usage of cpu features up to <target>; set to \"help\" to see the available options\n" | |
112 | " -C, --cpu-target <target> Limit usage of CPU features up to <target>; set to \"help\" to see the available options\n" | |
113 | 113 | " -O, --optimize={0,1,2,3} Set the optimization level (default level is 2 if unspecified or 3 if used without a level)\n" |
114 | 114 | " -g, -g <level> Enable / Set the level of debug info generation" |
115 | 115 | #ifdef JL_DEBUG_BUILD |
2058 | 2058 | jl_method_type = |
2059 | 2059 | jl_new_datatype(jl_symbol("Method"), core, |
2060 | 2060 | jl_any_type, jl_emptysvec, |
2061 | jl_perm_symsvec(19, | |
2061 | jl_perm_symsvec(20, | |
2062 | 2062 | "name", |
2063 | 2063 | "module", |
2064 | 2064 | "file", |
2065 | 2065 | "line", |
2066 | 2066 | "sig", |
2067 | 2067 | "min_world", |
2068 | "max_world", | |
2068 | 2069 | "ambig", |
2069 | 2070 | "specializations", |
2070 | 2071 | "sparam_syms", |
2078 | 2079 | "nospecialize", |
2079 | 2080 | "isva", |
2080 | 2081 | "pure"), |
2081 | jl_svec(19, | |
2082 | jl_svec(20, | |
2082 | 2083 | jl_sym_type, |
2083 | 2084 | jl_module_type, |
2084 | 2085 | jl_sym_type, |
2085 | 2086 | jl_int32_type, |
2086 | 2087 | jl_type_type, |
2088 | jl_long_type, | |
2087 | 2089 | jl_long_type, |
2088 | 2090 | jl_any_type, // Union{Array, Nothing} |
2089 | 2091 | jl_any_type, // TypeMap |
2098 | 2100 | jl_int32_type, |
2099 | 2101 | jl_bool_type, |
2100 | 2102 | jl_bool_type), |
2101 | 0, 1, 9); | |
2103 | 0, 1, 10); | |
2102 | 2104 | |
2103 | 2105 | jl_method_instance_type = |
2104 | 2106 | jl_new_datatype(jl_symbol("MethodInstance"), core, |
2210 | 2212 | jl_svecset(jl_methtable_type->types, 7, jl_int32_type); // DWORD |
2211 | 2213 | #endif |
2212 | 2214 | jl_svecset(jl_methtable_type->types, 8, jl_int32_type); // uint32_t |
2213 | jl_svecset(jl_method_type->types, 10, jl_method_instance_type); | |
2215 | jl_svecset(jl_method_type->types, 11, jl_method_instance_type); | |
2214 | 2216 | jl_svecset(jl_method_instance_type->types, 11, jl_voidpointer_type); |
2215 | 2217 | jl_svecset(jl_method_instance_type->types, 12, jl_voidpointer_type); |
2216 | 2218 | jl_svecset(jl_method_instance_type->types, 13, jl_voidpointer_type); |
778 | 778 | (begin (if (not (ts:space? s)) |
779 | 779 | (error "space required before \"?\" operator")) |
780 | 780 | (take-token s) ; take the ? |
781 | (let ((t (with-whitespace-newline (without-range-colon (peek-token s))))) | |
781 | (let ((t (with-whitespace-newline (without-range-colon (require-token s))))) | |
782 | 782 | (if (not (ts:space? s)) |
783 | 783 | (error "space required after \"?\" operator"))) |
784 | 784 | (let ((then (without-range-colon (parse-eq* s)))) |
787 | 787 | (if (not (ts:space? s)) |
788 | 788 | (error "space required before colon in \"?\" expression")) |
789 | 789 | (take-token s) ; take the : |
790 | (let ((t (with-whitespace-newline (peek-token s)))) | |
790 | (let ((t (with-whitespace-newline (require-token s)))) | |
791 | 791 | (if (not (ts:space? s)) |
792 | 792 | (error "space required after colon in \"?\" expression"))) |
793 | 793 | (list 'if ex then (parse-eq* s))))) |
199 | 199 | (let ((bounds (map analyze-typevar params))) |
200 | 200 | (values (map car bounds) bounds))) |
201 | 201 | |
202 | (define (unmangled-name v) | |
203 | (if (eq? v '||) | |
204 | v | |
205 | (let ((s (string v))) | |
206 | (if (eqv? (string.char s 0) #\#) | |
207 | (symbol (last (string-split s "#"))) | |
208 | v)))) | |
209 | ||
202 | 210 | ;; construct expression to allocate a TypeVar |
203 | (define (bounds-to-TypeVar v) | |
204 | (let ((v (car v)) | |
211 | (define (bounds-to-TypeVar v (unmangle #f)) | |
212 | (let ((v ((if unmangle unmangled-name identity) (car v))) | |
205 | 213 | (lb (cadr v)) |
206 | 214 | (ub (caddr v))) |
207 | 215 | `(call (core TypeVar) ',v |
683 | 691 | ,@(map make-decl field-names field-types)) |
684 | 692 | (block |
685 | 693 | ,@locs |
686 | (new ,name ,@field-names)))) | |
694 | (new (outerref ,name) ,@field-names)))) | |
687 | 695 | any-ctor) |
688 | 696 | (list any-ctor)))) |
689 | 697 | |
835 | 843 | (block |
836 | 844 | (global ,name) (const ,name) |
837 | 845 | ,@(map (lambda (v) `(local ,v)) params) |
838 | ,@(map (lambda (n v) (make-assignment n (bounds-to-TypeVar v))) params bounds) | |
846 | ,@(map (lambda (n v) (make-assignment n (bounds-to-TypeVar v #t))) params bounds) | |
839 | 847 | (struct_type ,name (call (core svec) ,@params) |
840 | 848 | (call (core svec) ,@(map quotify field-names)) |
841 | 849 | ,super (call (core svec) ,@field-types) ,mut ,min-initialized))) |
876 | 884 | (scope-block |
877 | 885 | (block |
878 | 886 | ,@(map (lambda (v) `(local ,v)) params) |
879 | ,@(map (lambda (n v) (make-assignment n (bounds-to-TypeVar v))) params bounds) | |
887 | ,@(map (lambda (n v) (make-assignment n (bounds-to-TypeVar v #t))) params bounds) | |
880 | 888 | (abstract_type ,name (call (core svec) ,@params) ,super)))))) |
881 | 889 | |
882 | 890 | (define (primitive-type-def-expr n name params super) |
887 | 895 | (scope-block |
888 | 896 | (block |
889 | 897 | ,@(map (lambda (v) `(local ,v)) params) |
890 | ,@(map (lambda (n v) (make-assignment n (bounds-to-TypeVar v))) params bounds) | |
898 | ,@(map (lambda (n v) (make-assignment n (bounds-to-TypeVar v #t))) params bounds) | |
891 | 899 | (primitive_type ,name (call (core svec) ,@params) ,n ,super)))))) |
892 | 900 | |
893 | 901 | ;; take apart a type signature, e.g. T{X} <: S{Y} |
1907 | 1915 | (ssavalue? x)) |
1908 | 1916 | x (make-ssavalue))) |
1909 | 1917 | (ini (if (eq? x xx) '() `((= ,xx ,(expand-forms x))))) |
1918 | (n (length lhss)) | |
1910 | 1919 | (st (gensy))) |
1911 | 1920 | `(block |
1912 | 1921 | ,@ini |
1913 | 1922 | ,.(map (lambda (i lhs) |
1914 | 1923 | (expand-forms |
1915 | 1924 | (lower-tuple-assignment |
1916 | (list lhs st) | |
1925 | (if (= i (- n 1)) | |
1926 | (list lhs) | |
1927 | (list lhs st)) | |
1917 | 1928 | `(call (top indexed_iterate) |
1918 | 1929 | ,xx ,(+ i 1) ,.(if (eq? i 0) '() `(,st)))))) |
1919 | (iota (length lhss)) | |
1930 | (iota n) | |
1920 | 1931 | lhss) |
1921 | 1932 | (unnecessary ,xx)))))) |
1922 | 1933 | ((typed_hcat) |
2421 | 2432 | '(null)) |
2422 | 2433 | ((eq? (car e) 'require-existing-local) |
2423 | 2434 | (if (not (memq (cadr e) env)) |
2424 | (error "no outer variable declaration exists for \"for outer\"")) | |
2435 | (error "no outer local variable declaration exists for \"for outer\"")) | |
2425 | 2436 | '(null)) |
2426 | 2437 | ((eq? (car e) 'lambda) |
2427 | 2438 | (let* ((lv (lam:vars e)) |
2738 | 2749 | ,(delete-duplicates (append (lam:sp lam) capt-sp))) |
2739 | 2750 | ,body))) |
2740 | 2751 | |
2752 | ;; renumber ssavalues assigned in an expr, allowing it to be repeated | |
2753 | (define (renumber-assigned-ssavalues e) | |
2754 | (let ((vals (expr-find-all (lambda (x) (and (assignment? x) (ssavalue? (cadr x)))) | |
2755 | e | |
2756 | cadadr))) | |
2757 | (if (null? vals) | |
2758 | e | |
2759 | (let ((repl (table))) | |
2760 | (for-each (lambda (id) (put! repl id (make-ssavalue))) | |
2761 | vals) | |
2762 | (let do-replace ((x e)) | |
2763 | (if (or (atom? x) (quoted? x)) | |
2764 | x | |
2765 | (if (eq? (car x) 'ssavalue) | |
2766 | (or (get repl (cadr x) #f) x) | |
2767 | (cons (car x) | |
2768 | (map do-replace (cdr x)))))))))) | |
2769 | ||
2741 | 2770 | (define (convert-for-type-decl rhs t) |
2742 | 2771 | (if (equal? t '(core Any)) |
2743 | 2772 | rhs |
2744 | `(call (core typeassert) | |
2745 | (call (top convert) ,t ,rhs) | |
2746 | ,t))) | |
2773 | (let* ((temp (if (or (atom? t) (ssavalue? t) (quoted? t)) | |
2774 | #f | |
2775 | (make-ssavalue))) | |
2776 | (ty (or temp t)) | |
2777 | (ex `(call (core typeassert) | |
2778 | (call (top convert) ,ty ,rhs) | |
2779 | ,ty))) | |
2780 | (if temp | |
2781 | `(block (= ,temp ,(renumber-assigned-ssavalues t)) ,ex) | |
2782 | ex)))) | |
2747 | 2783 | |
2748 | 2784 | ;; convert assignment to a closed variable to a setfield! call. |
2749 | 2785 | ;; while we're at it, generate `convert` calls for variables with |
263 | 263 | // method's type signature. redundant with TypeMapEntry->specTypes |
264 | 264 | jl_value_t *sig; |
265 | 265 | size_t min_world; |
266 | size_t max_world; | |
266 | 267 | |
267 | 268 | // list of potentially-ambiguous methods (nothing = none, Vector{Any} of Methods otherwise) |
268 | 269 | jl_value_t *ambig; |
462 | 462 | jl_value_t *jl_nth_slot_type(jl_value_t *sig JL_PROPAGATES_ROOT, size_t i) JL_NOTSAFEPOINT; |
463 | 463 | void jl_compute_field_offsets(jl_datatype_t *st); |
464 | 464 | jl_array_t *jl_new_array_for_deserialization(jl_value_t *atype, uint32_t ndims, size_t *dims, |
465 | int isunboxed, int elsz); | |
465 | int isunboxed, int isunion, int elsz); | |
466 | 466 | void jl_module_run_initializer(jl_module_t *m); |
467 | 467 | extern jl_array_t *jl_module_init_order JL_GLOBALLY_ROOTED; |
468 | 468 | extern jl_array_t *jl_cfunction_list JL_GLOBALLY_ROOTED; |
348 | 348 | NoteUse(S, BBS, V, BBS.UpExposedUses); |
349 | 349 | } |
350 | 350 | Value *MaybeExtractUnion(std::pair<Value*,int> Val, Instruction *InsertBefore); |
351 | int LiftPhi(State &S, PHINode *Phi); | |
352 | int LiftSelect(State &S, SelectInst *SI); | |
351 | void LiftPhi(State &S, PHINode *Phi, SmallVector<int, 16> &PHINumbers); | |
352 | bool LiftSelect(State &S, SelectInst *SI); | |
353 | 353 | int Number(State &S, Value *V); |
354 | 354 | std::vector<int> NumberVector(State &S, Value *Vec); |
355 | 355 | int NumberBase(State &S, Value *V, Value *Base); |
382 | 382 | }; |
383 | 383 | |
384 | 384 | static unsigned getValueAddrSpace(Value *V) { |
385 | return cast<PointerType>(V->getType())->getAddressSpace(); | |
385 | Type *Ty = V->getType(); | |
386 | if (isa<VectorType>(Ty)) | |
387 | Ty = cast<VectorType>(V->getType())->getElementType(); | |
388 | return cast<PointerType>(Ty)->getAddressSpace(); | |
386 | 389 | } |
387 | 390 | |
388 | 391 | static bool isSpecialPtr(Type *Ty) { |
507 | 510 | return Val.first; |
508 | 511 | } |
509 | 512 | |
510 | int LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) { | |
511 | Value *TrueBase = MaybeExtractUnion(FindBaseValue(S, SI->getTrueValue(), false), SI); | |
512 | Value *FalseBase = MaybeExtractUnion(FindBaseValue(S, SI->getFalseValue(), false), SI); | |
513 | if (getValueAddrSpace(TrueBase) != AddressSpace::Tracked) | |
514 | TrueBase = ConstantPointerNull::get(cast<PointerType>(FalseBase->getType())); | |
515 | if (getValueAddrSpace(FalseBase) != AddressSpace::Tracked) | |
516 | FalseBase = ConstantPointerNull::get(cast<PointerType>(TrueBase->getType())); | |
517 | if (getValueAddrSpace(TrueBase) != AddressSpace::Tracked) | |
518 | return -1; | |
519 | Value *SelectBase = SelectInst::Create(SI->getCondition(), | |
520 | TrueBase, FalseBase, "gclift", SI); | |
521 | int Number = ++S.MaxPtrNumber; | |
522 | S.PtrNumbering[SelectBase] = S.AllPtrNumbering[SelectBase] = | |
523 | S.AllPtrNumbering[SI] = Number; | |
524 | S.ReversePtrNumbering[Number] = SelectBase; | |
525 | return Number; | |
526 | } | |
527 | ||
528 | int LateLowerGCFrame::LiftPhi(State &S, PHINode *Phi) | |
513 | static Value *GetPtrForNumber(State &S, unsigned Num, Instruction *InsertionPoint) | |
529 | 514 | { |
530 | PHINode *lift = PHINode::Create(T_prjlvalue, Phi->getNumIncomingValues(), "gclift", Phi); | |
531 | for (unsigned i = 0; i < Phi->getNumIncomingValues(); ++i) { | |
532 | Value *Incoming = Phi->getIncomingValue(i); | |
533 | Value *Base = MaybeExtractUnion(FindBaseValue(S, Incoming, false), | |
534 | Phi->getIncomingBlock(i)->getTerminator()); | |
535 | if (getValueAddrSpace(Base) != AddressSpace::Tracked) | |
536 | Base = ConstantPointerNull::get(cast<PointerType>(T_prjlvalue)); | |
537 | if (Base->getType() != T_prjlvalue) | |
538 | Base = new BitCastInst(Base, T_prjlvalue, "", Phi->getIncomingBlock(i)->getTerminator()); | |
539 | lift->addIncoming(Base, Phi->getIncomingBlock(i)); | |
540 | } | |
541 | int Number = ++S.MaxPtrNumber; | |
542 | S.PtrNumbering[lift] = S.AllPtrNumbering[lift] = | |
543 | S.AllPtrNumbering[Phi] = Number; | |
544 | S.ReversePtrNumbering[Number] = lift; | |
545 | return Number; | |
515 | Value *Val = S.ReversePtrNumbering[Num]; | |
516 | if (isSpecialPtrVec(Val->getType())) { | |
517 | const std::vector<int> &AllNums = S.AllVectorNumbering[Val]; | |
518 | unsigned Idx = 0; | |
519 | for (; Idx < AllNums.size(); ++Idx) { | |
520 | if ((unsigned)AllNums[Idx] == Num) | |
521 | break; | |
522 | } | |
523 | Val = ExtractElementInst::Create(Val, ConstantInt::get( | |
524 | Type::getInt32Ty(Val->getContext()), Idx), "", InsertionPoint); | |
525 | } | |
526 | return Val; | |
527 | } | |
528 | ||
529 | bool LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) { | |
530 | if (isSpecialPtrVec(SI->getType())) { | |
531 | VectorType *VT = cast<VectorType>(SI->getType()); | |
532 | std::vector<int> TrueNumbers = NumberVector(S, SI->getTrueValue()); | |
533 | std::vector<int> FalseNumbers = NumberVector(S, SI->getFalseValue()); | |
534 | std::vector<int> Numbers; | |
535 | for (unsigned i = 0; i < VT->getNumElements(); ++i) { | |
536 | SelectInst *LSI = SelectInst::Create(SI->getCondition(), | |
537 | TrueNumbers[i] < 0 ? | |
538 | ConstantPointerNull::get(cast<PointerType>(T_prjlvalue)) : | |
539 | GetPtrForNumber(S, TrueNumbers[i], SI), | |
540 | FalseNumbers[i] < 0 ? | |
541 | ConstantPointerNull::get(cast<PointerType>(T_prjlvalue)) : | |
542 | GetPtrForNumber(S, FalseNumbers[i], SI), | |
543 | "gclift", SI); | |
544 | int Number = ++S.MaxPtrNumber; | |
545 | Numbers.push_back(Number); | |
546 | S.PtrNumbering[LSI] = S.AllPtrNumbering[LSI] = Number; | |
547 | S.ReversePtrNumbering[Number] = LSI; | |
548 | } | |
549 | S.AllVectorNumbering[SI] = Numbers; | |
550 | } else { | |
551 | Value *TrueBase = MaybeExtractUnion(FindBaseValue(S, SI->getTrueValue(), false), SI); | |
552 | Value *FalseBase = MaybeExtractUnion(FindBaseValue(S, SI->getFalseValue(), false), SI); | |
553 | if (getValueAddrSpace(TrueBase) != AddressSpace::Tracked) | |
554 | TrueBase = ConstantPointerNull::get(cast<PointerType>(FalseBase->getType())); | |
555 | if (getValueAddrSpace(FalseBase) != AddressSpace::Tracked) | |
556 | FalseBase = ConstantPointerNull::get(cast<PointerType>(TrueBase->getType())); | |
557 | if (getValueAddrSpace(TrueBase) != AddressSpace::Tracked) | |
558 | return false; | |
559 | Value *SelectBase = SelectInst::Create(SI->getCondition(), | |
560 | TrueBase, FalseBase, "gclift", SI); | |
561 | int Number = ++S.MaxPtrNumber; | |
562 | S.PtrNumbering[SelectBase] = S.AllPtrNumbering[SelectBase] = | |
563 | S.AllPtrNumbering[SI] = Number; | |
564 | S.ReversePtrNumbering[Number] = SelectBase; | |
565 | } | |
566 | return true; | |
567 | } | |
568 | ||
569 | void LateLowerGCFrame::LiftPhi(State &S, PHINode *Phi, SmallVector<int, 16> &PHINumbers) | |
570 | { | |
571 | if (isSpecialPtrVec(Phi->getType())) { | |
572 | VectorType *VT = cast<VectorType>(Phi->getType()); | |
573 | std::vector<PHINode *> lifted; | |
574 | for (unsigned i = 0; i < VT->getNumElements(); ++i) { | |
575 | lifted.push_back(PHINode::Create(T_prjlvalue, Phi->getNumIncomingValues(), "gclift", Phi)); | |
576 | } | |
577 | for (unsigned i = 0; i < Phi->getNumIncomingValues(); ++i) { | |
578 | std::vector<int> Numbers = NumberVector(S, Phi->getIncomingValue(i)); | |
579 | BasicBlock *IncomingBB = Phi->getIncomingBlock(i); | |
580 | Instruction *Terminator = IncomingBB->getTerminator(); | |
581 | for (unsigned i = 0; i < VT->getNumElements(); ++i) { | |
582 | if (Numbers[i] < 0) | |
583 | lifted[i]->addIncoming(ConstantPointerNull::get(cast<PointerType>(T_prjlvalue)), IncomingBB); | |
584 | else | |
585 | lifted[i]->addIncoming(GetPtrForNumber(S, Numbers[i], Terminator), IncomingBB); | |
586 | } | |
587 | } | |
588 | std::vector<int> Numbers; | |
589 | for (unsigned i = 0; i < VT->getNumElements(); ++i) { | |
590 | int Number = ++S.MaxPtrNumber; | |
591 | PHINumbers.push_back(Number); | |
592 | Numbers.push_back(Number); | |
593 | S.PtrNumbering[lifted[i]] = S.AllPtrNumbering[lifted[i]] = Number; | |
594 | S.ReversePtrNumbering[Number] = lifted[i]; | |
595 | } | |
596 | S.AllVectorNumbering[Phi] = Numbers; | |
597 | } else { | |
598 | PHINode *lift = PHINode::Create(T_prjlvalue, Phi->getNumIncomingValues(), "gclift", Phi); | |
599 | for (unsigned i = 0; i < Phi->getNumIncomingValues(); ++i) { | |
600 | Value *Incoming = Phi->getIncomingValue(i); | |
601 | Value *Base = MaybeExtractUnion(FindBaseValue(S, Incoming, false), | |
602 | Phi->getIncomingBlock(i)->getTerminator()); | |
603 | if (getValueAddrSpace(Base) != AddressSpace::Tracked) | |
604 | Base = ConstantPointerNull::get(cast<PointerType>(T_prjlvalue)); | |
605 | if (Base->getType() != T_prjlvalue) | |
606 | Base = new BitCastInst(Base, T_prjlvalue, "", Phi->getIncomingBlock(i)->getTerminator()); | |
607 | lift->addIncoming(Base, Phi->getIncomingBlock(i)); | |
608 | } | |
609 | int Number = ++S.MaxPtrNumber; | |
610 | PHINumbers.push_back(Number); | |
611 | S.PtrNumbering[lift] = S.AllPtrNumbering[lift] = | |
612 | S.AllPtrNumbering[Phi] = Number; | |
613 | S.ReversePtrNumbering[Number] = lift; | |
614 | } | |
546 | 615 | } |
547 | 616 | |
548 | 617 | int LateLowerGCFrame::NumberBase(State &S, Value *V, Value *CurrentV) |
565 | 634 | // input IR) |
566 | 635 | Number = -1; |
567 | 636 | } else if (isa<SelectInst>(CurrentV) && !isUnion && getValueAddrSpace(CurrentV) != AddressSpace::Tracked) { |
568 | int Number = LiftSelect(S, cast<SelectInst>(CurrentV)); | |
569 | S.AllPtrNumbering[V] = Number; | |
637 | Number = -1; | |
638 | if (LiftSelect(S, cast<SelectInst>(CurrentV))) | |
639 | Number = S.AllPtrNumbering[V] = S.AllPtrNumbering.at(CurrentV); | |
570 | 640 | return Number; |
571 | 641 | } else if (isa<PHINode>(CurrentV) && !isUnion && getValueAddrSpace(CurrentV) != AddressSpace::Tracked) { |
572 | int Number = LiftPhi(S, cast<PHINode>(CurrentV)); | |
573 | S.AllPtrNumbering[V] = Number; | |
642 | SmallVector<int, 16> PHINumbers; | |
643 | LiftPhi(S, cast<PHINode>(CurrentV), PHINumbers); | |
644 | Number = S.AllPtrNumbering[V] = S.AllPtrNumbering.at(CurrentV); | |
574 | 645 | return Number; |
575 | 646 | } else if (isa<ExtractValueInst>(CurrentV) && !isUnion) { |
576 | 647 | assert(false && "TODO: Extract"); |
629 | 700 | Numbers = NumberVectorBase(S, IEI->getOperand(0)); |
630 | 701 | int ElNumber = Number(S, IEI->getOperand(1)); |
631 | 702 | Numbers[idx] = ElNumber; |
632 | } else if (isa<LoadInst>(CurrentV) || isa<CallInst>(CurrentV) || isa<PHINode>(CurrentV)) { | |
703 | } else if (isa<SelectInst>(CurrentV) && getValueAddrSpace(CurrentV) != AddressSpace::Tracked) { | |
704 | LiftSelect(S, cast<SelectInst>(CurrentV)); | |
705 | Numbers = S.AllVectorNumbering[CurrentV]; | |
706 | } else if (isa<PHINode>(CurrentV) && getValueAddrSpace(CurrentV) != AddressSpace::Tracked) { | |
707 | SmallVector<int, 16> PHINumbers; | |
708 | LiftPhi(S, cast<PHINode>(CurrentV), PHINumbers); | |
709 | Numbers = S.AllVectorNumbering[CurrentV]; | |
710 | } else if (isa<LoadInst>(CurrentV) || isa<CallInst>(CurrentV) || isa<PHINode>(CurrentV) || | |
711 | isa<SelectInst>(CurrentV)) { | |
633 | 712 | // This is simple, we can just number them sequentially |
634 | 713 | for (unsigned i = 0; i < cast<VectorType>(CurrentV->getType())->getNumElements(); ++i) { |
635 | 714 | int Num = ++S.MaxPtrNumber; |
637 | 716 | S.ReversePtrNumbering[Num] = CurrentV; |
638 | 717 | } |
639 | 718 | } else { |
640 | assert(false && "Unexpected vector generating operating"); | |
719 | assert(false && "Unexpected vector generating operation"); | |
641 | 720 | } |
642 | 721 | S.AllVectorNumbering[CurrentV] = Numbers; |
643 | 722 | return Numbers; |
1147 | 1226 | NoteOperandUses(S, BBS, I, BBS.UpExposedUsesUnrooted); |
1148 | 1227 | } else if (SelectInst *SI = dyn_cast<SelectInst>(&I)) { |
1149 | 1228 | // We need to insert an extra select for the GC root |
1150 | if (!isSpecialPtr(SI->getType()) && !isUnionRep(SI->getType())) | |
1229 | if (!isSpecialPtr(SI->getType()) && !isSpecialPtrVec(SI->getType()) && | |
1230 | !isUnionRep(SI->getType())) | |
1151 | 1231 | continue; |
1152 | 1232 | if (!isUnionRep(SI->getType()) && getValueAddrSpace(SI) != AddressSpace::Tracked) { |
1153 | if (S.AllPtrNumbering.find(SI) != S.AllPtrNumbering.end()) | |
1233 | if (isSpecialPtrVec(SI->getType()) ? | |
1234 | S.AllVectorNumbering.find(SI) != S.AllVectorNumbering.end() : | |
1235 | S.AllPtrNumbering.find(SI) != S.AllPtrNumbering.end()) | |
1154 | 1236 | continue; |
1155 | auto Num = LiftSelect(S, SI); | |
1156 | if (Num < 0) | |
1237 | if (!LiftSelect(S, SI)) | |
1157 | 1238 | continue; |
1158 | auto SelectBase = cast<SelectInst>(S.ReversePtrNumbering[Num]); | |
1159 | SmallVector<int, 1> RefinedPtr{Number(S, SelectBase->getTrueValue()), | |
1160 | Number(S, SelectBase->getFalseValue())}; | |
1161 | S.Refinements[Num] = std::move(RefinedPtr); | |
1239 | if (!isSpecialPtrVec(SI->getType())) { | |
1240 | // TODO: Refinements for vector select | |
1241 | int Num = S.AllPtrNumbering[SI]; | |
1242 | if (Num < 0) | |
1243 | continue; | |
1244 | auto SelectBase = cast<SelectInst>(S.ReversePtrNumbering[Num]); | |
1245 | SmallVector<int, 2> RefinedPtr{Number(S, SelectBase->getTrueValue()), | |
1246 | Number(S, SelectBase->getFalseValue())}; | |
1247 | S.Refinements[Num] = std::move(RefinedPtr); | |
1248 | } | |
1162 | 1249 | } else { |
1163 | SmallVector<int, 1> RefinedPtr{Number(S, SI->getTrueValue()), | |
1164 | Number(S, SI->getFalseValue())}; | |
1250 | SmallVector<int, 2> RefinedPtr; | |
1251 | if (!isSpecialPtrVec(SI->getType())) { | |
1252 | RefinedPtr = { | |
1253 | Number(S, SI->getTrueValue()), | |
1254 | Number(S, SI->getFalseValue()) | |
1255 | }; | |
1256 | } | |
1165 | 1257 | MaybeNoteDef(S, BBS, SI, BBS.Safepoints, std::move(RefinedPtr)); |
1166 | 1258 | NoteOperandUses(S, BBS, I, BBS.UpExposedUsesUnrooted); |
1167 | 1259 | } |
1168 | 1260 | } else if (PHINode *Phi = dyn_cast<PHINode>(&I)) { |
1169 | if (!isSpecialPtr(Phi->getType()) && !isUnionRep(Phi->getType())) { | |
1261 | if (!isSpecialPtr(Phi->getType()) && !isSpecialPtrVec(Phi->getType()) && | |
1262 | !isUnionRep(Phi->getType())) { | |
1170 | 1263 | continue; |
1171 | 1264 | } |
1172 | 1265 | auto nIncoming = Phi->getNumIncomingValues(); |
1173 | 1266 | // We need to insert an extra phi for the GC root |
1174 | 1267 | if (!isUnionRep(Phi->getType()) && getValueAddrSpace(Phi) != AddressSpace::Tracked) { |
1175 | if (S.AllPtrNumbering.find(Phi) != S.AllPtrNumbering.end()) | |
1268 | if (isSpecialPtrVec(Phi->getType()) ? | |
1269 | S.AllVectorNumbering.find(Phi) != S.AllVectorNumbering.end() : | |
1270 | S.AllPtrNumbering.find(Phi) != S.AllPtrNumbering.end()) | |
1176 | 1271 | continue; |
1177 | auto Num = LiftPhi(S, Phi); | |
1178 | auto lift = cast<PHINode>(S.ReversePtrNumbering[Num]); | |
1179 | S.Refinements[Num] = GetPHIRefinements(lift, S); | |
1180 | PHINumbers.push_back(Num); | |
1272 | LiftPhi(S, Phi, PHINumbers); | |
1181 | 1273 | } else { |
1182 | MaybeNoteDef(S, BBS, Phi, BBS.Safepoints, GetPHIRefinements(Phi, S)); | |
1183 | PHINumbers.push_back(Number(S, Phi)); | |
1274 | SmallVector<int, 1> PHIRefinements; | |
1275 | if (!isSpecialPtrVec(Phi->getType())) | |
1276 | PHIRefinements = GetPHIRefinements(Phi, S); | |
1277 | MaybeNoteDef(S, BBS, Phi, BBS.Safepoints, std::move(PHIRefinements)); | |
1278 | if (isSpecialPtrVec(Phi->getType())) { | |
1279 | // TODO: Vector refinements | |
1280 | std::vector<int> Nums = NumberVector(S, Phi); | |
1281 | for (int Num : Nums) | |
1282 | PHINumbers.push_back(Num); | |
1283 | } else { | |
1284 | PHINumbers.push_back(Number(S, Phi)); | |
1285 | } | |
1184 | 1286 | for (unsigned i = 0; i < nIncoming; ++i) { |
1185 | 1287 | BBState &IncomingBBS = S.BBStates[Phi->getIncomingBlock(i)]; |
1186 | 1288 | NoteUse(S, IncomingBBS, Phi->getIncomingValue(i), IncomingBBS.PhiOuts); |
1773 | 1875 | Frame->setOperand(0, ConstantInt::get(T_int32, maxframeargs)); |
1774 | 1876 | } |
1775 | 1877 | return ChangesMade; |
1776 | } | |
1777 | ||
1778 | static Value *GetPtrForNumber(State &S, unsigned Num, Instruction *InsertionPoint) | |
1779 | { | |
1780 | Value *Val = S.ReversePtrNumbering[Num]; | |
1781 | if (isSpecialPtrVec(Val->getType())) { | |
1782 | const std::vector<int> &AllNums = S.AllVectorNumbering[Val]; | |
1783 | unsigned Idx = 0; | |
1784 | for (; Idx < AllNums.size(); ++Idx) { | |
1785 | if ((unsigned)AllNums[Idx] == Num) | |
1786 | break; | |
1787 | } | |
1788 | Val = ExtractElementInst::Create(Val, ConstantInt::get( | |
1789 | Type::getInt32Ty(Val->getContext()), Idx), "", InsertionPoint); | |
1790 | } | |
1791 | return Val; | |
1792 | 1878 | } |
1793 | 1879 | |
1794 | 1880 | static void AddInPredLiveOuts(BasicBlock *BB, BitVector &LiveIn, State &S) |
59 | 59 | |
60 | 60 | ;; function definition |
61 | 61 | (pattern-lambda (function (-$ (call name . argl) (|::| (call name . argl) _t)) body) |
62 | (cons 'varlist (safe-llist-positional-args (fix-arglist argl)))) | |
62 | (cons 'varlist (safe-llist-positional-args (fix-arglist (append (self-argname name) argl))))) | |
63 | 63 | (pattern-lambda (function (where callspec . wheres) body) |
64 | 64 | (let ((others (pattern-expand1 vars-introduced-by-patterns `(function ,callspec ,body)))) |
65 | 65 | (cons 'varlist (append (if (and (pair? others) (eq? (car others) 'varlist)) |
74 | 74 | (pattern-lambda (= (call (curly name . sparams) . argl) body) |
75 | 75 | `(function (call (curly ,name . ,sparams) . ,argl) ,body)) |
76 | 76 | (pattern-lambda (= (-$ (call name . argl) (|::| (call name . argl) _t)) body) |
77 | `(function (call ,name ,@argl) ,body)) | |
77 | `(function ,(cadr __) ,body)) | |
78 | 78 | (pattern-lambda (= (where callspec . wheres) body) |
79 | 79 | (cons 'function (cdr __))) |
80 | 80 | |
134 | 134 | (if var (list 'varlist var) '())) |
135 | 135 | |
136 | 136 | ;; type definition |
137 | (pattern-lambda (struct mut (<: (curly tn . tvars) super) body) | |
138 | (list* 'varlist (cons (unescape tn) (unescape tn)) '(new . new) | |
139 | (typevar-names tvars))) | |
140 | (pattern-lambda (struct mut (curly tn . tvars) body) | |
141 | (list* 'varlist (cons (unescape tn) (unescape tn)) '(new . new) | |
142 | (typevar-names tvars))) | |
143 | (pattern-lambda (struct mut (<: tn super) body) | |
144 | (list 'varlist (cons (unescape tn) (unescape tn)) '(new . new))) | |
145 | (pattern-lambda (struct mut tn body) | |
146 | (list 'varlist (cons (unescape tn) (unescape tn)) '(new . new))) | |
137 | (pattern-lambda (struct mut spec body) | |
138 | (let ((tn (typedef-expr-name spec)) | |
139 | (tv (typedef-expr-tvars spec))) | |
140 | (list* 'varlist (cons (unescape tn) (unescape tn)) '(new . new) | |
141 | (typevar-names tv)))) | |
142 | (pattern-lambda (abstract spec) | |
143 | (let ((tn (typedef-expr-name spec)) | |
144 | (tv (typedef-expr-tvars spec))) | |
145 | (list* 'varlist (cons (unescape tn) (unescape tn)) | |
146 | (typevar-names tv)))) | |
147 | (pattern-lambda (primitive spec nb) | |
148 | (let ((tn (typedef-expr-name spec)) | |
149 | (tv (typedef-expr-tvars spec))) | |
150 | (list* 'varlist (cons (unescape tn) (unescape tn)) | |
151 | (typevar-names tv)))) | |
147 | 152 | |
148 | 153 | )) ; vars-introduced-by-patterns |
149 | 154 | |
176 | 181 | (if (and (pair? e) (eq? (car e) 'escape)) |
177 | 182 | (cadr e) |
178 | 183 | e)) |
184 | ||
185 | (define (typedef-expr-name e) | |
186 | (cond ((atom? e) e) | |
187 | ((or (eq? (car e) 'curly) (eq? (car e) '<:)) (typedef-expr-name (cadr e))) | |
188 | (else e))) | |
189 | ||
190 | (define (typedef-expr-tvars e) | |
191 | (cond ((atom? e) '()) | |
192 | ((eq? (car e) '<:) (typedef-expr-tvars (cadr e))) | |
193 | ((eq? (car e) 'curly) (cddr e)) | |
194 | (else '()))) | |
179 | 195 | |
180 | 196 | (define (typevar-expr-name e) (car (analyze-typevar e))) |
181 | 197 | |
239 | 255 | (safe-arg-names kwargs #t) |
240 | 256 | ;; count escaped argument names as "keywords" to prevent renaming |
241 | 257 | (safe-llist-positional-args lst #t)))) |
258 | ||
259 | ;; argument name for the function itself given `function (f::T)(...)`, otherwise () | |
260 | (define (self-argname name) | |
261 | (if (and (length= name 3) (eq? (car name) '|::|)) | |
262 | (list (cadr name)) | |
263 | '())) | |
242 | 264 | |
243 | 265 | ;; resolve-expansion-vars-with-new-env, but turn on `inarg` once we get inside |
244 | 266 | ;; the formal argument list. `e` in general might be e.g. `(f{T}(x)::T) where T`, |
362 | 384 | ;; in keyword arg A=B, don't transform "A" |
363 | 385 | (unescape (cadr (cadr e)))) |
364 | 386 | ,(resolve-expansion-vars- (caddr (cadr e)) env m parent-scope inarg)) |
365 | ,(resolve-expansion-vars- (caddr e) env m parent-scope inarg))) | |
387 | ,(resolve-expansion-vars-with-new-env (caddr e) env m parent-scope inarg))) | |
366 | 388 | (else |
367 | 389 | `(kw ,(if inarg |
368 | 390 | (resolve-expansion-vars- (cadr e) env m parent-scope inarg) |
369 | 391 | (unescape (cadr e))) |
370 | ,(resolve-expansion-vars- (caddr e) env m parent-scope inarg))))) | |
392 | ,(resolve-expansion-vars-with-new-env (caddr e) env m parent-scope inarg))))) | |
371 | 393 | |
372 | 394 | ((let) |
373 | 395 | (let* ((newenv (new-expansion-env-for e env)) |
459 | 459 | new_linfo->specTypes = types; |
460 | 460 | new_linfo->sparam_vals = sp; |
461 | 461 | new_linfo->min_world = m->min_world; |
462 | new_linfo->max_world = ~(size_t)0; | |
462 | new_linfo->max_world = m->max_world; | |
463 | 463 | return new_linfo; |
464 | 464 | } |
465 | 465 | |
594 | 594 | m->nargs = 0; |
595 | 595 | m->traced = 0; |
596 | 596 | m->min_world = 1; |
597 | m->max_world = ~(size_t)0; | |
597 | 598 | JL_MUTEX_INIT(&m->writelock); |
598 | 599 | return m; |
599 | 600 | } |
638 | 639 | |
639 | 640 | JL_GC_POP(); |
640 | 641 | m->min_world = ++jl_world_counter; |
642 | m->max_world = ~(size_t)0; | |
641 | 643 | return m; |
642 | 644 | } |
643 | 645 |
77 | 77 | JL_DLLEXPORT jl_value_t *jl_cglobal(jl_value_t *v, jl_value_t *ty) |
78 | 78 | { |
79 | 79 | JL_TYPECHK(cglobal, type, ty); |
80 | JL_GC_PUSH1(&v); | |
80 | 81 | jl_value_t *rt = |
81 | v == (jl_value_t*)jl_void_type ? (jl_value_t*)jl_voidpointer_type : // a common case | |
82 | ty == (jl_value_t*)jl_void_type ? (jl_value_t*)jl_voidpointer_type : // a common case | |
82 | 83 | (jl_value_t*)jl_apply_type1((jl_value_t*)jl_pointer_type, ty); |
83 | 84 | |
84 | 85 | if (!jl_is_concrete_type(rt)) |
87 | 88 | if (jl_is_tuple(v) && jl_nfields(v) == 1) |
88 | 89 | v = jl_fieldref(v, 0); |
89 | 90 | |
90 | if (jl_is_pointer(v)) | |
91 | return jl_bitcast(rt, v); | |
91 | if (jl_is_pointer(v)) { | |
92 | v = jl_bitcast(rt, v); | |
93 | JL_GC_POP(); | |
94 | return v; | |
95 | } | |
92 | 96 | |
93 | 97 | char *f_lib = NULL; |
94 | 98 | if (jl_is_tuple(v) && jl_nfields(v) > 1) { |
119 | 123 | jl_value_t *jv = jl_gc_alloc_1w(); |
120 | 124 | jl_set_typeof(jv, rt); |
121 | 125 | *(void**)jl_data_ptr(jv) = ptr; |
126 | JL_GC_POP(); | |
122 | 127 | return jv; |
123 | 128 | } |
124 | 129 |
597 | 597 | { |
598 | 598 | if (!jl_is_typevar(ty) && jl_has_free_typevars(ty)) { |
599 | 599 | jl_value_t *ans = ty; |
600 | jl_array_t *vs = jl_find_free_typevars(ty); | |
600 | jl_array_t *vs = NULL; | |
601 | 601 | JL_GC_PUSH2(&ans, &vs); |
602 | vs = jl_find_free_typevars(ty); | |
602 | 603 | int i; |
603 | 604 | for (i = 0; i < jl_array_len(vs); i++) { |
604 | 605 | ans = jl_type_unionall((jl_tvar_t*)jl_array_ptr_ref(vs, i), ans); |
629 | 630 | btemp = btemp->prev; |
630 | 631 | } |
631 | 632 | jl_varbinding_t vb = { u->var, u->var->lb, u->var->ub, R, NULL, 0, 0, 0, 0, e->invdepth, 0, NULL, e->vars }; |
632 | JL_GC_PUSH3(&u, &vb.lb, &vb.ub); | |
633 | JL_GC_PUSH4(&u, &vb.lb, &vb.ub, &vb.innervars); | |
633 | 634 | e->vars = &vb; |
634 | 635 | int ans; |
635 | 636 | if (R) { |
1187 | 1188 | { |
1188 | 1189 | if (obviously_egal(a, b)) return 1; |
1189 | 1190 | if (obviously_unequal(a, b)) return 0; |
1191 | if (jl_is_datatype(a) && !jl_is_concrete_type(b)) { | |
1192 | // if one type looks more likely to be abstract, check it on the left | |
1193 | // first in order to reject more quickly. | |
1194 | jl_value_t *temp = a; | |
1195 | a = b; | |
1196 | b = temp; | |
1197 | } | |
1190 | 1198 | return jl_subtype(a, b) && jl_subtype(b, a); |
1191 | 1199 | } |
1192 | 1200 | |
1723 | 1731 | // only do the check if N is free in the tuple type's last parameter |
1724 | 1732 | if (jl_is_typevar(N) && N != (jl_value_t*)va_p1 && N != (jl_value_t*)va_p2) { |
1725 | 1733 | jl_value_t *len = jl_box_long(n); |
1734 | JL_GC_PUSH1(&len); | |
1726 | 1735 | jl_value_t *il = R ? intersect(len, N, e, 2) : intersect(N, len, e, 2); |
1736 | JL_GC_POP(); | |
1727 | 1737 | if (il == jl_bottom_type) |
1728 | 1738 | return 0; |
1729 | 1739 | } |
2608 | 2618 | return ret; |
2609 | 2619 | } |
2610 | 2620 | |
2611 | static int partially_morespecific(jl_value_t *a, jl_value_t *b, int invariant, jl_typeenv_t *env) | |
2612 | { | |
2613 | if (jl_is_uniontype(b)) { | |
2614 | jl_uniontype_t *u = (jl_uniontype_t*)b; | |
2615 | if (type_morespecific_(a, u->a, invariant, env) || | |
2616 | type_morespecific_(a, u->b, invariant, env)) | |
2617 | return 1; | |
2618 | return 0; | |
2619 | } | |
2620 | return type_morespecific_(a, b, invariant, env); | |
2621 | } | |
2622 | ||
2623 | 2621 | static int count_occurs(jl_value_t *t, jl_tvar_t *v) |
2624 | 2622 | { |
2625 | 2623 | if (t == (jl_value_t*)v) |
2691 | 2689 | if (jl_is_uniontype(a)) { |
2692 | 2690 | // Union a is more specific than b if some element of a is more specific than b, but |
2693 | 2691 | // not vice-versa. |
2692 | if (sub_msp(b, a, env)) | |
2693 | return 0; | |
2694 | 2694 | jl_uniontype_t *u = (jl_uniontype_t*)a; |
2695 | return ((partially_morespecific(u->a, b, invariant, env) || partially_morespecific(u->b, b, invariant, env)) && | |
2696 | !partially_morespecific(b, a, invariant, env)); | |
2695 | if (type_morespecific_(u->a, b, invariant, env) || type_morespecific_(u->b, b, invariant, env)) { | |
2696 | if (jl_is_uniontype(b)) { | |
2697 | jl_uniontype_t *v = (jl_uniontype_t*)b; | |
2698 | if (type_morespecific_(v->a, a, invariant, env) || type_morespecific_(v->b, a, invariant, env)) | |
2699 | return 0; | |
2700 | } | |
2701 | return 1; | |
2702 | } | |
2703 | return 0; | |
2697 | 2704 | } |
2698 | 2705 | |
2699 | 2706 | if (jl_is_type_type(a) && !invariant) { |
522 | 522 | ((jl_expr_t*)e)->head == jl_incomplete_sym); |
523 | 523 | } |
524 | 524 | |
525 | int jl_needs_lowering(jl_value_t *e) JL_NOTSAFEPOINT | |
526 | { | |
527 | if (!jl_is_expr(e)) | |
528 | return 0; | |
529 | jl_expr_t *ex = (jl_expr_t*)e; | |
530 | jl_sym_t *head = ex->head; | |
531 | if (head == module_sym || head == import_sym || head == using_sym || | |
532 | head == export_sym || head == thunk_sym || head == toplevel_sym || | |
533 | head == error_sym || head == jl_incomplete_sym || head == method_sym) { | |
534 | return 0; | |
535 | } | |
536 | if (head == global_sym) { | |
537 | size_t i, l = jl_array_len(ex->args); | |
538 | for (i = 0; i < l; i++) { | |
539 | jl_value_t *a = jl_exprarg(ex, i); | |
540 | if (!jl_is_symbol(a) && !jl_is_globalref(a)) | |
541 | return 1; | |
542 | } | |
543 | return 0; | |
544 | } | |
545 | return 1; | |
546 | } | |
547 | ||
525 | 548 | void jl_resolve_globals_in_ir(jl_array_t *stmts, jl_module_t *m, jl_svec_t *sparam_vals, |
526 | 549 | int binding_effects); |
527 | 550 | |
599 | 622 | } |
600 | 623 | |
601 | 624 | jl_expr_t *ex = (jl_expr_t*)e; |
625 | ||
602 | 626 | if (ex->head == dot_sym) { |
603 | 627 | if (jl_expr_nargs(ex) != 2) |
604 | 628 | jl_error("syntax: malformed \".\" expression"); |
605 | 629 | jl_value_t *lhs = jl_exprarg(ex, 0); |
606 | 630 | jl_value_t *rhs = jl_exprarg(ex, 1); |
607 | // only handle `a.b` syntax here | |
631 | // only handle `a.b` syntax here, so qualified names can be eval'd in pure contexts | |
608 | 632 | if (jl_is_quotenode(rhs) && jl_is_symbol(jl_fieldref(rhs,0))) |
609 | 633 | return jl_eval_dot_expr(m, lhs, rhs, fast); |
610 | 634 | } |
635 | ||
611 | 636 | if (ptls->in_pure_callback) { |
612 | 637 | jl_error("eval cannot be used in a generated function"); |
613 | 638 | } |
614 | else if (ex->head == module_sym) { | |
615 | return jl_eval_module_expr(m, ex); | |
616 | } | |
617 | else if (ex->head == using_sym) { | |
639 | ||
640 | jl_method_instance_t *li = NULL; | |
641 | jl_code_info_t *thk = NULL; | |
642 | JL_GC_PUSH3(&li, &thk, &ex); | |
643 | ||
644 | if (!expanded && jl_needs_lowering(e)) { | |
645 | ex = (jl_expr_t*)jl_expand(e, m); | |
646 | } | |
647 | jl_sym_t *head = jl_is_expr(ex) ? ex->head : NULL; | |
648 | ||
649 | if (head == module_sym) { | |
650 | jl_value_t *val = jl_eval_module_expr(m, ex); | |
651 | JL_GC_POP(); | |
652 | return val; | |
653 | } | |
654 | else if (head == using_sym) { | |
618 | 655 | size_t last_age = ptls->world_age; |
619 | 656 | ptls->world_age = jl_world_counter; |
620 | 657 | jl_sym_t *name = NULL; |
651 | 688 | } |
652 | 689 | } |
653 | 690 | ptls->world_age = last_age; |
691 | JL_GC_POP(); | |
654 | 692 | return jl_nothing; |
655 | 693 | } |
656 | else if (ex->head == import_sym) { | |
694 | else if (head == import_sym) { | |
657 | 695 | size_t last_age = ptls->world_age; |
658 | 696 | ptls->world_age = jl_world_counter; |
659 | 697 | jl_sym_t *name = NULL; |
678 | 716 | } |
679 | 717 | } |
680 | 718 | ptls->world_age = last_age; |
719 | JL_GC_POP(); | |
681 | 720 | return jl_nothing; |
682 | 721 | } |
683 | else if (ex->head == export_sym) { | |
722 | else if (head == export_sym) { | |
684 | 723 | for (size_t i = 0; i < jl_array_len(ex->args); i++) { |
685 | 724 | jl_sym_t *name = (jl_sym_t*)jl_array_ptr_ref(ex->args, i); |
686 | 725 | if (!jl_is_symbol(name)) |
687 | 726 | jl_error("syntax: malformed \"export\" statement"); |
688 | 727 | jl_module_export(m, name); |
689 | 728 | } |
729 | JL_GC_POP(); | |
690 | 730 | return jl_nothing; |
691 | 731 | } |
692 | else if (ex->head == global_sym) { | |
732 | else if (head == global_sym) { | |
693 | 733 | // create uninitialized mutable binding for "global x" decl |
694 | 734 | size_t i, l = jl_array_len(ex->args); |
695 | 735 | for (i = 0; i < l; i++) { |
696 | jl_value_t *a = jl_exprarg(ex, i); | |
697 | if (!jl_is_symbol(a) && !jl_is_globalref(a)) | |
698 | break; | |
699 | } | |
700 | if (i == l) { | |
701 | for (i = 0; i < l; i++) { | |
702 | jl_sym_t *gs = (jl_sym_t*)jl_exprarg(ex, i); | |
703 | jl_module_t *gm = m; | |
704 | if (jl_is_globalref(gs)) { | |
705 | gm = jl_globalref_mod(gs); | |
706 | gs = jl_globalref_name(gs); | |
707 | } | |
708 | assert(jl_is_symbol(gs)); | |
709 | jl_get_binding_wr(gm, gs, 0); | |
710 | } | |
711 | return jl_nothing; | |
712 | } | |
713 | // fall-through to expand to normalize the syntax | |
714 | } | |
715 | ||
716 | jl_method_instance_t *li = NULL; | |
717 | jl_code_info_t *thk = NULL; | |
718 | JL_GC_PUSH3(&li, &thk, &ex); | |
719 | ||
720 | if (!expanded && ex->head != thunk_sym && ex->head != method_sym && ex->head != toplevel_sym && | |
721 | ex->head != error_sym && ex->head != jl_incomplete_sym) { | |
722 | // not yet expanded | |
723 | ex = (jl_expr_t*)jl_expand(e, m); | |
724 | } | |
725 | jl_sym_t *head = jl_is_expr(ex) ? ex->head : NULL; | |
726 | ||
727 | if (head == toplevel_sym) { | |
736 | jl_value_t *arg = jl_exprarg(ex, i); | |
737 | jl_module_t *gm; | |
738 | jl_sym_t *gs; | |
739 | if (jl_is_globalref(arg)) { | |
740 | gm = jl_globalref_mod(arg); | |
741 | gs = jl_globalref_name(arg); | |
742 | } | |
743 | else { | |
744 | assert(jl_is_symbol(arg)); | |
745 | gm = m; | |
746 | gs = (jl_sym_t*)arg; | |
747 | } | |
748 | jl_get_binding_wr(gm, gs, 0); | |
749 | } | |
750 | JL_GC_POP(); | |
751 | return jl_nothing; | |
752 | } | |
753 | else if (head == toplevel_sym) { | |
728 | 754 | size_t last_age = ptls->world_age; |
729 | 755 | jl_value_t *res = jl_nothing; |
730 | 756 | int i; |
742 | 742 | { |
743 | 743 | // some manually-unrolled common special cases |
744 | 744 | while (ml->simplesig == (void*)jl_nothing && ml->guardsigs == jl_emptysvec && ml->isleafsig) { |
745 | // use a tight loop for a long as possible | |
745 | // use a tight loop for as long as possible | |
746 | 746 | if (world >= ml->min_world && world <= ml->max_world) { |
747 | 747 | if (n == jl_field_count(ml->sig) && jl_typeof(args[0]) == jl_tparam(ml->sig, 0)) { |
748 | 748 | if (n == 1) |
186 | 186 | |
187 | 187 | julia> Dates.dayofweekofmonth(Date("2000-02-15")) |
188 | 188 | 3 |
189 | ```` | |
189 | ``` | |
190 | 190 | """ |
191 | 191 | function dayofweekofmonth(dt::TimeType) |
192 | 192 | d = day(dt) |
643 | 643 | |
644 | 644 | Return the cluster cookie. |
645 | 645 | """ |
646 | cluster_cookie() = LPROC.cookie | |
646 | cluster_cookie() = (init_multi(); LPROC.cookie) | |
647 | 647 | |
648 | 648 | """ |
649 | 649 | cluster_cookie(cookie) -> cookie |
651 | 651 | Set the passed cookie as the cluster cookie, then returns it. |
652 | 652 | """ |
653 | 653 | function cluster_cookie(cookie) |
654 | init_multi() | |
654 | 655 | # The cookie must be an ASCII string with length <= HDR_COOKIE_LEN |
655 | 656 | @assert isascii(cookie) |
656 | 657 | @assert length(cookie) <= HDR_COOKIE_LEN |
718 | 719 | myid() |
719 | 720 | |
720 | 721 | Get the id of the current process. |
722 | ||
723 | # Examples | |
724 | ```julia-repl | |
725 | julia> myid() | |
726 | 1 | |
727 | ||
728 | julia> remotecall_fetch(() -> myid(), 4) | |
729 | 4 | |
730 | ``` | |
721 | 731 | """ |
722 | 732 | myid() = LPROC.id |
723 | 733 | |
725 | 735 | nprocs() |
726 | 736 | |
727 | 737 | Get the number of available processes. |
738 | ||
739 | # Examples | |
740 | ```julia-repl | |
741 | julia> nprocs() | |
742 | 3 | |
743 | ||
744 | julia> workers() | |
745 | 5-element Array{Int64,1}: | |
746 | 2 | |
747 | 3 | |
748 | ``` | |
728 | 749 | """ |
729 | 750 | function nprocs() |
730 | 751 | if myid() == 1 || (PGRP.topology == :all_to_all && !isclusterlazy()) |
744 | 765 | """ |
745 | 766 | nworkers() |
746 | 767 | |
747 | Get the number of available worker processes. This is one less than `nprocs()`. Equal to | |
768 | Get the number of available worker processes. This is one less than [`nprocs()`](@ref). Equal to | |
748 | 769 | `nprocs()` if `nprocs() == 1`. |
770 | ||
771 | # Examples | |
772 | ```julia-repl | |
773 | \$ julia -p 5 | |
774 | ||
775 | julia> nprocs() | |
776 | 6 | |
777 | ||
778 | julia> nworkers() | |
779 | 5 | |
780 | ``` | |
749 | 781 | """ |
750 | 782 | function nworkers() |
751 | 783 | n = nprocs() |
755 | 787 | """ |
756 | 788 | procs() |
757 | 789 | |
758 | Return a list of all process identifiers. | |
790 | Return a list of all process identifiers, including pid 1 (which is not included by [`workers()`](@ref)). | |
791 | ||
792 | # Examples | |
793 | ```julia-repl | |
794 | \$ julia -p 5 | |
795 | ||
796 | julia> procs() | |
797 | 3-element Array{Int64,1}: | |
798 | 1 | |
799 | 2 | |
800 | 3 | |
801 | ``` | |
759 | 802 | """ |
760 | 803 | function procs() |
761 | 804 | if myid() == 1 || (PGRP.topology == :all_to_all && !isclusterlazy()) |
807 | 850 | workers() |
808 | 851 | |
809 | 852 | Return a list of all worker process identifiers. |
853 | ||
854 | # Examples | |
855 | ```julia-repl | |
856 | \$ julia -p 5 | |
857 | ||
858 | julia> workers() | |
859 | 2-element Array{Int64,1}: | |
860 | 2 | |
861 | 3 | |
862 | ``` | |
810 | 863 | """ |
811 | 864 | function workers() |
812 | 865 | allp = procs() |
830 | 883 | workers. |
831 | 884 | |
832 | 885 | Argument `waitfor` specifies how long to wait for the workers to shut down: |
833 | - If unspecified, `rmprocs` will wait until all requested `pids` are removed. | |
834 | - An `ErrorException` is raised if all workers cannot be terminated before | |
835 | the requested `waitfor` seconds. | |
836 | - With a `waitfor` value of 0, the call returns immediately with the workers | |
837 | scheduled for removal in a different task. The scheduled `Task` object is | |
838 | returned. The user should call `wait` on the task before invoking any other | |
839 | parallel calls. | |
886 | - If unspecified, `rmprocs` will wait until all requested `pids` are removed. | |
887 | - An [`ErrorException`](@ref) is raised if all workers cannot be terminated before | |
888 | the requested `waitfor` seconds. | |
889 | - With a `waitfor` value of 0, the call returns immediately with the workers | |
890 | scheduled for removal in a different task. The scheduled [`Task`](@ref) object is | |
891 | returned. The user should call [`wait`](@ref) on the task before invoking any other | |
892 | parallel calls. | |
893 | ||
894 | # Examples | |
895 | ```julia-repl | |
896 | \$ julia -p 5 | |
897 | ||
898 | julia> t = rmprocs(2, 3, waitfor=0) | |
899 | Task (runnable) @0x0000000107c718d0 | |
900 | ||
901 | julia> wait(t) | |
902 | ||
903 | julia> workers() | |
904 | 3-element Array{Int64,1}: | |
905 | 4 | |
906 | 5 | |
907 | 6 | |
908 | ``` | |
840 | 909 | """ |
841 | 910 | function rmprocs(pids...; waitfor=typemax(Int)) |
842 | 911 | cluster_mgmt_from_master_check() |
250 | 250 | |
251 | 251 | function preduce(reducer, f, R) |
252 | 252 | N = length(R) |
253 | chunks = splitrange(N, nworkers()) | |
253 | chunks = splitrange(Int(N), nworkers()) | |
254 | 254 | all_w = workers()[1:length(chunks)] |
255 | 255 | |
256 | 256 | w_exec = Task[] |
387 | 387 | [`RemoteException`](@ref) and thrown. |
388 | 388 | |
389 | 389 | See also [`fetch`](@ref) and [`remotecall`](@ref). |
390 | ||
391 | # Examples | |
392 | ```julia-repl | |
393 | \$ julia -p 2 | |
394 | ||
395 | julia> remotecall_fetch(sqrt, 2, 4) | |
396 | 2.0 | |
397 | ||
398 | julia> remotecall_fetch(sqrt, 2, -4) | |
399 | ERROR: On worker 2: | |
400 | DomainError with -4.0: | |
401 | sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)). | |
402 | ... | |
403 | ``` | |
390 | 404 | """ |
391 | 405 | remotecall_fetch(f, id::Integer, args...; kwargs...) = |
392 | 406 | remotecall_fetch(f, worker_from_id(id), args...; kwargs...) |
480 | 494 | """ |
481 | 495 | wait(r::Future) |
482 | 496 | |
483 | Wait for a value to become available for the specified future. | |
497 | Wait for a value to become available for the specified [`Future`](@ref). | |
484 | 498 | """ |
485 | 499 | wait(r::Future) = (r.v !== nothing && return r; call_on_owner(wait_ref, r, myid()); r) |
486 | 500 | |
487 | 501 | """ |
488 | 502 | wait(r::RemoteChannel, args...) |
489 | 503 | |
490 | Wait for a value to become available on the specified remote channel. | |
504 | Wait for a value to become available on the specified [`RemoteChannel`](@ref). | |
491 | 505 | """ |
492 | 506 | wait(r::RemoteChannel, args...) = (call_on_owner(wait_ref, r, myid(), args...); r) |
493 | 507 |
31 | 31 | """ |
32 | 32 | WorkerPool(workers::Vector{Int}) |
33 | 33 | |
34 | Create a WorkerPool from a vector of worker ids. | |
34 | Create a `WorkerPool` from a vector of worker ids. | |
35 | ||
36 | # Examples | |
37 | ```julia-repl | |
38 | \$ julia -p 3 | |
39 | ||
40 | julia> WorkerPool([2, 3]) | |
41 | WorkerPool(Channel{Int64}(sz_max:9223372036854775807,sz_curr:2), Set([2, 3]), RemoteChannel{Channel{Any}}(1, 1, 6)) | |
42 | ``` | |
35 | 43 | """ |
36 | 44 | function WorkerPool(workers::Vector{Int}) |
37 | 45 | pool = WorkerPool() |
154 | 162 | """ |
155 | 163 | remotecall(f, pool::AbstractWorkerPool, args...; kwargs...) -> Future |
156 | 164 | |
157 | `WorkerPool` variant of `remotecall(f, pid, ....)`. Waits for and takes a free worker from `pool` and performs a `remotecall` on it. | |
165 | [`WorkerPool`](@ref) variant of `remotecall(f, pid, ....)`. Wait for and take a free worker from `pool` and perform a `remotecall` on it. | |
166 | ||
167 | # Examples | |
168 | ```julia-repl | |
169 | \$ julia -p 3 | |
170 | ||
171 | julia> wp = WorkerPool([2, 3]); | |
172 | ||
173 | julia> A = rand(3000); | |
174 | ||
175 | julia> f = remotecall(maximum, wp, A) | |
176 | Future(2, 1, 6, nothing) | |
177 | ``` | |
178 | In this example, the task ran on pid 2, called from pid 1. | |
158 | 179 | """ |
159 | 180 | remotecall(f, pool::AbstractWorkerPool, args...; kwargs...) = remotecall_pool(remotecall, f, pool, args...; kwargs...) |
160 | 181 | |
162 | 183 | """ |
163 | 184 | remotecall_wait(f, pool::AbstractWorkerPool, args...; kwargs...) -> Future |
164 | 185 | |
165 | `WorkerPool` variant of `remotecall_wait(f, pid, ....)`. Waits for and takes a free worker from `pool` and | |
166 | performs a `remotecall_wait` on it. | |
186 | [`WorkerPool`](@ref) variant of `remotecall_wait(f, pid, ....)`. Wait for and take a free worker from `pool` and | |
187 | perform a `remotecall_wait` on it. | |
188 | ||
189 | # Examples | |
190 | ```julia-repl | |
191 | \$ julia -p 3 | |
192 | ||
193 | julia> wp = WorkerPool([2, 3]); | |
194 | ||
195 | julia> A = rand(3000); | |
196 | ||
197 | julia> f = remotecall_wait(maximum, wp, A) | |
198 | Future(3, 1, 9, nothing) | |
199 | ||
200 | julia> fetch(f) | |
201 | 0.9995177101692958 | |
202 | ``` | |
167 | 203 | """ |
168 | 204 | remotecall_wait(f, pool::AbstractWorkerPool, args...; kwargs...) = remotecall_pool(remotecall_wait, f, pool, args...; kwargs...) |
169 | 205 | |
171 | 207 | """ |
172 | 208 | remotecall_fetch(f, pool::AbstractWorkerPool, args...; kwargs...) -> result |
173 | 209 | |
174 | `WorkerPool` variant of `remotecall_fetch(f, pid, ....)`. Waits for and takes a free worker from `pool` and | |
210 | [`WorkerPool`](@ref) variant of `remotecall_fetch(f, pid, ....)`. Waits for and takes a free worker from `pool` and | |
175 | 211 | performs a `remotecall_fetch` on it. |
212 | ||
213 | # Examples | |
214 | ```julia-repl | |
215 | \$ julia -p 3 | |
216 | ||
217 | julia> wp = WorkerPool([2, 3]); | |
218 | ||
219 | julia> A = rand(3000); | |
220 | ||
221 | julia> remotecall_fetch(maximum, wp, A) | |
222 | 0.9995177101692958 | |
223 | ``` | |
176 | 224 | """ |
177 | 225 | remotecall_fetch(f, pool::AbstractWorkerPool, args...; kwargs...) = remotecall_pool(remotecall_fetch, f, pool, args...; kwargs...) |
178 | 226 | |
179 | 227 | """ |
180 | 228 | remote_do(f, pool::AbstractWorkerPool, args...; kwargs...) -> nothing |
181 | 229 | |
182 | `WorkerPool` variant of `remote_do(f, pid, ....)`. Waits for and takes a free worker from `pool` and | |
183 | performs a `remote_do` on it. | |
230 | [`WorkerPool`](@ref) variant of `remote_do(f, pid, ....)`. Wait for and take a free worker from `pool` and | |
231 | perform a `remote_do` on it. | |
184 | 232 | """ |
185 | 233 | remote_do(f, pool::AbstractWorkerPool, args...; kwargs...) = remotecall_pool(remote_do, f, pool, args...; kwargs...) |
186 | 234 | |
189 | 237 | """ |
190 | 238 | default_worker_pool() |
191 | 239 | |
192 | `WorkerPool` containing idle `workers` - used by `remote(f)` and [`pmap`](@ref) (by default). | |
240 | [`WorkerPool`](@ref) containing idle [`workers`](@ref) - used by `remote(f)` and [`pmap`](@ref) (by default). | |
241 | ||
242 | # Examples | |
243 | ```julia-repl | |
244 | \$ julia -p 3 | |
245 | ||
246 | julia> default_worker_pool() | |
247 | WorkerPool(Channel{Int64}(sz_max:9223372036854775807,sz_curr:3), Set([4, 2, 3]), RemoteChannel{Channel{Any}}(1, 1, 4)) | |
248 | ``` | |
193 | 249 | """ |
194 | 250 | function default_worker_pool() |
195 | 251 | # On workers retrieve the default worker pool from the master when accessed |
205 | 261 | end |
206 | 262 | |
207 | 263 | """ |
208 | remote([::AbstractWorkerPool], f) -> Function | |
264 | remote([p::AbstractWorkerPool], f) -> Function | |
209 | 265 | |
210 | 266 | Return an anonymous function that executes function `f` on an available worker |
211 | using [`remotecall_fetch`](@ref). | |
267 | (drawn from [`WorkerPool`](@ref) `p` if provided) using [`remotecall_fetch`](@ref). | |
212 | 268 | """ |
213 | 269 | remote(f) = (args...; kwargs...)->remotecall_fetch(f, default_worker_pool(), args...; kwargs...) |
214 | 270 | remote(p::AbstractWorkerPool, f) = (args...; kwargs...)->remotecall_fetch(f, p, args...; kwargs...) |
1 | 1 | |
2 | 2 | using Test, Distributed, Random, Serialization, Sockets |
3 | 3 | import Distributed: launch, manage |
4 | ||
5 | @test cluster_cookie() isa String | |
4 | 6 | |
5 | 7 | include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl")) |
6 | 8 | |
1524 | 1526 | a27933 = :_not_defined_27933 |
1525 | 1527 | @test remotecall_fetch(()->a27933, first(workers())) === a27933 |
1526 | 1528 | |
1529 | # PR #28651 | |
1530 | for T in (UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64) | |
1531 | n = @distributed (+) for i in Base.OneTo(T(10)) | |
1532 | i | |
1533 | end | |
1534 | @test n == 55 | |
1535 | end | |
1536 | ||
1527 | 1537 | # Run topology tests last after removing all workers, since a given |
1528 | 1538 | # cluster at any time only supports a single topology. |
1529 | 1539 | rmprocs(workers()) |
14 | 14 | $(fcn)(Core.kwfunc(arg1), |
15 | 15 | Tuple{typeof(kwargs), Core.Typeof(arg1), map(Core.Typeof, args)...}) |
16 | 16 | end |
17 | elseif ex0.head == :call | |
17 | elseif ex0.head === :call | |
18 | 18 | return Expr(:call, fcn, esc(ex0.args[1]), |
19 | 19 | Expr(:call, typesof, map(esc, ex0.args[2:end])...)) |
20 | elseif ex0.head == :(=) && length(ex0.args) == 2 && ex0.args[1].head == :(.) | |
21 | return Expr(:call, fcn, Base.setproperty!, | |
22 | Expr(:call, typesof, map(esc, [ex0.args[1].args..., ex0.args[2]])...)) | |
20 | elseif ex0.head === :(=) && length(ex0.args) == 2 | |
21 | lhs, rhs = ex0.args | |
22 | if isa(lhs, Expr) | |
23 | if lhs.head === :(.) | |
24 | return Expr(:call, fcn, Base.setproperty!, | |
25 | Expr(:call, typesof, map(esc, lhs.args)..., esc(rhs))) | |
26 | elseif lhs.head === :ref | |
27 | return Expr(:call, fcn, Base.setindex!, | |
28 | Expr(:call, typesof, esc(lhs.args[1]), esc(rhs), map(esc, lhs.args[2:end])...)) | |
29 | end | |
30 | end | |
31 | elseif ex0.head === :vcat || ex0.head === :typed_vcat | |
32 | if ex0.head === :vcat | |
33 | f, hf = Base.vcat, Base.hvcat | |
34 | args = ex0.args | |
35 | else | |
36 | f, hf = Base.typed_vcat, Base.typed_hvcat | |
37 | args = ex0.args[2:end] | |
38 | end | |
39 | if any(a->isa(a,Expr) && a.head === :row, args) | |
40 | rows = Any[ (isa(x,Expr) && x.head === :row ? x.args : Any[x]) for x in args ] | |
41 | lens = map(length, rows) | |
42 | return Expr(:call, fcn, hf, | |
43 | Expr(:call, typesof, | |
44 | (ex0.head === :vcat ? [] : Any[esc(ex0.args[1])])..., | |
45 | Expr(:tuple, lens...), | |
46 | map(esc, vcat(rows...))...)) | |
47 | else | |
48 | return Expr(:call, fcn, f, | |
49 | Expr(:call, typesof, map(esc, ex0.args)...)) | |
50 | end | |
23 | 51 | else |
24 | for (head, f) in (:ref => Base.getindex, :vcat => Base.vcat, :hcat => Base.hcat, :(.) => Base.getproperty, :vect => Base.vect) | |
25 | if ex0.head == head | |
52 | for (head, f) in (:ref => Base.getindex, :hcat => Base.hcat, :(.) => Base.getproperty, :vect => Base.vect, Symbol("'") => Base.adjoint, :typed_hcat => Base.typed_hcat, :string => string) | |
53 | if ex0.head === head | |
26 | 54 | return Expr(:call, fcn, f, |
27 | 55 | Expr(:call, typesof, map(esc, ex0.args)...)) |
28 | 56 | end |
29 | 57 | end |
30 | 58 | end |
31 | 59 | end |
32 | if isa(ex0, Expr) && ex0.head == :macrocall # Make @edit @time 1+2 edit the macro by using the types of the *expressions* | |
60 | if isa(ex0, Expr) && ex0.head === :macrocall # Make @edit @time 1+2 edit the macro by using the types of the *expressions* | |
33 | 61 | return Expr(:call, fcn, esc(ex0.args[1]), Tuple{#=__source__=#LineNumberNode, #=__module__=#Module, Any[ Core.Typeof(a) for a in ex0.args[3:end] ]...}) |
34 | 62 | end |
35 | 63 | |
39 | 67 | end |
40 | 68 | |
41 | 69 | exret = Expr(:none) |
42 | if ex.head == :call | |
43 | if any(e->(isa(e, Expr) && e.head==:(...)), ex0.args) && | |
70 | if ex.head === :call | |
71 | if any(e->(isa(e, Expr) && e.head === :(...)), ex0.args) && | |
44 | 72 | (ex.args[1] === GlobalRef(Core,:_apply) || |
45 | 73 | ex.args[1] === GlobalRef(Base,:_apply)) |
46 | 74 | # check for splatting |
52 | 80 | Expr(:call, typesof, map(esc, ex.args[2:end])...)) |
53 | 81 | end |
54 | 82 | end |
55 | if ex.head == :thunk || exret.head == :none | |
83 | if ex.head === :thunk || exret.head === :none | |
56 | 84 | exret = Expr(:call, :error, "expression is not a function call, " |
57 | 85 | * "or is too complex for @$fcn to analyze; " |
58 | 86 | * "break it down to simpler parts if possible") |
197 | 197 | # issue #13264 |
198 | 198 | @test (@which vcat(1...)).name == :vcat |
199 | 199 | |
200 | # PR #28122 | |
200 | # PR #28122, issue #25474 | |
201 | 201 | @test (@which [1][1]).name === :getindex |
202 | @test (@which [1 2]).name == :hcat | |
203 | @test (@which [1; 2]).name == :vcat | |
204 | @test (@which [1]).name == :vect | |
202 | @test (@which [1][1] = 2).name === :setindex! | |
203 | @test (@which [1]).name === :vect | |
204 | @test (@which [1 2]).name === :hcat | |
205 | @test (@which [1; 2]).name === :vcat | |
206 | @test (@which Int[1 2]).name === :typed_hcat | |
207 | @test (@which Int[1; 2]).name === :typed_vcat | |
208 | @test (@which [1 2;3 4]).name === :hvcat | |
209 | @test (@which Int[1 2;3 4]).name === :typed_hvcat | |
205 | 210 | |
206 | 211 | # issue #13464 |
207 | let t13464 = "hey there sailor" | |
208 | try | |
209 | @which t13464[1,1] = (1.0,true) | |
210 | error("unexpected") | |
211 | catch err13464 | |
212 | @test startswith(err13464.msg, "expression is not a function call, or is too complex") | |
213 | end | |
212 | try | |
213 | @which x = 1 | |
214 | error("unexpected") | |
215 | catch err13464 | |
216 | @test startswith(err13464.msg, "expression is not a function call, or is too complex") | |
214 | 217 | end |
215 | 218 | |
216 | 219 | module MacroTest |
977 | 977 | |
978 | 978 | atexit() do |
979 | 979 | # refcount zero, no objects to be finalized |
980 | if Threads.atomic_sub!(REFCOUNT, 1) >= 1 | |
980 | if Threads.atomic_sub!(REFCOUNT, 1) == 1 | |
981 | 981 | ccall((:git_libgit2_shutdown, :libgit2), Cint, ()) |
982 | 982 | end |
983 | 983 | end |
59 | 59 | axpby!, |
60 | 60 | bunchkaufman, |
61 | 61 | bunchkaufman!, |
62 | chol, | |
63 | 62 | cholesky, |
64 | 63 | cholesky!, |
65 | 64 | cond, |
133 | 132 | tr, |
134 | 133 | transpose, |
135 | 134 | transpose!, |
136 | transpose_type, | |
137 | 135 | tril, |
138 | 136 | triu, |
139 | 137 | tril!, |
149 | 149 | |
150 | 150 | # sundry basic definitions |
151 | 151 | parent(A::AdjOrTrans) = A.parent |
152 | vec(v::AdjOrTransAbsVec) = v.parent | |
152 | vec(v::TransposeAbsVec) = parent(v) | |
153 | 153 | |
154 | 154 | cmp(A::AdjOrTransAbsVec, B::AdjOrTransAbsVec) = cmp(parent(A), parent(B)) |
155 | 155 | isless(A::AdjOrTransAbsVec, B::AdjOrTransAbsVec) = isless(parent(A), parent(B)) |
339 | 339 | Cuplo = getfield(C, :uplo) |
340 | 340 | info = getfield(C, :info) |
341 | 341 | if d == :U |
342 | return UpperTriangular(Symbol(Cuplo) == d ? Cfactors : copy(Cfactors')) | |
342 | return UpperTriangular(Cuplo === char_uplo(d) ? Cfactors : copy(Cfactors')) | |
343 | 343 | elseif d == :L |
344 | return LowerTriangular(Symbol(Cuplo) == d ? Cfactors : copy(Cfactors')) | |
344 | return LowerTriangular(Cuplo === char_uplo(d) ? Cfactors : copy(Cfactors')) | |
345 | 345 | elseif d == :UL |
346 | return (Symbol(Cuplo) == :U ? UpperTriangular(Cfactors) : LowerTriangular(Cfactors)) | |
346 | return (Cuplo === 'U' ? UpperTriangular(Cfactors) : LowerTriangular(Cfactors)) | |
347 | 347 | else |
348 | 348 | return getfield(C, d) |
349 | 349 | end |
540 | 540 | A2 = A * A |
541 | 541 | A4 = A2 * A2 |
542 | 542 | A6 = A2 * A4 |
543 | U = A * (A6 * (CC[14]*A6 + CC[12]*A4 + CC[10]*A2) + | |
544 | CC[8]*A6 + CC[6]*A4 + CC[4]*A2 + CC[2]*Inn) | |
545 | V = A6 * (CC[13]*A6 + CC[11]*A4 + CC[9]*A2) + | |
546 | CC[7]*A6 + CC[5]*A4 + CC[3]*A2 + CC[1]*Inn | |
543 | U = A * (A6 * (CC[14].*A6 .+ CC[12].*A4 .+ CC[10].*A2) .+ | |
544 | CC[8].*A6 .+ CC[6].*A4 .+ CC[4].*A2 .+ CC[2].*Inn) | |
545 | V = A6 * (CC[13].*A6 .+ CC[11].*A4 .+ CC[9].*A2) .+ | |
546 | CC[7].*A6 .+ CC[5].*A4 .+ CC[3].*A2 .+ CC[1].*Inn | |
547 | 547 | |
548 | 548 | X = V + U |
549 | 549 | LAPACK.gesv!(V-U, X) |
276 | 276 | mul!(out::AbstractVector, A::Adjoint{<:Any,<:Diagonal}, in::AbstractVector) = out .= adjoint.(A.parent.diag) .* in |
277 | 277 | mul!(out::AbstractVector, A::Transpose{<:Any,<:Diagonal}, in::AbstractVector) = out .= transpose.(A.parent.diag) .* in |
278 | 278 | |
279 | mul!(out::AbstractMatrix, A::Diagonal, in::AbstractMatrix) = out .= A.diag .* in | |
280 | mul!(out::AbstractMatrix, A::Adjoint{<:Any,<:Diagonal}, in::AbstractMatrix) = out .= adjoint.(A.parent.diag) .* in | |
281 | mul!(out::AbstractMatrix, A::Transpose{<:Any,<:Diagonal}, in::AbstractMatrix) = out .= transpose.(A.parent.diag) .* in | |
279 | mul!(out::AbstractMatrix, A::Diagonal, in::StridedMatrix) = out .= A.diag .* in | |
280 | mul!(out::AbstractMatrix, A::Adjoint{<:Any,<:Diagonal}, in::StridedMatrix) = out .= adjoint.(A.parent.diag) .* in | |
281 | mul!(out::AbstractMatrix, A::Transpose{<:Any,<:Diagonal}, in::StridedMatrix) = out .= transpose.(A.parent.diag) .* in | |
282 | 282 | |
283 | 283 | # ambiguities with Symmetric/Hermitian |
284 | 284 | # RealHermSymComplex[Sym]/[Herm] only include Number; invariant to [c]transpose |
1273 | 1273 | (0.6931471805599453, 1.0) |
1274 | 1274 | ``` |
1275 | 1275 | """ |
1276 | logabsdet(A::AbstractMatrix) = logabsdet(lu(A)) | |
1276 | logabsdet(A::AbstractMatrix) = logabsdet(lu(A, check=false)) | |
1277 | 1277 | |
1278 | 1278 | """ |
1279 | 1279 | logdet(M) |
1323 | 1323 | Complex{Float64} |
1324 | 1324 | ``` |
1325 | 1325 | """ |
1326 | promote_leaf_eltypes(x::Union{AbstractArray{T},Tuple{Vararg{T}}}) where {T<:Number} = T | |
1327 | promote_leaf_eltypes(x::Union{AbstractArray{T},Tuple{Vararg{T}}}) where {T<:NumberArray} = eltype(T) | |
1326 | promote_leaf_eltypes(x::Union{AbstractArray{T},Tuple{T,Vararg{T}}}) where {T<:Number} = T | |
1327 | promote_leaf_eltypes(x::Union{AbstractArray{T},Tuple{T,Vararg{T}}}) where {T<:NumberArray} = eltype(T) | |
1328 | 1328 | promote_leaf_eltypes(x::T) where {T} = T |
1329 | 1329 | promote_leaf_eltypes(x::Union{AbstractArray,Tuple}) = mapreduce(promote_leaf_eltypes, promote_type, x; init=Bool) |
1330 | 1330 |
57 | 57 | """ |
58 | 58 | LowerTriangular(A::AbstractMatrix) |
59 | 59 | |
60 | Construct a `LowerTriangular` view of the the matrix `A`. | |
60 | Construct a `LowerTriangular` view of the matrix `A`. | |
61 | 61 | |
62 | 62 | # Examples |
63 | 63 | ```jldoctest |
78 | 78 | """ |
79 | 79 | UpperTriangular(A::AbstractMatrix) |
80 | 80 | |
81 | Construct an `UpperTriangular` view of the the matrix `A`. | |
81 | Construct an `UpperTriangular` view of the matrix `A`. | |
82 | 82 | |
83 | 83 | # Examples |
84 | 84 | ```jldoctest |
270 | 270 | |
271 | 271 | @testset "Adjoint and Transpose vector vec methods" begin |
272 | 272 | intvec = [1, 2] |
273 | @test vec(Adjoint(intvec)) === intvec | |
273 | @test vec(Adjoint(intvec)) == intvec | |
274 | 274 | @test vec(Transpose(intvec)) === intvec |
275 | cvec = [1 + 1im] | |
276 | @test vec(cvec')[1] == cvec[1]' | |
275 | 277 | end |
276 | 278 | |
277 | 279 | @testset "horizontal concatenation of Adjoint/Transpose-wrapped vectors and Numbers" begin |
0 | # This file is a part of Julia. License is MIT: https://julialang.org/license | |
1 | ||
2 | using Test, LinearAlgebra | |
3 | @test detect_ambiguities(LinearAlgebra; imported=true, recursive=true) == [] |
79 | 79 | @test logdet(A) ≈ log(det(A)) |
80 | 80 | @test logabsdet(A)[1] ≈ log(abs(det(A))) |
81 | 81 | @test logabsdet(Matrix{elty}(-I, n, n))[2] == -1 |
82 | infinity = convert(float(elty), Inf) | |
83 | @test logabsdet(zeros(elty, n, n)) == (-infinity, zero(elty)) | |
82 | 84 | if elty <: Real |
83 | 85 | @test logabsdet(A)[2] == sign(det(A)) |
84 | 86 | @test_throws DomainError logdet(Matrix{elty}(-I, n, n)) |
444 | 444 | @test Xv1'*Xv3' ≈ XcXc |
445 | 445 | end |
446 | 446 | |
447 | @testset "method ambiguity" begin | |
448 | # Ambiguity test is run inside a clean process. | |
449 | # https://github.com/JuliaLang/julia/issues/28804 | |
450 | script = joinpath(@__DIR__, "ambiguous_exec.jl") | |
451 | cmd = `$(Base.julia_cmd()) --startup-file=no $script` | |
452 | @test success(pipeline(cmd; stdout=stdout, stderr=stderr)) | |
453 | end | |
454 | ||
447 | 455 | end # module TestMatmul |
192 | 192 | modules, such as `Pkg`, or module roots (see [`Base.moduleroot`](@ref)). To |
193 | 193 | enable all debug logging, use the special value `all`. |
194 | 194 | |
195 | ## Writing log events to a file | |
196 | ||
197 | Sometimes it can be useful to write log events to a file. Here is an example | |
198 | of how to use a task-local and global logger to write information to a text | |
199 | file: | |
200 | ||
201 | ```julia-repl | |
202 | # Load the logging module | |
203 | julia> using Logging | |
204 | ||
205 | # Open a textfile for writing | |
206 | julia> io = open("log.txt", "w+") | |
207 | IOStream(<file log.txt>) | |
208 | ||
209 | # Create a simple logger | |
210 | julia> logger = SimpleLogger(io) | |
211 | SimpleLogger(IOStream(<file log.txt>), Info, Dict{Any,Int64}()) | |
212 | ||
213 | # Log a task-specific message | |
214 | julia> with_logger(logger) do | |
215 | @info("a context specific log message") | |
216 | end | |
217 | ||
218 | # Write all buffered messages to the file | |
219 | julia> flush(io) | |
220 | ||
221 | # Set the global logger to logger | |
222 | julia> global_logger(logger) | |
223 | SimpleLogger(IOStream(<file log.txt>), Info, Dict{Any,Int64}()) | |
224 | ||
225 | # This message will now also be written to the file | |
226 | julia> @info("a global log message") | |
227 | ||
228 | # Close the file | |
229 | julia> close(io) | |
230 | ``` | |
231 | ||
195 | 232 | |
196 | 233 | ## Reference |
197 | 234 |
80 | 80 | |
81 | 81 | **Application:** a project which provides standalone functionality not intended |
82 | 82 | to be reused by other Julia projects. For example a web application or a |
83 | commmand-line utility, or simulation/analytics code accompanying a scientific paper. | |
83 | command-line utility, or simulation/analytics code accompanying a scientific paper. | |
84 | 84 | An application may have a UUID but does not need one. |
85 | 85 | An application may also provide global configuration options for packages it |
86 | 86 | depends on. Packages, on the other hand, may not provide global configuration |
145 | 145 | **Depot:** a directory on a system where various package-related resources live, |
146 | 146 | including: |
147 | 147 | |
148 | - `environments`: shared named environments (e.g. `v0.7`, `devtools`) | |
148 | - `environments`: shared named environments (e.g. `v1.0`, `devtools`) | |
149 | 149 | - `clones`: bare clones of package repositories |
150 | 150 | - `compiled`: cached compiled package images (`.ji` files) |
151 | 151 | - `config`: global configuration files (e.g. `startup.jl`) |
180 | 180 | The Pkg REPL-mode is entered from the Julia REPL using the key `]`. |
181 | 181 | |
182 | 182 | ``` |
183 | (v0.7) pkg> | |
183 | (v1.0) pkg> | |
184 | 184 | ``` |
185 | 185 | |
186 | 186 | The part inside the parenthesis of the prompt shows the name of the current project. |
187 | Since we haven't created our own project yet, we are in the default project, located at `~/.julia/environments/v0.7` | |
187 | Since we haven't created our own project yet, we are in the default project, located at `~/.julia/environments/v1.0` | |
188 | 188 | (or whatever version of Julia you happen to run). |
189 | 189 | |
190 | 190 | To return to the `julia>` prompt, either press backspace when the input line is empty or press Ctrl+C. |
206 | 206 | In the Pkg REPL packages can be added with the `add` command followed by the name of the package, for example: |
207 | 207 | |
208 | 208 | ``` |
209 | (v0.7) pkg> add Example | |
209 | (v1.0) pkg> add Example | |
210 | 210 | Cloning default registries into /Users/kristoffer/.julia/registries |
211 | 211 | Cloning registry General from "https://github.com/JuliaRegistries/General.git" |
212 | 212 | Updating registry at `~/.julia/registries/General` |
213 | 213 | Updating git-repo `https://github.com/JuliaRegistries/General.git` |
214 | 214 | Resolving package versions... |
215 | Updating `~/.julia/environments/v0.7/Project.toml` | |
215 | Updating `~/.julia/environments/v1.0/Project.toml` | |
216 | 216 | [7876af07] + Example v0.5.1 |
217 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
217 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
218 | 218 | [7876af07] + Example v0.5.1 |
219 | 219 | [8dfed614] + Test |
220 | 220 | ``` |
227 | 227 | you have added yourself, in this case, `Example`: |
228 | 228 | |
229 | 229 | ``` |
230 | (v0.7) pkg> st | |
230 | (v1.0) pkg> st | |
231 | 231 | Status `Project.toml` |
232 | 232 | [7876af07] Example v0.5.1 |
233 | 233 | ``` |
235 | 235 | The manifest status, in addition, includes the dependencies of explicitly added packages. |
236 | 236 | |
237 | 237 | ``` |
238 | (v0.7) pkg> st --manifest | |
238 | (v1.0) pkg> st --manifest | |
239 | 239 | Status `Manifest.toml` |
240 | 240 | [7876af07] Example v0.5.1 |
241 | 241 | [8dfed614] Test |
255 | 255 | A specific version can be installed by appending a version after a `@` symbol, e.g. `@v0.4`, to the package name: |
256 | 256 | |
257 | 257 | ``` |
258 | (v0.7) pkg> add Example@0.4 | |
259 | Resolving package versions... | |
260 | Updating `~/.julia/environments/v0.7/Project.toml` | |
258 | (v1.0) pkg> add Example@0.4 | |
259 | Resolving package versions... | |
260 | Updating `~/.julia/environments/v1.0/Project.toml` | |
261 | 261 | [7876af07] + Example v0.4.1 |
262 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
262 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
263 | 263 | [7876af07] + Example v0.4.1 |
264 | 264 | ``` |
265 | 265 | |
267 | 267 | we can explicitly track a branch (or commit) by appending `#branch` (or `#commit`) to the package name: |
268 | 268 | |
269 | 269 | ``` |
270 | (v0.7) pkg> add Example#master | |
270 | (v1.0) pkg> add Example#master | |
271 | 271 | Updating git-repo `https://github.com/JuliaLang/Example.jl.git` |
272 | 272 | Resolving package versions... |
273 | Updating `~/.julia/environments/v0.7/Project.toml` | |
273 | Updating `~/.julia/environments/v1.0/Project.toml` | |
274 | 274 | [7876af07] ~ Example v0.5.1 ⇒ v0.5.1+ #master (https://github.com/JuliaLang/Example.jl.git) |
275 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
275 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
276 | 276 | [7876af07] ~ Example v0.5.1 ⇒ v0.5.1+ #master (https://github.com/JuliaLang/Example.jl.git) |
277 | 277 | ``` |
278 | 278 | |
282 | 282 | To go back to tracking the registry version of `Example`, the command `free` is used: |
283 | 283 | |
284 | 284 | ``` |
285 | (v0.7) pkg> free Example | |
286 | Resolving package versions... | |
287 | Updating `~/.julia/environments/v0.7/Project.toml` | |
285 | (v1.0) pkg> free Example | |
286 | Resolving package versions... | |
287 | Updating `~/.julia/environments/v1.0/Project.toml` | |
288 | 288 | [7876af07] ~ Example v0.5.1+ #master (https://github.com/JuliaLang/Example.jl.git) ⇒ v0.5.1 |
289 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
289 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
290 | 290 | [7876af07] ~ Example v0.5.1+ #master )https://github.com/JuliaLang/Example.jl.git) ⇒ v0.5.1 |
291 | 291 | ``` |
292 | 292 | |
296 | 296 | If a package is not in a registry, it can still be added by instead of the package name giving the URL to the repository to `add`. |
297 | 297 | |
298 | 298 | ``` |
299 | (v0.7) pkg> add https://github.com/fredrikekre/ImportMacros.jl | |
299 | (v1.0) pkg> add https://github.com/fredrikekre/ImportMacros.jl | |
300 | 300 | Updating git-repo `https://github.com/fredrikekre/ImportMacros.jl` |
301 | 301 | Resolving package versions... |
302 | 302 | Downloaded MacroTools ─ v0.4.1 |
303 | Updating `~/.julia/environments/v0.7/Project.toml` | |
303 | Updating `~/.julia/environments/v1.0/Project.toml` | |
304 | 304 | [e6797606] + ImportMacros v0.0.0 # (https://github.com/fredrikekre/ImportMacros.jl) |
305 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
305 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
306 | 306 | [e6797606] + ImportMacros v0.0.0 # (https://github.com/fredrikekre/ImportMacros.jl) |
307 | 307 | [1914dd2f] + MacroTools v0.4.1 |
308 | 308 | ``` |
329 | 329 | Let's try to `dev` a registered package: |
330 | 330 | |
331 | 331 | ``` |
332 | (v0.7) pkg> dev Example | |
332 | (v1.0) pkg> dev Example | |
333 | 333 | Updating git-repo `https://github.com/JuliaLang/Example.jl.git` |
334 | 334 | Resolving package versions... |
335 | Updating `~/.julia/environments/v0.7/Project.toml` | |
335 | Updating `~/.julia/environments/v1.0/Project.toml` | |
336 | 336 | [7876af07] + Example v0.5.1+ [`~/.julia/dev/Example`] |
337 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
337 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
338 | 338 | [7876af07] + Example v0.5.1+ [`~/.julia/dev/Example`] |
339 | 339 | ``` |
340 | 340 | |
346 | 346 | For example: |
347 | 347 | |
348 | 348 | ``` |
349 | (v0.7) pkg> dev Example | |
349 | (v1.0) pkg> dev Example | |
350 | 350 | Updating git-repo `https://github.com/JuliaLang/Example.jl.git` |
351 | 351 | [ Info: Path `/Users/kristoffer/.julia/dev/Example` exists and looks like the correct package, using existing path instead of cloning |
352 | 352 | ``` |
360 | 360 | To stop tracking a path and use the registered version again, use `free` |
361 | 361 | |
362 | 362 | ``` |
363 | (v0.7) pkg> free Example | |
364 | Resolving package versions... | |
365 | Updating `~/.julia/environments/v0.7/Project.toml` | |
363 | (v1.0) pkg> free Example | |
364 | Resolving package versions... | |
365 | Updating `~/.julia/environments/v1.0/Project.toml` | |
366 | 366 | [7876af07] ↓ Example v0.5.1+ [`~/.julia/dev/Example`] ⇒ v0.5.1 |
367 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
367 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
368 | 368 | [7876af07] ↓ Example v0.5.1+ [`~/.julia/dev/Example`] ⇒ v0.5.1 |
369 | 369 | ``` |
370 | 370 | |
389 | 389 | to the latest compatible version. Sometimes this is not what you want. You can specify a subset of the dependencies to upgrade by giving them as arguments to `up`, e.g: |
390 | 390 | |
391 | 391 | ``` |
392 | (v0.7) pkg> up Example | |
392 | (v1.0) pkg> up Example | |
393 | 393 | ``` |
394 | 394 | |
395 | 395 | The version of all other packages direct dependencies will stay the same. If you only want to update the minor version of packages, to reduce the risk that your project breaks, you can give the `--minor` flag, e.g: |
396 | 396 | |
397 | 397 | ``` |
398 | (v0.7) pkg> up --minor Example | |
398 | (v1.0) pkg> up --minor Example | |
399 | 399 | ``` |
400 | 400 | |
401 | 401 | Packages that track a repository are not updated when a minor upgrade is done. |
406 | 406 | A pinned package will never be updated. A package can be pinned using `pin` as for example |
407 | 407 | |
408 | 408 | ``` |
409 | (v0.7) pkg> pin Example | |
410 | Resolving package versions... | |
411 | Updating `~/.julia/environments/v0.7/Project.toml` | |
409 | (v1.0) pkg> pin Example | |
410 | Resolving package versions... | |
411 | Updating `~/.julia/environments/v1.0/Project.toml` | |
412 | 412 | [7876af07] ~ Example v0.5.1 ⇒ v0.5.1 ⚲ |
413 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
413 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
414 | 414 | [7876af07] ~ Example v0.5.1 ⇒ v0.5.1 ⚲ |
415 | 415 | ``` |
416 | 416 | |
417 | 417 | Note the pin symbol `⚲` showing that the package is pinned. Removing the pin is done using `free` |
418 | 418 | |
419 | 419 | ``` |
420 | (v0.7) pkg> free Example | |
421 | Updating `~/.julia/environments/v0.7/Project.toml` | |
420 | (v1.0) pkg> free Example | |
421 | Updating `~/.julia/environments/v1.0/Project.toml` | |
422 | 422 | [7876af07] ~ Example v0.5.1 ⚲ ⇒ v0.5.1 |
423 | Updating `~/.julia/environments/v0.7/Manifest.toml` | |
423 | Updating `~/.julia/environments/v1.0/Manifest.toml` | |
424 | 424 | [7876af07] ~ Example v0.5.1 ⚲ ⇒ v0.5.1 |
425 | 425 | ``` |
426 | 426 | |
427 | 427 | ### Testing packages |
428 | 428 | |
429 | The tests for a package can be run using `test`command: | |
430 | ||
431 | ``` | |
432 | (v0.7) pkg> test Example | |
429 | The tests for a package can be run using `test` command: | |
430 | ||
431 | ``` | |
432 | (v1.0) pkg> test Example | |
433 | 433 | Testing Example |
434 | 434 | Testing Example tests passed |
435 | 435 | ``` |
441 | 441 | To explicitly run the build step for a package the `build` command is used: |
442 | 442 | |
443 | 443 | ``` |
444 | (v0.7) pkg> build MbedTLS | |
444 | (v1.0) pkg> build MbedTLS | |
445 | 445 | Building MbedTLS → `~/.julia/packages/MbedTLS/h1Vu/deps/build.log` |
446 | 446 | |
447 | 447 | shell> cat ~/.julia/packages/MbedTLS/h1Vu/deps/build.log |
454 | 454 | |
455 | 455 | ## Creating your own projects |
456 | 456 | |
457 | So far we have added packages to the default project at `~/.julia/environments/v0.7`, it is, however, easy to create other, independent, projects. | |
457 | So far we have added packages to the default project at `~/.julia/environments/v1.0`, it is, however, easy to create other, independent, projects. | |
458 | 458 | It should be pointed out if two projects uses the same package at the same version, the content of this package is not duplicated. |
459 | 459 | In order to create a new project, create a directory for it and then activate that directory to make it the "active project" which package operations manipulate: |
460 | 460 | |
464 | 464 | shell> cd MyProject |
465 | 465 | /Users/kristoffer/MyProject |
466 | 466 | |
467 | (v0.7) pkg> activate . | |
467 | (v1.0) pkg> activate . | |
468 | 468 | |
469 | 469 | (MyProject) pkg> st |
470 | 470 | Status `Project.toml` |
517 | 517 | This is done with the `gc` command: |
518 | 518 | |
519 | 519 | ``` |
520 | (v0.7) pkg> gc | |
520 | (v1.0) pkg> gc | |
521 | 521 | Active manifests at: |
522 | 522 | `/Users/kristoffer/BinaryProvider/Manifest.toml` |
523 | 523 | ... |
541 | 541 | To generate files for a new package, use `pkg> generate`. |
542 | 542 | |
543 | 543 | ``` |
544 | (v0.7) pkg> generate HelloWorld | |
544 | (v1.0) pkg> generate HelloWorld | |
545 | 545 | ``` |
546 | 546 | |
547 | 547 | This creates a new project `HelloWorld` with the following files (visualized with the external [`tree` command](https://linux.die.net/man/1/tree)): |
730 | 730 | |
731 | 731 | ```toml |
732 | 732 | [compat] |
733 | julia = "1.0" | |
733 | 734 | Example = "0.4.3" |
734 | 735 | ``` |
735 | 736 | |
824 | 825 | Simply clone their project using e.g. `git clone`, `cd` to the project directory and call |
825 | 826 | |
826 | 827 | ``` |
827 | (v0.7) pkg> activate . | |
828 | (v1.0) pkg> activate . | |
828 | 829 | |
829 | 830 | (SomeProject) pkg> instantiate |
830 | 831 | ``` |
28 | 28 | add_or_develop(pkgs::Vector{PackageSpec}; kwargs...) = add_or_develop(Context(), pkgs; kwargs...) |
29 | 29 | |
30 | 30 | function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, shared::Bool=true, kwargs...) |
31 | pkgs = deepcopy(pkgs) # deepcopy for avoid mutating PackageSpec members | |
31 | 32 | Context!(ctx; kwargs...) |
32 | 33 | |
33 | 34 | # All developed packages should go through handle_repos_develop so just give them an empty repo |
47 | 48 | |
48 | 49 | ctx.preview && preview_info() |
49 | 50 | if mode == :develop |
50 | devdir = shared ? Pkg.devdir() : joinpath(dirname(ctx.env.project_file), "dev") | |
51 | new_git = handle_repos_develop!(ctx, pkgs, devdir) | |
51 | new_git = handle_repos_develop!(ctx, pkgs, shared = shared) | |
52 | 52 | else |
53 | 53 | new_git = handle_repos_add!(ctx, pkgs; upgrade_or_add=true) |
54 | 54 | end |
73 | 73 | rm(pkgs::Vector{PackageSpec}; kwargs...) = rm(Context(), pkgs; kwargs...) |
74 | 74 | |
75 | 75 | function rm(ctx::Context, pkgs::Vector{PackageSpec}; mode=PKGMODE_PROJECT, kwargs...) |
76 | for pkg in pkgs | |
77 | #TODO only overwrite pkg.mode is default value ? | |
76 | pkgs = deepcopy(pkgs) # deepcopy for avoid mutating PackageSpec members | |
77 | for pkg in pkgs | |
78 | # TODO only overwrite pkg.mode if default value ? | |
78 | 79 | pkg.mode = mode |
79 | 80 | end |
80 | 81 | |
96 | 97 | else |
97 | 98 | for reg in registries() |
98 | 99 | if isdir(joinpath(reg, ".git")) |
99 | regpath = pathrepr(ctx, reg) | |
100 | regpath = pathrepr(reg) | |
100 | 101 | printpkgstyle(ctx, :Updating, "registry at " * regpath) |
101 | LibGit2.with(LibGit2.GitRepo, reg) do repo | |
102 | # Using LibGit2.with here crashes julia when running the | |
103 | # tests for PkgDev wiht "Unreachable reached". | |
104 | # This seems to work around it. | |
105 | local repo | |
106 | try | |
107 | repo = LibGit2.GitRepo(reg) | |
102 | 108 | if LibGit2.isdirty(repo) |
103 | 109 | push!(errors, (regpath, "registry dirty")) |
104 | return | |
110 | @goto done | |
105 | 111 | end |
106 | 112 | if !LibGit2.isattached(repo) |
107 | 113 | push!(errors, (regpath, "registry detached")) |
108 | return | |
114 | @goto done | |
115 | end | |
116 | if !("origin" in LibGit2.remotes(repo)) | |
117 | push!(errors, (regpath, "origin not in the list of remotes")) | |
118 | @goto done | |
109 | 119 | end |
110 | 120 | branch = LibGit2.headname(repo) |
111 | 121 | try |
113 | 123 | catch e |
114 | 124 | e isa PkgError || rethrow(e) |
115 | 125 | push!(errors, (reg, "failed to fetch from repo")) |
116 | return | |
126 | @goto done | |
117 | 127 | end |
118 | 128 | ff_succeeded = try |
119 | 129 | LibGit2.merge!(repo; branch="refs/remotes/origin/$branch", fastforward=true) |
120 | 130 | catch e |
121 | 131 | e isa LibGit2.GitError && e.code == LibGit2.Error.ENOTFOUND || rethrow(e) |
122 | 132 | push!(errors, (reg, "branch origin/$branch not found")) |
123 | return | |
133 | @goto done | |
124 | 134 | end |
125 | 135 | |
126 | 136 | if !ff_succeeded |
128 | 138 | catch e |
129 | 139 | e isa LibGit2.GitError || rethrow(e) |
130 | 140 | push!(errors, (reg, "registry failed to rebase on origin/$branch")) |
131 | return | |
141 | @goto done | |
132 | 142 | end |
133 | 143 | end |
144 | @label done | |
145 | finally | |
146 | close(repo) | |
134 | 147 | end |
135 | 148 | end |
136 | 149 | end |
154 | 167 | |
155 | 168 | function up(ctx::Context, pkgs::Vector{PackageSpec}; |
156 | 169 | level::UpgradeLevel=UPLEVEL_MAJOR, mode::PackageMode=PKGMODE_PROJECT, do_update_registry=true, kwargs...) |
170 | pkgs = deepcopy(pkgs) # deepcopy for avoid mutating PackageSpec members | |
157 | 171 | for pkg in pkgs |
158 | 172 | # TODO only override if they are not already set |
159 | 173 | pkg.mode = mode |
193 | 207 | pin(pkgs::Vector{PackageSpec}; kwargs...) = pin(Context(), pkgs; kwargs...) |
194 | 208 | |
195 | 209 | function pin(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...) |
210 | pkgs = deepcopy(pkgs) # deepcopy for avoid mutating PackageSpec members | |
196 | 211 | Context!(ctx; kwargs...) |
197 | 212 | ctx.preview && preview_info() |
198 | 213 | project_deps_resolve!(ctx.env, pkgs) |
207 | 222 | free(pkgs::Vector{PackageSpec}; kwargs...) = free(Context(), pkgs; kwargs...) |
208 | 223 | |
209 | 224 | function free(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...) |
225 | pkgs = deepcopy(pkgs) # deepcopy for avoid mutating PackageSpec members | |
210 | 226 | Context!(ctx; kwargs...) |
211 | 227 | ctx.preview && preview_info() |
212 | 228 | registry_resolve!(ctx.env, pkgs) |
238 | 254 | test(pkgs::Vector{PackageSpec}; kwargs...) = test(Context(), pkgs; kwargs...) |
239 | 255 | |
240 | 256 | function test(ctx::Context, pkgs::Vector{PackageSpec}; coverage=false, kwargs...) |
257 | pkgs = deepcopy(pkgs) # deepcopy for avoid mutating PackageSpec members | |
241 | 258 | Context!(ctx; kwargs...) |
242 | 259 | ctx.preview && preview_info() |
243 | 260 | if isempty(pkgs) |
407 | 424 | build(pkg::PackageSpec) = build([pkg]) |
408 | 425 | build(pkgs::Vector{PackageSpec}) = build(Context(), pkgs) |
409 | 426 | function build(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...) |
427 | pkgs = deepcopy(pkgs) # deepcopy for avoid mutating PackageSpec members | |
410 | 428 | Context!(ctx; kwargs...) |
411 | 429 | |
412 | 430 | ctx.preview && preview_info() |
471 | 489 | for pkg in pkgids |
472 | 490 | paths = Base.find_all_in_cache_path(pkg) |
473 | 491 | sourcepath = Base.locate_package(pkg) |
474 | if sourcepath == nothing | |
475 | # XXX: this isn't supposed to be fatal | |
476 | pkgerror("couldn't find path to $(pkg.name) when trying to precompilie project") | |
477 | end | |
492 | sourcepath == nothing && continue | |
493 | # Heuristic for when precompilation is disabled | |
494 | occursin(r"\b__precompile__\(\s*false\s*\)", read(sourcepath, String)) && continue | |
478 | 495 | stale = true |
479 | 496 | for path_to_try in paths::Vector{String} |
480 | 497 | staledeps = Base.stale_cachefile(sourcepath, path_to_try) |
571 | 588 | fullpath = abspath(devpath) |
572 | 589 | else |
573 | 590 | fullpath = abspath(path) |
574 | isdir(fullpath) || @info("new environment will be placed at $fullpath") | |
591 | isdir(fullpath) || @info("activating new environment at $(Base.contractuser(fullpath)).") | |
575 | 592 | end |
576 | 593 | else |
577 | 594 | # initialize `fullpath` in case of empty `Pkg.depots()` |
588 | 605 | # unless the shared environment already exists, place it in the first depots |
589 | 606 | if !isdir(fullpath) |
590 | 607 | fullpath = joinpath(Pkg.envdir(Pkg.depots1()), path) |
591 | @info("new shared environment \"$path\" will be placed at $fullpath") | |
608 | @info("activating new environment at $(Base.contractuser(fullpath)).") | |
592 | 609 | end |
593 | 610 | end |
594 | 611 | Base.ACTIVE_PROJECT[] = Base.load_path_expand(fullpath) |
55 | 55 | m₁ = filter_manifest(in_project(project₁["deps"]), manifest₁) |
56 | 56 | diff = manifest_diff(ctx, m₀, m₁) |
57 | 57 | if !use_as_api |
58 | printpkgstyle(ctx, :Status, pathrepr(ctx, env.project_file), #=ignore_indent=# true) | |
58 | printpkgstyle(ctx, :Status, pathrepr(env.project_file), #=ignore_indent=# true) | |
59 | 59 | print_diff(ctx, diff, #=status=# true) |
60 | 60 | end |
61 | 61 | end |
62 | 62 | if mode == PKGMODE_MANIFEST |
63 | 63 | diff = manifest_diff(ctx, manifest₀, manifest₁) |
64 | 64 | if !use_as_api |
65 | printpkgstyle(ctx, :Status, pathrepr(ctx, env.manifest_file), #=ignore_indent=# true) | |
65 | printpkgstyle(ctx, :Status, pathrepr(env.manifest_file), #=ignore_indent=# true) | |
66 | 66 | print_diff(ctx, diff, #=status=# true) |
67 | 67 | end |
68 | 68 | elseif mode == PKGMODE_COMBINED |
72 | 72 | c_diff = filter!(x->x.old != x.new, manifest_diff(ctx, m₀, m₁)) |
73 | 73 | if !isempty(c_diff) |
74 | 74 | if !use_as_api |
75 | printpkgstyle(ctx, :Status, pathrepr(ctx, env.manifest_file), #=ignore_indent=# true) | |
75 | printpkgstyle(ctx, :Status, pathrepr(env.manifest_file), #=ignore_indent=# true) | |
76 | 76 | print_diff(ctx, c_diff, #=status=# true) |
77 | 77 | end |
78 | 78 | diff = Base.vcat(c_diff, diff) |
115 | 115 | vstring(ctx::Context, a::VerInfo) = |
116 | 116 | string((a.ver == nothing && a.hash != nothing) ? "[$(string(a.hash)[1:16])]" : "", |
117 | 117 | a.ver != nothing ? "v$(a.ver)" : "", |
118 | a.path != nothing ? " [$(pathrepr(ctx, a.path))]" : "", | |
118 | a.path != nothing ? " [$(pathrepr(a.path))]" : "", | |
119 | 119 | a.repo != nothing ? " #$(revstring(a.repo.rev)) ($(a.repo.url))" : "", |
120 | 120 | a.pinned == true ? " ⚲" : "", |
121 | 121 | ) |
74 | 74 | # TODO: extend this to more urls |
75 | 75 | function normalize_url(url::AbstractString) |
76 | 76 | m = match(GITHUB_REGEX, url) |
77 | (m === nothing || GIT_PROTOCOL[] === nothing) ? | |
78 | url : "$(GIT_PROTOCOL[])://github.com/$(m.captures[1]).git" | |
77 | if m === nothing || GIT_PROTOCOL[] === nothing | |
78 | url | |
79 | elseif GIT_PROTOCOL[] == "ssh" | |
80 | "ssh://git@github.com/$(m.captures[1]).git" | |
81 | else | |
82 | "$(GIT_PROTOCOL[])://github.com/$(m.captures[1]).git" | |
83 | end | |
79 | 84 | end |
80 | 85 | |
81 | 86 | function clone(url, source_path; header=nothing, kwargs...) |
97 | 97 | path = pkg.path |
98 | 98 | elseif info !== nothing && haskey(info, "repo-url") |
99 | 99 | path = find_installed(pkg.name, pkg.uuid, SHA1(info["git-tree-sha1"])) |
100 | pkg.version = VersionNumber(info["version"]) | |
101 | 100 | pkg.repo = Types.GitRepo(info["repo-url"], info["repo-rev"], SHA1(info["git-tree-sha1"])) |
102 | 101 | else |
103 | 102 | continue |
309 | 308 | uuid_to_name[uuid] = name |
310 | 309 | |
311 | 310 | uuid_idx = findfirst(isequal(uuid), uuids) |
312 | ver = VersionSpec() | |
311 | info = manifest_info(ctx.env, uuid) | |
312 | if info !== nothing && haskey(info, "version") # stdlibs might not have a version | |
313 | ver = VersionSpec(VersionNumber(info["version"])) | |
314 | else | |
315 | ver = VersionSpec() | |
316 | end | |
313 | 317 | if uuid_idx != nothing |
314 | 318 | pkg = pkgs[uuid_idx] |
315 | info = manifest_info(ctx.env, uuid) | |
316 | if info !== nothing && haskey(info, "version") # stdlibs might not have a version | |
317 | ver = VersionNumber(info["version"]) | |
318 | if pkg.special_action != PKGSPEC_FREED && get(info, "pinned", false) | |
319 | # This is a pinned package, fix its version | |
320 | pkg.version = ver | |
321 | end | |
319 | if info !== nothing && pkg.special_action != PKGSPEC_FREED && get(info, "pinned", false) | |
320 | # This is a pinned package, fix its version | |
321 | pkg.version = ver | |
322 | 322 | end |
323 | 323 | else |
324 | 324 | pkg = PackageSpec(name, uuid, ver) |
325 | 325 | push!(pkgs, pkg) |
326 | 326 | end |
327 | proj_compat = Types.project_compatibility(ctx, name) | |
328 | v = intersect(pkg.version, proj_compat) | |
329 | if isempty(v) | |
330 | pkgerror(string("for package $(pkg.name) intersection between project compatibility $(proj_compat) ", | |
331 | "and package version $(pkg.version) is empty")) | |
332 | end | |
333 | pkg.version = v | |
334 | end | |
327 | end | |
328 | ||
329 | # construct data structures for resolver and call it | |
330 | # this also sets pkg.version for fixed packages | |
331 | fixed = collect_fixed!(ctx, pkgs, uuid_to_name) | |
332 | ||
333 | # compatibility | |
335 | 334 | proj_compat = Types.project_compatibility(ctx, "julia") |
336 | 335 | v = intersect(VERSION, proj_compat) |
337 | 336 | if isempty(v) |
338 | @warn("julia version requirement for project not satisfied") | |
339 | end | |
340 | ||
341 | # construct data structures for resolver and call it | |
337 | @warn "julia version requirement for project not satisfied" _module=nothing _file=nothing | |
338 | end | |
339 | ||
340 | for pkg in pkgs | |
341 | proj_compat = Types.project_compatibility(ctx, pkg.name) | |
342 | v = intersect(pkg.version, proj_compat) | |
343 | if isempty(v) | |
344 | pkgerror(string("empty intersection between $(pkg.name)@$(pkg.version) and project ", | |
345 | "compatibility $(proj_compat)")) | |
346 | end | |
347 | # Work around not clobbering 0.x.y+ for checked out old type of packages | |
348 | if !(pkg.version isa VersionNumber) | |
349 | pkg.version = v | |
350 | end | |
351 | end | |
352 | ||
342 | 353 | reqs = Requires(pkg.uuid => VersionSpec(pkg.version) for pkg in pkgs if pkg.uuid ≠ uuid_julia) |
343 | fixed = collect_fixed!(ctx, pkgs, uuid_to_name) | |
344 | 354 | fixed[uuid_julia] = Fixed(VERSION) |
345 | 355 | graph = deps_graph(ctx, uuid_to_name, reqs, fixed) |
346 | 356 | |
646 | 656 | return stdlib_deps |
647 | 657 | end |
648 | 658 | |
649 | function relative_project_path_if_in_project(ctx::Context, path::String) | |
650 | # Check if path is in project => relative | |
651 | project_path = dirname(ctx.env.project_file) | |
652 | if startswith(normpath(path), project_path) | |
653 | return relpath(path, project_path) | |
654 | else | |
655 | return abspath(path) | |
656 | end | |
657 | end | |
658 | ||
659 | project_rel_path(ctx::Context, path::String) = joinpath(dirname(ctx.env.project_file), path) | |
659 | project_rel_path(ctx::Context, path::String) = | |
660 | normpath(joinpath(dirname(ctx.env.project_file), path)) | |
660 | 661 | |
661 | 662 | function update_manifest(ctx::Context, pkg::PackageSpec, hash::Union{SHA1, Nothing}) |
662 | 663 | env = ctx.env |
1036 | 1037 | for (uuid, name, hash_or_path, build_file, version) in builds |
1037 | 1038 | log_file = splitext(build_file)[1] * ".log" |
1038 | 1039 | printpkgstyle(ctx, :Building, |
1039 | rpad(name * " ", max_name + 1, "─") * "→ " * Types.pathrepr(ctx, log_file)) | |
1040 | rpad(name * " ", max_name + 1, "─") * "→ " * Types.pathrepr(log_file)) | |
1040 | 1041 | code = """ |
1041 | 1042 | $(Base.load_path_setup_code(false)) |
1042 | 1043 | cd($(repr(dirname(build_file)))) |
1044 | 1045 | """ |
1045 | 1046 | cmd = ``` |
1046 | 1047 | $(Base.julia_cmd()) -O0 --color=no --history-file=no |
1047 | --startup-file=$(Base.JLOptions().startupfile != 2 ? "yes" : "no") | |
1048 | --startup-file=$(Base.JLOptions().startupfile == 1 ? "yes" : "no") | |
1048 | 1049 | --compiled-modules=$(Bool(Base.JLOptions().use_compiled_modules) ? "yes" : "no") |
1049 | 1050 | --eval $code |
1050 | 1051 | ``` |
73 | 73 | |
74 | 74 | # Define new variables so tab comleting Pkg. works. |
75 | 75 | """ |
76 | Pkg.add(pkg::Union{String, Vector{String}) | |
76 | Pkg.add(pkg::Union{String, Vector{String}}) | |
77 | 77 | Pkg.add(pkg::Union{PackageSpec, Vector{PackageSpec}}) |
78 | 78 | |
79 | 79 | Add a package to the current project. This package will be available using the |
93 | 93 | const add = API.add |
94 | 94 | |
95 | 95 | """ |
96 | Pkg.rm(pkg::Union{String, Vector{String}) | |
96 | Pkg.rm(pkg::Union{String, Vector{String}}) | |
97 | 97 | Pkg.rm(pkg::Union{PackageSpec, Vector{PackageSpec}}) |
98 | 98 | |
99 | 99 | Remove a package from the current project. If the `mode` of `pkg` is |
106 | 106 | |
107 | 107 | """ |
108 | 108 | Pkg.update(; level::UpgradeLevel=UPLEVEL_MAJOR, mode::PackageMode = PKGMODE_PROJECT) |
109 | Pkg.update(pkg::Union{String, Vector{String}) | |
109 | Pkg.update(pkg::Union{String, Vector{String}}) | |
110 | 110 | Pkg.update(pkg::Union{PackageSpec, Vector{PackageSpec}}) |
111 | 111 | |
112 | 112 | Update a package `pkg`. If no posistional argument is given, update all packages in the manifest if `mode` is `PKGMODE_MANIFEST` and packages in both manifest and project if `mode` is `PKGMODE_PROJECT`. |
161 | 161 | |
162 | 162 | """ |
163 | 163 | Pkg.build() |
164 | Pkg.build(pkg::Union{String, Vector{String}) | |
164 | Pkg.build(pkg::Union{String, Vector{String}}) | |
165 | 165 | Pkg.build(pkgs::Union{PackageSpec, Vector{PackageSpec}}) |
166 | 166 | |
167 | 167 | Run the build script in `deps/build.jl` for `pkg` and all of the dependencies in |
177 | 177 | const installed = API.installed |
178 | 178 | |
179 | 179 | """ |
180 | Pkg.pin(pkg::Union{String, Vector{String}) | |
180 | Pkg.pin(pkg::Union{String, Vector{String}}) | |
181 | 181 | Pkg.pin(pkgs::Union{Packagespec, Vector{Packagespec}}) |
182 | 182 | |
183 | 183 | Pin a package to the current version (or the one given in the `packagespec` or a certain |
186 | 186 | const pin = API.pin |
187 | 187 | |
188 | 188 | """ |
189 | Pkg.free(pkg::Union{String, Vector{String}) | |
189 | Pkg.free(pkg::Union{String, Vector{String}}) | |
190 | 190 | Pkg.free(pkgs::Union{Packagespec, Vector{Packagespec}}) |
191 | 191 | |
192 | 192 | Free a package which removes a `pin` if it exists, or if the package is tracking a path, |
202 | 202 | |
203 | 203 | |
204 | 204 | """ |
205 | Pkg.develop(pkg::Union{String, Vector{String}) | |
205 | Pkg.develop(pkg::Union{String, Vector{String}}) | |
206 | 206 | Pkg.develop(pkgs::Union{Packagespec, Vector{Packagespec}}) |
207 | 207 | |
208 | 208 | Make a package available for development by tracking it by path. |
218 | 218 | Pkg.develop("Example") |
219 | 219 | |
220 | 220 | # By url |
221 | Pkg.develop(PackageSpec(url="https://github.com/JuliaLang/Compat.jl", rev="master")) | |
222 | ||
223 | # By path (also uses url keyword to PackageSpec) | |
224 | Pkg.develop(PackageSpec(url="MyJuliaPackages/Package.jl") | |
221 | Pkg.develop(PackageSpec(url="https://github.com/JuliaLang/Compat.jl")) | |
222 | ||
223 | # By path | |
224 | Pkg.develop(PackageSpec(path="MyJuliaPackages/Package.jl") | |
225 | 225 | ``` |
226 | 226 | |
227 | 227 | See also [`PackageSpec`](@ref) |
269 | 269 | The logic for what path is activated is as follows: |
270 | 270 | |
271 | 271 | * If `shared` is `true`, the first existing environment named `s` from the depots |
272 | in the depot stack will be activated. If no such environment exists yet, | |
273 | activate it in the first depot. | |
274 | * If `s` is a path that exist, that environment will be activated. | |
275 | * If `s` is a package name in the current project activate that is tracking a path, | |
276 | activate the environment at that path. | |
277 | * If `s` is a non-existing path, activate that path. | |
278 | ||
279 | If no argument is given to `activate`, activate the home project, | |
280 | which is the one specified by either `--project` command line when starting julia, | |
281 | or `JULIA_PROJECT` environment variable. | |
272 | in the depot stack will be activated. If no such environment exists, | |
273 | create and activate that environment in the first depot. | |
274 | * If `s` is an existing path, then activate the environment at that path. | |
275 | * If `s` is a package in the current project and `s` is tracking a path, then | |
276 | activate the environment at the tracked path. | |
277 | * Else, `s` is interpreted as a non-existing path, activate that path. | |
278 | ||
279 | If no argument is given to `activate`, then activate the home project. | |
280 | The home project is specified by either the `--project` command line option to | |
281 | the julia executable, or the `JULIA_PROJECT` environment variable. | |
282 | 282 | |
283 | 283 | # Examples |
284 | 284 | ``` |
367 | 367 | ] activate . |
368 | 368 | $CTRL_C |
369 | 369 | Pkg.add("Test") # adding an stdlib doesn't require internet access |
370 | ] add Te\t\t$CTRL_C | |
370 | 371 | ] st |
371 | 372 | $CTRL_C |
372 | 373 | rm(tmp; recursive=true)""" |
373 | 374 | |
374 | module PrecompileArea | |
375 | import ..Pkg | |
376 | using ..Types | |
377 | using UUIDs | |
378 | import LibGit2 | |
379 | import REPL | |
380 | import SHA | |
381 | include("precompile.jl") | |
382 | end | |
383 | ||
384 | 375 | end # module |
198 | 198 | [System.Net.ServicePointManager]::SecurityProtocol = |
199 | 199 | [System.Net.SecurityProtocolType]::Tls12; |
200 | 200 | \$webclient = (New-Object System.Net.Webclient); |
201 | \$webclient.UseDefaultCredentials = \$true; | |
202 | \$webclient.Proxy.Credentials = \$webclient.Credentials; | |
201 | 203 | \$webclient.Headers.Add("user-agent", \"Pkg.jl (https://github.com/JuliaLang/Pkg.jl)\"); |
202 | 204 | \$webclient.DownloadFile(\"$url\", \"$path\") |
203 | 205 | """ |
81 | 81 | end |
82 | 82 | |
83 | 83 | meta_option_declarations = OptionDeclaration[ |
84 | ("env", OPT_ARG, :env => arg->EnvCache(Base.parse_env(arg))) | |
84 | ("preview", OPT_SWITCH, :preview => true) | |
85 | 85 | ] |
86 | 86 | meta_option_specs = OptionSpecs(meta_option_declarations) |
87 | 87 | |
96 | 96 | ) |
97 | 97 | @enum(ArgClass, ARG_RAW, ARG_PKG, ARG_VERSION, ARG_REV, ARG_ALL) |
98 | 98 | struct ArgSpec |
99 | class::ArgClass | |
100 | count::Vector{Int} | |
99 | count::Pair | |
100 | parser::Function | |
101 | parser_keys::Vector{Pair{Symbol, Any}} | |
101 | 102 | end |
102 | 103 | const CommandDeclaration = Tuple{CommandKind, |
103 | 104 | Vector{String}, # names |
104 | 105 | Union{Nothing,Function}, # handler |
105 | Tuple{ArgClass, Vector{Int}}, # argument count | |
106 | Tuple{Pair, # count | |
107 | Function, # parser | |
108 | Vector{Pair{Symbol, Any}}, # parser keys | |
109 | }, # arguments | |
106 | 110 | Vector{OptionDeclaration}, # options |
111 | String, #description | |
107 | 112 | Union{Nothing, Markdown.MD}, #help |
108 | 113 | } |
109 | 114 | struct CommandSpec |
110 | 115 | kind::CommandKind |
111 | names::Vector{String} | |
116 | canonical_name::String | |
117 | short_name::Union{Nothing,String} | |
112 | 118 | handler::Union{Nothing,Function} |
113 | argument_spec::ArgSpec # note: just use range operator for max/min | |
119 | argument_spec::ArgSpec | |
114 | 120 | option_specs::Dict{String, OptionSpec} |
121 | description::String | |
115 | 122 | help::Union{Nothing, Markdown.MD} |
116 | 123 | end |
117 | 124 | command_specs = Dict{String,CommandSpec}() # TODO remove this ? |
134 | 141 | for dec in declarations |
135 | 142 | names = dec[2] |
136 | 143 | spec = CommandSpec(dec[1], |
137 | names, | |
144 | names[1], | |
145 | length(names) == 2 ? names[2] : nothing, | |
138 | 146 | dec[3], |
139 | 147 | ArgSpec(dec[4]...), |
140 | 148 | OptionSpecs(dec[5]), |
149 | dec[6], | |
141 | 150 | dec[end]) |
142 | 151 | for name in names |
143 | 152 | # TODO regex check name |
195 | 204 | isquoted::Bool |
196 | 205 | end |
197 | 206 | |
198 | function parse(cmd::String)::Vector{Statement} | |
207 | function unwrap_option(option::String) | |
208 | if startswith(option, "--") | |
209 | return length(option) == 2 ? "" : option[3:end] | |
210 | elseif length(option) == 2 | |
211 | return option[end] | |
212 | end | |
213 | end | |
214 | ||
215 | wrap_option(option::String) = | |
216 | length(option) == 1 ? "-$option" : "--$option" | |
217 | ||
218 | function _statement(words) | |
219 | is_option(word) = first(word) == '-' | |
220 | ||
221 | word = popfirst!(words) | |
222 | # meta options | |
223 | while is_option(word) | |
224 | if isempty(words) | |
225 | if unwrap_option(word) in keys(meta_option_specs) | |
226 | return :cmd, "", nothing, true | |
227 | else | |
228 | return :meta, word, nothing, true | |
229 | end | |
230 | end | |
231 | word = popfirst!(words) | |
232 | end | |
233 | # command | |
234 | if word == "preview" | |
235 | if isempty(words) | |
236 | return :cmd, "", nothing, true | |
237 | end | |
238 | word = popfirst!(words) | |
239 | end | |
240 | if word in keys(super_specs) # have a super command | |
241 | super_name = word | |
242 | super = super_specs[word] | |
243 | if isempty(words) | |
244 | return :sub, "", super_name, true | |
245 | end | |
246 | word = popfirst!(words) | |
247 | command = get(super, word, nothing) | |
248 | if command === nothing | |
249 | if isempty(words) | |
250 | return :sub, word, super_name, true | |
251 | else | |
252 | return nothing | |
253 | end | |
254 | end | |
255 | elseif get(super_specs["package"], word, nothing) !== nothing # given a "package" command | |
256 | command = get(super_specs["package"], word, nothing) | |
257 | elseif isempty(words) # try to complete the super command | |
258 | return :cmd, word, nothing, true | |
259 | else | |
260 | return nothing | |
261 | end | |
262 | if isempty(words) | |
263 | return :arg, "", command, true | |
264 | end | |
265 | word = words[end] | |
266 | manifest = any(x->x in ["--manifest", "-m"], filter(is_option, words)) | |
267 | return is_option(word) ? | |
268 | (:opt, word, command, true) : | |
269 | (:arg, word, command, !manifest) | |
270 | end | |
271 | ||
272 | function parse(cmd::String; for_completions=false) | |
199 | 273 | # replace new lines with ; to support multiline commands |
200 | 274 | cmd = replace(replace(cmd, "\r\n" => "; "), "\n" => "; ") |
201 | 275 | # tokenize accoring to whitespace / quotes |
205 | 279 | # break up words according to ";"(doing this early makes subsequent processing easier) |
206 | 280 | word_groups = group_words(words) |
207 | 281 | # create statements |
208 | statements = map(Statement, word_groups) | |
209 | return statements | |
282 | if for_completions | |
283 | return _statement(word_groups[end]) | |
284 | end | |
285 | return map(Statement, word_groups) | |
210 | 286 | end |
211 | 287 | |
212 | 288 | # vector of words -> structured statement |
223 | 299 | word = popfirst!(words) |
224 | 300 | end |
225 | 301 | # command |
302 | # special handling for `preview`, just convert it to a meta option under the hood | |
303 | if word == "preview" | |
304 | if !("--preview" in statement.meta_options) | |
305 | push!(statement.meta_options, "--preview") | |
306 | end | |
307 | isempty(words) && pkgerror("preview requires a command") | |
308 | word = popfirst!(words) | |
309 | end | |
226 | 310 | if word in keys(super_specs) |
227 | 311 | super = super_specs[word] |
312 | isempty(words) && pkgerror("no subcommand specified") | |
228 | 313 | word = popfirst!(words) |
229 | 314 | else |
230 | 315 | super = super_specs["package"] |
314 | 399 | # PkgCommand # |
315 | 400 | ############## |
316 | 401 | const Token = Union{String, VersionRange, Rev} |
402 | const ArgToken = Union{VersionRange, Rev} | |
403 | const PkgToken = Union{String, VersionRange, Rev} | |
317 | 404 | const PkgArguments = Union{Vector{String}, Vector{PackageSpec}} |
318 | 405 | struct PkgCommand |
319 | 406 | meta_options::Vector{Option} |
343 | 430 | return Dict(keyword_vec) |
344 | 431 | end |
345 | 432 | |
346 | function enforce_argument_order(args::Vector{Token}) | |
347 | prev_arg = nothing | |
348 | function check_prev_arg(valid_type::DataType, error_message::AbstractString) | |
349 | prev_arg isa valid_type || pkgerror(error_message) | |
350 | end | |
351 | ||
352 | for arg in args | |
353 | if arg isa VersionRange | |
354 | check_prev_arg(String, "package name/uuid must precede version spec `@$arg`") | |
355 | elseif arg isa Rev | |
356 | check_prev_arg(String, "package name/uuid must precede rev spec `#$(arg.rev)`") | |
357 | end | |
358 | prev_arg = arg | |
359 | end | |
360 | end | |
361 | ||
362 | function word2token(word::AbstractString)::Token | |
363 | if first(word) == '@' | |
364 | return VersionRange(word[2:end]) | |
365 | elseif first(word) == '#' | |
366 | return Rev(word[2:end]) | |
367 | else | |
368 | return String(word) | |
369 | end | |
370 | end | |
371 | ||
372 | function enforce_arg_spec(raw_args::Vector{String}, class::ArgClass) | |
373 | # TODO is there a more idiomatic way to do this? | |
374 | function has_types(arguments::Vector{Token}, types::Vector{DataType}) | |
375 | return !isempty(filter(x->typeof(x) in types, arguments)) | |
376 | end | |
377 | ||
378 | class == ARG_RAW && return raw_args | |
379 | args::Vector{Token} = map(word2token, raw_args) | |
380 | class == ARG_ALL && return args | |
381 | ||
382 | if class == ARG_PKG && has_types(args, [VersionRange, Rev]) | |
383 | pkgerror("no versioned packages allowed") | |
384 | elseif class == ARG_REV && has_types(args, [VersionRange]) | |
385 | pkgerror("no versioned packages allowed") | |
386 | elseif class == ARG_VERSION && has_types(args, [Rev]) | |
387 | pkgerror("no reved packages allowed") | |
388 | end | |
389 | return args | |
390 | end | |
391 | ||
392 | function package_args(args::Vector{Token}, spec::CommandSpec)::Vector{PackageSpec} | |
433 | function enforce_argument_count(spec::Pair, args::PkgArguments) | |
434 | count = length(args) | |
435 | spec.first <= count <= spec.second || | |
436 | pkgerror("Wrong number of arguments") | |
437 | end | |
438 | ||
439 | # Only for PkgSpec | |
440 | function package_args(args::Vector{Token}; add_or_dev=false)::Vector{PackageSpec} | |
393 | 441 | pkgs = PackageSpec[] |
394 | 442 | for arg in args |
395 | 443 | if arg isa String |
396 | is_add_or_develop = spec.kind in (CMD_ADD, CMD_DEVELOP) | |
397 | push!(pkgs, parse_package(arg; add_or_develop=is_add_or_develop)) | |
444 | push!(pkgs, parse_package(arg; add_or_develop=add_or_dev)) | |
398 | 445 | elseif arg isa VersionRange |
399 | 446 | pkgs[end].version = VersionSpec(arg) |
400 | 447 | elseif arg isa Rev |
401 | if spec.kind == CMD_DEVELOP | |
402 | pkgerror("a git revision cannot be given to `develop`") | |
403 | end | |
404 | 448 | pkg = pkgs[end] |
405 | 449 | if pkg.repo == nothing |
406 | 450 | pkg.repo = Types.GitRepo("", arg.rev) |
414 | 458 | return pkgs |
415 | 459 | end |
416 | 460 | |
417 | function enforce_arg_count(count::Vector{Int}, args::PkgArguments) | |
418 | isempty(count) && return | |
419 | length(args) in count || | |
420 | pkgerror("Wrong number of arguments") | |
421 | end | |
422 | ||
423 | function enforce_args(raw_args::Vector{String}, spec::ArgSpec, cmd_spec::CommandSpec)::PkgArguments | |
424 | if spec.class == ARG_RAW | |
425 | enforce_arg_count(spec.count, raw_args) | |
426 | return raw_args | |
427 | end | |
428 | ||
429 | args = enforce_arg_spec(raw_args, spec.class) | |
461 | # Only for PkgSpec | |
462 | function word2token(word::AbstractString)::Token | |
463 | if first(word) == '@' | |
464 | return VersionRange(word[2:end]) | |
465 | elseif first(word) == '#' | |
466 | return Rev(word[2:end]) | |
467 | else | |
468 | return String(word) | |
469 | end | |
470 | end | |
471 | ||
472 | # Only for PkgSpec | |
473 | function enforce_argument_order(args::Vector{Token}) | |
474 | prev_arg = nothing | |
475 | function check_prev_arg(valid_type::DataType, error_message::AbstractString) | |
476 | prev_arg isa valid_type || pkgerror(error_message) | |
477 | end | |
478 | ||
479 | for arg in args | |
480 | if arg isa VersionRange | |
481 | check_prev_arg(String, "package name/uuid must precede version spec `@$arg`") | |
482 | elseif arg isa Rev | |
483 | check_prev_arg(String, "package name/uuid must precede rev spec `#$(arg.rev)`") | |
484 | end | |
485 | prev_arg = arg | |
486 | end | |
487 | end | |
488 | ||
489 | function parse_pkg(raw_args::Vector{String}; valid=[], add_or_dev=false) | |
490 | args::Vector{PkgToken} = map(word2token, raw_args) | |
430 | 491 | enforce_argument_order(args) |
431 | pkgs = package_args(args, cmd_spec) | |
432 | enforce_arg_count(spec.count, pkgs) | |
433 | return pkgs | |
492 | # enforce spec | |
493 | push!(valid, String) # always want at least PkgSpec identifiers | |
494 | if !all(x->typeof(x) in valid, args) | |
495 | pkgerror("invalid token") | |
496 | end | |
497 | # convert to final arguments | |
498 | return package_args(args; add_or_dev=add_or_dev) | |
499 | end | |
500 | ||
501 | function enforce_argument(raw_args::Vector{String}, spec::ArgSpec)::PkgArguments | |
502 | args = spec.parser(raw_args; spec.parser_keys...) | |
503 | enforce_argument_count(spec.count, args) | |
504 | return args | |
434 | 505 | end |
435 | 506 | |
436 | 507 | function enforce_option(option::String, specs::Dict{String,OptionSpec})::Option |
486 | 557 | function PkgCommand(statement::Statement)::PkgCommand |
487 | 558 | meta_opts = enforce_meta_options(statement.meta_options, |
488 | 559 | meta_option_specs) |
489 | args = enforce_args(statement.arguments, | |
490 | statement.command.argument_spec, | |
491 | statement.command) | |
560 | args = enforce_argument(statement.arguments, | |
561 | statement.command.argument_spec) | |
492 | 562 | opts = enforce_opts(statement.options, statement.command.option_specs) |
493 | 563 | return PkgCommand(meta_opts, statement.command, opts, args) |
494 | 564 | end |
519 | 589 | |
520 | 590 | function do_cmd!(command::PkgCommand, repl) |
521 | 591 | context = APIOptions(command.meta_options, meta_option_specs) |
522 | spec = command.spec | |
523 | 592 | |
524 | 593 | # REPL specific commands |
525 | if spec.kind == CMD_HELP | |
594 | if command.spec.kind == CMD_HELP | |
526 | 595 | return Base.invokelatest(do_help!, command, repl) |
527 | elseif spec.kind == CMD_PREVIEW | |
528 | context[:preview] = true | |
529 | cmd = command.arguments[1] | |
530 | cmd_spec = get(command_specs, cmd, nothing) | |
531 | cmd_spec === nothing && | |
532 | pkgerror("'$cmd' is not a valid command") | |
533 | spec = cmd_spec | |
534 | command = PkgCommand([], cmd, [], PackageSpec[]) | |
535 | 596 | end |
536 | 597 | |
537 | 598 | # API commands |
538 | 599 | # TODO is invokelatest still needed? |
539 | 600 | api_opts = APIOptions(command) |
540 | if applicable(spec.handler, context, command.arguments, api_opts) | |
541 | Base.invokelatest(spec.handler, context, command.arguments, api_opts) | |
601 | if applicable(command.spec.handler, context, command.arguments, api_opts) | |
602 | Base.invokelatest(command.spec.handler, context, command.arguments, api_opts) | |
542 | 603 | else |
543 | Base.invokelatest(spec.handler, command.arguments, api_opts) | |
544 | end | |
604 | Base.invokelatest(command.spec.handler, command.arguments, api_opts) | |
605 | end | |
606 | end | |
607 | ||
608 | function CommandSpec(command_name::String)::Union{Nothing,CommandSpec} | |
609 | # maybe a "package" command | |
610 | spec = get(super_specs["package"], command_name, nothing) | |
611 | if spec !== nothing | |
612 | return spec | |
613 | end | |
614 | # maybe a "compound command" | |
615 | m = match(r"(\w+)-(\w+)", command_name) | |
616 | m !== nothing || (return nothing) | |
617 | super = get(super_specs, m.captures[1], nothing) | |
618 | super !== nothing || (return nothing) | |
619 | return get(super, m.captures[2], nothing) | |
545 | 620 | end |
546 | 621 | |
547 | 622 | function do_help!(command::PkgCommand, repl::REPL.AbstractREPL) |
552 | 627 | end |
553 | 628 | help_md = md"" |
554 | 629 | for arg in command.arguments |
555 | spec = get(command_specs, arg, nothing) | |
556 | spec === nothing && | |
630 | spec = CommandSpec(arg) | |
631 | if spec === nothing | |
557 | 632 | pkgerror("'$arg' does not name a command") |
633 | end | |
558 | 634 | spec.help === nothing && |
559 | 635 | pkgerror("Sorry, I don't have any help for the `$arg` command.") |
560 | 636 | isempty(help_md.content) || |
665 | 741 | pkgstr(str::String) = do_cmd(minirepl[], str; do_rethrow=true) |
666 | 742 | |
667 | 743 | # handle completions |
668 | all_commands_sorted = [] | |
669 | long_commands = [] | |
670 | all_options_sorted = [] | |
671 | long_options = [] | |
744 | mutable struct CompletionCache | |
745 | commands::Vector{String} | |
746 | canonical_names::Vector{String} | |
747 | meta_options::Vector{String} | |
748 | options::Dict{CommandKind, Vector{String}} | |
749 | subcommands::Dict{String, Vector{String}} | |
750 | CompletionCache() = new([],[],[],Dict(),Dict()) | |
751 | end | |
752 | ||
753 | completion_cache = CompletionCache() | |
672 | 754 | |
673 | 755 | struct PkgCompletionProvider <: LineEdit.CompletionProvider end |
674 | 756 | |
679 | 761 | return ret, partial[range], should_complete |
680 | 762 | end |
681 | 763 | |
682 | function complete_command(s, i1, i2) | |
683 | # only show short form commands when no input is given at all | |
684 | cmp = filter(cmd -> startswith(cmd, s), isempty(s) ? all_commands_sorted : long_commands) | |
685 | return cmp, i1:i2, !isempty(cmp) | |
686 | end | |
687 | ||
688 | function complete_option(s, i1, i2) | |
689 | # only show short form options if only a dash is given | |
690 | cmp = filter(cmd -> startswith(cmd, s), length(s) == 1 && first(s) == '-' ? | |
691 | all_options_sorted : | |
692 | long_options) | |
693 | return cmp, i1:i2, !isempty(cmp) | |
694 | end | |
695 | ||
696 | function complete_package(s, i1, i2, lastcommand, project_opt) | |
697 | if lastcommand in [CMD_STATUS, CMD_RM, CMD_UP, CMD_TEST, CMD_BUILD, CMD_FREE, CMD_PIN] | |
698 | return complete_installed_package(s, i1, i2, project_opt) | |
699 | elseif lastcommand in [CMD_ADD, CMD_DEVELOP] | |
700 | return complete_remote_package(s, i1, i2) | |
701 | end | |
702 | return String[], 0:-1, false | |
764 | function complete_local_path(s, i1, i2) | |
765 | cmp = REPL.REPLCompletions.complete_path(s, i2) | |
766 | completions = filter!(isdir, [REPL.REPLCompletions.completion_text(p) for p in cmp[1]]) | |
767 | return completions, cmp[2], !isempty(completions) | |
703 | 768 | end |
704 | 769 | |
705 | 770 | function complete_installed_package(s, i1, i2, project_opt) |
736 | 801 | return cmp, i1:i2, !isempty(cmp) |
737 | 802 | end |
738 | 803 | |
739 | function completions(full, index) | |
804 | function complete_argument(to_complete, i1, i2, lastcommand, project_opt | |
805 | )::Tuple{Vector{String},UnitRange{Int},Bool} | |
806 | if lastcommand == CMD_HELP | |
807 | completions = filter(x->startswith(x,to_complete), completion_cache.canonical_names) | |
808 | return completions, i1:i2, !isempty(completions) | |
809 | elseif lastcommand in [CMD_STATUS, CMD_RM, CMD_UP, CMD_TEST, CMD_BUILD, CMD_FREE, CMD_PIN] | |
810 | return complete_installed_package(to_complete, i1, i2, project_opt) | |
811 | elseif lastcommand in [CMD_ADD, CMD_DEVELOP] | |
812 | if occursin(Base.Filesystem.path_separator_re, to_complete) | |
813 | return complete_local_path(to_complete, i1, i2) | |
814 | else | |
815 | rps = complete_remote_package(to_complete, i1, i2) | |
816 | lps = complete_local_path(to_complete, i1, i2) | |
817 | return vcat(rps[1], lps[1]), isempty(rps[1]) ? lps[2] : i1:i2, length(rps[1]) + length(lps[1]) > 0 | |
818 | end | |
819 | end | |
820 | return String[], 0:-1, false | |
821 | end | |
822 | ||
823 | function completions(full, index)::Tuple{Vector{String},UnitRange{Int},Bool} | |
740 | 824 | pre = full[1:index] |
741 | ||
742 | pre_words = split(pre, ' ', keepempty=true) | |
743 | ||
744 | # first word should always be a command | |
745 | if isempty(pre_words) | |
746 | return complete_command("", 1:1) | |
747 | else | |
748 | to_complete = pre_words[end] | |
749 | offset = isempty(to_complete) ? index+1 : to_complete.offset+1 | |
750 | ||
751 | if length(pre_words) == 1 | |
752 | return complete_command(to_complete, offset, index) | |
753 | end | |
754 | ||
755 | # tokenize input, don't offer any completions for invalid commands | |
756 | statement = try | |
757 | parse(join(pre_words[1:end-1], ' '))[end] | |
758 | catch | |
759 | return String[], 0:-1, false | |
760 | end | |
761 | ||
762 | lastcommand = statement.command.kind | |
763 | project_opt = true | |
764 | for opt in statement.options | |
765 | if opt in ["--manifest", "--project", "-m", "-p"] | |
766 | project_opt = opt in ["--project", "-p"] | |
767 | break | |
768 | end | |
769 | end | |
770 | ||
771 | if lastcommand in [CMD_HELP, CMD_PREVIEW] | |
772 | return complete_command(to_complete, offset, index) | |
773 | elseif !isempty(to_complete) && first(to_complete) == '-' | |
774 | return complete_option(to_complete, offset, index) | |
775 | else | |
776 | return complete_package(to_complete, offset, index, lastcommand, project_opt) | |
777 | end | |
778 | end | |
825 | if isempty(pre) | |
826 | return completion_cache.commands, 0:-1, false | |
827 | end | |
828 | x = parse(pre; for_completions=true) | |
829 | if x === nothing # failed parse (invalid command name) | |
830 | return String[], 0:-1, false | |
831 | end | |
832 | (key::Symbol, to_complete::String, spec, proj::Bool) = x | |
833 | last = split(pre, ' ', keepempty=true)[end] | |
834 | offset = isempty(last) ? index+1 : last.offset+1 | |
835 | if last != to_complete # require a space before completing next field | |
836 | return String[], 0:-1, false | |
837 | end | |
838 | if key == :arg | |
839 | return complete_argument(to_complete, offset, index, spec.kind, proj) | |
840 | end | |
841 | possible::Vector{String} = | |
842 | key == :meta ? completion_cache.meta_options : | |
843 | key == :cmd ? completion_cache.commands : | |
844 | key == :sub ? completion_cache.subcommands[spec] : | |
845 | key == :opt ? completion_cache.options[spec.kind] : | |
846 | String[] | |
847 | completions = filter(x->startswith(x,to_complete), possible) | |
848 | return completions, offset:index, !isempty(completions) | |
779 | 849 | end |
780 | 850 | |
781 | 851 | prev_project_file = nothing |
899 | 969 | # SPEC # |
900 | 970 | ######## |
901 | 971 | command_declarations = [ |
972 | #= | |
902 | 973 | ["registry"] => CommandDeclaration[ |
903 | 974 | ( |
904 | 975 | CMD_REGISTRY_ADD, |
905 | 976 | ["add"], |
906 | 977 | do_registry_add!, |
907 | (ARG_PKG, []), | |
978 | (1=>Inf, identity, []), | |
908 | 979 | [], |
980 | "Currently just a placeholder for a future command", | |
909 | 981 | nothing, |
910 | 982 | ), |
911 | 983 | ], #registry |
984 | =# | |
912 | 985 | |
913 | 986 | ["package"] => CommandDeclaration[ |
914 | 987 | ( CMD_TEST, |
915 | 988 | ["test"], |
916 | 989 | do_test!, |
917 | (ARG_PKG, []), | |
990 | (0=>Inf, parse_pkg, []), | |
918 | 991 | [ |
919 | 992 | ("coverage", OPT_SWITCH, :coverage => true), |
920 | 993 | ], |
994 | "run tests for packages", | |
921 | 995 | md""" |
922 | 996 | |
923 | 997 | test [opts] pkg[=uuid] ... |
932 | 1006 | ),( CMD_HELP, |
933 | 1007 | ["help", "?"], |
934 | 1008 | nothing, |
935 | (ARG_RAW, []), | |
1009 | (0=>Inf, identity, []), | |
936 | 1010 | [], |
1011 | "show this message", | |
937 | 1012 | md""" |
938 | 1013 | |
939 | 1014 | help |
949 | 1024 | ),( CMD_INSTANTIATE, |
950 | 1025 | ["instantiate"], |
951 | 1026 | do_instantiate!, |
952 | (ARG_RAW, [0]), | |
1027 | (0=>0, identity, []), | |
953 | 1028 | [ |
954 | 1029 | (["project", "p"], OPT_SWITCH, :manifest => false), |
955 | 1030 | (["manifest", "m"], OPT_SWITCH, :manifest => true), |
956 | 1031 | ], |
1032 | "downloads all the dependencies for the project", | |
957 | 1033 | md""" |
958 | 1034 | instantiate |
959 | 1035 | instantiate [-m|--manifest] |
965 | 1041 | ),( CMD_RM, |
966 | 1042 | ["remove", "rm"], |
967 | 1043 | do_rm!, |
968 | (ARG_PKG, []), | |
1044 | (1=>Inf, parse_pkg, []), | |
969 | 1045 | [ |
970 | 1046 | (["project", "p"], OPT_SWITCH, :mode => PKGMODE_PROJECT), |
971 | 1047 | (["manifest", "m"], OPT_SWITCH, :mode => PKGMODE_MANIFEST), |
972 | 1048 | ], |
1049 | "remove packages from project or manifest", | |
973 | 1050 | md""" |
974 | 1051 | |
975 | 1052 | rm [-p|--project] pkg[=uuid] ... |
993 | 1070 | ),( CMD_ADD, |
994 | 1071 | ["add"], |
995 | 1072 | do_add!, |
996 | (ARG_ALL, []), | |
1073 | (1=>Inf, parse_pkg, [:add_or_dev => true, :valid => [VersionRange, Rev]]), | |
997 | 1074 | [], |
1075 | "add packages to project", | |
998 | 1076 | md""" |
999 | 1077 | |
1000 | 1078 | add pkg[=uuid] [@version] [#rev] ... |
1023 | 1101 | ),( CMD_DEVELOP, |
1024 | 1102 | ["develop", "dev"], |
1025 | 1103 | do_develop!, |
1026 | (ARG_ALL, []), | |
1104 | (1=>Inf, parse_pkg, [:add_or_dev => true, :valid => [VersionRange]]), | |
1027 | 1105 | [ |
1028 | 1106 | ("local", OPT_SWITCH, :shared => false), |
1029 | 1107 | ("shared", OPT_SWITCH, :shared => true), |
1030 | 1108 | ], |
1109 | "clone the full package repo locally for development", | |
1031 | 1110 | md""" |
1032 | 1111 | develop [--shared|--local] pkg[=uuid] ... |
1033 | 1112 | |
1041 | 1120 | *Example* |
1042 | 1121 | ```jl |
1043 | 1122 | pkg> develop Example |
1044 | pkg> develop Example#master | |
1045 | pkg> develop Example#c37b675 | |
1046 | pkg> develop https://github.com/JuliaLang/Example.jl#master | |
1123 | pkg> develop https://github.com/JuliaLang/Example.jl | |
1124 | pkg> develop ~/mypackages/Example | |
1047 | 1125 | pkg> develop --local Example |
1048 | 1126 | ``` |
1049 | 1127 | """, |
1050 | 1128 | ),( CMD_FREE, |
1051 | 1129 | ["free"], |
1052 | 1130 | do_free!, |
1053 | (ARG_PKG, []), | |
1131 | (1=>Inf, parse_pkg, []), | |
1054 | 1132 | [], |
1133 | "undoes a `pin`, `develop`, or stops tracking a repo", | |
1055 | 1134 | md""" |
1056 | 1135 | free pkg[=uuid] ... |
1057 | 1136 | |
1061 | 1140 | ),( CMD_PIN, |
1062 | 1141 | ["pin"], |
1063 | 1142 | do_pin!, |
1064 | (ARG_VERSION, []), | |
1143 | (1=>Inf, parse_pkg, [:valid => [VersionRange]]), | |
1065 | 1144 | [], |
1145 | "pins the version of packages", | |
1066 | 1146 | md""" |
1067 | 1147 | |
1068 | 1148 | pin pkg[=uuid] ... |
1073 | 1153 | ),( CMD_BUILD, |
1074 | 1154 | ["build"], |
1075 | 1155 | do_build!, |
1076 | (ARG_PKG, []), | |
1156 | (0=>Inf, parse_pkg, []), | |
1077 | 1157 | [], |
1158 | "run the build script for packages", | |
1078 | 1159 | md""" |
1079 | 1160 | |
1080 | 1161 | build pkg[=uuid] ... |
1086 | 1167 | ),( CMD_RESOLVE, |
1087 | 1168 | ["resolve"], |
1088 | 1169 | do_resolve!, |
1089 | (ARG_RAW, [0]), | |
1170 | (0=>0, identity, []), | |
1090 | 1171 | [], |
1172 | "resolves to update the manifest from changes in dependencies of developed packages", | |
1091 | 1173 | md""" |
1092 | 1174 | resolve |
1093 | 1175 | |
1094 | 1176 | Resolve the project i.e. run package resolution and update the Manifest. This is useful in case the dependencies of developed |
1095 | packages have changed causing the current Manifest to_indices be out of sync. | |
1177 | packages have changed causing the current Manifest to be out of sync. | |
1096 | 1178 | """, |
1097 | 1179 | ),( CMD_ACTIVATE, |
1098 | 1180 | ["activate"], |
1099 | 1181 | do_activate!, |
1100 | (ARG_RAW, [0,1]), | |
1182 | (0=>1, identity, []), | |
1101 | 1183 | [ |
1102 | 1184 | ("shared", OPT_SWITCH, :shared => true), |
1103 | 1185 | ], |
1186 | "set the primary environment the package manager manipulates", | |
1104 | 1187 | md""" |
1105 | 1188 | activate |
1106 | 1189 | activate [--shared] path |
1114 | 1197 | ),( CMD_UP, |
1115 | 1198 | ["update", "up"], |
1116 | 1199 | do_up!, |
1117 | (ARG_VERSION, []), | |
1200 | (0=>Inf, parse_pkg, [:valid => [VersionRange]]), | |
1118 | 1201 | [ |
1119 | 1202 | (["project", "p"], OPT_SWITCH, :mode => PKGMODE_PROJECT), |
1120 | 1203 | (["manifest", "m"], OPT_SWITCH, :mode => PKGMODE_MANIFEST), |
1123 | 1206 | ("patch", OPT_SWITCH, :level => UPLEVEL_PATCH), |
1124 | 1207 | ("fixed", OPT_SWITCH, :level => UPLEVEL_FIXED), |
1125 | 1208 | ], |
1209 | "update packages in manifest", | |
1126 | 1210 | md""" |
1127 | 1211 | |
1128 | 1212 | up [-p|project] [opts] pkg[=uuid] [@version] ... |
1142 | 1226 | ),( CMD_GENERATE, |
1143 | 1227 | ["generate"], |
1144 | 1228 | do_generate!, |
1145 | (ARG_RAW, [1]), | |
1229 | (1=>1, identity, []), | |
1146 | 1230 | [], |
1231 | "generate files for a new project", | |
1147 | 1232 | md""" |
1148 | 1233 | |
1149 | 1234 | generate pkgname |
1153 | 1238 | ),( CMD_PRECOMPILE, |
1154 | 1239 | ["precompile"], |
1155 | 1240 | do_precompile!, |
1156 | (ARG_RAW, [0]), | |
1241 | (0=>0, identity, []), | |
1157 | 1242 | [], |
1243 | "precompile all the project dependencies", | |
1158 | 1244 | md""" |
1159 | 1245 | precompile |
1160 | 1246 | |
1161 | 1247 | Precompile all the dependencies of the project by running `import` on all of them in a new process. |
1162 | The `startup.jl` file is disabled during precompilation unless julia is started with `--startup-file=yes`. | |
1163 | 1248 | """, |
1164 | 1249 | ),( CMD_STATUS, |
1165 | 1250 | ["status", "st"], |
1166 | 1251 | do_status!, |
1167 | (ARG_RAW, [0]), | |
1252 | (0=>0, identity, []), | |
1168 | 1253 | [ |
1169 | 1254 | (["project", "p"], OPT_SWITCH, :mode => PKGMODE_PROJECT), |
1170 | 1255 | (["manifest", "m"], OPT_SWITCH, :mode => PKGMODE_MANIFEST), |
1171 | 1256 | ], |
1257 | "summarize contents of and changes to environment", | |
1172 | 1258 | md""" |
1173 | 1259 | |
1174 | 1260 | status |
1185 | 1271 | ),( CMD_GC, |
1186 | 1272 | ["gc"], |
1187 | 1273 | do_gc!, |
1188 | (ARG_RAW, [0]), | |
1274 | (0=>0, identity, []), | |
1189 | 1275 | [], |
1276 | "garbage collect packages not used for a significant time", | |
1190 | 1277 | md""" |
1191 | 1278 | |
1192 | 1279 | Deletes packages that cannot be reached from any existing environment. |
1193 | 1280 | """, |
1194 | ),( CMD_PREVIEW, | |
1281 | ),( # preview is not a regular command. | |
1282 | # this is here so that preview appears as a registered command to users | |
1283 | CMD_PREVIEW, | |
1195 | 1284 | ["preview"], |
1196 | 1285 | nothing, |
1197 | (ARG_RAW, [1]), | |
1286 | (1=>Inf, identity, []), | |
1198 | 1287 | [], |
1288 | "previews a subsequent command without affecting the current state", | |
1199 | 1289 | md""" |
1200 | 1290 | |
1201 | 1291 | preview cmd |
1209 | 1299 | ] #command_declarations |
1210 | 1300 | |
1211 | 1301 | super_specs = SuperSpecs(command_declarations) |
1302 | # cache things you need for completions | |
1303 | completion_cache.meta_options = sort(map(wrap_option, collect(keys(meta_option_specs)))) | |
1304 | completion_cache.commands = sort(append!(collect(keys(super_specs)), | |
1305 | collect(keys(super_specs["package"])))) | |
1306 | let names = String[] | |
1307 | for (super, specs) in pairs(super_specs) | |
1308 | super == "package" && continue # skip "package" | |
1309 | for spec in unique(values(specs)) | |
1310 | push!(names, join([super, spec.canonical_name], "-")) | |
1311 | end | |
1312 | end | |
1313 | for spec in unique(values(super_specs["package"])) | |
1314 | push!(names, spec.canonical_name) | |
1315 | end | |
1316 | completion_cache.canonical_names = names | |
1317 | sort!(completion_cache.canonical_names) | |
1318 | end | |
1319 | for (k, v) in pairs(super_specs) | |
1320 | completion_cache.subcommands[k] = sort(collect(keys(v))) | |
1321 | for spec in values(v) | |
1322 | completion_cache.options[spec.kind] = | |
1323 | sort(map(wrap_option, collect(keys(spec.option_specs)))) | |
1324 | end | |
1325 | end | |
1326 | # TODO remove this | |
1212 | 1327 | command_specs = super_specs["package"] |
1213 | all_commands_sorted = sort(collect(String,keys(command_specs))) | |
1214 | long_commands = filter(c -> length(c) > 2, all_commands_sorted) | |
1215 | function all_options() | |
1216 | all_opts = [] | |
1217 | for command in values(command_specs) | |
1218 | for opt_spec in values(command.option_specs) | |
1219 | push!(all_opts, opt_spec.name) | |
1220 | opt_spec.short_name !== nothing && push!(all_opts, opt_spec.short_name) | |
1221 | end | |
1222 | end | |
1223 | unique!(all_opts) | |
1224 | return all_opts | |
1225 | end | |
1226 | all_options_sorted = [length(opt) > 1 ? "--$opt" : "-$opt" for opt in sort!(all_options())] | |
1227 | long_options = filter(c -> length(c) > 2, all_options_sorted) | |
1228 | 1328 | |
1229 | 1329 | const help = md""" |
1230 | 1330 | |
1234 | 1334 | |
1235 | 1335 | **Synopsis** |
1236 | 1336 | |
1237 | pkg> [--env=...] cmd [opts] [args] | |
1337 | pkg> cmd [opts] [args] | |
1238 | 1338 | |
1239 | 1339 | Multiple commands can be given on the same line by interleaving a `;` between the commands. |
1240 | 1340 | |
1241 | **Environment** | |
1242 | ||
1243 | The `--env` meta option determines which project environment to manipulate. By | |
1244 | default, this looks for a git repo in the parents directories of the current | |
1245 | working directory, and if it finds one, it uses that as an environment. Otherwise, | |
1246 | it uses a named environment (typically found in `~/.julia/environments`) looking | |
1247 | for environments named `v$(VERSION.major).$(VERSION.minor).$(VERSION.patch)`, | |
1248 | `v$(VERSION.major).$(VERSION.minor)`, `v$(VERSION.major)` or `default` in order. | |
1249 | ||
1250 | 1341 | **Commands** |
1251 | ||
1252 | What action you want the package manager to take: | |
1253 | ||
1254 | `help`: show this message | |
1255 | ||
1256 | `status`: summarize contents of and changes to environment | |
1257 | ||
1258 | `add`: add packages to project | |
1259 | ||
1260 | `develop`: clone the full package repo locally for development | |
1261 | ||
1262 | `rm`: remove packages from project or manifest | |
1263 | ||
1264 | `up`: update packages in manifest | |
1265 | ||
1266 | `test`: run tests for packages | |
1267 | ||
1268 | `build`: run the build script for packages | |
1269 | ||
1270 | `pin`: pins the version of packages | |
1271 | ||
1272 | `free`: undoes a `pin`, `develop`, or stops tracking a repo. | |
1273 | ||
1274 | `instantiate`: downloads all the dependencies for the project | |
1275 | ||
1276 | `resolve`: resolves to update the manifest from changes in dependencies of | |
1277 | developed packages | |
1278 | ||
1279 | `generate`: generate files for a new project | |
1280 | ||
1281 | `preview`: previews a subsequent command without affecting the current state | |
1282 | ||
1283 | `precompile`: precompile all the project dependencies | |
1284 | ||
1285 | `gc`: garbage collect packages not used for a significant time | |
1286 | ||
1287 | `activate`: set the primary environment the package manager manipulates | |
1288 | 1342 | """ |
1289 | 1343 | |
1344 | for command in completion_cache.canonical_names | |
1345 | spec = CommandSpec(command) | |
1346 | push!(help.content, Markdown.parse("`$command`: $(spec.description)")) | |
1347 | end | |
1348 | ||
1290 | 1349 | end #module |
239 | 239 | project_file = nothing |
240 | 240 | if env isa Nothing |
241 | 241 | project_file = Base.active_project() |
242 | project_file == nothing && error("no active project") | |
242 | project_file == nothing && pkgerror("no active project") | |
243 | 243 | elseif startswith(env, '@') |
244 | 244 | project_file = Base.load_path_expand(env) |
245 | project_file === nothing && error("package environment does not exist: $env") | |
245 | project_file === nothing && pkgerror("package environment does not exist: $env") | |
246 | 246 | elseif env isa String |
247 | 247 | if isdir(env) |
248 | isempty(readdir(env)) || error("environment is a package directory: $env") | |
248 | isempty(readdir(env)) || pkgerror("environment is a package directory: $env") | |
249 | 249 | project_file = joinpath(env, Base.project_names[end]) |
250 | 250 | else |
251 | 251 | project_file = endswith(env, ".toml") ? abspath(env) : |
332 | 332 | ########### |
333 | 333 | # Context # |
334 | 334 | ########### |
335 | stdlib_dir() = joinpath(Sys.BINDIR, "..", "share", "julia", "stdlib", "v$(VERSION.major).$(VERSION.minor)") | |
335 | stdlib_dir() = normpath(joinpath(Sys.BINDIR, "..", "share", "julia", "stdlib", "v$(VERSION.major).$(VERSION.minor)")) | |
336 | 336 | stdlib_path(stdlib::String) = joinpath(stdlib_dir(), stdlib) |
337 | 337 | function gather_stdlib_uuids() |
338 | 338 | stdlibs = Dict{UUID,String}() |
491 | 491 | end |
492 | 492 | end |
493 | 493 | |
494 | # try to call realpath on as much as possible | |
495 | function safe_realpath(path) | |
496 | ispath(path) && return realpath(path) | |
497 | a, b = splitdir(path) | |
498 | return joinpath(safe_realpath(a), b) | |
499 | end | |
500 | function relative_project_path(ctx::Context, path::String) | |
501 | # compute path relative the project | |
502 | # realpath needed to expand symlinks before taking the relative path | |
503 | return relpath(safe_realpath(abspath(path)), | |
504 | safe_realpath(dirname(ctx.env.project_file))) | |
505 | end | |
506 | ||
494 | 507 | casesensitive_isdir(dir::String) = isdir_windows_workaround(dir) && dir in readdir(joinpath(dir, "..")) |
495 | 508 | |
496 | function handle_repos_develop!(ctx::Context, pkgs::AbstractVector{PackageSpec}, devdir::String) | |
509 | function handle_repos_develop!(ctx::Context, pkgs::AbstractVector{PackageSpec}; shared::Bool) | |
497 | 510 | Base.shred!(LibGit2.CachedCredentials()) do creds |
498 | 511 | env = ctx.env |
499 | 512 | new_uuids = UUID[] |
511 | 524 | else |
512 | 525 | # Relative paths are given relative pwd() so we |
513 | 526 | # translate that to be relative the project instead. |
514 | # `realpath` is needed to expand symlinks before taking the relative path. | |
515 | pkg.path = relpath(realpath(abspath(pkg.repo.url)), realpath(dirname(ctx.env.project_file))) | |
527 | pkg.path = relative_project_path(ctx, pkg.repo.url) | |
516 | 528 | end |
517 | 529 | folder_already_downloaded = true |
518 | 530 | project_path = pkg.repo.url |
549 | 561 | else |
550 | 562 | rev = string(LibGit2.GitHash(LibGit2.head(repo))) |
551 | 563 | end |
552 | gitobject, isbranch = get_object_branch(repo, rev) | |
564 | gitobject, isbranch = get_object_branch(repo, rev, creds) | |
553 | 565 | try |
554 | 566 | LibGit2.transact(repo) do r |
555 | 567 | if isbranch |
564 | 576 | end |
565 | 577 | |
566 | 578 | parse_package!(ctx, pkg, project_path) |
579 | devdir = shared ? Pkg.devdir() : joinpath(dirname(ctx.env.project_file), "dev") | |
567 | 580 | dev_pkg_path = joinpath(devdir, pkg.name) |
568 | 581 | if isdir(dev_pkg_path) |
569 | 582 | if !isfile(joinpath(dev_pkg_path, "src", pkg.name * ".jl")) |
576 | 589 | mv(project_path, dev_pkg_path; force=true) |
577 | 590 | push!(new_uuids, pkg.uuid) |
578 | 591 | end |
579 | # Save the path as relative if the location is inside the project | |
580 | # (e.g. from `dev --local`), otherwise put in the absolute path. | |
581 | pkg.path = Pkg.Operations.relative_project_path_if_in_project(ctx, dev_pkg_path) | |
592 | # Save the path as relative if it is a --local dev, | |
593 | # otherwise put in the absolute path. | |
594 | pkg.path = shared ? dev_pkg_path : relative_project_path(ctx, dev_pkg_path) | |
582 | 595 | end |
583 | 596 | @assert pkg.path != nothing |
597 | @assert has_uuid(pkg) | |
584 | 598 | end |
585 | 599 | return new_uuids |
586 | 600 | end |
606 | 620 | project_path = nothing |
607 | 621 | folder_already_downloaded = false |
608 | 622 | try |
609 | repo, just_cloned = ispath(repo_path) ? (LibGit2.GitRepo(repo_path), false) : begin | |
610 | r = GitTools.clone(pkg.repo.url, repo_path, isbare=true, credentials=creds) | |
611 | GitTools.fetch(r, pkg.repo.url; refspecs=refspecs, credentials=creds) | |
612 | r, true | |
623 | repo = if ispath(repo_path) | |
624 | LibGit2.GitRepo(repo_path) | |
625 | else | |
626 | GitTools.clone(pkg.repo.url, repo_path, isbare=true, credentials=creds) | |
613 | 627 | end |
614 | 628 | info = manifest_info(env, pkg.uuid) |
615 | 629 | pinned = (info != nothing && get(info, "pinned", false)) |
616 | if upgrade_or_add && !pinned && !just_cloned | |
617 | rev = pkg.repo.rev | |
618 | GitTools.fetch(repo, pkg.repo.url; refspecs=refspecs, credentials=creds) | |
619 | end | |
620 | 630 | upgrading = upgrade_or_add && !pinned |
621 | 631 | if upgrading |
632 | GitTools.fetch(repo; refspecs=refspecs, credentials=creds) | |
622 | 633 | rev = pkg.repo.rev |
634 | # see if we can get rev as a branch | |
635 | if isempty(rev) | |
636 | if LibGit2.isattached(repo) | |
637 | rev = LibGit2.branch(repo) | |
638 | else | |
639 | rev = string(LibGit2.GitHash(LibGit2.head(repo))) | |
640 | end | |
641 | end | |
623 | 642 | else |
624 | 643 | # Not upgrading so the rev should be the current git-tree-sha |
625 | 644 | rev = info["git-tree-sha1"] |
626 | 645 | pkg.version = VersionNumber(info["version"]) |
627 | 646 | end |
628 | 647 | |
629 | # see if we can get rev as a branch | |
630 | if isempty(rev) | |
631 | if LibGit2.isattached(repo) | |
632 | rev = LibGit2.branch(repo) | |
633 | else | |
634 | rev = string(LibGit2.GitHash(LibGit2.head(repo))) | |
635 | end | |
636 | end | |
637 | gitobject, isbranch = get_object_branch(repo, rev) | |
648 | gitobject, isbranch = get_object_branch(repo, rev, creds) | |
638 | 649 | # If the user gave a shortened commit SHA, might as well update it to the full one |
639 | 650 | try |
640 | 651 | if upgrading |
651 | 662 | info = manifest_info(env, pkg.uuid) |
652 | 663 | if info != nothing && get(info, "git-tree-sha1", "") == string(pkg.repo.git_tree_sha1) && folder_already_downloaded |
653 | 664 | # Same tree sha and this version already downloaded, nothing left to do |
654 | pkg.version = VersionNumber(info["version"]) | |
655 | 665 | do_nothing_more = true |
656 | 666 | end |
657 | 667 | end |
678 | 688 | mv(project_path, version_path; force=true) |
679 | 689 | push!(new_uuids, pkg.uuid) |
680 | 690 | end |
681 | @assert pkg.version isa VersionNumber | |
691 | @assert has_uuid(pkg) | |
682 | 692 | end |
683 | 693 | return new_uuids |
684 | 694 | finally |
693 | 703 | project_data = read_package(project_file) |
694 | 704 | pkg.uuid = UUID(project_data["uuid"]) |
695 | 705 | pkg.name = project_data["name"] |
696 | if haskey(project_data, "version") | |
697 | pkg.version = VersionNumber(project_data["version"]) | |
698 | else | |
699 | @warn "project file for $(pkg.name) at $(project_path) is missing a `version` entry" | |
700 | Pkg.Operations.set_maximum_version_registry!(env, pkg) | |
701 | end | |
702 | 706 | else |
703 | # @warn "package $(pkg.name) at $(project_path) will need to have a [Julia]Project.toml file in the future" | |
704 | 707 | if !isempty(ctx.old_pkg2_clone_name) # remove when legacy CI script support is removed |
705 | 708 | pkg.name = ctx.old_pkg2_clone_name |
706 | 709 | else |
707 | # This is an old style package, get the name from src/PackageName | |
708 | if isdir_windows_workaround(pkg.repo.url) | |
709 | m = match(reg_pkg, abspath(pkg.repo.url)) | |
710 | else | |
711 | m = match(reg_pkg, pkg.repo.url) | |
712 | end | |
713 | m === nothing && pkgerror("cannot determine package name from URL or path: $(pkg.repo.url)") | |
714 | pkg.name = m.captures[1] | |
710 | # This is an old style package, if not set, get the name from src/PackageName | |
711 | if !has_name(pkg) | |
712 | if isdir_windows_workaround(pkg.repo.url) | |
713 | m = match(reg_pkg, abspath(pkg.repo.url)) | |
714 | else | |
715 | m = match(reg_pkg, pkg.repo.url) | |
716 | end | |
717 | m === nothing && pkgerror("cannot determine package name from URL or path: $(pkg.repo.url), provide a name argument to `PackageSpec`") | |
718 | pkg.name = m.captures[1] | |
719 | end | |
715 | 720 | end |
716 | 721 | reg_uuids = registered_uuids(env, pkg.name) |
717 | 722 | is_registered = !isempty(reg_uuids) |
722 | 727 | pkg.uuid = uuid5(uuid_unreg_pkg, pkg.name) |
723 | 728 | @info "Assigning UUID $(pkg.uuid) to $(pkg.name)" |
724 | 729 | end |
725 | pkg.version = v"0.0" | |
726 | 730 | else |
727 | # TODO: Fix | |
728 | 731 | @assert length(reg_uuids) == 1 |
729 | 732 | pkg.uuid = reg_uuids[1] |
730 | # Old style registered package | |
731 | # What version does this package have? We have no idea... let's give it the latest one with a `+`... | |
732 | Pkg.Operations.set_maximum_version_registry!(env, pkg) | |
733 | 733 | end |
734 | 734 | end |
735 | 735 | end |
743 | 743 | _, pkg.repo.url = Types.registered_info(env, pkg.uuid, "repo")[1] |
744 | 744 | end |
745 | 745 | |
746 | function get_object_branch(repo, rev) | |
746 | function get_object_branch(repo, rev, creds) | |
747 | 747 | gitobject = nothing |
748 | 748 | isbranch = false |
749 | 749 | try |
757 | 757 | gitobject = LibGit2.GitObject(repo, rev) |
758 | 758 | catch err |
759 | 759 | err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err) |
760 | pkgerror("git object $(rev) could not be found") | |
760 | GitTools.fetch(repo; refspecs=refspecs, credentials=creds) | |
761 | try | |
762 | gitobject = LibGit2.GitObject(repo, rev) | |
763 | catch err | |
764 | err isa LibGit2.GitError && err.code == LibGit2.Error.ENOTFOUND || rethrow(err) | |
765 | pkgerror("git object $(rev) could not be found") | |
766 | end | |
761 | 767 | end |
762 | 768 | end |
763 | 769 | return gitobject, isbranch |
781 | 787 | # Disambiguate name/uuid package specifications using project info. |
782 | 788 | function project_deps_resolve!(env::EnvCache, pkgs::AbstractVector{PackageSpec}) |
783 | 789 | uuids = env.project["deps"] |
784 | names = Dict(uuid => name for (uuid, name) in uuids) | |
790 | names = Dict(uuid => name for (name, uuid) in uuids) | |
785 | 791 | length(uuids) < length(names) && # TODO: handle this somehow? |
786 | 792 | pkgerror("duplicate UUID found in project file's [deps] section") |
787 | 793 | for pkg in pkgs |
1049 | 1055 | end |
1050 | 1056 | end |
1051 | 1057 | length(choices_cache) == 1 && return choices_cache[1][1] |
1052 | # prompt for which UUID was intended: | |
1053 | menu = RadioMenu(choices) | |
1054 | choice = request("There are multiple registered `$name` packages, choose one:", menu) | |
1055 | choice == -1 && return UUID(zero(UInt128)) | |
1056 | env.paths[choices_cache[choice][1]] = [choices_cache[choice][2]] | |
1057 | return choices_cache[choice][1] | |
1058 | if isinteractive() | |
1059 | # prompt for which UUID was intended: | |
1060 | menu = RadioMenu(choices) | |
1061 | choice = request("There are multiple registered `$name` packages, choose one:", menu) | |
1062 | choice == -1 && return UUID(zero(UInt128)) | |
1063 | env.paths[choices_cache[choice][1]] = [choices_cache[choice][2]] | |
1064 | return choices_cache[choice][1] | |
1065 | else | |
1066 | pkgerror("there are multiple registered `$name` packages, explicitly set the uuid") | |
1067 | end | |
1058 | 1068 | end |
1059 | 1069 | |
1060 | 1070 | # Determine current name for a given package UUID |
1108 | 1118 | end |
1109 | 1119 | |
1110 | 1120 | |
1111 | function pathrepr(ctx::Union{Nothing, Context}, path::String, base::String=pwd()) | |
1112 | project_path = dirname(ctx.env.project_file) | |
1113 | path = joinpath(project_path, path) | |
1114 | if startswith(path, project_path) && startswith(base, project_path) | |
1115 | # We are in project and path is in project | |
1116 | path = relpath(path, base) | |
1117 | end | |
1118 | if !Sys.iswindows() && isabspath(path) | |
1119 | home = joinpath(homedir(), "") | |
1120 | if startswith(path, home) | |
1121 | path = joinpath("~", path[nextind(path, lastindex(home)):end]) | |
1122 | end | |
1123 | end | |
1124 | return "`" * path * "`" | |
1121 | function pathrepr(path::String) | |
1122 | # print stdlib paths as @stdlib/Name | |
1123 | if startswith(path, stdlib_dir()) | |
1124 | path = "@stdlib/" * basename(path) | |
1125 | end | |
1126 | return "`" * Base.contractuser(path) * "`" | |
1125 | 1127 | end |
1126 | 1128 | |
1127 | 1129 | function project_key_order(key::String) |
1144 | 1146 | isempty(project["deps"]) && delete!(project, "deps") |
1145 | 1147 | if !isempty(project) || ispath(env.project_file) |
1146 | 1148 | if display_diff && !(ctx.currently_running_target) |
1147 | printpkgstyle(ctx, :Updating, pathrepr(ctx, env.project_file)) | |
1149 | printpkgstyle(ctx, :Updating, pathrepr(env.project_file)) | |
1148 | 1150 | Pkg.Display.print_project_diff(ctx, old_env, env) |
1149 | 1151 | end |
1150 | 1152 | if !ctx.preview |
1157 | 1159 | # update the manifest file |
1158 | 1160 | if !isempty(env.manifest) || ispath(env.manifest_file) |
1159 | 1161 | if display_diff && !(ctx.currently_running_target) |
1160 | printpkgstyle(ctx, :Updating, pathrepr(ctx, env.manifest_file)) | |
1162 | printpkgstyle(ctx, :Updating, pathrepr(env.manifest_file)) | |
1161 | 1163 | Pkg.Display.print_manifest_diff(ctx, old_env, env) |
1162 | 1164 | end |
1163 | 1165 | manifest = deepcopy(env.manifest) |
0 | # This file is a part of Julia. License is MIT: https://julialang.org/license | |
1 | ||
2 | precompile(Tuple{Type{Base.Dict{K, V} where V where K}, Array{Base.Pair{A, B} where B where A, 1}}) | |
3 | precompile(Tuple{Type{Base.Dict{Pkg.Types.VersionRange, Base.Dict{String, Base.UUID}}}}) | |
4 | precompile(Tuple{Type{Base.Dict{Pkg.Types.VersionRange, Base.Dict{String, Pkg.Types.VersionSpec}}}}) | |
5 | precompile(Tuple{Type{Base.Dict{String, Any}}, Base.Pair{String, String}}) | |
6 | precompile(Tuple{Type{Base.Dict{String, Base.UUID}}}) | |
7 | precompile(Tuple{Type{Base.Dict{String, Pkg.Types.VersionSpec}}}) | |
8 | precompile(Tuple{Type{Base.Generator{I, F} where F where I}, Type{Base.UUID}, Base.ValueIterator{Base.Dict{String, Any}}}) | |
9 | precompile(Tuple{Type{Base.Generator{I, F} where F where I}, Type{Base.UUID}, Base.ValueIterator{Base.Dict{String, String}}}) | |
10 | precompile(Tuple{Type{Base.Generator{I, F} where F where I}, typeof(Base.close), Array{LibGit2.GitAnnotated, 1}}) | |
11 | precompile(Tuple{Type{Base.Generator{I, F} where F where I}, typeof(Pkg.TOML.is_tabular), Base.ValueIterator{Base.Dict{String, Any}}}) | |
12 | precompile(Tuple{Type{Base.Generator{I, F} where F where I}, typeof(Pkg.TOML.table2dict), Array{Any, 1}}) | |
13 | precompile(Tuple{Type{Base.IOContext{IO_t} where IO_t<:IO}, Base.GenericIOBuffer{Array{UInt8, 1}}, Base.TTY}) | |
14 | precompile(Tuple{Type{Base.Pair{A, B} where B where A}, Base.UUID, Int64}) | |
15 | precompile(Tuple{Type{Base.Pair{A, B} where B where A}, Base.UUID, Pkg.Types.VersionSpec}) | |
16 | precompile(Tuple{Type{Base.Pair{A, B} where B where A}, Base.VersionNumber, Base.SHA1}) | |
17 | precompile(Tuple{Type{Base.Pair{A, B} where B where A}, String, Base.UUID}) | |
18 | precompile(Tuple{Type{Base.SHA1}, Base.SubString{String}}) | |
19 | precompile(Tuple{Type{Base.SHA1}, String}) | |
20 | precompile(Tuple{Type{Char}, Int32}) | |
21 | precompile(Tuple{Type{NamedTuple{(:by,), T} where T<:Tuple}, Tuple{typeof(Base.identity)}}) | |
22 | precompile(Tuple{Type{NamedTuple{(:header, :color), T} where T<:Tuple}, Tuple{String, Symbol}}) | |
23 | precompile(Tuple{Type{NamedTuple{(:indent, :region_active), T} where T<:Tuple}, Tuple{Int64, Bool}}) | |
24 | precompile(Tuple{Type{NamedTuple{(:indent, :sorted, :by), T} where T<:Tuple}, Tuple{Int64, Bool, typeof(Base.identity)}}) | |
25 | precompile(Tuple{Type{NamedTuple{(:init,), T} where T<:Tuple}, Tuple{Int64}}) | |
26 | precompile(Tuple{Type{NamedTuple{(:mode,), T} where T<:Tuple}, Tuple{Symbol}}) | |
27 | precompile(Tuple{Type{NamedTuple{(:transfer_progress, :credentials), T} where T<:Tuple}, Tuple{Ptr{Nothing}, Ptr{Nothing}}}) | |
28 | precompile(Tuple{Type{Pkg.Display.DiffEntry}, Base.UUID, String, Pkg.Display.VerInfo, Pkg.Display.VerInfo}) | |
29 | precompile(Tuple{Type{Pkg.Display.VerInfo}, Base.SHA1, Nothing, Base.VersionNumber, Bool, Nothing}) | |
30 | precompile(Tuple{Type{Pkg.Display.VerInfo}, Base.SHA1, Nothing, Base.VersionNumber, Bool, Pkg.Types.GitRepo}) | |
31 | precompile(Tuple{Type{Pkg.Display.VerInfo}, Nothing, Nothing, Nothing, Bool, Nothing}) | |
32 | precompile(Tuple{Type{Pkg.Display.VerInfo}, Nothing, String, Base.VersionNumber, Bool, Nothing}) | |
33 | precompile(Tuple{Type{Pkg.Types.EnvCache}, Nothing, Nothing, String, String, Nothing, Base.Dict{String, Any}, Base.Dict{String, Any}, Base.Dict{String, Array{Base.UUID, 1}}, Base.Dict{Base.UUID, Array{String, 1}}, Base.Dict{Base.UUID, Array{String, 1}}}) | |
34 | precompile(Tuple{Type{Pkg.Types.GitRepo}, String, String, Base.SHA1}) | |
35 | precompile(Tuple{Type{Pkg.Types.GitRepo}, String, String}) | |
36 | precompile(Tuple{Type{Pkg.Types.PackageSpec}, Base.SubString{String}, Pkg.Types.VersionSpec}) | |
37 | precompile(Tuple{Type{Pkg.Types.PackageSpec}, Base.SubString{String}}) | |
38 | precompile(Tuple{Type{Pkg.Types.PackageSpec}, String, Base.UUID, Pkg.Types.VersionSpec}) | |
39 | precompile(Tuple{Type{Pkg.Types.PackageSpec}, String}) | |
40 | precompile(Tuple{Type{Pkg.Types.VersionBound}, Base.SubString{String}}) | |
41 | precompile(Tuple{Type{Pkg.Types.VersionBound}, Int64, Int64}) | |
42 | precompile(Tuple{Type{Pkg.Types.VersionBound}, Tuple{Int64, Int64, Int64}}) | |
43 | precompile(Tuple{Type{Pkg.Types.VersionBound}, Tuple{Int64, Int64}}) | |
44 | precompile(Tuple{Type{Pkg.Types.VersionBound}, Tuple{UInt32, UInt32}}) | |
45 | precompile(Tuple{Type{Pkg.Types.VersionBound}, UInt32, UInt32}) | |
46 | precompile(Tuple{Type{Pkg.Types.VersionRange}, Base.VersionNumber}) | |
47 | precompile(Tuple{Type{Pkg.Types.VersionSpec}, String}) | |
48 | precompile(Tuple{Type{REPL.LineEdit.PrefixSearchState}, REPL.Terminals.TTYTerminal, REPL.LineEdit.PrefixHistoryPrompt, String, Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
49 | precompile(Tuple{Type{REPL.LineEdit.PromptState}, REPL.Terminals.TTYTerminal, REPL.LineEdit.Prompt, Base.GenericIOBuffer{Array{UInt8, 1}}, Symbol, Array{Base.GenericIOBuffer{Array{UInt8, 1}}, 1}, Int64, REPL.LineEdit.InputAreaState, Int64, Base.Threads.TatasLock, Float64}) | |
50 | precompile(Tuple{Type{REPL.LineEdit.SearchState}, REPL.Terminals.TTYTerminal, REPL.LineEdit.HistoryPrompt, Bool, Base.GenericIOBuffer{Array{UInt8, 1}}, Base.GenericIOBuffer{Array{UInt8, 1}}}) | |
51 | precompile(Tuple{Type{REPL.REPLHistoryProvider}, Array{String, 1}, Nothing, Int64, Int64, Int64, Base.GenericIOBuffer{Array{UInt8, 1}}, Nothing, Base.Dict{Symbol, Any}, Array{UInt8, 1}}) | |
52 | precompile(Tuple{Type{REPL.REPLHistoryProvider}, Base.Dict{Symbol, Any}}) | |
53 | precompile(Tuple{getfield(Base, Symbol("#kw##printstyled")), NamedTuple{(:bold, :color), Tuple{Bool, Symbol}}, typeof(Base.printstyled), Base.TTY, String}) | |
54 | precompile(Tuple{getfield(Base, Symbol("#kw##sort!")), NamedTuple{(:by,), Tuple{typeof(Base.Unicode.lowercase)}}, typeof(Base.sort!), Array{String, 1}}) | |
55 | precompile(Tuple{getfield(Base, Symbol("#kw##sort!")), NamedTuple{(:by,), Tuple{typeof(Base.identity)}}, typeof(Base.sort!), Array{String, 1}}) | |
56 | precompile(Tuple{getfield(Base.Cartesian, Symbol("#@nloops")), LineNumberNode, Module, Int64, Symbol, Expr, Expr, Expr}) | |
57 | precompile(Tuple{getfield(Core, Symbol("#kw#Type")), NamedTuple{(:header, :color), Tuple{String, Symbol}}, Type{Pkg.GitTools.MiniProgressBar}}) | |
58 | precompile(Tuple{getfield(Core, Symbol("#kw#Type")), NamedTuple{(:payload, :transfer_progress, :credentials), Tuple{Base.Dict{Symbol, Any}, Ptr{Nothing}, Ptr{Nothing}}}, Type{LibGit2.RemoteCallbacks}}) | |
59 | precompile(Tuple{getfield(Pkg.API, Symbol("#kw##add_or_develop")), NamedTuple{(:mode,), Tuple{Symbol}}, typeof(Pkg.API.add_or_develop), Pkg.Types.Context, Array{Pkg.Types.PackageSpec, 1}}) | |
60 | precompile(Tuple{getfield(Pkg.TOML, Symbol("#kw##_print")), NamedTuple{(:indent, :sorted, :by), Tuple{Int64, Bool, typeof(Base.identity)}}, typeof(Pkg.TOML._print), Base.IOStream, Base.Dict{String, Any}, Array{String, 1}}) | |
61 | precompile(Tuple{getfield(Pkg.TOML, Symbol("#kw##print")), NamedTuple{(:sorted,), Tuple{Bool}}, typeof(Pkg.TOML.print), Base.IOStream, Base.Dict{String, Any}}) | |
62 | precompile(Tuple{getfield(Pkg.TOML, Symbol("#kw##printvalue")), NamedTuple{(:sorted,), Tuple{Bool}}, typeof(Pkg.TOML.printvalue), Base.IOStream, Array{String, 1}}) | |
63 | precompile(Tuple{getfield(Pkg.TOML, Symbol("#kw##printvalue")), NamedTuple{(:sorted,), Tuple{Bool}}, typeof(Pkg.TOML.printvalue), Base.IOStream, String}) | |
64 | precompile(Tuple{getfield(REPL.LineEdit, Symbol("#kw##add_nested_key!")), NamedTuple{(:override,), Tuple{Bool}}, typeof(REPL.LineEdit.add_nested_key!), Base.Dict{Char, Any}, String, Nothing}) | |
65 | precompile(Tuple{getfield(REPL.LineEdit, Symbol("#kw##refresh_multi_line")), NamedTuple{(:indent, :region_active), Tuple{Int64, Bool}}, typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TerminalBuffer, REPL.Terminals.TTYTerminal, Base.GenericIOBuffer{Array{UInt8, 1}}, REPL.LineEdit.InputAreaState, REPL.LineEdit.PromptState}) | |
66 | precompile(Tuple{typeof(Base.:(!=)), Base.SubString{String}, Nothing}) | |
67 | precompile(Tuple{typeof(Base.:(!=)), Base.UUID, Base.UUID}) | |
68 | precompile(Tuple{typeof(Base.:(==)), Base.Dict{String, Any}, Nothing}) | |
69 | precompile(Tuple{typeof(Base.:(==)), Base.SHA1, Nothing}) | |
70 | precompile(Tuple{typeof(Base.:(==)), Base.UUID, Base.UUID}) | |
71 | precompile(Tuple{typeof(Base.:(==)), Expr, Int64}) | |
72 | precompile(Tuple{typeof(Base.:(==)), Nothing, Base.UUID}) | |
73 | precompile(Tuple{typeof(Base.:(==)), Nothing, Nothing}) | |
74 | precompile(Tuple{typeof(Base.:(==)), String, Nothing}) | |
75 | precompile(Tuple{typeof(Base.:(==)), Symbol, Int64}) | |
76 | precompile(Tuple{typeof(Base.Cartesian._nloops), Int64, Symbol, Expr, Expr, Expr}) | |
77 | precompile(Tuple{typeof(Base.Cartesian.exprresolve), LineNumberNode}) | |
78 | precompile(Tuple{typeof(Base.Cartesian.lreplace!), Int64, Base.Cartesian.LReplace{String}}) | |
79 | precompile(Tuple{typeof(Base.Filesystem.ispath), String}) | |
80 | precompile(Tuple{typeof(Base.Filesystem.mtime), String}) | |
81 | precompile(Tuple{typeof(Base.Iterators.enumerate), Array{Base.VersionNumber, 1}}) | |
82 | precompile(Tuple{typeof(Base._array_for), Type{Array{Base.BitArray{2}, 1}}, Base.UnitRange{Int64}, Base.HasShape{1}}) | |
83 | precompile(Tuple{typeof(Base._array_for), Type{Array{Base.VersionNumber, 1}}, Base.UnitRange{Int64}, Base.HasShape{1}}) | |
84 | precompile(Tuple{typeof(Base._array_for), Type{Base.BitArray{1}}, Base.UnitRange{Int64}, Base.HasShape{1}}) | |
85 | precompile(Tuple{typeof(Base._array_for), Type{Base.BitArray{2}}, Base.UnitRange{Int64}, Base.HasShape{1}}) | |
86 | precompile(Tuple{typeof(Base._array_for), Type{Base.Dict{Base.VersionNumber, Int64}}, Base.UnitRange{Int64}, Base.HasShape{1}}) | |
87 | precompile(Tuple{typeof(Base._array_for), Type{Base.UUID}, Base.ValueIterator{Base.Dict{String, Any}}, Base.HasLength}) | |
88 | precompile(Tuple{typeof(Base._collect), Array{Pkg.REPLMode.Statement, 1}, Base.Generator{Array{Pkg.REPLMode.Statement, 1}, Type{Pkg.REPLMode.PkgCommand}}, Base.EltypeUnknown, Base.HasShape{1}}) | |
89 | precompile(Tuple{typeof(Base._compute_eltype), Type{Tuple{Array{String, 1}, LibGit2.CachedCredentials}}}) | |
90 | precompile(Tuple{typeof(Base._compute_eltype), Type{Tuple{Bool, LibGit2.CachedCredentials}}}) | |
91 | precompile(Tuple{typeof(Base._compute_eltype), Type{Tuple{Int32, Base.Cstring, Ptr{Nothing}}}}) | |
92 | precompile(Tuple{typeof(Base._deepcopy_array_t), Array{Base.Dict{String, Any}, 1}, Type{Base.Dict{String, Any}}, Base.IdDict{Any, Any}}) | |
93 | precompile(Tuple{typeof(Base._getindex), Base.IndexLinear, Base.BitArray{2}, Base.LogicalIndex{Int64, Base.BitArray{1}}, Int64}) | |
94 | precompile(Tuple{typeof(Base._iterate), Base.Dict{String, Any}, Int64}) | |
95 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Any}, Type{Ptr{Nothing}}}) | |
96 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Array{String, 1}}, Type{LibGit2.CachedCredentials}}) | |
97 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Bool}, Type{LibGit2.CachedCredentials}}) | |
98 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Int32}, Type{Base.Cstring}}) | |
99 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Union{}}, Type{Array{String, 1}}}) | |
100 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Union{}}, Type{Bool}}) | |
101 | precompile(Tuple{typeof(Base._promote_typejoin), Type{Union{}}, Type{Int32}}) | |
102 | precompile(Tuple{typeof(Base._shrink), typeof(Base.setdiff!), Array{Base.UUID, 1}, Tuple{Array{Base.UUID, 1}}}) | |
103 | precompile(Tuple{typeof(Base.add_sum), Int64, Int64}) | |
104 | precompile(Tuple{typeof(Base.afoldl), typeof(Base.:(+)), Int64, Int64, Int64}) | |
105 | precompile(Tuple{typeof(Base.all), Base.Generator{Base.ValueIterator{Base.Dict{String, Any}}, typeof(Pkg.TOML.is_tabular)}}) | |
106 | precompile(Tuple{typeof(Base.close), Base.Channel{Any}}) | |
107 | precompile(Tuple{typeof(Base.close), LibGit2.GitAnnotated}) | |
108 | precompile(Tuple{typeof(Base.close), LibGit2.GitConfig}) | |
109 | precompile(Tuple{typeof(Base.close), LibGit2.GitDiff}) | |
110 | precompile(Tuple{typeof(Base.close), LibGit2.GitReference}) | |
111 | precompile(Tuple{typeof(Base.close), LibGit2.GitRemote}) | |
112 | precompile(Tuple{typeof(Base.close), LibGit2.GitRepo}) | |
113 | precompile(Tuple{typeof(Base.close), LibGit2.GitTree}) | |
114 | precompile(Tuple{typeof(Base.cmd_gen), Tuple{Tuple{Base.Cmd}}}) | |
115 | precompile(Tuple{typeof(Base.collect), Base.Generator{Array{Any, 1}, typeof(Pkg.TOML.table2dict)}}) | |
116 | precompile(Tuple{typeof(Base.collect), Base.Generator{Base.ValueIterator{Base.Dict{String, Any}}, Type{Base.UUID}}}) | |
117 | precompile(Tuple{typeof(Base.collect), Base.Generator{Base.ValueIterator{Base.Dict{String, String}}, Type{Base.UUID}}}) | |
118 | precompile(Tuple{typeof(Base.collect), Base.KeySet{String, Base.Dict{String, Any}}}) | |
119 | precompile(Tuple{typeof(Base.collect_similar), Array{LibGit2.GitAnnotated, 1}, Base.Generator{Array{LibGit2.GitAnnotated, 1}, typeof(Base.close)}}) | |
120 | precompile(Tuple{typeof(Base.collect_to_with_first!), Array{Base.UUID, 1}, Base.UUID, Base.Generator{Base.ValueIterator{Base.Dict{String, Any}}, Type{Base.UUID}}, Int64}) | |
121 | precompile(Tuple{typeof(Base.collect_to_with_first!), Array{String, 1}, String, Base.Generator{Array{String, 1}, typeof(Pkg.REPLMode.word2token)}, Int64}) | |
122 | precompile(Tuple{typeof(Base.convert), Type{Array{Array{Base.BitArray{2}, 1}, 1}}, Array{Array{Base.BitArray{2}, 1}, 1}}) | |
123 | precompile(Tuple{typeof(Base.convert), Type{Array{Array{Base.VersionNumber, 1}, 1}}, Array{Array{Base.VersionNumber, 1}, 1}}) | |
124 | precompile(Tuple{typeof(Base.convert), Type{Array{Array{Int64, 1}, 1}}, Array{Array{Int64, 1}, 1}}) | |
125 | precompile(Tuple{typeof(Base.convert), Type{Array{Base.BitArray{1}, 1}}, Array{Base.BitArray{1}, 1}}) | |
126 | precompile(Tuple{typeof(Base.convert), Type{Array{Base.Dict{Base.VersionNumber, Int64}, 1}}, Array{Base.Dict{Base.VersionNumber, Int64}, 1}}) | |
127 | precompile(Tuple{typeof(Base.convert), Type{Array{Base.UUID, 1}}, Array{Base.UUID, 1}}) | |
128 | precompile(Tuple{typeof(Base.convert), Type{Array{Char, 1}}, Array{Char, 1}}) | |
129 | precompile(Tuple{typeof(Base.convert), Type{Array{Int64, 1}}, Array{Int64, 1}}) | |
130 | precompile(Tuple{typeof(Base.convert), Type{Array{Symbol, 1}}, Array{UInt8, 1}}) | |
131 | precompile(Tuple{typeof(Base.convert), Type{Array{Union{Pkg.Types.VersionRange, String, Pkg.REPLMode.Rev}, 1}}, Array{String, 1}}) | |
132 | precompile(Tuple{typeof(Base.convert), Type{Base.Dict{Base.UUID, Int64}}, Base.Dict{Base.UUID, Int64}}) | |
133 | precompile(Tuple{typeof(Base.convert), Type{Base.Dict{Base.UUID, Pkg.GraphType.ResolveLogEntry}}, Base.Dict{Base.UUID, Pkg.GraphType.ResolveLogEntry}}) | |
134 | precompile(Tuple{typeof(Base.convert), Type{Base.Dict{K, V} where V where K}, Base.Dict{Symbol, Any}}) | |
135 | precompile(Tuple{typeof(Base.convert), Type{Base.Dict{Symbol, Any}}, Base.Dict{Any, Any}}) | |
136 | precompile(Tuple{typeof(Base.convert), Type{Base.UUID}, Base.UUID}) | |
137 | precompile(Tuple{typeof(Base.convert), Type{REPL.LineEdit.TextInterface}, REPL.LineEdit.Prompt}) | |
138 | precompile(Tuple{typeof(Base.convert), Type{REPL.Terminals.AbstractTerminal}, REPL.Terminals.TTYTerminal}) | |
139 | precompile(Tuple{typeof(Base.convert), Type{REPL.Terminals.TextTerminal}, REPL.Terminals.TTYTerminal}) | |
140 | precompile(Tuple{typeof(Base.convert), Type{Union{Nothing, IO}}, Base.IOStream}) | |
141 | precompile(Tuple{typeof(Base.convert), Type{Union{Nothing, IO}}, Nothing}) | |
142 | precompile(Tuple{typeof(Base.convert), Type{Union{Nothing, REPL.LineEdit.Prompt}}, Nothing}) | |
143 | precompile(Tuple{typeof(Base.convert), Type{Union{Pkg.Types.UpgradeLevel, Base.VersionNumber, Pkg.Types.VersionSpec}}, Base.VersionNumber}) | |
144 | precompile(Tuple{typeof(Base.copy_chunks!), Array{UInt64, 1}, Int64, Array{UInt64, 1}, Int64, Int64}) | |
145 | precompile(Tuple{typeof(Base.count), Base.BitArray{1}}) | |
146 | precompile(Tuple{typeof(Base.deepcopy), Base.Dict{String, Any}}) | |
147 | precompile(Tuple{typeof(Base.deepcopy_internal), Array{Base.Dict{String, Any}, 1}, Base.IdDict{Any, Any}}) | |
148 | precompile(Tuple{typeof(Base.deepcopy_internal), Base.Dict{Any, Any}, Base.IdDict{Any, Any}}) | |
149 | precompile(Tuple{typeof(Base.deepcopy_internal), Base.Dict{String, Any}, Base.IdDict{Any, Any}}) | |
150 | precompile(Tuple{typeof(Base.deepcopy_internal), Base.Dict{String, String}, Base.IdDict{Any, Any}}) | |
151 | precompile(Tuple{typeof(Base.deepcopy_internal), String, Base.IdDict{Any, Any}}) | |
152 | precompile(Tuple{typeof(Base.delete!), Base.Dict{String, Any}, String}) | |
153 | precompile(Tuple{typeof(Base.delete!), Base.IdDict{Any, Any}, Symbol}) | |
154 | precompile(Tuple{typeof(Base.empty), Base.Dict{Any, Any}, Type{Base.UUID}, Type{Int64}}) | |
155 | precompile(Tuple{typeof(Base.empty), Base.Dict{Any, Any}, Type{String}, Type{Base.UUID}}) | |
156 | precompile(Tuple{typeof(Base.empty), Base.Dict{Any, Any}, Type{String}, Type{String}}) | |
157 | precompile(Tuple{typeof(Base.eof), Base.IOStream}) | |
158 | precompile(Tuple{typeof(Base.get!), Base.Dict{Base.UUID, Array{String, 1}}, Base.UUID, Array{String, 1}}) | |
159 | precompile(Tuple{typeof(Base.get!), Base.Dict{Pkg.Types.VersionRange, Base.Dict{String, Base.UUID}}, Pkg.Types.VersionRange, Base.Dict{String, Base.UUID}}) | |
160 | precompile(Tuple{typeof(Base.get!), Base.Dict{Pkg.Types.VersionRange, Base.Dict{String, Pkg.Types.VersionSpec}}, Pkg.Types.VersionRange, Base.Dict{String, Pkg.Types.VersionSpec}}) | |
161 | precompile(Tuple{typeof(Base.get!), Base.Dict{String, Any}, String, Array{Base.Dict{String, Any}, 1}}) | |
162 | precompile(Tuple{typeof(Base.get!), Base.Dict{String, Array{Base.UUID, 1}}, String, Array{Base.UUID, 1}}) | |
163 | precompile(Tuple{typeof(Base.get), Base.Dict{String, Any}, String, Base.Dict{Any, Any}}) | |
164 | precompile(Tuple{typeof(Base.get), Base.Dict{String, Pkg.REPLMode.CommandSpec}, String, Nothing}) | |
165 | precompile(Tuple{typeof(Base.getindex), Array{Array{Base.VersionNumber, 1}, 1}, Int64}) | |
166 | precompile(Tuple{typeof(Base.getindex), Array{Array{Int64, 1}, 1}, Int64}) | |
167 | precompile(Tuple{typeof(Base.getindex), Array{Array{UInt64, 1}, 1}, Int64}) | |
168 | precompile(Tuple{typeof(Base.getindex), Array{Base.BitArray{1}, 1}, Int64}) | |
169 | precompile(Tuple{typeof(Base.getindex), Array{Base.BitArray{2}, 1}, Int64}) | |
170 | precompile(Tuple{typeof(Base.getindex), Array{Base.Dict{Int64, Int64}, 1}, Int64}) | |
171 | precompile(Tuple{typeof(Base.getindex), Array{Base.Dict{String, Any}, 1}, Int64}) | |
172 | precompile(Tuple{typeof(Base.getindex), Array{Base.UUID, 1}, Int64}) | |
173 | precompile(Tuple{typeof(Base.getindex), Array{Base.VersionNumber, 1}, Base.BitArray{1}}) | |
174 | precompile(Tuple{typeof(Base.getindex), Array{Int64, 1}, Int64}) | |
175 | precompile(Tuple{typeof(Base.getindex), Base.BitArray{1}, Base.UnitRange{Int64}}) | |
176 | precompile(Tuple{typeof(Base.getindex), Base.BitArray{2}, Base.BitArray{1}, Base.BitArray{1}}) | |
177 | precompile(Tuple{typeof(Base.getindex), Base.Dict{Int64, Int64}, Int64}) | |
178 | precompile(Tuple{typeof(Base.getindex), Base.Dict{String, Base.UUID}, String}) | |
179 | precompile(Tuple{typeof(Base.getindex), Base.Dict{Symbol, Function}, Symbol}) | |
180 | precompile(Tuple{typeof(Base.getindex), NamedTuple{(:indent, :region_active), Tuple{Int64, Bool}}, Symbol}) | |
181 | precompile(Tuple{typeof(Base.getindex), NamedTuple{(:prompt_prefix, :prompt_suffix, :complete, :sticky), Tuple{String, String, Pkg.REPLMode.PkgCompletionProvider, Bool}}, Symbol}) | |
182 | precompile(Tuple{typeof(Base.getindex), NamedTuple{(:prompt_prefix, :prompt_suffix, :repl, :complete, :on_enter), Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}, Symbol}) | |
183 | precompile(Tuple{typeof(Base.getindex), Pkg.TOML.Table, String}) | |
184 | precompile(Tuple{typeof(Base.getindex), Type{Pkg.Types.VersionRange}, Pkg.Pkg2.Pkg2Types.VersionInterval}) | |
185 | precompile(Tuple{typeof(Base.getproperty), Pkg.TOML.Table, Symbol}) | |
186 | precompile(Tuple{typeof(Base.getproperty), Pkg.Types.PackageSpec, Symbol}) | |
187 | precompile(Tuple{typeof(Base.getproperty), REPL.Terminals.TerminalBuffer, Symbol}) | |
188 | precompile(Tuple{typeof(Base.hash), Tuple{String, UInt64}, UInt64}) | |
189 | precompile(Tuple{typeof(Base.hash), Tuple{String}, UInt64}) | |
190 | precompile(Tuple{typeof(Base.haskey), Base.Dict{Base.UUID, Base.Dict{K, V} where V where K}, Base.UUID}) | |
191 | precompile(Tuple{typeof(Base.haskey), Base.Dict{String, Base.UUID}, String}) | |
192 | precompile(Tuple{typeof(Base.haskey), Base.Dict{String, Pkg.Types.VersionSpec}, String}) | |
193 | precompile(Tuple{typeof(Base.haskey), NamedTuple{(:indent, :region_active), Tuple{Int64, Bool}}, Symbol}) | |
194 | precompile(Tuple{typeof(Base.haskey), NamedTuple{(:prompt_prefix, :prompt_suffix, :complete, :sticky), Tuple{String, String, Pkg.REPLMode.PkgCompletionProvider, Bool}}, Symbol}) | |
195 | precompile(Tuple{typeof(Base.haskey), NamedTuple{(:prompt_prefix, :prompt_suffix, :repl, :complete, :on_enter), Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}, Symbol}) | |
196 | precompile(Tuple{typeof(Base.haskey), Pkg.TOML.Table, String}) | |
197 | precompile(Tuple{typeof(Base.ident_cmp), Tuple{String, UInt64}, Tuple{String, UInt64}}) | |
198 | precompile(Tuple{typeof(Base.ident_cmp), Tuple{String}, Tuple{String}}) | |
199 | precompile(Tuple{typeof(Base.ident_cmp), Tuple{}, Tuple{}}) | |
200 | precompile(Tuple{typeof(Base.identity), Int64}) | |
201 | precompile(Tuple{typeof(Base.in), Base.UUID, Array{Base.UUID, 1}}) | |
202 | precompile(Tuple{typeof(Base.in), Base.VersionNumber, Pkg.Types.VersionSpec}) | |
203 | precompile(Tuple{typeof(Base.in), String, Array{String, 1}}) | |
204 | precompile(Tuple{typeof(Base.in), String, Base.KeySet{String, Base.Dict{String, Any}}}) | |
205 | precompile(Tuple{typeof(Base.in), String, Base.KeySet{String, Base.Dict{String, Base.Dict{String, Pkg.REPLMode.CommandSpec}}}}) | |
206 | precompile(Tuple{typeof(Base.indexed_iterate), Base.Pair{Any, Any}, Int64, Int64}) | |
207 | precompile(Tuple{typeof(Base.indexed_iterate), Base.Pair{Any, Any}, Int64}) | |
208 | precompile(Tuple{typeof(Base.indexed_iterate), Base.Pair{String, Any}, Int64, Int64}) | |
209 | precompile(Tuple{typeof(Base.indexed_iterate), Base.Pair{String, Any}, Int64}) | |
210 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Char, Bool}, Int64, Int64}) | |
211 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Char, Bool}, Int64}) | |
212 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{String, Array{String, 1}, Array{String, 1}}, Int64, Int64}) | |
213 | precompile(Tuple{typeof(Base.indexed_iterate), Tuple{String, Array{String, 1}, Array{String, 1}}, Int64}) | |
214 | precompile(Tuple{typeof(Base.input_color)}) | |
215 | precompile(Tuple{typeof(Base.invokelatest), typeof(Pkg.REPLMode.do_status!), Base.Dict{Symbol, Any}, Array{String, 1}, Base.Dict{Symbol, Any}}) | |
216 | precompile(Tuple{typeof(Base.isempty), Array{Base.Dict{String, Any}, 1}}) | |
217 | precompile(Tuple{typeof(Base.isempty), Array{Base.UUID, 1}}) | |
218 | precompile(Tuple{typeof(Base.isempty), Base.Dict{String, Any}}) | |
219 | precompile(Tuple{typeof(Base.isempty), Base.Dict{String, String}}) | |
220 | precompile(Tuple{typeof(Base.isempty), NamedTuple{(:mode,), Tuple{Symbol}}}) | |
221 | precompile(Tuple{typeof(Base.isopen), Base.Channel{Any}}) | |
222 | precompile(Tuple{typeof(Base.iterate), Array{Base.Dict{String, Any}, 1}, Int64}) | |
223 | precompile(Tuple{typeof(Base.iterate), Array{Base.Dict{String, Any}, 1}}) | |
224 | precompile(Tuple{typeof(Base.iterate), Array{Base.UUID, 1}, Int64}) | |
225 | precompile(Tuple{typeof(Base.iterate), Array{Base.UUID, 1}}) | |
226 | precompile(Tuple{typeof(Base.iterate), Base.Channel{Any}}) | |
227 | precompile(Tuple{typeof(Base.iterate), Base.Dict{Any, Any}, Int64}) | |
228 | precompile(Tuple{typeof(Base.iterate), Base.Dict{Any, Any}}) | |
229 | precompile(Tuple{typeof(Base.iterate), Base.Dict{String, Any}, Int64}) | |
230 | precompile(Tuple{typeof(Base.iterate), Base.Dict{String, Any}}) | |
231 | precompile(Tuple{typeof(Base.iterate), Tuple{Base.BitArray{1}}, Int64}) | |
232 | precompile(Tuple{typeof(Base.iterate), Tuple{Base.BitArray{1}}}) | |
233 | precompile(Tuple{typeof(Base.join), Base.GenericIOBuffer{Array{UInt8, 1}}, Tuple{String}, Char}) | |
234 | precompile(Tuple{typeof(Base.join), Base.GenericIOBuffer{Array{UInt8, 1}}, Tuple{Symbol, Symbol}, String}) | |
235 | precompile(Tuple{typeof(Base.join), Base.GenericIOBuffer{Array{UInt8, 1}}, Tuple{UInt32, UInt32, UInt32}, Char}) | |
236 | precompile(Tuple{typeof(Base.join), Base.GenericIOBuffer{Array{UInt8, 1}}, Tuple{UInt32, UInt32}, Char}) | |
237 | precompile(Tuple{typeof(Base.join), Tuple{Symbol, Symbol}, String}) | |
238 | precompile(Tuple{typeof(Base.keys), Base.Dict{String, Any}}) | |
239 | precompile(Tuple{typeof(Base.keys), Base.Dict{String, Base.Dict{String, Pkg.REPLMode.CommandSpec}}}) | |
240 | precompile(Tuple{typeof(Base.lastindex), Base.BitArray{1}}) | |
241 | precompile(Tuple{typeof(Base.length), Array{Array{Base.BitArray{2}, 1}, 1}}) | |
242 | precompile(Tuple{typeof(Base.length), Array{Array{Base.VersionNumber, 1}, 1}}) | |
243 | precompile(Tuple{typeof(Base.length), Array{Array{Int64, 1}, 1}}) | |
244 | precompile(Tuple{typeof(Base.length), Array{Base.BitArray{1}, 1}}) | |
245 | precompile(Tuple{typeof(Base.length), Array{Base.Dict{Base.VersionNumber, Int64}, 1}}) | |
246 | precompile(Tuple{typeof(Base.length), Array{Base.Dict{Int64, Int64}, 1}}) | |
247 | precompile(Tuple{typeof(Base.length), Array{Base.Dict{String, Any}, 1}}) | |
248 | precompile(Tuple{typeof(Base.length), Array{Base.UUID, 1}}) | |
249 | precompile(Tuple{typeof(Base.length), Array{Int64, 1}}) | |
250 | precompile(Tuple{typeof(Base.length), Base.BitArray{1}}) | |
251 | precompile(Tuple{typeof(Base.length), Base.Dict{Base.UUID, Int64}}) | |
252 | precompile(Tuple{typeof(Base.length), Base.Dict{Base.UUID, Pkg.GraphType.ResolveLogEntry}}) | |
253 | precompile(Tuple{typeof(Base.length), Base.Dict{String, Any}}) | |
254 | precompile(Tuple{typeof(Base.map), Type{Base.UUID}, Base.ValueIterator{Base.Dict{String, Any}}}) | |
255 | precompile(Tuple{typeof(Base.map), Type{Base.UUID}, Base.ValueIterator{Base.Dict{String, String}}}) | |
256 | precompile(Tuple{typeof(Base.map), typeof(Base.close), Array{LibGit2.GitAnnotated, 1}}) | |
257 | precompile(Tuple{typeof(Base.mapreduce_first), typeof(Base.identity), typeof(Base.add_sum), Int64}) | |
258 | precompile(Tuple{typeof(Base.match), Base.Regex, String}) | |
259 | precompile(Tuple{typeof(Base.merge!), Base.Dict{String, Any}, Base.Dict{String, Any}}) | |
260 | precompile(Tuple{typeof(Base.merge), Base.Dict{String, Any}, Base.Dict{String, String}}) | |
261 | precompile(Tuple{typeof(Base.merge), NamedTuple{(), Tuple{}}, Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}) | |
262 | precompile(Tuple{typeof(Base.merge), NamedTuple{(), Tuple{}}, NamedTuple{(:mode,), Tuple{Symbol}}}) | |
263 | precompile(Tuple{typeof(Base.merge), NamedTuple{(:payload,), Tuple{Base.Dict{Symbol, Any}}}, NamedTuple{(:transfer_progress, :credentials), Tuple{Ptr{Nothing}, Ptr{Nothing}}}}) | |
264 | precompile(Tuple{typeof(Base.merge_names), Tuple{Symbol, Symbol, Symbol}, Tuple{Symbol}}) | |
265 | precompile(Tuple{typeof(Base.merge_names), Tuple{Symbol, Symbol}, Tuple{Symbol, Symbol}}) | |
266 | precompile(Tuple{typeof(Base.merge_names), Tuple{Symbol, Symbol}, Tuple{Symbol}}) | |
267 | precompile(Tuple{typeof(Base.merge_names), Tuple{Symbol}, Tuple{Symbol, Symbol}}) | |
268 | precompile(Tuple{typeof(Base.merge_names), Tuple{Symbol}, Tuple{Symbol}}) | |
269 | precompile(Tuple{typeof(Base.merge_names), Tuple{Symbol}, Tuple{}}) | |
270 | precompile(Tuple{typeof(Base.notify_error), Base.Channel{Any}, Base.InvalidStateException}) | |
271 | precompile(Tuple{typeof(Base.peek), Base.IOStream}) | |
272 | precompile(Tuple{typeof(Base.prepend!), Array{Base.Dict{Any, Any}, 1}, Array{Base.Dict{Any, Any}, 1}}) | |
273 | precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, Base.SubString{String}}) | |
274 | precompile(Tuple{typeof(Base.print), Base.GenericIOBuffer{Array{UInt8, 1}}, Pkg.Types.VersionSpec}) | |
275 | precompile(Tuple{typeof(Base.print), Base.IOStream, String, String, String, Char}) | |
276 | precompile(Tuple{typeof(Base.print), Base.TTY, String, String, Char}) | |
277 | precompile(Tuple{typeof(Base.promote_eltype), Base.KeySet{Base.UUID, Base.Dict{Base.UUID, Pkg.Types.VersionSpec}}}) | |
278 | precompile(Tuple{typeof(Base.push!), Array{Base.UUID, 1}, Base.UUID}) | |
279 | precompile(Tuple{typeof(Base.push!), Array{Int64, 1}, Int64}) | |
280 | precompile(Tuple{typeof(Base.push!), Array{Pkg.Types.VersionRange, 1}, Pkg.Types.VersionRange}) | |
281 | precompile(Tuple{typeof(Base.push!), Array{Tuple{Base.UUID, String}, 1}, Tuple{Base.UUID, String}}) | |
282 | precompile(Tuple{typeof(Base.push!), Base.Set{Base.VersionNumber}, Base.VersionNumber}) | |
283 | precompile(Tuple{typeof(Base.push!), Base.Set{Symbol}, Symbol}) | |
284 | precompile(Tuple{typeof(Base.push!), Pkg.GraphType.ResolveLogEntry, Tuple{Nothing, String}}) | |
285 | precompile(Tuple{typeof(Base.push!), Pkg.GraphType.ResolveLogEntry, Tuple{Pkg.GraphType.ResolveLogEntry, String}}) | |
286 | precompile(Tuple{typeof(Base.put!), Base.Channel{Any}, Tuple{String, Array{String, 1}, Array{String, 1}}}) | |
287 | precompile(Tuple{typeof(Base.rethrow), Base.InvalidStateException}) | |
288 | precompile(Tuple{typeof(Base.rstrip), String}) | |
289 | precompile(Tuple{typeof(Base.seek), Base.IOStream, Int64}) | |
290 | precompile(Tuple{typeof(Base.setdiff!), Base.Set{Base.UUID}, Array{Base.UUID, 1}}) | |
291 | precompile(Tuple{typeof(Base.setindex!), Array{Base.BitArray{1}, 1}, Base.BitArray{1}, Int64}) | |
292 | precompile(Tuple{typeof(Base.setindex!), Base.BitArray{1}, Bool, Int64}) | |
293 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Base.UUID, Base.Dict{K, V} where V where K}, Base.Dict{String, Any}, Base.UUID}) | |
294 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Base.UUID, Int64}, Int64, Base.UUID}) | |
295 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Base.UUID, Pkg.Types.VersionSpec}, Pkg.Types.VersionSpec, Base.UUID}) | |
296 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Base.UUID, String}, String, Base.UUID}) | |
297 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Base.VersionNumber, Base.SHA1}, Base.SHA1, Base.VersionNumber}) | |
298 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Int64, Int64}, Int64, Int64}) | |
299 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{String, Any}, Array{Any, 1}, String}) | |
300 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{String, Any}, Array{Base.Dict{String, Any}, 1}, String}) | |
301 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{String, Any}, Array{String, 1}, String}) | |
302 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{String, Any}, Base.Dict{Any, Any}, String}) | |
303 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{String, Any}, Base.Dict{String, String}, String}) | |
304 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{String, Any}, Base.UUID, String}) | |
305 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{String, Base.UUID}, Base.UUID, String}) | |
306 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{String, Pkg.Types.VersionSpec}, Pkg.Types.VersionSpec, String}) | |
307 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Symbol, Any}, LibGit2.CredentialPayload, Symbol}) | |
308 | precompile(Tuple{typeof(Base.setindex!), Base.Dict{Symbol, Any}, Pkg.GitTools.MiniProgressBar, Symbol}) | |
309 | precompile(Tuple{typeof(Base.setindex!), Base.EnvDict, String, String}) | |
310 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.Graph, Symbol, Array{Array{Base.BitArray{2}, 1}, 1}}) | |
311 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.Graph, Symbol, Array{Array{Int64, 1}, 1}}) | |
312 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.Graph, Symbol, Array{Base.BitArray{1}, 1}}) | |
313 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.Graph, Symbol, Array{Int64, 1}}) | |
314 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.GraphData, Symbol, Array{Array{Base.VersionNumber, 1}, 1}}) | |
315 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.GraphData, Symbol, Array{Base.Dict{Base.VersionNumber, Int64}, 1}}) | |
316 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.GraphData, Symbol, Array{Base.UUID, 1}}) | |
317 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.GraphData, Symbol, Array{Int64, 1}}) | |
318 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.GraphData, Symbol, Base.Dict{Base.UUID, Int64}}) | |
319 | precompile(Tuple{typeof(Base.setproperty!), Pkg.GraphType.ResolveLog, Symbol, Base.Dict{Base.UUID, Pkg.GraphType.ResolveLogEntry}}) | |
320 | precompile(Tuple{typeof(Base.setproperty!), Pkg.REPLMode.Statement, Symbol, Pkg.REPLMode.CommandSpec}) | |
321 | precompile(Tuple{typeof(Base.setproperty!), Pkg.Types.PackageSpec, Symbol, Base.UUID}) | |
322 | precompile(Tuple{typeof(Base.setproperty!), Pkg.Types.PackageSpec, Symbol, Base.VersionNumber}) | |
323 | precompile(Tuple{typeof(Base.setproperty!), Pkg.Types.PackageSpec, Symbol, String}) | |
324 | precompile(Tuple{typeof(Base.similar), Array{Base.Dict{String, Any}, 1}}) | |
325 | precompile(Tuple{typeof(Base.skip_deleted_floor!), Base.Dict{String, Any}}) | |
326 | precompile(Tuple{typeof(Base.string), String, Base.SubString{String}, String, String}) | |
327 | precompile(Tuple{typeof(Base.string), Symbol, Int64}) | |
328 | precompile(Tuple{typeof(Base.strip), Base.SubString{String}}) | |
329 | precompile(Tuple{typeof(Base.structdiff), NamedTuple{(:indent, :region_active), Tuple{Int64, Bool}}, Type{NamedTuple{(:indent, :region_active), T} where T<:Tuple}}) | |
330 | precompile(Tuple{typeof(Base.structdiff), NamedTuple{(:prompt_prefix, :prompt_suffix, :complete, :sticky), Tuple{String, String, Pkg.REPLMode.PkgCompletionProvider, Bool}}, Type{NamedTuple{(:prompt_prefix, :prompt_suffix, :keymap_dict, :repl, :complete, :on_enter, :on_done, :hist, :sticky), T} where T<:Tuple}}) | |
331 | precompile(Tuple{typeof(Base.structdiff), NamedTuple{(:prompt_prefix, :prompt_suffix, :repl, :complete, :on_enter), Tuple{String, typeof(Base.input_color), REPL.LineEditREPL, REPL.REPLCompletionProvider, typeof(REPL.return_callback)}}, Type{NamedTuple{(:prompt_prefix, :prompt_suffix, :keymap_dict, :repl, :complete, :on_enter, :on_done, :hist, :sticky), T} where T<:Tuple}}) | |
332 | precompile(Tuple{typeof(Base.sum), Array{Int64, 1}}) | |
333 | precompile(Tuple{typeof(Base.sym_in), Symbol, Tuple{Symbol, Symbol}}) | |
334 | precompile(Tuple{typeof(Base.sym_in), Symbol, Tuple{Symbol}}) | |
335 | precompile(Tuple{typeof(Base.sym_in), Symbol, Tuple{}}) | |
336 | precompile(Tuple{typeof(Base.to_indices), Base.BitArray{2}, Tuple{Base.OneTo{Int64}}, Tuple{Int64}}) | |
337 | precompile(Tuple{typeof(Base.trues), Int64}) | |
338 | precompile(Tuple{typeof(Base.union!), Base.Set{Base.UUID}, Base.KeySet{Base.UUID, Base.Dict{Base.UUID, Pkg.Types.Fixed}}}) | |
339 | precompile(Tuple{typeof(Base.union!), Base.Set{Base.UUID}, Base.KeySet{Base.UUID, Base.Dict{Base.UUID, Pkg.Types.VersionSpec}}}) | |
340 | precompile(Tuple{typeof(Base.unique!), Array{Base.UUID, 1}}) | |
341 | precompile(Tuple{typeof(Base.unique!), Array{String, 1}}) | |
342 | precompile(Tuple{typeof(Base.values), Base.Dict{String, Any}}) | |
343 | precompile(Tuple{typeof(Base.values), Base.Dict{String, String}}) | |
344 | precompile(Tuple{typeof(Base.vcat), Base.BitArray{1}, Base.BitArray{1}}) | |
345 | precompile(Tuple{typeof(Base.vcat), Base.BitArray{1}}) | |
346 | precompile(Tuple{typeof(Base.vcat), Base.BitArray{2}, Base.BitArray{2}, Base.BitArray{2}, Base.BitArray{2}}) | |
347 | precompile(Tuple{typeof(Base.vcat), Base.BitArray{2}, Base.BitArray{2}}) | |
348 | precompile(Tuple{typeof(Base.vect), Base.Cmd, Base.Cmd}) | |
349 | precompile(Tuple{typeof(Base.vect), Base.VersionNumber}) | |
350 | precompile(Tuple{typeof(Base.vect), Nothing}) | |
351 | precompile(Tuple{typeof(Base.write), Base.TTY, Array{UInt8, 1}}) | |
352 | precompile(Tuple{typeof(Base.write), REPL.Terminals.TTYTerminal, Array{UInt8, 1}}) | |
353 | precompile(Tuple{typeof(Core.Compiler.eltype), Type{Array{Base.BitArray{2}, 1}}}) | |
354 | precompile(Tuple{typeof(Core.Compiler.eltype), Type{Array{Base.KeySet{Base.UUID, Base.Dict{Base.UUID, Pkg.Types.VersionSpec}}, 1}}}) | |
355 | precompile(Tuple{typeof(Core.Compiler.eltype), Type{Array{Pkg.Pkg2.Pkg2Types.VersionInterval, 1}}}) | |
356 | precompile(Tuple{typeof(Core.Compiler.eltype), Type{Array{UInt32, 1}}}) | |
357 | precompile(Tuple{typeof(Core.Compiler.eltype), Type{Array{UInt8, 1}}}) | |
358 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), Nothing}, Int64}) | |
359 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.invokelatest), typeof(Pkg.REPLMode.do_help!)}, Int64}) | |
360 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.open), typeof(Pkg.Pkg2.Reqs.read)}, Int64}) | |
361 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, typeof(Base.open), typeof(Pkg.TOML.parse)}, Int64}) | |
362 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.IteratorsMD.CartesianIndex{0}}, Int64}) | |
363 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Missing, Int64}, Int64}) | |
364 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Missing}, Int64}) | |
365 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Base.Val{1}, typeof(Base.cat_t), Union}, Int64}) | |
366 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Bool, typeof(Pkg.Types.parse_toml)}, Int64}) | |
367 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Int64, Tuple{Int64, Tuple{Int64, Tuple{Int64, Tuple{}}}}}, Int64}) | |
368 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{NamedTuple{(:dims,), Tuple{Base.Val{1}}}, typeof(Base.cat_t), Union}, Int64}) | |
369 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Nothing, Int64, typeof(Base.sprint), typeof(Base.showerror)}, Int64}) | |
370 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Nothing, Int64, typeof(Base.sprint), typeof(Pkg.GraphType.showlog)}, Int64}) | |
371 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{Pkg.REPLMode.CommandKind, Int64}, Int64}) | |
372 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.:(!))}, Int64}) | |
373 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.:(&))}, Int64}) | |
374 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.:(+))}, Int64}) | |
375 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.:(-))}, Int64}) | |
376 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.:(==))}, Int64}) | |
377 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.:(>))}, Int64}) | |
378 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.:(~))}, Int64}) | |
379 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.Unicode.lowercase)}, Int64}) | |
380 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.abs)}, Int64}) | |
381 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.first)}, Int64}) | |
382 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.identity)}, Int64}) | |
383 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Base.maximum)}, Int64}) | |
384 | precompile(Tuple{typeof(Core.Compiler.getindex), Tuple{typeof(Pkg.BinaryProvider.parse_tar_list)}, Int64}) | |
385 | precompile(Tuple{typeof(Pkg.Display.filter_manifest), Pkg.Display.InProject{Base.Dict{String, Any}}, Base.Dict{String, Any}}) | |
386 | precompile(Tuple{typeof(Pkg.Display.in_project), Base.Dict{String, Any}}) | |
387 | precompile(Tuple{typeof(Pkg.Display.manifest_diff), Pkg.Types.Context, Base.Dict{String, Any}, Base.Dict{String, Any}}) | |
388 | precompile(Tuple{typeof(Pkg.Display.name_ver_info), Base.Dict{String, Any}}) | |
389 | precompile(Tuple{typeof(Pkg.Display.not_in_project), Base.Dict{String, Any}}) | |
390 | precompile(Tuple{typeof(Pkg.Display.print_diff), Base.TTY, Pkg.Types.Context, Array{Pkg.Display.DiffEntry, 1}, Bool}) | |
391 | precompile(Tuple{typeof(Pkg.Operations.load_package_data_raw), Type{Base.UUID}, String}) | |
392 | precompile(Tuple{typeof(Pkg.REPLMode.do_add!), Base.Dict{Symbol, Any}, Array{Pkg.Types.PackageSpec, 1}, Base.Dict{Symbol, Any}}) | |
393 | precompile(Tuple{typeof(Pkg.REPLMode.do_status!), Base.Dict{Symbol, Any}, Array{String, 1}, Base.Dict{Symbol, Any}}) | |
394 | precompile(Tuple{typeof(Pkg.REPLMode.promptf)}) | |
395 | precompile(Tuple{typeof(Pkg.TOML.SOME), Array{String, 1}}) | |
396 | precompile(Tuple{typeof(Pkg.TOML.SOME), Pkg.TOML.Table}) | |
397 | precompile(Tuple{typeof(Pkg.TOML.insertpair), Pkg.TOML.Parser{Base.IOStream}, Pkg.TOML.Table, String, Array{String, 1}, Int64}) | |
398 | precompile(Tuple{typeof(Pkg.TOML.insertpair), Pkg.TOML.Parser{Base.IOStream}, Pkg.TOML.Table, String, Pkg.TOML.Table, Int64}) | |
399 | precompile(Tuple{typeof(Pkg.TOML.is_array_of_tables), Array{Base.Dict{String, Any}, 1}}) | |
400 | precompile(Tuple{typeof(Pkg.TOML.is_array_of_tables), Array{String, 1}}) | |
401 | precompile(Tuple{typeof(Pkg.TOML.is_array_of_tables), String}) | |
402 | precompile(Tuple{typeof(Pkg.TOML.is_tabular), Array{Base.Dict{String, Any}, 1}}) | |
403 | precompile(Tuple{typeof(Pkg.TOML.is_tabular), Array{String, 1}}) | |
404 | precompile(Tuple{typeof(Pkg.TOML.is_tabular), Base.Dict{String, Any}}) | |
405 | precompile(Tuple{typeof(Pkg.TOML.is_tabular), String}) | |
406 | precompile(Tuple{typeof(Pkg.TOML.parsefile), String}) | |
407 | precompile(Tuple{typeof(Pkg.Types.printpkgstyle), Base.TTY, Symbol, String}) | |
408 | precompile(Tuple{typeof(Pkg.Types.semver_interval), Base.RegexMatch}) | |
409 | precompile(Tuple{typeof(Pkg.Types.write_env_usage), String}) | |
410 | precompile(Tuple{typeof(REPL.LineEdit._clear_input_area), REPL.Terminals.TerminalBuffer, REPL.LineEdit.InputAreaState}) | |
411 | precompile(Tuple{typeof(REPL.LineEdit.add_history), REPL.REPLHistoryProvider, REPL.LineEdit.PromptState}) | |
412 | precompile(Tuple{typeof(REPL.LineEdit.clear_input_area), REPL.Terminals.TerminalBuffer, REPL.LineEdit.PromptState}) | |
413 | precompile(Tuple{typeof(REPL.LineEdit.edit_abort), REPL.LineEdit.MIState, Bool}) | |
414 | precompile(Tuple{typeof(REPL.LineEdit.edit_insert), REPL.LineEdit.MIState, String}) | |
415 | precompile(Tuple{typeof(REPL.LineEdit.edit_insert), REPL.LineEdit.PromptState, String}) | |
416 | precompile(Tuple{typeof(REPL.LineEdit.fixup_keymaps!), Base.Dict{Char, Any}, Int64, Char, Nothing}) | |
417 | precompile(Tuple{typeof(REPL.LineEdit.init_state), REPL.Terminals.TTYTerminal, REPL.LineEdit.Prompt}) | |
418 | precompile(Tuple{typeof(REPL.LineEdit.move_input_end), REPL.LineEdit.MIState}) | |
419 | precompile(Tuple{typeof(REPL.LineEdit.normalize_key), Int64}) | |
420 | precompile(Tuple{typeof(REPL.LineEdit.normalize_key), String}) | |
421 | precompile(Tuple{typeof(REPL.LineEdit.on_enter), REPL.LineEdit.MIState}) | |
422 | precompile(Tuple{typeof(REPL.LineEdit.postprocess!), Base.Dict{Char, Any}}) | |
423 | precompile(Tuple{typeof(REPL.LineEdit.prompt_string), String}) | |
424 | precompile(Tuple{typeof(REPL.LineEdit.push_undo), REPL.LineEdit.PromptState, Bool}) | |
425 | precompile(Tuple{typeof(REPL.LineEdit.refresh_line), REPL.LineEdit.PromptState, REPL.Terminals.TTYTerminal}) | |
426 | precompile(Tuple{typeof(REPL.LineEdit.refresh_multi_line), REPL.Terminals.TerminalBuffer, REPL.LineEdit.PromptState}) | |
427 | precompile(Tuple{typeof(REPL.LineEdit.state), REPL.LineEdit.MIState, REPL.LineEdit.Prompt}) | |
428 | precompile(Tuple{typeof(REPL.LineEdit.update_key_repeats), REPL.LineEdit.MIState, Array{Char, 1}}) | |
429 | precompile(Tuple{typeof(REPL.LineEdit.write_prompt), REPL.Terminals.TerminalBuffer, REPL.LineEdit.Prompt}) | |
430 | precompile(Tuple{typeof(REPL.LineEdit.write_prompt), REPL.Terminals.TerminalBuffer, String}) |
65 | 65 | # `2.3.4` can be joined with `2.3.5` etc. |
66 | 66 | |
67 | 67 | function isjoinable(up::VersionBound, lo::VersionBound) |
68 | up.n == 0 && up.lo == 0 && return true | |
68 | up.n == 0 && lo.n == 0 && return true | |
69 | 69 | if up.n == lo.n |
70 | 70 | n = up.n |
71 | 71 | for i = 1:(n - 1) |
87 | 87 | @test_throws ErrorException semver_spec("^^0.2.3") |
88 | 88 | @test_throws ErrorException semver_spec("^^0.2.3.4") |
89 | 89 | @test_throws ErrorException semver_spec("0.0.0") |
90 | ||
91 | @test Pkg.Types.isjoinable(Pkg.Types.VersionBound((1,5)), Pkg.Types.VersionBound((1,6))) | |
92 | @test !(Pkg.Types.isjoinable(Pkg.Types.VersionBound((1,5)), Pkg.Types.VersionBound((1,6,0)))) | |
90 | 93 | end |
91 | 94 | |
92 | 95 | # TODO: Should rewrite these tests not to rely on internals like field names |
143 | 146 | # VersionRange |
144 | 147 | Pkg.add(PackageSpec(TEST_PKG.name, VersionSpec(VersionRange("0.3.0-0.3.2")))) |
145 | 148 | @test Pkg.API.__installed()[TEST_PKG.name] == v"0.3.2" |
149 | # Check that adding another packages doesn't upgrade other packages | |
150 | Pkg.add("Test") | |
151 | @test Pkg.API.__installed()[TEST_PKG.name] == v"0.3.2" | |
146 | 152 | Pkg.update(; level = UPLEVEL_PATCH) |
147 | 153 | @test Pkg.API.__installed()[TEST_PKG.name] == v"0.3.3" |
148 | 154 | Pkg.update(; level = UPLEVEL_MINOR) |
152 | 158 | |
153 | 159 | @testset "testing" begin |
154 | 160 | # TODO: Check that preview = true doesn't actually execute the test |
155 | # TODO: Test-only dependencies | |
156 | 161 | Pkg.add(TEST_PKG.name) |
157 | 162 | Pkg.test(TEST_PKG.name; coverage=true) |
158 | 163 | pkgdir = Base.locate_package(Base.PkgId(TEST_PKG.uuid, TEST_PKG.name)) |
250 | 255 | end |
251 | 256 | end |
252 | 257 | end |
258 | mktempdir() do devdir | |
259 | withenv("JULIA_PKG_DEVDIR" => devdir) do | |
260 | try | |
261 | https_url = "https://github.com/JuliaLang/Example.jl.git" | |
262 | ssh_url = "ssh://git@github.com/JuliaLang/Example.jl.git" | |
263 | @test Pkg.GitTools.normalize_url(https_url) == https_url | |
264 | Pkg.setprotocol!("ssh") | |
265 | @test Pkg.GitTools.normalize_url(https_url) == ssh_url | |
266 | # TODO: figure out how to test this without | |
267 | # having to deploy a ssh key on github | |
268 | #Pkg.develop("Example") | |
269 | #@test isinstalled(TEST_PKG) | |
270 | finally | |
271 | Pkg.setprotocol!() | |
272 | end | |
273 | end | |
274 | end | |
253 | 275 | end |
254 | 276 | |
255 | 277 | @testset "check logging" begin |
413 | 435 | end |
414 | 436 | end |
415 | 437 | |
438 | temp_pkg_dir() do project_path; cd(project_path) do | |
439 | @testset "instantiating updated repo" begin | |
440 | tmp = mktempdir() | |
441 | cd(tmp) | |
442 | depo1 = mktempdir() | |
443 | depo2 = mktempdir() | |
444 | ||
445 | empty!(DEPOT_PATH) | |
446 | pushfirst!(DEPOT_PATH, depo1) | |
447 | LibGit2.close(LibGit2.clone("https://github.com/JuliaLang/Example.jl", "Example.jl")) | |
448 | mkdir("machine1") | |
449 | cd("machine1") | |
450 | Pkg.activate(".") | |
451 | Pkg.add(PackageSpec(path="../Example.jl")) | |
452 | cd("..") | |
453 | cp("machine1", "machine2") | |
454 | empty!(DEPOT_PATH) | |
455 | pushfirst!(DEPOT_PATH, depo2) | |
456 | cd("machine2") | |
457 | Pkg.activate(".") | |
458 | Pkg.instantiate() | |
459 | cd("..") | |
460 | cd("Example.jl") | |
461 | open("README.md", "a") do io | |
462 | print(io, "Hello") | |
463 | end | |
464 | LibGit2.with(LibGit2.GitRepo(".")) do repo | |
465 | LibGit2.add!(repo, "*") | |
466 | LibGit2.commit(repo, "changes"; author=TEST_SIG, committer=TEST_SIG) | |
467 | end | |
468 | cd("../machine1") | |
469 | empty!(DEPOT_PATH) | |
470 | pushfirst!(DEPOT_PATH, depo1) | |
471 | Pkg.activate(".") | |
472 | Pkg.update() | |
473 | cd("..") | |
474 | cp("machine1/Manifest.toml", "machine2/Manifest.toml"; force=true) | |
475 | cd("machine2") | |
476 | empty!(DEPOT_PATH) | |
477 | pushfirst!(DEPOT_PATH, depo2) | |
478 | Pkg.activate(".") | |
479 | Pkg.instantiate() | |
480 | end | |
481 | end end | |
482 | ||
416 | 483 | temp_pkg_dir() do project_path |
417 | 484 | cd(project_path) do |
418 | 485 | project = """ |
447 | 514 | end |
448 | 515 | end |
449 | 516 | |
517 | @testset "printing of stdlib paths, issue #605" begin | |
518 | path = Pkg.Types.stdlib_path("Test") | |
519 | @test Pkg.Types.pathrepr(path) == "`@stdlib/Test`" | |
520 | end | |
521 | ||
522 | ||
523 | temp_pkg_dir() do project_path | |
524 | @testset "Pkg.add should not mutate" begin | |
525 | package_names = ["JSON"] | |
526 | packages = PackageSpec.(package_names) | |
527 | Pkg.add(packages) | |
528 | @test [p.name for p in packages] == package_names | |
529 | end | |
530 | end | |
531 | ||
450 | 532 | include("repl.jl") |
451 | 533 | include("api.jl") |
452 | 534 |
2 | 2 | module REPLTests |
3 | 3 | |
4 | 4 | using Pkg |
5 | using Pkg.Types: manifest_info, EnvCache | |
5 | 6 | import Pkg.Types.PkgError |
6 | 7 | using UUIDs |
7 | 8 | using Test |
8 | 9 | import LibGit2 |
9 | 10 | |
10 | 11 | include("utils.jl") |
11 | ||
12 | const TEST_SIG = LibGit2.Signature("TEST", "TEST@TEST.COM", round(time()), 0) | |
13 | const TEST_PKG = (name = "Example", uuid = UUID("7876af07-990d-54b4-ab0e-23690620f79a")) | |
14 | 12 | |
15 | 13 | function git_init_package(tmp, path) |
16 | 14 | base = basename(path) |
67 | 65 | @test length(statement.arguments) == 1 |
68 | 66 | @test statement.arguments[1] == "dev" |
69 | 67 | statement = Pkg.REPLMode.parse("add git@github.com:JuliaLang/Example.jl.git")[1] |
70 | @test "add" in statement.command.names | |
68 | @test "add" == statement.command.canonical_name | |
71 | 69 | @test statement.arguments[1] == "git@github.com:JuliaLang/Example.jl.git" |
72 | 70 | statement = Pkg.REPLMode.parse("add git@github.com:JuliaLang/Example.jl.git#master")[1] |
73 | @test "add" in statement.command.names | |
71 | @test "add" == statement.command.canonical_name | |
74 | 72 | @test length(statement.arguments) == 2 |
75 | 73 | @test statement.arguments[1] == "git@github.com:JuliaLang/Example.jl.git" |
76 | 74 | @test statement.arguments[2] == "#master" |
77 | 75 | statement = Pkg.REPLMode.parse("add git@github.com:JuliaLang/Example.jl.git#c37b675")[1] |
78 | @test "add" in statement.command.names | |
76 | @test "add" == statement.command.canonical_name | |
79 | 77 | @test length(statement.arguments) == 2 |
80 | 78 | @test statement.arguments[1] == "git@github.com:JuliaLang/Example.jl.git" |
81 | 79 | @test statement.arguments[2] == "#c37b675" |
83 | 81 | @test statement.arguments[1] == "git@github.com:JuliaLang/Example.jl.git" |
84 | 82 | @test statement.arguments[2] == "@v0.5.0" |
85 | 83 | statement = Pkg.REPLMode.parse("add git@gitlab-fsl.jsc.näsan.guvv:drats/URGA2010.jl.git@0.5.0")[1] |
86 | @test "add" in statement.command.names | |
84 | @test "add" == statement.command.canonical_name | |
87 | 85 | @test length(statement.arguments) == 2 |
88 | 86 | @test statement.arguments[1] == "git@gitlab-fsl.jsc.näsan.guvv:drats/URGA2010.jl.git" |
89 | 87 | @test statement.arguments[2] == "@0.5.0" |
263 | 261 | pkg"activate Foo" # activate path Foo over deps Foo |
264 | 262 | @test Base.active_project() == joinpath(path, "Foo", "Project.toml") |
265 | 263 | pkg"activate ." |
266 | @test_logs (:info, r"new shared environment") pkg"activate --shared Foo" # activate shared Foo | |
264 | @test_logs (:info, r"activating new environment at ") pkg"activate --shared Foo" # activate shared Foo | |
267 | 265 | @test Base.active_project() == joinpath(Pkg.envdir(), "Foo", "Project.toml") |
268 | 266 | pkg"activate ." |
269 | 267 | rm("Foo"; force=true, recursive=true) |
270 | 268 | pkg"activate Foo" # activate path from developed Foo |
271 | 269 | @test Base.active_project() == joinpath(path, "modules", "Foo", "Project.toml") |
272 | 270 | pkg"activate ." |
273 | @test_logs (:info, r"new environment") pkg"activate ./Foo" # activate empty directory Foo (sidestep the developed Foo) | |
271 | @test_logs (:info, r"activating new environment at ") pkg"activate ./Foo" # activate empty directory Foo (sidestep the developed Foo) | |
274 | 272 | @test Base.active_project() == joinpath(path, "Foo", "Project.toml") |
275 | 273 | pkg"activate ." |
276 | @test_logs (:info, r"new environment") pkg"activate Bar" # activate empty directory Bar | |
274 | @test_logs (:info, r"activating new environment at ") pkg"activate Bar" # activate empty directory Bar | |
277 | 275 | @test Base.active_project() == joinpath(path, "Bar", "Project.toml") |
278 | 276 | pkg"activate ." |
279 | 277 | pkg"add Example" # non-deved deps should not be activated |
280 | @test_logs (:info, r"new environment") pkg"activate Example" | |
278 | @test_logs (:info, r"activating new environment at ") pkg"activate Example" | |
281 | 279 | @test Base.active_project() == joinpath(path, "Example", "Project.toml") |
282 | 280 | pkg"activate ." |
283 | 281 | cd(mkdir("tests")) |
310 | 308 | @test manifest["SubModule"][1]["path"] == joinpath("..", "SubModule") |
311 | 309 | end |
312 | 310 | |
311 | # path should not be relative when devdir() happens to be in project | |
312 | # unless user used dev --local. | |
313 | temp_pkg_dir() do depot | |
314 | cd(mktempdir()) do | |
315 | uuid = UUID("7876af07-990d-54b4-ab0e-23690620f79a") # Example | |
316 | pkg"activate ." | |
317 | withenv("JULIA_PKG_DEVDIR" => joinpath(pwd(), "dev")) do | |
318 | pkg"dev Example" | |
319 | @test manifest_info(EnvCache(), uuid)["path"] == joinpath(pwd(), "dev", "Example") | |
320 | pkg"dev --shared Example" | |
321 | @test manifest_info(EnvCache(), uuid)["path"] == joinpath(pwd(), "dev", "Example") | |
322 | pkg"dev --local Example" | |
323 | @test manifest_info(EnvCache(), uuid)["path"] == joinpath("dev", "Example") | |
324 | end | |
325 | end | |
326 | end | |
327 | ||
328 | # test relative dev paths (#490) without existing Project.toml | |
329 | temp_pkg_dir() do depot | |
330 | cd(mktempdir()) do | |
331 | pkg"activate NonExistent" | |
332 | withenv("USER" => "Test User") do | |
333 | pkg"generate Foo" | |
334 | end | |
335 | # this dev should not error even if NonExistent/Project.toml file is non-existent | |
336 | @test !isdir("NonExistent") | |
337 | pkg"dev Foo" | |
338 | manifest = Pkg.Types.Context().env.manifest | |
339 | @test manifest["Foo"][1]["path"] == joinpath("..", "Foo") | |
340 | end | |
341 | end | |
342 | ||
313 | 343 | # develop with --shared and --local |
314 | using Pkg.Types: manifest_info, EnvCache | |
315 | 344 | cd(mktempdir()) do |
316 | 345 | uuid = UUID("7876af07-990d-54b4-ab0e-23690620f79a") # Example |
317 | 346 | pkg"activate ." |
323 | 352 | @test manifest_info(EnvCache(), uuid)["path"] == joinpath("dev", "Example") |
324 | 353 | end |
325 | 354 | |
355 | @testset "parse completions" begin | |
356 | # meta options | |
357 | @test Pkg.REPLMode.parse("--pre"; for_completions=true) == (:meta, "--pre", nothing, true) | |
358 | @test Pkg.REPLMode.parse("--meta --pre"; for_completions=true) == (:meta, "--pre", nothing, true) | |
359 | @test Pkg.REPLMode.parse("--meta -"; for_completions=true) == (:meta, "-", nothing, true) | |
360 | @test Pkg.REPLMode.parse("--meta --"; for_completions=true) == (:meta, "--", nothing, true) | |
361 | # commands | |
362 | @test Pkg.REPLMode.parse("--preview"; for_completions=true) == (:cmd, "", nothing, true) | |
363 | @test Pkg.REPLMode.parse("--preview ad"; for_completions=true) == (:cmd, "ad", nothing, true) | |
364 | @test Pkg.REPLMode.parse("--meta --preview r"; for_completions=true) == (:cmd, "r", nothing, true) | |
365 | @test Pkg.REPLMode.parse("--preview reg"; for_completions=true) == (:cmd, "reg", nothing, true) | |
366 | # sub commands | |
367 | @test Pkg.REPLMode.parse("--preview package"; for_completions=true) == | |
368 | (:sub, "", "package", true) | |
369 | @test Pkg.REPLMode.parse("--preview package a"; for_completions=true) == | |
370 | (:sub, "a", "package", true) | |
371 | # options | |
372 | @test Pkg.REPLMode.parse("add -"; for_completions=true) == | |
373 | (:opt, "-", Pkg.REPLMode.super_specs["package"]["add"], true) | |
374 | @test Pkg.REPLMode.parse("up --m"; for_completions=true) == | |
375 | (:opt, "--m", Pkg.REPLMode.super_specs["package"]["up"], true) | |
376 | @test Pkg.REPLMode.parse("up --major --pro"; for_completions=true) == | |
377 | (:opt, "--pro", Pkg.REPLMode.super_specs["package"]["up"], true) | |
378 | @test Pkg.REPLMode.parse("foo --maj"; for_completions=true) === | |
379 | nothing | |
380 | # arguments | |
381 | @test Pkg.REPLMode.parse("up --major Ex"; for_completions=true) == | |
382 | (:arg, "Ex", Pkg.REPLMode.super_specs["package"]["up"], true) | |
383 | @test Pkg.REPLMode.parse("--preview up --major foo Ex"; for_completions=true) == | |
384 | (:arg, "Ex", Pkg.REPLMode.super_specs["package"]["up"], true) | |
385 | @test Pkg.REPLMode.parse("remove --manifest Ex"; for_completions=true) == | |
386 | (:arg, "Ex", Pkg.REPLMode.super_specs["package"]["remove"], false) | |
387 | end | |
388 | ||
326 | 389 | test_complete(s) = Pkg.REPLMode.completions(s,lastindex(s)) |
327 | 390 | apply_completion(str) = begin |
328 | 391 | c, r, s = test_complete(str) |
329 | @test s == true | |
330 | 392 | str[1:prevind(str, first(r))]*first(c) |
331 | 393 | end |
332 | 394 | |
333 | 395 | # Autocompletions |
334 | 396 | temp_pkg_dir() do project_path; cd(project_path) do |
335 | Pkg.Types.registries() | |
336 | pkg"activate ." | |
337 | c, r = test_complete("add Exam") | |
338 | @test "Example" in c | |
339 | c, r = test_complete("rm Exam") | |
340 | @test isempty(c) | |
341 | Pkg.REPLMode.pkgstr("develop $(joinpath(@__DIR__, "test_packages", "RequireDependency"))") | |
342 | ||
343 | c, r = test_complete("rm RequireDep") | |
344 | @test "RequireDependency" in c | |
345 | c, r = test_complete("rm -p RequireDep") | |
346 | @test "RequireDependency" in c | |
347 | c, r = test_complete("rm --project RequireDep") | |
348 | @test "RequireDependency" in c | |
349 | c, r = test_complete("rm Exam") | |
350 | @test isempty(c) | |
351 | c, r = test_complete("rm -p Exam") | |
352 | @test isempty(c) | |
353 | c, r = test_complete("rm --project Exam") | |
354 | @test isempty(c) | |
355 | ||
356 | c, r = test_complete("rm -m RequireDep") | |
357 | @test "RequireDependency" in c | |
358 | c, r = test_complete("rm --manifest RequireDep") | |
359 | @test "RequireDependency" in c | |
360 | c, r = test_complete("rm -m Exam") | |
361 | @test "Example" in c | |
362 | c, r = test_complete("rm --manifest Exam") | |
363 | @test "Example" in c | |
364 | ||
365 | c, r = test_complete("rm RequireDep") | |
366 | @test "RequireDependency" in c | |
367 | c, r = test_complete("rm Exam") | |
368 | @test isempty(c) | |
369 | c, r = test_complete("rm -m Exam") | |
370 | c, r = test_complete("rm -m Exam") | |
371 | @test "Example" in c | |
372 | ||
373 | pkg"add Example" | |
374 | c, r = test_complete("rm Exam") | |
375 | @test "Example" in c | |
376 | c, r = test_complete("add --man") | |
377 | @test "--manifest" in c | |
378 | c, r = test_complete("rem") | |
379 | @test "remove" in c | |
380 | @test apply_completion("rm E") == "rm Example" | |
381 | @test apply_completion("add Exampl") == "add Example" | |
382 | ||
383 | c, r = test_complete("preview r") | |
384 | @test "remove" in c | |
385 | c, r = test_complete("help r") | |
386 | @test "remove" in c | |
387 | @test !("rm" in c) | |
388 | ||
389 | c, r = test_complete("add REPL") | |
390 | # Filtered by version | |
391 | @test !("REPL" in c) | |
397 | @testset "tab completion" begin | |
398 | Pkg.Types.registries() | |
399 | pkg"activate ." | |
400 | c, r = test_complete("add Exam") | |
401 | @test "Example" in c | |
402 | c, r = test_complete("rm Exam") | |
403 | @test isempty(c) | |
404 | Pkg.REPLMode.pkgstr("develop $(joinpath(@__DIR__, "test_packages", "RequireDependency"))") | |
405 | ||
406 | c, r = test_complete("rm RequireDep") | |
407 | @test "RequireDependency" in c | |
408 | c, r = test_complete("rm -p RequireDep") | |
409 | @test "RequireDependency" in c | |
410 | c, r = test_complete("rm --project RequireDep") | |
411 | @test "RequireDependency" in c | |
412 | c, r = test_complete("rm Exam") | |
413 | @test isempty(c) | |
414 | c, r = test_complete("rm -p Exam") | |
415 | @test isempty(c) | |
416 | c, r = test_complete("rm --project Exam") | |
417 | @test isempty(c) | |
418 | ||
419 | c, r = test_complete("rm -m RequireDep") | |
420 | @test "RequireDependency" in c | |
421 | c, r = test_complete("rm --manifest RequireDep") | |
422 | @test "RequireDependency" in c | |
423 | c, r = test_complete("rm -m Exam") | |
424 | @test "Example" in c | |
425 | c, r = test_complete("rm --manifest Exam") | |
426 | @test "Example" in c | |
427 | ||
428 | c, r = test_complete("rm RequireDep") | |
429 | @test "RequireDependency" in c | |
430 | c, r = test_complete("rm Exam") | |
431 | @test isempty(c) | |
432 | c, r = test_complete("rm -m Exam") | |
433 | c, r = test_complete("rm -m Exam") | |
434 | @test "Example" in c | |
435 | ||
436 | pkg"add Example" | |
437 | c, r = test_complete("rm Exam") | |
438 | @test "Example" in c | |
439 | c, r = test_complete("up --man") | |
440 | @test "--manifest" in c | |
441 | c, r = test_complete("rem") | |
442 | @test "remove" in c | |
443 | @test apply_completion("rm E") == "rm Example" | |
444 | @test apply_completion("add Exampl") == "add Example" | |
445 | ||
446 | c, r = test_complete("preview r") | |
447 | @test "remove" in c | |
448 | c, r = test_complete("help r") | |
449 | @test "remove" in c | |
450 | @test !("rm" in c) | |
451 | ||
452 | c, r = test_complete("add REPL") | |
453 | # Filtered by version | |
454 | @test !("REPL" in c) | |
455 | ||
456 | mkdir("testdir") | |
457 | c, r = test_complete("add ") | |
458 | @test Sys.iswindows() ? ("testdir\\\\" in c) : ("testdir/" in c) | |
459 | @test "Example" in c | |
460 | @test apply_completion("add tes") == (Sys.iswindows() ? "add testdir\\\\" : "add testdir/") | |
461 | @test apply_completion("add ./tes") == (Sys.iswindows() ? "add ./testdir\\\\" : "add ./testdir/") | |
462 | c, r = test_complete("dev ./") | |
463 | @test (Sys.iswindows() ? ("testdir\\\\" in c) : ("testdir/" in c)) | |
464 | # dont complete files | |
465 | touch("README.md") | |
466 | c, r = test_complete("add RE") | |
467 | @test !("README.md" in c) | |
468 | end # testset | |
392 | 469 | end end |
393 | 470 | |
394 | 471 | temp_pkg_dir() do project_path; cd(project_path) do |
420 | 497 | print(io, """ |
421 | 498 | |
422 | 499 | [compat] |
423 | JSON = "0.16.0" | |
500 | JSON = "0.18.0" | |
424 | 501 | """ |
425 | 502 | ) |
426 | 503 | end |
427 | 504 | pkg"up" |
428 | @test Pkg.API.installed()["JSON"].minor == 16 | |
505 | @test Pkg.API.installed()["JSON"].minor == 18 | |
429 | 506 | write("Project.toml", old_project) |
430 | 507 | pkg"up" |
431 | 508 | @test Pkg.API.installed()["JSON"] == current_json |
819 | 896 | @test_throws PkgError Pkg.REPLMode.pkgstr("--foo=foo add Example") |
820 | 897 | @test_throws PkgError Pkg.REPLMode.pkgstr("--bar add Example") |
821 | 898 | @test_throws PkgError Pkg.REPLMode.pkgstr("-x add Example") |
822 | # malformed, but registered meta option | |
823 | 899 | @test_throws PkgError Pkg.REPLMode.pkgstr("--env Example") |
824 | 900 | end end end |
825 | 901 | end |
841 | 917 | Pkg.REPLMode.pkg"package add Example" |
842 | 918 | @test isinstalled(TEST_PKG) |
843 | 919 | Pkg.REPLMode.pkg"package rm Example" |
920 | @test !isinstalled(TEST_PKG) | |
921 | end end end | |
922 | end | |
923 | ||
924 | @testset "preview" begin | |
925 | temp_pkg_dir() do project_path; cd_tempdir() do tmpdir; with_temp_env() do; | |
926 | pkg"add Example" | |
927 | pkg"preview rm Example" | |
928 | @test isinstalled(TEST_PKG) | |
929 | pkg"rm Example" | |
930 | pkg"preview add Example" | |
931 | @test !isinstalled(TEST_PKG) | |
932 | # as a meta option | |
933 | pkg"add Example" | |
934 | pkg"--preview rm Example" | |
935 | @test isinstalled(TEST_PKG) | |
936 | pkg"rm Example" | |
937 | pkg"--preview add Example" | |
938 | @test !isinstalled(TEST_PKG) | |
939 | # both | |
940 | pkg"--preview preview add Example" | |
844 | 941 | @test !isinstalled(TEST_PKG) |
845 | 942 | end end end |
846 | 943 | end |
14 | 14 | empty!(DEPOT_PATH) |
15 | 15 | Base.HOME_PROJECT[] = nothing |
16 | 16 | Base.ACTIVE_PROJECT[] = nothing |
17 | mktempdir() do env_dir | |
18 | mktempdir() do depot_dir | |
19 | push!(LOAD_PATH, "@", "@v#.#", "@stdlib") | |
20 | push!(DEPOT_PATH, depot_dir) | |
21 | fn(env_dir) | |
17 | withenv("JULIA_PROJECT" => nothing, "JULIA_LOAD_PATH" => nothing) do | |
18 | mktempdir() do env_dir | |
19 | mktempdir() do depot_dir | |
20 | push!(LOAD_PATH, "@", "@v#.#", "@stdlib") | |
21 | push!(DEPOT_PATH, depot_dir) | |
22 | fn(env_dir) | |
23 | end | |
22 | 24 | end |
23 | 25 | end |
24 | 26 | finally |
79 | 81 | Pkg.activate() |
80 | 82 | end |
81 | 83 | end |
84 | ||
85 | import LibGit2 | |
86 | using UUIDs | |
87 | const TEST_SIG = LibGit2.Signature("TEST", "TEST@TEST.COM", round(time()), 0) | |
88 | const TEST_PKG = (name = "Example", uuid = UUID("7876af07-990d-54b4-ab0e-23690620f79a")) |
5 | 5 | shell modes. The REPL can be started by simply calling `julia` with no arguments or double-clicking |
6 | 6 | on the executable: |
7 | 7 | |
8 | ``` | |
9 | $ julia | |
10 | _ | |
11 | _ _ _(_)_ | A fresh approach to technical computing | |
12 | (_) | (_) (_) | Documentation: https://docs.julialang.org | |
13 | _ _ _| |_ __ _ | Type "?help" for help. | |
14 | | | | | | | |/ _` | | | |
15 | | | |_| | | | (_| | | Version 0.6.0-dev.2493 (2017-01-31 18:53 UTC) | |
16 | _/ |\__'_|_|_|\__'_| | Commit c99e12c* (0 days old master) | |
17 | |__/ | x86_64-linux-gnu | |
18 | ||
19 | julia> | |
8 | ```@eval | |
9 | io = IOBuffer() | |
10 | Base.banner(io) | |
11 | banner = String(take!(io)) | |
12 | import Markdown | |
13 | Markdown.parse("```\n\$ julia\n\n$(banner)\njulia>\n```") | |
20 | 14 | ``` |
21 | 15 | |
22 | 16 | To exit the interactive session, type `^D` -- the control key together with the `d` key on a blank |
23 | line -- or type `quit()` followed by the return or enter key. The REPL greets you with a banner | |
17 | line -- or type `exit()` followed by the return or enter key. The REPL greets you with a banner | |
24 | 18 | and a `julia>` prompt. |
25 | 19 | |
26 | 20 | ## The different prompt modes |
345 | 345 | partial = beforecursor(s.input_buffer) |
346 | 346 | full = LineEdit.input_string(s) |
347 | 347 | ret, range, should_complete = completions(full, lastindex(partial)) |
348 | return map(completion_text, ret), partial[range], should_complete | |
348 | return unique!(map(completion_text, ret)), partial[range], should_complete | |
349 | 349 | end |
350 | 350 | |
351 | 351 | function complete_line(c::ShellCompletionProvider, s) |
353 | 353 | partial = beforecursor(s.input_buffer) |
354 | 354 | full = LineEdit.input_string(s) |
355 | 355 | ret, range, should_complete = shell_completions(full, lastindex(partial)) |
356 | return map(completion_text, ret), partial[range], should_complete | |
356 | return unique!(map(completion_text, ret)), partial[range], should_complete | |
357 | 357 | end |
358 | 358 | |
359 | 359 | function complete_line(c::LatexCompletions, s) |
360 | 360 | partial = beforecursor(LineEdit.buffer(s)) |
361 | 361 | full = LineEdit.input_string(s) |
362 | 362 | ret, range, should_complete = bslash_completions(full, lastindex(partial))[2] |
363 | return map(completion_text, ret), partial[range], should_complete | |
363 | return unique!(map(completion_text, ret)), partial[range], should_complete | |
364 | 364 | end |
365 | 365 | |
366 | 366 | mutable struct REPLHistoryProvider <: HistoryProvider |
119 | 119 | cmove_line_down(t::UnixTerminal, n) = (cmove_down(t, n); cmove_col(t, 1)) |
120 | 120 | cmove_col(t::UnixTerminal, n) = (write(t.out_stream, '\r'); n > 1 && cmove_right(t, n-1)) |
121 | 121 | |
122 | const is_precompiling = Ref(false) | |
122 | 123 | if Sys.iswindows() |
123 | 124 | function raw!(t::TTYTerminal,raw::Bool) |
125 | is_precompiling[] && return true | |
124 | 126 | check_open(t.in_stream) |
125 | 127 | if Base.ispty(t.in_stream) |
126 | 128 | run((raw ? `stty raw -echo onlcr -ocrnl opost` : `stty sane`), |
99 | 99 | @test "CompletionFoo" in c |
100 | 100 | @test isempty(r) |
101 | 101 | @test s[r] == "" |
102 | end | |
103 | ||
104 | let s = "using REP" | |
105 | c, r = test_complete(s) | |
106 | @test count(isequal("REPL"), c) == 1 | |
102 | 107 | end |
103 | 108 | |
104 | 109 | let s = "Comp" |
22 | 22 | shuffle, shuffle!, |
23 | 23 | randperm, randperm!, |
24 | 24 | randcycle, randcycle!, |
25 | AbstractRNG, MersenneTwister, RandomDevice, | |
26 | randjump | |
27 | ||
25 | AbstractRNG, MersenneTwister, RandomDevice | |
28 | 26 | |
29 | 27 | ## general definitions |
30 | 28 |
120 | 120 | end |
121 | 121 | |
122 | 122 | """ |
123 | randsubseq!(S, A, p) | |
123 | randsubseq!([rng=GLOBAL_RNG,] S, A, p) | |
124 | 124 | |
125 | 125 | Like [`randsubseq`](@ref), but the results are stored in `S` |
126 | 126 | (which is resized as needed). |
127 | ||
128 | # Examples | |
129 | ```jldoctest | |
130 | julia> rng = MersenneTwister(1234); | |
131 | ||
132 | julia> S = Int64[]; | |
133 | ||
134 | julia> randsubseq!(rng, S, collect(1:8), 0.3); | |
135 | ||
136 | julia> S | |
137 | 2-element Array{Int64,1}: | |
138 | 7 | |
139 | 8 | |
140 | ``` | |
127 | 141 | """ |
128 | 142 | randsubseq!(S::AbstractArray, A::AbstractArray, p::Real) = randsubseq!(GLOBAL_RNG, S, A, p) |
129 | 143 | |
131 | 145 | randsubseq!(r, T[], A, p) |
132 | 146 | |
133 | 147 | """ |
134 | randsubseq(A, p) -> Vector | |
148 | randsubseq([rng=GLOBAL_RNG,] A, p) -> Vector | |
135 | 149 | |
136 | 150 | Return a vector consisting of a random subsequence of the given array `A`, where each |
137 | 151 | element of `A` is included (in order) with independent probability `p`. (Complexity is |
138 | 152 | linear in `p*length(A)`, so this function is efficient even if `p` is small and `A` is |
139 | 153 | large.) Technically, this process is known as "Bernoulli sampling" of `A`. |
154 | ||
155 | # Examples | |
156 | ```jldoctest | |
157 | julia> rng = MersenneTwister(1234); | |
158 | ||
159 | julia> randsubseq(rng, collect(1:8), 0.3) | |
160 | 2-element Array{Int64,1}: | |
161 | 7 | |
162 | 8 | |
163 | ``` | |
140 | 164 | """ |
141 | 165 | randsubseq(A::AbstractArray, p::Real) = randsubseq(GLOBAL_RNG, A, p) |
142 | 166 | |
181 | 205 | function shuffle!(r::AbstractRNG, a::AbstractArray) |
182 | 206 | @assert !has_offset_axes(a) |
183 | 207 | n = length(a) |
208 | n <= 1 && return a # nextpow below won't work with n == 0 | |
184 | 209 | @assert n <= Int64(2)^52 |
185 | 210 | mask = nextpow(2, n) - 1 |
186 | 211 | for i = n:-1:2 |
685 | 685 | @test Random.gentype(Random.UInt52(UInt128)) == UInt128 |
686 | 686 | @test Random.gentype(Random.UInt104()) == UInt128 |
687 | 687 | end |
688 | ||
689 | @testset "shuffle[!]" begin | |
690 | a = [] | |
691 | @test shuffle(a) == a # issue #28727 | |
692 | @test shuffle!(a) === a | |
693 | a = rand(Int, 1) | |
694 | @test shuffle(a) == a | |
695 | end |
6 | 6 | |
7 | 7 | [extras] |
8 | 8 | Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" |
9 | InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | |
9 | 10 | |
10 | 11 | [targets] |
11 | test = ["Test"] | |
12 | test = ["Test", "InteractiveUtils"] |
967 | 967 | end |
968 | 968 | |
969 | 969 | # multiply by diagonal matrix as vector |
970 | function mul!(C::SparseMatrixCSC, A::SparseMatrixCSC, D::Diagonal{<:Vector}) | |
970 | function mul!(C::SparseMatrixCSC, A::SparseMatrixCSC, D::Diagonal{T, <:Vector}) where T | |
971 | 971 | m, n = size(A) |
972 | 972 | b = D.diag |
973 | 973 | (n==length(b) && size(A)==size(C)) || throw(DimensionMismatch()) |
981 | 981 | C |
982 | 982 | end |
983 | 983 | |
984 | function mul!(C::SparseMatrixCSC, D::Diagonal{<:Vector}, A::SparseMatrixCSC) | |
984 | function mul!(C::SparseMatrixCSC, D::Diagonal{T, <:Vector}, A::SparseMatrixCSC) where T | |
985 | 985 | m, n = size(A) |
986 | 986 | b = D.diag |
987 | 987 | (m==length(b) && size(A)==size(C)) || throw(DimensionMismatch()) |
355 | 355 | |
356 | 356 | |
357 | 357 | # converting between SparseMatrixCSC types |
358 | SparseMatrixCSC(S::SparseMatrixCSC) = copy(S) | |
358 | 359 | AbstractMatrix{Tv}(A::SparseMatrixCSC) where {Tv} = SparseMatrixCSC{Tv}(A) |
359 | 360 | SparseMatrixCSC{Tv}(S::SparseMatrixCSC{Tv}) where {Tv} = copy(S) |
360 | 361 | SparseMatrixCSC{Tv}(S::SparseMatrixCSC) where {Tv} = SparseMatrixCSC{Tv,eltype(S.colptr)}(S) |
399 | 400 | end |
400 | 401 | SparseMatrixCSC(M::Adjoint{<:Any,<:SparseMatrixCSC}) = copy(M) |
401 | 402 | SparseMatrixCSC(M::Transpose{<:Any,<:SparseMatrixCSC}) = copy(M) |
403 | SparseMatrixCSC{Tv}(M::Adjoint{Tv,SparseMatrixCSC{Tv}}) where {Tv} = copy(M) | |
404 | SparseMatrixCSC{Tv}(M::Transpose{Tv,SparseMatrixCSC{Tv}}) where {Tv} = copy(M) | |
405 | SparseMatrixCSC{Tv,Ti}(M::Adjoint{Tv,SparseMatrixCSC{Tv,Ti}}) where {Tv,Ti} = copy(M) | |
406 | SparseMatrixCSC{Tv,Ti}(M::Transpose{Tv,SparseMatrixCSC{Tv,Ti}}) where {Tv,Ti} = copy(M) | |
407 | ||
408 | # converting from adjoint or transpose sparse matrices to sparse matrices with different eltype | |
409 | SparseMatrixCSC{Tv}(M::Adjoint{<:Any,SparseMatrixCSC}) where {Tv} = SparseMatrixCSC{Tv}(copy(M)) | |
410 | SparseMatrixCSC{Tv}(M::Transpose{<:Any,SparseMatrixCSC}) where {Tv} = SparseMatrixCSC{Tv}(copy(M)) | |
411 | SparseMatrixCSC{Tv,Ti}(M::Adjoint{<:Any,SparseMatrixCSC}) where {Tv,Ti} = SparseMatrixCSC{Tv,Ti}(copy(M)) | |
412 | SparseMatrixCSC{Tv,Ti}(M::Transpose{<:Any,SparseMatrixCSC}) where {Tv,Ti} = SparseMatrixCSC{Tv,Ti}(copy(M)) | |
402 | 413 | |
403 | 414 | # converting from SparseMatrixCSC to other matrix types |
404 | 415 | function Matrix(S::SparseMatrixCSC{Tv}) where Tv |
7 | 7 | using Base.Printf: @printf |
8 | 8 | using Random |
9 | 9 | using Test: guardseed |
10 | using InteractiveUtils: @which | |
10 | 11 | |
11 | 12 | @testset "issparse" begin |
12 | 13 | @test issparse(sparse(fill(1,5,5))) |
2288 | 2289 | @test adjoint(MC) == copy(adjoint(SC)) |
2289 | 2290 | end |
2290 | 2291 | |
2292 | @testset "Issue #28634" begin | |
2293 | a = SparseMatrixCSC{Int8, Int16}([1 2; 3 4]) | |
2294 | na = SparseMatrixCSC(a) | |
2295 | @test typeof(a) === typeof(na) | |
2296 | end | |
2297 | ||
2298 | #PR #29045 | |
2299 | @testset "Issue #28934" begin | |
2300 | A = sprand(5,5,0.5) | |
2301 | D = Diagonal(rand(5)) | |
2302 | C = copy(A) | |
2303 | m1 = @which mul!(C,A,D) | |
2304 | m2 = @which mul!(C,D,A) | |
2305 | @test m1.module == SparseArrays | |
2306 | @test m2.module == SparseArrays | |
2307 | end | |
2308 | ||
2291 | 2309 | end # module |
247 | 247 | Compute the sample variance of a collection `v` with known mean(s) `m`, |
248 | 248 | optionally over the given dimensions. `m` may contain means for each dimension of |
249 | 249 | `v`. If `corrected` is `true`, then the sum is scaled with `n-1`, |
250 | whereas the sum is scaled with `n` if `corrected` is `false` where `n = length(x)`. | |
250 | whereas the sum is scaled with `n` if `corrected` is `false` where `n = length(v)`. | |
251 | 251 | |
252 | 252 | !!! note |
253 | 253 | If array contains `NaN` or [`missing`](@ref) values, the result is also |
277 | 277 | under the assumption that each entry of `v` is an IID drawn from that generative |
278 | 278 | distribution. This computation is equivalent to calculating `sum(abs2, v - mean(v)) / |
279 | 279 | (length(v) - 1)`. If `corrected` is `true`, then the sum is scaled with `n-1`, |
280 | whereas the sum is scaled with `n` if `corrected` is `false` where `n = length(x)`. | |
280 | whereas the sum is scaled with `n` if `corrected` is `false` where `n = length(v)`. | |
281 | 281 | The mean `mean` over the region may be provided. |
282 | 282 | |
283 | 283 | !!! note |
344 | 344 | distribution. This computation is equivalent to calculating `sqrt(sum((v - mean(v)).^2) / |
345 | 345 | (length(v) - 1))`. A pre-computed `mean` may be provided. If `corrected` is `true`, |
346 | 346 | then the sum is scaled with `n-1`, whereas the sum is scaled with `n` if `corrected` is |
347 | `false` where `n = length(x)`. | |
347 | `false` where `n = length(v)`. | |
348 | 348 | |
349 | 349 | !!! note |
350 | 350 | If array contains `NaN` or [`missing`](@ref) values, the result is also |
375 | 375 | Compute the sample standard deviation of a vector `v` |
376 | 376 | with known mean `m`. If `corrected` is `true`, |
377 | 377 | then the sum is scaled with `n-1`, whereas the sum is |
378 | scaled with `n` if `corrected` is `false` where `n = length(x)`. | |
378 | scaled with `n` if `corrected` is `false` where `n = length(v)`. | |
379 | 379 | |
380 | 380 | !!! note |
381 | 381 | If array contains `NaN` or [`missing`](@ref) values, the result is also |
881 | 881 | `itr` can be assumed to be sorted. |
882 | 882 | |
883 | 883 | Quantiles are computed via linear interpolation between the points `((k-1)/(n-1), v[k])`, |
884 | for `k = 1:n` where `n = length(v)`. This corresponds to Definition 7 of Hyndman and Fan | |
884 | for `k = 1:n` where `n = length(itr)`. This corresponds to Definition 7 of Hyndman and Fan | |
885 | 885 | (1996), and is the same as the R default. |
886 | 886 | |
887 | 887 | !!! note |
272 | 272 | pop!(need_to_handle_undef_sparam, first(methods(Core.Compiler.same_names))) |
273 | 273 | pop!(need_to_handle_undef_sparam, which(Core.Compiler.convert, (Type{Union{Core.Compiler.Some{T}, Nothing}} where T, Core.Compiler.Some))) |
274 | 274 | pop!(need_to_handle_undef_sparam, which(Core.Compiler.convert, (Type{Union{T, Nothing}} where T, Core.Compiler.Some))) |
275 | pop!(need_to_handle_undef_sparam, which(Core.Compiler.convert, Tuple{Type{Tuple{Vararg{Int}}}, Tuple{}})) | |
276 | pop!(need_to_handle_undef_sparam, which(Core.Compiler.convert, Tuple{Type{Tuple{Vararg{Int}}}, Tuple{Int8}})) | |
275 | 277 | @test need_to_handle_undef_sparam == Set() |
276 | 278 | end |
277 | 279 | let need_to_handle_undef_sparam = |
294 | 296 | pop!(need_to_handle_undef_sparam, which(Base.nonmissingtype, Tuple{Type{Union{Missing, T}} where T})) |
295 | 297 | pop!(need_to_handle_undef_sparam, which(Base.convert, (Type{Union{Some{T}, Nothing}} where T, Some))) |
296 | 298 | pop!(need_to_handle_undef_sparam, which(Base.convert, (Type{Union{T, Nothing}} where T, Some))) |
299 | pop!(need_to_handle_undef_sparam, which(Base.convert, Tuple{Type{Tuple{Vararg{Int}}}, Tuple{}})) | |
300 | pop!(need_to_handle_undef_sparam, which(Base.convert, Tuple{Type{Tuple{Vararg{Int}}}, Tuple{Int8}})) | |
297 | 301 | @test need_to_handle_undef_sparam == Set() |
298 | 302 | end |
299 | 303 | end |
400 | 400 | |
401 | 401 | # Issue #24298 |
402 | 402 | @test mod(BigInt(6), UInt(5)) == mod(6, 5) |
403 | ||
404 | @testset "cmp has values in [-1, 0, 1], issue #28780" begin | |
405 | # _rand produces values whose log2 is better distributed than rand | |
406 | _rand(::Type{BigInt}, n=1000) = let x = big(2)^rand(1:rand(1:n)) | |
407 | rand(-x:x) | |
408 | end | |
409 | _rand(F::Type{<:AbstractFloat}) = F(_rand(BigInt, round(Int, log2(floatmax(F))))) + rand(F) | |
410 | _rand(T) = rand(T) | |
411 | for T in (Base.BitInteger_types..., BigInt, Float64, Float32, Float16) | |
412 | @test cmp(big(2)^130, one(T)) === 1 | |
413 | @test cmp(-big(2)^130, one(T)) === -1 | |
414 | c = cmp(_rand(BigInt), _rand(T)) | |
415 | @test c ∈ (-1, 0, 1) | |
416 | @test c isa Int | |
417 | (T <: Integer && T !== BigInt) || continue | |
418 | x = rand(T) | |
419 | @test cmp(big(2)^130, x) === cmp(x, -big(2)^130) === 1 | |
420 | @test cmp(-big(2)^130, x) === cmp(x, big(2)^130) === -1 | |
421 | @test cmp(big(x), x) === cmp(x, big(x)) === 0 | |
422 | end | |
423 | c = cmp(_rand(BigInt), _rand(BigInt)) | |
424 | @test c ∈ (-1, 0, 1) | |
425 | @test c isa Int | |
426 | end |
1976 | 1976 | e[1] |
1977 | 1977 | end |
1978 | 1978 | @test bar28444() == 1 |
1979 | ||
1980 | # issue #28641 | |
1981 | struct VoxelIndices{T <: Integer} | |
1982 | voxCrnrPos::NTuple{8,NTuple{3,T}} | |
1983 | voxEdgeCrnrs::NTuple{19, NTuple{2,T}} | |
1984 | voxEdgeDir::NTuple{19,T} | |
1985 | voxEdgeIx::NTuple{8,NTuple{8,T}} | |
1986 | subTets::NTuple{6,NTuple{4,T}} | |
1987 | tetEdgeCrnrs::NTuple{6,NTuple{2,T}} | |
1988 | tetTri::NTuple{16,NTuple{6,T}} | |
1989 | end | |
1990 | f28641(x::VoxelIndices, f) = getfield(x, f) | |
1991 | @test Base.return_types(f28641, (Any,Symbol)) == Any[Tuple] | |
1992 | ||
1993 | # issue #29036 | |
1994 | function f29036(s, i) | |
1995 | val, i = iterate(s, i) | |
1996 | val | |
1997 | end | |
1998 | @test Base.return_types(f29036, (String, Int)) == Any[Char] |
139 | 139 | # typejoin with Vararg{T,N} |
140 | 140 | @test typejoin(Tuple{Vararg{Int,2}}, Tuple{Int,Int,Int}) === Tuple{Int,Int,Vararg{Int}} |
141 | 141 | @test typejoin(Tuple{Vararg{Int,2}}, Tuple{Vararg{Int}}) === Tuple{Vararg{Int}} |
142 | ||
143 | @test typejoin(NTuple{3,Tuple}, NTuple{2,T} where T) == Tuple{Any,Any,Vararg{Tuple}} | |
142 | 144 | |
143 | 145 | # issue #26321 |
144 | 146 | struct T26321{N,S<:NTuple{N}} |
3253 | 3255 | @test forouter() == 3 |
3254 | 3256 | end |
3255 | 3257 | |
3256 | @test_throws ErrorException("syntax: no outer variable declaration exists for \"for outer\"") @eval function f() | |
3258 | @test_throws ErrorException("syntax: no outer local variable declaration exists for \"for outer\"") @eval function f() | |
3257 | 3259 | for outer i = 1:2 |
3258 | 3260 | end |
3259 | 3261 | end |
6694 | 6696 | true |
6695 | 6697 | end |
6696 | 6698 | @test repackage28445() |
6699 | ||
6700 | # issue #28597 | |
6701 | @test_throws ErrorException Array{Int, 2}(undef, 0, -10) | |
6702 | @test_throws ErrorException Array{Int, 2}(undef, -10, 0) | |
6703 | @test_throws ErrorException Array{Int, 2}(undef, -1, -1) | |
6704 | ||
6705 | # issue #29145 | |
6706 | struct T29145{A,B} | |
6707 | function T29145() | |
6708 | new{S,Ref{S}}() where S | |
6709 | end | |
6710 | end | |
6711 | @test_throws TypeError T29145() | |
6712 | ||
6713 | # issue #29175 | |
6714 | function f29175(tuple::T) where {T<:Tuple} | |
6715 | prefix::Tuple{T.parameters[1:end-1]...} = tuple[1:length(T.parameters)-1] | |
6716 | x = prefix | |
6717 | prefix = x # force another conversion to declared type | |
6718 | return prefix | |
6719 | end | |
6720 | @test f29175((1,2,3)) === (1,2) |
1120 | 1120 | |
1121 | 1121 | @test docstrings_equal(@doc(A_20087()), doc"a") |
1122 | 1122 | |
1123 | struct B_20087 end | |
1124 | ||
1125 | """b""" | |
1126 | (::B_20087)() = a | |
1127 | ||
1128 | @test docstrings_equal(@doc(B_20087()), doc"b") | |
1129 | ||
1123 | 1130 | # issue #27832 |
1124 | 1131 | |
1125 | 1132 | _last_atdoc = Core.atdoc |
76 | 76 | @test Int(_neg4) === -4 |
77 | 77 | @test Int(_neg3) === -3 |
78 | 78 | |
79 | @test_throws ArgumentError("invalid value for Enum Test1, _zerofp = 0.0=0.0; values must be integers") @macrocall(@enum Test1 _zerofp=0.0) | |
80 | @test_throws ArgumentError("invalid value for Enum Test11, _zerofp2 = 0.5=0.5; values must be integers") @macrocall(@enum Test11 _zerofp2=0.5) | |
79 | @test_throws ArgumentError("invalid value for Enum Test1, _zerofp = 0.0; values must be integers") @macrocall(@enum Test1 _zerofp=0.0) | |
80 | @test_throws ArgumentError("invalid value for Enum Test11, _zerofp2 = 0.5; values must be integers") @macrocall(@enum Test11 _zerofp2=0.5) | |
81 | 81 | @enum Test111 _zerobi=BigInt(1) |
82 | 82 | @test Integer(_zerobi) == 1 |
83 | 83 | |
106 | 106 | @test typeof(Integer(_one_Test6)) == UInt128 |
107 | 107 | |
108 | 108 | # enum values must be integers |
109 | @test_throws ArgumentError("invalid value for Enum Test7, _zero = \"zero\"=zero; values must be integers") @macrocall(@enum Test7 _zero="zero") | |
110 | @test_throws ArgumentError("invalid value for Enum Test8, _zero = '0'=0; values must be integers") @macrocall(@enum Test8 _zero='0') | |
111 | @test_throws ArgumentError("invalid value for Enum Test9, _zero = 0.5=0.5; values must be integers") @macrocall(@enum Test9 _zero=0.5) | |
109 | @test_throws ArgumentError("invalid value for Enum Test7, _zero = \"zero\"; values must be integers") @macrocall(@enum Test7 _zero="zero") | |
110 | @test_throws ArgumentError("invalid value for Enum Test8, _zero = '0'; values must be integers") @macrocall(@enum Test8 _zero='0') | |
111 | @test_throws ArgumentError("invalid value for Enum Test9, _zero = 0.5; values must be integers") @macrocall(@enum Test9 _zero=0.5) | |
112 | 112 | |
113 | 113 | # test macro handles keyword arguments |
114 | 114 | @enum(Test11, _zero_Test11=2, |
110 | 110 | @test a[] == 1 |
111 | 111 | end |
112 | 112 | |
113 | # issue #29083 | |
114 | f29083(;μ,σ) = μ + σ*randn() | |
115 | g29083() = f29083(μ=2.0,σ=0.1) | |
116 | let c = code_typed(g29083, ())[1][1].code | |
117 | # make sure no call to kwfunc remains | |
118 | @test !any(e->(isa(e,Expr) && ((e.head === :invoke && e.args[1].def.name === :kwfunc) || | |
119 | (e.head === :foreigncall && e.args[1] === QuoteNode(:jl_get_keyword_sorter)))), | |
120 | c) | |
121 | end | |
122 | ||
113 | 123 | @testset "issue #19122: [no]inline of short func. def. with return type annotation" begin |
114 | 124 | exf19122 = @macroexpand(@inline f19122()::Bool = true) |
115 | 125 | exg19122 = @macroexpand(@noinline g19122()::Bool = true) |
136 | 146 | (src, _) = code_typed(sum27403, Tuple{Vector{Int}})[1] |
137 | 147 | @test !any(x -> x isa Expr && x.head === :invoke, src.code) |
138 | 148 | end |
149 | ||
150 | # check that type.mutable can be fully eliminated | |
151 | f_mutable_nothrow(s::String) = Val{typeof(s).mutable} | |
152 | @test length(code_typed(f_mutable_nothrow, (String,))[1][1].code) == 1 |
138 | 138 | @test iszero([Base.ndigits0z(false, b) for b in [-20:-2;2:20]]) |
139 | 139 | @test all(n -> n == 1, Base.ndigits0z(true, b) for b in [-20:-2;2:20]) |
140 | 140 | @test all(n -> n == 1, ndigits(x, base=b) for b in [-20:-2;2:20] for x in [true, false]) |
141 | ||
142 | # issue #29148 | |
143 | @test ndigits(typemax(UInt64), base=-2) == ndigits(big(typemax(UInt64)), base=-2) | |
144 | for T in Base.BitInteger_types | |
145 | n = rand(T) | |
146 | b = -rand(2:100) | |
147 | @test ndigits(n, base=b) == ndigits(big(n), base=b) | |
148 | end | |
149 | ||
141 | 150 | end |
142 | 151 | @testset "bin/oct/dec/hex/bits" begin |
143 | 152 | @test string(UInt32('3'), base = 2) == "110011" |
364 | 364 | @test length(flatten(zip(1:3, 4:6))) == 6 |
365 | 365 | @test length(flatten(1:6)) == 6 |
366 | 366 | @test collect(flatten(Any[])) == Any[] |
367 | @test collect(flatten(())) == Union{}[] | |
367 | 368 | @test_throws ArgumentError length(flatten(NTuple[(1,), ()])) # #16680 |
368 | 369 | @test_throws ArgumentError length(flatten([[1], [1]])) |
369 | 370 |
413 | 413 | ret %jl_value_t addrspace(10)* %obj |
414 | 414 | } |
415 | 415 | |
416 | define void @vecphi(i1 %cond, <2 x %jl_value_t addrspace(10)*> *%arg) { | |
417 | ; CHECK-LABEL: @vecphi | |
418 | ; CHECK: %gcframe = alloca %jl_value_t addrspace(10)*, i32 4 | |
419 | top: | |
420 | %ptls = call %jl_value_t*** @julia.ptls_states() | |
421 | br i1 %cond, label %A, label %B | |
422 | ||
423 | A: | |
424 | br label %common | |
425 | ||
426 | B: | |
427 | %loaded = load <2 x %jl_value_t addrspace(10)*>, <2 x %jl_value_t addrspace(10)*> *%arg | |
428 | call void @jl_safepoint() | |
429 | br label %common | |
430 | ||
431 | common: | |
432 | %phi = phi <2 x %jl_value_t addrspace(10)*> [ zeroinitializer, %A ], [ %loaded, %B ] | |
433 | call void @jl_safepoint() | |
434 | %el1 = extractelement <2 x %jl_value_t addrspace(10)*> %phi, i32 0 | |
435 | %el2 = extractelement <2 x %jl_value_t addrspace(10)*> %phi, i32 1 | |
436 | call void @one_arg_boxed(%jl_value_t addrspace(10)* %el1) | |
437 | call void @one_arg_boxed(%jl_value_t addrspace(10)* %el2) | |
438 | unreachable | |
439 | } | |
440 | ||
441 | define i8 @phi_arrayptr(i1 %cond) { | |
442 | ; CHECK-LABEL: @phi_arrayptr | |
443 | ; CHECK: %gcframe = alloca %jl_value_t addrspace(10)*, i32 4 | |
444 | top: | |
445 | %ptls = call %jl_value_t*** @julia.ptls_states() | |
446 | br i1 %cond, label %A, label %B | |
447 | ||
448 | A: | |
449 | %obj1 = call %jl_value_t addrspace(10) *@alloc() | |
450 | %obj2 = call %jl_value_t addrspace(10) *@alloc() | |
451 | %decayed1 = addrspacecast %jl_value_t addrspace(10) *%obj1 to %jl_value_t addrspace(11) * | |
452 | %arrayptrptr1 = bitcast %jl_value_t addrspace(11) *%decayed1 to i8 addrspace(13)* addrspace(11)* | |
453 | %arrayptr1 = load i8 addrspace(13)*, i8 addrspace(13)* addrspace(11)* %arrayptrptr1 | |
454 | %decayed2 = addrspacecast %jl_value_t addrspace(10) *%obj2 to %jl_value_t addrspace(11) * | |
455 | %arrayptrptr2 = bitcast %jl_value_t addrspace(11) *%decayed2 to i8 addrspace(13)* addrspace(11)* | |
456 | %arrayptr2 = load i8 addrspace(13)*, i8 addrspace(13)* addrspace(11)* %arrayptrptr2 | |
457 | %insert1 = insertelement <2 x i8 addrspace(13)*> undef, i8 addrspace(13)* %arrayptr1, i32 0 | |
458 | %insert2 = insertelement <2 x i8 addrspace(13)*> %insert1, i8 addrspace(13)* %arrayptr2, i32 1 | |
459 | call void @jl_safepoint() | |
460 | br label %common | |
461 | ||
462 | B: | |
463 | br label %common | |
464 | ||
465 | common: | |
466 | ; CHECK: %gclift | |
467 | ; CHECK: %gclift1 | |
468 | ; CHECK-NOT: %gclift2 | |
469 | %phi = phi <2 x i8 addrspace(13)*> [ %insert2, %A ], [ zeroinitializer, %B ] | |
470 | call void @jl_safepoint() | |
471 | %el1 = extractelement <2 x i8 addrspace(13)*> %phi, i32 0 | |
472 | %el2 = extractelement <2 x i8 addrspace(13)*> %phi, i32 1 | |
473 | %l1 = load i8, i8 addrspace(13)* %el1 | |
474 | %l2 = load i8, i8 addrspace(13)* %el2 | |
475 | %add = add i8 %l1, %l2 | |
476 | ret i8 %add | |
477 | } | |
478 | ||
479 | define void @vecselect(i1 %cond, <2 x %jl_value_t addrspace(10)*> *%arg) { | |
480 | ; CHECK-LABEL: @vecselect | |
481 | ; CHECK: %gcframe = alloca %jl_value_t addrspace(10)*, i32 4 | |
482 | top: | |
483 | %ptls = call %jl_value_t*** @julia.ptls_states() | |
484 | %loaded = load <2 x %jl_value_t addrspace(10)*>, <2 x %jl_value_t addrspace(10)*> *%arg | |
485 | call void @jl_safepoint() | |
486 | %select = select i1 %cond, <2 x %jl_value_t addrspace(10)*> zeroinitializer, <2 x %jl_value_t addrspace(10)*> %loaded | |
487 | call void @jl_safepoint() | |
488 | %el1 = extractelement <2 x %jl_value_t addrspace(10)*> %select, i32 0 | |
489 | %el2 = extractelement <2 x %jl_value_t addrspace(10)*> %select, i32 1 | |
490 | call void @one_arg_boxed(%jl_value_t addrspace(10)* %el1) | |
491 | call void @one_arg_boxed(%jl_value_t addrspace(10)* %el2) | |
492 | unreachable | |
493 | } | |
494 | ||
495 | define i8 @select_arrayptr(i1 %cond) { | |
496 | ; CHECK-LABEL: @select_arrayptr | |
497 | ; CHECK: %gcframe = alloca %jl_value_t addrspace(10)*, i32 4 | |
498 | top: | |
499 | %ptls = call %jl_value_t*** @julia.ptls_states() | |
500 | %obj1 = call %jl_value_t addrspace(10) *@alloc() | |
501 | %obj2 = call %jl_value_t addrspace(10) *@alloc() | |
502 | %decayed1 = addrspacecast %jl_value_t addrspace(10) *%obj1 to %jl_value_t addrspace(11) * | |
503 | %arrayptrptr1 = bitcast %jl_value_t addrspace(11) *%decayed1 to i8 addrspace(13)* addrspace(11)* | |
504 | %arrayptr1 = load i8 addrspace(13)*, i8 addrspace(13)* addrspace(11)* %arrayptrptr1 | |
505 | %decayed2 = addrspacecast %jl_value_t addrspace(10) *%obj2 to %jl_value_t addrspace(11) * | |
506 | %arrayptrptr2 = bitcast %jl_value_t addrspace(11) *%decayed2 to i8 addrspace(13)* addrspace(11)* | |
507 | %arrayptr2 = load i8 addrspace(13)*, i8 addrspace(13)* addrspace(11)* %arrayptrptr2 | |
508 | %insert1 = insertelement <2 x i8 addrspace(13)*> undef, i8 addrspace(13)* %arrayptr1, i32 0 | |
509 | %insert2 = insertelement <2 x i8 addrspace(13)*> %insert1, i8 addrspace(13)* %arrayptr2, i32 1 | |
510 | call void @jl_safepoint() | |
511 | %select = select i1 %cond, <2 x i8 addrspace(13)*> %insert2, <2 x i8 addrspace(13)*> zeroinitializer | |
512 | call void @jl_safepoint() | |
513 | %el1 = extractelement <2 x i8 addrspace(13)*> %select, i32 0 | |
514 | %el2 = extractelement <2 x i8 addrspace(13)*> %select, i32 1 | |
515 | %l1 = load i8, i8 addrspace(13)* %el1 | |
516 | %l2 = load i8, i8 addrspace(13)* %el2 | |
517 | %add = add i8 %l1, %l2 | |
518 | ret i8 %add | |
519 | } | |
520 | ||
416 | 521 | !0 = !{!"jtbaa"} |
417 | 522 | !1 = !{!"jtbaa_const", !0, i64 0} |
418 | 523 | !2 = !{!1, !1, i64 0, i64 1} |
546 | 546 | popfirst!(LOAD_PATH) |
547 | 547 | end |
548 | 548 | |
549 | @testset "--project and JULIA_PROJECT paths should be absolutified" begin | |
550 | mktempdir() do dir; cd(dir) do | |
551 | mkdir("foo") | |
552 | script = """ | |
553 | using Test | |
554 | old = Base.active_project() | |
555 | cd("foo") | |
556 | @test Base.active_project() == old | |
557 | """ | |
558 | @test success(`$(Base.julia_cmd()) --project=foo -e $(script)`) | |
559 | withenv("JULIA_PROJECT" => "foo") do | |
560 | @test success(`$(Base.julia_cmd()) -e $(script)`) | |
561 | end | |
562 | end; end | |
563 | end | |
564 | ||
549 | 565 | ## cleanup after tests ## |
550 | 566 | |
551 | 567 | for env in keys(envs) |
677 | 677 | # Just checking that this doesn't stack overflow on construction |
678 | 678 | @test Test27970Empty() == Test27970Empty() |
679 | 679 | end |
680 | ||
681 | @testset "exports of modules" begin | |
682 | for (_, mod) in Base.loaded_modules | |
683 | for v in names(mod) | |
684 | @test isdefined(mod, v) | |
685 | end | |
686 | end | |
687 | end |
135 | 135 | const x28297 = Result(missing) |
136 | 136 | |
137 | 137 | |
138 | # issue #28998 | |
139 | const x28998 = [missing, 2, missing, 6, missing, | |
140 | missing, missing, missing, | |
141 | missing, missing, missing, | |
142 | missing, missing, 6] | |
143 | ||
138 | 144 | let some_method = which(Base.include, (String,)) |
139 | 145 | # global const some_method // FIXME: support for serializing a direct reference to an external Method not implemented |
140 | 146 | global const some_linfo = |
179 | 185 | @test Foo.abigint_x::BigInt + 1 == big"125" |
180 | 186 | |
181 | 187 | @test Foo.x28297.result === missing |
188 | ||
189 | @test Foo.x28998[end] == 6 | |
182 | 190 | end |
183 | 191 | |
184 | 192 | cachedir = joinpath(dir, "compiled", "v$(VERSION.major).$(VERSION.minor)") |
1370 | 1370 | end |
1371 | 1371 | end |
1372 | 1372 | end |
1373 | ||
1374 | @testset "constant-valued ranges (issues #10391 and #29052)" begin | |
1375 | for r in ((1:4), (1:1:4), (1.0:4.0)) | |
1376 | if eltype(r) === Int | |
1377 | @test_broken @inferred(0 * r) == [0.0, 0.0, 0.0, 0.0] | |
1378 | @test_broken @inferred(0 .* r) == [0.0, 0.0, 0.0, 0.0] | |
1379 | @test_broken @inferred(r + (4:-1:1)) == [5.0, 5.0, 5.0, 5.0] | |
1380 | @test_broken @inferred(r .+ (4:-1:1)) == [5.0, 5.0, 5.0, 5.0] | |
1381 | else | |
1382 | @test @inferred(0 * r) == [0.0, 0.0, 0.0, 0.0] | |
1383 | @test @inferred(0 .* r) == [0.0, 0.0, 0.0, 0.0] | |
1384 | @test @inferred(r + (4:-1:1)) == [5.0, 5.0, 5.0, 5.0] | |
1385 | @test @inferred(r .+ (4:-1:1)) == [5.0, 5.0, 5.0, 5.0] | |
1386 | end | |
1387 | @test @inferred(r .+ (4.0:-1:1)) == [5.0, 5.0, 5.0, 5.0] | |
1388 | @test @inferred(0.0 * r) == [0.0, 0.0, 0.0, 0.0] | |
1389 | @test @inferred(0.0 .* r) == [0.0, 0.0, 0.0, 0.0] | |
1390 | @test @inferred(r / Inf) == [0.0, 0.0, 0.0, 0.0] | |
1391 | @test @inferred(r ./ Inf) == [0.0, 0.0, 0.0, 0.0] | |
1392 | end | |
1393 | ||
1394 | @test_broken @inferred(range(0, step=0, length=4)) == [0, 0, 0, 0] | |
1395 | @test @inferred(range(0, stop=0, length=4)) == [0, 0, 0, 0] | |
1396 | @test @inferred(range(0.0, step=0.0, length=4)) == [0.0, 0.0, 0.0, 0.0] | |
1397 | @test @inferred(range(0.0, stop=0.0, length=4)) == [0.0, 0.0, 0.0, 0.0] | |
1398 | @test @inferred(range(0, step=0.0, length=4)) == [0.0, 0.0, 0.0, 0.0] | |
1399 | @test @inferred(range(0.0, step=0, length=4)) == [0.0, 0.0, 0.0, 0.0] | |
1400 | @test @inferred(range(0, stop=0.0, length=4)) == [0.0, 0.0, 0.0, 0.0] | |
1401 | @test @inferred(range(0.0, stop=0, length=4)) == [0.0, 0.0, 0.0, 0.0] | |
1402 | ||
1403 | z4 = 0.0 * (1:4) | |
1404 | @test @inferred(z4 .+ (1:4)) === 1.0:1.0:4.0 | |
1405 | @test @inferred(z4 .+ z4) === z4 | |
1406 | end | |
1407 | ||
1408 | @testset "allocation of TwicePrecision call" begin | |
1409 | 0:286.493442:360 | |
1410 | 0:286:360 | |
1411 | @test @allocated(0:286.493442:360) == 0 | |
1412 | @test @allocated(0:286:360) == 0 | |
1413 | end |
774 | 774 | @test typeparam(Float64, rand(2)) == 1 |
775 | 775 | @test typeparam(Int, rand(Int, 2)) == 2 |
776 | 776 | |
777 | # prior ambiguities (issue #28899) | |
778 | uambig(::Union{Int,Nothing}) = 1 | |
779 | uambig(::Union{Float64,Nothing}) = 2 | |
780 | @test uambig(1) == 1 | |
781 | @test uambig(1.0) == 2 | |
782 | @test_throws MethodError uambig(nothing) | |
783 | m = which(uambig, Tuple{Int}) | |
784 | Base.delete_method(m) | |
785 | @test_throws MethodError uambig(1) | |
786 | @test uambig(1.0) == 2 | |
787 | @test uambig(nothing) == 2 | |
788 | ||
777 | 789 | end |
778 | 790 | |
779 | 791 | # issue #26267 |
263 | 263 | s = Set([1,2,3,4]) |
264 | 264 | setdiff!(s, Set([2,4,5,6])) |
265 | 265 | @test isequal(s,Set([1,3])) |
266 | ||
267 | # setdiff iterates the shorter set - make sure this algorithm works | |
268 | sa, sb = Set([1,2,3,4,5,6,7]), Set([2,3,9]) | |
269 | @test Set([1,4,5,6,7]) == setdiff(sa, sb) !== sa | |
270 | @test Set([1,4,5,6,7]) == setdiff!(sa, sb) === sa | |
271 | sa, sb = Set([1,2,3,4,5,6,7]), Set([2,3,9]) | |
272 | @test Set([9]) == setdiff(sb, sa) !== sb | |
273 | @test Set([9]) == setdiff!(sb, sa) === sb | |
266 | 274 | end |
267 | 275 | |
268 | 276 | @testset "ordering" begin |
603 | 611 | end |
604 | 612 | end |
605 | 613 | end |
614 | ||
615 | struct OpenInterval{T} | |
616 | lower::T | |
617 | upper::T | |
618 | end | |
619 | Base.in(x, i::OpenInterval) = i.lower < x < i.upper | |
620 | Base.IteratorSize(::Type{<:OpenInterval}) = Base.SizeUnknown() | |
621 | ||
622 | @testset "Continuous sets" begin | |
623 | i = OpenInterval(2, 4) | |
624 | @test 3 ∈ i | |
625 | @test issubset(3, i) | |
626 | end |
213 | 213 | |
214 | 214 | @test args_morespecific(Tuple{Type{Any}, Type}, Tuple{Type{T}, Type{T}} where T) |
215 | 215 | @test !args_morespecific(Tuple{Type{Any}, Type}, Tuple{Type{T}, Type{T}} where T<:Union{}) |
216 | ||
217 | # issue #22592 | |
218 | abstract type Colorant22592{T,N} end | |
219 | abstract type Color22592{T, N} <: Colorant22592{T,N} end | |
220 | abstract type AbstractRGB22592{T} <: Color22592{T,3} end | |
221 | AbstractGray22592{T} = Color22592{T,1} | |
222 | MathTypes22592{T,C} = Union{AbstractRGB22592{T},AbstractGray22592{T}} | |
223 | @test !args_morespecific(Tuple{MathTypes22592}, Tuple{AbstractGray22592}) | |
224 | @test !args_morespecific(Tuple{MathTypes22592, MathTypes22592}, Tuple{AbstractGray22592}) | |
225 | ||
226 | @test args_morespecific(Union{Set,Dict,Vector}, Union{Vector,AbstractSet}) |
33 | 33 | @test string("∀∃", "1∀∃") === "∀∃1∀∃" |
34 | 34 | @test string(SubString("∀∃"), SubString("1∀∃", 2)) === "∀∃∀∃" |
35 | 35 | @test string(s"123") === s"123" |
36 | @test string("123", 'α', SubString("1∀∃", 2), 'a', "foo") === "123α∀∃afoo" | |
36 | 37 | codegen_egal_of_strings(x, y) = (x===y, x!==y) |
37 | 38 | @test codegen_egal_of_strings(string("ab", 'c'), "abc") === (true, false) |
38 | 39 | let strs = ["", "a", "a b c", "до свидания"] |
1501 | 1501 | end |
1502 | 1502 | @test test27710() === Int64 |
1503 | 1503 | |
1504 | # issue #29064 | |
1505 | struct X29064 | |
1506 | X29064::Int | |
1507 | end | |
1508 | @test X29064(1) isa X29064 | |
1509 | ||
1504 | 1510 | # issue #27268 |
1505 | 1511 | function f27268() |
1506 | 1512 | g(col::AbstractArray{<:Real}) = col |
1641 | 1647 | for ex in [:([x=1]), :(T{x=1})] |
1642 | 1648 | @test Meta.lower(@__MODULE__, ex) == Expr(:error, string("misplaced assignment statement in \"", ex, "\"")) |
1643 | 1649 | end |
1650 | ||
1651 | # issue #28576 | |
1652 | @test Meta.isexpr(Meta.parse("1 == 2 ?"), :incomplete) | |
1653 | @test Meta.isexpr(Meta.parse("1 == 2 ? 3 :"), :incomplete) | |
1654 | ||
1655 | # issue #28991 | |
1656 | eval(Expr(:toplevel, | |
1657 | Expr(:module, true, :Mod28991, | |
1658 | Expr(:block, | |
1659 | Expr(:export, :Inner), | |
1660 | Expr(:abstract, :Inner))))) | |
1661 | @test names(Mod28991) == Symbol[:Inner, :Mod28991] | |
1662 | ||
1663 | # issue #28593 | |
1664 | macro a28593() | |
1665 | quote | |
1666 | abstract type A28593{S<:Real, V<:AbstractVector{S}} end | |
1667 | end | |
1668 | end | |
1669 | ||
1670 | macro b28593() | |
1671 | quote | |
1672 | struct B28593{S<:Real, V<:AbstractVector{S}} end | |
1673 | end | |
1674 | end | |
1675 | ||
1676 | macro c28593() | |
1677 | quote | |
1678 | primitive type C28593{S<:Real, V<:AbstractVector{S}} 32 end | |
1679 | end | |
1680 | end | |
1681 | ||
1682 | @a28593 | |
1683 | @b28593 | |
1684 | @c28593 | |
1685 | ||
1686 | @test A28593.var.name === :S | |
1687 | @test B28593.var.name === :S | |
1688 | @test C28593.var.name === :S | |
1689 | ||
1690 | # issue #25955 | |
1691 | macro noeffect25955(e) | |
1692 | return e | |
1693 | end | |
1694 | ||
1695 | struct foo25955 | |
1696 | end | |
1697 | ||
1698 | @noeffect25955 function (f::foo25955)() | |
1699 | 42 | |
1700 | end | |
1701 | ||
1702 | @test foo25955()() == 42 | |
1703 | ||
1704 | # issue #28833 | |
1705 | macro m28833(expr) | |
1706 | esc(:(global a28833)) | |
1707 | end | |
1708 | @m28833 1+1 | |
1709 | ||
1710 | # issue #28900 | |
1711 | macro foo28900(x) | |
1712 | quote | |
1713 | $x | |
1714 | end | |
1715 | end | |
1716 | f28900(; kwarg) = kwarg | |
1717 | let g = @foo28900 f28900(kwarg = x->2x) | |
1718 | @test g(10) == 20 | |
1719 | end |