41 PrettyPrinter::PrettyPrinter(Zone* zone) {
45 InitializeAstVisitor(zone);
49 PrettyPrinter::~PrettyPrinter() {
54 void PrettyPrinter::VisitBlock(
Block* node) {
55 if (!node->is_initializer_block())
Print(
"{ ");
56 PrintStatements(node->statements());
57 if (node->statements()->length() > 0)
Print(
" ");
58 if (!node->is_initializer_block())
Print(
"}");
62 void PrettyPrinter::VisitVariableDeclaration(VariableDeclaration* node) {
64 PrintLiteral(node->proxy()->name(),
false);
69 void PrettyPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
71 PrintLiteral(node->proxy()->name(),
false);
73 PrintFunctionLiteral(node->fun());
78 void PrettyPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
80 PrintLiteral(node->proxy()->name(),
false);
82 Visit(node->module());
87 void PrettyPrinter::VisitImportDeclaration(ImportDeclaration* node) {
89 PrintLiteral(node->proxy()->name(),
false);
91 Visit(node->module());
96 void PrettyPrinter::VisitExportDeclaration(ExportDeclaration* node) {
98 PrintLiteral(node->proxy()->name(),
false);
103 void PrettyPrinter::VisitModuleLiteral(ModuleLiteral* node) {
104 VisitBlock(node->body());
108 void PrettyPrinter::VisitModuleVariable(ModuleVariable* node) {
109 Visit(node->proxy());
113 void PrettyPrinter::VisitModulePath(ModulePath* node) {
114 Visit(node->module());
116 PrintLiteral(node->name(),
false);
120 void PrettyPrinter::VisitModuleUrl(ModuleUrl* node) {
122 PrintLiteral(node->url(),
true);
126 void PrettyPrinter::VisitModuleStatement(ModuleStatement* node) {
128 PrintLiteral(node->proxy()->name(),
false);
134 void PrettyPrinter::VisitExpressionStatement(ExpressionStatement* node) {
135 Visit(node->expression());
140 void PrettyPrinter::VisitEmptyStatement(EmptyStatement* node) {
145 void PrettyPrinter::VisitIfStatement(IfStatement* node) {
147 Visit(node->condition());
149 Visit(node->then_statement());
150 if (node->HasElseStatement()) {
152 Visit(node->else_statement());
157 void PrettyPrinter::VisitContinueStatement(ContinueStatement* node) {
160 if (labels !=
NULL) {
162 ASSERT(labels->length() > 0);
163 PrintLiteral(labels->at(0),
false);
169 void PrettyPrinter::VisitBreakStatement(BreakStatement* node) {
172 if (labels !=
NULL) {
174 ASSERT(labels->length() > 0);
175 PrintLiteral(labels->at(0),
false);
181 void PrettyPrinter::VisitReturnStatement(ReturnStatement* node) {
183 Visit(node->expression());
188 void PrettyPrinter::VisitWithStatement(WithStatement* node) {
190 Visit(node->expression());
192 Visit(node->statement());
196 void PrettyPrinter::VisitSwitchStatement(SwitchStatement* node) {
197 PrintLabels(node->labels());
201 ZoneList<CaseClause*>* cases = node->cases();
202 for (
int i = 0; i < cases->length(); i++)
208 void PrettyPrinter::VisitCaseClause(CaseClause* clause) {
209 if (clause->is_default()) {
213 Visit(clause->label());
216 PrintStatements(clause->statements());
217 if (clause->statements()->length() > 0)
222 void PrettyPrinter::VisitDoWhileStatement(DoWhileStatement* node) {
223 PrintLabels(node->labels());
232 void PrettyPrinter::VisitWhileStatement(WhileStatement* node) {
233 PrintLabels(node->labels());
241 void PrettyPrinter::VisitForStatement(ForStatement* node) {
242 PrintLabels(node->labels());
244 if (node->init() !=
NULL) {
250 if (node->cond() !=
NULL) Visit(node->cond());
252 if (node->next() !=
NULL) {
261 void PrettyPrinter::VisitForInStatement(ForInStatement* node) {
262 PrintLabels(node->labels());
266 Visit(node->enumerable());
272 void PrettyPrinter::VisitForOfStatement(ForOfStatement* node) {
273 PrintLabels(node->labels());
277 Visit(node->iterable());
283 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
285 Visit(node->try_block());
287 const bool quote =
false;
288 PrintLiteral(node->variable()->name(), quote);
290 Visit(node->catch_block());
294 void PrettyPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
296 Visit(node->try_block());
298 Visit(node->finally_block());
302 void PrettyPrinter::VisitDebuggerStatement(DebuggerStatement* node) {
307 void PrettyPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
309 PrintFunctionLiteral(node);
314 void PrettyPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
316 PrintLiteral(node->name(),
false);
321 void PrettyPrinter::VisitConditional(Conditional* node) {
322 Visit(node->condition());
324 Visit(node->then_expression());
326 Visit(node->else_expression());
330 void PrettyPrinter::VisitLiteral(Literal* node) {
331 PrintLiteral(node->value(),
true);
335 void PrettyPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
337 PrintLiteral(node->pattern(),
false);
339 PrintLiteral(node->flags(),
false);
344 void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) {
346 for (
int i = 0; i < node->properties()->length(); i++) {
347 if (i != 0)
Print(
",");
348 ObjectLiteral::Property*
property = node->properties()->at(i);
350 Visit(property->key());
352 Visit(property->value());
358 void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) {
360 for (
int i = 0; i < node->values()->length(); i++) {
361 if (i != 0)
Print(
",");
362 Visit(node->values()->at(i));
368 void PrettyPrinter::VisitVariableProxy(VariableProxy* node) {
369 PrintLiteral(node->name(),
false);
373 void PrettyPrinter::VisitAssignment(Assignment* node) {
374 Visit(node->target());
376 Visit(node->value());
380 void PrettyPrinter::VisitYield(Yield* node) {
382 Visit(node->expression());
386 void PrettyPrinter::VisitThrow(Throw* node) {
388 Visit(node->exception());
392 void PrettyPrinter::VisitProperty(Property* node) {
393 Expression* key = node->key();
394 Literal* literal = key->AsLiteral();
395 if (literal !=
NULL && literal->value()->IsInternalizedString()) {
399 PrintLiteral(literal->value(),
false);
409 void PrettyPrinter::VisitCall(Call* node) {
410 Visit(node->expression());
411 PrintArguments(node->arguments());
415 void PrettyPrinter::VisitCallNew(CallNew* node) {
417 Visit(node->expression());
419 PrintArguments(node->arguments());
423 void PrettyPrinter::VisitCallRuntime(CallRuntime* node) {
425 PrintLiteral(node->name(),
false);
426 PrintArguments(node->arguments());
430 void PrettyPrinter::VisitUnaryOperation(UnaryOperation* node) {
433 op == Token::DELETE || op == Token::TYPEOF || op ==
Token::VOID;
435 Visit(node->expression());
440 void PrettyPrinter::VisitCountOperation(CountOperation* node) {
443 Visit(node->expression());
449 void PrettyPrinter::VisitBinaryOperation(BinaryOperation* node) {
453 Visit(node->right());
458 void PrettyPrinter::VisitCompareOperation(CompareOperation* node) {
462 Visit(node->right());
467 void PrettyPrinter::VisitThisFunction(ThisFunction* node) {
468 Print(
"<this-function>");
479 const char* PrettyPrinter::PrintExpression(FunctionLiteral* program) {
481 ExpressionStatement* statement =
482 program->body()->at(0)->AsExpressionStatement();
483 Visit(statement->expression());
488 const char* PrettyPrinter::PrintProgram(FunctionLiteral* program) {
490 PrintStatements(program->body());
496 void PrettyPrinter::PrintOut(Zone* zone, AstNode* node) {
497 PrettyPrinter printer(zone);
498 PrintF(
"%s", printer.Print(node));
502 void PrettyPrinter::Init() {
505 const int initial_size = 256;
506 output_ = NewArray<char>(initial_size);
507 size_ = initial_size;
517 va_start(arguments, format);
529 const int slack = 32;
530 int new_size = size_ + (size_ >> 1) + slack;
531 char* new_output = NewArray<char>(new_size);
534 output_ = new_output;
541 void PrettyPrinter::PrintStatements(ZoneList<Statement*>* statements) {
542 if (statements ==
NULL)
return;
543 for (
int i = 0; i < statements->length(); i++) {
544 if (i != 0)
Print(
" ");
545 Visit(statements->at(i));
551 if (labels !=
NULL) {
552 for (
int i = 0; i < labels->length(); i++) {
553 PrintLiteral(labels->at(i),
false);
560 void PrettyPrinter::PrintArguments(ZoneList<Expression*>* arguments) {
562 for (
int i = 0; i < arguments->length(); i++) {
563 if (i != 0)
Print(
", ");
564 Visit(arguments->at(i));
570 void PrettyPrinter::PrintLiteral(Handle<Object> value,
bool quote) {
572 if (object->IsString()) {
574 if (quote)
Print(
"\"");
575 for (
int i = 0; i <
string->length(); i++) {
576 Print(
"%c", string->Get(i));
578 if (quote)
Print(
"\"");
579 }
else if (object->IsNull()) {
581 }
else if (object->IsTrue()) {
583 }
else if (object->IsFalse()) {
585 }
else if (object->IsUndefined()) {
587 }
else if (object->IsNumber()) {
588 Print(
"%g", object->Number());
589 }
else if (object->IsJSObject()) {
591 if (object->IsJSFunction()) {
592 Print(
"JS-Function");
593 }
else if (object->IsJSArray()) {
595 }
else if (object->IsJSObject()) {
600 }
else if (object->IsFixedArray()) {
603 Print(
"<unknown literal %p>",
object);
608 void PrettyPrinter::PrintParameters(Scope* scope) {
610 for (
int i = 0; i < scope->num_parameters(); i++) {
611 if (i > 0)
Print(
", ");
612 PrintLiteral(scope->parameter(i)->name(),
false);
618 void PrettyPrinter::PrintDeclarations(ZoneList<Declaration*>* declarations) {
619 for (
int i = 0; i < declarations->length(); i++) {
620 if (i > 0)
Print(
" ");
621 Visit(declarations->at(i));
626 void PrettyPrinter::PrintFunctionLiteral(FunctionLiteral*
function) {
628 PrintLiteral(function->name(),
false);
629 PrintParameters(function->scope());
631 PrintDeclarations(function->scope()->declarations());
632 PrintStatements(function->body());
641 IndentedScope(AstPrinter* printer,
const char* txt)
642 : ast_printer_(printer) {
643 ast_printer_->PrintIndented(txt);
644 ast_printer_->Print(
"\n");
645 ast_printer_->inc_indent();
648 virtual ~IndentedScope() {
649 ast_printer_->dec_indent();
653 AstPrinter* ast_printer_;
660 AstPrinter::AstPrinter(Zone* zone) : PrettyPrinter(zone), indent_(0) {
664 AstPrinter::~AstPrinter() {
669 void AstPrinter::PrintIndented(
const char* txt) {
670 for (
int i = 0; i < indent_; i++) {
677 void AstPrinter::PrintLiteralIndented(
const char*
info,
678 Handle<Object> value,
682 PrintLiteral(value, quote);
687 void AstPrinter::PrintLiteralWithModeIndented(
const char*
info,
689 Handle<Object> value) {
691 PrintLiteralIndented(info, value,
true);
693 EmbeddedVector<char, 256> buf;
697 PrintLiteralIndented(buf.start(), value,
true);
703 if (labels ==
NULL || labels->length() == 0)
return;
704 PrintIndented(
"LABELS ");
710 void AstPrinter::PrintIndentedVisit(
const char* s, AstNode* node) {
711 IndentedScope indent(
this, s);
716 const char* AstPrinter::PrintProgram(FunctionLiteral* program) {
718 { IndentedScope indent(
this,
"FUNC");
719 PrintLiteralIndented(
"NAME", program->name(),
true);
720 PrintLiteralIndented(
"INFERRED NAME", program->inferred_name(),
true);
721 PrintParameters(program->scope());
722 PrintDeclarations(program->scope()->declarations());
723 PrintStatements(program->body());
729 void AstPrinter::PrintDeclarations(ZoneList<Declaration*>* declarations) {
730 if (declarations->length() > 0) {
731 IndentedScope indent(
this,
"DECLS");
732 for (
int i = 0; i < declarations->length(); i++) {
733 Visit(declarations->at(i));
739 void AstPrinter::PrintParameters(Scope* scope) {
740 if (scope->num_parameters() > 0) {
741 IndentedScope indent(
this,
"PARAMS");
742 for (
int i = 0; i < scope->num_parameters(); i++) {
743 PrintLiteralWithModeIndented(
"VAR", scope->parameter(i),
744 scope->parameter(i)->name());
750 void AstPrinter::PrintStatements(ZoneList<Statement*>* statements) {
751 for (
int i = 0; i < statements->length(); i++) {
752 Visit(statements->at(i));
757 void AstPrinter::PrintArguments(ZoneList<Expression*>* arguments) {
758 for (
int i = 0; i < arguments->length(); i++) {
759 Visit(arguments->at(i));
764 void AstPrinter::VisitBlock(
Block* node) {
765 const char* block_txt = node->is_initializer_block() ?
"BLOCK INIT" :
"BLOCK";
766 IndentedScope indent(
this, block_txt);
767 PrintStatements(node->statements());
772 void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) {
774 node->proxy()->var(),
775 node->proxy()->name());
780 void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
781 PrintIndented(
"FUNCTION ");
782 PrintLiteral(node->proxy()->name(),
true);
783 Print(
" = function ");
784 PrintLiteral(node->fun()->name(),
false);
789 void AstPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
790 IndentedScope indent(
this,
"MODULE");
791 PrintLiteralIndented(
"NAME", node->proxy()->name(),
true);
792 Visit(node->module());
796 void AstPrinter::VisitImportDeclaration(ImportDeclaration* node) {
797 IndentedScope indent(
this,
"IMPORT");
798 PrintLiteralIndented(
"NAME", node->proxy()->name(),
true);
799 Visit(node->module());
803 void AstPrinter::VisitExportDeclaration(ExportDeclaration* node) {
804 IndentedScope indent(
this,
"EXPORT ");
805 PrintLiteral(node->proxy()->name(),
true);
809 void AstPrinter::VisitModuleLiteral(ModuleLiteral* node) {
810 IndentedScope indent(
this,
"MODULE LITERAL");
811 VisitBlock(node->body());
815 void AstPrinter::VisitModuleVariable(ModuleVariable* node) {
816 IndentedScope indent(
this,
"MODULE VARIABLE");
817 Visit(node->proxy());
821 void AstPrinter::VisitModulePath(ModulePath* node) {
822 IndentedScope indent(
this,
"MODULE PATH");
823 PrintIndentedVisit(
"MODULE PATH PARENT", node->module());
824 PrintLiteralIndented(
"NAME", node->name(),
true);
828 void AstPrinter::VisitModuleUrl(ModuleUrl* node) {
829 PrintLiteralIndented(
"URL", node->url(),
true);
833 void AstPrinter::VisitModuleStatement(ModuleStatement* node) {
834 IndentedScope indent(
this,
"MODULE STATEMENT");
835 PrintLiteralIndented(
"NAME", node->proxy()->name(),
true);
836 PrintStatements(node->body()->statements());
840 void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) {
841 IndentedScope indent(
this,
"EXPRESSION STATEMENT");
842 Visit(node->expression());
846 void AstPrinter::VisitEmptyStatement(EmptyStatement* node) {
847 IndentedScope indent(
this,
"EMPTY");
851 void AstPrinter::VisitIfStatement(IfStatement* node) {
852 IndentedScope indent(
this,
"IF");
853 PrintIndentedVisit(
"CONDITION", node->condition());
854 PrintIndentedVisit(
"THEN", node->then_statement());
855 if (node->HasElseStatement()) {
856 PrintIndentedVisit(
"ELSE", node->else_statement());
861 void AstPrinter::VisitContinueStatement(ContinueStatement* node) {
862 IndentedScope indent(
this,
"CONTINUE");
863 PrintLabelsIndented(node->target()->labels());
867 void AstPrinter::VisitBreakStatement(BreakStatement* node) {
868 IndentedScope indent(
this,
"BREAK");
869 PrintLabelsIndented(node->target()->labels());
873 void AstPrinter::VisitReturnStatement(ReturnStatement* node) {
874 IndentedScope indent(
this,
"RETURN");
875 Visit(node->expression());
879 void AstPrinter::VisitWithStatement(WithStatement* node) {
880 IndentedScope indent(
this,
"WITH");
881 PrintIndentedVisit(
"OBJECT", node->expression());
882 PrintIndentedVisit(
"BODY", node->statement());
886 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) {
887 IndentedScope indent(
this,
"SWITCH");
888 PrintLabelsIndented(node->labels());
889 PrintIndentedVisit(
"TAG", node->tag());
890 for (
int i = 0; i < node->cases()->length(); i++) {
891 Visit(node->cases()->at(i));
896 void AstPrinter::VisitCaseClause(CaseClause* clause) {
897 if (clause->is_default()) {
898 IndentedScope indent(
this,
"DEFAULT");
899 PrintStatements(clause->statements());
901 IndentedScope indent(
this,
"CASE");
902 Visit(clause->label());
903 PrintStatements(clause->statements());
908 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) {
909 IndentedScope indent(
this,
"DO");
910 PrintLabelsIndented(node->labels());
911 PrintIndentedVisit(
"BODY", node->body());
912 PrintIndentedVisit(
"COND", node->cond());
916 void AstPrinter::VisitWhileStatement(WhileStatement* node) {
917 IndentedScope indent(
this,
"WHILE");
918 PrintLabelsIndented(node->labels());
919 PrintIndentedVisit(
"COND", node->cond());
920 PrintIndentedVisit(
"BODY", node->body());
924 void AstPrinter::VisitForStatement(ForStatement* node) {
925 IndentedScope indent(
this,
"FOR");
926 PrintLabelsIndented(node->labels());
927 if (node->init()) PrintIndentedVisit(
"INIT", node->init());
928 if (node->cond()) PrintIndentedVisit(
"COND", node->cond());
929 PrintIndentedVisit(
"BODY", node->body());
930 if (node->next()) PrintIndentedVisit(
"NEXT", node->next());
934 void AstPrinter::VisitForInStatement(ForInStatement* node) {
935 IndentedScope indent(
this,
"FOR IN");
936 PrintIndentedVisit(
"FOR", node->each());
937 PrintIndentedVisit(
"IN", node->enumerable());
938 PrintIndentedVisit(
"BODY", node->body());
942 void AstPrinter::VisitForOfStatement(ForOfStatement* node) {
943 IndentedScope indent(
this,
"FOR OF");
944 PrintIndentedVisit(
"FOR", node->each());
945 PrintIndentedVisit(
"OF", node->iterable());
946 PrintIndentedVisit(
"BODY", node->body());
950 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
951 IndentedScope indent(
this,
"TRY CATCH");
952 PrintIndentedVisit(
"TRY", node->try_block());
953 PrintLiteralWithModeIndented(
"CATCHVAR",
955 node->variable()->name());
956 PrintIndentedVisit(
"CATCH", node->catch_block());
960 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
961 IndentedScope indent(
this,
"TRY FINALLY");
962 PrintIndentedVisit(
"TRY", node->try_block());
963 PrintIndentedVisit(
"FINALLY", node->finally_block());
967 void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) {
968 IndentedScope indent(
this,
"DEBUGGER");
972 void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
973 IndentedScope indent(
this,
"FUNC LITERAL");
974 PrintLiteralIndented(
"NAME", node->name(),
false);
975 PrintLiteralIndented(
"INFERRED NAME", node->inferred_name(),
false);
976 PrintParameters(node->scope());
984 void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
985 IndentedScope indent(
this,
"NATIVE FUNC LITERAL");
986 PrintLiteralIndented(
"NAME", node->name(),
false);
990 void AstPrinter::VisitConditional(Conditional* node) {
991 IndentedScope indent(
this,
"CONDITIONAL");
992 PrintIndentedVisit(
"CONDITION", node->condition());
993 PrintIndentedVisit(
"THEN", node->then_expression());
994 PrintIndentedVisit(
"ELSE", node->else_expression());
999 void AstPrinter::VisitLiteral(Literal* node) {
1000 PrintLiteralIndented(
"LITERAL", node->value(),
true);
1004 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
1005 IndentedScope indent(
this,
"REGEXP LITERAL");
1006 PrintLiteralIndented(
"PATTERN", node->pattern(),
false);
1007 PrintLiteralIndented(
"FLAGS", node->flags(),
false);
1011 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
1012 IndentedScope indent(
this,
"OBJ LITERAL");
1013 for (
int i = 0; i < node->properties()->length(); i++) {
1014 const char* prop_kind =
NULL;
1015 switch (node->properties()->at(i)->kind()) {
1017 prop_kind =
"PROPERTY - CONSTANT";
1019 case ObjectLiteral::Property::COMPUTED:
1020 prop_kind =
"PROPERTY - COMPUTED";
1022 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1023 prop_kind =
"PROPERTY - MATERIALIZED_LITERAL";
1025 case ObjectLiteral::Property::PROTOTYPE:
1026 prop_kind =
"PROPERTY - PROTOTYPE";
1028 case ObjectLiteral::Property::GETTER:
1029 prop_kind =
"PROPERTY - GETTER";
1031 case ObjectLiteral::Property::SETTER:
1032 prop_kind =
"PROPERTY - SETTER";
1037 IndentedScope prop(
this, prop_kind);
1038 PrintIndentedVisit(
"KEY", node->properties()->at(i)->key());
1039 PrintIndentedVisit(
"VALUE", node->properties()->at(i)->value());
1044 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) {
1045 IndentedScope indent(
this,
"ARRAY LITERAL");
1046 if (node->values()->length() > 0) {
1047 IndentedScope indent(
this,
"VALUES");
1048 for (
int i = 0; i < node->values()->length(); i++) {
1049 Visit(node->values()->at(i));
1056 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
1057 Variable* var = node->var();
1058 EmbeddedVector<char, 128> buf;
1060 switch (var->location()) {
1064 OS::SNPrintF(buf + pos,
" parameter[%d]", var->index());
1076 PrintLiteralWithModeIndented(buf.start(), var, node->name());
1080 void AstPrinter::VisitAssignment(Assignment* node) {
1081 IndentedScope indent(
this,
Token::Name(node->op()));
1082 Visit(node->target());
1083 Visit(node->value());
1087 void AstPrinter::VisitYield(Yield* node) {
1088 IndentedScope indent(
this,
"YIELD");
1089 Visit(node->expression());
1093 void AstPrinter::VisitThrow(Throw* node) {
1094 IndentedScope indent(
this,
"THROW");
1095 Visit(node->exception());
1099 void AstPrinter::VisitProperty(Property* node) {
1100 IndentedScope indent(
this,
"PROPERTY");
1102 Literal* literal = node->key()->AsLiteral();
1103 if (literal !=
NULL && literal->value()->IsInternalizedString()) {
1104 PrintLiteralIndented(
"NAME", literal->value(),
false);
1106 PrintIndentedVisit(
"KEY", node->key());
1111 void AstPrinter::VisitCall(Call* node) {
1112 IndentedScope indent(
this,
"CALL");
1113 Visit(node->expression());
1114 PrintArguments(node->arguments());
1118 void AstPrinter::VisitCallNew(CallNew* node) {
1119 IndentedScope indent(
this,
"CALL NEW");
1120 Visit(node->expression());
1121 PrintArguments(node->arguments());
1125 void AstPrinter::VisitCallRuntime(CallRuntime* node) {
1126 IndentedScope indent(
this,
"CALL RUNTIME");
1127 PrintLiteralIndented(
"NAME", node->name(),
false);
1128 PrintArguments(node->arguments());
1132 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
1133 IndentedScope indent(
this,
Token::Name(node->op()));
1134 Visit(node->expression());
1138 void AstPrinter::VisitCountOperation(CountOperation* node) {
1139 EmbeddedVector<char, 128> buf;
1140 OS::SNPrintF(buf,
"%s %s", (node->is_prefix() ?
"PRE" :
"POST"),
1142 IndentedScope indent(
this, buf.start());
1143 Visit(node->expression());
1147 void AstPrinter::VisitBinaryOperation(BinaryOperation* node) {
1148 IndentedScope indent(
this,
Token::Name(node->op()));
1149 Visit(node->left());
1150 Visit(node->right());
1154 void AstPrinter::VisitCompareOperation(CompareOperation* node) {
1155 IndentedScope indent(
this,
Token::Name(node->op()));
1156 Visit(node->left());
1157 Visit(node->right());
1161 void AstPrinter::VisitThisFunction(ThisFunction* node) {
1162 IndentedScope indent(
this,
"THIS-FUNCTION");
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
void PrintF(const char *format,...)
static int VSNPrintF(Vector< char > str, const char *format, va_list args)
static String * cast(Object *obj)
static const char * Name(Value tok)
kSerializedDataOffset Object
#define ASSERT(condition)
static void MemCopy(void *dest, const void *src, size_t size)
static const char * String(Value tok)
static const char * Mode2String(VariableMode mode)
static JSArray * cast(Object *obj)
static int SNPrintF(Vector< char > str, const char *format,...)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
ZoneList< Handle< String > > ZoneStringList
void DeleteArray(T *array)