| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } else if (object->IsJSArray()) { | 522 } else if (object->IsJSArray()) { |
| 523 Print("JS-array[%u]", | 523 Print("JS-array[%u]", |
| 524 Smi::cast(JSArray::cast(object)->length())->value()); | 524 Smi::cast(JSArray::cast(object)->length())->value()); |
| 525 } else if (object->IsJSObject()) { | 525 } else if (object->IsJSObject()) { |
| 526 Print("JS-Object"); | 526 Print("JS-Object"); |
| 527 } else { | 527 } else { |
| 528 Print("?UNKNOWN?"); | 528 Print("?UNKNOWN?"); |
| 529 } | 529 } |
| 530 } else if (object->IsFixedArray()) { | 530 } else if (object->IsFixedArray()) { |
| 531 Print("FixedArray"); | 531 Print("FixedArray"); |
| 532 } else if (object->IsSymbol()) { |
| 533 // Symbols can only occur as literals if they were inserted by the parser. |
| 534 Symbol* symbol = Symbol::cast(object); |
| 535 if (symbol->name()->IsString()) { |
| 536 int length = 0; |
| 537 String* string = String::cast(symbol->name()); |
| 538 std::unique_ptr<char[]> desc = string->ToCString( |
| 539 ALLOW_NULLS, FAST_STRING_TRAVERSAL, 0, string->length(), &length); |
| 540 Print("Symbol(%*s)", length, desc.get()); |
| 541 } else { |
| 542 Print("Symbol()"); |
| 543 } |
| 532 } else { | 544 } else { |
| 533 Print("<unknown literal %p>", static_cast<void*>(object)); | 545 Print("<unknown literal %p>", static_cast<void*>(object)); |
| 534 } | 546 } |
| 535 } | 547 } |
| 536 | 548 |
| 537 void AstPrinter::PrintLiteral(const AstRawString* value, bool quote) { | 549 void AstPrinter::PrintLiteral(const AstRawString* value, bool quote) { |
| 538 PrintLiteral(value->string(), quote); | 550 PrintLiteral(value->string(), quote); |
| 539 } | 551 } |
| 540 | 552 |
| 541 | 553 |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 | 1202 |
| 1191 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { | 1203 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { |
| 1192 Visit(node->expression()); | 1204 Visit(node->expression()); |
| 1193 } | 1205 } |
| 1194 | 1206 |
| 1195 | 1207 |
| 1196 #endif // DEBUG | 1208 #endif // DEBUG |
| 1197 | 1209 |
| 1198 } // namespace internal | 1210 } // namespace internal |
| 1199 } // namespace v8 | 1211 } // namespace v8 |
| OLD | NEW |