Issue #2142 - Implement syntax for public/private fields and computed field names

This state still has the initializers scoped on .initializers local variable, which will be changed later.

Based-on: m-c 1499448, 1530084, 1530832, 1529448 (partial), 1532921, 1528039, 1528038, 1535166, 1550628,
              1535166, 1550628, 1541641, 1547133, 1540787, 1535804/9
This commit is contained in:
Martok 2023-04-06 03:10:50 +02:00 • committed by roytam1
commit 51db22ff2f
24 changed files with 1383 additions and 290 deletions

View file

@ -83,6 +83,7 @@ class NameResolver
}
case PNK_NAME:
case PNK_PRIVATE_NAME:
*foundName = true;
return buf->append(n->as<NameNode>().atom());
@ -136,6 +137,7 @@ class NameResolver
return cur;
switch (cur->getKind()) {
case PNK_PRIVATE_NAME:
case PNK_NAME: return cur; /* found the initialized declaration */
case PNK_THIS: return cur; /* Setting a property of 'this'. */
case PNK_FUNCTION: return nullptr; /* won't find an assignment or declaration */
@ -404,6 +406,7 @@ class NameResolver
break;
case PNK_OBJECT_PROPERTY_NAME:
case PNK_PRIVATE_NAME:
case PNK_STRING:
case PNK_TEMPLATE_STRING:
MOZ_ASSERT(cur->is<NameNode>());
@ -498,6 +501,19 @@ class NameResolver
break;
}
case PNK_CLASSFIELD: {
ClassField* node = &cur->as<ClassField>();
if (!resolve(&node->name(), prefix)) {
return false;
}
if (ParseNode* init = node->initializer()) {
if (!resolve(init, prefix)) {
return false;
}
}
break;
}
case PNK_ELEM: {
PropertyByValue* elem = &cur->as<PropertyByValue>();
if (!elem->isSuper() && !resolve(&elem->expression(), prefix))
@ -643,7 +659,7 @@ class NameResolver
if (!resolve(heritage, prefix))
return false;
}
if (!resolve(classNode->methodList(), prefix))
if (!resolve(classNode->memberList(), prefix))
return false;
break;
}
@ -757,7 +773,7 @@ class NameResolver
}
case PNK_OBJECT:
case PNK_CLASSMETHODLIST:
case PNK_CLASSMEMBERLIST:
for (ParseNode* element : cur->as<ListNode>().contents()) {
if (!resolve(element, prefix))
return false;