| 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/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" |
| 11 #include "src/base/platform/platform.h" | 11 #include "src/base/platform/platform.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 #define RETURN_IF_FIND_NODE(node) \ |
| 17 do { \ |
| 18 AstNode* tmp = node; \ |
| 19 if (tmp != nullptr) { \ |
| 20 Find(tmp); \ |
| 21 return; \ |
| 22 } \ |
| 23 } while (false) |
| 24 |
| 16 CallPrinter::CallPrinter(Isolate* isolate) { | 25 CallPrinter::CallPrinter(Isolate* isolate) { |
| 17 output_ = NULL; | 26 output_ = NULL; |
| 18 size_ = 0; | 27 size_ = 0; |
| 19 pos_ = 0; | 28 pos_ = 0; |
| 20 position_ = 0; | 29 position_ = 0; |
| 21 found_ = false; | 30 found_ = false; |
| 22 done_ = false; | 31 done_ = false; |
| 23 InitializeAstVisitor(isolate); | 32 InitializeAstVisitor(isolate); |
| 24 } | 33 } |
| 25 | 34 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 399 |
| 391 | 400 |
| 392 void CallPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) {} | 401 void CallPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) {} |
| 393 | 402 |
| 394 | 403 |
| 395 void CallPrinter::VisitSuperCallReference(SuperCallReference* node) { | 404 void CallPrinter::VisitSuperCallReference(SuperCallReference* node) { |
| 396 Print("super"); | 405 Print("super"); |
| 397 } | 406 } |
| 398 | 407 |
| 399 | 408 |
| 409 void CallPrinter::VisitRewritableExpression(RewritableExpression* node) { |
| 410 Find(node->expression()); |
| 411 } |
| 412 |
| 413 |
| 400 void CallPrinter::FindStatements(ZoneList<Statement*>* statements) { | 414 void CallPrinter::FindStatements(ZoneList<Statement*>* statements) { |
| 401 if (statements == NULL) return; | 415 if (statements == NULL) return; |
| 402 for (int i = 0; i < statements->length(); i++) { | 416 for (int i = 0; i < statements->length(); i++) { |
| 403 Find(statements->at(i)); | 417 Find(statements->at(i)); |
| 404 } | 418 } |
| 405 } | 419 } |
| 406 | 420 |
| 407 | 421 |
| 408 void CallPrinter::FindArguments(ZoneList<Expression*>* arguments) { | 422 void CallPrinter::FindArguments(ZoneList<Expression*>* arguments) { |
| 409 if (found_) return; | 423 if (found_) return; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 void PrettyPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) { | 915 void PrettyPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) { |
| 902 Print("<super-property-reference>"); | 916 Print("<super-property-reference>"); |
| 903 } | 917 } |
| 904 | 918 |
| 905 | 919 |
| 906 void PrettyPrinter::VisitSuperCallReference(SuperCallReference* node) { | 920 void PrettyPrinter::VisitSuperCallReference(SuperCallReference* node) { |
| 907 Print("<super-call-reference>"); | 921 Print("<super-call-reference>"); |
| 908 } | 922 } |
| 909 | 923 |
| 910 | 924 |
| 925 void PrettyPrinter::VisitRewritableExpression(RewritableExpression* node) { |
| 926 Visit(node->expression()); |
| 927 } |
| 928 |
| 929 |
| 911 const char* PrettyPrinter::Print(AstNode* node) { | 930 const char* PrettyPrinter::Print(AstNode* node) { |
| 912 Init(); | 931 Init(); |
| 913 Visit(node); | 932 Visit(node); |
| 914 return output_; | 933 return output_; |
| 915 } | 934 } |
| 916 | 935 |
| 917 | 936 |
| 918 const char* PrettyPrinter::PrintExpression(FunctionLiteral* program) { | 937 const char* PrettyPrinter::PrintExpression(FunctionLiteral* program) { |
| 919 Init(); | 938 Init(); |
| 920 ExpressionStatement* statement = | 939 ExpressionStatement* statement = |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 void AstPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) { | 1671 void AstPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) { |
| 1653 IndentedScope indent(this, "SUPER-PROPERTY-REFERENCE", node->position()); | 1672 IndentedScope indent(this, "SUPER-PROPERTY-REFERENCE", node->position()); |
| 1654 } | 1673 } |
| 1655 | 1674 |
| 1656 | 1675 |
| 1657 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { | 1676 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { |
| 1658 IndentedScope indent(this, "SUPER-CALL-REFERENCE", node->position()); | 1677 IndentedScope indent(this, "SUPER-CALL-REFERENCE", node->position()); |
| 1659 } | 1678 } |
| 1660 | 1679 |
| 1661 | 1680 |
| 1681 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { |
| 1682 Visit(node->expression()); |
| 1683 } |
| 1684 |
| 1685 |
| 1662 #endif // DEBUG | 1686 #endif // DEBUG |
| 1663 | 1687 |
| 1664 } // namespace internal | 1688 } // namespace internal |
| 1665 } // namespace v8 | 1689 } // namespace v8 |
| OLD | NEW |