Compound assignments inside expressions

This commit is contained in:
Jindra Petřík
2021-03-12 22:12:39 +01:00
parent 8fa321cfd3
commit 570b0f976a
5 changed files with 18 additions and 10 deletions
@@ -125,8 +125,8 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S
}
SetLocalAVM2Item result = new SetLocalAVM2Item(ins, localData.lineStartInstruction, regId, value);
if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup();
if (value.getNotCoerced() instanceof CompoundableBinaryOp) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoerced();
if (binaryOp.getLeftSide() instanceof LocalRegAVM2Item) {
LocalRegAVM2Item loc = (LocalRegAVM2Item) binaryOp.getLeftSide();
if (loc.regIndex == regId) {
@@ -376,9 +376,9 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns
}
}
if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) {
if (value.getNotCoerced() instanceof CompoundableBinaryOp) {
if (!obj.hasSideEffect() && !multiname.hasSideEffect()) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup();
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoerced();
if (binaryOp.getLeftSide() instanceof GetPropertyAVM2Item) {
GetPropertyAVM2Item propItem = (GetPropertyAVM2Item) binaryOp.getLeftSide();
if (Objects.equals(obj, propItem.object.getThroughDuplicate()) && Objects.equals(multiname, propItem.propertyName)) {
@@ -144,9 +144,9 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns {
SetSlotAVM2Item result = new SetSlotAVM2Item(ins, localData.lineStartInstruction, obj, objnoreg, slotIndex, slotname, value);
if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) {
if (value.getNotCoerced() instanceof CompoundableBinaryOp) {
if (!obj.hasSideEffect()) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup();
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoerced();
if (binaryOp.getLeftSide() instanceof GetSlotAVM2Item) {
GetSlotAVM2Item getSlot = (GetSlotAVM2Item) binaryOp.getLeftSide();
if (Objects.equals(obj, getSlot.scope.getThroughDuplicate()) && slotIndex == getSlot.slotIndex) {
@@ -117,9 +117,13 @@ public class ActionSetVariable extends Action implements StoreTypeAction {
SetVariableActionItem setVar = new SetVariableActionItem(this, lineStartAction, name, value);
GraphTargetItem ret = setVar;
if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) {
GraphTargetItem inside = value.getNotCoercedNoDup();
if (inside instanceof StoreRegisterActionItem) {
inside = inside.value;
}
if (inside instanceof CompoundableBinaryOp) {
if (!name.hasSideEffect()) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup();
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) inside;
if (binaryOp.getLeftSide() instanceof GetVariableActionItem) {
GetVariableActionItem getVar = (GetVariableActionItem) binaryOp.getLeftSide();
if (GraphTargetItem.objectsValueEquals(name, getVar.name)) {
@@ -116,9 +116,13 @@ public class ActionSetMember extends Action {
SetMemberActionItem setMem = new SetMemberActionItem(this, lineStartAction, object, memberName, value);
if (value.getNotCoercedNoDup() instanceof CompoundableBinaryOp) {
GraphTargetItem inside = value.getNotCoercedNoDup();
if (inside instanceof StoreRegisterActionItem) {
inside = inside.value;
}
if (inside instanceof CompoundableBinaryOp) {
if (!object.hasSideEffect() && !memberName.hasSideEffect()) {
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) value.getNotCoercedNoDup();
CompoundableBinaryOp binaryOp = (CompoundableBinaryOp) inside;
if (binaryOp.getLeftSide() instanceof GetMemberActionItem) {
GetMemberActionItem getMember = (GetMemberActionItem) binaryOp.getLeftSide();
if (GraphTargetItem.objectsValueEquals(object, getMember.object.getThroughDuplicate()) && GraphTargetItem.objectsValueEquals(memberName, getMember.memberName)) {