Cleanup and refactor code for better readability

This commit is contained in:
Fedor Isakov 2024-06-14 13:42:46 +02:00
parent a01c63059e
commit cdb6c91958
23 changed files with 126 additions and 235 deletions

View File

@ -17,7 +17,6 @@
package jetbrains.mps.logic.reactor.core
import jetbrains.mps.logic.reactor.core.internal.FeedbackStatus
import jetbrains.mps.logic.reactor.core.internal.MatchJournal
import jetbrains.mps.logic.reactor.evaluation.PredicateInvocation
import jetbrains.mps.logic.reactor.evaluation.Solver
import jetbrains.mps.logic.reactor.evaluation.StoreView
@ -39,9 +38,7 @@ interface Controller {
fun activate(constraint: Constraint): FeedbackStatus
fun reactivate(occ: Occurrence): FeedbackStatus
fun logicalStateObservable(): LogicalStateObservable
/** For tests only */
fun evaluate(occ: Occurrence): StoreView
@ -61,6 +58,6 @@ interface Controller {
* its status allowed the operation.
* The returned status captures the result of evaluating the rule's body.
*/
fun processBody(match: RuleMatchEx, parent: MatchJournal.MatchChunk, inStatus: FeedbackStatus): FeedbackStatus
fun processBody(match: RuleMatchEx, inStatus: FeedbackStatus): FeedbackStatus
}

View File

@ -24,19 +24,8 @@ import jetbrains.mps.logic.reactor.logical.Logical
interface LogicalStateObservable {
fun addForwardingObserver(logical: Logical<*>, observer: ForwardingLogicalObserver)
fun addReactivatable(logical: Logical<*>, reactivatable: Reactivatable)
fun removeForwardingObserver(logical: Logical<*>, observer: ForwardingLogicalObserver)
= removeForwardingObserversWhere(logical, observer::equals)
fun removeForwardingObserversWhere(logical: Logical<*>, where: (ForwardingLogicalObserver) -> Boolean)
}
interface ForwardingLogicalObserver {
fun valueUpdated(logical: Logical<*>, controller: Controller)
fun parentUpdated(logical: Logical<*>, controller: Controller)
fun removeReactivatable(logical: Logical<*>, reactivatable: Reactivatable)
}

View File

@ -30,14 +30,13 @@ import jetbrains.mps.logic.reactor.program.Rule
*
* @author Fedor Isakov
*/
class Occurrence (observable: LogicalStateObservable,
val constraint: Constraint,
val logicalContext: LogicalContext,
val arguments: List<*>,
override val evidence: Evidence,
private val justifications: Justifications,
val sourceRule: Rule.Tag? = null):
ConstraintOccurrence, ForwardingLogicalObserver, Justified
class Occurrence(val constraint: Constraint,
val logicalContext: LogicalContext,
val arguments: List<*>,
override val evidence: Evidence,
private val justifications: Justifications,
val sourceRule: Rule.Tag? = null):
ConstraintOccurrence, Justified, Reactivatable
{
var alive = false
@ -56,14 +55,12 @@ class Occurrence (observable: LogicalStateObservable,
override fun justifications(): Justifications = justifications
override fun valueUpdated(logical: Logical<*>, controller: Controller) = doReactivate(controller)
override fun parentUpdated(logical: Logical<*>, controller: Controller) = doReactivate(controller)
override fun reactivate(controller: Controller) = doReactivate(controller)
fun terminate(observable: LogicalStateObservable) {
for (a in arguments) {
if (a is Logical<*>) {
observable.removeForwardingObserver(a, this)
observable.removeReactivatable(a, this)
}
}
alive = false
@ -73,7 +70,7 @@ class Occurrence (observable: LogicalStateObservable,
if (!alive) {
for (a in HashSet(arguments)) { // avoid duplicate subscriptions
if (a is Logical<*>) {
observable.addForwardingObserver(a, this)
observable.addReactivatable(a, this)
}
}
}
@ -99,10 +96,9 @@ class Occurrence (observable: LogicalStateObservable,
fun Occurrence.arity() = constraint().symbol().arity()
fun Constraint.occurrence(observable: LogicalStateObservable,
arguments: List<*>,
fun Constraint.occurrence(arguments: List<*>,
evidence: Evidence,
justifications: Justifications,
logicalContext: LogicalContext,
ruleUniqueTag: Rule.Tag? = null): Occurrence =
Occurrence(observable, this, logicalContext, arguments, evidence, justifications, ruleUniqueTag)
Occurrence(this, logicalContext, arguments, evidence, justifications, ruleUniqueTag)

View File

@ -0,0 +1,23 @@
/*
* Copyright 2014-2024 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
interface Reactivatable {
fun reactivate(controller: Controller)
}

View File

@ -40,8 +40,7 @@ internal class ConstraintsProcessing(
journal: MatchJournalImpl,
val logicalState: LogicalState,
val trace: EvaluationTrace = EvaluationTrace.NULL,
val profiler: Profiler? = null ) : MatchJournal by journal,
LogicalStateObservable by LogicalState()
val profiler: Profiler? = null ) : MatchJournal by journal
{
fun getFrontState(): DispatchingFrontState = dispatchingFront.state()
@ -58,7 +57,7 @@ internal class ConstraintsProcessing(
* Calls the controller to process matches (if any) that were triggered.
* This method may be called at most once for a fresh state frame.
*/
fun processActivated(controller: Controller, active: Occurrence, parent: MatchJournal.MatchChunk, inStatus: FeedbackStatus) : FeedbackStatus {
fun processActivated(controller: Controller, active: Occurrence, inStatus: FeedbackStatus) : FeedbackStatus {
if (!active.stored) {
active.stored = true
logActivation(active)
@ -75,7 +74,7 @@ internal class ConstraintsProcessing(
val matches = dispatchingFront.matches().toList()
val currentMatches = matches
val outStatus = processMatches(controller, active, currentMatches, parent, inStatus)
val outStatus = processMatches(controller, active, currentMatches, inStatus)
// TODO: should be isAlive()
if (active.stored) {
@ -85,13 +84,13 @@ internal class ConstraintsProcessing(
return outStatus
}
fun processMatches(controller: Controller, active: Occurrence, matches: List<RuleMatchEx>, parent: MatchJournal.MatchChunk, inStatus: FeedbackStatus) : FeedbackStatus =
fun processMatches(controller: Controller, active: Occurrence, matches: List<RuleMatchEx>, inStatus: FeedbackStatus) : FeedbackStatus =
matches.fold(inStatus) { status, match ->
// TODO: paranoid check. should be isAlive() instead
// FIXME: move this check elsewhere
if (status.operational && active.stored && match.allStored()) {
assert(match.allHeads().contains(active))
processMatch(controller, match, parent, status)
processMatch(controller, match, status)
} else status
}
@ -99,7 +98,7 @@ internal class ConstraintsProcessing(
private inline fun FeedbackStatus.then(action: (FeedbackStatus) -> FeedbackStatus) : FeedbackStatus =
if (operational) action(this) else this
private fun processMatch(controller: Controller, match: RuleMatchEx, parent: MatchJournal.MatchChunk, inStatus: FeedbackStatus) : FeedbackStatus =
private fun processMatch(controller: Controller, match: RuleMatchEx, inStatus: FeedbackStatus) : FeedbackStatus =
inStatus
.let {
controller.offerMatch(match, inStatus)
@ -121,7 +120,7 @@ internal class ConstraintsProcessing(
}
.also { trace.trigger(match) }
.also { accept(controller, match) }
.then { controller.processBody(match, parent, it) }
.then { controller.processBody(match, it) }
.also { trace.finish(match) }
private fun accept(controller: Controller, match: RuleMatchEx) {
@ -160,7 +159,6 @@ internal class ConstraintsProcessing(
private val savedJustifications: Justifications = justifications()
) {
fun Constraint.occurrence(
observable: LogicalStateObservable,
arguments: List<*>,
logicalContext: LogicalContext,
ruleUniqueTag: Rule.Tag? = null
@ -171,8 +169,8 @@ internal class ConstraintsProcessing(
val justifications = justsCopy(savedJustifications).apply { add(evidence) }
return Occurrence(
observable, this, logicalContext, arguments,
evidence, justifications, ruleUniqueTag
this, logicalContext, arguments, evidence,
justifications, ruleUniqueTag
)
}
}

View File

@ -49,12 +49,12 @@ internal class ControllerImpl (
/** For tests only */
override fun evaluate(occ: Occurrence): StoreView {
// create the internal occurrence
val active = occ.constraint().occurrence(logicalStateObservable(), occ.arguments(), occ.evidence, occ.justifications(), object: LogicalContext {
val active = occ.constraint().occurrence(occ.arguments(), occ.evidence, occ.justifications(), object: LogicalContext {
override fun <V : Any> variable(metaLogical: MetaLogical<V>): Logical<V>? = null
})
trace.activate(occ)
val status = processing.processActivated(this, active, processing.initialChunk(), NORMAL())
val status = processing.processActivated(this, active, NORMAL())
if (status is FAILED) {
throw status.failure.failureCause()
}
@ -69,10 +69,7 @@ internal class ControllerImpl (
return context.currentStatus()
}
override fun logicalStateObservable(): LogicalStateObservable =
processing
override fun ask(invocation: PredicateInvocation): Boolean {
val solver = invocation.predicate().symbol().solver(supervisor)
val result = solver.ask(invocation)
@ -96,7 +93,7 @@ internal class ControllerImpl (
profiler.profile<FeedbackStatus>("reactivate_${occ.constraint.symbol()}") {
trace.reactivate(occ)
processing.processActivated(this, occ, processing.parentChunk(), NORMAL())
processing.processActivated(this, occ, NORMAL())
}
@ -129,7 +126,7 @@ internal class ControllerImpl (
return context.currentStatus()
}
override fun processBody(match: RuleMatchEx, parent: MatchJournal.MatchChunk, inStatus: FeedbackStatus) : FeedbackStatus {
override fun processBody(match: RuleMatchEx, inStatus: FeedbackStatus) : FeedbackStatus {
val context = Context(inStatus, match.logicalContext(), match.rule().uniqueTag(), trace)
val altIt = match.rule().bodyAlternation().iterator()
@ -233,9 +230,9 @@ internal class ControllerImpl (
profiler.profile<FeedbackStatus>("activate_${constraint.symbol()}") {
with(creator) {
constraint.occurrence(logicalStateObservable(), args, context.logicalContext, context.ruleUniqueTag).let { occ ->
constraint.occurrence(args, context.logicalContext, context.ruleUniqueTag).let { occ ->
trace.activate(occ)
processing.processActivated(this@ControllerImpl, occ, parent, status)
processing.processActivated(this@ControllerImpl, occ, status)
}
}

View File

@ -63,8 +63,7 @@ internal data class SessionParts(
val journal: MatchJournal,
val logicalState: LogicalState,
val controller: ControllerImpl,
val processing: ConstraintsProcessing,
val principalObservers: PrincipalObserverDispatcher
val processing: ConstraintsProcessing
) {
val frontState: DispatchingFrontState get() = processing.getFrontState()
}
@ -94,8 +93,7 @@ internal class EvaluationSessionImpl private constructor (
fun getSession(token: SessionTokenImpl?): SessionParts {
val ruleIndex = token
?.ruleIndex
?.also { it.updateIndexFromRules(program.rules()) }
?.updateRuleIndex(program.rules())
?: RuleIndex(program.rules())
val journal = MatchJournalImpl(trace)
@ -106,11 +104,11 @@ internal class EvaluationSessionImpl private constructor (
val controller = ControllerImpl(supervisor, processing, trace, profiler)
return SessionParts(ruleIndex, journal, logicalState, controller, processing, PrincipalObserverDispatcher.EMPTY)
return SessionParts(ruleIndex, journal, logicalState, controller, processing)
}
override fun endSession(session: SessionParts): SessionToken = with(session) {
SessionTokenImpl(journal.storeView(), ruleIndex.toRules(), emptyFrontState(), ruleIndex, logicalState, principalObservers.apply { clearTriggerReceiver() })
SessionTokenImpl(journal.storeView(), ruleIndex.toRules(), emptyFrontState(), ruleIndex, logicalState)
}
override fun runSession(session: SessionParts, main: Constraint): EvaluationResult = with(session) {

View File

@ -16,7 +16,7 @@
package jetbrains.mps.logic.reactor.core.internal
import jetbrains.mps.logic.reactor.core.LogicalObserver
import jetbrains.mps.logic.reactor.logical.LogicalObserver
import jetbrains.mps.logic.reactor.logical.MutableLogical
import jetbrains.mps.logic.reactor.logical.MetaLogical
import java.util.ArrayList
@ -206,17 +206,3 @@ internal class LogicalImpl<T> : MutableLogical<T> {
class DefaultMetaLogical<V> (val name: String) : MetaLogical<V>(name, Object::class.java as Class<V>) {}
// Used from tests
@Deprecated(message = "use jetbrains.mps.logic.reactor.logical.Logical")
fun <V> anonLogical(value: V): MutableLogical<V> = LogicalImpl<V>(value)
@Deprecated(message = "use jetbrains.mps.logic.reactor.logical.Logical")
fun <V> namedLogical(name: String): MutableLogical<V> = LogicalImpl<V>(name)
@Deprecated(message = "use jetbrains.mps.logic.reactor.logical.Logical")
fun <V> MetaLogical<V>.logical(): MutableLogical<V> = LogicalImpl<V>(this)
@Deprecated(message = "use jetbrains.mps.logic.reactor.logical.Logical")
fun <V> MetaLogical<V>.logical(value: V): MutableLogical<V> = LogicalImpl<V>(name(), value)

View File

@ -18,6 +18,7 @@ package jetbrains.mps.logic.reactor.core.internal
import jetbrains.mps.logic.reactor.core.*
import jetbrains.mps.logic.reactor.logical.Logical
import jetbrains.mps.logic.reactor.logical.LogicalObserver
import java.util.*
import java.util.Collections.singleton
@ -30,7 +31,7 @@ import java.util.Collections.singleton
class LogicalState : LogicalStateObservable, LogicalObserver
{
private val observers = IdentityHashMap<Logical<*>, ArrayList<ForwardingLogicalObserver>>()
private val observers = IdentityHashMap<Logical<*>, ArrayList<Reactivatable>>()
private var controller: Controller? = null
@ -45,26 +46,16 @@ class LogicalState : LogicalStateObservable, LogicalObserver
return this
}
override fun addForwardingObserver(logical: Logical<*>, observer: ForwardingLogicalObserver) {
override fun addReactivatable(logical: Logical<*>, reactivatable: Reactivatable) {
if (!observers.containsKey(logical)) {
logical.addObserver(this)
}
observers.getOrPut(logical) { arrayListOf() }.add(observer)
observers.getOrPut(logical) { arrayListOf() }.add(reactivatable)
}
override fun removeForwardingObserver(logical: Logical<*>, observer: ForwardingLogicalObserver) {
override fun removeReactivatable(logical: Logical<*>, reactivatable: Reactivatable) {
observers[logical]?.apply {
removeAll(singleton(observer))
if (isEmpty()) observers.remove(logical)
}
if (!observers.containsKey(logical)) {
logical.removeObserver(this)
}
}
override fun removeForwardingObserversWhere(logical: Logical<*>, where: (ForwardingLogicalObserver) -> Boolean) {
observers[logical]?.apply {
removeIf(where)
removeAll(singleton(reactivatable))
if (isEmpty()) observers.remove(logical)
}
if (!observers.containsKey(logical)) {
@ -75,19 +66,17 @@ class LogicalState : LogicalStateObservable, LogicalObserver
override fun valueUpdated(logical: Logical<*>) {
observers[logical]?.let { list ->
for (observer in ArrayList(list)) {
observer.valueUpdated(logical, controller!!)
observer.reactivate(controller!!)
}
}
}
override fun parentUpdated(logical: Logical<*>) {
observers[logical]?.let { list ->
for (observer in ArrayList(list)) {
observer.parentUpdated(logical, controller!!)
observer.reactivate(controller!!)
}
}
}
}

View File

@ -1,49 +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.LogicalStateObservable
import jetbrains.mps.logic.reactor.core.Occurrence
typealias ObserverTriggeredHandler = (Occurrence) -> Boolean
interface PrincipalObserverDispatcher {
fun onActivated(occ: Occurrence, observable: LogicalStateObservable)
fun onInvalidated(occ: Occurrence, observable: LogicalStateObservable)
fun setTriggerReceiver(receiver: ObserverTriggeredHandler)
fun clearTriggerReceiver()
fun isObserving(occ: Occurrence): Boolean
fun isTriggered(occ: Occurrence): Boolean
fun removeTriggered(occ: Occurrence): Boolean
fun isEmpty(): Boolean
fun isNotEmpty() = !isEmpty()
companion object EMPTY : PrincipalObserverDispatcher {
override fun onActivated(occ: Occurrence, observable: LogicalStateObservable) { }
override fun onInvalidated(occ: Occurrence, observable: LogicalStateObservable) { }
override fun setTriggerReceiver(receiver: ObserverTriggeredHandler) { }
override fun clearTriggerReceiver() { }
override fun isEmpty(): Boolean = true
override fun isObserving(occ: Occurrence): Boolean = false
override fun isTriggered(occ: Occurrence): Boolean = false
override fun removeTriggered(occ: Occurrence): Boolean = false
}
}

View File

@ -19,10 +19,7 @@ package jetbrains.mps.logic.reactor.core.internal
import jetbrains.mps.logic.reactor.core.Occurrence
import jetbrains.mps.logic.reactor.core.RuleMatchEx
import jetbrains.mps.logic.reactor.core.Subst
import jetbrains.mps.logic.reactor.logical.Logical
import jetbrains.mps.logic.reactor.logical.LogicalContext
import jetbrains.mps.logic.reactor.logical.LogicalOwner
import jetbrains.mps.logic.reactor.logical.MetaLogical
import jetbrains.mps.logic.reactor.logical.*
import jetbrains.mps.logic.reactor.program.Rule
import jetbrains.mps.logic.reactor.util.Id

View File

@ -26,11 +26,13 @@ data class SessionTokenImpl(
private val storeView: StoreView,
private val rules: Iterable<Rule>,
private val frontState: DispatchingFrontState,
val ruleIndex: RuleIndex,
val logicalState: LogicalState,
val principalObservers: PrincipalObserverDispatcher = PrincipalObserverDispatcher.EMPTY
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) }
}

View File

@ -17,8 +17,6 @@
package jetbrains.mps.logic.reactor.logical;
import jetbrains.mps.logic.reactor.core.LogicalObservable;
/**
* A run-time representation of a logical variable.
*

View File

@ -0,0 +1,30 @@
/*
* Copyright 2014-2024 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.logical
/**
* An observable interface of a [Logical] instance.
*
* @author Fedor Isakov
*/
interface LogicalObservable {
fun addObserver(observer: LogicalObserver)
fun removeObserver(observer: LogicalObserver)
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 JetBrains s.r.o.
* Copyright 2014-2024 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.
@ -14,18 +14,8 @@
* limitations under the License.
*/
package jetbrains.mps.logic.reactor.core
package jetbrains.mps.logic.reactor.logical
import jetbrains.mps.logic.reactor.logical.Logical
interface LogicalObservable {
fun addObserver(observer: LogicalObserver)
fun removeObserver(observer: LogicalObserver)
}
/**
* An observer interface of a [Logical] instance.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2014-2020 JetBrains s.r.o.
* Copyright 2014-2024 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.
@ -13,11 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jetbrains.mps.logic.reactor.core.internal
package jetbrains.mps.unification
import jetbrains.mps.logic.reactor.logical.Logical
import jetbrains.mps.logic.reactor.logical.LogicalOwner
import jetbrains.mps.unification.Term
import java.util.*
/**

View File

@ -1,6 +1,6 @@
import jetbrains.mps.logic.reactor.core.LogicalObserver
import jetbrains.mps.logic.reactor.core.internal.anonLogical
import jetbrains.mps.logic.reactor.core.internal.namedLogical
import jetbrains.mps.logic.reactor.logical.LogicalObserver
import jetbrains.mps.logic.reactor.logical.anonLogical
import jetbrains.mps.logic.reactor.logical.namedLogical
import jetbrains.mps.logic.reactor.logical.MutableLogical
import jetbrains.mps.logic.reactor.logical.Logical
import jetbrains.mps.logic.reactor.logical.MetaLogical

View File

@ -102,15 +102,15 @@ fun equals(left: Any, right: Any): ConjBuilder.() -> Unit = {
fun occurrence(id: String, vararg args: Any): Occurrence =
MockConstraint(ConstraintSymbol.symbol(id, args.size))
.occurrence(MockController().logicalStateObservable(), listOf(* args), 0, justsOf(0), noLogicalContext)
.occurrence(listOf(* args), 0, justsOf(0), noLogicalContext)
fun taggedOccurrence(ruleUniqueTag: String, id: String, vararg args: Any): Occurrence =
MockConstraint(ConstraintSymbol.symbol(id, args.size))
.occurrence(MockController().logicalStateObservable(), listOf(* args), 0, justsOf(0), noLogicalContext, Rule.Tag(ruleUniqueTag))
.occurrence(listOf(* args), 0, justsOf(0), noLogicalContext, Rule.Tag(ruleUniqueTag))
fun justifiedOccurrence(id: String, evidence: Evidence, justifications: Justifications, principal: Boolean, vararg args: Any): Occurrence =
MockConstraint(ConstraintSymbol.symbol(id, args.size), principal)
.occurrence(MockController().logicalStateObservable(), listOf(* args), evidence, justifications, noLogicalContext)
.occurrence(listOf(* args), evidence, justifications, noLogicalContext)
fun principalOccurrence(id: String, hist: MatchJournal, vararg args: Any): Occurrence =
justifiedOccurrence(id, hist.evidence(), hist.justifications(), true, * args)
@ -134,56 +134,6 @@ private val noLogicalContext = object : LogicalContext {
override fun <V : Any> variable(metaLogical: MetaLogical<V>): Logical<V>? = null
}
class MockController : Controller {
override fun ask(invocation: PredicateInvocation): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun tell(invocation: PredicateInvocation) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun tryTell(invocation: PredicateInvocation): Solver.Result {
TODO("Not yet implemented")
}
override fun activate(constraint: Constraint): FeedbackStatus {
TODO("Not yet implemented")
}
override fun reactivate(occ: Occurrence): FeedbackStatus {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun evaluate(occ: Occurrence): StoreView {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun logicalStateObservable(): LogicalStateObservable = object : LogicalStateObservable {
override fun addForwardingObserver(logical: Logical<*>, observer: ForwardingLogicalObserver) {
}
override fun removeForwardingObserver(logical: Logical<*>, observer: ForwardingLogicalObserver) {
}
override fun removeForwardingObserversWhere(logical: Logical<*>, where: (ForwardingLogicalObserver) -> Boolean) {
}
}
override fun storeView(): StoreView {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun offerMatch(match: RuleMatchEx, inStatus: FeedbackStatus): FeedbackStatus {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun processBody(match: RuleMatchEx, parent: MatchJournal.MatchChunk, inStatus: FeedbackStatus): FeedbackStatus {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
class ConjBuilder(val type: Class<out AndItem>) {
val constraints = ArrayList<AndItem>()

View File

@ -1,6 +1,6 @@
import jetbrains.mps.logic.reactor.core.*
import jetbrains.mps.logic.reactor.core.internal.createController
import jetbrains.mps.logic.reactor.core.internal.logical
import jetbrains.mps.logic.reactor.logical.logical
import jetbrains.mps.logic.reactor.evaluation.*
import jetbrains.mps.logic.reactor.logical.Logical
import jetbrains.mps.logic.reactor.program.ConstraintSymbol

View File

@ -1,4 +1,4 @@
import jetbrains.mps.logic.reactor.core.LogicalObserver
import jetbrains.mps.logic.reactor.logical.LogicalObserver
import jetbrains.mps.logic.reactor.logical.Logical
import org.junit.Test

View File

@ -1,7 +1,7 @@
import jetbrains.mps.logic.reactor.core.*
import jetbrains.mps.logic.reactor.core.internal.UnionFindLinkedList
import jetbrains.mps.logic.reactor.core.internal.createOccurrenceMatcher
import jetbrains.mps.logic.reactor.core.internal.logical
import jetbrains.mps.logic.reactor.logical.logical
import jetbrains.mps.logic.reactor.evaluation.RuleMatch
import jetbrains.mps.logic.reactor.program.ConstraintSymbol
import jetbrains.mps.logic.reactor.program.ConstraintSymbol.symbol

View File

@ -16,8 +16,9 @@
package jetbrains.mps.unification.test;
import jetbrains.mps.logic.reactor.core.internal.TermWalker;
import jetbrains.mps.unification.Term;
import jetbrains.mps.unification.TermWalker;
import static org.junit.Assert.*;
import java.util.*;

View File

@ -16,9 +16,9 @@
package jetbrains.mps.unification.test;
import jetbrains.mps.logic.reactor.core.internal.LogicalImplKt;
import jetbrains.mps.logic.reactor.logical.MutableLogical;
import jetbrains.mps.logic.reactor.logical.MetaLogical;
import jetbrains.mps.logic.reactor.logical.LogicalKt;
import jetbrains.mps.unification.Substitution;
import jetbrains.mps.unification.Term;
import jetbrains.mps.unification.TermWrapper;
@ -666,9 +666,9 @@ public class SolverTests {
MetaLogical<Term> X = new MetaLogical<>("X", Term.class);
MetaLogical<Term> Y = new MetaLogical<>("Y", Term.class);
MetaLogical<Term> Z = new MetaLogical<>("Z", Term.class);
MutableLogical<Term> xLogical = LogicalImplKt.logical(X);
MutableLogical<Term> yLogical = LogicalImplKt.logical(Y);
MutableLogical<Term> zLogical = LogicalImplKt.logical(Z);
MutableLogical<Term> xLogical = LogicalKt.logical(X);
MutableLogical<Term> yLogical = LogicalKt.logical(Y);
MutableLogical<Term> zLogical = LogicalKt.logical(Z);
Term left = term("foo", term("bar", logicalVar(yLogical)), logicalVar(zLogical));
Term right = term("foo", term("bar", logicalVar(xLogical)), logicalVar(zLogical));
@ -686,9 +686,9 @@ public class SolverTests {
MetaLogical<Term> X = new MetaLogical<>("X", Term.class);
MetaLogical<Term> Y = new MetaLogical<>("Y", Term.class);
MetaLogical<Term> Z = new MetaLogical<>("Z", Term.class);
MutableLogical<Term> xLogical = LogicalImplKt.logical(X);
MutableLogical<Term> yLogical = LogicalImplKt.logical(Y);
MutableLogical<Term> zLogical = LogicalImplKt.logical(Z);
MutableLogical<Term> xLogical = LogicalKt.logical(X);
MutableLogical<Term> yLogical = LogicalKt.logical(Y);
MutableLogical<Term> zLogical = LogicalKt.logical(Z);
Term left = logicalVar(yLogical);
Term right = term("foo", term("bar", logicalVar(xLogical)), logicalVar(zLogical));