Drop obsolete interface and its usages
This commit is contained in:
parent
c7c55605f5
commit
cf4e9b2b33
|
|
@ -47,10 +47,6 @@ internal class ConstraintsProcessing(
|
|||
// fixme: can get rid of inheritance from journal, use composition instead
|
||||
) : StoreAwareJournalImpl(journal, logicalState), IncrSpecHolder {
|
||||
|
||||
private var incrementalProcessing: ProcessingStrategy = EmptyProcessing()
|
||||
|
||||
fun setStrategy(strategy: ProcessingStrategy) { this.incrementalProcessing = strategy }
|
||||
|
||||
fun getFrontState(): DispatchingFrontState = dispatchingFront.state()
|
||||
|
||||
fun engage(controller: Controller) {
|
||||
|
|
@ -90,7 +86,6 @@ internal class ConstraintsProcessing(
|
|||
active.stored = true
|
||||
logActivation(active)
|
||||
active.revive(logicalState)
|
||||
incrementalProcessing.processActivated(active, logicalState)
|
||||
}
|
||||
assert(active.alive)
|
||||
|
||||
|
|
@ -101,7 +96,7 @@ internal class ConstraintsProcessing(
|
|||
}
|
||||
|
||||
val matches = dispatchingFront.matches().toList()
|
||||
val currentMatches = incrementalProcessing.processOccurrenceMatches(active, matches)
|
||||
val currentMatches = matches
|
||||
|
||||
val outStatus = processMatches(controller, active, currentMatches, parent, inStatus)
|
||||
|
||||
|
|
@ -130,10 +125,7 @@ internal class ConstraintsProcessing(
|
|||
private fun processMatch(controller: Controller, match: RuleMatchEx, parent: MatchJournal.MatchChunk, inStatus: FeedbackStatus) : FeedbackStatus =
|
||||
inStatus
|
||||
.let {
|
||||
//fixme: refactor this abort logic?
|
||||
if (incrementalProcessing.offerMatch(match)) {
|
||||
controller.offerMatch(match, inStatus)
|
||||
} else inStatus.abort(DetailedFeedback("incremental processing omitted match"))
|
||||
controller.offerMatch(match, inStatus)
|
||||
}
|
||||
.let {
|
||||
when (it) {
|
||||
|
|
@ -149,7 +141,6 @@ internal class ConstraintsProcessing(
|
|||
else -> it
|
||||
}
|
||||
}
|
||||
.also { incrementalProcessing.processMatch(match) }
|
||||
.also { trace.trigger(match) }
|
||||
.also { accept(controller, match) }
|
||||
.then { controller.processBody(match, parent, it) }
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ internal data class SessionParts(
|
|||
val logicalState: LogicalState,
|
||||
val controller: ControllerImpl,
|
||||
val processing: ConstraintsProcessing,
|
||||
val strategy: ProcessingStrategy,
|
||||
val principalObservers: PrincipalObserverDispatcher
|
||||
) {
|
||||
val frontState: DispatchingFrontState get() = processing.getFrontState()
|
||||
|
|
@ -102,7 +101,7 @@ internal class EvaluationSessionImpl private constructor (
|
|||
|
||||
fun getSession(token: SessionTokenImpl?): SessionParts {
|
||||
val ruleIndex = token
|
||||
?.let { it.ruleIndex }
|
||||
?.ruleIndex
|
||||
?.also { it.updateIndexFromRules(program.rules()) }
|
||||
?: RuleIndex(program.rules())
|
||||
|
||||
|
|
@ -110,13 +109,11 @@ internal class EvaluationSessionImpl private constructor (
|
|||
val logicalState = LogicalState()
|
||||
val dispatchingFront = Dispatcher(ruleIndex).front()
|
||||
|
||||
val processingStrategy = EmptyProcessing()
|
||||
val processing = ConstraintsProcessing(dispatchingFront, journal, logicalState, incrementality, trace, profiler)
|
||||
processing.setStrategy(processingStrategy)
|
||||
|
||||
val controller = ControllerImpl(supervisor, processing, incrementality, trace, profiler)
|
||||
|
||||
return SessionParts(ruleIndex, journal, logicalState, controller, processing, processingStrategy, PrincipalObserverDispatcher.EMPTY)
|
||||
return SessionParts(ruleIndex, journal, logicalState, controller, processing, PrincipalObserverDispatcher.EMPTY)
|
||||
}
|
||||
|
||||
override fun endSession(session: SessionParts): SessionToken = with(session) {
|
||||
|
|
@ -127,10 +124,10 @@ internal class EvaluationSessionImpl private constructor (
|
|||
val status = run(main)
|
||||
controller.shutDown()
|
||||
val newToken = endSession(session)
|
||||
return EvaluationResultImpl(newToken, status, strategy.invalidatedFeedback(), strategy.invalidatedRules())
|
||||
return EvaluationResultImpl(newToken, status, emptySet(), emptyList())
|
||||
}
|
||||
|
||||
protected fun SessionParts.run(main: Constraint): FeedbackStatus = strategy.run(processing, controller, main)
|
||||
protected fun SessionParts.run(main: Constraint): FeedbackStatus = controller.activate(main)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
* Copyright 2014-2020 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.*
|
||||
import jetbrains.mps.logic.reactor.evaluation.EvaluationTrace
|
||||
import jetbrains.mps.logic.reactor.program.Constraint
|
||||
import jetbrains.mps.logic.reactor.program.IncrementalContractViolationException
|
||||
import jetbrains.mps.logic.reactor.program.IncrementalSpec
|
||||
import jetbrains.mps.logic.reactor.program.Rule
|
||||
|
||||
/**
|
||||
* Facade interface for incremental processing.
|
||||
*
|
||||
* Specifies points in program evaluation where
|
||||
* incremental processing must be must be injected:
|
||||
* [offerMatch], [processMatch], [processOccurrenceMatches],
|
||||
* [processActivated], [processInvalidated].
|
||||
*
|
||||
* Provides an entry point for evaluation: [run].
|
||||
*
|
||||
* Provides additional session output through
|
||||
* [invalidatedFeedback] & [invalidatedRules].
|
||||
*/
|
||||
internal interface ProcessingStrategy {
|
||||
|
||||
/**
|
||||
* Output of incremental processing session.
|
||||
*
|
||||
* Specifies keys for invalid program feedback
|
||||
* so that caller could clear it.
|
||||
*
|
||||
* @return collection of invalid program feedback keys.
|
||||
*/
|
||||
fun invalidatedFeedback(): FeedbackKeySet
|
||||
|
||||
/**
|
||||
* Output of incremental processing session.
|
||||
*
|
||||
* Specifies unique tags of principal rules which
|
||||
* matches were invalidated. From this rule information
|
||||
* it can be inferred which rule origins were affected.
|
||||
*
|
||||
* @return collection of unique tags of affected rules.
|
||||
*/
|
||||
fun invalidatedRules(): List<Any>
|
||||
|
||||
/**
|
||||
* Entry point for processing session.
|
||||
*/
|
||||
fun run(processing: ConstraintsProcessing, controller: Controller, main: Constraint): FeedbackStatus
|
||||
|
||||
/**
|
||||
* Injection point into program evaluation process.
|
||||
*
|
||||
* Called before [Controller.offerMatch].
|
||||
* Allows to omit match (by returning `false`)
|
||||
* from usual evaluation process and handle it
|
||||
* in some special manner according to strategy.
|
||||
*
|
||||
* @return `true` if match isn't affected by the strategy,
|
||||
* `false` if it was and must be omitted.
|
||||
*/
|
||||
fun offerMatch(match: RuleMatchEx): Boolean
|
||||
|
||||
/**
|
||||
* Injection point into program evaluation process.
|
||||
*
|
||||
* Pre-process [match] accepted by [Controller.offerMatch]
|
||||
* before general processing in [Controller.processBody].
|
||||
* Aimed at processing heads of the [match], while [match]
|
||||
* itself is evaluated in a usual manner by [Controller].
|
||||
*/
|
||||
fun processMatch(match: RuleMatchEx)
|
||||
|
||||
/**
|
||||
* Injection point into program evaluation process.
|
||||
*
|
||||
* Processes [matches] of activated [Occurrence]
|
||||
* returned by [Dispatcher.DispatchingFront.matches].
|
||||
* Allows to filter [matches] according to the strategy
|
||||
* e.g. postpone them or drop entirely.
|
||||
*
|
||||
* In contrast to [offerMatch], happens earlier and allows
|
||||
* to process all new matches of [active] at once.
|
||||
*
|
||||
* @return list of filtered [matches].
|
||||
*/
|
||||
fun processOccurrenceMatches(active: Occurrence, matches: List<RuleMatchEx>): List<RuleMatchEx>
|
||||
|
||||
/**
|
||||
* Injection point into program evaluation process.
|
||||
*
|
||||
* Called on new activated [Occurrence].
|
||||
* Allows to handle program's logical state,
|
||||
* e.g. add processing-specific observers with [observable].
|
||||
*/
|
||||
fun processActivated(active: Occurrence, observable: LogicalStateObservable)
|
||||
|
||||
// fixme: essentially InvalidationStage.invalidateChunk redirects back here -- unnecessary circle
|
||||
/**
|
||||
* Injection point into program evaluation process.
|
||||
*
|
||||
* Called for invalidated [Occurrence]s.
|
||||
* It's a pair method for [processActivated] to discharge
|
||||
* its effects, e.g. to clear program logical state.
|
||||
*/
|
||||
fun processInvalidated(occ: Occurrence, observable: LogicalStateObservable)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default non-incremental processing with stubs. Does nothing.
|
||||
*/
|
||||
internal open class EmptyProcessing: ProcessingStrategy {
|
||||
|
||||
override fun invalidatedFeedback(): FeedbackKeySet = emptySet()
|
||||
|
||||
override fun invalidatedRules(): List<Any> = emptyList()
|
||||
|
||||
/**
|
||||
* Entry point. Simply redirects evaluation to [Controller].
|
||||
*/
|
||||
override fun run(processing: ConstraintsProcessing, controller: Controller, main: Constraint) =
|
||||
controller.activate(main)
|
||||
|
||||
override fun offerMatch(match: RuleMatchEx): Boolean = true
|
||||
|
||||
override fun processMatch(match: RuleMatchEx) {}
|
||||
|
||||
override fun processOccurrenceMatches(active: Occurrence, matches: List<RuleMatchEx>): List<RuleMatchEx> = matches
|
||||
|
||||
override fun processActivated(active: Occurrence, observable: LogicalStateObservable) {}
|
||||
|
||||
override fun processInvalidated(occ: Occurrence, observable: LogicalStateObservable) {}
|
||||
}
|
||||
Loading…
Reference in New Issue