1
0
mirror of https://github.com/KarolS/millfork.git synced 2025-02-13 01:30:27 +00:00

Fixed miscompiled loops

This commit is contained in:
Karol Stasiak 2018-03-05 18:21:20 +01:00
parent 05e147b880
commit 56e4b1fb70

View File

@ -273,7 +273,7 @@ object StatementCompiler {
val condType = ExpressionCompiler.getExpressionType(ctx, condition)
val bodyBlock = compile(ctx.addLabels(labels, Label(end), Label(inc)), bodyPart)
val incrementBlock = compile(ctx.addLabels(labels, Label(end), Label(inc)), incrementPart)
val largeBodyBlock = bodyBlock.map(_.sizeInBytes).sum > 100
val largeBodyBlock = bodyBlock.map(_.sizeInBytes).sum + incrementBlock.map(_.sizeInBytes).sum > 100
condType match {
case ConstantBooleanType(_, true) =>
List(labelChunk(start), bodyBlock, labelChunk(inc), incrementBlock, jmpChunk(start), labelChunk(end)).flatten
@ -305,7 +305,7 @@ object StatementCompiler {
val condType = ExpressionCompiler.getExpressionType(ctx, condition)
val bodyBlock = compile(ctx.addLabels(labels, Label(end), Label(inc)), bodyPart)
val incrementBlock = compile(ctx.addLabels(labels, Label(end), Label(inc)), incrementPart)
val largeBodyBlock = bodyBlock.map(_.sizeInBytes).sum > 100
val largeBodyBlock = bodyBlock.map(_.sizeInBytes).sum + incrementBlock.map(_.sizeInBytes).sum > 100
condType match {
case ConstantBooleanType(_, true) =>
val conditionBlock = ExpressionCompiler.compile(ctx, condition, someRegisterA, NoBranching)