@@ -6,6 +6,7 @@ using ..NodeModule: AbstractExpressionNode, Node
66using .. OperatorEnumModule: AbstractOperatorEnum, OperatorEnum
77using .. UtilsModule: Undefined
88
9+ import .. NodeModule: copy_node, set_node!, count_nodes, tree_mapreduce, constructorof
910import .. NodeUtilsModule:
1011 preserve_sharing,
1112 count_constants,
128129function Base. copy (ex:: AbstractExpression ; break_sharing:: Val = Val (false ))
129130 return error (" `copy` function must be implemented for $(typeof (ex)) types." )
130131end
131- function Base. hash (ex:: AbstractExpression , h:: UInt )
132- return error (" `hash` function must be implemented for $(typeof (ex)) types." )
133- end
134- function Base.:(== )(x:: AbstractExpression , y:: AbstractExpression )
135- return error (" `==` function must be implemented for $(typeof (x)) types." )
136- end
137132function get_constants (ex:: AbstractExpression )
138133 return error (" `get_constants` function must be implemented for $(typeof (ex)) types." )
139134end
@@ -199,25 +194,17 @@ end
199194function Base. copy (ex:: Expression ; break_sharing:: Val = Val (false ))
200195 return Expression (copy (ex. tree; break_sharing), copy (ex. metadata))
201196end
202- function Base. hash (ex:: Expression , h:: UInt )
203- return hash (ex . tree , hash (ex . metadata , h))
197+ function Base. hash (ex:: AbstractExpression , h:: UInt )
198+ return hash (get_contents (ex) , hash (get_metadata (ex) , h))
204199end
205-
206- """
207- Base.:(==)(x::Expression, y::Expression)
208-
209- Check equality of two expressions `x` and `y` by comparing their trees and metadata.
210- """
211- function Base.:(== )(x:: Expression , y:: Expression )
212- return x. tree == y. tree && x. metadata == y. metadata
200+ function Base.:(== )(x:: AbstractExpression , y:: AbstractExpression )
201+ return get_contents (x) == get_contents (y) && get_metadata (x) == get_metadata (y)
213202end
214203
215204# Overload all methods on AbstractExpressionNode that return an aggregation, or can
216205# return an entire tree. Methods that only return the nodes are *not* overloaded, so
217206# that the user must use the low-level interface.
218207
219- import .. NodeModule: copy_node, set_node!, count_nodes, tree_mapreduce, constructorof
220-
221208# ! format: off
222209@unstable constructorof (:: Type{E} ) where {E<: AbstractExpression } = Base. typename (E). wrapper
223210@unstable constructorof (:: Type{<:Expression} ) = Expression
0 commit comments