Cleanup code, drop obsolete classes
This commit is contained in:
parent
ef3aec13d5
commit
c90382ec8f
|
|
@ -42,11 +42,10 @@ internal class ConstraintsProcessing(
|
|||
val logicalState: LogicalState,
|
||||
override val ispec: IncrementalSpec = IncrementalSpec.DefaultSpec,
|
||||
val trace: EvaluationTrace = EvaluationTrace.NULL,
|
||||
val profiler: Profiler? = null
|
||||
|
||||
// fixme: can get rid of inheritance from journal, use composition instead
|
||||
) : StoreAwareJournalImpl(journal, logicalState), IncrSpecHolder {
|
||||
|
||||
val profiler: Profiler? = null ) : MatchJournal by journal,
|
||||
LogicalStateObservable by LogicalState(),
|
||||
IncrSpecHolder
|
||||
{
|
||||
fun getFrontState(): DispatchingFrontState = dispatchingFront.state()
|
||||
|
||||
fun engage(controller: Controller) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,14 @@ typealias ChunkIndex = TIntObjectHashMap<MatchJournal.Chunk>
|
|||
|
||||
interface MatchJournal : EvidenceSource {
|
||||
|
||||
// for tests
|
||||
companion object {
|
||||
fun fromView(
|
||||
ispec: IncrementalSpec = IncrementalSpec.DefaultSpec,
|
||||
view: MatchJournal.View? = null
|
||||
): MatchJournal = MatchJournalImpl(ispec, EvaluationTrace.NULL, view)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new [Chunk] for matches of principal rules.
|
||||
* Log occurrences discarded by match in current [Chunk].
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package jetbrains.mps.logic.reactor.core.internal
|
|||
import jetbrains.mps.logic.reactor.core.*
|
||||
import jetbrains.mps.logic.reactor.core.internal.MatchJournal.*
|
||||
import jetbrains.mps.logic.reactor.evaluation.ConstraintOccurrence
|
||||
import jetbrains.mps.logic.reactor.evaluation.EvaluationTrace
|
||||
import jetbrains.mps.logic.reactor.evaluation.RuleMatch
|
||||
import jetbrains.mps.logic.reactor.evaluation.StoreView
|
||||
import jetbrains.mps.logic.reactor.logical.Logical
|
||||
|
|
@ -31,6 +32,7 @@ import java.util.*
|
|||
|
||||
internal open class MatchJournalImpl(
|
||||
override val ispec: IncrementalSpec,
|
||||
val trace: EvaluationTrace = EvaluationTrace.NULL,
|
||||
view: MatchJournal.View? = null
|
||||
) : MatchJournal, IncrSpecHolder {
|
||||
|
||||
|
|
@ -98,7 +100,8 @@ internal open class MatchJournalImpl(
|
|||
assert(initialChunk.match is InitRuleMatch)
|
||||
}
|
||||
|
||||
constructor(view: MatchJournal.View? = null) : this(IncrementalSpec.DefaultSpec, view)
|
||||
constructor(trace: EvaluationTrace = EvaluationTrace.NULL,
|
||||
view: MatchJournal.View? = null) : this(IncrementalSpec.DefaultSpec, trace, view)
|
||||
|
||||
override fun logMatch(match: RuleMatch): MatchChunk? {
|
||||
val added: MatchChunk?
|
||||
|
|
|
|||
|
|
@ -1,61 +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.core.internal
|
||||
|
||||
import jetbrains.mps.logic.reactor.core.LogicalStateObservable
|
||||
import jetbrains.mps.logic.reactor.program.IncrementalSpec
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
|
||||
/**
|
||||
* [MatchJournal] which also maintains observers in [LogicalStateObservable] in sync with its current position.
|
||||
*/
|
||||
interface StoreAwareJournal : MatchJournal, LogicalStateObservable {
|
||||
|
||||
// for tests
|
||||
companion object {
|
||||
fun fromView(
|
||||
ispec: IncrementalSpec = IncrementalSpec.DefaultSpec,
|
||||
view: MatchJournal.View? = null
|
||||
): StoreAwareJournal = StoreAwareJournalImpl(MatchJournalImpl(ispec, view))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal open class StoreAwareJournalImpl(private val journal: MatchJournal,
|
||||
private val logicalState: LogicalState = LogicalState())
|
||||
: MatchJournal by journal, StoreAwareJournal, LogicalStateObservable by logicalState
|
||||
{
|
||||
|
||||
private class FramePos(
|
||||
chunk: MatchJournal.Chunk,
|
||||
entriesCount: Int = 0
|
||||
) : MatchJournal.Pos(chunk, entriesCount)
|
||||
|
||||
override fun currentPos(): MatchJournal.Pos =
|
||||
FramePos(journal.currentPos().chunk, journal.currentPos().entriesCount)
|
||||
|
||||
// Throw away recently added chunks and reset store accordingly
|
||||
// NB: not checking that chunks are actually recently added, from this exec session
|
||||
override fun reset(pastPos: MatchJournal.Pos) {
|
||||
if (pastPos is FramePos) {
|
||||
journal.reset(pastPos)
|
||||
} else {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ class TestStoreAwareJournal {
|
|||
private class JournalDispatcherHelper(
|
||||
dispatcher: Dispatcher,
|
||||
ispec: IncrementalSpec = LegacyMockIncrProgSpec,
|
||||
val hist: StoreAwareJournal = StoreAwareJournal.fromView(ispec)
|
||||
val hist: MatchJournal = MatchJournal.fromView(ispec)
|
||||
) {
|
||||
val initialJournalSize = hist.view().chunks.size
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue