graceful handling of empty files

This commit is contained in:
Donggyu Kim
2017-07-05 15:53:58 -07:00
committed by edwardcwang
parent 9e7c8dce3e
commit 02fef8e2c3
2 changed files with 10 additions and 9 deletions

View File

@@ -376,18 +376,19 @@ object MacroCompiler extends App {
throw new Exception(usage)
}
def run(args: List[String]) = {
def run(args: List[String]) {
val (params, synflops) = parseArgs(Map[MacroParam, File](), false, args)
try {
val macros = readJSON(params get Macros).get map (x => (new Macro(x)).blackbox)
val circuit = Circuit(NoInfo, macros, macros.last.name)
val annotations = AnnotationMap(Seq(MacroCompilerAnnotation(
circuit.main, params(Macros), params get Library, synflops)))
val state = CircuitState(circuit, HighForm, Some(annotations))
val verilog = new FileWriter(params(Verilog))
val result = new MacroCompiler compile (state, verilog)
if (macros.nonEmpty) {
val circuit = Circuit(NoInfo, macros, macros.last.name)
val annotations = AnnotationMap(Seq(MacroCompilerAnnotation(
circuit.main, params(Macros), params get Library, synflops)))
val state = CircuitState(circuit, HighForm, Some(annotations))
val result = new MacroCompiler compile (state, verilog)
}
verilog.close
result
} catch {
case e: java.util.NoSuchElementException =>
throw new Exception(usage)

View File

@@ -128,10 +128,10 @@ object Utils {
case (res, _) => res
}
)
case _ => None
case _ => Some(Nil)
}
} catch {
case _: Throwable => None
case _: Throwable => Some(Nil)
}
}