All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.it.unibo.tuprolog.solve.ExecutionContext.kt Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package it.unibo.tuprolog.solve

import it.unibo.tuprolog.core.Struct
import it.unibo.tuprolog.core.Substitution
import it.unibo.tuprolog.core.operators.OperatorSet
import it.unibo.tuprolog.solve.channel.InputStore
import it.unibo.tuprolog.solve.channel.OutputStore
import it.unibo.tuprolog.solve.data.CustomDataStore
import it.unibo.tuprolog.solve.flags.FlagStore
import it.unibo.tuprolog.solve.library.Runtime
import it.unibo.tuprolog.solve.sideffects.SideEffect
import it.unibo.tuprolog.theory.Theory
import it.unibo.tuprolog.unify.Unificator
import kotlin.js.JsName

/** An interface representing the Solver execution context, containing important information that determines its behaviour */
interface ExecutionContext : ExecutionContextAware, Durable {
    /** The current procedure being executed */
    @JsName("procedure")
    val procedure: Struct?

    /** The set of current substitution till this context */
    @JsName("substitution")
    val substitution: Substitution.Unifier

    /** The Prolog call stacktrace till this ExecutionContext */
    @JsName("logicStackTrace")
    val logicStackTrace: List

    @JsName("customData")
    val customData: CustomDataStore

    @JsName("createSolver")
    fun createSolver(
        unificator: Unificator = this.unificator,
        libraries: Runtime = this.libraries,
        flags: FlagStore = this.flags,
        staticKb: Theory = this.staticKb,
        dynamicKb: Theory = this.dynamicKb,
        inputChannels: InputStore = this.inputChannels,
        outputChannels: OutputStore = this.outputChannels,
    ): Solver

    @JsName("createMutableSolver")
    fun createMutableSolver(
        unificator: Unificator = this.unificator,
        libraries: Runtime = this.libraries,
        flags: FlagStore = this.flags,
        staticKb: Theory = this.staticKb,
        dynamicKb: Theory = this.dynamicKb,
        inputChannels: InputStore = this.inputChannels,
        outputChannels: OutputStore = this.outputChannels,
    ): MutableSolver

    @JsName("apply")
    fun apply(sideEffect: SideEffect): ExecutionContext {
        return apply(listOf(sideEffect))
    }

    @JsName("applyIterable")
    fun apply(sideEffects: Iterable): ExecutionContext {
        var current = this
        for (sideEffect in sideEffects) {
            current = sideEffect.applyTo(current)
        }
        return current
    }

    @JsName("applySequence")
    fun apply(sideEffects: Sequence): ExecutionContext = apply(sideEffects.asIterable())

    @JsName("update")
    fun update(
        unificator: Unificator = this.unificator,
        libraries: Runtime = this.libraries,
        flags: FlagStore = this.flags,
        staticKb: Theory = this.staticKb,
        dynamicKb: Theory = this.dynamicKb,
        operators: OperatorSet = this.operators,
        inputChannels: InputStore = this.inputChannels,
        outputChannels: OutputStore = this.outputChannels,
        customData: CustomDataStore = this.customData,
    ): ExecutionContext
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy