| OLD | NEW |
| 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/prettyprinter.h" | 5 #include "src/prettyprinter.h" |
| 6 | 6 |
| 7 #include <stdarg.h> | 7 #include <stdarg.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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 void CallPrinter::PrintLiteral(const AstRawString* value, bool quote) { | 422 void CallPrinter::PrintLiteral(const AstRawString* value, bool quote) { |
| 423 PrintLiteral(value->string(), quote); | 423 PrintLiteral(value->string(), quote); |
| 424 } | 424 } |
| 425 | 425 |
| 426 | 426 |
| 427 //----------------------------------------------------------------------------- | 427 //----------------------------------------------------------------------------- |
| 428 | 428 |
| 429 | 429 |
| 430 #ifdef DEBUG | 430 #ifdef DEBUG |
| 431 | 431 |
| 432 // A helper for ast nodes that use FeedbackVectorICSlots. | 432 // A helper for ast nodes that use FeedbackVectorSlots. |
| 433 static int FormatICSlotNode(Vector<char>* buf, Expression* node, | 433 static int FormatSlotNode(Vector<char>* buf, Expression* node, |
| 434 const char* node_name, FeedbackVectorICSlot slot) { | 434 const char* node_name, FeedbackVectorSlot slot) { |
| 435 int pos = SNPrintF(*buf, "%s", node_name); | 435 int pos = SNPrintF(*buf, "%s", node_name); |
| 436 if (!slot.IsInvalid()) { | 436 if (!slot.IsInvalid()) { |
| 437 pos = SNPrintF(*buf + pos, " ICSlot(%d)", slot.ToInt()); | 437 pos = SNPrintF(*buf + pos, " Slot(%d)", slot.ToInt()); |
| 438 } | 438 } |
| 439 return pos; | 439 return pos; |
| 440 } | 440 } |
| 441 | 441 |
| 442 | 442 |
| 443 PrettyPrinter::PrettyPrinter(Isolate* isolate, Zone* zone) { | 443 PrettyPrinter::PrettyPrinter(Isolate* isolate, Zone* zone) { |
| 444 output_ = NULL; | 444 output_ = NULL; |
| 445 size_ = 0; | 445 size_ = 0; |
| 446 pos_ = 0; | 446 pos_ = 0; |
| 447 InitializeAstVisitor(isolate, zone); | 447 InitializeAstVisitor(isolate, zone); |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 Visit(node->values()->at(i)); | 1471 Visit(node->values()->at(i)); |
| 1472 } | 1472 } |
| 1473 } | 1473 } |
| 1474 } | 1474 } |
| 1475 | 1475 |
| 1476 | 1476 |
| 1477 void AstPrinter::VisitVariableProxy(VariableProxy* node) { | 1477 void AstPrinter::VisitVariableProxy(VariableProxy* node) { |
| 1478 Variable* var = node->var(); | 1478 Variable* var = node->var(); |
| 1479 EmbeddedVector<char, 128> buf; | 1479 EmbeddedVector<char, 128> buf; |
| 1480 int pos = | 1480 int pos = |
| 1481 FormatICSlotNode(&buf, node, "VAR PROXY", node->VariableFeedbackSlot()); | 1481 FormatSlotNode(&buf, node, "VAR PROXY", node->VariableFeedbackSlot()); |
| 1482 | 1482 |
| 1483 switch (var->location()) { | 1483 switch (var->location()) { |
| 1484 case VariableLocation::UNALLOCATED: | 1484 case VariableLocation::UNALLOCATED: |
| 1485 break; | 1485 break; |
| 1486 case VariableLocation::PARAMETER: | 1486 case VariableLocation::PARAMETER: |
| 1487 SNPrintF(buf + pos, " parameter[%d]", var->index()); | 1487 SNPrintF(buf + pos, " parameter[%d]", var->index()); |
| 1488 break; | 1488 break; |
| 1489 case VariableLocation::LOCAL: | 1489 case VariableLocation::LOCAL: |
| 1490 SNPrintF(buf + pos, " local[%d]", var->index()); | 1490 SNPrintF(buf + pos, " local[%d]", var->index()); |
| 1491 break; | 1491 break; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1517 | 1517 |
| 1518 | 1518 |
| 1519 void AstPrinter::VisitThrow(Throw* node) { | 1519 void AstPrinter::VisitThrow(Throw* node) { |
| 1520 IndentedScope indent(this, "THROW", node->position()); | 1520 IndentedScope indent(this, "THROW", node->position()); |
| 1521 Visit(node->exception()); | 1521 Visit(node->exception()); |
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 | 1524 |
| 1525 void AstPrinter::VisitProperty(Property* node) { | 1525 void AstPrinter::VisitProperty(Property* node) { |
| 1526 EmbeddedVector<char, 128> buf; | 1526 EmbeddedVector<char, 128> buf; |
| 1527 FormatICSlotNode(&buf, node, "PROPERTY", node->PropertyFeedbackSlot()); | 1527 FormatSlotNode(&buf, node, "PROPERTY", node->PropertyFeedbackSlot()); |
| 1528 IndentedScope indent(this, buf.start(), node->position()); | 1528 IndentedScope indent(this, buf.start(), node->position()); |
| 1529 | 1529 |
| 1530 Visit(node->obj()); | 1530 Visit(node->obj()); |
| 1531 Literal* literal = node->key()->AsLiteral(); | 1531 Literal* literal = node->key()->AsLiteral(); |
| 1532 if (literal != NULL && literal->value()->IsInternalizedString()) { | 1532 if (literal != NULL && literal->value()->IsInternalizedString()) { |
| 1533 PrintLiteralIndented("NAME", literal->value(), false); | 1533 PrintLiteralIndented("NAME", literal->value(), false); |
| 1534 } else { | 1534 } else { |
| 1535 PrintIndentedVisit("KEY", node->key()); | 1535 PrintIndentedVisit("KEY", node->key()); |
| 1536 } | 1536 } |
| 1537 } | 1537 } |
| 1538 | 1538 |
| 1539 | 1539 |
| 1540 void AstPrinter::VisitCall(Call* node) { | 1540 void AstPrinter::VisitCall(Call* node) { |
| 1541 EmbeddedVector<char, 128> buf; | 1541 EmbeddedVector<char, 128> buf; |
| 1542 FormatICSlotNode(&buf, node, "CALL", node->CallFeedbackICSlot()); | 1542 FormatSlotNode(&buf, node, "CALL", node->CallFeedbackICSlot()); |
| 1543 IndentedScope indent(this, buf.start()); | 1543 IndentedScope indent(this, buf.start()); |
| 1544 | 1544 |
| 1545 Visit(node->expression()); | 1545 Visit(node->expression()); |
| 1546 PrintArguments(node->arguments()); | 1546 PrintArguments(node->arguments()); |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 | 1549 |
| 1550 void AstPrinter::VisitCallNew(CallNew* node) { | 1550 void AstPrinter::VisitCallNew(CallNew* node) { |
| 1551 IndentedScope indent(this, "CALL NEW", node->position()); | 1551 IndentedScope indent(this, "CALL NEW", node->position()); |
| 1552 Visit(node->expression()); | 1552 Visit(node->expression()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 | 1614 |
| 1615 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { | 1615 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { |
| 1616 IndentedScope indent(this, "SUPER-CALL-REFERENCE", node->position()); | 1616 IndentedScope indent(this, "SUPER-CALL-REFERENCE", node->position()); |
| 1617 } | 1617 } |
| 1618 | 1618 |
| 1619 | 1619 |
| 1620 #endif // DEBUG | 1620 #endif // DEBUG |
| 1621 | 1621 |
| 1622 } // namespace internal | 1622 } // namespace internal |
| 1623 } // namespace v8 | 1623 } // namespace v8 |
| OLD | NEW |