mirror of
https://github.com/KarolS/millfork.git
synced 2025-01-11 12:29:46 +00:00
Use one statement preprocessor per function.
This commit is contained in:
parent
bf47473162
commit
7cf78ca2bd
@ -12,11 +12,9 @@ import millfork.node._
|
||||
abstract class AbstractStatementCompiler[T <: AbstractCode] {
|
||||
|
||||
def compile(ctx: CompilationContext, statements: List[ExecutableStatement]): List[T] = {
|
||||
getStatementPreprocessor(ctx, statements)().flatMap(s => compile(ctx, s))
|
||||
statements.flatMap(s => compile(ctx, s))
|
||||
}
|
||||
|
||||
def getStatementPreprocessor(ctx: CompilationContext, statements: List[ExecutableStatement]): AbstractStatementPreprocessor
|
||||
|
||||
def compile(ctx: CompilationContext, statement: ExecutableStatement): List[T]
|
||||
|
||||
def labelChunk(labelName: String): List[T]
|
||||
|
@ -15,7 +15,7 @@ object MosCompiler extends AbstractCompiler[AssemblyLine] {
|
||||
|
||||
override def compile(ctx: CompilationContext): List[AssemblyLine] = {
|
||||
ctx.env.nameCheck(ctx.function.code)
|
||||
val chunk = MosStatementCompiler.compile(ctx, ctx.function.code)
|
||||
val chunk = MosStatementCompiler.compile(ctx, new MosStatementPreprocessor(ctx, ctx.function.code)())
|
||||
val zpRegisterSize = ctx.options.zpRegisterSize
|
||||
|
||||
val storeParamsFromRegisters = ctx.function.params match {
|
||||
|
@ -307,7 +307,4 @@ object MosStatementCompiler extends AbstractStatementCompiler[AssemblyLine] {
|
||||
}
|
||||
AssemblyLine.implied(TSX) :: (List.fill(m.stackVariablesSize)(AssemblyLine.implied(INX)) :+ AssemblyLine.implied(TXS)) // this TXS is fine, it won't appear in 65816 code
|
||||
}
|
||||
|
||||
override def getStatementPreprocessor(ctx: CompilationContext, statements: List[ExecutableStatement]): AbstractStatementPreprocessor =
|
||||
new MosStatementPreprocessor(ctx, statements)
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ object Z80Compiler extends AbstractCompiler[ZLine] {
|
||||
|
||||
override def compile(ctx: CompilationContext): List[ZLine] = {
|
||||
ctx.env.nameCheck(ctx.function.code)
|
||||
val chunk = Z80StatementCompiler.compile(ctx, ctx.function.code)
|
||||
val chunk = Z80StatementCompiler.compile(ctx, new Z80StatementPreprocessor(ctx, ctx.function.code)())
|
||||
val label = ZLine.label(Label(ctx.function.name)).copy(elidable = false)
|
||||
val storeParamsFromRegisters = ctx.function.params match {
|
||||
case NormalParamSignature(List(param)) if param.typ.size == 1 =>
|
||||
|
@ -265,7 +265,4 @@ object Z80StatementCompiler extends AbstractStatementCompiler[ZLine] {
|
||||
|
||||
override def compileExpressionForBranching(ctx: CompilationContext, expr: Expression, branching: BranchSpec): List[ZLine] =
|
||||
Z80ExpressionCompiler.compile(ctx, expr, ZExpressionTarget.NOTHING, branching)
|
||||
|
||||
override def getStatementPreprocessor(ctx: CompilationContext, statements: List[ExecutableStatement]): AbstractStatementPreprocessor =
|
||||
new Z80StatementPreprocessor(ctx, statements)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user