@@ -59,15 +59,21 @@ ParseNodeVar * ParseNode::AsParseNodeVar()
5959 return reinterpret_cast <ParseNodeVar *>(this );
6060}
6161
62- ParseNodePid * ParseNode::AsParseNodePid ()
62+ ParseNodeStr * ParseNode::AsParseNodeStr ()
6363{
64- Assert (this ->nop == knopName || this ->nop == knopStr);
65- return reinterpret_cast <ParseNodePid *>(this );
64+ Assert (this ->nop == knopStr);
65+ return reinterpret_cast <ParseNodeStr *>(this );
66+ }
67+
68+ ParseNodeName * ParseNode::AsParseNodeName ()
69+ {
70+ Assert (this ->nop == knopName);
71+ return reinterpret_cast <ParseNodeName *>(this );
6672}
6773
6874ParseNodeSpecialName * ParseNode::AsParseNodeSpecialName ()
6975{
70- Assert (this ->nop == knopName && this ->AsParseNodePid ()->IsSpecialName ());
76+ Assert (this ->nop == knopName && this ->AsParseNodeName ()->IsSpecialName ());
7177 return reinterpret_cast <ParseNodeSpecialName *>(this );
7278}
7379
@@ -245,9 +251,13 @@ ParseNodeModule * ParseNode::AsParseNodeModule()
245251
246252IdentPtr ParseNode::name ()
247253{
248- if (this ->nop == knopName || this -> nop == knopStr)
254+ if (this ->nop == knopStr)
249255 {
250- return this ->AsParseNodePid ()->pid ;
256+ return this ->AsParseNodeStr ()->pid ;
257+ }
258+ else if (this ->nop == knopName)
259+ {
260+ return this ->AsParseNodeName ()->pid ;
251261 }
252262 else if (this ->nop == knopVarDecl || this ->nop == knopConstDecl)
253263 {
@@ -274,7 +284,7 @@ ParseNodePtr ParseNode::GetFormalNext()
274284
275285bool ParseNode::IsUserIdentifier ()
276286{
277- return this ->nop == knopName && !this ->AsParseNodePid ()->IsSpecialName ();
287+ return this ->nop == knopName && !this ->AsParseNodeName ()->IsSpecialName ();
278288}
279289
280290ParseNodeUni::ParseNodeUni (OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnode1)
@@ -286,6 +296,13 @@ ParseNodeUni::ParseNodeUni(OpCode nop, charcount_t ichMin, charcount_t ichLim, P
286296ParseNodeBin::ParseNodeBin (OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnode1, ParseNode * pnode2)
287297 : ParseNode(nop, ichMin, ichLim)
288298{
299+ // Member name is either a string or a computed name
300+ Assert ((nop != knopMember && nop != knopMemberShort && nop != knopObjectPatternMember && nop != knopGetMember && nop != knopSetMember)
301+ || (pnode1->nop == knopStr || pnode1->nop == knopComputedName));
302+
303+ // Dot's rhs has to be a name;
304+ Assert (nop != knopDot || pnode2->nop == knopName);
305+
289306 this ->pnode1 = pnode1;
290307 this ->pnode2 = pnode2;
291308
@@ -326,21 +343,45 @@ ParseNodeRegExp::ParseNodeRegExp(OpCode nop, charcount_t ichMin, charcount_t ich
326343 this ->regexPatternIndex = 0 ;
327344}
328345
329- ParseNodePid::ParseNodePid (OpCode nop, charcount_t ichMin, charcount_t ichLim, IdentPtr pid )
330- : ParseNode(nop , ichMin, ichLim)
346+ ParseNodeStr::ParseNodeStr ( charcount_t ichMin, charcount_t ichLim, IdentPtr name )
347+ : ParseNode(knopStr , ichMin, ichLim), pid(name )
331348{
332- this ->pid = pid;
333- this ->sym = nullptr ;
349+ }
350+
351+ ParseNodeName::ParseNodeName (charcount_t ichMin, charcount_t ichLim, IdentPtr name)
352+ : ParseNode(knopName, ichMin, ichLim), pid(name)
353+ {
354+ this ->sym = nullptr ;
334355 this ->symRef = nullptr ;
335356 this ->isSpecialName = false ;
336357}
337358
359+ void ParseNodeName::SetSymRef (PidRefStack * ref)
360+ {
361+ Assert (this ->symRef == nullptr );
362+ this ->symRef = ref->GetSymRef ();
363+ }
364+
365+ Js::PropertyId ParseNodeName::PropertyIdFromNameNode () const
366+ {
367+ Js::PropertyId propertyId;
368+ Symbol *sym = this ->sym ;
369+ if (sym)
370+ {
371+ propertyId = sym->GetPosition ();
372+ }
373+ else
374+ {
375+ propertyId = this ->pid ->GetPropertyId ();
376+ }
377+ return propertyId;
378+ }
379+
338380ParseNodeVar::ParseNodeVar (OpCode nop, charcount_t ichMin, charcount_t ichLim, IdentPtr name)
339- : ParseNode(nop, ichMin, ichLim)
381+ : ParseNode(nop, ichMin, ichLim), pid(name)
340382{
341383 Assert (nop == knopVarDecl || nop == knopConstDecl || nop == knopLetDecl || nop == knopTemp);
342384
343- this ->pid = name;
344385 this ->pnodeInit = nullptr ;
345386 this ->pnodeNext = nullptr ;
346387 this ->sym = nullptr ;
@@ -545,7 +586,7 @@ ParseNodeFinally::ParseNodeFinally(OpCode nop, charcount_t ichMin, charcount_t i
545586}
546587
547588ParseNodeSpecialName::ParseNodeSpecialName (charcount_t ichMin, charcount_t ichLim, IdentPtr pid)
548- : ParseNodePid(knopName, ichMin, ichLim, pid)
589+ : ParseNodeName( ichMin, ichLim, pid)
549590{
550591 this ->SetIsSpecialName ();
551592 this ->isThis = false ;
0 commit comments