diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index 045b38874..55d73fa77 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -137,7 +137,7 @@ gfx2 { } 0, 128 -> { ; 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 { gfx2.plot(x, y, color) x++ @@ -147,7 +147,7 @@ gfx2 { } 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 { plot(x, y, color) y++ diff --git a/compiler/src/prog8/optimizer/ConstantFoldingOptimizer.kt b/compiler/src/prog8/optimizer/ConstantFoldingOptimizer.kt index b9d16b42e..390e28f7a 100644 --- a/compiler/src/prog8/optimizer/ConstantFoldingOptimizer.kt +++ b/compiler/src/prog8/optimizer/ConstantFoldingOptimizer.kt @@ -226,7 +226,8 @@ internal class ConstantFoldingOptimizer(private val program: Program) : AstWalke val rangeTo = iterableRange.to as? NumericLiteralValue 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 when(loopvar.datatype) { DataType.UBYTE -> { diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 9c27b7022..cfb54831b 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,7 +2,6 @@ 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) - 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) diff --git a/examples/test.p8 b/examples/test.p8 index df846f24a..2f6355672 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -9,15 +9,6 @@ main { 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() }