From 6218c1c00b2808a71118b13feea94ff212e0b54e Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 22 Mar 2023 18:25:28 +0100 Subject: [PATCH] fix too greedy expression simplification could cause problems when variables occur multiple times in the same expression. Fixes #101 --- compilerAst/src/prog8/ast/expressions/AstExpressions.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt index d82d6d1b3..0f33326e3 100644 --- a/compilerAst/src/prog8/ast/expressions/AstExpressions.kt +++ b/compilerAst/src/prog8/ast/expressions/AstExpressions.kt @@ -979,10 +979,7 @@ class FunctionCallExpression(override var target: IdentifierReference, } override fun copy() = FunctionCallExpression(target.copy(), args.map { it.copy() }.toMutableList(), position) - override val isSimple = - target.nameInSource.size==1 - && target.nameInSource[0] in arrayOf("msb", "lsb", "peek", "peekw", "mkword") - && args.all { it.isSimple } + override val isSimple = false override fun replaceChildNode(node: Node, replacement: Node) { if(node===target) @@ -1142,7 +1139,7 @@ class BuiltinFunctionCall(override var target: IdentifierReference, } override fun copy() = BuiltinFunctionCall(target.copy(), args.map { it.copy() }.toMutableList(), position) - override val isSimple = name in arrayOf("msb", "lsb", "peek", "peekw", "set_carry", "set_irqd", "clear_carry", "clear_irqd") + override val isSimple = false override fun replaceChildNode(node: Node, replacement: Node) { if(node===target)