| 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 <stdarg.h> | 5 #include <stdarg.h> |
| 6 | 6 |
| 7 #include "v8.h" | 7 #include "v8.h" |
| 8 | 8 |
| 9 #include "prettyprinter.h" | 9 #include "prettyprinter.h" |
| 10 #include "scopes.h" | 10 #include "scopes.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 Print(" : "); | 302 Print(" : "); |
| 303 Visit(node->else_expression()); | 303 Visit(node->else_expression()); |
| 304 } | 304 } |
| 305 | 305 |
| 306 | 306 |
| 307 void PrettyPrinter::VisitLiteral(Literal* node) { | 307 void PrettyPrinter::VisitLiteral(Literal* node) { |
| 308 PrintLiteral(node->value(), true); | 308 PrintLiteral(node->value(), true); |
| 309 } | 309 } |
| 310 | 310 |
| 311 | 311 |
| 312 void PrettyPrinter::VisitStringLiteral(StringLiteral* node) { |
| 313 VisitLiteral(node); |
| 314 } |
| 315 |
| 316 |
| 317 void PrettyPrinter::VisitNumberLiteral(NumberLiteral* node) { |
| 318 VisitLiteral(node); |
| 319 } |
| 320 |
| 321 |
| 312 void PrettyPrinter::VisitRegExpLiteral(RegExpLiteral* node) { | 322 void PrettyPrinter::VisitRegExpLiteral(RegExpLiteral* node) { |
| 313 Print(" RegExp("); | 323 Print(" RegExp("); |
| 314 PrintLiteral(node->pattern(), false); | 324 PrintLiteral(node->pattern(), false); |
| 315 Print(","); | 325 Print(","); |
| 316 PrintLiteral(node->flags(), false); | 326 PrintLiteral(node->flags(), false); |
| 317 Print(") "); | 327 Print(") "); |
| 318 } | 328 } |
| 319 | 329 |
| 320 | 330 |
| 321 void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) { | 331 void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 371 |
| 362 | 372 |
| 363 void PrettyPrinter::VisitThrow(Throw* node) { | 373 void PrettyPrinter::VisitThrow(Throw* node) { |
| 364 Print("throw "); | 374 Print("throw "); |
| 365 Visit(node->exception()); | 375 Visit(node->exception()); |
| 366 } | 376 } |
| 367 | 377 |
| 368 | 378 |
| 369 void PrettyPrinter::VisitProperty(Property* node) { | 379 void PrettyPrinter::VisitProperty(Property* node) { |
| 370 Expression* key = node->key(); | 380 Expression* key = node->key(); |
| 371 Literal* literal = key->AsLiteral(); | 381 StringLiteral* literal = key->AsStringLiteral(); |
| 372 if (literal != NULL && literal->value()->IsInternalizedString()) { | 382 if (literal != NULL) { |
| 373 Print("("); | 383 Print("("); |
| 374 Visit(node->obj()); | 384 Visit(node->obj()); |
| 375 Print(")."); | 385 Print(")."); |
| 376 PrintLiteral(literal->value(), false); | 386 PrintLiteral(literal->value(), false); |
| 377 } else { | 387 } else { |
| 378 Visit(node->obj()); | 388 Visit(node->obj()); |
| 379 Print("["); | 389 Print("["); |
| 380 Visit(key); | 390 Visit(key); |
| 381 Print("]"); | 391 Print("]"); |
| 382 } | 392 } |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 PrintIndentedVisit("ELSE", node->else_expression()); | 981 PrintIndentedVisit("ELSE", node->else_expression()); |
| 972 } | 982 } |
| 973 | 983 |
| 974 | 984 |
| 975 // TODO(svenpanne) Start with IndentedScope. | 985 // TODO(svenpanne) Start with IndentedScope. |
| 976 void AstPrinter::VisitLiteral(Literal* node) { | 986 void AstPrinter::VisitLiteral(Literal* node) { |
| 977 PrintLiteralIndented("LITERAL", node->value(), true); | 987 PrintLiteralIndented("LITERAL", node->value(), true); |
| 978 } | 988 } |
| 979 | 989 |
| 980 | 990 |
| 991 void AstPrinter::VisitStringLiteral(StringLiteral* node) { |
| 992 VisitLiteral(node); |
| 993 } |
| 994 |
| 995 |
| 996 void AstPrinter::VisitNumberLiteral(NumberLiteral* node) { |
| 997 VisitLiteral(node); |
| 998 } |
| 999 |
| 1000 |
| 981 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { | 1001 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { |
| 982 IndentedScope indent(this, "REGEXP LITERAL"); | 1002 IndentedScope indent(this, "REGEXP LITERAL"); |
| 983 PrintLiteralIndented("PATTERN", node->pattern(), false); | 1003 PrintLiteralIndented("PATTERN", node->pattern(), false); |
| 984 PrintLiteralIndented("FLAGS", node->flags(), false); | 1004 PrintLiteralIndented("FLAGS", node->flags(), false); |
| 985 } | 1005 } |
| 986 | 1006 |
| 987 | 1007 |
| 988 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { | 1008 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { |
| 989 IndentedScope indent(this, "OBJ LITERAL"); | 1009 IndentedScope indent(this, "OBJ LITERAL"); |
| 990 for (int i = 0; i < node->properties()->length(); i++) { | 1010 for (int i = 0; i < node->properties()->length(); i++) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 | 1089 |
| 1070 void AstPrinter::VisitThrow(Throw* node) { | 1090 void AstPrinter::VisitThrow(Throw* node) { |
| 1071 IndentedScope indent(this, "THROW"); | 1091 IndentedScope indent(this, "THROW"); |
| 1072 Visit(node->exception()); | 1092 Visit(node->exception()); |
| 1073 } | 1093 } |
| 1074 | 1094 |
| 1075 | 1095 |
| 1076 void AstPrinter::VisitProperty(Property* node) { | 1096 void AstPrinter::VisitProperty(Property* node) { |
| 1077 IndentedScope indent(this, "PROPERTY"); | 1097 IndentedScope indent(this, "PROPERTY"); |
| 1078 Visit(node->obj()); | 1098 Visit(node->obj()); |
| 1079 Literal* literal = node->key()->AsLiteral(); | 1099 StringLiteral* literal = node->key()->AsStringLiteral(); |
| 1080 if (literal != NULL && literal->value()->IsInternalizedString()) { | 1100 if (literal != NULL) { |
| 1081 PrintLiteralIndented("NAME", literal->value(), false); | 1101 PrintLiteralIndented("NAME", literal->value(), false); |
| 1082 } else { | 1102 } else { |
| 1083 PrintIndentedVisit("KEY", node->key()); | 1103 PrintIndentedVisit("KEY", node->key()); |
| 1084 } | 1104 } |
| 1085 } | 1105 } |
| 1086 | 1106 |
| 1087 | 1107 |
| 1088 void AstPrinter::VisitCall(Call* node) { | 1108 void AstPrinter::VisitCall(Call* node) { |
| 1089 IndentedScope indent(this, "CALL"); | 1109 IndentedScope indent(this, "CALL"); |
| 1090 Visit(node->expression()); | 1110 Visit(node->expression()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 } | 1155 } |
| 1136 | 1156 |
| 1137 | 1157 |
| 1138 void AstPrinter::VisitThisFunction(ThisFunction* node) { | 1158 void AstPrinter::VisitThisFunction(ThisFunction* node) { |
| 1139 IndentedScope indent(this, "THIS-FUNCTION"); | 1159 IndentedScope indent(this, "THIS-FUNCTION"); |
| 1140 } | 1160 } |
| 1141 | 1161 |
| 1142 #endif // DEBUG | 1162 #endif // DEBUG |
| 1143 | 1163 |
| 1144 } } // namespace v8::internal | 1164 } } // namespace v8::internal |
| OLD | NEW |