don't remove 'duplicate' assignments that aren't removable (i.e. not literalvalues)

This commit is contained in:
Irmen de Jong 2019-03-31 16:10:02 +02:00
parent 03d0411679
commit b57c02b0ba

View File

@ -20,7 +20,6 @@ import kotlin.math.floor
todo inline subroutines that are only called a few times (3?) and that are "sufficiently small" (0-3 statements) todo inline subroutines that are only called a few times (3?) and that are "sufficiently small" (0-3 statements)
todo analyse for unreachable code and remove that (f.i. code after goto or return that has no label so can never be jumped to) todo analyse for unreachable code and remove that (f.i. code after goto or return that has no label so can never be jumped to)
*/ */
class StatementOptimizer(private val namespace: INameScope, private val heap: HeapValues) : IAstProcessor { class StatementOptimizer(private val namespace: INameScope, private val heap: HeapValues) : IAstProcessor {
@ -76,7 +75,7 @@ class StatementOptimizer(private val namespace: INameScope, private val heap: He
var previousAssignmentLine: Int? = null var previousAssignmentLine: Int? = null
for (i in 0 until statements.size) { for (i in 0 until statements.size) {
val stmt = statements[i] as? Assignment val stmt = statements[i] as? Assignment
if (stmt != null) { if (stmt != null && stmt.value is LiteralValue) {
if (previousAssignmentLine == null) { if (previousAssignmentLine == null) {
previousAssignmentLine = i previousAssignmentLine = i
continue continue