diff --git a/compiler/res/prog8lib/cx16/gfx2.p8 b/compiler/res/prog8lib/cx16/gfx2.p8 index b500edfea..a1ba679c0 100644 --- a/compiler/res/prog8lib/cx16/gfx2.p8 +++ b/compiler/res/prog8lib/cx16/gfx2.p8 @@ -627,7 +627,7 @@ gfx2 { ; Non-recursive scanline flood fill. ; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm ; with the fixes applied to the seedfill_4 routine as mentioned in the comments. - const ubyte MAXDEPTH = 48 + const ubyte MAXDEPTH = 64 word @zp xx = x as word word @zp yy = y as word word[MAXDEPTH] @split @shared stack_xl diff --git a/compiler/res/prog8lib/cx16/monogfx.p8 b/compiler/res/prog8lib/cx16/monogfx.p8 index e1e6c3069..ce1aa493e 100644 --- a/compiler/res/prog8lib/cx16/monogfx.p8 +++ b/compiler/res/prog8lib/cx16/monogfx.p8 @@ -638,7 +638,7 @@ _done ; Non-recursive scanline flood fill. ; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm ; with the fixes applied to the seedfill_4 routine as mentioned in the comments. - const ubyte MAXDEPTH = 48 + const ubyte MAXDEPTH = 64 word @zp xx = x as word word @zp yy = y as word word[MAXDEPTH] @split @shared stack_xl diff --git a/compiler/res/prog8lib/virtual/monogfx.p8 b/compiler/res/prog8lib/virtual/monogfx.p8 index b1f7cbd40..74d8fe972 100644 --- a/compiler/res/prog8lib/virtual/monogfx.p8 +++ b/compiler/res/prog8lib/virtual/monogfx.p8 @@ -373,7 +373,7 @@ monogfx { ; Non-recursive scanline flood fill. ; based loosely on code found here https://www.codeproject.com/Articles/6017/QuickFill-An-efficient-flood-fill-algorithm ; with the fixes applied to the seedfill_4 routine as mentioned in the comments. - const ubyte MAXDEPTH = 48 + const ubyte MAXDEPTH = 64 word @zp xx = x as word word @zp yy = y as word word[MAXDEPTH] @split @shared stack_xl diff --git a/compiler/src/prog8/compiler/astprocessing/VerifyFunctionArgTypes.kt b/compiler/src/prog8/compiler/astprocessing/VerifyFunctionArgTypes.kt index 4ef9878e5..eca8749b4 100644 --- a/compiler/src/prog8/compiler/astprocessing/VerifyFunctionArgTypes.kt +++ b/compiler/src/prog8/compiler/astprocessing/VerifyFunctionArgTypes.kt @@ -19,8 +19,24 @@ internal class VerifyFunctionArgTypes(val program: Program, val errors: IErrorRe errors.err("memory block '${slab.name}' already exists with a different size and/or alignment at ${other.position}", slab.position) } } + + // remove unused strings from interned strings block + val internedBlock = program.allBlocks.singleOrNull { it.name== internedStringsModuleName } + internedBlock?.statements?.withIndex()?.reversed()?.forEach { (index, st) -> + if(st is VarDecl && st.scopedName !in allStringRefs) { + internedBlock.statements.removeAt(index) + } + } } + override fun visit(identifier: IdentifierReference) { + if(identifier.wasStringLiteral(program)) { + allStringRefs.add(identifier.nameInSource) + } + } + + private val allStringRefs = mutableListOf>() + private class Slab(val name: String, val size: Int, val align: Int, val position: Position) private val memorySlabs = mutableListOf() diff --git a/docs/source/todo.rst b/docs/source/todo.rst index c54ca92f4..a4f0f7419 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,7 +1,7 @@ + TODO ==== -- remove unused interned strings in the resulting code (for example from removed if/else blocks) - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... - [on branch: ir-less-branch-opcodes] IR: reduce the number of branch instructions such as BEQ, BEQR, etc (gradually), replace with CMP(I) + status branch instruction - IR: reduce amount of CMP/CMPI after instructions that set the status bits correctly (LOADs? INC? Bitwise operations, etc), but only after setting the status bits is verified! diff --git a/examples/test.p8 b/examples/test.p8 index c221e254c..63d46a43c 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,21 +1,12 @@ %import textio -%import string %zeropage basicsafe main { sub start() { - str name = "irmen????????????" - name[5] = 0 - - txt.print(name) - txt.nl() - ubyte length = string.append(name, ".prg") - - txt.print_ub(length) - txt.chrout('[') - for cx16.r0L in 0 to length-1 { - txt.chrout(name[cx16.r0L]) + if true { + txt.print("true") + } else { + txt.print("false") } - txt.chrout(']') } } diff --git a/gradle.properties b/gradle.properties index a3f713e95..7f4722d3f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ org.gradle.daemon=true kotlin.code.style=official javaVersion=11 kotlinVersion=1.9.20 -version=9.6-SNAPSHOT +version=9.6 diff --git a/parser/antlr/Prog8ANTLR.g4 b/parser/antlr/Prog8ANTLR.g4 index 1825528b9..b26e01594 100644 --- a/parser/antlr/Prog8ANTLR.g4 +++ b/parser/antlr/Prog8ANTLR.g4 @@ -188,8 +188,7 @@ expression : arrayindexed: scoped_identifier arrayindex - // TODO to allow chained array indexing: | arrayindexed arrayindex - // TODO or even to allow array indexing on any uword address value: | expression arrayindex + // TODO to allow chained/multidimensional array indexing: | arrayindexed arrayindex ;