Move replayOccurrences back to MatchJournal again, fix tests
This commit is contained in:
parent
8d615852c6
commit
71eac08775
|
|
@ -38,7 +38,6 @@ interface MatchJournal : MutableIterable<MatchJournal.Chunk> {
|
||||||
fun resetPos()
|
fun resetPos()
|
||||||
fun reset(pastPos: Pos)
|
fun reset(pastPos: Pos)
|
||||||
fun replay(controller: Controller, futurePos: Pos)
|
fun replay(controller: Controller, futurePos: Pos)
|
||||||
fun replayOccurrences(controller: Controller, occSpecs: Iterable<MatchJournal.Chunk.Entry>) {}
|
|
||||||
|
|
||||||
fun view(): View
|
fun view(): View
|
||||||
fun storeView(): StoreView
|
fun storeView(): StoreView
|
||||||
|
|
@ -164,7 +163,8 @@ internal open class MatchJournalImpl(
|
||||||
if (currentPos() != futurePos) throw IllegalStateException()
|
if (currentPos() != futurePos) throw IllegalStateException()
|
||||||
}
|
}
|
||||||
|
|
||||||
// override fun replayOccurrences(occSpecs: Iterable<MatchJournal.Chunk.Entry>) {}
|
private fun replayOccurrences(controller: Controller, occSpecs: Iterable<MatchJournal.Chunk.Entry>) =
|
||||||
|
occSpecs.forEach { if (it.isDiscarded) it.occ.terminate(controller) else it.occ.revive(controller) }
|
||||||
|
|
||||||
|
|
||||||
override fun view() = MatchJournal.View(ArrayList(hist), nextChunkId)
|
override fun view() = MatchJournal.View(ArrayList(hist), nextChunkId)
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,6 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp
|
||||||
private data class ExecPos(val pos: MatchJournal.Pos, val activeOcc: Occurrence)
|
private data class ExecPos(val pos: MatchJournal.Pos, val activeOcc: Occurrence)
|
||||||
|
|
||||||
|
|
||||||
override fun replayOccurrences(controller: Controller, occSpecs: Iterable<MatchJournal.Chunk.Entry>) =
|
|
||||||
occSpecs.forEach { if (it.isDiscarded) it.occ.terminate(controller) else it.occ.revive(controller) }
|
|
||||||
|
|
||||||
|
|
||||||
// only for tests
|
// only for tests
|
||||||
fun pushActivateFirstOccOf(ctr: Constraint): Boolean {
|
fun pushActivateFirstOccOf(ctr: Constraint): Boolean {
|
||||||
val pos = currentPos()
|
val pos = currentPos()
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package jetbrains.mps.logic.reactor.core.internal
|
package jetbrains.mps.logic.reactor.core.internal
|
||||||
|
|
||||||
import jetbrains.mps.logic.reactor.core.Dispatcher
|
|
||||||
import jetbrains.mps.logic.reactor.core.ProcessingState
|
import jetbrains.mps.logic.reactor.core.ProcessingState
|
||||||
import java.lang.IllegalArgumentException
|
import java.lang.IllegalArgumentException
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import jetbrains.mps.logic.reactor.core.IncrementalProgramSpec
|
import jetbrains.mps.logic.reactor.core.IncrementalProgramSpec
|
||||||
|
import jetbrains.mps.logic.reactor.core.Occurrence
|
||||||
import jetbrains.mps.logic.reactor.core.ReactorLifecycle
|
import jetbrains.mps.logic.reactor.core.ReactorLifecycle
|
||||||
import jetbrains.mps.logic.reactor.core.SessionToken
|
import jetbrains.mps.logic.reactor.core.SessionToken
|
||||||
import jetbrains.mps.logic.reactor.evaluation.EvaluationResult
|
import jetbrains.mps.logic.reactor.evaluation.EvaluationResult
|
||||||
import jetbrains.mps.logic.reactor.evaluation.EvaluationSession
|
import jetbrains.mps.logic.reactor.evaluation.EvaluationSession
|
||||||
import jetbrains.mps.logic.reactor.evaluation.StoreView
|
|
||||||
import jetbrains.mps.logic.reactor.program.Constraint
|
import jetbrains.mps.logic.reactor.program.Constraint
|
||||||
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
|
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
|
||||||
import jetbrains.mps.logic.reactor.program.Rule as CRule
|
import jetbrains.mps.logic.reactor.program.Rule as CRule
|
||||||
|
|
@ -147,10 +147,13 @@ class TestIncrementalProgram {
|
||||||
)
|
)
|
||||||
).relaunch("test1", progSpec, evalRes.token()) { result ->
|
).relaunch("test1", progSpec, evalRes.token()) { result ->
|
||||||
result.storeView().constraintSymbols() shouldBe setOf(sym0("foo"), sym0("bar"), sym0("baz"))
|
result.storeView().constraintSymbols() shouldBe setOf(sym0("foo"), sym0("bar"), sym0("baz"))
|
||||||
|
result.token().journalView.chunks.last().activated().constraintSymbols() shouldBe listOf(sym0("baz"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun Iterable<Occurrence>.constraintSymbols() = this.map { it.constraint.symbol() }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addMatchAfterReplaced() {
|
fun addMatchAfterReplaced() {
|
||||||
val progSpec = MockIncrProgSpec(
|
val progSpec = MockIncrProgSpec(
|
||||||
|
|
@ -370,6 +373,9 @@ class TestIncrementalProgram {
|
||||||
}.also { (builder, evalRes) ->
|
}.also { (builder, evalRes) ->
|
||||||
builder.programWithRules(
|
builder.programWithRules(
|
||||||
rule("baz.lax",
|
rule("baz.lax",
|
||||||
|
headReplaced(
|
||||||
|
princConstraint("foo")
|
||||||
|
),
|
||||||
headKept(
|
headKept(
|
||||||
princConstraint("baz")
|
princConstraint("baz")
|
||||||
),
|
),
|
||||||
|
|
@ -378,7 +384,7 @@ class TestIncrementalProgram {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).relaunch("test2", progSpec, evalRes.token()) { result ->
|
).relaunch("test2", progSpec, evalRes.token()) { result ->
|
||||||
result.storeView().constraintSymbols() shouldBe setOf(sym0("bar"), sym0("baz"), sym0("qux"))
|
result.storeView().constraintSymbols() shouldBe setOf(sym0("bar"), sym0("baz"), sym0("lax"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue