diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index 29f6b20c5..6ffa82de9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -133,13 +133,12 @@ public class MethodBody implements Cloneable, Serializable { //try { s += deobfuscated.toSource(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, b, hilight, getLocalRegNames(abc), scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap(), deobfuscated.visitCode(b)); s = s.trim(); + if (s.equals("")) { + s = " "; + } if (hilight) { s = Highlighting.hilighMethod(s, this.method_info); } - /*} catch (Exception|StackOverflowError|OutOfMemoryError er) { - Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Error during decompilation", er); - s = "//error:" + er.toString(); - }*/ } return s; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 342c9685a..75936a86c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -449,8 +449,8 @@ public class TraitClass extends Trait implements TraitWithSlot { bodyStr = Highlighting.stripHilights(bodyStr); } } - if (Highlighting.stripHilights(bodyStr).equals("")) { - toPrint = ABC.addTabs(bodyStr, 3); + if (Highlighting.stripHilights(bodyStr).trim().equals("")) { + toPrint = ABC.addTabs(bodyStr + "/*classInitializer*/", 3); } else { toPrint = ABC.IDENT_STRING + ABC.IDENT_STRING + "{\r\n" + ABC.addTabs(bodyStr, 3) + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"; } @@ -508,11 +508,15 @@ public class TraitClass extends Trait implements TraitWithSlot { String glue = "\r\n\r\n"; for (String s : outTraits) { if (!Highlighting.stripHilights(s).trim().equals("")) { - if (!first) { - - bui.append(glue); + if (s.contains("/*classInitializer*/")) { + s = s.replace("/*classInitializer*/", ""); + s = s + "\r\n"; } else { - first = false; + if (!first) { + bui.append(glue); + } else { + first = false; + } } } else { s = s.replace(ABC.IDENT_STRING, ""); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index 2ecbbae77..6ae526a49 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -806,37 +806,6 @@ public class Action implements GraphSourceItem { while (ip <= end) { long addr = ip2adr(actions, ip, version); - /*if (unknownJumps.contains(addr)) { - unknownJumps.remove(new Long(addr)); - boolean switchFound = false; - for (int i = output.size() - 1; i >= 0; i--) { - if (output.get(i) instanceof SwitchActionItem) { - if (((SwitchActionItem) output.get(i)).defaultCommands == null) { - List continues = ((SwitchActionItem) output.get(i)).getContinues(); - boolean breakFound = false; - for (ContinueActionItem cti : continues) { - if (cti.loopPos == addr) { - cti.isKnown = true; - cti.isBreak = true; - ((SwitchActionItem) output.get(i)).loopBreak = addr; - breakFound = true; - } - } - if (breakFound) { - switchFound = true; - ((SwitchActionItem) output.get(i)).defaultCommands = new ArrayList(); - for (int k = i + 1; k < output.size(); k++) { - ((SwitchActionItem) output.get(i)).defaultCommands.add(output.remove(i + 1)); - } - } - } - break; - } - } - if (!switchFound) { - throw new UnknownJumpException(stack, addr, output); - } - }*/ if (ip > end) { break; } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index f0e055a24..c95c98515 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -187,7 +187,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } for (Highlighting tm : methodHighlights) { - if ((pos >= tm.startPos) && (pos < tm.startPos + tm.len)) { + if ((pos >= tm.startPos) && ((pos < tm.startPos + tm.len) || (tm.len == 0 && pos == tm.startPos))) { String name = ""; if (abc != null) { if (classIndex > -1) { @@ -226,7 +226,8 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL Trait tr = abc.findTraitByTraitId(classIndex, (int) th.offset); if (tr != null) { if (tr instanceof TraitSlotConst) { - abcPanel.detailPanel.slotConstTraitPanel.load((TraitSlotConst) tr, abc); + abcPanel.detailPanel.slotConstTraitPanel.load((TraitSlotConst) tr, abc, + abc.isStaticTraitId(classIndex, lastTraitIndex)); abcPanel.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD, tr); abcPanel.detailPanel.setEditMode(false); return; @@ -379,7 +380,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL View.execInEventDispatch(new Runnable() { @Override public void run() { - if (hilightedCode.length() > 65000) { + if (hilightedCode.length() > 1000000) { setContentType("text/plain"); } else { setContentType("text/actionscript"); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java index b51dc6d0e..2369fac66 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java @@ -24,8 +24,13 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; import com.jpexs.decompiler.flash.helpers.Helper; import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; import java.util.ArrayList; import javax.swing.*; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; import jsyntaxpane.syntaxkits.Flasm3MethodInfoSyntaxKit; /** @@ -37,18 +42,31 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { public JEditorPane slotConstEditor; private ABC abc; private TraitSlotConst trait; + private JTextPane warnLabel; public SlotConstTraitDetailPanel() { slotConstEditor = new JEditorPane(); setLayout(new BorderLayout()); add(new JLabel(translate("abc.detail.slotconst.typevalue")), BorderLayout.NORTH); add(new JScrollPane(slotConstEditor), BorderLayout.CENTER); + warnLabel = new JTextPane(); + warnLabel.setText("WARNING:\nStatic fields and consts are often initialized in initializers.\nEditing value here is usually not enough!"); + StyledDocument doc = warnLabel.getStyledDocument(); + SimpleAttributeSet center = new SimpleAttributeSet(); + StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER); + doc.setParagraphAttributes(0, doc.getLength(), center, false); + warnLabel.setOpaque(false); + warnLabel.setFocusable(false); + //warnLabel.setWrapStyleWord(true); + //warnLabel.setLineWrap(true); + warnLabel.setFont(new JLabel().getFont().deriveFont(Font.BOLD)); + add(warnLabel, BorderLayout.SOUTH); slotConstEditor.setContentType("text/flasm3_methodinfo"); Flasm3MethodInfoSyntaxKit sk = (Flasm3MethodInfoSyntaxKit) slotConstEditor.getEditorKit(); sk.deinstallComponent(slotConstEditor, "jsyntaxpane.components.LineNumbersRuler"); } - public void load(TraitSlotConst trait, ABC abc) { + public void load(TraitSlotConst trait, ABC abc, boolean isStatic) { this.abc = abc; this.trait = trait; String s; @@ -65,6 +83,7 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { s = typeStr + valueStr; + warnLabel.setVisible(trait.isConst() || isStatic); slotConstEditor.setText(s); }