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 dd25c5a53..fbd884ea8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -366,6 +366,21 @@ public final class SWF implements SWFContainerItem, Timelined { return jtt; } + public String getDocumentClass() { + for (Tag t : tags) { + if (t instanceof SymbolClassTag) { + SymbolClassTag sc = (SymbolClassTag) t; + for (int i = 0; i < sc.tags.length; i++) { + if (sc.tags[i] == 0) { + return sc.names[i]; + } + } + } + } + + return null; + } + public void fixCharactersOrder(boolean checkAll) { Set addedCharacterIds = new HashSet<>(); Set movedTags = new HashSet<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index 6b4746647..22853cc57 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -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; import com.jpexs.decompiler.flash.EventListener; @@ -1193,20 +1194,8 @@ public class ABC { String scriptName = pack.getPathScriptName() + ".as"; int oldIndex = pack.scriptIndex; int newIndex = script_info.size(); - String documentClass = ""; - loopt: - for (Tag t : swf.tags) { - if (t instanceof SymbolClassTag) { - SymbolClassTag sc = (SymbolClassTag) t; - for (int i = 0; i < sc.tags.length; i++) { - if (sc.tags[i] == 0) { - documentClass = sc.names[i]; - break loopt; - } - } - } - } - boolean isDocumentClass = documentClass.equals(pack.getClassPath().toString()); + String documentClass = swf.getDocumentClass(); + boolean isDocumentClass = documentClass != null && documentClass.equals(pack.getClassPath().toString()); ScriptInfo si = script_info.get(oldIndex); si.delete(this, true); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index 53e01de8f..0c8ca5b72 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -1492,14 +1492,20 @@ public class AVM2SourceGenerator implements SourceGenerator { for (AssignableAVM2Item an : subvariables) { if (an instanceof NameAVM2Item) { NameAVM2Item n = (NameAVM2Item) an; - if (n.getVariableName() != null) { - if (!n.getVariableName().equals("this") && needsActivation) { + String variableName = n.getVariableName(); + if (variableName != null) { + boolean isThisOrSuper = variableName.equals("this") || variableName.equals("super"); + if (!isThisOrSuper && needsActivation) { if (n.getSlotNumber() <= 0) { - n.setSlotNumber(slotNames.indexOf(n.getVariableName())); + n.setSlotNumber(slotNames.indexOf(variableName)); n.setSlotScope(slotScope); } } else { - n.setRegNumber(registerNames.indexOf(n.getVariableName())); + if (isThisOrSuper) { + n.setRegNumber(0); + } else { + n.setRegNumber(registerNames.indexOf(variableName)); + } } } } @@ -1553,7 +1559,8 @@ public class AVM2SourceGenerator implements SourceGenerator { continue; } - if ("this".equals(n.getVariableName()) || paramNames.contains(n.getVariableName()) || "argmuments".equals(n.getVariableName())) { + String variableName = n.getVariableName(); + if ("this".equals(variableName) || "super".equals(variableName) || paramNames.contains(variableName) || "argmuments".equals(variableName)) { continue; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java index 726d82561..1704bb1a9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java @@ -12,15 +12,19 @@ * 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.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropVoidIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropertyIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallSuperVoidIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrictIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetGlobalScopeIns; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; @@ -133,8 +137,14 @@ public class CallAVM2Item extends AVM2Item { if (obj == null) { obj = new AVM2Instruction(0, new FindPropertyStrictIns(), new int[]{propIndex}); } + + boolean isSuper = (obj instanceof NameAVM2Item) && "super".equals(((NameAVM2Item) obj).getVariableName()); + + InstructionDefinition insDef = isSuper ? + (needsReturn ? new CallSuperIns() : new CallSuperVoidIns()) : + (needsReturn ? new CallPropertyIns() : new CallPropVoidIns()); return toSourceMerge(localData, generator, obj, arguments, - ins(needsReturn ? new CallPropertyIns() : new CallPropVoidIns(), propIndex, arguments.size()) + ins(insDef, propIndex, arguments.size()) ); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java index 858a00e6c..2d6aff696 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java @@ -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.parser.script; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -22,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns; +import com.jpexs.decompiler.flash.abc.avm2.model.CallSuperAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; @@ -427,7 +429,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } } - if (parts.get(0).equals("this")) { + if (parts.get(0).equals("this") || parts.get(0).equals("super")) { if (thisType == null) { throw new CompilationException("Cannot use this in that context", line); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 0d5c12645..e3a6141fc 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -81,7 +81,6 @@ import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.DefineSoundTag; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.FileAttributesTag; -import com.jpexs.decompiler.flash.tags.SymbolClassTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.BoundedTag; @@ -1094,19 +1093,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (swf == null) { return; } - String documentClass = null; - loopdc: - for (Tag t : swf.tags) { - if (t instanceof SymbolClassTag) { - SymbolClassTag sc = (SymbolClassTag) t; - for (int i = 0; i < sc.tags.length; i++) { - if (sc.tags[i] == 0) { - documentClass = sc.names[i]; - break loopdc; - } - } - } - } + String documentClass = swf.getDocumentClass(); if (documentClass != null && !Configuration.dumpView.get()) { showDetail(DETAILCARDAS3NAVIGATOR); showCard(CARDACTIONSCRIPT3PANEL);