diff --git a/src/equations.jl b/src/equations.jl index 9739f51de..58e5d4e4e 100644 --- a/src/equations.jl +++ b/src/equations.jl @@ -8,7 +8,9 @@ hide_lhs(_) = false struct Connection systems end +Base.broadcastable(x::Connection) = Ref(x) Connection() = Connection(nothing) +Base.hash(c::Connection, seed::UInt) = hash(c.systems, (0xc80093537bdc1311 % UInt) ⊻ seed) hide_lhs(_::Connection) = true function connect(sys1, sys2, syss...) @@ -19,11 +21,13 @@ end function Base.show(io::IO, c::Connection) print(io, "connect(") - n = length(c.systems) - for (i, s) in enumerate(c.systems) - str = join(split(string(nameof(s)), NAMESPACE_SEPARATOR), '.') - print(io, str) - i != n && print(io, ", ") + if c.systems isa AbstractArray + n = length(c.systems) + for (i, s) in enumerate(c.systems) + str = join(split(string(nameof(s)), NAMESPACE_SEPARATOR), '.') + print(io, str) + i != n && print(io, ", ") + end end print(io, ")") end @@ -34,6 +38,7 @@ end _nameof(s) = nameof(s) _nameof(s::Union{Int, Symbol}) = s abstract type StateMachineOperator end +Base.broadcastable(x::StateMachineOperator) = Ref(x) hide_lhs(_::StateMachineOperator) = true struct InitialState <: StateMachineOperator s diff --git a/src/struct.jl b/src/struct.jl index c96706d30..f829c7a5f 100644 --- a/src/struct.jl +++ b/src/struct.jl @@ -72,6 +72,11 @@ struct Struct <: Real v::Vector{StructElement} end +function Base.hash(x::Struct, seed::UInt) + h1 = hash(juliatype(x), seed) + h2 = foldr(hash, getelements(x), init = h1) + h2 ⊻ (0x0e39036b7de2101a % UInt) +end """ symstruct(T)