mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-11 12:29:46 +00:00
Check if all segment exist right after parsing
This commit is contained in:
parent
46f060ecc8
commit
11825c43e1
@ -217,6 +217,8 @@ object Main {
|
|||||||
OptimizationPresets.NodeOpt0.foldLeft(unoptimized)((p, opt) => p.applyNodeOptimization(opt, options))
|
OptimizationPresets.NodeOpt0.foldLeft(unoptimized)((p, opt) => p.applyNodeOptimization(opt, options))
|
||||||
}
|
}
|
||||||
val callGraph = new StandardCallGraph(program, options.log)
|
val callGraph = new StandardCallGraph(program, options.log)
|
||||||
|
program.checkSegments(options.log, platform.codeAllocators.keySet)
|
||||||
|
options.log.assertNoErrors("Build failed due to undefined segments")
|
||||||
|
|
||||||
val env = new Environment(None, "", platform.cpuFamily, options)
|
val env = new Environment(None, "", platform.cpuFamily, options)
|
||||||
env.collectDeclarations(program, options)
|
env.collectDeclarations(program, options)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package millfork.node
|
package millfork.node
|
||||||
|
|
||||||
import millfork.CompilationOptions
|
import millfork.CompilationOptions
|
||||||
|
import millfork.error.Logger
|
||||||
import millfork.node.opt.NodeOptimization
|
import millfork.node.opt.NodeOptimization
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,6 +19,17 @@ case class Program(declarations: List[DeclarationStatement]) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def checkSegments(log: Logger, existingBanks: Set[String]): Unit = {
|
||||||
|
declarations.foreach {
|
||||||
|
case s: BankedDeclarationStatement =>
|
||||||
|
s.bank.foreach{ b =>
|
||||||
|
if (!existingBanks(b)) {
|
||||||
|
log.error(s"Cannot allocate ${s.name}: Segment $b doesn't exist")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
}
|
||||||
def applyNodeOptimization(o: NodeOptimization, options: CompilationOptions) = Program(o.optimize(declarations, options).asInstanceOf[List[DeclarationStatement]])
|
def applyNodeOptimization(o: NodeOptimization, options: CompilationOptions) = Program(o.optimize(declarations, options).asInstanceOf[List[DeclarationStatement]])
|
||||||
def +(p:Program): Program = Program(this.declarations ++ p.declarations)
|
def +(p:Program): Program = Program(this.declarations ++ p.declarations)
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,8 @@ class EmuRun(cpu: millfork.Cpu.Value, nodeOptimizations: List[NodeOptimization],
|
|||||||
tmp
|
tmp
|
||||||
}
|
}
|
||||||
val program = nodeOptimizations.foldLeft(withLibraries.applyImportantAliases)((p, opt) => p.applyNodeOptimization(opt, options))
|
val program = nodeOptimizations.foldLeft(withLibraries.applyImportantAliases)((p, opt) => p.applyNodeOptimization(opt, options))
|
||||||
|
program.checkSegments(log, platform.codeAllocators.keySet)
|
||||||
|
log.assertNoErrors("Failed")
|
||||||
val callGraph = new StandardCallGraph(program, log)
|
val callGraph = new StandardCallGraph(program, log)
|
||||||
val env = new Environment(None, "", CpuFamily.M6502, options)
|
val env = new Environment(None, "", CpuFamily.M6502, options)
|
||||||
env.collectDeclarations(program, options)
|
env.collectDeclarations(program, options)
|
||||||
|
@ -111,6 +111,8 @@ class EmuZ80Run(cpu: millfork.Cpu.Value, nodeOptimizations: List[NodeOptimizatio
|
|||||||
tmp
|
tmp
|
||||||
}
|
}
|
||||||
val program = nodeOptimizations.foldLeft(withLibraries.applyImportantAliases)((p, opt) => p.applyNodeOptimization(opt, options))
|
val program = nodeOptimizations.foldLeft(withLibraries.applyImportantAliases)((p, opt) => p.applyNodeOptimization(opt, options))
|
||||||
|
program.checkSegments(log, platform.codeAllocators.keySet)
|
||||||
|
log.assertNoErrors("Failed")
|
||||||
val callGraph = new StandardCallGraph(program, log)
|
val callGraph = new StandardCallGraph(program, log)
|
||||||
val env = new Environment(None, "", CpuFamily.I80, options)
|
val env = new Environment(None, "", CpuFamily.I80, options)
|
||||||
env.collectDeclarations(program, options)
|
env.collectDeclarations(program, options)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user