From 8f0dfd272538fe38375b77ca5fb6de1fe758f926 Mon Sep 17 00:00:00 2001 From: Graham Date: Wed, 5 Aug 2020 11:31:19 +0100 Subject: [PATCH] Fix FieldAccessExpr's hasSideEffects() implementation Signed-off-by: Graham --- .../src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt index d017fe0a38..fb4202a807 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt @@ -116,7 +116,7 @@ fun Expression.countNots(): Int { } fun Expression.hasSideEffects(): Boolean { - if (isLiteralExpr || isNameExpr || isFieldAccessExpr || isThisExpr) { + if (isLiteralExpr || isNameExpr || isThisExpr) { return false } else if (isUnaryExpr) { return asUnaryExpr().expression.hasSideEffects() @@ -126,7 +126,11 @@ fun Expression.hasSideEffects(): Boolean { } else if (isArrayAccessExpr) { val access = asArrayAccessExpr() return access.name.hasSideEffects() || access.index.hasSideEffects() + } else if (isFieldAccessExpr) { + val access = asFieldAccessExpr() + return access.scope.hasSideEffects() } + // TODO(gpe): more cases return true }