From 577662e2020d98b43bcde929edda396f1de595ce Mon Sep 17 00:00:00 2001 From: Grigorii Kirgizov Date: Wed, 10 Jul 2019 12:49:36 +0300 Subject: [PATCH] Fix problem with some recovering rules not being reexecuted --- .../core/internal/ProcessingStateImpl.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt index 2c08b758..eba90569 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt @@ -100,22 +100,6 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp if (chunk is MatchJournal.MatchChunk && ruleIds.contains(chunk.match.rule().uniqueTag())) { justificationRoots.add(chunk.id) - - // We removed the match, so need to reactivate all still valid occurrences from the head - // by definition of Chunk and principal rule, all occurrences from the head are principal - val matchedOccs = chunk.match.allHeads() as Iterable - val (invalidatedOccs, validOccs) = matchedOccs.partition { occ -> - occ.justifications().intersects(justificationRoots) - } - assert(matchedOccs.all { it.isPrincipal() }) - - // todo: do need to reactivate only the main, matching~activating match? - // (i.e. don't reactivate additional, inactive heads that only completed the match?) - execQueue.addAll(validOccs.mapNotNull { occ -> - journalIndex.activatingChunkOf(Id(occ))?.let { chunk -> - ExecPos(chunk.toPos(), occ) - } - }) } // Invalidating dependent chunks @@ -141,6 +125,22 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp chunk.match.matchHeadReplaced().forEach { dispatchingFront = dispatchingFront.forget(it as Occurrence) } + + // We removed the match, so need to reactivate all still valid occurrences from the head + // by definition of Chunk and principal rule, all occurrences from the head are principal + val matchedOccs = chunk.match.allHeads() as Iterable + val (invalidatedOccs, validOccs) = matchedOccs.partition { occ -> + occ.justifications().intersects(justificationRoots) + } + assert(matchedOccs.all { it.isPrincipal() }) + + // todo: do need to reactivate only the main, matching~activating match? + // (i.e. don't reactivate additional, inactive heads that only completed the match?) + execQueue.addAll(validOccs.mapNotNull { occ -> + journalIndex.activatingChunkOf(Id(occ))?.let { chunk -> + ExecPos(chunk.toPos(), occ) + } + }) } }