Skip to content

Commit c17868e

Browse files
committed
eliminate private AstNode expr() in favor of private AstNode
expr(boolean)
1 parent a3f43df commit c17868e

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

src/org/mozilla/javascript/Parser.java

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ private ConditionData condition() throws IOException {
10811081

10821082
if (mustMatchToken(Token.LP, "msg.no.paren.cond", true)) data.lp = ts.tokenBeg;
10831083

1084-
data.condition = expr();
1084+
data.condition = expr(false);
10851085

10861086
if (mustMatchToken(Token.RP, "msg.no.paren.after.cond", true)) data.rp = ts.tokenBeg;
10871087

@@ -1245,7 +1245,7 @@ private AstNode statementHelper() throws IOException {
12451245
return pn;
12461246
default:
12471247
lineno = ts.lineno;
1248-
pn = new ExpressionStatement(expr(), !insideFunction());
1248+
pn = new ExpressionStatement(expr(false), !insideFunction());
12491249
pn.setLineno(lineno);
12501250
break;
12511251
}
@@ -1319,7 +1319,7 @@ private SwitchStatement switchStatement() throws IOException {
13191319
if (mustMatchToken(Token.LP, "msg.no.paren.switch", true)) pn.setLp(ts.tokenBeg - pos);
13201320
pn.setLineno(ts.lineno);
13211321

1322-
AstNode discriminant = expr();
1322+
AstNode discriminant = expr(false);
13231323
pn.setExpression(discriminant);
13241324
enterSwitch(pn);
13251325

@@ -1343,7 +1343,7 @@ private SwitchStatement switchStatement() throws IOException {
13431343
break switchLoop;
13441344

13451345
case Token.CASE:
1346-
caseExpression = expr();
1346+
caseExpression = expr(false);
13471347
mustMatchToken(Token.COLON, "msg.no.colon.case", true);
13481348
break;
13491349

@@ -1499,22 +1499,22 @@ private Loop forLoop() throws IOException {
14991499
isForIn = true;
15001500
inPos = ts.tokenBeg - forPos;
15011501
markDestructuring(init);
1502-
cond = expr(); // object over which we're iterating
1502+
cond = expr(false); // object over which we're iterating
15031503
} else if (compilerEnv.getLanguageVersion() >= Context.VERSION_ES6
15041504
&& matchToken(Token.NAME, true)
15051505
&& "of".equals(ts.getString())) {
15061506
isForOf = true;
15071507
inPos = ts.tokenBeg - forPos;
15081508
markDestructuring(init);
1509-
cond = expr(); // object over which we're iterating
1509+
cond = expr(false); // object over which we're iterating
15101510
} else { // ordinary for-loop
15111511
mustMatchToken(Token.SEMI, "msg.no.semi.for", true);
15121512
if (peekToken() == Token.SEMI) {
15131513
// no loop condition
15141514
cond = new EmptyExpression(ts.tokenBeg, 1);
15151515
cond.setLineno(ts.lineno);
15161516
} else {
1517-
cond = expr();
1517+
cond = expr(false);
15181518
}
15191519

15201520
mustMatchToken(Token.SEMI, "msg.no.semi.for.cond", true);
@@ -1523,7 +1523,7 @@ && matchToken(Token.NAME, true)
15231523
incr = new EmptyExpression(tmpPos, 1);
15241524
incr.setLineno(ts.lineno);
15251525
} else {
1526-
incr = expr();
1526+
incr = expr(false);
15271527
}
15281528
}
15291529

@@ -1593,7 +1593,7 @@ private AstNode forLoopInit(int tt) throws IOException {
15931593
consumeToken();
15941594
init = variables(tt, ts.tokenBeg, false);
15951595
} else {
1596-
init = expr();
1596+
init = expr(false);
15971597
}
15981598
return init;
15991599
} finally {
@@ -1667,7 +1667,7 @@ private TryStatement tryStatement() throws IOException {
16671667

16681668
if (matchToken(Token.IF, true)) {
16691669
guardPos = ts.tokenBeg;
1670-
catchCond = expr();
1670+
catchCond = expr(false);
16711671
} else {
16721672
sawDefaultCatch = true;
16731673
}
@@ -1751,7 +1751,7 @@ private ThrowStatement throwStatement() throws IOException {
17511751
// see bug 256617
17521752
reportError("msg.bad.throw.eol");
17531753
}
1754-
AstNode expr = expr();
1754+
AstNode expr = expr(false);
17551755
ThrowStatement pn = new ThrowStatement(pos, expr);
17561756
pn.setLineno(lineno);
17571757
return pn;
@@ -1853,7 +1853,7 @@ private WithStatement withStatement() throws IOException {
18531853
int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
18541854
if (mustMatchToken(Token.LP, "msg.no.paren.with", true)) lp = ts.tokenBeg;
18551855

1856-
AstNode obj = expr();
1856+
AstNode obj = expr(false);
18571857

18581858
if (mustMatchToken(Token.RP, "msg.no.paren.after.with", true)) rp = ts.tokenBeg;
18591859

@@ -1927,7 +1927,7 @@ private AstNode returnOrYield(int tt, boolean exprContext) throws IOException {
19271927
}
19281928
// fallthrough
19291929
default:
1930-
e = expr();
1930+
e = expr(false);
19311931
end = getNodeEnd(e);
19321932
}
19331933

@@ -2004,7 +2004,7 @@ private AstNode defaultXmlNamespace() throws IOException {
20042004
reportError("msg.bad.namespace");
20052005
}
20062006

2007-
AstNode e = expr();
2007+
AstNode e = expr(false);
20082008
UnaryExpression dxmln = new UnaryExpression(pos, getNodeEnd(e) - pos);
20092009
dxmln.setOperator(Token.DEFAULTNAMESPACE);
20102010
dxmln.setOperand(e);
@@ -2046,7 +2046,7 @@ private AstNode nameOrLabel() throws IOException {
20462046

20472047
// set check for label and call down to primaryExpr
20482048
currentFlaggedToken |= TI_CHECK_LABEL;
2049-
AstNode expr = expr();
2049+
AstNode expr = expr(false);
20502050

20512051
if (expr.getType() != Token.LABEL) {
20522052
AstNode n = new ExpressionStatement(expr, !insideFunction());
@@ -2061,7 +2061,7 @@ private AstNode nameOrLabel() throws IOException {
20612061
AstNode stmt = null;
20622062
while (peekToken() == Token.NAME) {
20632063
currentFlaggedToken |= TI_CHECK_LABEL;
2064-
expr = expr();
2064+
expr = expr(false);
20652065
if (expr.getType() != Token.LABEL) {
20662066
stmt = new ExpressionStatement(expr, !insideFunction());
20672067
autoInsertSemicolon(stmt);
@@ -2203,7 +2203,7 @@ private AstNode let(boolean isStatement, int pos) throws IOException {
22032203
pn.setType(Token.LET);
22042204
} else {
22052205
// let expression
2206-
AstNode expr = expr();
2206+
AstNode expr = expr(false);
22072207
pn.setLength(getNodeEnd(expr) - pos);
22082208
pn.setBody(expr);
22092209
if (isStatement) {
@@ -2287,10 +2287,6 @@ else if (symDeclType == Token.LP) {
22872287
}
22882288
}
22892289

2290-
private AstNode expr() throws IOException {
2291-
return expr(false);
2292-
}
2293-
22942290
private AstNode expr(boolean allowTrailingComma) throws IOException {
22952291
AstNode pn = assignExpr();
22962292
int pos = pn.getPosition();
@@ -2641,7 +2637,7 @@ private AstNode xmlInitializer() throws IOException {
26412637
AstNode expr =
26422638
(peekToken() == Token.RC)
26432639
? new EmptyExpression(beg, ts.tokenEnd - beg)
2644-
: expr();
2640+
: expr(false);
26452641
mustMatchToken(Token.RC, "msg.syntax", true);
26462642
XmlExpression xexpr = new XmlExpression(beg, expr);
26472643
xexpr.setIsXmlAttribute(ts.isXMLAttribute());
@@ -2773,7 +2769,7 @@ private AstNode memberExprTail(boolean allowCallSyntax, AstNode pn) throws IOExc
27732769
lineno = ts.lineno;
27742770
mustHaveXML();
27752771
setRequiresActivation();
2776-
AstNode filter = expr();
2772+
AstNode filter = expr(false);
27772773
int end = getNodeEnd(filter);
27782774
if (mustMatchToken(Token.RP, "msg.no.paren", true)) {
27792775
rp = ts.tokenBeg;
@@ -2792,7 +2788,7 @@ private AstNode memberExprTail(boolean allowCallSyntax, AstNode pn) throws IOExc
27922788
consumeToken();
27932789
int lb = ts.tokenBeg, rb = -1;
27942790
lineno = ts.lineno;
2795-
AstNode expr = expr();
2791+
AstNode expr = expr(false);
27962792
end = getNodeEnd(expr);
27972793
if (mustMatchToken(Token.RB, "msg.no.bracket.index", true)) {
27982794
rb = ts.tokenBeg;
@@ -3043,7 +3039,7 @@ private AstNode propertyName(int atPos, int memberTypeFlags) throws IOException
30433039
*/
30443040
private XmlElemRef xmlElemRef(int atPos, Name namespace, int colonPos) throws IOException {
30453041
int lb = ts.tokenBeg, rb = -1, pos = atPos != -1 ? atPos : lb;
3046-
AstNode expr = expr();
3042+
AstNode expr = expr(false);
30473043
int end = getNodeEnd(expr);
30483044
if (mustMatchToken(Token.RB, "msg.no.bracket.index", true)) {
30493045
rb = ts.tokenBeg;
@@ -3366,7 +3362,7 @@ private ArrayComprehensionLoop arrayComprehensionLoop() throws IOException {
33663362
default:
33673363
reportError("msg.in.after.for.name");
33683364
}
3369-
AstNode obj = expr();
3365+
AstNode obj = expr(false);
33703366
if (mustMatchToken(Token.RP, "msg.no.paren.for.ctrl", true)) rp = ts.tokenBeg - pos;
33713367

33723368
pn.setLength(ts.tokenEnd - pos);
@@ -3451,7 +3447,7 @@ private GeneratorExpressionLoop generatorExpressionLoop() throws IOException {
34513447
}
34523448

34533449
if (mustMatchToken(Token.IN, "msg.in.after.for.name", true)) inPos = ts.tokenBeg - pos;
3454-
AstNode obj = expr();
3450+
AstNode obj = expr(false);
34553451
if (mustMatchToken(Token.RP, "msg.no.paren.for.ctrl", true)) rp = ts.tokenBeg - pos;
34563452

34573453
pn.setLength(ts.tokenEnd - pos);
@@ -3733,7 +3729,7 @@ private AstNode templateLiteral(boolean isTaggedLiteral) throws IOException {
37333729
int tt = ts.readTemplateLiteral(isTaggedLiteral);
37343730
while (tt == Token.TEMPLATE_LITERAL_SUBST) {
37353731
elements.add(createTemplateLiteralCharacters(posChars));
3736-
elements.add(expr());
3732+
elements.add(expr(false));
37373733
mustMatchToken(Token.RC, "msg.syntax", true);
37383734
posChars = ts.tokenBeg + 1;
37393735
tt = ts.readTemplateLiteral(isTaggedLiteral);

0 commit comments

Comments
 (0)