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" |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 | 971 |
972 // TODO(svenpanne) Start with IndentedScope. | 972 // TODO(svenpanne) Start with IndentedScope. |
973 void AstPrinter::VisitLiteral(Literal* node) { | 973 void AstPrinter::VisitLiteral(Literal* node) { |
974 PrintLiteralIndented("LITERAL", node->value(), true); | 974 PrintLiteralIndented("LITERAL", node->value(), true); |
975 } | 975 } |
976 | 976 |
977 | 977 |
978 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { | 978 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { |
979 IndentedScope indent(this, "REGEXP LITERAL", node->position()); | 979 IndentedScope indent(this, "REGEXP LITERAL", node->position()); |
980 EmbeddedVector<char, 128> buf; | 980 EmbeddedVector<char, 128> buf; |
981 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); | 981 SNPrintF(buf, "literal_slot = %d\n", node->literal_slot().ToInt()); |
982 PrintIndented(buf.start()); | 982 PrintIndented(buf.start()); |
983 PrintLiteralIndented("PATTERN", node->pattern(), false); | 983 PrintLiteralIndented("PATTERN", node->pattern(), false); |
984 int i = 0; | 984 int i = 0; |
985 if (node->flags() & RegExp::kGlobal) buf[i++] = 'g'; | 985 if (node->flags() & RegExp::kGlobal) buf[i++] = 'g'; |
986 if (node->flags() & RegExp::kIgnoreCase) buf[i++] = 'i'; | 986 if (node->flags() & RegExp::kIgnoreCase) buf[i++] = 'i'; |
987 if (node->flags() & RegExp::kMultiline) buf[i++] = 'm'; | 987 if (node->flags() & RegExp::kMultiline) buf[i++] = 'm'; |
988 if (node->flags() & RegExp::kUnicode) buf[i++] = 'u'; | 988 if (node->flags() & RegExp::kUnicode) buf[i++] = 'u'; |
989 if (node->flags() & RegExp::kSticky) buf[i++] = 'y'; | 989 if (node->flags() & RegExp::kSticky) buf[i++] = 'y'; |
990 buf[i] = '\0'; | 990 buf[i] = '\0'; |
991 PrintIndented("FLAGS "); | 991 PrintIndented("FLAGS "); |
992 Print("%s", buf.start()); | 992 Print("%s", buf.start()); |
993 Print("\n"); | 993 Print("\n"); |
994 } | 994 } |
995 | 995 |
996 | 996 |
997 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { | 997 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { |
998 IndentedScope indent(this, "OBJ LITERAL", node->position()); | 998 IndentedScope indent(this, "OBJ LITERAL", node->position()); |
999 EmbeddedVector<char, 128> buf; | 999 EmbeddedVector<char, 128> buf; |
1000 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); | 1000 SNPrintF(buf, "literal_slot = %d\n", node->literal_slot().ToInt()); |
1001 PrintIndented(buf.start()); | 1001 PrintIndented(buf.start()); |
1002 PrintObjectProperties(node->properties()); | 1002 PrintObjectProperties(node->properties()); |
1003 } | 1003 } |
1004 | 1004 |
1005 void AstPrinter::PrintObjectProperties( | 1005 void AstPrinter::PrintObjectProperties( |
1006 ZoneList<ObjectLiteral::Property*>* properties) { | 1006 ZoneList<ObjectLiteral::Property*>* properties) { |
1007 for (int i = 0; i < properties->length(); i++) { | 1007 for (int i = 0; i < properties->length(); i++) { |
1008 ObjectLiteral::Property* property = properties->at(i); | 1008 ObjectLiteral::Property* property = properties->at(i); |
1009 const char* prop_kind = nullptr; | 1009 const char* prop_kind = nullptr; |
1010 switch (property->kind()) { | 1010 switch (property->kind()) { |
(...skipping 25 matching lines...) Expand all Loading... |
1036 PrintIndentedVisit("KEY", properties->at(i)->key()); | 1036 PrintIndentedVisit("KEY", properties->at(i)->key()); |
1037 PrintIndentedVisit("VALUE", properties->at(i)->value()); | 1037 PrintIndentedVisit("VALUE", properties->at(i)->value()); |
1038 } | 1038 } |
1039 } | 1039 } |
1040 | 1040 |
1041 | 1041 |
1042 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) { | 1042 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) { |
1043 IndentedScope indent(this, "ARRAY LITERAL", node->position()); | 1043 IndentedScope indent(this, "ARRAY LITERAL", node->position()); |
1044 | 1044 |
1045 EmbeddedVector<char, 128> buf; | 1045 EmbeddedVector<char, 128> buf; |
1046 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); | 1046 SNPrintF(buf, "literal_slot = %d\n", node->literal_slot().ToInt()); |
1047 PrintIndented(buf.start()); | 1047 PrintIndented(buf.start()); |
1048 if (node->values()->length() > 0) { | 1048 if (node->values()->length() > 0) { |
1049 IndentedScope indent(this, "VALUES", node->position()); | 1049 IndentedScope indent(this, "VALUES", node->position()); |
1050 for (int i = 0; i < node->values()->length(); i++) { | 1050 for (int i = 0; i < node->values()->length(); i++) { |
1051 Visit(node->values()->at(i)); | 1051 Visit(node->values()->at(i)); |
1052 } | 1052 } |
1053 } | 1053 } |
1054 } | 1054 } |
1055 | 1055 |
1056 | 1056 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 | 1220 |
1221 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { | 1221 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { |
1222 Visit(node->expression()); | 1222 Visit(node->expression()); |
1223 } | 1223 } |
1224 | 1224 |
1225 | 1225 |
1226 #endif // DEBUG | 1226 #endif // DEBUG |
1227 | 1227 |
1228 } // namespace internal | 1228 } // namespace internal |
1229 } // namespace v8 | 1229 } // namespace v8 |
OLD | NEW |