diff --git a/CHANGELOG.md b/CHANGELOG.md index e76a6dfe8..f9f06ad8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. ### Fixed - [#2375] Added limit of simultaneously played sounds +- AS1/2 - Push action hilighting, GetProperty, Call action hilighting ## [22.0.1] - 2024-11-20 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 481083024..66e94c0cf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -4266,8 +4266,8 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { pu.replacement = new ArrayList<>(); pu.replacement.addAll(pu.values); } - if (pu.replacement.get(it.getKey().pos) instanceof ConstantIndex) { - ConstantIndex ci = (ConstantIndex) pu.replacement.get(it.getKey().pos); + if (pu.replacement.get(it.getKey().getPos()) instanceof ConstantIndex) { + ConstantIndex ci = (ConstantIndex) pu.replacement.get(it.getKey().getPos()); ConstantPool pool = it.getValue(); if (pool == null) { continue; @@ -4286,7 +4286,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable { } } } else { - pu.replacement.set(it.getKey().pos, changed); + pu.replacement.set(it.getKey().getPos(), changed); } ret++; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/ActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/ActionItem.java index 8c8ed1b89..3d50a57d2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/ActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/ActionItem.java @@ -96,7 +96,10 @@ public abstract class ActionItem extends GraphTargetItem implements Serializable protected GraphTextWriter stripQuotes(GraphTargetItem target, LocalData localData, GraphTextWriter writer) throws InterruptedException { if (target instanceof DirectValueActionItem) { if (((DirectValueActionItem) target).value instanceof String) { - return writer.append((String) ((DirectValueActionItem) target).value); + DirectValueActionItem dv = (DirectValueActionItem) target; + + //dv.toStringNoQuotes(writer, localData); + return writer.append((String) dv.value); } } if (target == null) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/CallActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/CallActionItem.java index e99c68fb8..e75fe4cce 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/CallActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/CallActionItem.java @@ -50,7 +50,7 @@ public class CallActionItem extends ActionItem { writer.append("call"); writer.spaceBeforeCallParenthesis(1); writer.append("("); - value.appendTo(writer, localData); + value.toString(writer, localData); return writer.append(")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index 47f737a7c..f54c465b0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -61,10 +61,6 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { */ public GraphTargetItem computedRegValue; - /** - * Position. - */ - public final int pos; /** * Constructor. @@ -91,11 +87,6 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { this.pos = instructionPos; } - @Override - protected int getPos() { - return pos; - } - @Override public boolean isVariableComputed() { return (computedRegValue != null); @@ -224,7 +215,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { HighlightData srcData = getSrcData(); srcData.localName = ((RegisterNumber) value).translate(); srcData.regIndex = ((RegisterNumber) value).number; - + return writer.appendWithData(IdentifiersDeobfuscation.printIdentifier(false, ((RegisterNumber) value).translate()), srcData); } return writer.append(EcmaScript.toString(value)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetPropertyActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetPropertyActionItem.java index b64f3c75a..4655c109a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetPropertyActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetPropertyActionItem.java @@ -88,7 +88,7 @@ public class GetPropertyActionItem extends ActionItem { writer.append("getProperty"); writer.spaceBeforeCallParenthesis(2); writer.append("("); - target.appendTo(writer, localData); + target.toString(writer, localData); writer.append(", "); writer.append(Action.propertyNames[propertyIndex]); writer.append(")"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java index b82e70016..193e87c57 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java @@ -109,7 +109,7 @@ public class GetVariableActionItem extends ActionItem { HighlightData srcData = getSrcData(); srcData.localName = name.toStringNoQuotes(localData); return stripQuotes(name, localData, writer); - } else { + } else { writer.append("eval("); name.appendTry(writer, localData); return writer.append(")"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/UnresolvedConstantActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/UnresolvedConstantActionItem.java index 4f518fcb1..f575807cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/UnresolvedConstantActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/UnresolvedConstantActionItem.java @@ -44,11 +44,6 @@ public class UnresolvedConstantActionItem extends ActionItem implements SimpleVa */ public GraphTargetItem computedRegValue; - /** - * Position - */ - public final int pos; - /** * Index */ @@ -76,11 +71,7 @@ public class UnresolvedConstantActionItem extends ActionItem implements SimpleVa this.index = index; this.pos = instructionPos; } - - @Override - protected int getPos() { - return pos; - } + @Override public boolean isVariableComputed() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index f7111b1c9..51cb95597 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -417,7 +417,7 @@ public class ActionPush extends Action { if (i > 0) { writer.appendNoHilight(", "); } - writer.append(toString(i), getAddress() + i + 1, getFileOffset()); + writer.append(toString(i), getAddress() + i, getFileOffset()); } return writer; } @@ -489,47 +489,51 @@ public class ActionPush extends Action { public void translate(Map> uninitializedClassTraits, SecondPassData secondPassData, boolean insideDoInitAction, GraphSourceItem lineStartAction, TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { int pos = 0; for (Object o : values) { + GraphTargetItem toPush = null; if (o instanceof ConstantIndex) { if ((constantPool == null) || (((ConstantIndex) o).index >= constantPool.size())) { - stack.push(new UnresolvedConstantActionItem(((ConstantIndex) o).index)); - continue; + toPush = new UnresolvedConstantActionItem(((ConstantIndex) o).index); } else { o = constantPool.get(((ConstantIndex) o).index); } } - if (o instanceof Boolean) { - Boolean b = (Boolean) o; - if (b) { - stack.push(new TrueItem(this, lineStartAction)); - } else { - stack.push(new FalseItem(this, lineStartAction)); - } - } else { - DirectValueActionItem dvt = new DirectValueActionItem(this, lineStartAction, pos, o, constantPool); - - if (o instanceof RegisterNumber) { //TemporaryRegister - dvt.computedRegValue = variables.get("__register" + ((RegisterNumber) o).number); - if (regNames.containsKey(((RegisterNumber) o).number)) { - ((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number); + if (toPush == null) { + if (o instanceof Boolean) { + Boolean b = (Boolean) o; + if (b) { + toPush = new TrueItem(this, lineStartAction); + } else { + toPush = new FalseItem(this, lineStartAction); } - } - if (dvt.computedRegValue instanceof TemporaryRegister) { - ((TemporaryRegister) dvt.computedRegValue).used = true; - for (int i = 0; i < output.size(); i++) { - if (output.get(i) instanceof TemporaryRegisterMark) { - TemporaryRegisterMark trm = (TemporaryRegisterMark) output.get(i); - if (trm.tempReg == dvt.computedRegValue) { - output.remove(i); - break; - } + } else { + DirectValueActionItem dvt = new DirectValueActionItem(this, lineStartAction, pos, o, constantPool); + + if (o instanceof RegisterNumber) { //TemporaryRegister + dvt.computedRegValue = variables.get("__register" + ((RegisterNumber) o).number); + if (regNames.containsKey(((RegisterNumber) o).number)) { + ((RegisterNumber) o).name = regNames.get(((RegisterNumber) o).number); } } - stack.push(new TemporaryRegister(((RegisterNumber) o).number, ((TemporaryRegister) dvt.computedRegValue).value)); - } else { - stack.push(dvt); + if (dvt.computedRegValue instanceof TemporaryRegister) { + ((TemporaryRegister) dvt.computedRegValue).used = true; + for (int i = 0; i < output.size(); i++) { + if (output.get(i) instanceof TemporaryRegisterMark) { + TemporaryRegisterMark trm = (TemporaryRegisterMark) output.get(i); + if (trm.tempReg == dvt.computedRegValue) { + output.remove(i); + break; + } + } + } + toPush = new TemporaryRegister(((RegisterNumber) o).number, ((TemporaryRegister) dvt.computedRegValue).value); + } else { + toPush = dvt; + } } } - pos++; + toPush.setPos(pos); + stack.push(toPush); + pos++; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java index 2cee054f7..29bde9b25 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java @@ -131,6 +131,11 @@ public abstract class GraphTargetItem implements Serializable, Cloneable { * Line start item */ public GraphSourceItem lineStartItem; + + /** + * ASM Position + */ + protected int pos = 0; /** * Gets the line start item @@ -362,8 +367,16 @@ public abstract class GraphTargetItem implements Serializable, Cloneable { * * @return Position */ - protected int getPos() { - return 0; + public int getPos() { + return pos; + } + + /** + * Sets position + * @param pos Position + */ + public void setPos(int pos) { + this.pos = pos; } /**