-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'unstable' of https://github.com/informalsystems/apalache …
…into ro/infinite-sets-bug
- Loading branch information
Showing
30 changed files
with
988 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
mod-infra/src/main/scala/at/forsyte/apalache/infra/Executor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package at.forsyte.apalache.infra | ||
|
||
import at.forsyte.apalache.infra.passes.{Pass, PassChainExecutor, ToolModule, WriteablePassOptions} | ||
import com.google.inject.Guice | ||
|
||
/** | ||
* This Executor abstracts the dependency injection and execution logic required for executing a PassChainExecutor | ||
* | ||
* @param toolModule | ||
* The [[ToolModule]] that specifies the sequence of passes | ||
* @throws [[AdaptedException]] | ||
* if any exceptions are caught by the configured [[ExceptionAdapter]] | ||
* @author | ||
* Shon Feder | ||
*/ | ||
case class Executor(val toolModule: ToolModule) { | ||
private val injector = Guice.createInjector(toolModule) | ||
|
||
/** Exposes mutable access to options configuring the behavior of the [passChainExecutor] */ | ||
val passOptions = injector.getInstance(classOf[WriteablePassOptions]) | ||
|
||
private val exceptionAdapter = injector.getInstance(classOf[ExceptionAdapter]) | ||
|
||
private val passChainExecutor = { | ||
val passes = toolModule.passes.zipWithIndex.map { case (p, i) => | ||
injector.getInstance(p).withNumber(i) | ||
} | ||
new PassChainExecutor(passOptions, passes) | ||
} | ||
|
||
/** Run the underlying PassChainExecutor, adapting exceptions as needed, and returning a `PassResult` */ | ||
def run(): Pass.PassResult = { | ||
try { | ||
passChainExecutor.run() | ||
} catch { | ||
case e: Throwable if exceptionAdapter.toMessage.isDefinedAt(e) => | ||
throw new AdaptedException(exceptionAdapter.toMessage(e)) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.