diff --git a/base/coreimg.jl b/base/coreimg.jl index 60f571669e5789..b22250647327b5 100644 --- a/base/coreimg.jl +++ b/base/coreimg.jl @@ -41,10 +41,10 @@ include("int.jl") include("operators.jl") include("pointer.jl") -# # traits +# traits getindex(A::Array, i1::Real) = arrayref(A, to_index(i1)) include("traits.jl") -#include("traits-bootstrap-tests.jl") +include("traits-bootstrap-tests.jl") # core array operations include("abstractarray.jl") diff --git a/base/sysimg.jl b/base/sysimg.jl index f9e160b3094127..cfd042c1432f9a 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -15,7 +15,7 @@ eval(m,x) = Core.eval(m,x) include("exports.jl") -if false +if true # simple print definitions for debugging. enable these if something # goes wrong during bootstrap before printing code is available. show(x::ANY) = ccall(:jl_static_show, Void, (Ptr{Void}, Any), @@ -51,7 +51,7 @@ include("functors.jl") # traits include("traits.jl") -#include("traits-bootstrap-tests.jl") +include("traits-bootstrap-tests.jl") # array structures include("abstractarray.jl") diff --git a/base/traits.jl b/base/traits.jl index 305ec71ac38244..7fa9b4068f0546 100644 --- a/base/traits.jl +++ b/base/traits.jl @@ -210,7 +210,7 @@ macro traitfn(tfn) tmp1 = :($tmp1()) addtoargs!(tmp1, args) tmp2 = :($fname($curmod.trait($trait))) - addtoargs!(tmp2, striparg(args)) + addtoargs!(tmp2, stripType(striparg(args))) fwrap = :($tmp1 = ($curmod.@_inline_meta(); $tmp2)) # The function containing the logic @@ -252,6 +252,11 @@ striparg{T}(args::Array{T,1}) = [striparg(args[i]) for i=1:arraylen(args)] striparg(a::Symbol) = a striparg(a::Expr) = a.args[1] +# :(Type{X}) -> X, X->X +stripType{T}(args::Array{T,1}) = [stripType(args[i]) for i=1:arraylen(args)] +stripType(a::Symbol) = a +stripType(a::Expr) = (a.head==:curly && a.args[1]==:Type) ? a.args[2] : a + #### # Some trait definitions #### @@ -273,19 +278,20 @@ typealias IsNothing{X} Not{IsAnything{X}} end end -# # from reflection.jl (need to be moved elsewhere because they don't bootstrap here) # "Trait of all isbits-types" # @traitdef IsBits{X} -# @generated trait{X}(::Type{IsBits{X}}) = +# @generated function trait{X}(::Type{IsBits{X}}) # isbits(X) ? :(IsBits{X}) : :(Not{IsBits{X}}) +# end # "Trait of all immutable types" # @traitdef IsImmutable{X} -# @generated trait{X}(::Type{IsImmutable{X}}) = +# @generated function trait{X}(::Type{IsImmutable{X}}) # X.mutable ? :(Not{IsImmutable{X}}) : :(IsImmutable{X}) +# end # "Trait of all leaf types types" # @traitdef IsLeafType{X} -# @generated trait{X}(::Type{IsLeafType{X}}) = +# @generated function trait{X}(::Type{IsLeafType{X}}) # X.mutable ? :(Not{IsLeafType{X}}) : :(IsLeafType{X}) - +# end