Get rid off nullability of Justs
This commit is contained in:
parent
52fd54afce
commit
0cbc32d4a0
|
|
@ -39,7 +39,7 @@ data class Occurrence (val controller: Controller,
|
|||
val constraint: Constraint,
|
||||
val logicalContext: LogicalContext,
|
||||
val arguments: List<*>,
|
||||
val justifications: Justs?):
|
||||
val justifications: Justs):
|
||||
ConstraintOccurrence,
|
||||
LogicalObserver
|
||||
{
|
||||
|
|
@ -58,7 +58,7 @@ data class Occurrence (val controller: Controller,
|
|||
|
||||
override fun logicalContext(): LogicalContext = logicalContext
|
||||
|
||||
override fun justifications(): Justs? = justifications
|
||||
override fun justifications(): Justs = justifications
|
||||
|
||||
override fun valueUpdated(logical: Logical<*>) {
|
||||
if (alive) {
|
||||
|
|
@ -96,18 +96,18 @@ data class Occurrence (val controller: Controller,
|
|||
|
||||
fun Constraint.occurrence(controller: Controller,
|
||||
arguments: List<*>,
|
||||
justifications: Justs?,
|
||||
justifications: Justs,
|
||||
logicalContext: LogicalContext): Occurrence =
|
||||
Occurrence(controller, this, logicalContext, arguments, justifications)
|
||||
|
||||
fun Constraint.occurrence(controller: Controller,
|
||||
arguments: List<*>,
|
||||
justifications: Justs?): Occurrence =
|
||||
justifications: Justs): Occurrence =
|
||||
Occurrence(controller, this, noLogicalContext, arguments, justifications)
|
||||
|
||||
fun Constraint.occurrence(controller: Controller,
|
||||
arguments: List<*>): Occurrence =
|
||||
Occurrence(controller, this, noLogicalContext, arguments, null)
|
||||
Occurrence(controller, this, noLogicalContext, arguments, justsOf())
|
||||
|
||||
private val noLogicalContext: LogicalContext = object: LogicalContext {
|
||||
override fun <V : Any> variable(metaLogical: MetaLogical<V>): Logical<V>? = null
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ internal class ControllerImpl (
|
|||
val args = supervisor.instantiateArguments(constraint.arguments(), context.logicalContext, context)
|
||||
return context.eval { status ->
|
||||
|
||||
state.processActivated(constraint.occurrence(this, args, null, context.logicalContext), status)
|
||||
state.processActivated(constraint.occurrence(this, args, justsOf(), context.logicalContext), status)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ internal open class MatchJournalImpl(view: MatchJournal.View?): MatchJournal {
|
|||
|
||||
// Log discards
|
||||
match.forEachReplaced {occ ->
|
||||
// this.dispatchFringe = dispatchFringe.contract(occ)
|
||||
current.occurrences.add(MatchJournal.Chunk.Entry(occ, true))
|
||||
occ.terminate()
|
||||
}
|
||||
|
|
@ -241,9 +240,8 @@ internal class StoreAwareJournalImpl(val state: ProcessingStateImpl, view: Match
|
|||
|
||||
private fun RuleMatch.headJustifications(): Justs {
|
||||
val res: Justs = justsOf()
|
||||
this.matchHeadKept().forEach { it.justifications()?.let { res.addAll(it) } }
|
||||
this.matchHeadReplaced().forEach { it.justifications()?.let { res.addAll(it) } }
|
||||
this.matchHeadKept().forEach { it.justifications().let { res.addAll(it) } }
|
||||
this.matchHeadReplaced().forEach { it.justifications().let { res.addAll(it) } }
|
||||
return res
|
||||
// return if (res.isEmpty) null else res
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package jetbrains.mps.logic.reactor.evaluation;
|
|||
import gnu.trove.set.TIntSet;
|
||||
import jetbrains.mps.logic.reactor.logical.LogicalContext;
|
||||
import jetbrains.mps.logic.reactor.program.Constraint;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ public interface ConstraintOccurrence {
|
|||
|
||||
LogicalContext logicalContext();
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
TIntSet justifications();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue