From a11015e90c7654f57e97f2200ce88555b7c888c3 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Thu, 26 Feb 2015 12:39:41 +0100 Subject: [PATCH] #816 P-code not shown after selecting "class initializer" trait fixed --- .../decompiler/flash/abc/ScriptPack.java | 9 ++++- .../flash/abc/types/MethodBody.java | 4 +-- .../flash/abc/types/traits/TraitClass.java | 3 +- .../abc/usages/ConstVarMultinameUsage.java | 6 ++-- .../abc/usages/MethodMultinameUsage.java | 6 ++-- .../jpexs/decompiler/flash/action/Action.java | 4 +-- .../jpexs/decompiler/flash/gui/MainPanel.java | 10 ------ src/com/jpexs/decompiler/flash/gui/View.java | 4 +-- .../flash/gui/abc/DecompiledEditorPane.java | 35 +++++++++++-------- 9 files changed, 43 insertions(+), 38 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index 0810714aa..3077b806e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -138,8 +138,13 @@ public class ScriptPack extends AS3ClassTreeItem { } } - public void appendTo(GraphTextWriter writer, List traits, ScriptExportMode exportMode, boolean parallel) throws InterruptedException { + private void appendTo(GraphTextWriter writer, List traits, ScriptExportMode exportMode, boolean parallel) throws InterruptedException { + boolean first = true; for (int t : traitIndices) { + if (!first) { + writer.newLine(); + } + Trait trait = traits.get(t); Multiname name = trait.getName(abc); Namespace ns = name.getNamespace(abc.constants); @@ -148,6 +153,8 @@ public class ScriptPack extends AS3ClassTreeItem { } else { trait.toString(null, "", abc, false, exportMode, scriptIndex, -1, writer, new ArrayList(), parallel); } + + first = false; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 692690738..b416ee26f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -208,9 +208,9 @@ public final class MethodBody implements Cloneable { throw ex; } catch (Exception | OutOfMemoryError | StackOverflowError ex) { if (ex instanceof TimeoutException) { - Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error in " + path, ex); - } else { Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation timeout in " + path, ex); + } else { + Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error in " + path, ex); } convertException = ex; Throwable cause = ex.getCause(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 1e83e6fd8..cf239e5dc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -361,7 +361,6 @@ public class TraitClass extends Trait implements TraitWithSlot { @Override public GraphTextWriter toString(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { - writer.startClass(class_info); String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants, false); //assume not null name List namesInThisPackage = new ArrayList<>(); for (ABCContainerTag tag : abc.getAbcTags()) { @@ -448,6 +447,8 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.newLine(); } + writer.startClass(class_info); + //class header abc.instance_info.get(class_info).getClassHeaderStr(writer, abc, fullyQualifiedNames, false); writer.startBlock(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java index 91ab56549..b298f368f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java @@ -1,16 +1,16 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. */ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java index 0a008f349..0699568a3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java @@ -1,16 +1,16 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. */ diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 470ab6d27..7137b6b02 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -720,9 +720,9 @@ public abstract class Action implements GraphSourceItem { throw ex; } catch (Exception | OutOfMemoryError | StackOverflowError ex) { if (ex instanceof TimeoutException) { - logger.log(Level.SEVERE, "Decompilation error in: " + path, ex); - } else { logger.log(Level.SEVERE, "Decompilation timeout in: " + path, ex); + } else { + logger.log(Level.SEVERE, "Decompilation error in: " + path, ex); } convertException = ex; Throwable cause = ex.getCause(); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 8d054718f..7c3f74bc6 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -25,7 +25,6 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.RenameType; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.types.traits.Trait; -import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.configuration.ConfigurationItem; import com.jpexs.decompiler.flash.dumpview.DumpInfo; @@ -2422,19 +2421,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec @Override protected Void doInBackground() throws Exception { - int classIndex = -1; - for (Trait t : scriptLeaf.abc.script_info.get(scriptLeaf.scriptIndex).traits.traits) { - if (t instanceof TraitClass) { - classIndex = ((TraitClass) t).class_info; - break; - } - } getABCPanel().detailPanel.methodTraitPanel.methodCodePanel.clear(); getABCPanel().navigator.setAbc(scriptLeaf.abc); - getABCPanel().navigator.setClassIndex(classIndex, scriptLeaf.scriptIndex); getABCPanel().setAbc(scriptLeaf.abc); getABCPanel().decompiledTextArea.setScript(scriptLeaf); - getABCPanel().decompiledTextArea.setClassIndex(classIndex); getABCPanel().decompiledTextArea.setNoTrait(); return null; } diff --git a/src/com/jpexs/decompiler/flash/gui/View.java b/src/com/jpexs/decompiler/flash/gui/View.java index 4c49a97cc..3ad442bc0 100644 --- a/src/com/jpexs/decompiler/flash/gui/View.java +++ b/src/com/jpexs/decompiler/flash/gui/View.java @@ -377,7 +377,7 @@ public class View { return ret[0]; } - public static int showConfirmDialog(final Component parentComponent, final Object message, final String title, final int optionType) { + public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) { return showConfirmDialog(parentComponent, message, title, optionType, JOptionPane.PLAIN_MESSAGE); } @@ -392,7 +392,7 @@ public class View { return ret[0]; } - public static int showConfirmDialog(final Component parentComponent, String message, final String title, final int optionType, ConfigurationItem showAgainConfig, int defaultOption) { + public static int showConfirmDialog(Component parentComponent, String message, String title, int optionType, ConfigurationItem showAgainConfig, int defaultOption) { return showConfirmDialog(parentComponent, message, title, optionType, JOptionPane.PLAIN_MESSAGE, showAgainConfig, defaultOption); } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 9f6861dfb..1ada9ccd1 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -552,6 +552,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } if (classIndex == -1) { + abcPanel.navigator.setClassIndex(-1, script.scriptIndex); setNoTrait(); return; } @@ -599,13 +600,13 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL public void gotoTrait(int traitId) { if (traitId == -1) { - setCaretPosition(0); return; } Highlighting tc = Highlighting.searchIndex(classHighlights, classIndex); if (tc != null) { Highlighting th = Highlighting.searchIndex(traitHighlights, traitId, tc.startPos, tc.startPos + tc.len); + int pos; if (th != null) { ignoreCarret = true; int startPos = th.startPos + th.len - 1; @@ -613,20 +614,21 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL setCaretPosition(startPos); } ignoreCarret = false; - final int pos = th.startPos; - new Timer().schedule(new TimerTask() { - @Override - public void run() { - if (pos <= getDocument().getLength()) { - setCaretPosition(pos); - } - } - }, 100); - return; + pos = th.startPos; + } else { + pos = tc.startPos; } - } - setCaretPosition(0); + final int fpos = pos; + new Timer().schedule(new TimerTask() { + @Override + public void run() { + if (fpos <= getDocument().getLength()) { + setCaretPosition(fpos); + } + } + }, 100); + } } public DecompiledEditorPane(ABCPanel abcPanel) { @@ -661,14 +663,19 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL cd = SWF.getCached(scriptLeaf); } catch (InterruptedException ex) { } + if (cd != null) { - final String hilightedCode = cd.text; + String hilightedCode = cd.text; highlights = cd.getInstructionHighlights(); specialHighlights = cd.getSpecialHighligths(); traitHighlights = cd.getTraitHighlights(); methodHighlights = cd.getMethodHighlights(); classHighlights = cd.getClassHighlights(); setText(hilightedCode); + + if (classHighlights.size() > 0) { + setCaretPosition(classHighlights.get(0).startPos); + } } fireScript(); }