diff --git a/CHANGELOG.md b/CHANGELOG.md index dfd2b2a6f..7d8e58ac8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. - [#2394] FLA export - shape tweens in some cases - Not resetting timeline after shape tag type conversion - [#2400] Transforming - buttons must use hit test frame outline +- [#2413] AS3 direct editation - try/catch clause in instance initializer ## [22.0.2] - 2025-01-17 ### Added @@ -3721,6 +3722,7 @@ Major version of SWF to XML export changed to 2. [#2416]: https://www.free-decompiler.com/flash/issues/2416 [#2394]: https://www.free-decompiler.com/flash/issues/2394 [#2400]: https://www.free-decompiler.com/flash/issues/2400 +[#2413]: https://www.free-decompiler.com/flash/issues/2413 [#2375]: https://www.free-decompiler.com/flash/issues/2375 [#2374]: https://www.free-decompiler.com/flash/issues/2374 [#2389]: https://www.free-decompiler.com/flash/issues/2389 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 6affadcd2..7adba9732 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 @@ -826,7 +826,6 @@ public class AVM2SourceGenerator implements SourceGenerator { } } - //List cinitcode = new ArrayList<>(); List initcode = new ArrayList<>(); for (GraphTargetItem ti : commands) { if ((ti instanceof SlotAVM2Item) || (ti instanceof ConstAVM2Item)) { @@ -854,13 +853,6 @@ public class AVM2SourceGenerator implements SourceGenerator { continue; } } - /*if (isStatic && val != null) { - cinitcode.add(ins(AVM2Instructions.FindProperty, traitName(ns, tname))); - localData.isStatic = true; - cinitcode.addAll(toInsList(val.toSource(localData, this))); - cinitcode.add(ins(isConst ? AVM2Instructions.InitProperty : AVM2Instructions.SetProperty, traitName(ns, tname))); - } - */ if (!isStatic && val != null) { //do not init basic values, that can be stored in trait if (!(val instanceof IntegerValueAVM2Item) @@ -881,11 +873,18 @@ public class AVM2SourceGenerator implements SourceGenerator { MethodBody initBody = null; if (!isInterface) { initBody = abcIndex.getSelectedAbc().findBody(init); + + int len = 0; + for (AVM2Instruction ins : initcode) { + len += ins.getBytesLength(); + } + initBody.getCode().code.addAll(iinit == null ? 0 : 2, initcode); //after getlocal0,pushscope - - /*if (cinitBody.getCode().code.get(cinitBody.getCode().code.size() - 1).definition instanceof ReturnVoidIns) { - cinitBody.getCode().code.addAll(2, cinitcode); //after getlocal0,pushscope - }*/ + for (ABCException ex:initBody.exceptions) { + ex.start += len; + ex.end += len; + ex.target += len; + } } cinitBody.markOffsets(); cinitBody.autoFillStats(abcIndex.getSelectedAbc(), initScope + (implementsStr.isEmpty() ? 0 : 1), true);