1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-05-31 18:41:30 +00:00

Don't compile the same functions twice

This commit is contained in:
Karol Stasiak 2017-12-20 01:07:38 +01:00
parent 4d8de94c8a
commit e0f9544733

View File

@ -143,6 +143,13 @@ class Assembler(private val rootEnv: Environment) {
val assembly = mutable.ArrayBuffer[String]()
val compiledFunctions = mutable.Map[String, List[AssemblyLine]]()
callGraph.recommendedCompilationOrder.foreach{ f =>
env.maybeGet[NormalFunction](f).foreach( function =>
compiledFunctions(f) = compileFunction(function, optimizations, options)
)
}
env.allPreallocatables.foreach {
case InitializedArray(name, Some(NumericConstant(address, _)), items) =>
var index = address.toInt
@ -159,17 +166,10 @@ class Assembler(private val rootEnv: Environment) {
case f: NormalFunction if f.address.isDefined =>
var index = f.address.get.asInstanceOf[NumericConstant].value.toInt
labelMap(f.name) = index
val code = compileFunction(f, optimizations, options)
index = outputFunction(code, index, assembly, options)
index = outputFunction(compiledFunctions(f.name), index, assembly, options)
case _ =>
}
val compiledFunctions = mutable.Map[String, List[AssemblyLine]]()
callGraph.recommendedCompilationOrder.foreach{ f =>
env.maybeGet[NormalFunction](f).foreach( function =>
compiledFunctions(f) = compileFunction(function, optimizations, options)
)
}
var index = platform.org
env.allPreallocatables.foreach {
case f: NormalFunction if f.address.isEmpty && f.name == "main" =>