fixed crash when loopvar in for loop wasn't defined

This commit is contained in:
Irmen de Jong 2020-12-28 00:28:25 +01:00
parent 6c8b18ddbd
commit 6777d952c1
4 changed files with 4 additions and 13 deletions

View File

@ -137,7 +137,7 @@ gfx2 {
} }
0, 128 -> { 0, 128 -> {
; 1 bpp mode ; 1 bpp mode
; TODO optimize this to plot 8 pixels at once while possible ; TODO optimize this to plot 8 pixels at once while possible, note: do mind the stipple setting
repeat length { repeat length {
gfx2.plot(x, y, color) gfx2.plot(x, y, color)
x++ x++
@ -147,7 +147,7 @@ gfx2 {
} }
sub vertical_line(uword x, uword y, uword height, ubyte color) { sub vertical_line(uword x, uword y, uword height, ubyte color) {
; TODO optimize this to use vera special increment mode ; TODO optimize this to use vera special increment mode, note: do mind the stipple setting
repeat height { repeat height {
plot(x, y, color) plot(x, y, color)
y++ y++

View File

@ -226,7 +226,8 @@ internal class ConstantFoldingOptimizer(private val program: Program) : AstWalke
val rangeTo = iterableRange.to as? NumericLiteralValue val rangeTo = iterableRange.to as? NumericLiteralValue
if(rangeFrom==null || rangeTo==null) return noModifications if(rangeFrom==null || rangeTo==null) return noModifications
val loopvar = forLoop.loopVar.targetVarDecl(program.namespace)!! val loopvar = forLoop.loopVar.targetVarDecl(program.namespace) ?: throw UndefinedSymbolError(forLoop.loopVar)
val stepLiteral = iterableRange.step as? NumericLiteralValue val stepLiteral = iterableRange.step as? NumericLiteralValue
when(loopvar.datatype) { when(loopvar.datatype) {
DataType.UBYTE -> { DataType.UBYTE -> {

View File

@ -2,7 +2,6 @@
TODO TODO
==== ====
- nice error msg for float as for loop var
- implement gfx2's rect, fillrect, horizontal_line and vertical_line in graphics modules as well. (and optimize bresenham line to use vert/horiz line if possible) - implement gfx2's rect, fillrect, horizontal_line and vertical_line in graphics modules as well. (and optimize bresenham line to use vert/horiz line if possible)
- detect variables that are written but never read - mark those as unused too and remove them, such as uword unused = memory("unused222", 20) - also remove the memory slab allocation - detect variables that are written but never read - mark those as unused too and remove them, such as uword unused = memory("unused222", 20) - also remove the memory slab allocation
- hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine) - hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine)

View File

@ -9,15 +9,6 @@ main {
sub start () { sub start () {
word ww
float y_f
float fl
for ww in -300 to 300 { ; TODO fix crash if ww is not defined
fl = ww as float
floats.print_f(fl)
txt.chrout(' ')
}
test_stack.test() test_stack.test()
} }