From 8e496d8655bd279936b25b4630d6eb3933fe03e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 25 Feb 2021 11:03:47 +0100 Subject: [PATCH] Fix tests - comma operator --- .../parser/script/ActionScript3Parser.java | 98 ++++++------ .../parser/script/ActionScript2Parser.java | 150 +++++++++--------- 2 files changed, 122 insertions(+), 126 deletions(-) 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 c5dbea844..4c08a418d 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 @@ -199,7 +199,7 @@ public class ActionScript3Parser { break; case FILTER: needsActivation.setVal(true); - ret = new XMLFilterAVM2Item(ret, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, inMethod, variables), openedNamespaces); + ret = new XMLFilterAVM2Item(ret, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, inMethod, variables, false), openedNamespaces); expectedType(SymbolType.PARENT_CLOSE); break; case PARENT_OPEN: @@ -293,7 +293,7 @@ public class ActionScript3Parser { ret = applyType(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, ret, registerVars, inFunction, inMethod, variables); s = lex(); } else if (s.type == SymbolType.BRACKET_OPEN) { - GraphTargetItem index = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem index = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.BRACKET_CLOSE); ret = new IndexAVM2Item(attr, ret, index, null, openedNamespaces); s = lex(); @@ -309,7 +309,7 @@ public class ActionScript3Parser { variables.add((UnresolvedAVM2Item) ns); s = lex(); if (s.type == SymbolType.BRACKET_OPEN) { - propItem = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + propItem = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.BRACKET_CLOSE); propName = null; } else { @@ -384,7 +384,7 @@ public class ActionScript3Parser { if (s.group == SymbolGroup.IDENTIFIER) { nsprop = s.value.toString(); } else if (s.type == SymbolType.BRACKET_OPEN) { - nspropItem = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + nspropItem = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.BRACKET_CLOSE); } name = name.getWithoutLast(); @@ -466,7 +466,7 @@ public class ActionScript3Parser { if (s.type != SymbolType.COMMA) { lexer.pushback(s); } - ret.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); s = lex(); expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE); } @@ -511,7 +511,7 @@ public class ActionScript3Parser { paramTypes.add(new UnboundedTypeItem()); } if (s.type == SymbolType.ASSIGN) { - paramValues.add(expression(allOpenedNamespaces, thisType, pkg, new Reference<>(false), importedClasses, openedNamespaces, null, isMethod, isMethod, isMethod, variables)); + paramValues.add(expression(allOpenedNamespaces, thisType, pkg, new Reference<>(false), importedClasses, openedNamespaces, null, isMethod, isMethod, isMethod, variables, false)); s = lex(); } else if (!paramValues.isEmpty()) { throw new AVM2ParseException("Some of parameters do not have default values", lexer.yyline()); @@ -845,7 +845,7 @@ public class ActionScript3Parser { GraphTargetItem value = null; if (s.type == SymbolType.ASSIGN) { - value = expression(allOpenedNamespaces, thisType, pkg, new Reference<>(false), importedClasses, openedNamespaces, new HashMap<>(), false, false, true, isStatic || isConst ? cinitVariables : iinitVariables); + value = expression(allOpenedNamespaces, thisType, pkg, new Reference<>(false), importedClasses, openedNamespaces, new HashMap<>(), false, false, true, isStatic || isConst ? cinitVariables : iinitVariables, false); s = lex(); } GraphTargetItem tar; @@ -1068,7 +1068,7 @@ public class ActionScript3Parser { GraphTargetItem value = null; if (s.type == SymbolType.ASSIGN) { - value = expression(allOpenedNamespaces, null, ns, new Reference<>(false), importedClasses, openedNamespaces, new HashMap<>(), false, false, true, sinitVariables); + value = expression(allOpenedNamespaces, null, ns, new Reference<>(false), importedClasses, openedNamespaces, new HashMap<>(), false, false, true, sinitVariables, false); s = lex(); } GraphTargetItem tar; @@ -1231,7 +1231,7 @@ public class ActionScript3Parser { case XML_ATTRNAMEVAR_BEGIN: //add usesVars.setVal(true); addS(rets, sb); - rets.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + rets.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); expectedType(SymbolType.CURLY_CLOSE); expectedType(SymbolType.ASSIGN); sb.append("="); @@ -1241,7 +1241,7 @@ public class ActionScript3Parser { usesVars.setVal(true); sb.append("\""); addS(rets, sb); - rets.add(new EscapeXAttrAVM2Item(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); + rets.add(new EscapeXAttrAVM2Item(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false))); sb.append("\""); expectedType(SymbolType.CURLY_CLOSE); lexer.yybegin(ActionScriptLexer.XMLOPENTAG); @@ -1249,7 +1249,7 @@ public class ActionScript3Parser { case XML_INSTRATTRNAMEVAR_BEGIN: //add usesVars.setVal(true); addS(rets, sb); - rets.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + rets.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); expectedType(SymbolType.CURLY_CLOSE); expectedType(SymbolType.ASSIGN); sb.append("="); @@ -1259,7 +1259,7 @@ public class ActionScript3Parser { usesVars.setVal(true); sb.append("\""); addS(rets, sb); - rets.add(new EscapeXAttrAVM2Item(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); + rets.add(new EscapeXAttrAVM2Item(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false))); sb.append("\""); expectedType(SymbolType.CURLY_CLOSE); lexer.yybegin(ActionScriptLexer.XMLOPENTAG); @@ -1267,7 +1267,7 @@ public class ActionScript3Parser { case XML_VAR_BEGIN: //esc_xelem usesVars.setVal(true); addS(rets, sb); - rets.add(new EscapeXElemAVM2Item(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables))); + rets.add(new EscapeXElemAVM2Item(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false))); expectedType(SymbolType.CURLY_CLOSE); lexer.yybegin(ActionScriptLexer.XML); break; @@ -1277,7 +1277,7 @@ public class ActionScript3Parser { sb.append(""); @@ -1288,7 +1288,7 @@ public class ActionScript3Parser { //openedTags.add("*"); //ret = add(ret, ); - GraphTargetItem ex = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem ex = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.CURLY_CLOSE); lexer.yybegin(ActionScriptLexer.XMLOPENTAG); sub.add("*"); @@ -1303,7 +1303,7 @@ public class ActionScript3Parser { addS(rets, sb); sb.append(" onTrueList = new ArrayList<>(); @@ -1512,7 +1512,7 @@ public class ActionScript3Parser { case WHILE: expectedType(SymbolType.PARENT_OPEN); List whileExpr = new ArrayList<>(); - whileExpr.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + whileExpr.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, true)); expectedType(SymbolType.PARENT_CLOSE); List whileBody = new ArrayList<>(); Loop wloop = new Loop(uniqId(), null, null); @@ -1534,7 +1534,7 @@ public class ActionScript3Parser { expectedType(SymbolType.WHILE); expectedType(SymbolType.PARENT_OPEN); List doExpr = new ArrayList<>(); - doExpr.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + doExpr.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, true)); expectedType(SymbolType.PARENT_CLOSE); ret = new DoWhileItem(null, null, dloop, doBody, doExpr); break; @@ -1577,13 +1577,9 @@ public class ActionScript3Parser { if (firstCommand != null) { //can be empty command forFirstCommands.add(firstCommand); } - while (s.isType(SymbolType.COMMA)) { - forFirstCommands.add(command(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, false, variables)); - s = lex(); - } lexer.pushback(s); //GraphTargetItem firstCommand = command(thisType,pkg,needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); - forExpr = (expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + forExpr = (expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); expectedType(SymbolType.SEMICOLON); GraphTargetItem fcom = command(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, loops, loopLabels, registerVars, inFunction, inMethod, forinlevel, true, variables); if (fcom != null) { @@ -1611,7 +1607,7 @@ public class ActionScript3Parser { loopLabels.put(sloop, loopLabel); } expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem switchExpr = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem switchExpr = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); s = lex(); @@ -1631,7 +1627,7 @@ public class ActionScript3Parser { int pos = 0; while (s.type == SymbolType.CASE || s.type == SymbolType.DEFAULT) { while (s.type == SymbolType.CASE || s.type == SymbolType.DEFAULT) { - GraphTargetItem curCaseExpr = s.type == SymbolType.DEFAULT ? new DefaultItem() : expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem curCaseExpr = s.type == SymbolType.DEFAULT ? new DefaultItem() : expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.COLON); s = lex(); caseExprsAll.add(curCaseExpr); @@ -1705,7 +1701,7 @@ public class ActionScript3Parser { ret = new ContinueItem(null, null, cloopId); break; case RETURN: - GraphTargetItem retexpr = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, true, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem retexpr = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, true, registerVars, inFunction, inMethod, true, variables, false); if (retexpr == null) { ret = new ReturnVoidAVM2Item(null, null); } else { @@ -1799,7 +1795,7 @@ public class ActionScript3Parser { ret = tai; break; case THROW: - ret = new ThrowAVM2Item(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret = new ThrowAVM2Item(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); break; default: GraphTargetItem valcmd = expressionCommands(s, registerVars, inFunction, inMethod, forinlevel, variables); @@ -1811,7 +1807,7 @@ public class ActionScript3Parser { return null; } lexer.pushback(s); - ret = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + ret = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, true); if (debugMode) { System.out.println("/command"); } @@ -1823,7 +1819,7 @@ public class ActionScript3Parser { lexer.removeListener(buf); if (ret == null) { //can be popped expression buf.pushAllBack(lexer); - ret = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + ret = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); } s = lex(); if ((s != null) && (s.type != SymbolType.SEMICOLON)) { @@ -1834,8 +1830,8 @@ public class ActionScript3Parser { } - private GraphTargetItem expression(List> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { - return expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, allowRemainder, variables); + private GraphTargetItem expression(List> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables, boolean allowComma) throws IOException, AVM2ParseException { + return expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, allowRemainder, variables, allowComma); } /*private GraphTargetItem expressionRemainder(TypeItem thisType, String pkg, Reference needsActivation, List openedNamespaces, GraphTargetItem expr, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables, List importedClasses) throws IOException, AVM2ParseException { @@ -1879,7 +1875,7 @@ public class ActionScript3Parser { lexer.pushback(s); } arrCnt++; - ret.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret.add(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); s = lex(); if (!s.isType(SymbolType.COMMA, SymbolType.BRACKET_CLOSE)) { expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.BRACKET_CLOSE); @@ -1892,7 +1888,7 @@ public class ActionScript3Parser { return arrCnt; } - private GraphTargetItem expression(List> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem expression(List> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables, boolean allowComma) throws IOException, AVM2ParseException { List commaItems = new ArrayList<>(); ParsedSymbol symb; @@ -1904,7 +1900,7 @@ public class ActionScript3Parser { GraphTargetItem item = expression1(allOpenedNamespaces, prim, GraphTargetItem.NOPRECEDENCE, thisType, pkg, needsActivation, importedClasses, openedNamespaces, allowEmpty, registerVars, inFunction, inMethod, allowRemainder, variables); commaItems.add(item); symb = lex(); - } while (symb != null && symb.type == SymbolType.COMMA); + } while (allowComma && symb != null && symb.type == SymbolType.COMMA); if (symb != null) { lexer.pushback(symb); } @@ -1983,7 +1979,7 @@ public class ActionScript3Parser { if (debugMode) { System.out.println("ternar-middle:"); } - mhs = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables); + mhs = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables, false); expectedType(SymbolType.COLON); if (debugMode) { System.out.println("/ternar-middle"); @@ -2162,7 +2158,7 @@ public class ActionScript3Parser { } } if (lhs instanceof ParenthesisItem) { - GraphTargetItem coerced = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables); + GraphTargetItem coerced = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables, false); if (coerced != null && isType(((ParenthesisItem) lhs).value)) { lhs = new CoerceAVM2Item(null, null, ((ParenthesisItem) lhs).value, coerced); } @@ -2187,36 +2183,36 @@ public class ActionScript3Parser { switch ("" + s.value) { //AS3 case "hasnext": - GraphTargetItem hnIndex = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem hnIndex = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.COMMA); - GraphTargetItem hnObject = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem hnObject = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); ret = new HasNextAVM2Item(null, null, hnIndex, hnObject); break; case "newactivation": ret = new NewActivationAVM2Item(null, null); break; case "nextname": - GraphTargetItem nnIndex = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem nnIndex = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.COMMA); - GraphTargetItem nnObject = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem nnObject = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); ret = new NextNameAVM2Item(null, null, nnIndex, nnObject); allowMemberOrCall = true; break; case "nextvalue": - GraphTargetItem nvIndex = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem nvIndex = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); expectedType(SymbolType.COMMA); - GraphTargetItem nvObject = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem nvObject = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); ret = new NextNameAVM2Item(null, null, nvIndex, nvObject); allowMemberOrCall = true; break; //Both ASs case "dup": - ret = new DuplicateItem(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret = new DuplicateItem(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); break; case "push": - ret = new PushItem(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret = new PushItem(expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); break; case "pop": ret = new PopItem(null, null); @@ -2311,7 +2307,7 @@ public class ActionScript3Parser { GraphTargetItem n = new StringAVM2Item(null, null, s.value.toString()); //expression(allOpenedNamespaces, thisType,pkg,needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables); expectedType(SymbolType.COLON); - GraphTargetItem v = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables); + GraphTargetItem v = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, allowRemainder, variables, false); NameValuePair nv = new NameValuePair(n, v); nvs.add(nv); @@ -2385,7 +2381,7 @@ public class ActionScript3Parser { break; case PARENT_OPEN: - ret = new ParenthesisItem(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables)); + ret = new ParenthesisItem(null, null, expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, true)); expectedType(SymbolType.PARENT_CLOSE); if (ret.value == null) { throw new AVM2ParseException("Expression in parenthesis expected", lexer.yyline()); @@ -2418,7 +2414,7 @@ public class ActionScript3Parser { brackets(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, params, registerVars, inFunction, inMethod, variables); ret = new InitVectorAVM2Item(subtype, params, openedNamespaces); } else if (s.type == SymbolType.PARENT_OPEN) { - GraphTargetItem newvar = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables); + GraphTargetItem newvar = expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false); newvar = applyType(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, newvar, registerVars, inFunction, inMethod, variables); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.PARENT_OPEN); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java index fd3303a72..af327aae0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScript2Parser.java @@ -351,7 +351,7 @@ public class ActionScript2Parser { if (s.type != SymbolType.COMMA) { lexer.pushback(s); } - ret.add(expression(inFunction, inMethod, true, variables, functions)); + ret.add(expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.PARENT_CLOSE); } @@ -485,7 +485,7 @@ public class ActionScript2Parser { s = lex(); } if (s.type == SymbolType.ASSIGN) { - traits.add(new MyEntry<>(pushConst(ident), expression(false, false, true, variables, functions))); + traits.add(new MyEntry<>(pushConst(ident), expression(false, false, true, variables, functions, false))); traitsStatic.add(isStatic); s = lex(); } @@ -520,52 +520,52 @@ public class ActionScript2Parser { break; case MBORD: expectedType(SymbolType.PARENT_OPEN); - ret = new MBCharToAsciiActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new MBCharToAsciiActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case MBCHR: expectedType(SymbolType.PARENT_OPEN); - ret = new MBAsciiToCharActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new MBAsciiToCharActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case MBLENGTH: expectedType(SymbolType.PARENT_OPEN); - ret = new MBStringLengthActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new MBStringLengthActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case MBSUBSTRING: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem val1 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem val1 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem index1 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem index1 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem len1 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem len1 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); ret = new MBStringExtractActionItem(null, null, val1, index1, len1); break; case SUBSTR: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem val2 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem val2 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem index2 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem index2 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem len2 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem len2 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); ret = new StringExtractActionItem(null, null, val2, index2, len2); break; case LENGTH: expectedType(SymbolType.PARENT_OPEN); - ret = new StringLengthActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new StringLengthActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case RANDOM: expectedType(SymbolType.PARENT_OPEN); - ret = new RandomNumberActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new RandomNumberActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case INT: expectedType(SymbolType.PARENT_OPEN); - ret = new ToIntegerActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new ToIntegerActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case NUMBER_OP: @@ -578,7 +578,7 @@ public class ActionScript2Parser { ret = vi; //memberOrCall(vi, inFunction, inMethod, variables, functions); } else { expected(s, lexer.yyline(), SymbolType.PARENT_OPEN); - ret = new ToNumberActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new ToNumberActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); } break; @@ -592,28 +592,28 @@ public class ActionScript2Parser { ret = vi2; //memberOrCall(vi2, inFunction, inMethod, variables, functions); } else { expected(s, lexer.yyline(), SymbolType.PARENT_OPEN); - ret = new ToStringActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new ToStringActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); //ret = memberOrCall(ret, inFunction, inMethod, variables, functions); } break; case ORD: expectedType(SymbolType.PARENT_OPEN); - ret = new CharToAsciiActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new CharToAsciiActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case CHR: expectedType(SymbolType.PARENT_OPEN); - ret = new AsciiToCharActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new AsciiToCharActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case DUPLICATEMOVIECLIP: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem src3 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem src3 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem tar3 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem tar3 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem dep3 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem dep3 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); ret = new CloneSpriteActionItem(null, null, src3, tar3, dep3); break; @@ -624,7 +624,7 @@ public class ActionScript2Parser { break; case TARGETPATH: expectedType(SymbolType.PARENT_OPEN); - ret = new TargetPathActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions))); + ret = new TargetPathActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions, false))); expectedType(SymbolType.PARENT_CLOSE); break; default: @@ -650,35 +650,35 @@ public class ActionScript2Parser { switch (s.type) { case FSCOMMAND: expectedType(SymbolType.PARENT_OPEN); - ret = new FSCommandActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new FSCommandActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); break; case CALL: expectedType(SymbolType.PARENT_OPEN); - ret = new CallActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions))); + ret = new CallActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions, false))); expectedType(SymbolType.PARENT_CLOSE); break; case LENGTH: expectedType(SymbolType.PARENT_OPEN); - ret = new StringLengthActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions))); + ret = new StringLengthActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions, false))); expectedType(SymbolType.PARENT_CLOSE); break; case MBLENGTH: expectedType(SymbolType.PARENT_OPEN); - ret = new MBStringLengthActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions))); + ret = new MBStringLengthActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions, false))); expectedType(SymbolType.PARENT_CLOSE); break; case SET: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem name1 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem name1 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem value1 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem value1 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); ret = new SetVariableActionItem(null, null, name1, value1); break; case WITH: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem wvar = expression(inFunction, inMethod, false, variables, functions);//(variable(inFunction, inMethod, variables, functions)); + GraphTargetItem wvar = expression(inFunction, inMethod, false, variables, functions, false);//(variable(inFunction, inMethod, variables, functions)); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); List wcmd = commands(inFunction, inMethod, forinlevel, variables, functions); @@ -686,7 +686,7 @@ public class ActionScript2Parser { ret = new WithActionItem(null, null, wvar, wcmd); break; case DELETE: - GraphTargetItem varDel = expression(inFunction, inMethod, false, variables, functions);//variable(inFunction, inMethod, variables, functions); + GraphTargetItem varDel = expression(inFunction, inMethod, false, variables, functions, false);//variable(inFunction, inMethod, variables, functions); if (varDel instanceof GetMemberActionItem) { GetMemberActionItem gm = (GetMemberActionItem) varDel; ret = new DeleteActionItem(null, null, gm.object, gm.memberName); @@ -701,19 +701,19 @@ public class ActionScript2Parser { break; case TRACE: expectedType(SymbolType.PARENT_OPEN); - ret = new TraceActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions))); + ret = new TraceActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions, false))); expectedType(SymbolType.PARENT_CLOSE); break; case GETURL: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem url = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem url = (expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); expected(s, lexer.yyline(), SymbolType.PARENT_CLOSE, SymbolType.COMMA); int getuMethod = 1; GraphTargetItem target; if (s.type == SymbolType.COMMA) { - target = (expression(inFunction, inMethod, true, variables, functions)); + target = (expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); if (s.type == SymbolType.COMMA) { s = lex(); @@ -737,11 +737,11 @@ public class ActionScript2Parser { break; case GOTOANDSTOP: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem gtsFrame = expression(inFunction, inMethod, true, variables, functions); + GraphTargetItem gtsFrame = expression(inFunction, inMethod, true, variables, functions, false); s = lex(); if (s.type == SymbolType.COMMA) { //Handle scene? lex(); - gtsFrame = expression(inFunction, inMethod, true, variables, functions); + gtsFrame = expression(inFunction, inMethod, true, variables, functions, false); } else { lexer.pushback(s); } @@ -765,7 +765,7 @@ public class ActionScript2Parser { break; case TELLTARGET: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem tellTarget = expression(inFunction, inMethod, true, variables, functions); + GraphTargetItem tellTarget = expression(inFunction, inMethod, true, variables, functions, false); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); List tellcmds = commands(inFunction, inMethod, forinlevel, variables, functions); @@ -798,7 +798,7 @@ public class ActionScript2Parser { case UNLOADMOVIENUM: SymbolType unloadType = s.type; expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem unTargetOrNum = expression(inFunction, inMethod, true, variables, functions); + GraphTargetItem unTargetOrNum = expression(inFunction, inMethod, true, variables, functions, false); expectedType(SymbolType.PARENT_CLOSE); if (unloadType == SymbolType.UNLOADMOVIE) { ret = new UnLoadMovieActionItem(null, null, unTargetOrNum); @@ -813,9 +813,9 @@ public class ActionScript2Parser { case PRINTNUM: SymbolType printType = s.type; expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem printTarget = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem printTarget = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem printBBox = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem printBBox = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); switch (printType) { @@ -839,9 +839,9 @@ public class ActionScript2Parser { case LOADMOVIENUM: SymbolType loadType = s.type; expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem url2 = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem url2 = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.COMMA); - GraphTargetItem targetOrNum = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem targetOrNum = (expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); expected(s, lexer.yyline(), SymbolType.PARENT_CLOSE, SymbolType.COMMA); @@ -877,11 +877,11 @@ public class ActionScript2Parser { break; case GOTOANDPLAY: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem gtpFrame = expression(inFunction, inMethod, true, variables, functions); + GraphTargetItem gtpFrame = expression(inFunction, inMethod, true, variables, functions, false); s = lex(); if (s.type == SymbolType.COMMA) { //Handle scene? lex(); - gtpFrame = expression(inFunction, inMethod, true, variables, functions); + gtpFrame = expression(inFunction, inMethod, true, variables, functions, false); } else { lexer.pushback(s); } @@ -891,12 +891,12 @@ public class ActionScript2Parser { case REMOVEMOVIECLIP: expectedType(SymbolType.PARENT_OPEN); - ret = new RemoveSpriteActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions))); + ret = new RemoveSpriteActionItem(null, null, (expression(inFunction, inMethod, true, variables, functions, false))); expectedType(SymbolType.PARENT_CLOSE); break; case STARTDRAG: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem dragTarget = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem dragTarget = (expression(inFunction, inMethod, true, variables, functions, false)); GraphTargetItem lockCenter; GraphTargetItem constrain; GraphTargetItem x1 = null; @@ -905,20 +905,20 @@ public class ActionScript2Parser { GraphTargetItem y2 = null; s = lex(); if (s.type == SymbolType.COMMA) { - lockCenter = (expression(inFunction, inMethod, true, variables, functions)); + lockCenter = (expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); if (s.type == SymbolType.COMMA) { constrain = new DirectValueActionItem(null, null, 0, 1L, new ArrayList<>()); - x1 = (expression(inFunction, inMethod, true, variables, functions)); + x1 = (expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); if (s.type == SymbolType.COMMA) { - y1 = (expression(inFunction, inMethod, true, variables, functions)); + y1 = (expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); if (s.type == SymbolType.COMMA) { - x2 = (expression(inFunction, inMethod, true, variables, functions)); + x2 = (expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); if (s.type == SymbolType.COMMA) { - y2 = (expression(inFunction, inMethod, true, variables, functions)); + y2 = (expression(inFunction, inMethod, true, variables, functions, false)); } else { lexer.pushback(s); y2 = new DirectValueActionItem(null, null, 0, 0L, new ArrayList<>()); @@ -951,7 +951,7 @@ public class ActionScript2Parser { case IFFRAMELOADED: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem iflExpr = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem iflExpr = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); List iflComs = commands(inFunction, inMethod, forinlevel, variables, functions); @@ -1011,7 +1011,7 @@ public class ActionScript2Parser { } if (s.type == SymbolType.ASSIGN) { - GraphTargetItem varval = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem varval = (expression(inFunction, inMethod, true, variables, functions, false)); ret = new VariableActionItem(varIdentifier, varval, true); variables.add((VariableActionItem) ret); } else { @@ -1026,7 +1026,7 @@ public class ActionScript2Parser { break; case INCREMENT: //preincrement case DECREMENT: //predecrement - GraphTargetItem varincdec = expression(inFunction, inMethod, false, variables, functions); + GraphTargetItem varincdec = expression(inFunction, inMethod, false, variables, functions, false); if (s.type == SymbolType.INCREMENT) { ret = new PreIncrementActionItem(null, null, varincdec); } else if (s.type == SymbolType.DECREMENT) { @@ -1047,7 +1047,7 @@ public class ActionScript2Parser { break; case IF: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem ifExpr = (expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem ifExpr = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); GraphTargetItem onTrue = command(inFunction, inMethod, forinlevel, true, variables, functions); List onTrueList = new ArrayList<>(); @@ -1065,7 +1065,7 @@ public class ActionScript2Parser { case WHILE: expectedType(SymbolType.PARENT_OPEN); List whileExpr = new ArrayList<>(); - whileExpr.add(expression(inFunction, inMethod, true, variables, functions)); + whileExpr.add(expression(inFunction, inMethod, true, variables, functions, true)); expectedType(SymbolType.PARENT_CLOSE); List whileBody = new ArrayList<>(); whileBody.add(command(inFunction, inMethod, forinlevel, true, variables, functions)); @@ -1077,7 +1077,7 @@ public class ActionScript2Parser { expectedType(SymbolType.WHILE); expectedType(SymbolType.PARENT_OPEN); List doExpr = new ArrayList<>(); - doExpr.add(expression(inFunction, inMethod, true, variables, functions)); + doExpr.add(expression(inFunction, inMethod, true, variables, functions, true)); expectedType(SymbolType.PARENT_CLOSE); ret = new DoWhileItem(null, null, null, doBody, doExpr); break; @@ -1138,7 +1138,7 @@ public class ActionScript2Parser { variables.add(item); - collection = expression(inFunction, inMethod, true, variables, functions); + collection = expression(inFunction, inMethod, true, variables, functions, false); forin = true; } else { lexer.pushback(s3); @@ -1164,7 +1164,7 @@ public class ActionScript2Parser { if (fc != null) { //can be empty command forFirstCommands.add(fc); } - forExpr = (expression(inFunction, inMethod, true, variables, functions)); + forExpr = (expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.SEMICOLON); GraphTargetItem fcom = command(inFunction, inMethod, forinlevel, true, variables, functions); if (fcom != null) { @@ -1182,7 +1182,7 @@ public class ActionScript2Parser { break; case SWITCH: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem switchExpr = expression(inFunction, inMethod, true, variables, functions); + GraphTargetItem switchExpr = expression(inFunction, inMethod, true, variables, functions, false); expectedType(SymbolType.PARENT_CLOSE); expectedType(SymbolType.CURLY_OPEN); s = lex(); @@ -1203,7 +1203,7 @@ public class ActionScript2Parser { while (s.type == SymbolType.CASE || s.type == SymbolType.DEFAULT) { //List caseExprs; = new ArrayList<>(); while (s.type == SymbolType.CASE || s.type == SymbolType.DEFAULT) { - GraphTargetItem curCaseExpr = s.type == SymbolType.DEFAULT ? new DefaultItem() : expression(inFunction, inMethod, true, variables, functions); + GraphTargetItem curCaseExpr = s.type == SymbolType.DEFAULT ? new DefaultItem() : expression(inFunction, inMethod, true, variables, functions, false); //caseExprs.add(curCaseExpr); expectedType(SymbolType.COLON); s = lex(); @@ -1226,7 +1226,7 @@ public class ActionScript2Parser { ret = new ContinueItem(null, null, 0); //? There is no more than 1 level continue/break in AS1/2 break; case RETURN: - GraphTargetItem retexpr = expression(inFunction, inMethod, true, variables, functions); + GraphTargetItem retexpr = expression(inFunction, inMethod, true, variables, functions, false); if (retexpr == null) { retexpr = new DirectValueActionItem(null, null, 0, Undefined.INSTANCE, new ArrayList<>()); } @@ -1277,7 +1277,7 @@ public class ActionScript2Parser { ret = new TryActionItem(tryCommands, catchExceptionNames, catchExceptionTypes, catchCommands, finallyCommands); break; case THROW: - ret = new ThrowActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new ThrowActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); break; case SEMICOLON: //empty command if (debugMode) { @@ -1291,7 +1291,7 @@ public class ActionScript2Parser { break; } lexer.pushback(s); - ret = expression(inFunction, inMethod, true, variables, functions); + ret = expression(inFunction, inMethod, true, variables, functions, true); } if (debugMode) { System.out.println("/command"); @@ -1299,7 +1299,7 @@ public class ActionScript2Parser { lexer.removeListener(buf); if (ret == null) { //can be popped expression buf.pushAllBack(lexer); - ret = expression(inFunction, inMethod, true, variables, functions); + ret = expression(inFunction, inMethod, true, variables, functions, false); } s = lex(); if ((s != null) && (s.type != SymbolType.SEMICOLON)) { @@ -1310,7 +1310,7 @@ public class ActionScript2Parser { } - private GraphTargetItem expression(boolean inFunction, boolean inMethod, boolean allowRemainder, List variables, List functions) throws IOException, ActionParseException { + private GraphTargetItem expression(boolean inFunction, boolean inMethod, boolean allowRemainder, List variables, List functions, boolean allowComma) throws IOException, ActionParseException { if (debugMode) { System.out.println("expression:"); } @@ -1324,7 +1324,7 @@ public class ActionScript2Parser { GraphTargetItem expr = expression1(prim, GraphTargetItem.NOPRECEDENCE, inFunction, inMethod, allowRemainder, variables, functions); commaItems.add(expr); symb = lex(); - } while (symb != null && symb.type == SymbolType.COMMA); + } while (allowComma && symb != null && symb.type == SymbolType.COMMA); if (symb != null) { lexer.pushback(symb); } @@ -1390,7 +1390,7 @@ public class ActionScript2Parser { if (debugMode) { System.out.println("ternar-middle:"); } - mhs = expression(inFunction, inMethod, allowRemainder, variables, functions); + mhs = expression(inFunction, inMethod, allowRemainder, variables, functions, false); expectedType(SymbolType.COLON); if (debugMode) { System.out.println("/ternar-middle"); @@ -1626,7 +1626,7 @@ public class ActionScript2Parser { lexer.pushback(s); } arrCnt++; - ret.add(expression(inFunction, inMethod, true, variables, functions)); + ret.add(expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); if (!s.isType(SymbolType.COMMA, SymbolType.BRACKET_CLOSE)) { expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.BRACKET_CLOSE); @@ -1659,14 +1659,14 @@ public class ActionScript2Parser { ret = new UnresolvedConstantActionItem((int) (long) (Long) s.value); break; case "enumerate": - ret = new EnumerateActionItem(null, null, expression(inFunction, inMethod, allowRemainder, variables, functions)); + ret = new EnumerateActionItem(null, null, expression(inFunction, inMethod, allowRemainder, variables, functions, false)); break; //Both ASs case "dup": - ret = new DuplicateItem(null, null, expression(inFunction, inMethod, allowRemainder, variables, functions)); + ret = new DuplicateItem(null, null, expression(inFunction, inMethod, allowRemainder, variables, functions, false)); break; case "push": - ret = new PushItem(expression(inFunction, inMethod, allowRemainder, variables, functions)); + ret = new PushItem(expression(inFunction, inMethod, allowRemainder, variables, functions, false)); break; case "pop": ret = new PopItem(null, null); @@ -1749,7 +1749,7 @@ public class ActionScript2Parser { expected(s, lexer.yyline(), SymbolType.IDENTIFIER); objectNames.add(0, pushConst((String) s.value)); expectedType(SymbolType.COLON); - objectValues.add(0, expression(inFunction, inMethod, true, variables, functions)); + objectValues.add(0, expression(inFunction, inMethod, true, variables, functions, false)); s = lex(); if (!s.isType(SymbolType.COMMA, SymbolType.CURLY_CLOSE)) { expected(s, lexer.yyline(), SymbolType.COMMA, SymbolType.CURLY_CLOSE); @@ -1822,7 +1822,7 @@ public class ActionScript2Parser { break; case PARENT_OPEN: - ret = new ParenthesisItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + ret = new ParenthesisItem(null, null, expression(inFunction, inMethod, true, variables, functions, true)); expectedType(SymbolType.PARENT_CLOSE); //ret = memberOrCall(ret, inFunction, inMethod, variables, functions); allowMemberOrCall = true; @@ -1857,7 +1857,7 @@ public class ActionScript2Parser { break; case EVAL: expectedType(SymbolType.PARENT_OPEN); - GraphTargetItem evar = new EvalActionItem(null, null, expression(inFunction, inMethod, true, variables, functions)); + GraphTargetItem evar = new EvalActionItem(null, null, expression(inFunction, inMethod, true, variables, functions, false)); expectedType(SymbolType.PARENT_CLOSE); //evar = memberOrCall(evar, inFunction, inMethod, variables, functions); ret = evar; @@ -1950,7 +1950,7 @@ public class ActionScript2Parser { } } if (op.type == SymbolType.BRACKET_OPEN) { - GraphTargetItem rhs = expression(inFunction, inMethod, false, variables, functions); + GraphTargetItem rhs = expression(inFunction, inMethod, false, variables, functions, false); ret = new GetMemberActionItem(null, null, ret, rhs); expectedType(SymbolType.BRACKET_CLOSE); }