Skip to content
Snippets Groups Projects
Commit 2456f05f authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Etienne Kneuss
Browse files

Some cosmetic changes in Main

parent 4e238ff0
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ object Main { ...@@ -45,7 +45,7 @@ object Main {
lazy val allOptions = allComponents.flatMap(_.definedOptions) ++ topLevelOptions lazy val allOptions = allComponents.flatMap(_.definedOptions) ++ topLevelOptions
def displayHelp(reporter: Reporter) { def displayHelp(reporter: Reporter, error: Boolean) {
reporter.info("usage: leon [--xlang] [--termination] [--synthesis] [--help] [--debug=<N>] [..] <files>") reporter.info("usage: leon [--xlang] [--termination] [--synthesis] [--help] [--debug=<N>] [..] <files>")
reporter.info("") reporter.info("")
for (opt <- topLevelOptions.toSeq.sortBy(_.name)) { for (opt <- topLevelOptions.toSeq.sortBy(_.name)) {
...@@ -63,9 +63,11 @@ object Main { ...@@ -63,9 +63,11 @@ object Main {
reporter.info(f"${opt.usageOption}%-20s ${opt.usageDesc}") reporter.info(f"${opt.usageOption}%-20s ${opt.usageDesc}")
} }
} }
sys.exit(1) exit(error)
} }
private def exit(error: Boolean) = sys.exit(if (error) 1 else 0)
def processOptions(args: Seq[String]): LeonContext = { def processOptions(args: Seq[String]): LeonContext = {
val initReporter = new DefaultReporter(Settings()) val initReporter = new DefaultReporter(Settings())
...@@ -129,7 +131,7 @@ object Main { ...@@ -129,7 +131,7 @@ object Main {
Some(LeonFlagOption(fod.name, v)) Some(LeonFlagOption(fod.name, v))
case None => case None =>
initReporter.error("Invalid option usage: --"+fod.name+"="+value) initReporter.error("Invalid option usage: --"+fod.name+"="+value)
displayHelp(initReporter) displayHelp(initReporter, error=true)
None None
} }
case (vod: LeonValueOptionDef, value) => case (vod: LeonValueOptionDef, value) =>
...@@ -174,7 +176,7 @@ object Main { ...@@ -174,7 +176,7 @@ object Main {
case LeonFlagOption("noop", true) => case LeonFlagOption("noop", true) =>
settings = settings.copy(verify = false) settings = settings.copy(verify = false)
case LeonFlagOption("help", true) => case LeonFlagOption("help", true) =>
displayHelp(initReporter) displayHelp(initReporter, error = false)
case _ => case _ =>
} }
...@@ -204,6 +206,8 @@ object Main { ...@@ -204,6 +206,8 @@ object Main {
def computePipeline(settings: Settings): Pipeline[List[String], Any] = { def computePipeline(settings: Settings): Pipeline[List[String], Any] = {
import purescala.Definitions.Program import purescala.Definitions.Program
import purescala.{FunctionClosure, RestoreMethods}
import utils.FileOutputPhase
import frontends.scalac.ExtractionPhase import frontends.scalac.ExtractionPhase
import synthesis.SynthesisPhase import synthesis.SynthesisPhase
import termination.TerminationPhase import termination.TerminationPhase
...@@ -232,9 +236,9 @@ object Main { ...@@ -232,9 +236,9 @@ object Main {
} else if (settings.xlang) { } else if (settings.xlang) {
XLangAnalysisPhase XLangAnalysisPhase
} else if (settings.verify) { } else if (settings.verify) {
purescala.FunctionClosure andThen AnalysisPhase FunctionClosure andThen AnalysisPhase
} else { } else {
purescala.RestoreMethods andThen utils.FileOutputPhase RestoreMethods andThen FileOutputPhase
} }
} }
...@@ -242,7 +246,7 @@ object Main { ...@@ -242,7 +246,7 @@ object Main {
pipeProcess pipeProcess
} }
private var hasFatal = false; private var hasFatal = false
def main(args: Array[String]) { def main(args: Array[String]) {
val argsl = args.toList val argsl = args.toList
...@@ -250,9 +254,10 @@ object Main { ...@@ -250,9 +254,10 @@ object Main {
// Process options // Process options
val ctx = try { val ctx = try {
processOptions(argsl) processOptions(argsl)
} catch { } catch {
case LeonFatalError(None) => case LeonFatalError(None) =>
sys.exit(1) exit(error=true)
case LeonFatalError(Some(msg)) => case LeonFatalError(Some(msg)) =>
// For the special case of fatal errors not sent though Reporter, we // For the special case of fatal errors not sent though Reporter, we
...@@ -263,7 +268,7 @@ object Main { ...@@ -263,7 +268,7 @@ object Main {
case _: LeonFatalError => case _: LeonFatalError =>
} }
sys.exit(1) exit(error=true)
} }
ctx.interruptManager.registerSignalHandler() ctx.interruptManager.registerSignalHandler()
...@@ -282,11 +287,7 @@ object Main { ...@@ -282,11 +287,7 @@ object Main {
execute(args, ctx) execute(args, ctx)
} }
if (hasFatal) { exit(hasFatal)
sys.exit(1)
} else {
sys.exit(0)
}
} }
def execute(args: Seq[String], ctx0: LeonContext): Unit = { def execute(args: Seq[String], ctx0: LeonContext): Unit = {
...@@ -314,6 +315,7 @@ object Main { ...@@ -314,6 +315,7 @@ object Main {
ctx.reporter.whenDebug(DebugSectionTimers) { debug => ctx.reporter.whenDebug(DebugSectionTimers) { debug =>
ctx.timers.outputTable(debug) ctx.timers.outputTable(debug)
} }
hasFatal = false
} catch { } catch {
case LeonFatalError(None) => case LeonFatalError(None) =>
hasFatal = true hasFatal = true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment