summaryrefslogtreecommitdiff
path: root/chromium/v8/src/ast/prettyprinter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/v8/src/ast/prettyprinter.cc')
-rw-r--r--chromium/v8/src/ast/prettyprinter.cc80
1 files changed, 67 insertions, 13 deletions
diff --git a/chromium/v8/src/ast/prettyprinter.cc b/chromium/v8/src/ast/prettyprinter.cc
index c0fe3baff39..581517ee4ec 100644
--- a/chromium/v8/src/ast/prettyprinter.cc
+++ b/chromium/v8/src/ast/prettyprinter.cc
@@ -27,6 +27,8 @@ CallPrinter::CallPrinter(Isolate* isolate, bool is_user_js)
is_call_error_ = false;
is_iterator_error_ = false;
is_async_iterator_error_ = false;
+ destructuring_prop_ = nullptr;
+ destructuring_assignment_ = nullptr;
is_user_js_ = is_user_js;
function_kind_ = kNormalFunction;
InitializeAstVisitor(isolate);
@@ -299,24 +301,50 @@ void CallPrinter::VisitVariableProxy(VariableProxy* node) {
void CallPrinter::VisitAssignment(Assignment* node) {
- Find(node->target());
- if (node->target()->IsArrayLiteral()) {
- // Special case the visit for destructuring array assignment.
- bool was_found = false;
- if (node->value()->position() == position_) {
- is_iterator_error_ = true;
+ bool was_found = false;
+ if (node->target()->IsObjectLiteral()) {
+ ObjectLiteral* target = node->target()->AsObjectLiteral();
+ if (target->position() == position_) {
was_found = !found_;
- if (was_found) {
- found_ = true;
+ found_ = true;
+ destructuring_assignment_ = node;
+ } else {
+ for (ObjectLiteralProperty* prop : *target->properties()) {
+ if (prop->value()->position() == position_) {
+ was_found = !found_;
+ found_ = true;
+ destructuring_prop_ = prop;
+ destructuring_assignment_ = node;
+ break;
+ }
}
}
- Find(node->value(), true);
- if (was_found) {
- done_ = true;
- found_ = false;
+ }
+ if (!was_found) {
+ Find(node->target());
+ if (node->target()->IsArrayLiteral()) {
+ // Special case the visit for destructuring array assignment.
+ bool was_found = false;
+ if (node->value()->position() == position_) {
+ is_iterator_error_ = true;
+ was_found = !found_;
+ found_ = true;
+ }
+ Find(node->value(), true);
+ if (was_found) {
+ done_ = true;
+ found_ = false;
+ }
+ } else {
+ Find(node->value());
}
} else {
- Find(node->value());
+ Find(node->value(), true);
+ }
+
+ if (was_found) {
+ done_ = true;
+ found_ = false;
}
}
@@ -342,6 +370,9 @@ void CallPrinter::VisitAwait(Await* node) { Find(node->expression()); }
void CallPrinter::VisitThrow(Throw* node) { Find(node->exception()); }
+void CallPrinter::VisitOptionalChain(OptionalChain* node) {
+ Find(node->expression());
+}
void CallPrinter::VisitProperty(Property* node) {
Expression* key = node->key();
@@ -349,12 +380,18 @@ void CallPrinter::VisitProperty(Property* node) {
if (literal != nullptr &&
literal->BuildValue(isolate_)->IsInternalizedString()) {
Find(node->obj(), true);
+ if (node->is_optional_chain_link()) {
+ Print("?");
+ }
Print(".");
// TODO(adamk): Teach Literal how to print its values without
// allocating on the heap.
PrintLiteral(literal->BuildValue(isolate_), false);
} else {
Find(node->obj(), true);
+ if (node->is_optional_chain_link()) {
+ Print("?.");
+ }
Print("[");
Find(key, true);
Print("]");
@@ -1272,6 +1309,11 @@ void AstPrinter::VisitThrow(Throw* node) {
Visit(node->exception());
}
+void AstPrinter::VisitOptionalChain(OptionalChain* node) {
+ IndentedScope indent(this, "OPTIONAL_CHAIN", node->position());
+ Visit(node->expression());
+}
+
void AstPrinter::VisitProperty(Property* node) {
EmbeddedVector<char, 128> buf;
SNPrintF(buf, "PROPERTY");
@@ -1289,6 +1331,18 @@ void AstPrinter::VisitProperty(Property* node) {
PrintIndentedVisit("PRIVATE_METHOD", node->key());
break;
}
+ case PRIVATE_GETTER_ONLY: {
+ PrintIndentedVisit("PRIVATE_GETTER_ONLY", node->key());
+ break;
+ }
+ case PRIVATE_SETTER_ONLY: {
+ PrintIndentedVisit("PRIVATE_SETTER_ONLY", node->key());
+ break;
+ }
+ case PRIVATE_GETTER_AND_SETTER: {
+ PrintIndentedVisit("PRIVATE_GETTER_AND_SETTER", node->key());
+ break;
+ }
case KEYED_PROPERTY:
case KEYED_SUPER_PROPERTY: {
PrintIndentedVisit("KEY", node->key());