mirror of
https://github.com/irmen/prog8.git
synced 2024-12-23 09:32:43 +00:00
tweak ifelse > and <= order
This commit is contained in:
parent
a282b17286
commit
c48012c385
@ -446,8 +446,19 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
ifPart.add(assignTrue)
|
||||
elsePart.add(assignFalse)
|
||||
val ifelse = PtIfElse(assign.position)
|
||||
val exprClone = PtBinaryExpression(expr.operator, expr.type, expr.position)
|
||||
expr.children.forEach { exprClone.children.add(it) } // doesn't seem to need a deep clone
|
||||
val exprClone: PtBinaryExpression
|
||||
if(!asmgen.isTargetCpu(CpuType.VIRTUAL)
|
||||
&& (expr.operator==">" || expr.operator=="<=")
|
||||
&& expr.right.type in WordDatatypes) {
|
||||
// word X>Y -> X<Y, X<=Y -> Y>=X , easier to do in 6502 (codegen also expects these to no longe exist!)
|
||||
exprClone = PtBinaryExpression(if(expr.operator==">") "<" else ">=", expr.type, expr.position)
|
||||
exprClone.children.add(expr.children[1]) // doesn't seem to need a deep clone
|
||||
exprClone.children.add(expr.children[0]) // doesn't seem to need a deep clone
|
||||
} else {
|
||||
exprClone = PtBinaryExpression(expr.operator, expr.type, expr.position)
|
||||
exprClone.children.add(expr.children[0]) // doesn't seem to need a deep clone
|
||||
exprClone.children.add(expr.children[1]) // doesn't seem to need a deep clone
|
||||
}
|
||||
ifelse.add(exprClone)
|
||||
ifelse.add(ifPart)
|
||||
ifelse.add(elsePart)
|
||||
@ -511,8 +522,19 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
}
|
||||
ifPart.add(assignTrue)
|
||||
val ifelse = PtIfElse(assign.position)
|
||||
val exprClone = PtBinaryExpression(expr.operator, expr.type, expr.position)
|
||||
expr.children.forEach { exprClone.children.add(it) } // doesn't seem to need a deep clone
|
||||
val exprClone: PtBinaryExpression
|
||||
if(!asmgen.isTargetCpu(CpuType.VIRTUAL)
|
||||
&& (expr.operator==">" || expr.operator=="<=")
|
||||
&& expr.right.type in WordDatatypes) {
|
||||
// word X>Y -> X<Y, X<=Y -> Y>=X , easier to do in 6502 (codegen also expects these to no longe exist!)
|
||||
exprClone = PtBinaryExpression(if(expr.operator==">") "<" else ">=", expr.type, expr.position)
|
||||
exprClone.children.add(expr.children[1]) // doesn't seem to need a deep clone
|
||||
exprClone.children.add(expr.children[0]) // doesn't seem to need a deep clone
|
||||
} else {
|
||||
exprClone = PtBinaryExpression(expr.operator, expr.type, expr.position)
|
||||
exprClone.children.add(expr.children[0]) // doesn't seem to need a deep clone
|
||||
exprClone.children.add(expr.children[1]) // doesn't seem to need a deep clone
|
||||
}
|
||||
ifelse.add(exprClone)
|
||||
ifelse.add(ifPart)
|
||||
ifelse.add(PtNodeGroup())
|
||||
|
@ -2,6 +2,9 @@ TODO
|
||||
====
|
||||
|
||||
larger programs:
|
||||
dirlist
|
||||
bobs
|
||||
cobramk3-gfx
|
||||
automatons
|
||||
mandelbrot (quite a bit larger)
|
||||
mandelbrot-gfx
|
||||
|
Loading…
Reference in New Issue
Block a user