@@ -147,18 +147,32 @@ struct ConnectionElement
147
147
sys:: LazyNamespace
148
148
v:: Any
149
149
isouter:: Bool
150
+ h:: UInt
150
151
end
151
- Base. nameof (l:: ConnectionElement ) = renamespace (nameof (l. sys), getname (l. v))
152
- function Base. hash (l:: ConnectionElement , salt:: UInt )
153
- hash (nameof (l. sys)) ⊻ hash (l. v) ⊻ hash (l. isouter) ⊻ salt
152
+ function _hash_impl (sys, v, isouter)
153
+ hashcore = hash (nameof (sys)) ⊻ hash (v)
154
+ hashouter = isouter ? hash (true ) : hash (false )
155
+ hashcore ⊻ hashouter
156
+ end
157
+ function ConnectionElement (sys:: LazyNamespace , v, isouter:: Bool )
158
+ ConnectionElement (sys, v, isouter, _hash_impl (sys, v, isouter))
154
159
end
160
+ Base. nameof (l:: ConnectionElement ) = renamespace (nameof (l. sys), getname (l. v))
155
161
Base. isequal (l1:: ConnectionElement , l2:: ConnectionElement ) = l1 == l2
156
162
function Base.:(== )(l1:: ConnectionElement , l2:: ConnectionElement )
157
163
nameof (l1. sys) == nameof (l2. sys) && isequal (l1. v, l2. v) && l1. isouter == l2. isouter
158
164
end
165
+ Base. hash (e:: ConnectionElement , salt:: UInt ) = e. h ⊻ salt
159
166
namespaced_var (l:: ConnectionElement ) = states (l, l. v)
160
167
states (l:: ConnectionElement , v) = states (copy (l. sys), v)
161
168
169
+ function withtrueouter (e:: ConnectionElement )
170
+ e. isouter && return e
171
+ # we undo the xor
172
+ newhash = (e. h ⊻ hash (false )) ⊻ hash (true )
173
+ ConnectionElement (e. sys, e. v, true , newhash)
174
+ end
175
+
162
176
struct ConnectionSet
163
177
set:: Vector{ConnectionElement} # namespace.sys, var, isouter
164
178
end
@@ -353,9 +367,7 @@ function partial_merge(csets::AbstractVector{<:ConnectionSet}, allouter = false)
353
367
merged = false
354
368
for (j, cset) in enumerate (csets)
355
369
if allouter
356
- cset = ConnectionSet (map (cset. set) do e
357
- @set! e. isouter = true
358
- end )
370
+ cset = ConnectionSet (map (withtrueouter, cset. set))
359
371
end
360
372
idx = nothing
361
373
for e in cset. set
390
402
391
403
function generate_connection_equations_and_stream_connections (csets:: AbstractVector {
392
404
<: ConnectionSet ,
393
- })
405
+ })
394
406
eqs = Equation[]
395
407
stream_connections = ConnectionSet[]
396
408
0 commit comments