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 151918f8b..302497e3f 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 @@ -159,7 +159,6 @@ public class ActionScript3SimpleParser implements SimpleParser { } else { lexer.pushback(s); expressionPrimary(errors, thisType, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, false, variables, abc); - } s = lex(); } while (s.type == SymbolType.COMMA); @@ -387,11 +386,11 @@ public class ActionScript3SimpleParser implements SimpleParser { } } - private void method(List errors, boolean outsidePackage, boolean isPrivate, List>> metadata, boolean isInterface, boolean isNative, String customAccess, Reference needsActivation, List importedClasses, boolean override, boolean isFinal, TypeItem thisType, List openedNamespaces, boolean isStatic, String functionName, boolean isMethod, List variables, ABC abc, int methodNamePos) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException { - function(errors, metadata, isInterface, isNative, needsActivation, importedClasses, thisType, openedNamespaces, functionName, isMethod, variables, abc, methodNamePos); + private void method(List errors, boolean outsidePackage, boolean isPrivate, boolean isInterface, boolean isNative, String customAccess, Reference needsActivation, List importedClasses, boolean override, boolean isFinal, TypeItem thisType, List openedNamespaces, boolean isStatic, String functionName, boolean isMethod, List variables, ABC abc, int methodNamePos) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException { + function(errors, isInterface, isNative, needsActivation, importedClasses, thisType, openedNamespaces, functionName, isMethod, variables, abc, methodNamePos); } - private void function(List errors, List>> metadata, boolean isInterface, boolean isNative, Reference needsActivation, List importedClasses, TypeItem thisType, List openedNamespaces, String functionName, boolean isMethod, List variables, ABC abc, int functionNamePos) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException { + private void function(List errors, boolean isInterface, boolean isNative, Reference needsActivation, List importedClasses, TypeItem thisType, List openedNamespaces, String functionName, boolean isMethod, List variables, ABC abc, int functionNamePos) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException { ParsedSymbol s; expectedType(errors, SymbolType.PARENT_OPEN); @@ -432,10 +431,14 @@ public class ActionScript3SimpleParser implements SimpleParser { } if (!s.isType(SymbolType.COMMA, SymbolType.PARENT_CLOSE)) { - expected(errors, s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE); + if (!expected(errors, s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE)) { + break; + } } if (hasRest) { - expected(errors, s, lexer.yyline(), SymbolType.PARENT_CLOSE); + if (!expected(errors, s, lexer.yyline(), SymbolType.PARENT_CLOSE)) { + break; + } } } s = lex(); @@ -469,8 +472,7 @@ public class ActionScript3SimpleParser implements SimpleParser { variables.add(fs); } - private List>> parseMetadata(List errors) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException { - List>> metadata = new ArrayList<>(); + private void parseMetadata(List errors) throws IOException, AVM2ParseException, SimpleParseException, InterruptedException { ParsedSymbol s = lex(); while (s.isType(SymbolType.BRACKET_OPEN)) { s = lex(); @@ -501,26 +503,16 @@ public class ActionScript3SimpleParser implements SimpleParser { s = lex(); } expected(errors, s, lexer.yyline(), SymbolType.BRACKET_CLOSE); - s = lex(); - - /* - * Skip Embed metadata - these are loaded automatically by the - * assignment in SymbolClass tag - */ - if (!"Embed".equals(name)) { - metadata.add(en); - } + s = lex(); } lexer.pushback(s); - return metadata; } private void classTraits(List errors, boolean outsidePackage, Reference cinitNeedsActivation, List importedClasses, List openedNamespaces, DottedChain pkg, String classNameStr, boolean isInterface, Reference iinitNeedsActivation, ABC abc, List classVariables) throws AVM2ParseException, SimpleParseException, IOException, CompilationException, InterruptedException { Stack cinitLoops = new Stack<>(); Map cinitLoopLabels = new HashMap<>(); - HashMap cinitRegisterVars = new HashMap<>(); - + looptraits: while (true) { TypeItem thisType = null; @@ -534,7 +526,7 @@ public class ActionScript3SimpleParser implements SimpleParser { String customNs = null; List preSymbols = new ArrayList<>(); - List>> metadata = parseMetadata(errors); + parseMetadata(errors); ParsedSymbol s = lex(); while (s.isType(SymbolType.NATIVE, SymbolType.STATIC, SymbolType.PUBLIC, SymbolType.PRIVATE, SymbolType.PROTECTED, SymbolType.OVERRIDE, SymbolType.FINAL, SymbolType.DYNAMIC, SymbolGroup.IDENTIFIER, SymbolType.INTERNAL, SymbolType.PREPROCESSOR)) { @@ -676,7 +668,7 @@ public class ActionScript3SimpleParser implements SimpleParser { if (isInterface) { errors.add(new SimpleParseException("Interface cannot have constructor", lexer.yyline(), s.position)); } - method(errors, outsidePackage, isPrivate, metadata, false, false, customNs, iinitNeedsActivation, importedClasses, false, false, thisType, openedNamespaces, false, "", true, classVariables, abc, fnamePos); + method(errors, outsidePackage, isPrivate, false, false, customNs, iinitNeedsActivation, importedClasses, false, false, thisType, openedNamespaces, false, "", true, classVariables, abc, fnamePos); } else { if (classNameStr == null) { isStatic = true; @@ -689,7 +681,7 @@ public class ActionScript3SimpleParser implements SimpleParser { lexer.pushback(s); } - method(errors, outsidePackage, isPrivate, metadata, isInterface, isNative, customNs, new Reference<>(false), importedClasses, isOverride, isFinal, thisType, openedNamespaces, isStatic, fname, true, classVariables, abc, fnamePos); + method(errors, outsidePackage, isPrivate, isInterface, isNative, customNs, new Reference<>(false), importedClasses, isOverride, isFinal, thisType, openedNamespaces, isStatic, fname, true, classVariables, abc, fnamePos); /* if (isGetter) { @@ -783,7 +775,7 @@ public class ActionScript3SimpleParser implements SimpleParser { lexer.pushback(preSymbols.get(i)); } - boolean cmd = command(errors, null, cinitNeedsActivation, importedClasses, openedNamespaces, cinitLoops, cinitLoopLabels, cinitRegisterVars, true, false, 0, false, classVariables, abc); + boolean cmd = command(errors, null, cinitNeedsActivation, importedClasses, openedNamespaces, cinitLoops, cinitLoopLabels, new HashMap<>(), true, false, 0, false, classVariables, abc); if (cmd) { //empty } else { @@ -867,7 +859,7 @@ public class ActionScript3SimpleParser implements SimpleParser { looptrait: while (true) { - List>> metadata = parseMetadata(errors); + parseMetadata(errors); s = lex(); boolean isFinal = false; boolean isDynamic = false; @@ -976,7 +968,7 @@ public class ActionScript3SimpleParser implements SimpleParser { expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER); String fname = s.value.toString(); - method(errors, !inPackage, false, metadata, false, isNative, null, new Reference<>(false), importedClasses, false, isFinal, null, openedNamespaces, true, fname, true, sinitVariables, abc, s.position); + method(errors, !inPackage, false, false, isNative, null, new Reference<>(false), importedClasses, false, isFinal, null, openedNamespaces, true, fname, true, sinitVariables, abc, s.position); break; case CONST: case VAR: @@ -1222,7 +1214,7 @@ public class ActionScript3SimpleParser implements SimpleParser { s = lexer.lex(); expected(errors, s, lexer.yyline(), SymbolGroup.IDENTIFIER); needsActivation.setVal(true); - function(errors, new ArrayList<>(), false, false, needsActivation, importedClasses, thisType, openedNamespaces, s.value.toString(), false, variables, abc, s.position); + function(errors, false, false, needsActivation, importedClasses, thisType, openedNamespaces, s.value.toString(), false, variables, abc, s.position); ret = true; break; case VAR: @@ -1844,7 +1836,7 @@ public class ActionScript3SimpleParser implements SimpleParser { lexer.pushback(s); } needsActivation.setVal(true); - function(errors, new ArrayList<>(), false, false, needsActivation, importedClasses, thisType, openedNamespaces, fname, false, variables, abc, fnamePos); + function(errors, false, false, needsActivation, importedClasses, thisType, openedNamespaces, fname, false, variables, abc, fnamePos); ret = true; allowMemberOrCall = true; break; @@ -1928,7 +1920,7 @@ public class ActionScript3SimpleParser implements SimpleParser { lexer.pushback(s); } needsActivation.setVal(true); - function(errors, new ArrayList<>(), false, false, needsActivation, importedClasses, thisType, openedNamespaces, ffname, false, variables, abc, ffnamePos); + function(errors, false, false, needsActivation, importedClasses, thisType, openedNamespaces, ffname, false, variables, abc, ffnamePos); ret = true; } else if (s.type == SymbolType.LOWER_THAN) { type(errors, thisType, needsActivation, importedClasses, openedNamespaces, variables, abc);