mirror of
https://github.com/irmen/prog8.git
synced 2024-09-29 08:57:51 +00:00
fix compiler stackoverflow crash on certain typecasted expressions containing floats.
This commit is contained in:
parent
7780d94de1
commit
b909facfe5
@ -442,10 +442,36 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(targetDt==DataType.FLOAT && (target.register==RegisterOrPair.FAC1 || target.register==RegisterOrPair.FAC2)) {
|
||||||
|
when(valueDt) {
|
||||||
|
DataType.UBYTE -> {
|
||||||
|
assignExpressionToRegister(value, RegisterOrPair.Y, false)
|
||||||
|
asmgen.out(" jsr floats.FREADUY")
|
||||||
|
}
|
||||||
|
DataType.BYTE -> {
|
||||||
|
assignExpressionToRegister(value, RegisterOrPair.A, true)
|
||||||
|
asmgen.out(" jsr floats.FREADSA")
|
||||||
|
}
|
||||||
|
DataType.UWORD -> {
|
||||||
|
assignExpressionToRegister(value, RegisterOrPair.AY, false)
|
||||||
|
asmgen.out(" jsr floats.GIVUAYFAY")
|
||||||
|
}
|
||||||
|
DataType.WORD -> {
|
||||||
|
assignExpressionToRegister(value, RegisterOrPair.AY, true)
|
||||||
|
asmgen.out(" jsr floats.GIVAYFAY")
|
||||||
|
}
|
||||||
|
else -> throw AssemblyError("invalid dt")
|
||||||
|
}
|
||||||
|
if(target.register==RegisterOrPair.FAC2) {
|
||||||
|
asmgen.out(" jsr floats.MOVEF")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// No more special optmized cases yet. Do the rest via more complex evaluation
|
// No more special optmized cases yet. Do the rest via more complex evaluation
|
||||||
// note: cannot use assignTypeCastedValue because that is ourselves :P
|
// note: cannot use assignTypeCastedValue because that is ourselves :P
|
||||||
|
// NOTE: THIS MAY TURN INTO A STACK OVERFLOW ERROR IF IT CAN'T SIMPLIFY THE TYPECAST..... :-/
|
||||||
asmgen.assignExpressionTo(origTypeCastExpression, target)
|
asmgen.assignExpressionTo(origTypeCastExpression, target)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun assignCastViaLsbFunc(value: Expression, target: AsmAssignTarget) {
|
private fun assignCastViaLsbFunc(value: Expression, target: AsmAssignTarget) {
|
||||||
val lsb = FunctionCall(IdentifierReference(listOf("lsb"), value.position), mutableListOf(value), value.position)
|
val lsb = FunctionCall(IdentifierReference(listOf("lsb"), value.position), mutableListOf(value), value.position)
|
||||||
|
@ -204,7 +204,6 @@ class TestOptimization: FunSpec({
|
|||||||
"""
|
"""
|
||||||
val result1 = compileText(C64Target, optimize=false, src, writeAssembly = false).assertSuccess()
|
val result1 = compileText(C64Target, optimize=false, src, writeAssembly = false).assertSuccess()
|
||||||
|
|
||||||
// yy = (dy*(pixely as float) )
|
|
||||||
val assignYY = result1.program.entrypoint.statements.last() as Assignment
|
val assignYY = result1.program.entrypoint.statements.last() as Assignment
|
||||||
assignYY.isAugmentable shouldBe true
|
assignYY.isAugmentable shouldBe true
|
||||||
assignYY.target.identifier!!.nameInSource shouldBe listOf("ff")
|
assignYY.target.identifier!!.nameInSource shouldBe listOf("ff")
|
||||||
|
@ -3,8 +3,6 @@ TODO
|
|||||||
|
|
||||||
For next compiler release (7.3)
|
For next compiler release (7.3)
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
- fix float crash in mandelbrot-gfx-colors.p8 (unittest is being written)
|
|
||||||
|
|
||||||
- add cosr8, sinr8, cosr16 and sinr16 that take a degree 0..179 (= 0..359 in 2 degree steps)
|
- add cosr8, sinr8, cosr16 and sinr16 that take a degree 0..179 (= 0..359 in 2 degree steps)
|
||||||
to more easily scale halves/quarters etc of a circle than possible with the ones that take 0..255 'degrees'.
|
to more easily scale halves/quarters etc of a circle than possible with the ones that take 0..255 'degrees'.
|
||||||
|
|
||||||
|
@ -1,17 +1,42 @@
|
|||||||
%import textio
|
%import textio
|
||||||
; %import floats
|
%import floats
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
ubyte unused ; TODO FIX : why is this not removed as an unused variable?
|
ubyte ub=99
|
||||||
ubyte @shared unused2
|
byte bb=-99
|
||||||
|
uword uw=9999
|
||||||
|
word ww=-9999
|
||||||
|
float ff
|
||||||
|
ff = 1.234
|
||||||
|
ff += (ub as float) ; operator doesn't matter
|
||||||
|
floats.print_f(ff)
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
ubyte bb
|
ff = 1.234
|
||||||
uword ww
|
ff += (bb as float) ; operator doesn't matter
|
||||||
ww = not bb or not ww ; TODO WHY DOES THIS USE STACK EVAL
|
floats.print_f(ff)
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
|
ff = 1.234
|
||||||
|
ff += (uw as float) ; operator doesn't matter
|
||||||
|
floats.print_f(ff)
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
|
ff = 1.234
|
||||||
|
ff += (ww as float) ; operator doesn't matter
|
||||||
|
floats.print_f(ff)
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
|
; ubyte unused ; TODO FIX : why is this not removed as an unused variable?
|
||||||
|
; ubyte @shared unused2
|
||||||
|
;
|
||||||
|
; ubyte bb
|
||||||
|
; uword ww
|
||||||
|
; ww = not bb or not ww ; TODO WHY DOES THIS USE STACK EVAL
|
||||||
|
|
||||||
; if not iteration_in_progress or not num_bytes
|
; if not iteration_in_progress or not num_bytes
|
||||||
; return
|
; return
|
||||||
@ -36,14 +61,14 @@ main {
|
|||||||
; txt.print("xx is zero\n")
|
; txt.print("xx is zero\n")
|
||||||
; }
|
; }
|
||||||
|
|
||||||
ubyte yy=$30
|
; ubyte yy=$30
|
||||||
; ubyte zz=9
|
; ubyte zz=9
|
||||||
; sys.memset(xx+200, yy*2, ~yy)
|
; sys.memset(xx+200, yy*2, ~yy)
|
||||||
;
|
;
|
||||||
|
;
|
||||||
if yy & %10000 {
|
; if yy & %10000 {
|
||||||
yy++
|
; yy++
|
||||||
}
|
; }
|
||||||
;
|
;
|
||||||
; @($c030) = 10
|
; @($c030) = 10
|
||||||
; @(~xx) *= 2
|
; @(~xx) *= 2
|
||||||
|
Loading…
Reference in New Issue
Block a user