From a62f1c0626915c49ac001ee3f23bb116fe57557d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 5 Mar 2023 22:57:44 +0100 Subject: [PATCH] Fixed AS3 interfaces - internal modifier on methods --- CHANGELOG.md | 1 + .../abc/avm2/parser/script/ActionScript3Parser.java | 13 +++++++------ .../decompiler/flash/abc/types/traits/Trait.java | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49a5ae572..cdc8b89bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file. - AS3 P-code ValueKind namespaces handling - AS3 direct editation - namespace definition without explicit value - AS3 direct editation - var/const outside package +- AS3 interfaces - internal modifier on methods ### Changed - AS1/2/3 P-code - format Number values with EcmaScript toString function 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 0d1261ad8..3b19824cd 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 @@ -697,27 +697,28 @@ public class ActionScript3Parser { case PUBLIC: namespace = publicNs; if (isInterface) { - throw new AVM2ParseException("Interface cannot have public, private or protected modifier", lexer.yyline()); + throw new AVM2ParseException("Interface members cannot be declared public, private, protected, or internal", lexer.yyline()); } break; case PRIVATE: isPrivate = true; namespace = privateNs; if (isInterface) { - throw new AVM2ParseException("Interface cannot have public, private or protected modifier", lexer.yyline()); + throw new AVM2ParseException("Interface members cannot be declared public, private, protected, or internal", lexer.yyline()); } break; case PROTECTED: namespace = protectedNs; if (isInterface) { - throw new AVM2ParseException("Interface cannot have public, private or protected modifier", lexer.yyline()); + throw new AVM2ParseException("Interface members cannot be declared public, private, protected, or internal", lexer.yyline()); } break; case INTERNAL: namespace = packageInternalNs; - break; - - + if (isInterface) { + throw new AVM2ParseException("Interface members cannot be declared public, private, protected, or internal", lexer.yyline()); + } + break; case PREPROCESSOR: if (((String)s.value).toLowerCase().equals("namespace")) { expectedType(SymbolType.PARENT_OPEN); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index cdcfcbfa2..b5339ae73 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -349,7 +349,9 @@ public abstract class Trait implements Cloneable, Serializable { Namespace ns = m.getNamespace(abc.constants); - if (ns.kind == Namespace.KIND_NAMESPACE && nsname == null && !insideInterface) { + if (insideInterface) { + //no namespace identifier + } else if (ns.kind == Namespace.KIND_NAMESPACE && nsname == null) { writer.append("§§namespace(\""); writer.append(Helper.escapeActionScriptString(ns.getRawName(abc.constants))); writer.append("\") ");