mirror of
https://github.com/irmen/prog8.git
synced 2026-04-20 11:17:01 +00:00
vm: support noreinit option
This commit is contained in:
@@ -27,8 +27,10 @@ internal class AssemblyProgram(override val name: String,
|
||||
}
|
||||
out.write("------PROGRAM------\n")
|
||||
|
||||
out.write("; global var inits\n")
|
||||
globalInits.forEach { out.writeLine(it) }
|
||||
if(!options.dontReinitGlobals) {
|
||||
out.write("; global var inits\n")
|
||||
globalInits.forEach { out.writeLine(it) }
|
||||
}
|
||||
|
||||
out.write("; actual program code\n")
|
||||
blocks.asSequence().flatMap { it.lines }.forEach { line->out.writeLine(line) }
|
||||
|
||||
@@ -35,19 +35,16 @@ class CodeGen(internal val program: PtProgram,
|
||||
private val builtinFuncGen = BuiltinFuncGen(this, expressionEval)
|
||||
internal val vmRegisters = VmRegisterPool()
|
||||
|
||||
init {
|
||||
if(options.dontReinitGlobals)
|
||||
TODO("support no globals re-init in vm")
|
||||
}
|
||||
|
||||
override fun compileToAssembly(): IAssemblyProgram? {
|
||||
val vmprog = AssemblyProgram(program.name, allocations)
|
||||
|
||||
// collect global variables initializers
|
||||
program.allBlocks().forEach {
|
||||
val code = VmCodeChunk()
|
||||
it.children.filterIsInstance<PtAssignment>().forEach { assign -> code += translate(assign) }
|
||||
vmprog.addGlobalInits(code)
|
||||
if(!options.dontReinitGlobals) {
|
||||
// collect global variables initializers
|
||||
program.allBlocks().forEach {
|
||||
val code = VmCodeChunk()
|
||||
it.children.filterIsInstance<PtAssignment>().forEach { assign -> code += translate(assign) }
|
||||
vmprog.addGlobalInits(code)
|
||||
}
|
||||
}
|
||||
|
||||
for (block in program.allBlocks()) {
|
||||
|
||||
Reference in New Issue
Block a user