fixed compiler recursion crash when returning certain typecasted value

This commit is contained in:
Irmen de Jong 2022-01-23 19:02:51 +01:00
parent ebf1f12e97
commit 3401cb5b4a
5 changed files with 45 additions and 17 deletions

View File

@ -609,6 +609,11 @@ $containsLabel lda #1
}
}
if(target.kind==TargetStorageKind.REGISTER) {
assignExpressionToRegister(value, target.register!!, targetDt==DataType.BYTE || targetDt==DataType.WORD)
return
}
if(targetDt==DataType.FLOAT && (target.register==RegisterOrPair.FAC1 || target.register==RegisterOrPair.FAC2)) {
when(valueDt) {
DataType.UBYTE -> {

View File

@ -1 +1 @@
7.8-dev
7.7.1

View File

@ -185,4 +185,19 @@ class TestTypecasts: FunSpec({
val statements = result.program.entrypoint.statements
statements.size shouldBe 16
}
test("no infinite typecast loop in assignment asmgen") {
val text = """
main {
sub start() {
word @shared qq = calculate(33)
}
sub calculate(ubyte row) -> word {
return (8-(row as byte))
}
}
"""
compileText(C64Target, false, text, writeAssembly = true).assertSuccess()
}
})

View File

@ -3,17 +3,7 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- BUGFIX RELEASE: Fix compiler stack overflow crash:
sub sprite_y_for_row(ubyte row) -> word {
return (8-row as byte)
}
- move vload() to cx16diskio module
- nameInAssemblyCode() should search smarter
- if char in "string" should fall back to string.find if string is longer than... 12?
also.. is "string" removed from the interned strings?
- add option to memory() to get aligned memory block (word, page aligned)
...
Need help with
^^^^^^^^^^^^^^
@ -30,6 +20,16 @@ Blocked by an official Commander-x16 r39 release
Future Things and Ideas
^^^^^^^^^^^^^^^^^^^^^^^
- why does this use stack eval on return:
sub sprite_y_for_row(ubyte row) -> word {
return (8-row as byte)
}
- move vload() to cx16diskio module
- nameInAssemblyCode() should search smarter
- if char in "string" should fall back to string.find if string is longer than... 16?
also.. is "string" removed from the interned strings?
- add option to memory() to get aligned memory block (word, page aligned)
- Typecastexpression.isSimple: make it 'expression.isSimple' rather than always false. (this breaks some things atm)
- IdentifierReference: fix equality to also include position. CallGraph can then also only store IdentifierRef instead of pair(ident, position) as keys.
- Fix: don't report as recursion if code assign address of its own subroutine to something, rather than calling it
- allow "xxx" * constexpr (where constexpr is not a number literal, now gives expression error not same type)

View File

@ -2,12 +2,20 @@
%zeropage basicsafe
main {
sub start() {
byte[3] @shared sprites_x = values
word ww
ww = calculate(6)
txt.print_w(ww)
txt.nl()
ww = calculate(8)
txt.print_w(ww)
txt.nl()
ww = calculate(10)
txt.print_w(ww)
txt.nl()
}
byte[3] values = [1,2,3]
sub calculate(ubyte row) -> word {
return 8-(row as byte)
}
}