diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleMatchingProbe.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleMatchingProbe.kt index 47be0db3..66349bda 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleMatchingProbe.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleMatchingProbe.kt @@ -16,7 +16,6 @@ package jetbrains.mps.logic.reactor.core -import jetbrains.mps.logic.reactor.evaluation.RuleMatchingProbeState import jetbrains.mps.logic.reactor.program.Rule import jetbrains.mps.logic.reactor.util.Profiler @@ -27,7 +26,7 @@ import java.util.BitSet * * @author Fedor Isakov */ -interface RuleMatchingProbe : RuleMatchingProbeState { +interface RuleMatchingProbe { fun rule(): Rule diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/EvaluationSessionImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/EvaluationSessionImpl.kt index 002684c2..952830fa 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/EvaluationSessionImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/EvaluationSessionImpl.kt @@ -71,7 +71,7 @@ internal class EvaluationSessionImpl private constructor ( val processing = ConstraintsProcessing( Dispatcher(ruleIndex, tkn.getFrontState()).front(), - MatchJournalImpl(ispec, tkn.journalView), + MatchJournalImpl(ispec, tkn.journalView as MatchJournal.View), ruleIndex, logicalState, ispec, trace, profiler ) val controller = ControllerImpl(supervisor, processing, ispec, trace, profiler) 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 a0a51f15..2377172c 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 @@ -133,23 +133,21 @@ interface MatchJournal : MutableIterable, EvidenceSource { /** * Immutable snapshot of [MatchJournal]. */ - data class View(private val chunks: List, private val evidenceSeed: Evidence) : MatchJournalView { - override fun getChunks(): List = chunks - override fun getEvidenceSeed(): Evidence = evidenceSeed + data class View(val chunks: List, val evidenceSeed: Evidence) : MatchJournalView { override fun getStoreView(): StoreView = StoreViewImpl( chunks.flatMap { it.entriesLog() }.allOccurrences().asSequence() ) } - interface Chunk : MatchJournalChunk, Justified { + interface Chunk : Justified { // fixme: hide rm-mutability var entries: MutableList - override fun entriesLog(): List = entries + fun entriesLog(): List = entries - data class Entry(val occ: Occurrence, val discarded: Boolean = false) : MatchJournalChunk.Entry { - override fun occ(): Occurrence = occ - override fun discarded(): Boolean = discarded + data class Entry(val occ: Occurrence, val discarded: Boolean = false) { + fun occ(): Occurrence = occ + fun discarded(): Boolean = discarded override fun toString() = (if (discarded) '-' else '+') + occ.toString() } @@ -219,7 +217,7 @@ internal class StoreViewImpl(occurrences: Sequence) : StoreView { } -private fun Iterable.allOccurrences(): List { +private fun Iterable.allOccurrences(): List { val set = HashSet>() for (it in this) { val idOcc = Id(it.occ() as Occurrence) 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 b4c991bb..957f4a35 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 @@ -32,7 +32,7 @@ import java.util.* internal open class MatchJournalImpl( private val ispec: IncrementalProgramSpec, - view: MatchJournalView? = null + view: MatchJournal.View? = null ) : MatchJournal { // invariant: never empty diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/MatchJournalChunk.java b/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/MatchJournalChunk.java deleted file mode 100644 index a92f250e..00000000 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/MatchJournalChunk.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2014-2019 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jetbrains.mps.logic.reactor.evaluation; - -import java.util.List; - - -public interface MatchJournalChunk { - interface Entry { - ConstraintOccurrence occ(); - boolean discarded(); - } - - List entriesLog(); -} diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/MatchJournalView.java b/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/MatchJournalView.java index 15af24e0..d3bb9d0b 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/MatchJournalView.java +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/MatchJournalView.java @@ -20,10 +20,5 @@ import org.jetbrains.annotations.NotNull; import java.util.List; public interface MatchJournalView { - @NotNull - List getChunks(); - - int getEvidenceSeed(); - StoreView getStoreView(); } diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/RuleMatchingProbeState.java b/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/RuleMatchingProbeState.java deleted file mode 100644 index 506abc9a..00000000 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/evaluation/RuleMatchingProbeState.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2014-2019 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jetbrains.mps.logic.reactor.evaluation; - -// fixme: empty interface and unchecked cast to RuleMatchingProbe in EvaluationSessionImpl -public interface RuleMatchingProbeState { -} diff --git a/reactor/Test/test/TestIncrementalProgram.kt b/reactor/Test/test/TestIncrementalProgram.kt index fa388125..3e439faa 100644 --- a/reactor/Test/test/TestIncrementalProgram.kt +++ b/reactor/Test/test/TestIncrementalProgram.kt @@ -76,14 +76,16 @@ class TestIncrementalProgram { return this to result } + private fun SessionToken.chunks(): Collection = + (this.journalView as MatchJournal.View).chunks - private fun EvaluationResult.chunksSymbolView() = this.token().journalView.chunks.map { + private fun EvaluationResult.chunksSymbolView() = this.token().chunks().map { it.entriesLog().map { entry -> !entry.discarded() to entry.occ().constraint().symbol() } } - private fun EvaluationResult.lastChunk() = this.token().journalView.chunks.last() as MatchJournal.Chunk + private fun EvaluationResult.lastChunk() = this.token().chunks().last() as MatchJournal.Chunk - private fun EvaluationResult.countChunks() = this.token().journalView.chunks.size + private fun EvaluationResult.countChunks() = this.token().chunks().size private fun Iterable.constraintSymbols() = this.map { it.constraint.symbol() } @@ -624,7 +626,7 @@ class TestIncrementalProgram { )) ).relaunch("withBar", progSpec, evalRes.token()) { result -> - println(result.token().journalView.chunks) + println(result.token().chunks()) // if "foobar" happens too early, "1st" occ won't be produced result.storeView().constraintSymbols() shouldBe setOf(sym0("start"), sym0("1st"), sym0("2nd"))