Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: src/prettyprinter.cc

Issue 1165613003: Fix issue with --print-ast and class expressions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed default case Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/prettyprinter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdarg.h> 5 #include <stdarg.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 PrintParameters(node->scope()); 1314 PrintParameters(node->scope());
1315 // We don't want to see the function literal in this case: it 1315 // We don't want to see the function literal in this case: it
1316 // will be printed via PrintProgram when the code for it is 1316 // will be printed via PrintProgram when the code for it is
1317 // generated. 1317 // generated.
1318 // PrintStatements(node->body()); 1318 // PrintStatements(node->body());
1319 } 1319 }
1320 1320
1321 1321
1322 void AstPrinter::VisitClassLiteral(ClassLiteral* node) { 1322 void AstPrinter::VisitClassLiteral(ClassLiteral* node) {
1323 IndentedScope indent(this, "CLASS LITERAL"); 1323 IndentedScope indent(this, "CLASS LITERAL");
1324 PrintLiteralIndented("NAME", node->name(), false); 1324 if (node->raw_name() != nullptr) {
1325 PrintLiteralIndented("NAME", node->name(), false);
1326 }
1327 if (node->extends() != nullptr) {
1328 PrintIndentedVisit("EXTENDS", node->extends());
1329 }
1330 PrintProperties(node->properties());
1325 } 1331 }
1326 1332
1327 1333
1334 void AstPrinter::PrintProperties(
1335 ZoneList<ObjectLiteral::Property*>* properties) {
1336 for (int i = 0; i < properties->length(); i++) {
1337 ObjectLiteral::Property* property = properties->at(i);
1338 const char* prop_kind = nullptr;
1339 switch (property->kind()) {
1340 case ObjectLiteral::Property::CONSTANT:
1341 prop_kind = "CONSTANT";
1342 break;
1343 case ObjectLiteral::Property::COMPUTED:
1344 prop_kind = "COMPUTED";
1345 break;
1346 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1347 prop_kind = "MATERIALIZED_LITERAL";
1348 break;
1349 case ObjectLiteral::Property::PROTOTYPE:
1350 prop_kind = "PROTOTYPE";
1351 break;
1352 case ObjectLiteral::Property::GETTER:
1353 prop_kind = "GETTER";
1354 break;
1355 case ObjectLiteral::Property::SETTER:
1356 prop_kind = "SETTER";
1357 break;
1358 }
1359 EmbeddedVector<char, 128> buf;
1360 SNPrintF(buf, "PROPERTY%s - %s", property->is_static() ? " - STATIC" : "",
1361 prop_kind);
1362 IndentedScope prop(this, buf.start());
1363 PrintIndentedVisit("KEY", properties->at(i)->key());
1364 PrintIndentedVisit("VALUE", properties->at(i)->value());
1365 }
1366 }
1367
1368
1328 void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) { 1369 void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
1329 IndentedScope indent(this, "NATIVE FUNC LITERAL"); 1370 IndentedScope indent(this, "NATIVE FUNC LITERAL");
1330 PrintLiteralIndented("NAME", node->name(), false); 1371 PrintLiteralIndented("NAME", node->name(), false);
1331 } 1372 }
1332 1373
1333 1374
1334 void AstPrinter::VisitConditional(Conditional* node) { 1375 void AstPrinter::VisitConditional(Conditional* node) {
1335 IndentedScope indent(this, "CONDITIONAL"); 1376 IndentedScope indent(this, "CONDITIONAL");
1336 PrintIndentedVisit("CONDITION", node->condition()); 1377 PrintIndentedVisit("CONDITION", node->condition());
1337 PrintIndentedVisit("THEN", node->then_expression()); 1378 PrintIndentedVisit("THEN", node->then_expression());
1338 PrintIndentedVisit("ELSE", node->else_expression()); 1379 PrintIndentedVisit("ELSE", node->else_expression());
1339 } 1380 }
1340 1381
1341 1382
1342 // TODO(svenpanne) Start with IndentedScope. 1383 // TODO(svenpanne) Start with IndentedScope.
1343 void AstPrinter::VisitLiteral(Literal* node) { 1384 void AstPrinter::VisitLiteral(Literal* node) {
1344 PrintLiteralIndented("LITERAL", node->value(), true); 1385 PrintLiteralIndented("LITERAL", node->value(), true);
1345 } 1386 }
1346 1387
1347 1388
1348 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { 1389 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
1349 IndentedScope indent(this, "REGEXP LITERAL"); 1390 IndentedScope indent(this, "REGEXP LITERAL");
1350 PrintLiteralIndented("PATTERN", node->pattern(), false); 1391 PrintLiteralIndented("PATTERN", node->pattern(), false);
1351 PrintLiteralIndented("FLAGS", node->flags(), false); 1392 PrintLiteralIndented("FLAGS", node->flags(), false);
1352 } 1393 }
1353 1394
1354 1395
1355 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { 1396 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
1356 IndentedScope indent(this, "OBJ LITERAL"); 1397 IndentedScope indent(this, "OBJ LITERAL");
1357 for (int i = 0; i < node->properties()->length(); i++) { 1398 PrintProperties(node->properties());
1358 const char* prop_kind = NULL;
1359 switch (node->properties()->at(i)->kind()) {
1360 case ObjectLiteral::Property::CONSTANT:
1361 prop_kind = "PROPERTY - CONSTANT";
1362 break;
1363 case ObjectLiteral::Property::COMPUTED:
1364 prop_kind = "PROPERTY - COMPUTED";
1365 break;
1366 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1367 prop_kind = "PROPERTY - MATERIALIZED_LITERAL";
1368 break;
1369 case ObjectLiteral::Property::PROTOTYPE:
1370 prop_kind = "PROPERTY - PROTOTYPE";
1371 break;
1372 case ObjectLiteral::Property::GETTER:
1373 prop_kind = "PROPERTY - GETTER";
1374 break;
1375 case ObjectLiteral::Property::SETTER:
1376 prop_kind = "PROPERTY - SETTER";
1377 break;
1378 default:
1379 UNREACHABLE();
1380 }
1381 IndentedScope prop(this, prop_kind);
1382 PrintIndentedVisit("KEY", node->properties()->at(i)->key());
1383 PrintIndentedVisit("VALUE", node->properties()->at(i)->value());
1384 }
1385 } 1399 }
1386 1400
1387 1401
1388 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) { 1402 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) {
1389 IndentedScope indent(this, "ARRAY LITERAL"); 1403 IndentedScope indent(this, "ARRAY LITERAL");
1390 if (node->values()->length() > 0) { 1404 if (node->values()->length() > 0) {
1391 IndentedScope indent(this, "VALUES"); 1405 IndentedScope indent(this, "VALUES");
1392 for (int i = 0; i < node->values()->length(); i++) { 1406 for (int i = 0; i < node->values()->length(); i++) {
1393 Visit(node->values()->at(i)); 1407 Visit(node->values()->at(i));
1394 } 1408 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 } 1527 }
1514 1528
1515 1529
1516 void AstPrinter::VisitSuperReference(SuperReference* node) { 1530 void AstPrinter::VisitSuperReference(SuperReference* node) {
1517 IndentedScope indent(this, "SUPER-REFERENCE"); 1531 IndentedScope indent(this, "SUPER-REFERENCE");
1518 } 1532 }
1519 1533
1520 #endif // DEBUG 1534 #endif // DEBUG
1521 1535
1522 } } // namespace v8::internal 1536 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/prettyprinter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698