OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 Visit(node->right()); | 410 Visit(node->right()); |
411 Print(")"); | 411 Print(")"); |
412 } | 412 } |
413 | 413 |
414 | 414 |
415 void PrettyPrinter::VisitThisFunction(ThisFunction* node) { | 415 void PrettyPrinter::VisitThisFunction(ThisFunction* node) { |
416 Print("<this-function>"); | 416 Print("<this-function>"); |
417 } | 417 } |
418 | 418 |
419 | 419 |
420 const char* PrettyPrinter::Print(Node* node) { | 420 const char* PrettyPrinter::Print(AstNode* node) { |
421 Init(); | 421 Init(); |
422 Visit(node); | 422 Visit(node); |
423 return output_; | 423 return output_; |
424 } | 424 } |
425 | 425 |
426 | 426 |
427 const char* PrettyPrinter::PrintExpression(FunctionLiteral* program) { | 427 const char* PrettyPrinter::PrintExpression(FunctionLiteral* program) { |
428 Init(); | 428 Init(); |
429 ExpressionStatement* statement = | 429 ExpressionStatement* statement = |
430 program->body()->at(0)->AsExpressionStatement(); | 430 program->body()->at(0)->AsExpressionStatement(); |
431 Visit(statement->expression()); | 431 Visit(statement->expression()); |
432 return output_; | 432 return output_; |
433 } | 433 } |
434 | 434 |
435 | 435 |
436 const char* PrettyPrinter::PrintProgram(FunctionLiteral* program) { | 436 const char* PrettyPrinter::PrintProgram(FunctionLiteral* program) { |
437 Init(); | 437 Init(); |
438 PrintStatements(program->body()); | 438 PrintStatements(program->body()); |
439 Print("\n"); | 439 Print("\n"); |
440 return output_; | 440 return output_; |
441 } | 441 } |
442 | 442 |
443 | 443 |
444 void PrettyPrinter::PrintOut(Node* node) { | 444 void PrettyPrinter::PrintOut(AstNode* node) { |
445 PrettyPrinter printer; | 445 PrettyPrinter printer; |
446 PrintF("%s", printer.Print(node)); | 446 PrintF("%s", printer.Print(node)); |
447 } | 447 } |
448 | 448 |
449 | 449 |
450 void PrettyPrinter::Init() { | 450 void PrettyPrinter::Init() { |
451 if (size_ == 0) { | 451 if (size_ == 0) { |
452 ASSERT(output_ == NULL); | 452 ASSERT(output_ == NULL); |
453 const int initial_size = 256; | 453 const int initial_size = 256; |
454 output_ = NewArray<char>(initial_size); | 454 output_ = NewArray<char>(initial_size); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 Print(" "); | 693 Print(" "); |
694 } | 694 } |
695 PrintLabels(labels); | 695 PrintLabels(labels); |
696 } else if (info != NULL) { | 696 } else if (info != NULL) { |
697 PrintIndented(info); | 697 PrintIndented(info); |
698 } | 698 } |
699 Print("\n"); | 699 Print("\n"); |
700 } | 700 } |
701 | 701 |
702 | 702 |
703 void AstPrinter::PrintIndentedVisit(const char* s, Node* node) { | 703 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { |
704 IndentedScope indent(s); | 704 IndentedScope indent(s); |
705 Visit(node); | 705 Visit(node); |
706 } | 706 } |
707 | 707 |
708 | 708 |
709 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { | 709 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { |
710 Init(); | 710 Init(); |
711 { IndentedScope indent("FUNC"); | 711 { IndentedScope indent("FUNC"); |
712 PrintLiteralIndented("NAME", program->name(), true); | 712 PrintLiteralIndented("NAME", program->name(), true); |
713 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true); | 713 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 | 1095 |
1096 void AstPrinter::VisitThisFunction(ThisFunction* node) { | 1096 void AstPrinter::VisitThisFunction(ThisFunction* node) { |
1097 IndentedScope indent("THIS-FUNCTION"); | 1097 IndentedScope indent("THIS-FUNCTION"); |
1098 } | 1098 } |
1099 | 1099 |
1100 | 1100 |
1101 | 1101 |
1102 #endif // DEBUG | 1102 #endif // DEBUG |
1103 | 1103 |
1104 } } // namespace v8::internal | 1104 } } // namespace v8::internal |
OLD | NEW |