diff --git a/CHANGELOG.md b/CHANGELOG.md index 20a936c8b..0152a0eff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. # [Unreleased] ### Fixed - AS1/2 handle declaration of registers in certain cases +- AS1/2 setProperty, getProperty handling ## [14.5.1] - 2021-11-20 ### Fixed 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 fc9be251e..bb8568713 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 @@ -56,11 +56,11 @@ public class GetPropertyActionItem extends ActionItem { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - if (isEmptyString(target)) { + /*if (isEmptyString(target)) { return writer.append(Action.propertyNames[propertyIndex]); - } + }*/ - if (!useGetPropertyFunction) { + if (!useGetPropertyFunction && !isEmptyString(target)) { target.appendToNoQuotes(writer, localData); writer.append(":"); writer.append(Action.propertyNames[propertyIndex]); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java index 35d5d89f2..fa1b4f561 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java @@ -79,10 +79,10 @@ public class SetPropertyActionItem extends ActionItem implements SetTypeActionIt @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - if (isEmptyString(target)) { + /*if (isEmptyString(target)) { writer.append(Action.propertyNames[propertyIndex]).append(" = "); return value.toString(writer, localData); - } + }*/ writer.append("setProperty"); writer.spaceBeforeCallParenthesies(3); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java index 956aed029..a2860e782 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java @@ -1554,7 +1554,9 @@ public class ActionScript2Parser { assigned = new BitXorActionItem(null, null, lhs, assigned); break; } - if (lhs instanceof VariableActionItem) { + if (lhs instanceof GetPropertyActionItem) { + lhs = new SetPropertyActionItem(null, null, ((GetPropertyActionItem) lhs).target, ((GetPropertyActionItem) lhs).propertyIndex, assigned); + } else if (lhs instanceof VariableActionItem) { if (assigned != rhs) { lhs = new VariableActionItem(((VariableActionItem) lhs).getVariableName(), assigned, false); variables.add((VariableActionItem) lhs); @@ -1898,8 +1900,12 @@ public class ActionScript2Parser { } lexer.pushback(s2); - ret = new VariableActionItem(varName, null, false); - variables.add((VariableActionItem) ret); + /*if (Action.propertyNamesList.contains(varName)) { + ret = new GetPropertyActionItem(null, null, pushConst(""), Action.propertyNamesList.indexOf(varName)); + } else {*/ + ret = new VariableActionItem(varName, null, false); + variables.add((VariableActionItem) ret); + //} allowMemberOrCall = true; } @@ -1967,7 +1973,20 @@ public class ActionScript2Parser { ret = new CallMethodActionItem(null, null, mem.object, mem.memberName, args); } else if (ret instanceof VariableActionItem) { VariableActionItem var = (VariableActionItem) ret; - ret = new CallFunctionActionItem(null, null, pushConst(var.getVariableName()), args); + + if (var.getVariableName().equals("getProperty") + && args.size() == 2 + && (args.get(1) instanceof VariableActionItem) + && (Action.propertyNamesList.contains(((VariableActionItem) args.get(1)).getVariableName()))) { + ret = new GetPropertyActionItem(null, null, args.get(0), Action.propertyNamesList.indexOf(((VariableActionItem) args.get(1)).getVariableName())); + } else if (var.getVariableName().equals("setProperty") + && args.size() == 3 + && (args.get(1) instanceof VariableActionItem) + && (Action.propertyNamesList.contains(((VariableActionItem) args.get(1)).getVariableName()))) { + ret = new SetPropertyActionItem(null, null, args.get(0), Action.propertyNamesList.indexOf(((VariableActionItem) args.get(1)).getVariableName()), args.get(2)); + } else { + ret = new CallFunctionActionItem(null, null, pushConst(var.getVariableName()), args); + } } else if (ret instanceof EvalActionItem) { EvalActionItem ev = (EvalActionItem) ret; ret = new CallFunctionActionItem(null, null, ev.value, args);