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

commonMain.it.unibo.tuprolog.solve.exception.warning.MissingPredicate.kt Maven / Gradle / Ivy

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

import it.unibo.tuprolog.solve.ExecutionContext
import it.unibo.tuprolog.solve.Signature
import it.unibo.tuprolog.solve.exception.Warning
import kotlin.js.JsName

class MissingPredicate(
    cause: Throwable?,
    contexts: Array,
    @JsName("signature") val signature: Signature,
) : Warning("No such a predicate: ${signature.toIndicator()}", cause, contexts) {
    constructor(
        cause: Throwable?,
        context: ExecutionContext,
        signature: Signature,
    ) : this(cause, arrayOf(context), signature)

    constructor(
        context: ExecutionContext,
        signature: Signature,
    ) : this(null, arrayOf(context), signature)

    override fun updateContext(
        newContext: ExecutionContext,
        index: Int,
    ): MissingPredicate = MissingPredicate(cause, contexts.setItem(index, newContext), signature)

    override fun updateLastContext(newContext: ExecutionContext): MissingPredicate =
        updateContext(
            newContext,
            contexts.lastIndex,
        )

    override fun pushContext(newContext: ExecutionContext): MissingPredicate =
        MissingPredicate(cause, contexts.addLast(newContext), signature)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy