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

Side by Side Diff: src/ast/prettyprinter.cc

Issue 1695393003: [es6] Implement for-of iterator finalization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable iterator test for Ignition Created 4 years, 10 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/ast/prettyprinter.h ('k') | src/ast/scopes.cc » ('j') | 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 "src/ast/prettyprinter.h" 5 #include "src/ast/prettyprinter.h"
6 6
7 #include <stdarg.h> 7 #include <stdarg.h>
8 8
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 PrintLiteralIndented("NAME", program->name(), true); 1196 PrintLiteralIndented("NAME", program->name(), true);
1197 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true); 1197 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true);
1198 PrintParameters(program->scope()); 1198 PrintParameters(program->scope());
1199 PrintDeclarations(program->scope()->declarations()); 1199 PrintDeclarations(program->scope()->declarations());
1200 PrintStatements(program->body()); 1200 PrintStatements(program->body());
1201 } 1201 }
1202 return Output(); 1202 return Output();
1203 } 1203 }
1204 1204
1205 1205
1206 void AstPrinter::PrintOut(Isolate* isolate, AstNode* node) {
1207 AstPrinter printer(isolate);
1208 printer.Init();
1209 printer.Visit(node);
1210 PrintF("%s", printer.Output());
1211 }
1212
1213
1206 void AstPrinter::PrintDeclarations(ZoneList<Declaration*>* declarations) { 1214 void AstPrinter::PrintDeclarations(ZoneList<Declaration*>* declarations) {
1207 if (declarations->length() > 0) { 1215 if (declarations->length() > 0) {
1208 IndentedScope indent(this, "DECLS"); 1216 IndentedScope indent(this, "DECLS");
1209 for (int i = 0; i < declarations->length(); i++) { 1217 for (int i = 0; i < declarations->length(); i++) {
1210 Visit(declarations->at(i)); 1218 Visit(declarations->at(i));
1211 } 1219 }
1212 } 1220 }
1213 } 1221 }
1214 1222
1215 1223
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 PrintIndentedVisit("IN", node->enumerable()); 1391 PrintIndentedVisit("IN", node->enumerable());
1384 PrintIndentedVisit("BODY", node->body()); 1392 PrintIndentedVisit("BODY", node->body());
1385 } 1393 }
1386 1394
1387 1395
1388 void AstPrinter::VisitForOfStatement(ForOfStatement* node) { 1396 void AstPrinter::VisitForOfStatement(ForOfStatement* node) {
1389 IndentedScope indent(this, "FOR OF", node->position()); 1397 IndentedScope indent(this, "FOR OF", node->position());
1390 PrintIndentedVisit("FOR", node->each()); 1398 PrintIndentedVisit("FOR", node->each());
1391 PrintIndentedVisit("OF", node->iterable()); 1399 PrintIndentedVisit("OF", node->iterable());
1392 PrintIndentedVisit("BODY", node->body()); 1400 PrintIndentedVisit("BODY", node->body());
1401 PrintIndentedVisit("INIT", node->assign_iterator());
1402 PrintIndentedVisit("NEXT", node->next_result());
1403 PrintIndentedVisit("EACH", node->assign_each());
1404 PrintIndentedVisit("DONE", node->result_done());
1393 } 1405 }
1394 1406
1395 1407
1396 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { 1408 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
1397 IndentedScope indent(this, "TRY CATCH", node->position()); 1409 IndentedScope indent(this, "TRY CATCH", node->position());
1398 PrintIndentedVisit("TRY", node->try_block()); 1410 PrintIndentedVisit("TRY", node->try_block());
1399 PrintLiteralWithModeIndented("CATCHVAR", 1411 PrintLiteralWithModeIndented("CATCHVAR",
1400 node->variable(), 1412 node->variable(),
1401 node->variable()->name()); 1413 node->variable()->name());
1402 PrintIndentedVisit("CATCH", node->catch_block()); 1414 PrintIndentedVisit("CATCH", node->catch_block());
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 if (node->values()->length() > 0) { 1547 if (node->values()->length() > 0) {
1536 IndentedScope indent(this, "VALUES", node->position()); 1548 IndentedScope indent(this, "VALUES", node->position());
1537 for (int i = 0; i < node->values()->length(); i++) { 1549 for (int i = 0; i < node->values()->length(); i++) {
1538 Visit(node->values()->at(i)); 1550 Visit(node->values()->at(i));
1539 } 1551 }
1540 } 1552 }
1541 } 1553 }
1542 1554
1543 1555
1544 void AstPrinter::VisitVariableProxy(VariableProxy* node) { 1556 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
1545 Variable* var = node->var();
1546 EmbeddedVector<char, 128> buf; 1557 EmbeddedVector<char, 128> buf;
1547 int pos = 1558 int pos =
1548 FormatSlotNode(&buf, node, "VAR PROXY", node->VariableFeedbackSlot()); 1559 FormatSlotNode(&buf, node, "VAR PROXY", node->VariableFeedbackSlot());
1549 1560
1550 switch (var->location()) { 1561 if (!node->is_resolved()) {
1551 case VariableLocation::UNALLOCATED: 1562 SNPrintF(buf + pos, " unresolved");
1552 break; 1563 PrintLiteralWithModeIndented(buf.start(), nullptr, node->name());
1553 case VariableLocation::PARAMETER: 1564 } else {
1554 SNPrintF(buf + pos, " parameter[%d]", var->index()); 1565 Variable* var = node->var();
1555 break; 1566 switch (var->location()) {
1556 case VariableLocation::LOCAL: 1567 case VariableLocation::UNALLOCATED:
1557 SNPrintF(buf + pos, " local[%d]", var->index()); 1568 break;
1558 break; 1569 case VariableLocation::PARAMETER:
1559 case VariableLocation::CONTEXT: 1570 SNPrintF(buf + pos, " parameter[%d]", var->index());
1560 SNPrintF(buf + pos, " context[%d]", var->index()); 1571 break;
1561 break; 1572 case VariableLocation::LOCAL:
1562 case VariableLocation::GLOBAL: 1573 SNPrintF(buf + pos, " local[%d]", var->index());
1563 SNPrintF(buf + pos, " global[%d]", var->index()); 1574 break;
1564 break; 1575 case VariableLocation::CONTEXT:
1565 case VariableLocation::LOOKUP: 1576 SNPrintF(buf + pos, " context[%d]", var->index());
1566 SNPrintF(buf + pos, " lookup"); 1577 break;
1567 break; 1578 case VariableLocation::GLOBAL:
1579 SNPrintF(buf + pos, " global[%d]", var->index());
1580 break;
1581 case VariableLocation::LOOKUP:
1582 SNPrintF(buf + pos, " lookup");
1583 break;
1584 }
1585 PrintLiteralWithModeIndented(buf.start(), var, node->name());
1568 } 1586 }
1569 PrintLiteralWithModeIndented(buf.start(), var, node->name());
1570 } 1587 }
1571 1588
1572 1589
1573 void AstPrinter::VisitAssignment(Assignment* node) { 1590 void AstPrinter::VisitAssignment(Assignment* node) {
1574 IndentedScope indent(this, Token::Name(node->op()), node->position()); 1591 IndentedScope indent(this, Token::Name(node->op()), node->position());
1575 Visit(node->target()); 1592 Visit(node->target());
1576 Visit(node->value()); 1593 Visit(node->value());
1577 } 1594 }
1578 1595
1579 1596
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 void AstPrinter::VisitRewritableAssignmentExpression( 1708 void AstPrinter::VisitRewritableAssignmentExpression(
1692 RewritableAssignmentExpression* node) { 1709 RewritableAssignmentExpression* node) {
1693 Visit(node->expression()); 1710 Visit(node->expression());
1694 } 1711 }
1695 1712
1696 1713
1697 #endif // DEBUG 1714 #endif // DEBUG
1698 1715
1699 } // namespace internal 1716 } // namespace internal
1700 } // namespace v8 1717 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/prettyprinter.h ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698