diff --git a/compiler/src/prog8/CompilerMain.kt b/compiler/src/prog8/CompilerMain.kt index fe0f37b43..a6f7de22a 100644 --- a/compiler/src/prog8/CompilerMain.kt +++ b/compiler/src/prog8/CompilerMain.kt @@ -104,10 +104,12 @@ private fun compileMain(args: Array) { } //println(" time4: $time4") + val allScopedSymbolDefinitions = moduleAst.checkIdentifiers(heap) // useful for checking symbol usage later? +// moduleAst.simplifyExpressions(namespace, heap) +// moduleAst.optimizeStatements(namespace, heap) if(optimize) { // optimize the parse tree println("Optimizing...") - val allScopedSymbolDefinitions = moduleAst.checkIdentifiers(heap) // useful for checking symbol usage later? while (true) { // keep optimizing expressions and statements until no more steps remain val optsDone1 = moduleAst.simplifyExpressions(namespace, heap) diff --git a/compiler/src/prog8/ast/AstIdentifiersChecker.kt b/compiler/src/prog8/ast/AstIdentifiersChecker.kt index 3a22fd655..84dd8128e 100644 --- a/compiler/src/prog8/ast/AstIdentifiersChecker.kt +++ b/compiler/src/prog8/ast/AstIdentifiersChecker.kt @@ -33,6 +33,7 @@ fun Module.checkIdentifiers(heap: HeapValues): MutableMap { } else -> TODO("replace literalvalue by identifierref: $variable (in $parent)") } + variable.second.linkParents(scope as Node) } printErrors(checker.result(), name) diff --git a/examples/test.p8 b/examples/test.p8 index b014ce393..8a1ddbb26 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -5,9 +5,6 @@ ; @todo see problem in looplabelproblem.p8 - ; @todo when using -noopt, the error "can only push address of string that is a variable on the heap" appears when using strings - - sub start() {