Drop obsolete unused stuff
This commit is contained in:
parent
87bb67cee3
commit
1bb759008b
|
|
@ -55,6 +55,4 @@ abstract class Feedback : EvaluationFeedback() {
|
|||
|
||||
}
|
||||
|
||||
typealias FeedbackKeySet = Set<Any>
|
||||
|
||||
internal val RuleMatch.feedbackKey: Any get() = System.identityHashCode(this)
|
||||
|
|
|
|||
|
|
@ -27,47 +27,13 @@ import java.util.*
|
|||
* @author Fedor Isakov
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles creation of the first and following sessions,
|
||||
* properly ending sessions and getting their results.
|
||||
*/
|
||||
internal interface SessionManager {
|
||||
|
||||
/**
|
||||
* Creates first session when there's no [SessionToken] available.
|
||||
*/
|
||||
fun firstSession(): SessionParts
|
||||
|
||||
/**
|
||||
* Creates following session when previous [token] is available.
|
||||
*/
|
||||
fun nextSession(token: SessionToken): SessionParts
|
||||
|
||||
/**
|
||||
* Clears state unneeded between sessions and return
|
||||
* next [SessionToken] required for following session.
|
||||
*/
|
||||
fun endSession(session: SessionParts): SessionToken
|
||||
|
||||
/**
|
||||
* Starts [session] and returns overall [EvaluationResult] of the program.
|
||||
*/
|
||||
fun runSession(session: SessionParts, main: Constraint): EvaluationResult
|
||||
}
|
||||
|
||||
/**
|
||||
* Bundle of all entities involved in a session.
|
||||
*/
|
||||
internal data class SessionParts(
|
||||
val ruleIndex: RuleIndex,
|
||||
internal data class SessionData(
|
||||
val journal: MatchJournal,
|
||||
val logicalState: LogicalState,
|
||||
val controller: ControllerImpl,
|
||||
val processing: ConstraintsProcessing
|
||||
) {
|
||||
val frontState: DispatchingFrontState get() = processing.getFrontState()
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
internal class EvaluationSessionImpl private constructor (
|
||||
val program: Program,
|
||||
|
|
@ -79,22 +45,16 @@ internal class EvaluationSessionImpl private constructor (
|
|||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : Any> parameter(key: ParameterKey<T>): T = params ?.get(key) as T
|
||||
|
||||
private fun launch(token: SessionToken?, main: Constraint): EvaluationResult {
|
||||
val sessionProcessing: DefaultProcessingSession = DefaultProcessingSession()
|
||||
val session = sessionProcessing.getSession(token as SessionTokenImpl?)
|
||||
private fun launch(main: Constraint): EvaluationResult {
|
||||
val sessionProcessing = DefaultProcessingSession()
|
||||
val session = sessionProcessing.getSession()
|
||||
return sessionProcessing.runSession(session, main)
|
||||
}
|
||||
|
||||
open inner class DefaultProcessingSession: SessionManager {
|
||||
open inner class DefaultProcessingSession {
|
||||
|
||||
override fun firstSession(): SessionParts = getSession(null)
|
||||
|
||||
override fun nextSession(token: SessionToken): SessionParts = getSession(token as SessionTokenImpl)
|
||||
|
||||
fun getSession(token: SessionTokenImpl?): SessionParts {
|
||||
val ruleIndex = token
|
||||
?.updateRuleIndex(program.rules())
|
||||
?: RuleIndex(program.rules())
|
||||
fun getSession(): SessionData {
|
||||
val ruleIndex = RuleIndex(program.rules())
|
||||
|
||||
val journal = MatchJournalImpl(trace)
|
||||
val logicalState = LogicalState()
|
||||
|
|
@ -104,21 +64,18 @@ internal class EvaluationSessionImpl private constructor (
|
|||
|
||||
val controller = ControllerImpl(supervisor, processing, trace, profiler)
|
||||
|
||||
return SessionParts(ruleIndex, journal, logicalState, controller, processing)
|
||||
return SessionData(journal, controller)
|
||||
}
|
||||
|
||||
override fun endSession(session: SessionParts): SessionToken = with(session) {
|
||||
SessionTokenImpl(journal.storeView(), ruleIndex.toRules(), emptyFrontState(), ruleIndex, logicalState)
|
||||
}
|
||||
fun endSession(session: SessionData): StoreView = session.journal.storeView()
|
||||
|
||||
override fun runSession(session: SessionParts, main: Constraint): EvaluationResult = with(session) {
|
||||
fun runSession(session: SessionData, main: Constraint): EvaluationResult = with(session) {
|
||||
val status = run(main)
|
||||
controller.shutDown()
|
||||
val newToken = endSession(session)
|
||||
return EvaluationResultImpl(newToken, status)
|
||||
return EvaluationResultImpl(endSession(session), status)
|
||||
}
|
||||
|
||||
protected fun SessionParts.run(main: Constraint): FeedbackStatus = controller.activate(main)
|
||||
protected fun SessionData.run(main: Constraint): FeedbackStatus = controller.activate(main)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -128,8 +85,6 @@ internal class EvaluationSessionImpl private constructor (
|
|||
|
||||
var evaluationTrace: EvaluationTrace = EvaluationTrace.NULL
|
||||
|
||||
var token: SessionToken? = null
|
||||
|
||||
var profiler: Profiler? = null
|
||||
|
||||
override fun withTrace(computingTracer: EvaluationTrace): EvaluationSession.Config {
|
||||
|
|
@ -137,11 +92,6 @@ internal class EvaluationSessionImpl private constructor (
|
|||
return this
|
||||
}
|
||||
|
||||
override fun withSessionToken(token: SessionToken?): EvaluationSession.Config {
|
||||
this.token = token
|
||||
return this
|
||||
}
|
||||
|
||||
override fun withProfiler(profiler: Profiler?): EvaluationSession.Config {
|
||||
this.profiler = profiler
|
||||
return this
|
||||
|
|
@ -160,7 +110,7 @@ internal class EvaluationSessionImpl private constructor (
|
|||
Backend.ourBackend.ourSession.set(session)
|
||||
try {
|
||||
val main = parameters[ParameterKey.of("main", Constraint::class.java)] as Constraint
|
||||
return session.launch(token, main)
|
||||
return session.launch(main)
|
||||
}
|
||||
finally {
|
||||
Backend.ourBackend.ourSession.set(null)
|
||||
|
|
@ -193,15 +143,11 @@ internal class EvaluationSessionImpl private constructor (
|
|||
}
|
||||
|
||||
private class EvaluationResultImpl(
|
||||
val token: SessionToken,
|
||||
val storeView: StoreView,
|
||||
val status: FeedbackStatus,
|
||||
): EvaluationResult {
|
||||
override fun token() = token
|
||||
override fun storeView(): StoreView = token.storeView
|
||||
override fun storeView(): StoreView = storeView
|
||||
override fun feedback(): EvaluationFeedback? = if (status is FAILED) status.failure else null
|
||||
}
|
||||
|
||||
|
||||
private fun RuleIndex.toRules() = ArrayList<Rule>().also { l -> this.forEach { l.add(it) }}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +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.DispatchingFrontState
|
||||
import jetbrains.mps.logic.reactor.core.RuleIndex
|
||||
import jetbrains.mps.logic.reactor.evaluation.SessionToken
|
||||
import jetbrains.mps.logic.reactor.evaluation.StoreView
|
||||
import jetbrains.mps.logic.reactor.program.Rule
|
||||
|
||||
data class SessionTokenImpl(
|
||||
private val storeView: StoreView,
|
||||
private val rules: Iterable<Rule>,
|
||||
private val frontState: DispatchingFrontState,
|
||||
private val ruleIndex: RuleIndex,
|
||||
private val logicalState: LogicalState
|
||||
) : SessionToken
|
||||
{
|
||||
override fun getStoreView(): StoreView = storeView
|
||||
override fun getRules(): Iterable<Rule> = rules
|
||||
|
||||
fun updateRuleIndex(rules: Iterable<Rule>) : RuleIndex =
|
||||
ruleIndex.also { it.updateIndexFromRules(rules) }
|
||||
}
|
||||
|
|
@ -21,8 +21,7 @@ package jetbrains.mps.logic.reactor.evaluation;
|
|||
*/
|
||||
public interface EvaluationResult {
|
||||
|
||||
SessionToken token();
|
||||
|
||||
// used in tests
|
||||
StoreView storeView();
|
||||
|
||||
EvaluationFeedback feedback();
|
||||
|
|
|
|||
|
|
@ -77,8 +77,6 @@ public abstract class EvaluationSession {
|
|||
|
||||
public abstract Config withTrace(EvaluationTrace computingTracer);
|
||||
|
||||
public Config withSessionToken(SessionToken token) { return this; }
|
||||
|
||||
public Config withProfiler(Profiler profiler) { return this; }
|
||||
|
||||
public abstract EvaluationResult start(Supervisor supervisor);
|
||||
|
|
|
|||
|
|
@ -1,28 +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 jetbrains.mps.logic.reactor.program.Rule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface SessionToken {
|
||||
@NotNull
|
||||
StoreView getStoreView();
|
||||
|
||||
@NotNull()
|
||||
Iterable<Rule> getRules();
|
||||
}
|
||||
Loading…
Reference in New Issue