mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-28 00:41:18 +00:00
Added AS3 support for logical AND/OR compound operator
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2022 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
|
||||
|
||||
/**
|
||||
* CompoundableBinaryOp but for AS1/2, which does not have &&, || compound operator.
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface CompoundableBinaryOpAs12 extends CompoundableBinaryOp {
|
||||
|
||||
}
|
||||
+2
-1
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionAdd;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionAdd2;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
@@ -38,7 +39,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AddActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class AddActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
boolean version2;
|
||||
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitAnd;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -33,7 +34,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class BitAndActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class BitAndActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public BitAndActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_BITWISEAND, leftSide, rightSide, "&", "int", "int");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitOr;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -33,7 +34,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class BitOrActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class BitOrActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public BitOrActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_BITWISEOR, leftSide, rightSide, "|", "int", "int");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitXor;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
@@ -36,7 +37,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class BitXorActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class BitXorActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public BitXorActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_BITWISEXOR, leftSide, rightSide, "^", "int", "int");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionDivide;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -32,7 +33,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DivideActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class DivideActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public DivideActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "/", "Number", "Number");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitLShift;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -33,7 +34,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class LShiftActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class LShiftActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public LShiftActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, "<<", "int", "int");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionModulo;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -32,7 +33,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ModuloActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class ModuloActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public ModuloActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "%", "Number", "Number");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionMultiply;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -32,7 +33,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class MultiplyActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class MultiplyActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public MultiplyActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "*", "Number", "Number");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitRShift;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
@@ -33,7 +34,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class RShiftActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class RShiftActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public RShiftActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>", "int", "int");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSubtract;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
@@ -35,7 +36,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SubtractActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class SubtractActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public SubtractActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_ADDITIVE, leftSide, rightSide, "-", "Number", "Number");
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitURShift;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
@@ -32,7 +33,7 @@ import java.util.List;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class URShiftActionItem extends BinaryOpItem implements CompoundableBinaryOp {
|
||||
public class URShiftActionItem extends BinaryOpItem implements CompoundableBinaryOpAs12 {
|
||||
|
||||
public URShiftActionItem(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem leftSide, GraphTargetItem rightSide) {
|
||||
super(instruction, lineStartIns, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>>", "Number", "Number");
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.StoreTypeAction;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.model.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.action.model.DecrementActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
@@ -136,7 +137,7 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
|
||||
if (inside instanceof StoreRegisterActionItem) {
|
||||
inside = inside.value;
|
||||
}
|
||||
if (inside instanceof CompoundableBinaryOp) {
|
||||
if (inside instanceof CompoundableBinaryOpAs12) {
|
||||
if (!name.hasSideEffect()) {
|
||||
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) inside;
|
||||
if (binaryOp.getLeftSide() instanceof GetVariableActionItem) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.BaseLocalData;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.ActionScriptObject;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.model.DecrementActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.GetMemberActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.IncrementActionItem;
|
||||
@@ -122,7 +123,7 @@ public class ActionSetMember extends Action {
|
||||
if (inside instanceof StoreRegisterActionItem) {
|
||||
inside = inside.value;
|
||||
}
|
||||
if (inside instanceof CompoundableBinaryOp) {
|
||||
if (inside instanceof CompoundableBinaryOpAs12) {
|
||||
if (!object.hasSideEffect() && !memberName.hasSideEffect()) {
|
||||
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) inside;
|
||||
if (binaryOp.getLeftSide() instanceof GetMemberActionItem) {
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.LocalDataArea;
|
||||
import com.jpexs.decompiler.flash.action.StoreTypeAction;
|
||||
import com.jpexs.decompiler.flash.action.model.CompoundableBinaryOpAs12;
|
||||
import com.jpexs.decompiler.flash.action.model.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.action.model.DecrementActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
@@ -166,7 +167,7 @@ public class ActionStoreRegister extends Action implements StoreTypeAction {
|
||||
variables.remove("__register" + registerNumber);
|
||||
}
|
||||
StoreRegisterActionItem ret = new StoreRegisterActionItem(this, lineStartAction, rn, value, define);
|
||||
if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) {
|
||||
if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOpAs12) {
|
||||
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup();
|
||||
if (binaryOp.getLeftSide() instanceof DirectValueActionItem) {
|
||||
DirectValueActionItem directValue = (DirectValueActionItem) binaryOp.getLeftSide();
|
||||
|
||||
Reference in New Issue
Block a user