@@ -7,9 +7,9 @@ export StaticInt, StaticFloat64, StaticSymbol, True, False, StaticBool, NDIndex
7
7
export dynamic, is_static, known, static
8
8
9
9
@static if VERSION >= v " 1.7.0-DEV.421"
10
- using Base: @aggressive_constprop
10
+ using Base: @constprop
11
11
else
12
- macro aggressive_constprop ( ex)
12
+ macro constprop (_, ex)
13
13
ex
14
14
end
15
15
end
@@ -30,7 +30,7 @@ Returns the known value corresponding to a static type `T`. If `T` is not a stat
30
30
See also: [`static`](@ref), [`is_static`](@ref)
31
31
"""
32
32
known
33
- @aggressive_constprop known (x) = known (typeof (x))
33
+ @constprop :aggressive known (x) = known (typeof (x))
34
34
known (:: Type{T} ) where {T} = nothing
35
35
known (:: Type{StaticInt{N}} ) where {N} = N:: Int
36
36
known (:: Type{StaticFloat64{N}} ) where {N} = N:: Float64
@@ -67,19 +67,19 @@ static(:x)
67
67
```
68
68
"""
69
69
static
70
- @aggressive_constprop static (x:: X ) where {X} = ifelse (is_static (X), identity, _no_static_type)(x)
71
- @aggressive_constprop static (x:: Int ) = StaticInt (x)
72
- @aggressive_constprop static (x:: Union{Int8,UInt8,Int16,UInt16} ) = StaticInt (x % Int)
70
+ @constprop :aggressive static (x:: X ) where {X} = ifelse (is_static (X), identity, _no_static_type)(x)
71
+ @constprop :aggressive static (x:: Int ) = StaticInt (x)
72
+ @constprop :aggressive static (x:: Union{Int8,UInt8,Int16,UInt16} ) = StaticInt (x % Int)
73
73
@static if sizeof (Int) == 8
74
- @aggressive_constprop static (x:: Union{Int32,UInt32} ) = StaticInt (x % Int)
75
- @aggressive_constprop static (x:: UInt64 ) = StaticInt (Int (x))
74
+ @constprop :aggressive static (x:: Union{Int32,UInt32} ) = StaticInt (x % Int)
75
+ @constprop :aggressive static (x:: UInt64 ) = StaticInt (Int (x))
76
76
else
77
- @aggressive_constprop static (x:: UInt32 ) = StaticInt (Int (x))
77
+ @constprop :aggressive static (x:: UInt32 ) = StaticInt (Int (x))
78
78
end
79
- @aggressive_constprop static (x:: Float64 ) = StaticFloat64 (x)
80
- @aggressive_constprop static (x:: Bool ) = StaticBool (x)
81
- @aggressive_constprop static (x:: Symbol ) = StaticSymbol (x)
82
- @aggressive_constprop static (x:: Tuple{Vararg{Any}} ) = map (static, x)
79
+ @constprop :aggressive static (x:: Float64 ) = StaticFloat64 (x)
80
+ @constprop :aggressive static (x:: Bool ) = StaticBool (x)
81
+ @constprop :aggressive static (x:: Symbol ) = StaticSymbol (x)
82
+ @constprop :aggressive static (x:: Tuple{Vararg{Any}} ) = map (static, x)
83
83
@generated static (:: Val{V} ) where {V} = static (V)
84
84
function _no_static_type (@nospecialize (x))
85
85
error (" There is no static alternative for type $(typeof (x)) ." )
@@ -102,7 +102,7 @@ is_static(@nospecialize(x::Type{<:Val})) = True()
102
102
is_static (@nospecialize (x:: Type{<:StaticFloat64} )) = True ()
103
103
is_static (x:: Type{T} ) where {T} = False ()
104
104
105
- @aggressive_constprop _tuple_static (:: Type{T} , i) where {T} = is_static (_get_tuple (T, i))
105
+ @constprop :aggressive _tuple_static (:: Type{T} , i) where {T} = is_static (_get_tuple (T, i))
106
106
function is_static (:: Type{T} ) where {N,T<: Tuple{Vararg{Any,N}} }
107
107
if all (eachop (_tuple_static, nstatic (Val (N)), T))
108
108
return True ()
@@ -119,7 +119,7 @@ Returns the "dynamic" or non-static form of `x`.
119
119
dynamic (x:: X ) where {X} = _dynamic (is_static (X), x)
120
120
_dynamic (:: True , x:: X ) where {X} = known (X)
121
121
_dynamic (:: False , x:: X ) where {X} = x
122
- @aggressive_constprop dynamic (x:: Tuple ) = map (dynamic, x)
122
+ @constprop :aggressive dynamic (x:: Tuple ) = map (dynamic, x)
123
123
dynamic (x:: NDIndex ) = CartesianIndex (dynamic (Tuple (x)))
124
124
125
125
end
0 commit comments