From e49362cf47d2bc4d522cc5bfe23448311af046db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 21 Jun 2015 15:42:24 +0200 Subject: [PATCH] AS3: Faster remove ignored without reparsing --- .../decompiler/flash/abc/avm2/AVM2Code.java | 30 +++---------------- .../AVM2DeobfuscatorRegisters.java | 2 +- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index ec330c9cc..ba0a7769e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -2525,35 +2525,13 @@ public class AVM2Code implements Cloneable { //restoreControlFlowPass(constants, body, true); } - /*private void removeIgnored(MethodBody body) { - for (int rem = code.size() - 1; rem >= 0; rem--) { - if (code.get(rem).ignored) { - removeInstruction(rem, body); - } - } - }*/ public void removeIgnored(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException { - try { - List outputMap = new ArrayList<>(); - HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); - toASMSource(constants, trait, info, body, outputMap, ScriptExportMode.PCODE, writer); - String src = writer.toString(); - AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, trait, body, info); - for (int i = 0; i < acode.code.size(); i++) { - if (outputMap.size() > i) { - int tpos = outputMap.get(i); - if (tpos == -1) { - } else if (code.get(tpos).mappedOffset >= 0) { - acode.code.get(i).mappedOffset = code.get(tpos).mappedOffset; - } else { - acode.code.get(i).mappedOffset = pos2adr(tpos); - } - } + for (int i = 0; i < code.size(); i++) { + if (code.get(i).ignored) { + removeInstruction(i, body); + i--; } - this.code = acode.code; - } catch (IOException | AVM2ParseException ex) { } - invalidateCache(); } public int removeDeadCode(AVM2ConstantPool constants, Trait trait, MethodInfo info, MethodBody body) throws InterruptedException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java index e4fe997cc..e81433260 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java @@ -233,7 +233,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { } } } catch (EmptyStackException | TranslateException | InterruptedException ex) { - ex.printStackTrace(); + //ignore } }