From 7588307dd0314be4e59a8d7749f2750bf3fbd1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 31 May 2025 13:02:34 +0200 Subject: [PATCH] Fixed: AS3 direct editation - Allow internal keyword on script traits (e.g. classes) --- CHANGELOG.md | 1 + .../parser/script/ActionScript3Parser.java | 18 +++++++++++++++--- .../script/ActionScript3SimpleParser.java | 19 ++++++++++++++++--- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94d9656de..745fbe523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ All notable changes to this project will be documented in this file. - [#2460] SVG export - incorrect caching colorTransform and ratio for the same tag - [#2461] SVG export - incorrect clipping / missing shapes - AS1/2 direct editation - Position in the code should stay same after clicking Edit button +- AS3 direct editation - Allow internal keyword on script traits (e.g. classes) ## [23.0.1] - 2025-05-16 ### Fixed diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java index 63c8e2054..14b2cd19d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java @@ -1101,9 +1101,10 @@ public class ActionScript3Parser { boolean isDynamic = false; boolean isPublic = false; boolean isNative = false; + boolean isInternal = false; NamespaceItem ns = packageInternalNs; List preSymbols = new ArrayList<>(); - while (s.isType(SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.PUBLIC)) { + while (s.isType(SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.PUBLIC, SymbolType.INTERNAL)) { if (s.type == SymbolType.FINAL) { if (isFinal) { throw new AVM2ParseException("Only one final keyword allowed", lexer.yyline()); @@ -1111,13 +1112,24 @@ public class ActionScript3Parser { isFinal = true; preSymbols.add(s); } + if (s.type == SymbolType.INTERNAL) { + if (!inPackage) { + throw new AVM2ParseException("internal only allowed inside package", lexer.yyline()); + } + if (isPublic || isInternal) { + throw new AVM2ParseException("Only one of public/internal keyword allowed", lexer.yyline()); + } + isInternal = true; + ns = packageInternalNs; + preSymbols.add(s); + } if (s.type == SymbolType.PUBLIC) { if (!inPackage) { throw new AVM2ParseException("public only allowed inside package", lexer.yyline()); } - if (isPublic) { - throw new AVM2ParseException("Only one public keyword allowed", lexer.yyline()); + if (isPublic || isInternal) { + throw new AVM2ParseException("Only one of public/internal keyword allowed", lexer.yyline()); } isPublic = true; ns = publicNs; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3SimpleParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3SimpleParser.java index fc69241f5..2f63b9fc8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3SimpleParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3SimpleParser.java @@ -883,8 +883,9 @@ public class ActionScript3SimpleParser implements SimpleParser { boolean isDynamic = false; boolean isPublic = false; boolean isNative = false; + boolean isInternal = false; List preSymbols = new ArrayList<>(); - while (s.isType(SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.PUBLIC)) { + while (s.isType(SymbolType.FINAL, SymbolType.DYNAMIC, SymbolType.PUBLIC, SymbolType.INTERNAL)) { if (s.type == SymbolType.FINAL) { if (isFinal) { errors.add(new SimpleParseException("Only one final keyword allowed", lexer.yyline(), s.position)); @@ -892,13 +893,25 @@ public class ActionScript3SimpleParser implements SimpleParser { isFinal = true; preSymbols.add(s); } + if (s.type == SymbolType.INTERNAL) { + if (!inPackage) { + errors.add(new SimpleParseException("internal only allowed inside package", lexer.yyline(), s.position)); + + } + if (isPublic || isInternal) { + errors.add(new SimpleParseException("Only one public/internal keyword allowed", lexer.yyline(), s.position)); + } + isInternal = true; + //ns = internalNs; + preSymbols.add(s); + } if (s.type == SymbolType.PUBLIC) { if (!inPackage) { errors.add(new SimpleParseException("public only allowed inside package", lexer.yyline(), s.position)); } - if (isPublic) { - errors.add(new SimpleParseException("Only one public keyword allowed", lexer.yyline(), s.position)); + if (isPublic || isInternal) { + errors.add(new SimpleParseException("Only one public/internal keyword allowed", lexer.yyline(), s.position)); } isPublic = true; //ns = publicNs;