tweak & fix if expression with word condition

This commit is contained in:
Irmen de Jong
2024-11-02 18:40:10 +01:00
parent 3b798097b9
commit 7cfb33a448
7 changed files with 258 additions and 113 deletions

View File

@@ -91,6 +91,10 @@ internal class ExpressionGen(private val codeGen: IRCodeGen) {
}
private fun translate(ifExpr: PtIfExpression): ExpressionCodeResult {
if((ifExpr.condition as? PtPrefix)?.operator=="not")
throw AssemblyError("not prefix in ifexpression should have been replaced by swapped values")
// TODO don't store condition as expression result but just use the flags, like a normal PtIfElse translation does
val condTr = translateExpression(ifExpr.condition)
val trueTr = translateExpression(ifExpr.truevalue)

View File

@@ -1330,6 +1330,9 @@ class IRCodeGen(
}
private fun translateIfElse(ifElse: PtIfElse): IRCodeChunks {
if((ifElse.condition as? PtPrefix)?.operator=="not")
throw AssemblyError("not prefix in ifelse should have been replaced by swapped if-else blocks")
val condition = ifElse.condition as? PtBinaryExpression
if(condition==null || condition.left.type != DataType.FLOAT) {
return ifWithElse_IntegerCond(ifElse)