fix: main outputs to current dir
This commit is contained in:
parent
1c6ea16b6e
commit
ab28f0950a
@ -216,15 +216,18 @@ _readi:
|
||||
case _ => List()
|
||||
}
|
||||
|
||||
def compile(filename: String)(using stdout: PrintStream = Console.out): Int =
|
||||
def compile(filename: String, outFile: Option[File] = None)(using
|
||||
stdout: PrintStream = Console.out
|
||||
): Int =
|
||||
frontend(os.read(os.Path(filename))) match {
|
||||
case Left(typedProg) =>
|
||||
val asmFile = outFile.getOrElse(File(filename.stripSuffix(".wacc") + ".s"))
|
||||
println("OUTPUT TO" + asmFile.getAbsolutePath())
|
||||
backend(typedProg) match {
|
||||
case s: String =>
|
||||
os.write.over(os.Path(filename.stripSuffix(".wacc") + ".s"), s)
|
||||
os.write.over(os.Path(asmFile.getAbsolutePath), s)
|
||||
case ops: List[asm.AsmLine] => {
|
||||
val outFile = File(filename.stripSuffix(".wacc") + ".s")
|
||||
writer.writeTo(ops, PrintStream(outFile))
|
||||
writer.writeTo(ops, PrintStream(asmFile))
|
||||
}
|
||||
}
|
||||
0
|
||||
@ -233,6 +236,10 @@ def compile(filename: String)(using stdout: PrintStream = Console.out): Int =
|
||||
|
||||
def main(args: Array[String]): Unit =
|
||||
OParser.parse(cliParser, args, CliConfig()) match {
|
||||
case Some(config) => compile(config.file.getAbsolutePath)
|
||||
case None =>
|
||||
case Some(config) =>
|
||||
compile(
|
||||
config.file.getAbsolutePath,
|
||||
outFile = Some(File(".", config.file.getName.stripSuffix(".wacc") + ".s"))
|
||||
)
|
||||
case None =>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user