fix too greedy expression simplification

could cause problems when variables occur multiple times in the same expression.
Fixes #101
This commit is contained in:
Irmen de Jong 2023-03-22 18:25:28 +01:00
parent cc81d6fe82
commit 6218c1c00b

View File

@ -979,10 +979,7 @@ class FunctionCallExpression(override var target: IdentifierReference,
} }
override fun copy() = FunctionCallExpression(target.copy(), args.map { it.copy() }.toMutableList(), position) override fun copy() = FunctionCallExpression(target.copy(), args.map { it.copy() }.toMutableList(), position)
override val isSimple = override val isSimple = false
target.nameInSource.size==1
&& target.nameInSource[0] in arrayOf("msb", "lsb", "peek", "peekw", "mkword")
&& args.all { it.isSimple }
override fun replaceChildNode(node: Node, replacement: Node) { override fun replaceChildNode(node: Node, replacement: Node) {
if(node===target) 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 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) { override fun replaceChildNode(node: Node, replacement: Node) {
if(node===target) if(node===target)