|
17 | 17 |
|
18 | 18 | if PACKAGE_VERSION < v"0.18.6" |
19 | 19 | @eval using DynamicExpressions: |
20 | | - index_constants as index_constant_nodes, count_constants as count_constant_nodes |
| 20 | + index_constants as index_constant_nodes, |
| 21 | + count_constants as count_constant_nodes, |
| 22 | + get_constants as get_scalar_constants, |
| 23 | + set_constants! as set_scalar_constants! |
21 | 24 | end |
22 | 25 |
|
23 | 26 | include("../test/tree_gen_utils.jl") |
@@ -115,15 +118,16 @@ end |
115 | 118 | PACKAGE_VERSION < v"0.14.0" && return :(copy_node(t; preserve_sharing=preserve_sharing)) |
116 | 119 | return :(copy_node(t)) # Assume type used to infer sharing |
117 | 120 | end |
118 | | -@generated function get_set_constants!(tree::N) where {T,N<:AbstractExpressionNode{T}} |
119 | | - if !(@isdefined set_constants!) |
120 | | - return :(set_constants(tree, get_constants(tree))) |
121 | | - elseif hasmethod(set_constants!, Tuple{N, Vector{T}}) |
122 | | - return :(set_constants!(tree, get_constants(tree))) |
| 121 | +@generated function get_set_constants!(tree::N) where {N} |
| 122 | + T = eltype(N) |
| 123 | + if !(@isdefined set_scalar_constants!) |
| 124 | + return :(set_scalar_constants(tree, get_scalar_constants(tree))) |
| 125 | + elseif hasmethod(set_scalar_constants!, Tuple{N, Vector{T}}) |
| 126 | + return :(set_scalar_constants!(tree, get_scalar_constants(tree))) |
123 | 127 | else |
124 | 128 | return quote |
125 | | - let (x, refs) = get_constants(tree) |
126 | | - set_constants!(tree, x, refs) |
| 129 | + let (x, refs) = get_scalar_constants(tree) |
| 130 | + set_scalar_constants!(tree, x, refs) |
127 | 131 | end |
128 | 132 | end |
129 | 133 | end |
|
0 commit comments