From 3b0008ad22b1497fe3880864e4a588e9a4f93d4b Mon Sep 17 00:00:00 2001 From: Grigorii Kirgizov Date: Mon, 3 Feb 2020 17:28:50 +0300 Subject: [PATCH] Remove some unused code --- .../reactor/core/internal/ExecutionQueue.kt | 14 ------------- .../reactor/core/internal/MatchJournal.kt | 21 ++----------------- .../reactor/core/internal/MatchJournalImpl.kt | 15 ------------- 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ExecutionQueue.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ExecutionQueue.kt index f853d2b9..72bcc453 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ExecutionQueue.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ExecutionQueue.kt @@ -115,15 +115,6 @@ internal class ExecutionQueue( return currentMatches } - /** - * Replays [processing] until a match of [matchedRule] can be inserted according to [RuleOrdering] - * If [ConstraintsProcessing.isFront] is true, then no unnecessary work is done. - */ - fun replayToMatch(matchedRule: Rule, activationChunk: MatchJournal.OccChunk, processing: ConstraintsProcessing) = - processing.replayUntil(processing.logicalState) { chunk -> - canBeInserted(matchedRule, activationChunk, chunk) - } - /** * Checks whether [candidateRule] can be inserted in journal as a child * of [parentChunk] before one of its child chunks, [beforeChunk]. @@ -158,11 +149,6 @@ internal class ExecutionQueue( if (seen.add(it)) execQueue.offer(it) else false } - // todo: remove - // special case when position in trace corresponds to position of activated occurrence -// fun offer(posInJournal: MatchJournal.Pos): Boolean = -// offer(posInJournal, posInJournal.occ) - fun isEmpty(): Boolean = execQueue.isEmpty() fun isNotEmpty(): Boolean = execQueue.isNotEmpty() diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt index bb41b2f5..e1d2a8f5 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt @@ -80,11 +80,6 @@ interface MatchJournal : MutableIterable { */ fun replayDescendants(observable: LogicalStateObservable, ancestor: Chunk, until: Pos) - /** - * Same as [replay]: replays [Chunk]s until [pred] returns true. - * May replay the whole journal, in which case position will point to the end of journal. - */ - fun replayUntil(observable: LogicalStateObservable, pred: (Chunk) -> Boolean) /** * Returns snapshot of the journal. @@ -121,14 +116,6 @@ interface MatchJournal : MutableIterable { */ fun lastDescendantOf(occChunk: OccChunk): Chunk? - // todo: remove - /** - * Returns [Pos] at which provided [RuleMatch] can be inserted - * according to its indexed head [Occurrence]s and rule ordering. - * Returns for matches of non-principal rules. - */ -// fun positionFor(newMatch: RuleMatchEx): Pos? - /** * Returns [Pos] at which provided [RuleMatch] is triggered * according to its indexed head [Occurrence]s. @@ -170,8 +157,8 @@ interface MatchJournal : MutableIterable { fun isDescendantOf(chunkId: Int): Boolean = justifications.contains(chunkId) fun isTopLevel(): Boolean = justifications.size() <= 1 // this condition implies that there're no ancestor chunks - fun activatedLog(): List = entriesLog().filter { !it.discarded() }.map { it.occ() as Occurrence } - fun discardedLog(): List = entriesLog().filter { it.discarded() }.map { it.occ() as Occurrence } + fun activatedLog(): List = entriesLog().filter { !it.discarded() }.map { it.occ() } + fun discardedLog(): List = entriesLog().filter { it.discarded() }.map { it.occ() } /** * Returns the resulting collection of activated occurrences @@ -204,10 +191,6 @@ interface MatchJournal : MutableIterable { } open class Pos(val chunk: Chunk, val entriesCount: Int) { - // todo: remove - val occ: Occurrence - get() = chunk.entriesLog()[entriesCount - 1].occ() - override fun equals(other: Any?) = other is Pos && other.chunk === chunk diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt index 6f71f896..d6006ab8 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt @@ -163,21 +163,6 @@ internal open class MatchJournalImpl( if (currentPos() != until) throw IllegalStateException() } - override fun replayUntil(observable: LogicalStateObservable, pred: (Chunk) -> Boolean) { - // todo: case when pred(current) == true? need replaying rest of current.entries? - while (posPtr.hasNext()) { - val previous = current - current = posPtr.next() - if (pred(current)) { - // reset ptr so that it points after previous chunk - current = previous - posPtr.previous() - return - } - replayOccurrences(observable, current.entries) - } - } - private fun resetOccurrences(occSpecs: Iterable) = occSpecs.forEach { if (it.discarded) {