in reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ReteRuleMatcherImpl.kt [318:348]
override fun update(nodes: UnionFindLinkedList<ReteNode>, introTrail: Trail, introNodes: MutableMap<Int, MutableList<ReteNode>>): Boolean {
var found = false
while (true) {
val n = onTopOf.nextNode(nodesIt)
if (n == null) break
if (n.isInvalid()) {
nodesIt.remove()
continue
}
val it = headPosMask.iterator()
while (it.hasNext()) {
val headPos = it.next()
if (n.occupiesHeadPosition(headPos)) continue
with(createOccurrenceMatcher(n.subst())) {
if (matches(head[headPos], occurrence)) {
val intro = AlphaNode(occurrence, headPos, subst())
introNodes.getOrPut(occurrence.identity) { arrayListOf() }.add(intro)
nodes.add(n.combine(intro, subst()))
found = true
}
}
}
if (found) {
introTrail.add(occurrence.identity)
}
}
return found
}