fix missing float casts

This commit is contained in:
Irmen de Jong 2020-11-09 23:57:50 +01:00
parent 225295a7d8
commit 8d0607ef58
2 changed files with 32 additions and 10 deletions

View File

@ -217,8 +217,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
if(!childIDt.isKnown)
throw AssemblyError("unknown dt")
val childDt = childIDt.typeOrElse(DataType.STRUCT)
if (value.type.equalsSize(childDt) || value.type.largerThan(childDt)) {
if (value.type!=DataType.FLOAT && (value.type.equalsSize(childDt) || value.type.largerThan(childDt))) {
// this typecast is redundant here; the rest of the code knows how to deal with the uncasted value.
// (works for integer types, not for float.)
inplaceModification(target, operator, value.expression)
return true
}

View File

@ -6,16 +6,37 @@
main {
sub start() {
float t = 0.0
repeat 10 {
float cosa = cos(t)
float sina = sin(t)
float cosb = cos(t*0.33)
float sinb = sin(t*0.33)
float cosc = cos(t*0.78)
float sinc = sin(t*0.78)
}
; byte bb = 4
; bb += sgn(bb+bb)
; txt.print_b(bb)
; txt.chrout('\n')
;
; word ww = 4
; ww += sgn(ww+ww)
; txt.print_w(ww)
; txt.chrout('\n')
float x = 4
x += abs(x+x)
floats.print_f(x)
txt.chrout('\n')
x = 4
x += sgn(x+x) ; TODO missing byte->float cast in assembly??? Also fucks up stack
x += sgn(x+x) ; TODO missing byte->float cast in assembly??? Also fucks up stack
x += sgn(x+x) ; TODO missing byte->float cast in assembly??? Also fucks up stack
floats.print_f(x)
txt.chrout('\n')
; repeat 10 {
; float cosa = cos(t)
; float sina = sin(t)
; float cosb = cos(t*0.33)
; float sinb = sin(t*0.33)
; float cosc = cos(t*0.78)
; float sinc = sin(t*0.78)
; }
testX()
}