AS3 using temp registers on compound assignments when hasSideeffect

This commit is contained in:
Jindra Petřík
2021-03-08 12:17:46 +01:00
parent e0948e2a38
commit 8fa321cfd3
66 changed files with 707 additions and 197 deletions

View File

@@ -31,6 +31,7 @@ import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -97,4 +98,12 @@ public class AddAVM2Item extends BinaryOpItem implements CompoundableBinaryOp {
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.Add, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -23,6 +24,7 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -46,4 +48,11 @@ public class AsTypeAVM2Item extends BinaryOpItem {
public GraphTargetItem returnType() {
return rightSide;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.AsTypeLate, null));
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -54,4 +55,11 @@ public class BitAndAVM2Item extends BinaryOpItem implements CompoundableBinaryOp
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.BitAnd, null));
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -54,4 +55,11 @@ public class BitOrAVM2Item extends BinaryOpItem implements CompoundableBinaryOp
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.BitOr, null));
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -54,4 +55,11 @@ public class BitXorAVM2Item extends BinaryOpItem implements CompoundableBinaryOp
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.BitXor, null));
return ret;
}
}

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -84,4 +85,11 @@ public class DivideAVM2Item extends BinaryOpItem implements CompoundableBinaryOp
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.Divide, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -28,6 +29,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -71,4 +73,11 @@ public class EqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.Equals, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -28,6 +29,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -77,4 +79,11 @@ public class GeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.GreaterEquals, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -28,6 +29,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -77,4 +79,11 @@ public class GtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.GreaterThan, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -48,4 +50,11 @@ public class InAVM2Item extends BinaryOpItem {
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.In, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -48,4 +50,11 @@ public class InstanceOfAVM2Item extends BinaryOpItem {
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.InstanceOf, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -48,4 +50,11 @@ public class IsTypeAVM2Item extends BinaryOpItem {
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.IsTypeLate, null));
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -54,4 +55,11 @@ public class LShiftAVM2Item extends BinaryOpItem implements CompoundableBinaryOp
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.LShift, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -76,4 +78,11 @@ public class LeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.LessEquals, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -28,6 +29,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -77,4 +79,11 @@ public class LtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.LessThan, null));
return ret;
}
}

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -82,4 +83,11 @@ public class ModuloAVM2Item extends BinaryOpItem implements CompoundableBinaryOp
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.Modulo, null));
return ret;
}
}

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -78,4 +79,11 @@ public class MultiplyAVM2Item extends BinaryOpItem implements CompoundableBinary
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.Multiply, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -71,4 +73,12 @@ public class NeqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfCondit
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.Equals, null));
ret.add(new AVM2Instruction(0, AVM2Instructions.Not, null));
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -54,4 +55,11 @@ public class RShiftAVM2Item extends BinaryOpItem implements CompoundableBinaryOp
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.RShift, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -28,6 +29,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -74,4 +76,11 @@ public class StrictEqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfC
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.StrictEquals, null));
return ret;
}
}

View File

@@ -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.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -74,4 +76,12 @@ public class StrictNeqAVM2Item extends BinaryOpItem implements LogicalOpItem, If
public GraphTargetItem returnType() {
return new TypeItem(DottedChain.BOOLEAN);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.StrictEquals, null));
ret.add(new AVM2Instruction(0, AVM2Instructions.Not, null));
return ret;
}
}

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -87,4 +88,11 @@ public class SubtractAVM2Item extends BinaryOpItem implements CompoundableBinary
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.Subtract, null));
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -54,4 +55,11 @@ public class URShiftAVM2Item extends BinaryOpItem implements CompoundableBinaryO
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new AVM2Instruction(0, AVM2Instructions.URShift, null));
return ret;
}
}

View File

@@ -1994,7 +1994,9 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
}
for (int i = 1; i < registerNames.size(); i++) {
mbodyCode.add(i - 1, ins(AVM2Instructions.Debug, 1, str(registerNames.get(i)), i - 1, (int) registerLines.get(i)));
if (!needsActivation) {
mbodyCode.add(i - 1, ins(AVM2Instructions.Debug, 1, str(registerNames.get(i)), i - 1, (int) registerLines.get(i)));
}
}
if (!subMethod) {
mbodyCode.add(0, new AVM2Instruction(0, AVM2Instructions.GetLocal0, null));

View File

@@ -208,4 +208,10 @@ public class CallAVM2Item extends AVM2Item {
public boolean hasReturnValue() {
return true;
}
@Override
public boolean hasSideEffect() {
return true;
}
}

View File

@@ -98,4 +98,9 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item {
}
return toSourceMerge(localData, generator, resname, arguments, ins(AVM2Instructions.Construct, arguments.size()));
}
@Override
public boolean hasSideEffect() {
return true;
}
}

View File

@@ -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.flash.abc.avm2.parser.script;
import com.jpexs.helpers.Reference;
@@ -25,10 +26,12 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
*
@@ -112,6 +115,34 @@ public class IndexAVM2Item extends AssignableAVM2Item {
Reference<Integer> ret_temp = new Reference<>(-1);
if (assignedValue != null) {
if (assignedValue instanceof CompoundableBinaryOp) {
CompoundableBinaryOp comp = (CompoundableBinaryOp) assignedValue;
if (comp.getLeftSide() instanceof IndexAVM2Item) {
IndexAVM2Item left = (IndexAVM2Item) comp.getLeftSide();
if (left.assignedValue == null && Objects.equals(left.object, object) && Objects.equals(left.index, index) && index.hasSideEffect()) {
Reference<Integer> val_temp = new Reference<>(-1);
Reference<Integer> index_temp = new Reference<>(-1);
return toSourceMerge(localData, generator,
index,
setTemp(localData, generator, index_temp),
object,
getTemp(localData, generator, index_temp),
ins(AVM2Instructions.GetProperty, indexPropIndex),
comp.getRightSide(),
comp.getOperatorInstruction(),
setTemp(localData, generator, val_temp),
object,
getTemp(localData, generator, index_temp),
getTemp(localData, generator, val_temp),
needsReturn ? dupSetTemp(localData, generator, ret_temp) : null,
ins(AVM2Instructions.SetProperty, indexPropIndex),
needsReturn ? getTemp(localData, generator, ret_temp) : null,
killTemp(localData, generator, Arrays.asList(index_temp, val_temp, ret_temp)));
}
}
}
return toSourceMerge(localData, generator,
object,
index,
@@ -143,4 +174,38 @@ public class IndexAVM2Item extends AssignableAVM2Item {
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSource(localData, generator, false, false, new ArrayList<>(), false, false);
}
@Override
public int hashCode() {
int hash = 3;
hash = 89 * hash + Objects.hashCode(this.object);
hash = 89 * hash + Objects.hashCode(this.index);
hash = 89 * hash + (this.attr ? 1 : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final IndexAVM2Item other = (IndexAVM2Item) obj;
if (this.attr != other.attr) {
return false;
}
if (!Objects.equals(this.object, other.object)) {
return false;
}
if (!Objects.equals(this.index, other.index)) {
return false;
}
return true;
}
}

View File

@@ -41,6 +41,7 @@ import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
*
@@ -352,4 +353,30 @@ public class NameAVM2Item extends AssignableAVM2Item {
slotNumber > -1 ? ins(AVM2Instructions.SetSlot, slotNumber) : null
);
}
@Override
public int hashCode() {
int hash = 7;
hash = 13 * hash + Objects.hashCode(this.variableName);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final NameAVM2Item other = (NameAVM2Item) obj;
if (!Objects.equals(this.variableName, other.variableName)) {
return false;
}
return true;
}
}

View File

@@ -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.flash.abc.avm2.parser.script;
import com.jpexs.helpers.Reference;

View File

@@ -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.flash.abc.avm2.parser.script;
import com.jpexs.helpers.Reference;
@@ -32,6 +33,7 @@ import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/**
*
@@ -214,4 +216,50 @@ public class NamespacedAVM2Item extends AssignableAVM2Item {
public List<GraphSourceItem> toSourceIgnoreReturnValue(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSource(localData, generator, false, false, new ArrayList<>(), false, false);
}
@Override
public int hashCode() {
int hash = 3;
hash = 59 * hash + Objects.hashCode(this.ns);
hash = 59 * hash + Objects.hashCode(this.name);
hash = 59 * hash + Objects.hashCode(this.nameItem);
hash = 59 * hash + Objects.hashCode(this.obj);
hash = 59 * hash + (this.attr ? 1 : 0);
hash = 59 * hash + Objects.hashCode(this.openedNamespaces);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final NamespacedAVM2Item other = (NamespacedAVM2Item) obj;
if (this.attr != other.attr) {
return false;
}
if (!Objects.equals(this.name, other.name)) {
return false;
}
if (!Objects.equals(this.ns, other.ns)) {
return false;
}
if (!Objects.equals(this.nameItem, other.nameItem)) {
return false;
}
if (!Objects.equals(this.obj, other.obj)) {
return false;
}
if (!Objects.equals(this.openedNamespaces, other.openedNamespaces)) {
return false;
}
return true;
}
}

View File

@@ -40,12 +40,14 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -450,165 +452,6 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
return propIndex.getVal();
}
/*
private String resolveObjectType() {
String objType = object == null ? null : object.returnType().toString();
if (objType == null) {
loopo:
for (int i = 0; i < openedNamespaces.size(); i++) {
int nsindex = openedNamespaces.get(i);
int nsKind = abc.constants.constant_namespace.get(openedNamespaces.get(i)).kind;
String nsname = abc.constants.constant_namespace.get(openedNamespaces.get(i)).getName(abc.constants);
int name_index = 0;
for (int m = 1; m < abc.constants.constant_multiname.size(); m++) {
Multiname mname = abc.constants.constant_multiname.get(m);
if (mname.kind == Multiname.QNAME && mname.getName(abc.constants, new ArrayList<>()).equals(propertyName) && mname.namespace_index == nsindex) {
name_index = m;
break;
}
}
if (name_index > 0) {
for (int s = 0; s < abc.script_info.size(); s++) {
for (Trait t : abc.script_info.get(s).traits.traits) {
if (t.name_index == name_index) {
return getTraitReturnType(abc, t).toString();
}
}
}
for (int c = 0; c < abc.instance_info.size(); c++) {
for (Trait t : abc.instance_info.get(c).instance_traits.traits) {
if (t.name_index == name_index) {
return getTraitReturnType(abc, t).toString();
}
}
for (Trait t : abc.class_info.get(c).static_traits.traits) {
if (t.name_index == name_index) {
return getTraitReturnType(abc, t).toString();
}
}
}
}
if (nsKind == Namespace.KIND_PACKAGE) {
List<ABC> abcs = new ArrayList<>();
abcs.add(abc);
abcs.addAll(otherABCs);
loopabc:
for (ABC a : otherABCs) {
for (int h = 0; h < a.instance_info.size(); h++) {
InstanceInfo ii = a.instance_info.get(h);
Multiname n = a.constants.constant_multiname.get(ii.name_index);
if (n.getNamespace(a.constants).kind == Namespace.KIND_PACKAGE && n.getNamespace(a.constants).getName(a.constants).equals(nsname)) {
Reference<String> outName = new Reference<>("");
Reference<String> outNs = new Reference<>("");
Reference<String> outPropNs = new Reference<>("");
Reference<Integer> outPropNsKind = new Reference<>(1);
if (AVM2SourceGenerator.searchPrototypeChain(abcs, nsname, n.getName(a.constants, new ArrayList<>()), propertyName, outName, outNs, outPropNs, outPropNsKind)) {
return "".equals(outNs.getVal()) ? outName.getVal() : outNs.getVal() + "." + outName.getVal();
}
}
}
}
}
}
}
if (objType == null) {
throw new RuntimeException("Unresolved object type");
}
return objType;
}*/
/*
public GraphTargetItem resolvePropertyType() {
if (index != null) {
return TypeItem.UNBOUNDED;
}
String objType = resolveObjectType();
for (ABC a : abcs) {
int ci = a.findClassByName(objType);
if (ci != -1) {
for (Trait t : a.instance_info.get(ci).instance_traits.traits) {
String tnames = t.getName(a).getName(a.constants, new ArrayList<>());
if (tnames.equals(propertyName)) {
if (t instanceof TraitSlotConst) {
TraitSlotConst tsc = (TraitSlotConst) t;
if (tsc.type_index == 0) {
return TypeItem.UNBOUNDED;
}
return new TypeItem(a.constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(a.constants));
}
if (t instanceof TraitMethodGetterSetter) {
TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) t;
if (tmgs.kindType == Trait.TRAIT_GETTER) {
return new TypeItem(a.constants.constant_multiname.get(a.method_info.get(tmgs.method_info).ret_type).getNameWithNamespace(a.constants));
}
if (tmgs.kindType == Trait.TRAIT_SETTER) {
return new TypeItem(a.constants.constant_multiname.get(a.method_info.get(tmgs.method_info).param_types[0]).getNameWithNamespace(a.constants));
}
}
if (t instanceof TraitFunction) {
return new TypeItem("Function");
}
return TypeItem.UNBOUNDED;
}
}
break;
}
}
return TypeItem.UNBOUNDED;
}
*/
/* public int resolveProperty() {
if (index != null) {
return abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL,
abc.constants.getStringId(propertyName, true), 0,
allNsSet(), 0, new ArrayList<Integer>()), true);
}
String objType = resolveObjectType();
for (ABC a : abcs) {
int ci = a.findClassByName(objType);
if (ci != -1) {
for (Trait t : a.instance_info.get(ci).instance_traits.traits) {
Multiname tname = t.getName(a);
String tnames = t.getName(a).getName(a.constants, new ArrayList<>());
if (tnames.equals(propertyName)) {
return abc.constants.getMultinameId(new Multiname(tname.kind,
abc.constants.getStringId(tnames, true),
abc.constants.getNamespaceId(new Namespace(tname.getNamespace(a.constants).kind, abc.constants.getStringId(tname.getNamespace(a.constants).getName(a.constants), true)), 0, true), 0, 0, new ArrayList<Integer>()), true);
}
}
for (Trait t : a.class_info.get(ci).static_traits.traits) {
Multiname tname = t.getName(a);
String tnames = t.getName(a).getName(a.constants, new ArrayList<>());
if (tnames.equals(propertyName)) {
return abc.constants.getMultinameId(new Multiname(tname.kind,
abc.constants.getStringId(tnames, true),
abc.constants.getNamespaceId(new Namespace(tname.getNamespace(a.constants).kind, abc.constants.getStringId(tname.getNamespace(a.constants).getName(a.constants), true)), 0, true), 0, 0, new ArrayList<Integer>()), true);
}
}
break;
}
}
for (ABC a : abcs) {
for (ScriptInfo si : a.script_info) {
for (Trait t : si.traits.traits) {
Multiname tname = t.getName(a);
String tnames = t.getName(a).getName(a.constants, new ArrayList<>());
if (tnames.equals(propertyName)) {
return abc.constants.getMultinameId(new Multiname(tname.kind,
abc.constants.getStringId(tnames, true),
abc.constants.getNamespaceId(new Namespace(tname.getNamespace(a.constants).kind, abc.constants.getStringId(tname.getNamespace(a.constants).getName(a.constants), true)), 0, true), 0, 0, new ArrayList<Integer>()), true);
}
}
}
}
return abc.constants.getMultinameId(new Multiname(Multiname.MULTINAME,
abc.constants.getStringId(propertyName, true), 0,
allNsSet(), 0, new ArrayList<Integer>()), true);
}*/
@Override
public GraphTargetItem returnType() {

View File

@@ -42,6 +42,7 @@ import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
*
@@ -509,4 +510,30 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item {
}
return resolvedRoot = ret;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + Objects.hashCode(this.name);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final UnresolvedAVM2Item other = (UnresolvedAVM2Item) obj;
if (!Objects.equals(this.name, other.name)) {
return false;
}
return true;
}
}

View File

@@ -30,6 +30,7 @@ import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
import java.util.List;
/**
@@ -91,4 +92,11 @@ public class AddActionItem extends BinaryOpItem implements CompoundableBinaryOp
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionAdd2());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -54,4 +56,11 @@ public class AndActionItem extends BinaryOpItem {
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionAnd());
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -56,4 +57,11 @@ public class BitAndActionItem extends BinaryOpItem implements CompoundableBinary
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionBitAnd());
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -56,4 +57,11 @@ public class BitOrActionItem extends BinaryOpItem implements CompoundableBinaryO
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionBitOr());
return ret;
}
}

View File

@@ -29,6 +29,7 @@ import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -76,4 +77,11 @@ public class BitXorActionItem extends BinaryOpItem implements CompoundableBinary
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionBitXor());
return ret;
}
}

View File

@@ -25,6 +25,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.UnboundedTypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -60,4 +61,11 @@ public class DivideActionItem extends BinaryOpItem implements CompoundableBinary
public GraphTargetItem returnType() {
return new UnboundedTypeItem();
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionDivide());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -70,4 +72,11 @@ public class EqActionItem extends BinaryOpItem implements LogicalOpItem, EqualsT
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionEquals2());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -30,6 +31,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -76,4 +78,11 @@ public class GeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionLess2()); //FIXME!!!
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -29,6 +30,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -74,4 +76,11 @@ public class GtActionItem extends BinaryOpItem implements LogicalOpItem {
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionGreater()); //FIXME!!!
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.action.model.ActionItem;
@@ -20,6 +21,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
@@ -41,4 +44,10 @@ public class InActionItem extends BinaryOpItem {
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -23,6 +24,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -50,4 +52,11 @@ public class InstanceOfActionItem extends BinaryOpItem {
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionInstanceOf());
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import java.util.ArrayList;
import java.util.List;
/**
@@ -56,4 +57,11 @@ public class LShiftActionItem extends BinaryOpItem implements CompoundableBinary
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionBitLShift());
return ret;
}
}

View File

@@ -12,11 +12,13 @@
* 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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.swf4.ActionLess;
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
import com.jpexs.decompiler.flash.action.swf5.ActionLess2;
@@ -30,6 +32,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -71,4 +74,13 @@ public class LeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
//FIXME!!!
ret.add(new ActionGreater());
ret.add(new ActionNot());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -29,6 +30,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -79,4 +81,11 @@ public class LtActionItem extends BinaryOpItem implements LogicalOpItem {
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionLess2()); //FIXME!!!
return ret;
}
}

View File

@@ -25,6 +25,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import java.util.ArrayList;
import java.util.List;
/**
@@ -58,4 +59,11 @@ public class ModuloActionItem extends BinaryOpItem implements CompoundableBinary
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionModulo());
return ret;
}
}

View File

@@ -25,6 +25,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import java.util.ArrayList;
import java.util.List;
/**
@@ -55,4 +56,11 @@ public class MultiplyActionItem extends BinaryOpItem implements CompoundableBina
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionMultiply());
return ret;
}
}

View File

@@ -12,11 +12,13 @@
* 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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
import com.jpexs.decompiler.flash.action.swf5.ActionEquals2;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
@@ -27,6 +29,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -66,4 +69,12 @@ public class NeqActionItem extends BinaryOpItem implements LogicalOpItem, Invert
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionEquals2());
ret.add(new ActionNot());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -54,4 +56,11 @@ public class OrActionItem extends BinaryOpItem {
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionOr());
return ret;
}
}

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import java.util.ArrayList;
import java.util.List;
/**
@@ -57,4 +58,11 @@ public class RShiftActionItem extends BinaryOpItem implements CompoundableBinary
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionBitRShift());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -26,6 +27,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -63,4 +65,11 @@ public class StrictEqActionItem extends BinaryOpItem implements LogicalOpItem, I
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStrictEquals());
return ret;
}
}

View File

@@ -12,11 +12,13 @@
* 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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
import com.jpexs.decompiler.flash.action.swf4.ActionStringEquals;
import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.graph.CompilationException;
@@ -26,6 +28,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LogicalOpItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -59,4 +62,12 @@ public class StrictNeqActionItem extends BinaryOpItem implements LogicalOpItem,
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStrictEquals());
ret.add(new ActionNot());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -60,4 +62,11 @@ public class StringAddActionItem extends BinaryOpItem {
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStringAdd());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -65,4 +67,11 @@ public class StringEqActionItem extends BinaryOpItem implements Inverted {
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringNeActionItem(getSrc(), getLineStartItem(), leftSide, rightSide);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStringEquals());
return ret;
}
}

View File

@@ -12,10 +12,12 @@
* 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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
import com.jpexs.decompiler.flash.action.swf4.ActionStringLess;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
@@ -25,6 +27,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -62,4 +65,12 @@ public class StringGeActionItem extends BinaryOpItem implements Inverted {
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringLtActionItem(getSrc(), getLineStartItem(), leftSide, rightSide);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStringLess());
ret.add(new ActionNot());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -26,6 +27,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -71,4 +73,11 @@ public class StringGtActionItem extends BinaryOpItem implements Inverted {
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringLeActionItem(getSrc(), getLineStartItem(), leftSide, rightSide);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStringGreater()); //FIXME!!!
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -27,6 +28,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -58,7 +60,7 @@ public class StringLeActionItem extends BinaryOpItem implements Inverted {
return toSourceMerge(localData, generator, leftSide, rightSide, new ActionStringGreater(), new ActionNot());
}
return toSourceMerge(localData, generator, rightSide, leftSide, new ActionStringLess(), new ActionNot()); //TODO: is this correct?
}
@Override
@@ -70,4 +72,12 @@ public class StringLeActionItem extends BinaryOpItem implements Inverted {
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringGtActionItem(getSrc(), getLineStartItem(), leftSide, rightSide);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStringGreater());
ret.add(new ActionNot()); //FIXME!!!
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -65,4 +67,11 @@ public class StringLtActionItem extends BinaryOpItem implements Inverted {
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringGeActionItem(getSrc(), getLineStartItem(), leftSide, rightSide);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStringLess());
return ret;
}
}

View File

@@ -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.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -24,6 +25,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -56,4 +58,12 @@ public class StringNeActionItem extends BinaryOpItem implements Inverted {
public GraphTargetItem invert(GraphSourceItem negSrc) {
return new StringEqActionItem(getSrc(), getLineStartItem(), leftSide, rightSide);
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionStringEquals());
ret.add(new ActionNot());
return ret;
}
}

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
import java.util.List;
/**
@@ -89,4 +90,11 @@ public class SubtractActionItem extends BinaryOpItem implements CompoundableBina
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionSubtract());
return ret;
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model.operations;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.swf5.ActionBitRShift;
import com.jpexs.decompiler.flash.action.swf5.ActionBitURShift;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -25,6 +26,7 @@ import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.CompoundableBinaryOp;
import java.util.ArrayList;
import java.util.List;
/**
@@ -57,4 +59,11 @@ public class URShiftActionItem extends BinaryOpItem implements CompoundableBinar
public GraphTargetItem returnType() {
return TypeItem.UNBOUNDED;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
List<GraphSourceItem> ret = new ArrayList<>();
ret.add(new ActionBitURShift());
return ret;
}
}

View File

@@ -585,7 +585,7 @@ public abstract class GraphTargetItem implements Serializable, Cloneable {
public abstract GraphTargetItem returnType();
@Override
protected GraphTargetItem clone() {
public GraphTargetItem clone() {
try {
return (GraphTargetItem) super.clone();
} catch (CloneNotSupportedException ex) {

View File

@@ -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;
@@ -22,6 +23,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -58,4 +60,9 @@ public class AndItem extends BinaryOpItem {
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
return new ArrayList<>(); //???
}
}

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.graph.model;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.List;
@@ -38,4 +39,6 @@ public interface BinaryOp {
public List<GraphTargetItem> getAllSubItems();
public String getOperator();
public List<GraphSourceItem> getOperatorInstruction();
}

View File

@@ -23,6 +23,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.decompiler.graph.TypeItem;
import java.util.ArrayList;
import java.util.List;
/**
@@ -59,4 +60,9 @@ public class OrItem extends BinaryOpItem {
public GraphTargetItem returnType() {
return TypeItem.BOOLEAN;
}
@Override
public List<GraphSourceItem> getOperatorInstruction() {
return new ArrayList<>(); //???
}
}