mirror of
https://github.com/KarolS/millfork.git
synced 2024-12-24 15:29:23 +00:00
Fix optimized struct assignments
This commit is contained in:
parent
fe25978d14
commit
a3a168b90b
@ -191,12 +191,17 @@ object MosStatementCompiler extends AbstractStatementCompiler[AssemblyLine] {
|
||||
case Assignment(dest, source) =>
|
||||
MosExpressionCompiler.compileAssignment(ctx, source, dest) -> Nil
|
||||
case ExpressionStatement(e@FunctionCallExpression(name, params)) =>
|
||||
env.lookupFunction(name, params.map(p => MosExpressionCompiler.getExpressionType(ctx, p) -> p)) match {
|
||||
case Some(i: MacroFunction) =>
|
||||
val (paramPreparation, inlinedStatements) = MosMacroExpander.inlineFunction(ctx, i, params, e.position)
|
||||
paramPreparation ++ compile(ctx.withInlinedEnv(i.environment, ctx.nextLabel("en")), inlinedStatements)._1 -> Nil
|
||||
case _ =>
|
||||
MosExpressionCompiler.compile(ctx, e, None, NoBranching) -> Nil
|
||||
env.maybeGet[Type](name) match {
|
||||
case Some(_) =>
|
||||
params.flatMap(p => MosExpressionCompiler.compile(ctx, p, None, NoBranching))-> Nil
|
||||
case None =>
|
||||
env.lookupFunction(name, params.map(p => MosExpressionCompiler.getExpressionType(ctx, p) -> p)) match {
|
||||
case Some(i: MacroFunction) =>
|
||||
val (paramPreparation, inlinedStatements) = MosMacroExpander.inlineFunction(ctx, i, params, e.position)
|
||||
paramPreparation ++ compile(ctx.withInlinedEnv(i.environment, ctx.nextLabel("en")), inlinedStatements)._1 -> Nil
|
||||
case _ =>
|
||||
MosExpressionCompiler.compile(ctx, e, None, NoBranching) -> Nil
|
||||
}
|
||||
}
|
||||
case ExpressionStatement(e) =>
|
||||
e match {
|
||||
|
Loading…
Reference in New Issue
Block a user