1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibJS: Implement private identifiers in optional chains

This commit is contained in:
davidot 2021-10-18 23:32:47 +02:00 committed by Linus Groh
parent 4c8090a45d
commit 2d48529073
3 changed files with 35 additions and 2 deletions

View file

@ -2704,6 +2704,11 @@ void OptionalChain::dump(int indent) const
print_indent(indent + 1);
outln("MemberReference({})", ref.mode == Mode::Optional ? "Optional" : "Not Optional");
ref.identifier->dump(indent + 2);
},
[&](PrivateMemberReference const& ref) {
print_indent(indent + 1);
outln("PrivateMemberReference({})", ref.mode == Mode::Optional ? "Optional" : "Not Optional");
ref.private_identifier->dump(indent + 2);
});
}
}
@ -2738,6 +2743,12 @@ Optional<OptionalChain::ReferenceAndValue> OptionalChain::to_reference_and_value
create_ast_node<SyntheticReferenceExpression>(source_range(), *base_reference, base),
ref.identifier,
false);
},
[&](PrivateMemberReference const& ref) -> NonnullRefPtr<Expression> {
return create_ast_node<MemberExpression>(source_range(),
create_ast_node<SyntheticReferenceExpression>(source_range(), *base_reference, base),
ref.private_identifier,
false);
});
if (is<CallExpression>(*expression)) {
base_reference = JS::Reference {};