@@ -133,72 +133,40 @@ func (c *closeContext) matchDecrement(ctx *OpContext, v *Vertex, kind depKind, d
133
133
}
134
134
}
135
135
136
- // addDependency adds a dependent arc to c. If child is an arc, child.src == key
137
- func (c * closeContext ) addDependency (ctx * OpContext , kind depKind , matched bool , key , child , root * closeContext ) {
136
+ // addArc adds a dependent arc to c. If child is an arc, child.src == key
137
+ func (c * closeContext ) addArcDependency (ctx * OpContext , matched bool , key , child , root * closeContext ) {
138
+ const kind = ARC
139
+
138
140
// NOTE: do not increment
139
141
// - either root closeContext or otherwise resulting from sub closeContext
140
142
// all conjuncts will be added now, notified, or scheduled as task.
141
- switch kind {
142
- case ARC :
143
- for _ , a := range c .arcs {
144
- if a .key == key {
145
- panic ("addArc: Label already exists" )
146
- }
147
- }
148
- child .incDependent (ctx , kind , c ) // matched in decDependent REF(arcs)
149
-
150
- c .arcs = append (c .arcs , ccArc {
151
- matched : matched ,
152
- key : key ,
153
- cc : child ,
154
- })
155
-
156
- // TODO: this tests seems sensible, but panics. Investigate what could
157
- // trigger this.
158
- // if child.src.Parent != c.src {
159
- // panic("addArc: inconsistent parent")
160
- // }
161
- if child .src .cc () != root .src .cc () {
162
- panic ("addArc: inconsistent root" )
163
- }
164
-
165
- root .externalDeps = append (root .externalDeps , ccArcRef {
166
- src : c ,
167
- kind : kind ,
168
- index : len (c .arcs ) - 1 ,
169
- })
170
- case NOTIFY :
171
- for _ , a := range c .notify {
172
- if a .key == key {
173
- panic ("addArc: Label already exists" )
174
- }
175
- }
176
- child .incDependent (ctx , kind , c ) // matched in decDependent REF(arcs)
177
-
178
- c .notify = append (c .notify , ccArc {
179
- matched : matched ,
180
- key : key ,
181
- cc : child ,
182
- })
183
-
184
- // TODO: this tests seems sensible, but panics. Investigate what could
185
- // trigger this.
186
- // if child.src.Parent != c.src {
187
- // panic("addArc: inconsistent parent")
188
- // }
189
- if child .src .cc () != root .src .cc () {
190
- panic ("addArc: inconsistent root" )
143
+ for _ , a := range c .arcs {
144
+ if a .key == key {
145
+ panic ("addArc: Label already exists" )
191
146
}
192
-
193
- root .externalDeps = append (root .externalDeps , ccArcRef {
194
- src : c ,
195
- kind : kind ,
196
- index : len (c .notify ) - 1 ,
197
- })
198
- default :
199
- panic (kind )
147
+ }
148
+ child .incDependent (ctx , kind , c ) // matched in decDependent REF(arcs)
149
+
150
+ c .arcs = append (c .arcs , ccArc {
151
+ matched : matched ,
152
+ key : key ,
153
+ cc : child ,
154
+ })
155
+
156
+ // TODO: this tests seems sensible, but panics. Investigate what could
157
+ // trigger this.
158
+ // if child.src.Parent != c.src {
159
+ // panic("addArc: inconsistent parent")
160
+ // }
161
+ if child .src .cc () != root .src .cc () {
162
+ panic ("addArc: inconsistent root" )
200
163
}
201
164
165
+ root .externalDeps = append (root .externalDeps , ccArcRef {
166
+ src : c ,
167
+ kind : kind ,
168
+ index : len (c .arcs ) - 1 ,
169
+ })
202
170
}
203
171
204
172
func (cc * closeContext ) linkNotify (ctx * OpContext , key * closeContext ) bool {
@@ -208,10 +176,41 @@ func (cc *closeContext) linkNotify(ctx *OpContext, key *closeContext) bool {
208
176
}
209
177
}
210
178
211
- cc .addDependency (ctx , NOTIFY , false , key , key , key .src .cc ())
179
+ cc .addNotificationDependency (ctx , false , key , key , key .src .cc ())
212
180
return true
213
181
}
214
182
183
+ func (c * closeContext ) addNotificationDependency (ctx * OpContext , matched bool , key , child , root * closeContext ) {
184
+ const kind = NOTIFY
185
+ for _ , a := range c .notify {
186
+ if a .key == key {
187
+ panic ("addArc: Label already exists" )
188
+ }
189
+ }
190
+ child .incDependent (ctx , kind , c ) // matched in decDependent REF(arcs)
191
+
192
+ c .notify = append (c .notify , ccArc {
193
+ matched : matched ,
194
+ key : key ,
195
+ cc : child ,
196
+ })
197
+
198
+ // TODO: this tests seems sensible, but panics. Investigate what could
199
+ // trigger this.
200
+ // if child.src.Parent != c.src {
201
+ // panic("addArc: inconsistent parent")
202
+ // }
203
+ if child .src .cc () != root .src .cc () {
204
+ panic ("addArc: inconsistent root" )
205
+ }
206
+
207
+ root .externalDeps = append (root .externalDeps , ccArcRef {
208
+ src : c ,
209
+ kind : kind ,
210
+ index : len (c .notify ) - 1 ,
211
+ })
212
+ }
213
+
215
214
// incDisjunct increases disjunction-related counters. We require kind to be
216
215
// passed explicitly so that we can easily find the points where certain kinds
217
216
// are used.
0 commit comments