@@ -11,11 +11,14 @@ const DEFAULT_MAX_DEGREE = 2
1111"""
1212 AbstractNode{D}
1313
14- Abstract type for D-arity trees. Must have the following fields:
14+ Abstract type for trees which can have up to `D` children per node.
15+ Must have the following fields:
1516
1617- `degree::UInt8`: Degree of the node. This should be a value
17- between 0 and `DEFAULT_MAX_DEGREE`.
18- - `children`: A collection of D references to children nodes.
18+ between 0 and `D`, inclusive.
19+ - `children`: A collection of up to `D` children nodes. The number
20+ of children which are _active_ is given by the `degree` field,
21+ but for type stability reasons, you can have inactive children.
1922
2023# Deprecated fields
2124
@@ -250,12 +253,14 @@ end
250253Base. eltype (:: Type{<:AbstractExpressionNode{T}} ) where {T} = T
251254Base. eltype (:: AbstractExpressionNode{T} ) where {T} = T
252255
256+ # COV_EXCL_START
253257max_degree (:: Type{<:AbstractNode} ) = DEFAULT_MAX_DEGREE
254258max_degree (:: Type{<:AbstractNode{D}} ) where {D} = D
255259max_degree (node:: AbstractNode ) = max_degree (typeof (node))
256260
257261has_max_degree (:: Type{<:AbstractNode} ) = false
258262has_max_degree (:: Type{<:AbstractNode{D}} ) where {D} = true
263+ # COV_EXCL_STOP
259264
260265@unstable function constructorof (:: Type{N} ) where {N<: Node }
261266 return Node{T,max_degree (N)} where {T}
358363 eltype (N)
359364 end
360365end
361- defines_eltype (:: Type{<:AbstractExpressionNode} ) = false
362- defines_eltype (:: Type{<:AbstractExpressionNode{T}} ) where {T} = true
366+ defines_eltype (:: Type{<:AbstractExpressionNode} ) = false # COV_EXCL_LINE
367+ defines_eltype (:: Type{<:AbstractExpressionNode{T}} ) where {T} = true # COV_EXCL_LINE
363368# ! format: on
364369
365370function (:: Type{N} )(
0 commit comments