| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 int pos = OS::SNPrintF(buf, "%s (mode = %s", info, | 626 int pos = OS::SNPrintF(buf, "%s (mode = %s", info, |
| 627 Variable::Mode2String(var->mode())); | 627 Variable::Mode2String(var->mode())); |
| 628 OS::SNPrintF(buf + pos, ")"); | 628 OS::SNPrintF(buf + pos, ")"); |
| 629 PrintLiteralIndented(buf.start(), value, true); | 629 PrintLiteralIndented(buf.start(), value, true); |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 | 632 |
| 633 | 633 |
| 634 void AstPrinter::PrintLabelsIndented(const char* info, ZoneStringList* labels) { | 634 void AstPrinter::PrintLabelsIndented(const char* info, ZoneStringList* labels) { |
| 635 if (labels != NULL && labels->length() > 0) { | 635 if (labels != NULL && labels->length() > 0) { |
| 636 if (info == NULL) { | 636 PrintIndented(info == NULL ? "LABELS" : info); |
| 637 PrintIndented("LABELS "); | 637 Print(" "); |
| 638 } else { | |
| 639 PrintIndented(info); | |
| 640 Print(" "); | |
| 641 } | |
| 642 PrintLabels(labels); | 638 PrintLabels(labels); |
| 639 Print("\n"); |
| 643 } else if (info != NULL) { | 640 } else if (info != NULL) { |
| 644 PrintIndented(info); | 641 PrintIndented(info); |
| 642 Print("\n"); |
| 645 } | 643 } |
| 646 Print("\n"); | |
| 647 } | 644 } |
| 648 | 645 |
| 649 | 646 |
| 650 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { | 647 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { |
| 651 IndentedScope indent(this, s, node); | 648 IndentedScope indent(this, s, node); |
| 652 Visit(node); | 649 Visit(node); |
| 653 } | 650 } |
| 654 | 651 |
| 655 | 652 |
| 656 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { | 653 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 IndentedScope indent(this, "VALUES"); | 919 IndentedScope indent(this, "VALUES"); |
| 923 for (int i = 0; i < node->values()->length(); i++) { | 920 for (int i = 0; i < node->values()->length(); i++) { |
| 924 Visit(node->values()->at(i)); | 921 Visit(node->values()->at(i)); |
| 925 } | 922 } |
| 926 } | 923 } |
| 927 } | 924 } |
| 928 | 925 |
| 929 | 926 |
| 930 void AstPrinter::VisitVariableProxy(VariableProxy* node) { | 927 void AstPrinter::VisitVariableProxy(VariableProxy* node) { |
| 931 Variable* var = node->var(); | 928 Variable* var = node->var(); |
| 932 PrintLiteralWithModeIndented("VAR PROXY", var, node->name()); | 929 EmbeddedVector<char, 128> buf; |
| 933 { IndentedScope indent(this); | 930 int pos = OS::SNPrintF(buf, "VAR PROXY"); |
| 934 switch (var->location()) { | 931 switch (var->location()) { |
| 935 case Variable::UNALLOCATED: | 932 case Variable::UNALLOCATED: |
| 936 break; | 933 break; |
| 937 case Variable::PARAMETER: | 934 case Variable::PARAMETER: |
| 938 Print("parameter[%d]", var->index()); | 935 OS::SNPrintF(buf + pos, " parameter[%d]", var->index()); |
| 939 break; | 936 break; |
| 940 case Variable::LOCAL: | 937 case Variable::LOCAL: |
| 941 Print("local[%d]", var->index()); | 938 OS::SNPrintF(buf + pos, " local[%d]", var->index()); |
| 942 break; | 939 break; |
| 943 case Variable::CONTEXT: | 940 case Variable::CONTEXT: |
| 944 Print("context[%d]", var->index()); | 941 OS::SNPrintF(buf + pos, " context[%d]", var->index()); |
| 945 break; | 942 break; |
| 946 case Variable::LOOKUP: | 943 case Variable::LOOKUP: |
| 947 Print("lookup"); | 944 OS::SNPrintF(buf + pos, " lookup"); |
| 948 break; | 945 break; |
| 949 } | |
| 950 } | 946 } |
| 947 PrintLiteralWithModeIndented(buf.start(), var, node->name()); |
| 951 } | 948 } |
| 952 | 949 |
| 953 | 950 |
| 954 void AstPrinter::VisitAssignment(Assignment* node) { | 951 void AstPrinter::VisitAssignment(Assignment* node) { |
| 955 IndentedScope indent(this, Token::Name(node->op()), node); | 952 IndentedScope indent(this, Token::Name(node->op()), node); |
| 956 Visit(node->target()); | 953 Visit(node->target()); |
| 957 Visit(node->value()); | 954 Visit(node->value()); |
| 958 } | 955 } |
| 959 | 956 |
| 960 | 957 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 AddAttribute("mode", Variable::Mode2String(decl->mode())); | 1426 AddAttribute("mode", Variable::Mode2String(decl->mode())); |
| 1430 } | 1427 } |
| 1431 Visit(decl->proxy()); | 1428 Visit(decl->proxy()); |
| 1432 if (decl->fun() != NULL) Visit(decl->fun()); | 1429 if (decl->fun() != NULL) Visit(decl->fun()); |
| 1433 } | 1430 } |
| 1434 | 1431 |
| 1435 | 1432 |
| 1436 #endif // DEBUG | 1433 #endif // DEBUG |
| 1437 | 1434 |
| 1438 } } // namespace v8::internal | 1435 } } // namespace v8::internal |
| OLD | NEW |