From f7bac4eb8e11880fc83263a5bec215dc214bd5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 16 Jun 2013 17:04:28 +0200 Subject: [PATCH] #102 Fixed highlighting in export --- .../decompiler/flash/abc/types/traits/TraitClass.java | 10 ++++++++-- .../abc/types/traits/TraitMethodGetterSetter.java | 8 ++++---- .../decompiler/flash/abc/types/traits/Traits.java | 2 +- .../jpexs/decompiler/flash/helpers/Highlighting.java | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) 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 515e4005a..e92a7ddaf 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 @@ -309,7 +309,7 @@ public class TraitClass extends Trait implements TraitWithSlot { public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int scriptIndex, int classIndex, boolean highlight, List fullyQualifiedNames) { if (!highlight) { - Highlighting.doHighlight = false; + //Highlighting.doHighlight = false; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream out = null; @@ -408,6 +408,9 @@ public class TraitClass extends Trait implements TraitWithSlot { if (bodyIndex != -1) { if (Configuration.DO_DECOMPILE) { bodyStr = abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits); + if (!highlight) { + bodyStr = Highlighting.stripHilights(bodyStr); + } } } if (Highlighting.stripHilights(bodyStr).equals("")) { @@ -444,6 +447,9 @@ public class TraitClass extends Trait implements TraitWithSlot { if (bodyIndex != -1) { if (Configuration.DO_DECOMPILE) { bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, scriptIndex, class_info, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3); + if (!highlight) { + bodyStr = Highlighting.stripHilights(bodyStr); + } } constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, abc.bodies[bodyIndex], abc, fullyQualifiedNames); } else { @@ -485,7 +491,7 @@ public class TraitClass extends Trait implements TraitWithSlot { out.println(bui.toString()); out.println(ABC.IDENT_STRING + "}");//class out.flush(); - Highlighting.doHighlight = true; + //Highlighting.doHighlight = true; try { if (highlight) { return Highlighting.hilighClass(new String(baos.toByteArray(), "UTF-8"), class_info); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index 11b5bd71e..84978c0a0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -64,11 +64,11 @@ public class TraitMethodGetterSetter extends Trait { String bodyStr = ""; int bodyIndex = abc.findBodyIndex(method_info); if ((bodyIndex != -1) && (Configuration.DO_DECOMPILE)) { - try{ - bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, null), 3); - }catch(StackOverflowError er){ + try { + bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, scriptIndex, classIndex, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, null), 3); + } catch (StackOverflowError er) { er.printStackTrace(); - bodyStr="//StackOverflowError"; + bodyStr = "//StackOverflowError"; } } return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java index b247d3f71..10c909087 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java @@ -128,7 +128,7 @@ public class Traits implements Serializable { Future future = executor.submit(new TraitConvertTask(traits[t], makePackages, path, abcTags, abc, isStatic, pcode, scriptIndex, classIndex, highlighting, fullyQualifiedNames, t)); futureResults.add(future); } - + for (int f = 0; f < futureResults.size(); f++) { if (f > 0) { s += "\r\n\r\n"; diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/Highlighting.java b/trunk/src/com/jpexs/decompiler/flash/helpers/Highlighting.java index 2fd8497ab..ad769bd10 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/Highlighting.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/Highlighting.java @@ -45,7 +45,7 @@ public class Highlighting implements Serializable { /** * Turn hignlighting on/off */ - public static boolean doHighlight = true; + private static boolean doHighlight = true; /** * Returns a string representation of the object