|
1 | 1 | module EvaluateModule |
2 | 2 |
|
3 | | -using DispatchDoctor: @unstable |
| 3 | +using DispatchDoctor: @stable, @unstable |
4 | 4 |
|
5 | 5 | import ..NodeModule: AbstractExpressionNode, constructorof |
6 | 6 | import ..StringsModule: string_tree |
@@ -51,39 +51,53 @@ struct EvalOptions{T,B,E} |
51 | 51 | early_exit::Val{E} |
52 | 52 | end |
53 | 53 |
|
54 | | -@inline _to_bool_val(x::Bool) = x ? Val(true) : Val(false) |
55 | | -@inline _to_bool_val(x::Val{T}) where {T} = Val(T::Bool) |
56 | | - |
57 | | -function EvalOptions(; |
58 | | - turbo::Union{Bool,Val}=Val(false), |
59 | | - bumper::Union{Bool,Val}=Val(false), |
60 | | - early_exit::Union{Bool,Val}=Val(true), |
| 54 | +@stable( |
| 55 | + default_mode = "disable", |
| 56 | + default_union_limit = 2, |
| 57 | + @inline _to_bool_val(x::Bool) = x ? Val(true) : Val(false) |
61 | 58 | ) |
62 | | - return EvalOptions(_to_bool_val(turbo), _to_bool_val(bumper), _to_bool_val(early_exit)) |
63 | | -end |
64 | | - |
65 | | -function _process_deprecated_kws(eval_options, deprecated_kws) |
66 | | - turbo = get(deprecated_kws, :turbo, nothing) |
67 | | - bumper = get(deprecated_kws, :bumper, nothing) |
68 | | - if any(Base.Fix2(∉, (:turbo, :bumper)), keys(deprecated_kws)) |
69 | | - throw(ArgumentError("Invalid keyword argument(s): $(keys(deprecated_kws))")) |
70 | | - end |
71 | | - if !isempty(deprecated_kws) |
72 | | - @assert eval_options === nothing "Cannot use both `eval_options` and deprecated flags `turbo` and `bumper`." |
73 | | - Base.depwarn( |
74 | | - "The `turbo` and `bumper` keyword arguments are deprecated. Please use `eval_options` instead.", |
75 | | - :eval_tree_array, |
76 | | - ) |
77 | | - end |
78 | | - if eval_options !== nothing |
79 | | - return eval_options |
80 | | - else |
81 | | - return EvalOptions(; |
82 | | - turbo=turbo === nothing ? Val(false) : turbo, |
83 | | - bumper=bumper === nothing ? Val(false) : bumper, |
| 59 | +@stable(default_mode = "disable", @inline _to_bool_val(x::Val{T}) where {T} = Val(T::Bool)) |
| 60 | + |
| 61 | +@stable( |
| 62 | + default_mode = "disable", |
| 63 | + default_union_limit = 4, |
| 64 | + begin |
| 65 | + function EvalOptions(; |
| 66 | + turbo::Union{Bool,Val}=Val(false), |
| 67 | + bumper::Union{Bool,Val}=Val(false), |
| 68 | + early_exit::Union{Bool,Val}=Val(true), |
84 | 69 | ) |
| 70 | + return EvalOptions( |
| 71 | + _to_bool_val(turbo), _to_bool_val(bumper), _to_bool_val(early_exit) |
| 72 | + ) |
| 73 | + end |
| 74 | + |
| 75 | + function _process_deprecated_kws(eval_options, deprecated_kws) |
| 76 | + turbo = get(deprecated_kws, :turbo, nothing) |
| 77 | + bumper = get(deprecated_kws, :bumper, nothing) |
| 78 | + if any(Base.Fix2(∉, (:turbo, :bumper)), keys(deprecated_kws)) |
| 79 | + throw( |
| 80 | + ArgumentError("Invalid keyword argument(s): $(keys(deprecated_kws))") |
| 81 | + ) |
| 82 | + end |
| 83 | + if !isempty(deprecated_kws) |
| 84 | + @assert eval_options === nothing "Cannot use both `eval_options` and deprecated flags `turbo` and `bumper`." |
| 85 | + Base.depwarn( |
| 86 | + "The `turbo` and `bumper` keyword arguments are deprecated. Please use `eval_options` instead.", |
| 87 | + :eval_tree_array, |
| 88 | + ) |
| 89 | + end |
| 90 | + if eval_options !== nothing |
| 91 | + return eval_options |
| 92 | + else |
| 93 | + return EvalOptions(; |
| 94 | + turbo=turbo === nothing ? Val(false) : turbo, |
| 95 | + bumper=bumper === nothing ? Val(false) : bumper, |
| 96 | + ) |
| 97 | + end |
| 98 | + end |
85 | 99 | end |
86 | | -end |
| 100 | +) |
87 | 101 |
|
88 | 102 | """ |
89 | 103 | eval_tree_array( |
|
0 commit comments