From 9927af1095813da02a371e36fbce94dd1de4516a Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Mon, 21 Oct 2024 21:20:47 +0200 Subject: [PATCH] about var inits --- codeCore/src/prog8/code/SymbolTableMaker.kt | 2 +- .../src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt | 1 + docs/source/todo.rst | 5 ----- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/codeCore/src/prog8/code/SymbolTableMaker.kt b/codeCore/src/prog8/code/SymbolTableMaker.kt index 8d9646eab..27524ef81 100644 --- a/codeCore/src/prog8/code/SymbolTableMaker.kt +++ b/codeCore/src/prog8/code/SymbolTableMaker.kt @@ -85,7 +85,7 @@ class SymbolTableMaker(private val program: PtProgram, private val options: Comp initialString = null initialArray = null val number = value.number - initialNumeric = if(number==0.0) null else number // 0 as init value -> just uninitialized TODO weird? + initialNumeric = number numElements = node.arraySize?.toInt() } } diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt index c7dfa33d0..e7810ddb1 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt @@ -471,6 +471,7 @@ internal class ProgramAndVarsGen( private fun entrypointInitialization() { // zero out the BSS area first, before setting the variable init values + // this is mainly to make sure the arrays are all zero'd out at program startup asmgen.out(" jsr prog8_lib.program_startup_clear_bss") // initialize block-level (global) variables at program start diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 4d4f80c7a..3fa9530d6 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,11 +1,6 @@ TODO ==== -In ast2 allow PtVariable to still have a numeric initialization value in codegen. (instead of only array and string) -why is 0 as value stored as null in symboltablemaker? - -are variables initialized with 0 reset to 0 with an assignment? WHY is the BSS area then cleared with memset? shouldn't be necessary? - - unit test for defer - describe defer in the manual