![JAR search and dependency download from the Maven repository](/logo.png)
commonMain.it.unibo.tuprolog.solve.stdlib.primitive.EnsureExecutable.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solve-jvm Show documentation
Show all versions of solve-jvm Show documentation
Resolution-agnostic API for logic solvers
package it.unibo.tuprolog.solve.stdlib.primitive
import it.unibo.tuprolog.core.Term
import it.unibo.tuprolog.core.Var
import it.unibo.tuprolog.solve.ExecutionContext
import it.unibo.tuprolog.solve.exception.error.InstantiationError
import it.unibo.tuprolog.solve.exception.error.TypeError
import it.unibo.tuprolog.solve.extractSignature
import it.unibo.tuprolog.solve.primitive.Solve
import it.unibo.tuprolog.solve.primitive.TypeEnsurer
object EnsureExecutable : TypeEnsurer("ensure_executable") {
override fun Solve.Request.ensureType(
context: ExecutionContext,
term: Term,
) {
val signature = context.procedure?.extractSignature() ?: signature
when (term) {
is Var -> {
val variable = context.substitution.getOriginal(term) ?: term
throw InstantiationError.forGoal(context, signature, variable)
}
else -> {
checkTermIsRecursivelyCallable(term)?.let {
throw TypeError.forGoal(context, signature, it.expectedType, term)
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy