Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/ast/prettyprinter.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast/prettyprinter.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "src/base/platform/platform.h" 11 #include "src/base/platform/platform.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 CallPrinter::CallPrinter(Isolate* isolate, bool is_builtin) { 16 CallPrinter::CallPrinter(Isolate* isolate, bool is_builtin) {
17 isolate_ = isolate;
17 output_ = NULL; 18 output_ = NULL;
18 size_ = 0; 19 size_ = 0;
19 pos_ = 0; 20 pos_ = 0;
20 position_ = 0; 21 position_ = 0;
21 found_ = false; 22 found_ = false;
22 done_ = false; 23 done_ = false;
23 is_builtin_ = is_builtin; 24 is_builtin_ = is_builtin;
24 InitializeAstVisitor(isolate); 25 InitializeAstVisitor(isolate);
25 } 26 }
26 27
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (object->IsString()) { 440 if (object->IsString()) {
440 if (quote) Print("\""); 441 if (quote) Print("\"");
441 Print("%s", String::cast(object)->ToCString().get()); 442 Print("%s", String::cast(object)->ToCString().get());
442 if (quote) Print("\""); 443 if (quote) Print("\"");
443 } else if (object->IsNull()) { 444 } else if (object->IsNull()) {
444 Print("null"); 445 Print("null");
445 } else if (object->IsTrue()) { 446 } else if (object->IsTrue()) {
446 Print("true"); 447 Print("true");
447 } else if (object->IsFalse()) { 448 } else if (object->IsFalse()) {
448 Print("false"); 449 Print("false");
449 } else if (object->IsUndefined()) { 450 } else if (object->IsUndefined(isolate_)) {
450 Print("undefined"); 451 Print("undefined");
451 } else if (object->IsNumber()) { 452 } else if (object->IsNumber()) {
452 Print("%g", object->Number()); 453 Print("%g", object->Number());
453 } else if (object->IsSymbol()) { 454 } else if (object->IsSymbol()) {
454 // Symbols can only occur as literals if they were inserted by the parser. 455 // Symbols can only occur as literals if they were inserted by the parser.
455 PrintLiteral(Symbol::cast(object)->name(), false); 456 PrintLiteral(Symbol::cast(object)->name(), false);
456 } 457 }
457 } 458 }
458 459
459 460
(...skipping 12 matching lines...) Expand all
472 const char* node_name, FeedbackVectorSlot slot) { 473 const char* node_name, FeedbackVectorSlot slot) {
473 int pos = SNPrintF(*buf, "%s", node_name); 474 int pos = SNPrintF(*buf, "%s", node_name);
474 if (!slot.IsInvalid()) { 475 if (!slot.IsInvalid()) {
475 pos += SNPrintF(*buf + pos, " Slot(%d)", slot.ToInt()); 476 pos += SNPrintF(*buf + pos, " Slot(%d)", slot.ToInt());
476 } 477 }
477 return pos; 478 return pos;
478 } 479 }
479 480
480 481
481 PrettyPrinter::PrettyPrinter(Isolate* isolate) { 482 PrettyPrinter::PrettyPrinter(Isolate* isolate) {
483 isolate_ = isolate;
482 output_ = NULL; 484 output_ = NULL;
483 size_ = 0; 485 size_ = 0;
484 pos_ = 0; 486 pos_ = 0;
485 InitializeAstVisitor(isolate); 487 InitializeAstVisitor(isolate);
486 } 488 }
487 489
488 490
489 PrettyPrinter::~PrettyPrinter() { 491 PrettyPrinter::~PrettyPrinter() {
490 DeleteArray(output_); 492 DeleteArray(output_);
491 } 493 }
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 for (int i = 0; i < string->length(); i++) { 1068 for (int i = 0; i < string->length(); i++) {
1067 Print("%c", string->Get(i)); 1069 Print("%c", string->Get(i));
1068 } 1070 }
1069 if (quote) Print("\""); 1071 if (quote) Print("\"");
1070 } else if (object->IsNull()) { 1072 } else if (object->IsNull()) {
1071 Print("null"); 1073 Print("null");
1072 } else if (object->IsTrue()) { 1074 } else if (object->IsTrue()) {
1073 Print("true"); 1075 Print("true");
1074 } else if (object->IsFalse()) { 1076 } else if (object->IsFalse()) {
1075 Print("false"); 1077 Print("false");
1076 } else if (object->IsUndefined()) { 1078 } else if (object->IsUndefined(isolate_)) {
1077 Print("undefined"); 1079 Print("undefined");
1078 } else if (object->IsNumber()) { 1080 } else if (object->IsNumber()) {
1079 Print("%g", object->Number()); 1081 Print("%g", object->Number());
1080 } else if (object->IsJSObject()) { 1082 } else if (object->IsJSObject()) {
1081 // regular expression 1083 // regular expression
1082 if (object->IsJSFunction()) { 1084 if (object->IsJSFunction()) {
1083 Print("JS-Function"); 1085 Print("JS-Function");
1084 } else if (object->IsJSArray()) { 1086 } else if (object->IsJSArray()) {
1085 Print("JS-array[%u]", 1087 Print("JS-array[%u]",
1086 Smi::cast(JSArray::cast(object)->length())->value()); 1088 Smi::cast(JSArray::cast(object)->length())->value());
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 1748
1747 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { 1749 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) {
1748 Visit(node->expression()); 1750 Visit(node->expression());
1749 } 1751 }
1750 1752
1751 1753
1752 #endif // DEBUG 1754 #endif // DEBUG
1753 1755
1754 } // namespace internal 1756 } // namespace internal
1755 } // namespace v8 1757 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/prettyprinter.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698