diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index 813e34298..c11710376 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -493,6 +493,12 @@ public abstract class InstructionDefinition implements Serializable { * @return Slot multiname or null if not found */ private static Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj, int multiNameIndex, Reference realObj) { + if (obj instanceof CommaExpressionItem) { + CommaExpressionItem ce = (CommaExpressionItem) obj; + if (!ce.commands.isEmpty()) { + obj = ce.commands.get(ce.commands.size() - 1); + } + } if ((obj instanceof ExceptionAVM2Item) && (multiNameIndex == -1 || ((ExceptionAVM2Item) obj).exception.name_index == multiNameIndex)) { return localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java index 46d013fb5..a739adbc8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java @@ -35,6 +35,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreDecrementAVM2Item import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.decompiler.graph.model.CommaExpressionItem; import com.jpexs.decompiler.graph.model.CompoundableBinaryOp; import com.jpexs.decompiler.graph.model.DuplicateItem; import com.jpexs.decompiler.graph.model.PopItem; @@ -74,8 +75,13 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S } else { localRegs.put(regId, value); }*/ - if (!(value instanceof PopItem)) { - localData.localRegs.put(regId, value); + if (value instanceof CommaExpressionItem) { + CommaExpressionItem ce = (CommaExpressionItem) value; + if (!ce.commands.isEmpty()) { + localData.localRegs.put(regId, ce.commands.get(ce.commands.size() - 1)); + } + } else if (!(value instanceof PopItem)) { + localData.localRegs.put(regId, value); } if (!localData.localRegAssignmentIps.containsKey(regId)) { localData.localRegAssignmentIps.put(regId, 0); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java index e33c74bb8..5e8a87bdb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java @@ -238,7 +238,13 @@ public class CallAVM2Item extends AVM2Item { if (a > 0) { writer.allowWrapHere().append(","); } + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append("("); + } arguments.get(a).toString(writer, localData); + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append(")"); + } } return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java index 77abf38db..5fa3489ce 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java @@ -85,7 +85,13 @@ public class CallMethodAVM2Item extends AVM2Item { if (a > 0) { writer.allowWrapHere().append(","); } + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append("("); + } arguments.get(a).toString(writer, localData); + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append(")"); + } } return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java index 649aee226..a0a4cc78f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java @@ -104,7 +104,13 @@ public class CallPropertyAVM2Item extends AVM2Item { if (a > 0) { writer.allowWrapHere().append(","); } + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append("("); + } arguments.get(a).toString(writer, localData); + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append(")"); + } } return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java index 6458d811d..a1e438f9b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java @@ -86,7 +86,13 @@ public class CallStaticAVM2Item extends AVM2Item { if (a > 0) { writer.append(","); } + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append("("); + } arguments.get(a).toString(writer, localData); + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append(")"); + } } return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java index 12827de71..e773f0d4e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java @@ -91,7 +91,13 @@ public class CallSuperAVM2Item extends AVM2Item { if (a > 0) { writer.append(","); } + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append("("); + } arguments.get(a).toString(writer, localData); + if (arguments.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append(")"); + } } return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructAVM2Item.java index 55db0972d..7bbb01ab1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructAVM2Item.java @@ -127,7 +127,13 @@ public class ConstructAVM2Item extends AVM2Item { if (a > 0) { writer.allowWrapHere().append(","); } + if (args.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append("("); + } args.get(a).toString(writer, localData); + if (args.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append(")"); + } } return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructPropAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructPropAVM2Item.java index 0aa69d86f..648adbe2f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructPropAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructPropAVM2Item.java @@ -125,7 +125,13 @@ public class ConstructPropAVM2Item extends AVM2Item { if (a > 0) { writer.allowWrapHere().append(","); } + if (args.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append("("); + } args.get(a).toString(writer, localData); + if (args.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append(")"); + } } return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java index e43207891..4e2a0a529 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java @@ -79,7 +79,13 @@ public class ConstructSuperAVM2Item extends AVM2Item { if (a > 0) { writer.allowWrapHere().append(","); } + if (args.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append("("); + } args.get(a).toString(writer, localData); + if (args.get(a).getPrecedence() >= PRECEDENCE_COMMA) { + writer.append(")"); + } } return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index 1512acd89..7cc979bbe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -3367,8 +3367,9 @@ public class Graph { } } - if (code.size() <= part.start) { + if (code.size() <= part.start) { if (!(!ret.isEmpty() && ret.get(ret.size() - 1) instanceof ExitItem)) { + stack.setConnectedOutput(0, ret); stack.addToOutput(new ScriptEndItem(dialect)); } return ret; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/CommaExpressionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/CommaExpressionItem.java index 1120c3fac..4268375e2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/CommaExpressionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/CommaExpressionItem.java @@ -65,7 +65,7 @@ public class CommaExpressionItem extends GraphTargetItem { continue; } if (!first) { - writer.append(", "); + writer.allowWrapHere().append(","); } t.toString(writer, localData); first = false;