mirror of
https://github.com/irmen/prog8.git
synced 2024-11-27 03:50:27 +00:00
fixed crash when loopvar in for loop wasn't defined
This commit is contained in:
parent
6c8b18ddbd
commit
6777d952c1
@ -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++
|
||||
|
@ -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 -> {
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user