diff --git a/build.gradle.kts b/build.gradle.kts index b6c37315a..4fe28bb72 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -100,7 +100,7 @@ ktSubprojects.forEachProject { val commonMain by getting { dependencies { api(kotlin("stdlib-common")) - api(kotlin("reflect")) +// api(kotlin("reflect")) } } val commonTest by getting { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solver.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solver.kt index b0f2a70ac..2f12239a3 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solver.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solver.kt @@ -2,6 +2,7 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.core.Struct import kotlin.js.JsName +import kotlin.jvm.JvmOverloads /** * Represents a Prolog Goal solver @@ -12,7 +13,10 @@ interface Solver : ExecutionContextAware { /** Solves the provided goal, returning lazily initialized sequence of solutions, optionally limiting computation [maxDuration] */ @JsName("solve") - fun solve(goal: Struct, maxDuration: TimeDuration = TimeDuration.MAX_VALUE): Sequence + fun solve(goal: Struct, maxDuration: TimeDuration): Sequence + + @JsName("solveMaxDuration") + fun solve(goal: Struct): Sequence = solve(goal, TimeDuration.MAX_VALUE) companion object { // To be extended through extension methods diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverFactory.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverFactory.kt index 5d1ccf566..caa63f618 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverFactory.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverFactory.kt @@ -45,7 +45,7 @@ interface SolverFactory { val defaultWarningsChannel: OutputChannel get() = OutputChannel.stdErr() - @JsName("solverOf") + @JsName("solver") fun solverOf( libraries: Libraries = defaultLibraries, flags: PrologFlags = defaultFlags, @@ -57,7 +57,93 @@ interface SolverFactory { warnings: OutputChannel = defaultWarningsChannel ): Solver - @JsName("solverWithDefaultBuiltins") + @JsName("solverOfLibrariesAndKBs") + fun solverOf( + libraries: Libraries, + staticKb: Theory, + dynamicKb: Theory + ) = solverOf( + libraries, + defaultFlags, + staticKb, + dynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverOfKBs") + fun solverOf( + staticKb: Theory, + dynamicKb: Theory + ) = solverOf( + defaultLibraries, + defaultFlags, + staticKb, + dynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverOfStaticKB") + fun solverOf( + staticKb: Theory + ) = solverOf( + defaultLibraries, + defaultFlags, + staticKb, + defaultStaticKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverOfLibrariesAndStaticKB") + fun solverOf( + libraries: Libraries, + staticKb: Theory + ) = solverOf( + libraries, + defaultFlags, + staticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverOfLibraries") + fun solverOf( + libraries: Libraries + ) = solverOf( + libraries, + defaultFlags, + defaultStaticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverOf") + fun solverOf() = solverOf( + defaultLibraries, + defaultFlags, + defaultStaticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverWithDefaultBuiltinsAnd") fun solverWithDefaultBuiltins( otherLibraries: Libraries = defaultLibraries, flags: PrologFlags = defaultFlags, @@ -71,7 +157,78 @@ interface SolverFactory { otherLibraries + defaultBuiltins, flags, staticKb, dynamicKb, stdIn, stdOut, stdErr, warnings ) - @JsName("mutableSolverOf") + @JsName("solverWithDefaultBuiltinsAndLibrariesAndKBs") + fun solverWithDefaultBuiltins( + otherLibraries: Libraries, + staticKb: Theory, + dynamicKb: Theory + ) = solverWithDefaultBuiltins( + otherLibraries, + defaultFlags, + staticKb, + dynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverWithDefaultBuiltinsAndKBs") + fun solverWithDefaultBuiltins( + staticKb: Theory, + dynamicKb: Theory + ) = solverWithDefaultBuiltins( + defaultLibraries, + defaultFlags, + staticKb, + dynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverWithDefaultBuiltinsAndStaticKB") + fun solverWithDefaultBuiltins( + staticKb: Theory + ) = solverWithDefaultBuiltins( + defaultLibraries, + defaultFlags, + staticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverWithDefaultBuiltinsAndLibraries") + fun solverWithDefaultBuiltins( + otherLibraries: Libraries + ) = solverWithDefaultBuiltins( + otherLibraries, + defaultFlags, + defaultStaticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("solverWithDefaultBuiltins") + fun solverWithDefaultBuiltins() = solverWithDefaultBuiltins( + defaultLibraries, + defaultFlags, + defaultStaticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolver") fun mutableSolverOf( libraries: Libraries = defaultLibraries, flags: PrologFlags = defaultFlags, @@ -83,7 +240,93 @@ interface SolverFactory { warnings: OutputChannel = defaultWarningsChannel ): MutableSolver - @JsName("mutableSolverWithDefaultBuiltins") + @JsName("mutableSolverOfLibrariesAndKBs") + fun mutableSolverOf( + libraries: Libraries, + staticKb: Theory, + dynamicKb: Theory + ) = mutableSolverOf( + libraries, + defaultFlags, + staticKb, + dynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverOfKBs") + fun mutableSolverOf( + staticKb: Theory, + dynamicKb: Theory + ) = mutableSolverOf( + defaultLibraries, + defaultFlags, + staticKb, + dynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverOfStaticKB") + fun mutableSolverOf( + staticKb: Theory + ) = mutableSolverOf( + defaultLibraries, + defaultFlags, + staticKb, + defaultStaticKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverOfLibrariesAndStaticKB") + fun mutableSolverOf( + libraries: Libraries, + staticKb: Theory + ) = mutableSolverOf( + libraries, + defaultFlags, + staticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverOfLibraries") + fun mutableSolverOf( + libraries: Libraries + ) = mutableSolverOf( + libraries, + defaultFlags, + defaultStaticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverOf") + fun mutableSolverOf() = mutableSolverOf( + defaultLibraries, + defaultFlags, + defaultStaticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverWithDefaultBuiltinsAnd") fun mutableSolverWithDefaultBuiltins( otherLibraries: Libraries = defaultLibraries, flags: PrologFlags = defaultFlags, @@ -95,4 +338,76 @@ interface SolverFactory { warnings: OutputChannel = defaultWarningsChannel ): MutableSolver = mutableSolverOf(otherLibraries + defaultBuiltins, flags, staticKb, dynamicKb, stdIn, stdOut, stdErr, warnings) + + @JsName("mutableSolverWithDefaultBuiltinsAndLibrariesAndKBs") + fun mutableSolverWithDefaultBuiltins( + otherLibraries: Libraries, + staticKb: Theory, + dynamicKb: Theory + ) = mutableSolverWithDefaultBuiltins( + otherLibraries, + defaultFlags, + staticKb, + dynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverWithDefaultBuiltinsAndKBs") + fun mutableSolverWithDefaultBuiltins( + staticKb: Theory, + dynamicKb: Theory + ) = mutableSolverWithDefaultBuiltins( + defaultLibraries, + defaultFlags, + staticKb, + dynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverWithDefaultBuiltinsAndStaticKB") + fun mutableSolverWithDefaultBuiltins( + staticKb: Theory + ) = mutableSolverWithDefaultBuiltins( + defaultLibraries, + defaultFlags, + staticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverWithDefaultBuiltinsAndLibraries") + fun mutableSolverWithDefaultBuiltins( + otherLibraries: Libraries + ) = mutableSolverWithDefaultBuiltins( + otherLibraries, + defaultFlags, + defaultStaticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) + + @JsName("mutableSolverWithDefaultBuiltins") + fun mutableSolverWithDefaultBuiltins() = + mutableSolverWithDefaultBuiltins( + defaultLibraries, + defaultFlags, + defaultStaticKb, + defaultDynamicKb, + defaultInputChannel, + defaultOutputChannel, + defaultErrorChannel, + defaultWarningsChannel + ) } \ No newline at end of file