19 PrettyPrinter::PrettyPrinter(Zone* zone) {
23 InitializeAstVisitor(zone);
27 PrettyPrinter::~PrettyPrinter() {
32 void PrettyPrinter::VisitBlock(Block* node) {
33 if (!node->is_initializer_block()) Print(
"{ ");
34 PrintStatements(node->statements());
35 if (node->statements()->length() > 0) Print(
" ");
36 if (!node->is_initializer_block()) Print(
"}");
40 void PrettyPrinter::VisitVariableDeclaration(VariableDeclaration* node) {
42 PrintLiteral(node->proxy()->name(),
false);
47 void PrettyPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
49 PrintLiteral(node->proxy()->name(),
false);
51 PrintFunctionLiteral(node->fun());
56 void PrettyPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
58 PrintLiteral(node->proxy()->name(),
false);
60 Visit(node->module());
65 void PrettyPrinter::VisitImportDeclaration(ImportDeclaration* node) {
67 PrintLiteral(node->proxy()->name(),
false);
69 Visit(node->module());
74 void PrettyPrinter::VisitExportDeclaration(ExportDeclaration* node) {
76 PrintLiteral(node->proxy()->name(),
false);
81 void PrettyPrinter::VisitModuleLiteral(ModuleLiteral* node) {
82 VisitBlock(node->body());
86 void PrettyPrinter::VisitModuleVariable(ModuleVariable* node) {
91 void PrettyPrinter::VisitModulePath(ModulePath* node) {
92 Visit(node->module());
94 PrintLiteral(node->name(),
false);
98 void PrettyPrinter::VisitModuleUrl(ModuleUrl* node) {
100 PrintLiteral(node->url(),
true);
104 void PrettyPrinter::VisitModuleStatement(ModuleStatement* node) {
106 PrintLiteral(node->proxy()->name(),
false);
112 void PrettyPrinter::VisitExpressionStatement(ExpressionStatement* node) {
113 Visit(node->expression());
118 void PrettyPrinter::VisitEmptyStatement(EmptyStatement* node) {
123 void PrettyPrinter::VisitIfStatement(IfStatement* node) {
125 Visit(node->condition());
127 Visit(node->then_statement());
128 if (node->HasElseStatement()) {
130 Visit(node->else_statement());
135 void PrettyPrinter::VisitContinueStatement(ContinueStatement* node) {
137 ZoneList<const AstRawString*>* labels = node->target()->labels();
138 if (labels !=
NULL) {
140 DCHECK(labels->length() > 0);
141 PrintLiteral(labels->at(0),
false);
147 void PrettyPrinter::VisitBreakStatement(BreakStatement* node) {
149 ZoneList<const AstRawString*>* labels = node->target()->labels();
150 if (labels !=
NULL) {
152 DCHECK(labels->length() > 0);
153 PrintLiteral(labels->at(0),
false);
159 void PrettyPrinter::VisitReturnStatement(ReturnStatement* node) {
161 Visit(node->expression());
166 void PrettyPrinter::VisitWithStatement(WithStatement* node) {
168 Visit(node->expression());
170 Visit(node->statement());
174 void PrettyPrinter::VisitSwitchStatement(SwitchStatement* node) {
175 PrintLabels(node->labels());
179 ZoneList<CaseClause*>* cases = node->cases();
180 for (
int i = 0;
i < cases->length();
i++)
186 void PrettyPrinter::VisitCaseClause(CaseClause* clause) {
187 if (clause->is_default()) {
191 Visit(clause->label());
194 PrintStatements(clause->statements());
195 if (clause->statements()->length() > 0)
200 void PrettyPrinter::VisitDoWhileStatement(DoWhileStatement* node) {
201 PrintLabels(node->labels());
210 void PrettyPrinter::VisitWhileStatement(WhileStatement* node) {
211 PrintLabels(node->labels());
219 void PrettyPrinter::VisitForStatement(ForStatement* node) {
220 PrintLabels(node->labels());
222 if (node->init() !=
NULL) {
228 if (node->cond() !=
NULL) Visit(node->cond());
230 if (node->next() !=
NULL) {
239 void PrettyPrinter::VisitForInStatement(ForInStatement* node) {
240 PrintLabels(node->labels());
244 Visit(node->enumerable());
250 void PrettyPrinter::VisitForOfStatement(ForOfStatement* node) {
251 PrintLabels(node->labels());
255 Visit(node->iterable());
261 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
263 Visit(node->try_block());
265 const bool quote =
false;
266 PrintLiteral(node->variable()->name(), quote);
268 Visit(node->catch_block());
272 void PrettyPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
274 Visit(node->try_block());
276 Visit(node->finally_block());
280 void PrettyPrinter::VisitDebuggerStatement(DebuggerStatement* node) {
285 void PrettyPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
287 PrintFunctionLiteral(node);
292 void PrettyPrinter::VisitClassLiteral(ClassLiteral* node) {
294 PrintLiteral(node->name(),
false);
295 if (node->extends()) {
297 Visit(node->extends());
300 for (
int i = 0;
i < node->properties()->length();
i++) {
301 PrintObjectLiteralProperty(node->properties()->at(
i));
307 void PrettyPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
309 PrintLiteral(node->name(),
false);
314 void PrettyPrinter::VisitConditional(Conditional* node) {
315 Visit(node->condition());
317 Visit(node->then_expression());
319 Visit(node->else_expression());
323 void PrettyPrinter::VisitLiteral(Literal* node) {
324 PrintLiteral(node->value(),
true);
328 void PrettyPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
330 PrintLiteral(node->pattern(),
false);
332 PrintLiteral(node->flags(),
false);
337 void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) {
339 for (
int i = 0;
i < node->properties()->length();
i++) {
340 if (
i != 0) Print(
",");
341 PrintObjectLiteralProperty(node->properties()->at(
i));
347 void PrettyPrinter::PrintObjectLiteralProperty(
348 ObjectLiteralProperty* property) {
351 Visit(property->key());
353 Visit(property->value());
357 void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) {
359 for (
int i = 0;
i < node->values()->length();
i++) {
360 if (
i != 0) Print(
",");
361 Visit(node->values()->at(
i));
367 void PrettyPrinter::VisitVariableProxy(VariableProxy* node) {
368 PrintLiteral(node->name(),
false);
372 void PrettyPrinter::VisitAssignment(Assignment* node) {
373 Visit(node->target());
375 Visit(node->value());
379 void PrettyPrinter::VisitYield(Yield* node) {
381 Visit(node->expression());
385 void PrettyPrinter::VisitThrow(
Throw* node) {
387 Visit(node->exception());
391 void PrettyPrinter::VisitProperty(Property* node) {
392 Expression* key = node->key();
393 Literal* literal = key->AsLiteral();
394 if (literal !=
NULL && literal->value()->IsInternalizedString()) {
398 PrintLiteral(literal->value(),
false);
408 void PrettyPrinter::VisitCall(Call* node) {
409 Visit(node->expression());
410 PrintArguments(node->arguments());
414 void PrettyPrinter::VisitCallNew(CallNew* node) {
416 Visit(node->expression());
418 PrintArguments(node->arguments());
422 void PrettyPrinter::VisitCallRuntime(CallRuntime* node) {
424 PrintLiteral(node->name(),
false);
425 PrintArguments(node->arguments());
429 void PrettyPrinter::VisitUnaryOperation(UnaryOperation* node) {
432 op == Token::DELETE || op == Token::TYPEOF || op ==
Token::VOID;
434 Visit(node->expression());
439 void PrettyPrinter::VisitCountOperation(CountOperation* node) {
441 if (node->is_prefix()) Print(
"%s",
Token::String(node->op()));
442 Visit(node->expression());
443 if (node->is_postfix()) Print(
"%s",
Token::String(node->op()));
448 void PrettyPrinter::VisitBinaryOperation(BinaryOperation* node) {
452 Visit(node->right());
457 void PrettyPrinter::VisitCompareOperation(CompareOperation* node) {
461 Visit(node->right());
466 void PrettyPrinter::VisitThisFunction(ThisFunction* node) {
467 Print(
"<this-function>");
471 void PrettyPrinter::VisitSuperReference(SuperReference* node) {
472 Print(
"<super-reference>");
476 const char* PrettyPrinter::Print(AstNode* node) {
483 const char* PrettyPrinter::PrintExpression(FunctionLiteral*
program) {
485 ExpressionStatement* statement =
486 program->body()->at(0)->AsExpressionStatement();
487 Visit(statement->expression());
492 const char* PrettyPrinter::PrintProgram(FunctionLiteral*
program) {
494 PrintStatements(
program->body());
500 void PrettyPrinter::PrintOut(Zone* zone, AstNode* node) {
501 PrettyPrinter printer(zone);
502 PrintF(
"%s", printer.Print(node));
506 void PrettyPrinter::Init() {
509 const int initial_size = 256;
510 output_ = NewArray<char>(initial_size);
511 size_ = initial_size;
518 void PrettyPrinter::Print(
const char* format, ...) {
521 va_start(arguments, format);
522 int n =
VSNPrintF(Vector<char>(output_, size_) + pos_,
533 const int slack = 32;
534 int new_size = size_ + (size_ >> 1) + slack;
535 char* new_output = NewArray<char>(new_size);
536 MemCopy(new_output, output_, pos_);
538 output_ = new_output;
545 void PrettyPrinter::PrintStatements(ZoneList<Statement*>* statements) {
546 if (statements ==
NULL)
return;
547 for (
int i = 0;
i < statements->length();
i++) {
548 if (
i != 0) Print(
" ");
549 Visit(statements->at(
i));
554 void PrettyPrinter::PrintLabels(ZoneList<const AstRawString*>* labels) {
555 if (labels !=
NULL) {
556 for (
int i = 0;
i < labels->length();
i++) {
557 PrintLiteral(labels->at(
i),
false);
564 void PrettyPrinter::PrintArguments(ZoneList<Expression*>* arguments) {
566 for (
int i = 0;
i < arguments->length();
i++) {
567 if (
i != 0) Print(
", ");
568 Visit(arguments->at(
i));
574 void PrettyPrinter::PrintLiteral(Handle<Object> value,
bool quote) {
576 if (object->IsString()) {
577 String*
string = String::cast(
object);
578 if (quote) Print(
"\"");
579 for (
int i = 0;
i <
string->length();
i++) {
580 Print(
"%c", string->Get(
i));
582 if (quote) Print(
"\"");
583 }
else if (object->IsNull()) {
585 }
else if (object->IsTrue()) {
587 }
else if (object->IsFalse()) {
589 }
else if (object->IsUndefined()) {
591 }
else if (object->IsNumber()) {
592 Print(
"%g", object->Number());
593 }
else if (object->IsJSObject()) {
595 if (object->IsJSFunction()) {
596 Print(
"JS-Function");
597 }
else if (object->IsJSArray()) {
598 Print(
"JS-array[%u]", JSArray::cast(
object)->length());
599 }
else if (object->IsJSObject()) {
604 }
else if (object->IsFixedArray()) {
607 Print(
"<unknown literal %p>",
object);
612 void PrettyPrinter::PrintLiteral(
const AstRawString* value,
bool quote) {
613 PrintLiteral(value->string(), quote);
617 void PrettyPrinter::PrintParameters(Scope* scope) {
619 for (
int i = 0;
i < scope->num_parameters();
i++) {
620 if (
i > 0) Print(
", ");
621 PrintLiteral(scope->parameter(
i)->name(),
false);
627 void PrettyPrinter::PrintDeclarations(ZoneList<Declaration*>* declarations) {
628 for (
int i = 0;
i < declarations->length();
i++) {
629 if (
i > 0) Print(
" ");
630 Visit(declarations->at(
i));
635 void PrettyPrinter::PrintFunctionLiteral(FunctionLiteral*
function) {
637 PrintLiteral(function->name(),
false);
638 PrintParameters(function->scope());
640 PrintDeclarations(function->scope()->declarations());
641 PrintStatements(function->body());
650 IndentedScope(AstPrinter* printer,
const char* txt)
651 : ast_printer_(printer) {
652 ast_printer_->PrintIndented(txt);
653 ast_printer_->Print(
"\n");
654 ast_printer_->inc_indent();
657 virtual ~IndentedScope() {
658 ast_printer_->dec_indent();
662 AstPrinter* ast_printer_;
669 AstPrinter::AstPrinter(Zone* zone) : PrettyPrinter(zone), indent_(0) {
673 AstPrinter::~AstPrinter() {
678 void AstPrinter::PrintIndented(
const char* txt) {
679 for (
int i = 0;
i < indent_;
i++) {
686 void AstPrinter::PrintLiteralIndented(
const char* info,
687 Handle<Object> value,
691 PrintLiteral(value, quote);
696 void AstPrinter::PrintLiteralWithModeIndented(
const char* info,
698 Handle<Object> value) {
700 PrintLiteralIndented(info, value,
true);
702 EmbeddedVector<char, 256> buf;
703 int pos =
SNPrintF(buf,
"%s (mode = %s", info,
704 Variable::Mode2String(var->mode()));
706 PrintLiteralIndented(buf.start(), value,
true);
711 void AstPrinter::PrintLabelsIndented(ZoneList<const AstRawString*>* labels) {
712 if (labels ==
NULL || labels->length() == 0)
return;
713 PrintIndented(
"LABELS ");
719 void AstPrinter::PrintIndentedVisit(
const char* s, AstNode* node) {
720 IndentedScope indent(
this, s);
725 const char* AstPrinter::PrintProgram(FunctionLiteral*
program) {
727 { IndentedScope indent(
this,
"FUNC");
728 PrintLiteralIndented(
"NAME",
program->name(),
true);
729 PrintLiteralIndented(
"INFERRED NAME",
program->inferred_name(),
true);
730 PrintParameters(
program->scope());
731 PrintDeclarations(
program->scope()->declarations());
732 PrintStatements(
program->body());
738 void AstPrinter::PrintDeclarations(ZoneList<Declaration*>* declarations) {
739 if (declarations->length() > 0) {
740 IndentedScope indent(
this,
"DECLS");
741 for (
int i = 0;
i < declarations->length();
i++) {
742 Visit(declarations->at(
i));
748 void AstPrinter::PrintParameters(Scope* scope) {
749 if (scope->num_parameters() > 0) {
750 IndentedScope indent(
this,
"PARAMS");
751 for (
int i = 0;
i < scope->num_parameters();
i++) {
752 PrintLiteralWithModeIndented(
"VAR", scope->parameter(
i),
753 scope->parameter(
i)->name());
759 void AstPrinter::PrintStatements(ZoneList<Statement*>* statements) {
760 for (
int i = 0;
i < statements->length();
i++) {
761 Visit(statements->at(
i));
766 void AstPrinter::PrintArguments(ZoneList<Expression*>* arguments) {
767 for (
int i = 0;
i < arguments->length();
i++) {
768 Visit(arguments->at(
i));
773 void AstPrinter::VisitBlock(Block* node) {
774 const char* block_txt = node->is_initializer_block() ?
"BLOCK INIT" :
"BLOCK";
775 IndentedScope indent(
this, block_txt);
776 PrintStatements(node->statements());
781 void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) {
782 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()),
783 node->proxy()->var(),
784 node->proxy()->name());
789 void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
790 PrintIndented(
"FUNCTION ");
791 PrintLiteral(node->proxy()->name(),
true);
792 Print(
" = function ");
793 PrintLiteral(node->fun()->name(),
false);
798 void AstPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
799 IndentedScope indent(
this,
"MODULE");
800 PrintLiteralIndented(
"NAME", node->proxy()->name(),
true);
801 Visit(node->module());
805 void AstPrinter::VisitImportDeclaration(ImportDeclaration* node) {
806 IndentedScope indent(
this,
"IMPORT");
807 PrintLiteralIndented(
"NAME", node->proxy()->name(),
true);
808 Visit(node->module());
812 void AstPrinter::VisitExportDeclaration(ExportDeclaration* node) {
813 IndentedScope indent(
this,
"EXPORT ");
814 PrintLiteral(node->proxy()->name(),
true);
818 void AstPrinter::VisitModuleLiteral(ModuleLiteral* node) {
819 IndentedScope indent(
this,
"MODULE LITERAL");
820 VisitBlock(node->body());
824 void AstPrinter::VisitModuleVariable(ModuleVariable* node) {
825 IndentedScope indent(
this,
"MODULE VARIABLE");
826 Visit(node->proxy());
830 void AstPrinter::VisitModulePath(ModulePath* node) {
831 IndentedScope indent(
this,
"MODULE PATH");
832 PrintIndentedVisit(
"MODULE PATH PARENT", node->module());
833 PrintLiteralIndented(
"NAME", node->name(),
true);
837 void AstPrinter::VisitModuleUrl(ModuleUrl* node) {
838 PrintLiteralIndented(
"URL", node->url(),
true);
842 void AstPrinter::VisitModuleStatement(ModuleStatement* node) {
843 IndentedScope indent(
this,
"MODULE STATEMENT");
844 PrintLiteralIndented(
"NAME", node->proxy()->name(),
true);
845 PrintStatements(node->body()->statements());
849 void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) {
850 IndentedScope indent(
this,
"EXPRESSION STATEMENT");
851 Visit(node->expression());
855 void AstPrinter::VisitEmptyStatement(EmptyStatement* node) {
856 IndentedScope indent(
this,
"EMPTY");
860 void AstPrinter::VisitIfStatement(IfStatement* node) {
861 IndentedScope indent(
this,
"IF");
862 PrintIndentedVisit(
"CONDITION", node->condition());
863 PrintIndentedVisit(
"THEN", node->then_statement());
864 if (node->HasElseStatement()) {
865 PrintIndentedVisit(
"ELSE", node->else_statement());
870 void AstPrinter::VisitContinueStatement(ContinueStatement* node) {
871 IndentedScope indent(
this,
"CONTINUE");
872 PrintLabelsIndented(node->target()->labels());
876 void AstPrinter::VisitBreakStatement(BreakStatement* node) {
877 IndentedScope indent(
this,
"BREAK");
878 PrintLabelsIndented(node->target()->labels());
882 void AstPrinter::VisitReturnStatement(ReturnStatement* node) {
883 IndentedScope indent(
this,
"RETURN");
884 Visit(node->expression());
888 void AstPrinter::VisitWithStatement(WithStatement* node) {
889 IndentedScope indent(
this,
"WITH");
890 PrintIndentedVisit(
"OBJECT", node->expression());
891 PrintIndentedVisit(
"BODY", node->statement());
895 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) {
896 IndentedScope indent(
this,
"SWITCH");
897 PrintLabelsIndented(node->labels());
898 PrintIndentedVisit(
"TAG", node->tag());
899 for (
int i = 0;
i < node->cases()->length();
i++) {
900 Visit(node->cases()->at(
i));
905 void AstPrinter::VisitCaseClause(CaseClause* clause) {
906 if (clause->is_default()) {
907 IndentedScope indent(
this,
"DEFAULT");
908 PrintStatements(clause->statements());
910 IndentedScope indent(
this,
"CASE");
911 Visit(clause->label());
912 PrintStatements(clause->statements());
917 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) {
918 IndentedScope indent(
this,
"DO");
919 PrintLabelsIndented(node->labels());
920 PrintIndentedVisit(
"BODY", node->body());
921 PrintIndentedVisit(
"COND", node->cond());
925 void AstPrinter::VisitWhileStatement(WhileStatement* node) {
926 IndentedScope indent(
this,
"WHILE");
927 PrintLabelsIndented(node->labels());
928 PrintIndentedVisit(
"COND", node->cond());
929 PrintIndentedVisit(
"BODY", node->body());
933 void AstPrinter::VisitForStatement(ForStatement* node) {
934 IndentedScope indent(
this,
"FOR");
935 PrintLabelsIndented(node->labels());
936 if (node->init()) PrintIndentedVisit(
"INIT", node->init());
937 if (node->cond()) PrintIndentedVisit(
"COND", node->cond());
938 PrintIndentedVisit(
"BODY", node->body());
939 if (node->next()) PrintIndentedVisit(
"NEXT", node->next());
943 void AstPrinter::VisitForInStatement(ForInStatement* node) {
944 IndentedScope indent(
this,
"FOR IN");
945 PrintIndentedVisit(
"FOR", node->each());
946 PrintIndentedVisit(
"IN", node->enumerable());
947 PrintIndentedVisit(
"BODY", node->body());
951 void AstPrinter::VisitForOfStatement(ForOfStatement* node) {
952 IndentedScope indent(
this,
"FOR OF");
953 PrintIndentedVisit(
"FOR", node->each());
954 PrintIndentedVisit(
"OF", node->iterable());
955 PrintIndentedVisit(
"BODY", node->body());
959 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
960 IndentedScope indent(
this,
"TRY CATCH");
961 PrintIndentedVisit(
"TRY", node->try_block());
962 PrintLiteralWithModeIndented(
"CATCHVAR",
964 node->variable()->name());
965 PrintIndentedVisit(
"CATCH", node->catch_block());
969 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
970 IndentedScope indent(
this,
"TRY FINALLY");
971 PrintIndentedVisit(
"TRY", node->try_block());
972 PrintIndentedVisit(
"FINALLY", node->finally_block());
976 void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) {
977 IndentedScope indent(
this,
"DEBUGGER");
981 void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
982 IndentedScope indent(
this,
"FUNC LITERAL");
983 PrintLiteralIndented(
"NAME", node->name(),
false);
984 PrintLiteralIndented(
"INFERRED NAME", node->inferred_name(),
false);
985 PrintParameters(node->scope());
993 void AstPrinter::VisitClassLiteral(ClassLiteral* node) {
994 IndentedScope indent(
this,
"CLASS LITERAL");
995 PrintLiteralIndented(
"NAME", node->name(),
false);
999 void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
1000 IndentedScope indent(
this,
"NATIVE FUNC LITERAL");
1001 PrintLiteralIndented(
"NAME", node->name(),
false);
1005 void AstPrinter::VisitConditional(Conditional* node) {
1006 IndentedScope indent(
this,
"CONDITIONAL");
1007 PrintIndentedVisit(
"CONDITION", node->condition());
1008 PrintIndentedVisit(
"THEN", node->then_expression());
1009 PrintIndentedVisit(
"ELSE", node->else_expression());
1014 void AstPrinter::VisitLiteral(Literal* node) {
1015 PrintLiteralIndented(
"LITERAL", node->value(),
true);
1019 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
1020 IndentedScope indent(
this,
"REGEXP LITERAL");
1021 PrintLiteralIndented(
"PATTERN", node->pattern(),
false);
1022 PrintLiteralIndented(
"FLAGS", node->flags(),
false);
1026 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
1027 IndentedScope indent(
this,
"OBJ LITERAL");
1028 for (
int i = 0;
i < node->properties()->length();
i++) {
1029 const char* prop_kind =
NULL;
1030 switch (node->properties()->at(
i)->kind()) {
1032 prop_kind =
"PROPERTY - CONSTANT";
1034 case ObjectLiteral::Property::COMPUTED:
1035 prop_kind =
"PROPERTY - COMPUTED";
1037 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1038 prop_kind =
"PROPERTY - MATERIALIZED_LITERAL";
1040 case ObjectLiteral::Property::PROTOTYPE:
1041 prop_kind =
"PROPERTY - PROTOTYPE";
1043 case ObjectLiteral::Property::GETTER:
1044 prop_kind =
"PROPERTY - GETTER";
1046 case ObjectLiteral::Property::SETTER:
1047 prop_kind =
"PROPERTY - SETTER";
1052 IndentedScope prop(
this, prop_kind);
1053 PrintIndentedVisit(
"KEY", node->properties()->at(
i)->key());
1054 PrintIndentedVisit(
"VALUE", node->properties()->at(
i)->value());
1059 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) {
1060 IndentedScope indent(
this,
"ARRAY LITERAL");
1061 if (node->values()->length() > 0) {
1062 IndentedScope indent(
this,
"VALUES");
1063 for (
int i = 0;
i < node->values()->length();
i++) {
1064 Visit(node->values()->at(
i));
1071 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
1072 Variable* var = node->var();
1073 EmbeddedVector<char, 128> buf;
1074 int pos =
SNPrintF(buf,
"VAR PROXY");
1075 switch (var->location()) {
1076 case Variable::UNALLOCATED:
1078 case Variable::PARAMETER:
1079 SNPrintF(buf + pos,
" parameter[%d]", var->index());
1081 case Variable::LOCAL:
1082 SNPrintF(buf + pos,
" local[%d]", var->index());
1084 case Variable::CONTEXT:
1085 SNPrintF(buf + pos,
" context[%d]", var->index());
1087 case Variable::LOOKUP:
1091 PrintLiteralWithModeIndented(buf.start(), var, node->name());
1095 void AstPrinter::VisitAssignment(Assignment* node) {
1096 IndentedScope indent(
this, Token::Name(node->op()));
1097 Visit(node->target());
1098 Visit(node->value());
1102 void AstPrinter::VisitYield(Yield* node) {
1103 IndentedScope indent(
this,
"YIELD");
1104 Visit(node->expression());
1108 void AstPrinter::VisitThrow(
Throw* node) {
1109 IndentedScope indent(
this,
"THROW");
1110 Visit(node->exception());
1114 void AstPrinter::VisitProperty(Property* node) {
1115 IndentedScope indent(
this,
"PROPERTY");
1117 Literal* literal = node->key()->AsLiteral();
1118 if (literal !=
NULL && literal->value()->IsInternalizedString()) {
1119 PrintLiteralIndented(
"NAME", literal->value(),
false);
1121 PrintIndentedVisit(
"KEY", node->key());
1126 void AstPrinter::VisitCall(Call* node) {
1127 IndentedScope indent(
this,
"CALL");
1128 Visit(node->expression());
1129 PrintArguments(node->arguments());
1133 void AstPrinter::VisitCallNew(CallNew* node) {
1134 IndentedScope indent(
this,
"CALL NEW");
1135 Visit(node->expression());
1136 PrintArguments(node->arguments());
1140 void AstPrinter::VisitCallRuntime(CallRuntime* node) {
1141 IndentedScope indent(
this,
"CALL RUNTIME");
1142 PrintLiteralIndented(
"NAME", node->name(),
false);
1143 PrintArguments(node->arguments());
1147 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
1148 IndentedScope indent(
this, Token::Name(node->op()));
1149 Visit(node->expression());
1153 void AstPrinter::VisitCountOperation(CountOperation* node) {
1154 EmbeddedVector<char, 128> buf;
1155 SNPrintF(buf,
"%s %s", (node->is_prefix() ?
"PRE" :
"POST"),
1156 Token::Name(node->op()));
1157 IndentedScope indent(
this, buf.start());
1158 Visit(node->expression());
1162 void AstPrinter::VisitBinaryOperation(BinaryOperation* node) {
1163 IndentedScope indent(
this, Token::Name(node->op()));
1164 Visit(node->left());
1165 Visit(node->right());
1169 void AstPrinter::VisitCompareOperation(CompareOperation* node) {
1170 IndentedScope indent(
this, Token::Name(node->op()));
1171 Visit(node->left());
1172 Visit(node->right());
1176 void AstPrinter::VisitThisFunction(ThisFunction* node) {
1177 IndentedScope indent(
this,
"THIS-FUNCTION");
1181 void AstPrinter::VisitSuperReference(SuperReference* node) {
1182 IndentedScope indent(
this,
"SUPER-REFERENCE");
static const char * String(Value tok)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort program(dump core) when an uncaught exception is thrown") DEFINE_BOOL(randomize_hashes
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
void DeleteArray(T *array)
int SNPrintF(Vector< char > str, const char *format,...)
kSerializedDataOffset Object
void PrintF(const char *format,...)
int VSNPrintF(Vector< char > str, const char *format, va_list args)
void MemCopy(void *dest, const void *src, size_t size)
Debugger support for the V8 JavaScript engine.
static Handle< Value > Throw(Isolate *isolate, const char *message)