Added AS3 support for logical AND/OR compound operator

This commit is contained in:
Jindra Petřík
2023-03-19 22:43:41 +01:00
parent e75991bee5
commit 9e6fa2e75b
32 changed files with 706 additions and 568 deletions
@@ -127,8 +127,8 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
SetLocalAVM2Item result = new SetLocalAVM2Item(ins, localData.lineStartInstruction, regId, value, value.returnType());
if (value.getNotCoerced() instanceof CompoundableBinaryOp) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoerced();
if (binaryOp.getLeftSide() instanceof LocalRegAVM2Item) {
LocalRegAVM2Item loc = (LocalRegAVM2Item) binaryOp.getLeftSide();
if (binaryOp.getLeftSide().getNotCoerced() instanceof LocalRegAVM2Item) {
LocalRegAVM2Item loc = (LocalRegAVM2Item) binaryOp.getLeftSide().getNotCoerced();
if (loc.regIndex == regId) {
result.setCompoundValue(binaryOp.getRightSide());
result.setCompoundOperator(binaryOp.getOperator());
@@ -78,8 +78,8 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
if (setLocName.regIndex == locName.regIndex) {
if (setLocVal.value instanceof CompoundableBinaryOp) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) setLocVal.value;
if (binaryOp.getLeftSide() instanceof GetPropertyAVM2Item) {
GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) binaryOp.getLeftSide();
if (binaryOp.getLeftSide().getNotCoerced() instanceof GetPropertyAVM2Item) {
GetPropertyAVM2Item getProp = (GetPropertyAVM2Item) binaryOp.getLeftSide().getNotCoerced();
if (((FullMultinameAVM2Item) getProp.propertyName).compareSame(multiname) && Objects.equals(getProp.object, obj)) {
multiname.name = setLocName.value;
result.setCompoundValue(binaryOp.getRightSide());
@@ -158,8 +158,8 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
if (value.getNotCoerced() instanceof CompoundableBinaryOp) {
if (!obj.hasSideEffect()) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoerced();
if (binaryOp.getLeftSide() instanceof GetSlotAVM2Item) {
GetSlotAVM2Item getSlot = (GetSlotAVM2Item) binaryOp.getLeftSide();
if (binaryOp.getLeftSide().getNotCoerced() instanceof GetSlotAVM2Item) {
GetSlotAVM2Item getSlot = (GetSlotAVM2Item) binaryOp.getLeftSide().getNotCoerced();
if (Objects.equals(obj, getSlot.scope.getThroughDuplicate()) && slotIndex == getSlot.slotIndex) {
result.compoundValue = binaryOp.getRightSide();
result.compoundOperator = binaryOp.getOperator();
@@ -61,8 +61,8 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns {
if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) {
if (!obj.hasSideEffect() && !multiname.hasSideEffect()) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup();
if (binaryOp.getLeftSide() instanceof GetSuperAVM2Item) {
GetSuperAVM2Item getSuper = (GetSuperAVM2Item) binaryOp.getLeftSide();
if (binaryOp.getLeftSide().getNotCoerced() instanceof GetSuperAVM2Item) {
GetSuperAVM2Item getSuper = (GetSuperAVM2Item) binaryOp.getLeftSide().getNotCoerced();
if (Objects.equals(obj, getSuper.object.getThroughDuplicate()) && Objects.equals(multiname, getSuper.propertyName)) {
result.setCompoundValue(binaryOp.getRightSide());
result.setCompoundOperator(binaryOp.getOperator());
@@ -2133,11 +2133,10 @@ public class ActionScript3Parser {
case ASSIGN_SHIFT_RIGHT:
case ASSIGN_USHIFT_RIGHT:
case ASSIGN_XOR:
case ASSIGN_AND:
case ASSIGN_OR:
GraphTargetItem assigned = rhs;
switch (op.type) {
case ASSIGN:
//assigned = assigned;
break;
switch (op.type) {
case ASSIGN_BITAND:
assigned = new BitAndAVM2Item(null, null, lhs, assigned);
break;
@@ -2171,6 +2170,16 @@ public class ActionScript3Parser {
case ASSIGN_XOR:
assigned = new BitXorAVM2Item(null, null, lhs, assigned);
break;
case ASSIGN_AND:
assigned = new AndItem(null, null, lhs, assigned);
break;
case ASSIGN_OR:
assigned = new OrItem(null, null, lhs, assigned);
break;
case ASSIGN:
default:
//assigned = assigned;
break;
}
if (!(lhs instanceof AssignableAVM2Item)) {
@@ -118,6 +118,8 @@ public enum SymbolType {
ASSIGN_SHIFT_LEFT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_SHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_USHIFT_RIGHT(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_AND(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
ASSIGN_OR(GraphTargetItem.PRECEDENCE_ASSIGMENT, true, true),
AS(GraphTargetItem.PRECEDENCE_RELATIONAL, true),
DELETE(GraphTargetItem.PRECEDENCE_UNARY, false),
INSTANCEOF(GraphTargetItem.PRECEDENCE_RELATIONAL, true),