@@ -12,6 +12,7 @@ using ..NodeModule:
1212 constructorof,
1313 default_allocator,
1414 with_type_parameters,
15+ children,
1516 leaf_copy,
1617 leaf_convert,
1718 leaf_hash,
@@ -248,8 +249,8 @@ function _check_eltype(tree::AbstractExpressionNode{T}) where {T}
248249end
249250function _check_with_type_parameters (tree:: AbstractExpressionNode{T} ) where {T}
250251 N = typeof (tree)
251- NT = with_type_parameters (Base . typename (N) . wrapper, eltype (tree) )
252- return NT == typeof (tree)
252+ Nf16 = with_type_parameters (N, Float16 )
253+ return Nf16 <: AbstractExpressionNode{Float16}
253254end
254255function _check_default_allocator (tree:: AbstractExpressionNode )
255256 N = Base. typename (typeof (tree)). wrapper
@@ -299,35 +300,21 @@ function _check_leaf_equal(tree::AbstractExpressionNode)
299300 return leaf_equal (tree, copy (tree))
300301end
301302function _check_branch_copy (tree:: AbstractExpressionNode )
302- if tree. degree == 0
303- return true
304- elseif tree. degree == 1
305- return branch_copy (tree, tree. l) isa typeof (tree)
306- else
307- return branch_copy (tree, tree. l, tree. r) isa typeof (tree)
308- end
303+ tree. degree == 0 && return true
304+ return branch_copy (tree, children (tree, Val (tree. degree))... ) isa typeof (tree)
309305end
310306function _check_branch_copy_into! (tree:: AbstractExpressionNode{T} ) where {T}
311- if tree. degree == 0
312- return true
313- end
307+ tree. degree == 0 && return true
314308 new_branch = constructorof (typeof (tree))(; val= zero (T))
315- if tree. degree == 1
316- ret = branch_copy_into! (new_branch, tree, copy (tree. l))
317- return new_branch == tree && ret === new_branch
318- else
319- ret = branch_copy_into! (new_branch, tree, copy (tree. l), copy (tree. r))
320- return new_branch == tree && ret === new_branch
321- end
309+ ret = branch_copy_into! (
310+ new_branch, tree, map (copy, children (tree, Val (tree. degree)))...
311+ )
312+ return new_branch == tree && ret === new_branch
322313end
323314function _check_branch_convert (tree:: AbstractExpressionNode )
324- if tree. degree == 0
325- return true
326- elseif tree. degree == 1
327- return branch_convert (typeof (tree), tree, tree. l) isa typeof (tree)
328- else
329- return branch_convert (typeof (tree), tree, tree. l, tree. r) isa typeof (tree)
330- end
315+ tree. degree == 0 && return true
316+ return branch_convert (typeof (tree), tree, children (tree, Val (tree. degree))... ) isa
317+ typeof (tree)
331318end
332319function _check_branch_hash (tree:: AbstractExpressionNode )
333320 tree. degree == 0 && return true
0 commit comments