diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ConstraintsProcessing.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ConstraintsProcessing.kt index 7c88bd40..c5fcec72 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ConstraintsProcessing.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ConstraintsProcessing.kt @@ -42,7 +42,6 @@ internal class ConstraintsProcessing( val trace: EvaluationTrace = EvaluationTrace.NULL, val profiler: Profiler? = null ) : MatchJournal by journal { - fun getFrontState(): DispatchingFrontState = dispatchingFront.state() fun engage(controller: Controller) { logicalState.setController(controller) @@ -72,9 +71,8 @@ internal class ConstraintsProcessing( } val matches = dispatchingFront.matches().toList() - val currentMatches = matches - val outStatus = processMatches(controller, active, currentMatches, inStatus) + val outStatus = processMatches(controller, active, matches, inStatus) // TODO: should be isAlive() if (active.stored) { diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ControllerImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ControllerImpl.kt index 723f8433..582963fd 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ControllerImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ControllerImpl.kt @@ -166,7 +166,7 @@ internal class ControllerImpl ( val itemOk = when (item) { is Constraint -> activateConstraint(item, newParent, occCreator, context) is Predicate -> tellPredicate(item, context) - else -> throw IllegalArgumentException("unknown item ${item}") + else -> throw IllegalArgumentException("unknown item $item") } if (itemOk) { @@ -303,7 +303,7 @@ internal class ControllerImpl ( logicalContext: LogicalContext, rule: Rule? = null, trace: EvaluationTrace = EvaluationTrace.NULL) : - this(inStatus, false, logicalContext, rule, trace) { } + this(inStatus, false, logicalContext, rule, trace) fun currentStatus(): FeedbackStatus = status diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/FeedbackStatus.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/FeedbackStatus.kt index ab4b5277..1d4b1d2b 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/FeedbackStatus.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/FeedbackStatus.kt @@ -60,19 +60,10 @@ abstract class FeedbackStatus(val feedback : Feedback?) { override fun recover(): FeedbackStatus = NORMAL(feedback) } - class ABORTED(status: FeedbackStatus, val reason: Feedback) : FeedbackStatus(compose(status.feedback, reason)) { + class ABORTED(status: FeedbackStatus, reason: Feedback) : FeedbackStatus(compose(status.feedback, reason)) { override val operational = false override fun recover(): FeedbackStatus = NORMAL(CompositeFeedback.dropLast(feedback)) } } internal fun compose(left: Feedback?, right: Feedback?) = CompositeFeedback.of(left, right) - -data class ReportMessage(val severity: Severity, val message: String) - -enum class Severity(val level: Int) { - INFO(0), - WARNING(1), - ERROR(2), - FATAL(3) -} diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/LogicalImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/LogicalImpl.kt index 94def4d6..e9023d10 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/LogicalImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/LogicalImpl.kt @@ -204,5 +204,5 @@ internal class LogicalImpl : MutableLogical { } -class DefaultMetaLogical (val name: String) : MetaLogical(name, Object::class.java as Class) {} +class DefaultMetaLogical (val name: String) : MetaLogical(name, Object::class.java as Class) diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt index 1bd6518c..368f5cda 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournal.kt @@ -63,13 +63,6 @@ interface MatchJournal : EvidenceSource { * will return the count of all [Occurrence]s. */ fun currentPos(): Pos - - /** - * Returns internal [ChunkIterator] that allows to remove future [Chunk]s. - */ - @Deprecated("Obsolete TBR") - val cursor: ChunkIterator - get() = TODO() /** * Erase journal between [currentPos] (erased) and [pastPos] (not erased). @@ -102,8 +95,7 @@ interface MatchJournal : EvidenceSource { * Immutable snapshot of [MatchJournal]. * FOR TESTS ONLY */ - data class View(val chunks: List, val evidenceSeed: Evidence) { - } + data class View(val chunks: List, val evidenceSeed: Evidence) /** * [MatchJournal] operates on [Chunk]s -- basic [Justified] entities. diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt index 0a016498..e6195bf2 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/MatchJournalImpl.kt @@ -45,7 +45,7 @@ internal open class MatchJournalImpl( private val justifications = match.collectJustifications(evidence) - override fun toString() = "(id=$evidence, ${justifications()}, ${match.rule().uniqueTag().toString()}, $entries)" + override fun toString() = "(id=$evidence, ${justifications()}, ${match.rule().uniqueTag()}, $entries)" } private class OccChunkImpl(override val occ: Occurrence) : ChunkImpl(), Justified by occ, OccChunk { @@ -123,21 +123,6 @@ internal open class MatchJournalImpl( ancestorChunksStack.push(nextChunk) } - private fun collectJustificationsFrom(match: RuleMatch) { - val parent: MatchChunk = parentChunk() - - val moreJustified = match.allHeads().filter { - // Filter to avoid justifying parent by its child! - !it.justifiedBy(parent) - }.toList() - - if (moreJustified.isNotEmpty()) { - __cursor.applyToPast(parent.toPos()) { child -> - child.addJustifications(moreJustified) - } - } - } - override fun logActivation(occ: Occurrence) { resetParentChunk(occ) __cursor.addChunk(OccChunkImpl(occ)) @@ -304,26 +289,6 @@ internal open class MatchJournalImpl( indexChunk(chunk) } - /** - * Walk in journal in direct order ([from] -> [current]) - * while applying [action] to each visited [Chunk] - * (not including [from], but including [__current]). - * No journal state is changed, except by [action] effects - * (i.e. no reset or replay of occurrences is performed). - */ - inline fun applyToPast(from: Pos, action: (Chunk) -> Unit) { - val returnTo = __current - // there's always at least initial chunk - do { - __current = iter.previous() - } while (!(this at from)) - - do { - __current = iter.next() - action(__current) - } while (!(this at returnTo)) - } - /** * Walk in journal in inverse order ([pastPos] <- [current]), excluding [pastPos] * while applying [action] to each [Chunk] and removing it. diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ReteRuleMatcherImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ReteRuleMatcherImpl.kt index 40e0c715..408f8327 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ReteRuleMatcherImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ReteRuleMatcherImpl.kt @@ -98,7 +98,7 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup?, } - inner class InitialNode() : ReteNode() { + inner class InitialNode : ReteNode() { override fun fillSignature(signature: Signature) {} @@ -379,7 +379,7 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup?, */ inner class Generation private constructor (prev: Generation?) { - val layers: MutableList = prev?.layers ?: ArrayList(4) + val layers: MutableList = prev?.layers ?: ArrayList(4) lateinit var nodesIt: MutableIterator @@ -452,14 +452,6 @@ internal class ReteRuleMatcherImpl(private var ruleLookup: RuleLookup?, return nextGeneration().reset() } - private fun clearInvalidNodes(): Generation { - while (nodesIt.hasNext()) { - val n = nodesIt.next() - if (n.isInvalid()) nodesIt.remove() - } - return this.reset() - } - fun nextGeneration(): Generation = Generation(this) fun calcMatches(): Collection { @@ -632,9 +624,7 @@ class UnionFindLinkedList : Iterable { } - inner class DataJoint(val value: T) : Joint() { - - } + inner class DataJoint(val value: T) : Joint() var head = Joint() var tail = head