Fixed #1360 Precedence of increment/decrement operations

This commit is contained in:
Jindra Petřík
2021-02-11 19:10:09 +01:00
parent ac89162be0
commit b82c83c2ad
11 changed files with 149 additions and 8 deletions

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;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -34,7 +35,13 @@ public class DecrementAVM2Item extends AVM2Item {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (value.getPrecedence() > precedence) {
writer.append("(");
value.toString(writer, localData);
writer.append(")");
} else {
value.toString(writer, localData);
}
return writer.append(" - 1");
}

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;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
@@ -34,7 +35,13 @@ public class IncrementAVM2Item extends AVM2Item {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (value.getPrecedence() > precedence) {
writer.append("(");
value.toString(writer, localData);
writer.append(")");
} else {
value.toString(writer, localData);
}
return writer.append(" + 1");
}

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;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -48,7 +49,13 @@ public class DecrementActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (object.getPrecedence() > precedence) {
writer.append("(");
object.toString(writer, localData);
writer.append(")");
} else {
object.toString(writer, localData);
}
return writer.append(" - 1");
}

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;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
@@ -48,7 +49,13 @@ public class IncrementActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
if (object.getPrecedence() > precedence) {
writer.append("(");
object.toString(writer, localData);
writer.append(")");
} else {
object.toString(writer, localData);
}
return writer.append(" + 1");
}