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