AS3 - Compound assignments detection

This commit is contained in:
Jindra Petřík
2021-03-12 22:12:39 +01:00
parent 16a03fe0f7
commit 23227caacd
7 changed files with 84 additions and 13 deletions
@@ -41,8 +41,10 @@ import com.jpexs.decompiler.graph.model.FalseItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.NotItem;
import com.jpexs.decompiler.graph.model.TrueItem;
import com.jpexs.helpers.Reference;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -372,7 +374,16 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
}
public boolean hasSideEffect() {
return false;
Reference<Boolean> ref = new Reference<>(false);
visitRecursively(new AbstractGraphTargetVisitor() {
@Override
public void visit(GraphTargetItem item) {
if (item.hasSideEffect()) {
ref.setVal(Boolean.TRUE);
}
}
});
return ref.getVal();
}
public boolean isVariableComputed() {
@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.␍ */
* License along with this library.
*/
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -118,4 +119,10 @@ public class DuplicateItem extends GraphTargetItem implements SimpleValue {
public boolean isSimpleValue() {
return ((value instanceof SimpleValue) && ((SimpleValue) value).isSimpleValue());
}
@Override
public boolean hasSideEffect() {
return value.hasSideEffect();
}
}