From 28277469b6096319ec1b803d2003c8f109b2211f Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 7 Mar 2019 22:04:00 +0100 Subject: [PATCH] fixed a compiler crash because with noopt, strings weren't put on the heap --- compiler/src/prog8/CompilerMain.kt | 4 +++- compiler/src/prog8/ast/AstIdentifiersChecker.kt | 1 + examples/test.p8 | 3 --- 3 files changed, 4 insertions(+), 4 deletions(-) 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() {