fix codegen crash on certain nested typecast

This commit is contained in:
Irmen de Jong 2022-07-13 22:24:31 +02:00
parent 35af53828a
commit 2d600da8b6
3 changed files with 6 additions and 10 deletions

View File

@ -738,10 +738,10 @@ internal class AssignmentAsmGen(private val program: Program,
return
}
if(origTypeCastExpression.type == DataType.UBYTE) {
if(valueDt in WordDatatypes && origTypeCastExpression.type == DataType.UBYTE) {
val parentTc = origTypeCastExpression.parent as? TypecastExpression
if(parentTc!=null && parentTc.type==DataType.UWORD) {
// typecast something to ubyte and directly back to uword
// typecast a word value to ubyte and directly back to uword
// generate code for lsb(value) here instead of the ubyte typecast
return assignCastViaLsbFunc(value, target)
}

View File

@ -701,6 +701,7 @@ main {
fl = bb as float
bb = fl as byte
uw = fl as uword
uw = 8888 + (bb as ubyte)
}
}
"""

View File

@ -4,14 +4,9 @@
main {
sub start() {
repeat {
uword keys = cx16.kbdbuf_peek2()
txt.print_uwhex(keys, true)
if msb(keys) {
c64.GETIN()
}
txt.nl()
}
byte tx = 1
uword @shared zzzz= $2000 + (tx as ubyte)
txt.print_uwhex(zzzz,true)
}
}