| 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 "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 282 } |
| 283 | 283 |
| 284 | 284 |
| 285 void PrettyPrinter::VisitFunctionLiteral(FunctionLiteral* node) { | 285 void PrettyPrinter::VisitFunctionLiteral(FunctionLiteral* node) { |
| 286 Print("("); | 286 Print("("); |
| 287 PrintFunctionLiteral(node); | 287 PrintFunctionLiteral(node); |
| 288 Print(")"); | 288 Print(")"); |
| 289 } | 289 } |
| 290 | 290 |
| 291 | 291 |
| 292 void PrettyPrinter::VisitClassLiteral(ClassLiteral* node) { |
| 293 Print("(class "); |
| 294 PrintLiteral(node->name(), false); |
| 295 if (node->extends()) { |
| 296 Print(" extends "); |
| 297 Visit(node->extends()); |
| 298 } |
| 299 Print(" { "); |
| 300 for (int i = 0; i < node->properties()->length(); i++) { |
| 301 PrintObjectLiteralProperty(node->properties()->at(i)); |
| 302 } |
| 303 Print(" })"); |
| 304 } |
| 305 |
| 306 |
| 292 void PrettyPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) { | 307 void PrettyPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) { |
| 293 Print("("); | 308 Print("("); |
| 294 PrintLiteral(node->name(), false); | 309 PrintLiteral(node->name(), false); |
| 295 Print(")"); | 310 Print(")"); |
| 296 } | 311 } |
| 297 | 312 |
| 298 | 313 |
| 299 void PrettyPrinter::VisitConditional(Conditional* node) { | 314 void PrettyPrinter::VisitConditional(Conditional* node) { |
| 300 Visit(node->condition()); | 315 Visit(node->condition()); |
| 301 Print(" ? "); | 316 Print(" ? "); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 316 Print(","); | 331 Print(","); |
| 317 PrintLiteral(node->flags(), false); | 332 PrintLiteral(node->flags(), false); |
| 318 Print(") "); | 333 Print(") "); |
| 319 } | 334 } |
| 320 | 335 |
| 321 | 336 |
| 322 void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) { | 337 void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) { |
| 323 Print("{ "); | 338 Print("{ "); |
| 324 for (int i = 0; i < node->properties()->length(); i++) { | 339 for (int i = 0; i < node->properties()->length(); i++) { |
| 325 if (i != 0) Print(","); | 340 if (i != 0) Print(","); |
| 326 ObjectLiteral::Property* property = node->properties()->at(i); | 341 PrintObjectLiteralProperty(node->properties()->at(i)); |
| 327 Print(" "); | |
| 328 Visit(property->key()); | |
| 329 Print(": "); | |
| 330 Visit(property->value()); | |
| 331 } | 342 } |
| 332 Print(" }"); | 343 Print(" }"); |
| 333 } | 344 } |
| 334 | 345 |
| 335 | 346 |
| 347 void PrettyPrinter::PrintObjectLiteralProperty( |
| 348 ObjectLiteralProperty* property) { |
| 349 // TODO(arv): Better printing of methods etc. |
| 350 Print(" "); |
| 351 Visit(property->key()); |
| 352 Print(": "); |
| 353 Visit(property->value()); |
| 354 } |
| 355 |
| 356 |
| 336 void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) { | 357 void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) { |
| 337 Print("[ "); | 358 Print("[ "); |
| 338 for (int i = 0; i < node->values()->length(); i++) { | 359 for (int i = 0; i < node->values()->length(); i++) { |
| 339 if (i != 0) Print(","); | 360 if (i != 0) Print(","); |
| 340 Visit(node->values()->at(i)); | 361 Visit(node->values()->at(i)); |
| 341 } | 362 } |
| 342 Print(" ]"); | 363 Print(" ]"); |
| 343 } | 364 } |
| 344 | 365 |
| 345 | 366 |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 PrintLiteralIndented("NAME", node->name(), false); | 983 PrintLiteralIndented("NAME", node->name(), false); |
| 963 PrintLiteralIndented("INFERRED NAME", node->inferred_name(), false); | 984 PrintLiteralIndented("INFERRED NAME", node->inferred_name(), false); |
| 964 PrintParameters(node->scope()); | 985 PrintParameters(node->scope()); |
| 965 // We don't want to see the function literal in this case: it | 986 // We don't want to see the function literal in this case: it |
| 966 // will be printed via PrintProgram when the code for it is | 987 // will be printed via PrintProgram when the code for it is |
| 967 // generated. | 988 // generated. |
| 968 // PrintStatements(node->body()); | 989 // PrintStatements(node->body()); |
| 969 } | 990 } |
| 970 | 991 |
| 971 | 992 |
| 993 void AstPrinter::VisitClassLiteral(ClassLiteral* node) { |
| 994 IndentedScope indent(this, "CLASS LITERAL"); |
| 995 PrintLiteralIndented("NAME", node->name(), false); |
| 996 } |
| 997 |
| 998 |
| 972 void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) { | 999 void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) { |
| 973 IndentedScope indent(this, "NATIVE FUNC LITERAL"); | 1000 IndentedScope indent(this, "NATIVE FUNC LITERAL"); |
| 974 PrintLiteralIndented("NAME", node->name(), false); | 1001 PrintLiteralIndented("NAME", node->name(), false); |
| 975 } | 1002 } |
| 976 | 1003 |
| 977 | 1004 |
| 978 void AstPrinter::VisitConditional(Conditional* node) { | 1005 void AstPrinter::VisitConditional(Conditional* node) { |
| 979 IndentedScope indent(this, "CONDITIONAL"); | 1006 IndentedScope indent(this, "CONDITIONAL"); |
| 980 PrintIndentedVisit("CONDITION", node->condition()); | 1007 PrintIndentedVisit("CONDITION", node->condition()); |
| 981 PrintIndentedVisit("THEN", node->then_expression()); | 1008 PrintIndentedVisit("THEN", node->then_expression()); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 } | 1178 } |
| 1152 | 1179 |
| 1153 | 1180 |
| 1154 void AstPrinter::VisitSuperReference(SuperReference* node) { | 1181 void AstPrinter::VisitSuperReference(SuperReference* node) { |
| 1155 IndentedScope indent(this, "SUPER-REFERENCE"); | 1182 IndentedScope indent(this, "SUPER-REFERENCE"); |
| 1156 } | 1183 } |
| 1157 | 1184 |
| 1158 #endif // DEBUG | 1185 #endif // DEBUG |
| 1159 | 1186 |
| 1160 } } // namespace v8::internal | 1187 } } // namespace v8::internal |
| OLD | NEW |