|
|
@ -116,7 +116,7 @@ fun Expression.countNots(): Int { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun Expression.hasSideEffects(): Boolean { |
|
|
|
fun Expression.hasSideEffects(): Boolean { |
|
|
|
if (isLiteralExpr || isNameExpr || isFieldAccessExpr || isThisExpr) { |
|
|
|
if (isLiteralExpr || isNameExpr || isThisExpr) { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} else if (isUnaryExpr) { |
|
|
|
} else if (isUnaryExpr) { |
|
|
|
return asUnaryExpr().expression.hasSideEffects() |
|
|
|
return asUnaryExpr().expression.hasSideEffects() |
|
|
@ -126,7 +126,11 @@ fun Expression.hasSideEffects(): Boolean { |
|
|
|
} else if (isArrayAccessExpr) { |
|
|
|
} else if (isArrayAccessExpr) { |
|
|
|
val access = asArrayAccessExpr() |
|
|
|
val access = asArrayAccessExpr() |
|
|
|
return access.name.hasSideEffects() || access.index.hasSideEffects() |
|
|
|
return access.name.hasSideEffects() || access.index.hasSideEffects() |
|
|
|
|
|
|
|
} else if (isFieldAccessExpr) { |
|
|
|
|
|
|
|
val access = asFieldAccessExpr() |
|
|
|
|
|
|
|
return access.scope.hasSideEffects() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO(gpe): more cases |
|
|
|
// TODO(gpe): more cases |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|