diff --git a/compilerAst/src/prog8/ast/AstToSourceTextConverter.kt b/compilerAst/src/prog8/ast/AstToSourceTextConverter.kt index d36a77a31..34a61b9ec 100644 --- a/compilerAst/src/prog8/ast/AstToSourceTextConverter.kt +++ b/compilerAst/src/prog8/ast/AstToSourceTextConverter.kt @@ -101,10 +101,7 @@ class AstToSourceTextConverter(val output: (text: String) -> Unit, val program: } override fun visit(decl: VarDecl) { - - // if the vardecl is a parameter of a subroutine, don't output it again - val paramNames = decl.definingSubroutine?.parameters?.map { it.name } - if(paramNames!=null && decl.name in paramNames) + if(decl.origin==VarDeclOrigin.SUBROUTINEPARAM) return when(decl.type) { @@ -191,7 +188,7 @@ class AstToSourceTextConverter(val output: (text: String) -> Unit, val program: else { outputln("{ ") scopelevel++ - outputStatements(subroutine.statements) + outputStatements(subroutine.statements.filter { it !is VarDecl || it.origin!=VarDeclOrigin.SUBROUTINEPARAM}) scopelevel-- outputi("}") } diff --git a/compilerInterfaces/src/prog8/compilerinterface/Zeropage.kt b/compilerInterfaces/src/prog8/compilerinterface/Zeropage.kt index 7c9453a46..576013b3f 100644 --- a/compilerInterfaces/src/prog8/compilerinterface/Zeropage.kt +++ b/compilerInterfaces/src/prog8/compilerinterface/Zeropage.kt @@ -117,7 +117,7 @@ abstract class Zeropage(protected val options: CompilationOptions) { allocations[address] = name to datatype if(name.isNotEmpty()) { allocatedVariables[name] = when(datatype) { - in NumericDatatypes -> ZpAllocation(address, datatype, size, originalScope, null, null) // numerical variables in zeropage never have an initial value here TODO why not? + in NumericDatatypes -> ZpAllocation(address, datatype, size, originalScope, null, null) // numerical variables in zeropage never have an initial value here because they are set in separate initializer assignments DataType.STR -> ZpAllocation(address, datatype, size, originalScope, initValue as? StringLiteral, null) in ArrayDatatypes -> ZpAllocation(address, datatype, size, originalScope, null, initValue as? ArrayLiteral) else -> throw AssemblyError("invalid dt") diff --git a/docs/source/todo.rst b/docs/source/todo.rst index f62d3358d..b161ac1d7 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,8 +3,7 @@ TODO For next release ^^^^^^^^^^^^^^^^ -- answer the question in zeropage.kt makeAllocation(): numerical variables in zeropage never have an initial value here TODO why not? -- (for 7.9:) remove support for old @"screencodes" string encoding syntax, parser+code+docs +- remove support for old @"screencodes" string encoding syntax, parser+code+docs - ... diff --git a/examples/test.p8 b/examples/test.p8 index 91eae5b7c..c1f43dd8d 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,12 +1,10 @@ %zeropage basicsafe main { + ubyte @requirezp foobar2 = 255 sub start() { - cx16.r0=0 - void routine22(1,2,3,4,5) - } - - sub routine22(ubyte aa1, ubyte aa2, ubyte aa3, ubyte aa4, ubyte aa5) -> ubyte { - return aa1+aa2+aa3+aa4+aa5 + ubyte @requirezp foobar = 255 + foobar++ + foobar2++ } }