Skip to content

Commit a845407

Browse files
author
Irina Yatsenko
committed
Mark strings used by 'in' operator as property names
1 parent aeb54d8 commit a845407

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

lib/Parser/Parse.cpp

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8834,11 +8834,14 @@ ParseNodePtr Parser::ParseExpr(int oplMin,
88348834
break;
88358835
}
88368836
}
8837-
else
8837+
else // a binary operator
88388838
{
8839+
ParseNode* pnode1 = pnode;
8840+
88398841
// Parse the operand, make a new node, and look for more
88408842
IdentToken token;
8841-
pnodeT = ParseExpr<buildAST>(opl, NULL, fAllowIn, FALSE, pNameHint, &hintLength, &hintOffset, &token, false, nullptr, plastRParen);
8843+
ParseNode* pnode2 = ParseExpr<buildAST>(
8844+
opl, nullptr, fAllowIn, FALSE, pNameHint, &hintLength, &hintOffset, &token, false, nullptr, plastRParen);
88428845

88438846
// Detect nested function escapes of the pattern "o.f = function(){...}" or "o[s] = function(){...}".
88448847
// Doing so in the parser allows us to disable stack-nested-functions in common cases where an escape
@@ -8850,36 +8853,42 @@ ParseNodePtr Parser::ParseExpr(int oplMin,
88508853

88518854
if (buildAST)
88528855
{
8853-
pnode = CreateBinNode(nop, pnode, pnodeT);
8854-
Assert(pnode->AsParseNodeBin()->pnode2 != NULL);
8855-
if (pnode->AsParseNodeBin()->pnode2->nop == knopFncDecl)
8856+
Assert(pnode2 != nullptr);
8857+
if (pnode2->nop == knopFncDecl)
88568858
{
88578859
Assert(hintLength >= hintOffset);
8858-
pnode->AsParseNodeBin()->pnode2->AsParseNodeFnc()->hint = pNameHint;
8859-
pnode->AsParseNodeBin()->pnode2->AsParseNodeFnc()->hintLength = hintLength;
8860-
pnode->AsParseNodeBin()->pnode2->AsParseNodeFnc()->hintOffset = hintOffset;
8860+
pnode2->AsParseNodeFnc()->hint = pNameHint;
8861+
pnode2->AsParseNodeFnc()->hintLength = hintLength;
8862+
pnode2->AsParseNodeFnc()->hintOffset = hintOffset;
88618863

8862-
if (pnode->AsParseNodeBin()->pnode1->nop == knopDot)
8864+
if (pnode1->nop == knopDot)
88638865
{
8864-
pnode->AsParseNodeBin()->pnode2->AsParseNodeFnc()->isNameIdentifierRef = false;
8866+
pnode2->AsParseNodeFnc()->isNameIdentifierRef = false;
88658867
}
8866-
else if (pnode->AsParseNodeBin()->pnode1->nop == knopName)
8868+
else if (pnode1->nop == knopName)
88678869
{
8868-
PidRefStack *pidRef = pnode->AsParseNodeBin()->pnode1->AsParseNodeName()->pid->GetTopRef();
8870+
PidRefStack *pidRef = pnode1->AsParseNodeName()->pid->GetTopRef();
88698871
pidRef->isFuncAssignment = true;
88708872
}
88718873
}
8872-
if (pnode->AsParseNodeBin()->pnode2->nop == knopClassDecl && pnode->AsParseNodeBin()->pnode1->nop == knopDot)
8874+
else if (pnode2->nop == knopClassDecl && pnode1->nop == knopDot)
88738875
{
8874-
Assert(pnode->AsParseNodeBin()->pnode2->AsParseNodeClass()->pnodeConstructor);
8876+
Assert(pnode2->AsParseNodeClass()->pnodeConstructor);
88758877

8876-
if (!pnode->AsParseNodeBin()->pnode2->AsParseNodeClass()->pnodeConstructor->pid)
8878+
if (!pnode2->AsParseNodeClass()->pnodeConstructor->pid)
88778879
{
8878-
pnode->AsParseNodeBin()->pnode2->AsParseNodeClass()->pnodeConstructor->isNameIdentifierRef = false;
8880+
pnode2->AsParseNodeClass()->pnodeConstructor->isNameIdentifierRef = false;
88798881
}
88808882
}
8883+
else if (pnode1->nop == knopName && nop == knopIn)
8884+
{
8885+
PidRefStack* pidRef = pnode1->AsParseNodeName()->pid->GetTopRef();
8886+
pidRef->SetIsUsedInLdElem(true);
8887+
}
8888+
8889+
pnode = CreateBinNode(nop, pnode1, pnode2);
88818890
}
8882-
pNameHint = NULL;
8891+
pNameHint = nullptr;
88838892
}
88848893
}
88858894

0 commit comments

Comments
 (0)