mirror of
https://github.com/KarolS/millfork.git
synced 2024-12-24 15:29:23 +00:00
Fix various compiler crashes
This commit is contained in:
parent
778d04ce21
commit
dcbf54872b
@ -268,6 +268,18 @@ object AbstractExpressionCompiler {
|
||||
case 3 => env.get[Type]("int24")
|
||||
case 4 => env.get[Type]("long")
|
||||
}
|
||||
case ConstantArrayElementExpression(constant) =>
|
||||
(constant.quickSimplify match {
|
||||
case SubbyteConstant(_, _) => false -> 1
|
||||
case NumericConstant(v, s) => (v < 0) -> s
|
||||
case CompoundConstant(MathOperator.Minus, NumericConstant(_, ls), NumericConstant(_, rs)) => true -> (ls max rs)
|
||||
}) match {
|
||||
case (false, 1) => b
|
||||
case (true, 1) => env.get[Type]("sbyte")
|
||||
case (_, 2) => b
|
||||
case (_, 3) => env.get[Type]("int24")
|
||||
case (_, 4) => env.get[Type]("long")
|
||||
}
|
||||
case GeneratedConstantExpression(_, typ) => typ
|
||||
case TextLiteralExpression(_) => env.get[Type]("pointer")
|
||||
case VariableExpression(name) =>
|
||||
|
@ -137,6 +137,9 @@ object Z80Comparisons {
|
||||
import ZOpcode._
|
||||
val calculateLeft = Z80ExpressionCompiler.compileToHL(ctx, l)
|
||||
val calculateRight = Z80ExpressionCompiler.compileToHL(ctx, r)
|
||||
if (branches == NoBranching) {
|
||||
return calculateLeft ++ calculateRight
|
||||
}
|
||||
val fastEqualityComparison: Option[List[ZLine]] = (calculateLeft, calculateRight) match {
|
||||
case (List(ZLine0(LD_16, TwoRegisters(HL, IMM_16), NumericConstant(0, _))), _) =>
|
||||
Some(calculateRight ++ List(ZLine.ld8(A, H), ZLine.register(OR, L)))
|
||||
|
@ -156,6 +156,7 @@ abstract class AbstractAssembler[T <: AbstractCode](private val program: Program
|
||||
case MathOperator.Shl => l << r
|
||||
case MathOperator.Shl9 => (l << r) & 0x1ff
|
||||
case MathOperator.Shr => l >>> r
|
||||
case MathOperator.Shr9 => ((l & 0x1ff) >>> r) & 0xff
|
||||
case MathOperator.DecimalPlus => asDecimal(l, r, _ + _)
|
||||
case MathOperator.DecimalPlus9 => asDecimal(l, r, _ + _) & 0x1ff
|
||||
case MathOperator.DecimalMinus => asDecimal(l, r, _ - _)
|
||||
|
Loading…
Reference in New Issue
Block a user