mirror of
https://github.com/irmen/prog8.git
synced 2026-04-19 04:17:08 +00:00
'-vm' option now also reads .p8ir files
This commit is contained in:
@@ -8,10 +8,10 @@ import java.io.BufferedWriter
|
||||
import kotlin.io.path.bufferedWriter
|
||||
import kotlin.io.path.div
|
||||
|
||||
internal class VmAssemblyProgram(override val name: String, val irProgram: IRProgram): IAssemblyProgram {
|
||||
internal class VmAssemblyProgram(override val name: String, private val irProgram: IRProgram): IAssemblyProgram {
|
||||
|
||||
override fun assemble(options: CompilationOptions): Boolean {
|
||||
val outfile = options.outputDir / ("$name.p8virt")
|
||||
override fun assemble(dummyOptions: CompilationOptions): Boolean {
|
||||
val outfile = irProgram.options.outputDir / ("$name.p8virt")
|
||||
println("write code to $outfile")
|
||||
|
||||
// at last, allocate the variables in memory.
|
||||
@@ -24,7 +24,7 @@ internal class VmAssemblyProgram(override val name: String, val irProgram: IRPro
|
||||
|
||||
out.write("------PROGRAM------\n")
|
||||
|
||||
if(!options.dontReinitGlobals) {
|
||||
if(!irProgram.options.dontReinitGlobals) {
|
||||
out.write("; global var inits\n")
|
||||
irProgram.globalInits.forEach { out.writeLine(it) }
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import prog8.code.core.IErrorReporter
|
||||
import prog8.codegen.intermediate.IRCodeGen
|
||||
import prog8.intermediate.IRFileReader
|
||||
import prog8.intermediate.IRFileWriter
|
||||
import java.nio.file.Path
|
||||
|
||||
class VmCodeGen(private val program: PtProgram,
|
||||
private val symbolTable: SymbolTable,
|
||||
@@ -26,4 +27,11 @@ class VmCodeGen(private val program: PtProgram,
|
||||
val irProgram2 = IRFileReader(options.outputDir, irProgram.name).readFile()
|
||||
return VmAssemblyProgram(irProgram2.name, irProgram2)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun compileIR(listingFilename: String): IAssemblyProgram {
|
||||
val irProgram = IRFileReader(Path.of(""), listingFilename).readFile()
|
||||
return VmAssemblyProgram(irProgram.name, irProgram)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user