mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-30 16:47:22 +00:00
Comma expression improvements. WIP
However, tests fail :-(
This commit is contained in:
@@ -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<GraphTargetItem> 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(")");
|
||||
}
|
||||
|
||||
@@ -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(")");
|
||||
}
|
||||
|
||||
@@ -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(")");
|
||||
}
|
||||
|
||||
@@ -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(")");
|
||||
}
|
||||
|
||||
@@ -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(")");
|
||||
}
|
||||
|
||||
@@ -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(")");
|
||||
}
|
||||
|
||||
@@ -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(")");
|
||||
}
|
||||
|
||||
@@ -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(")");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CommaExpressionItem extends GraphTargetItem {
|
||||
continue;
|
||||
}
|
||||
if (!first) {
|
||||
writer.append(", ");
|
||||
writer.allowWrapHere().append(",");
|
||||
}
|
||||
t.toString(writer, localData);
|
||||
first = false;
|
||||
|
||||
Reference in New Issue
Block a user