| Index: src/prettyprinter.cc
|
| diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc
|
| index 282057d739c10bc3c474c9812908cf051b51ea32..77cb1c5245a680049c457a8543c6250425d3fe99 100644
|
| --- a/src/prettyprinter.cc
|
| +++ b/src/prettyprinter.cc
|
| @@ -1063,6 +1063,13 @@ class IndentedScope BASE_EMBEDDED {
|
| ast_printer_->inc_indent();
|
| }
|
|
|
| + IndentedScope(AstPrinter* printer, const char* txt, int pos)
|
| + : ast_printer_(printer) {
|
| + ast_printer_->PrintIndented(txt);
|
| + ast_printer_->Print(" at %d\n", pos);
|
| + ast_printer_->inc_indent();
|
| + }
|
| +
|
| virtual ~IndentedScope() {
|
| ast_printer_->dec_indent();
|
| }
|
| @@ -1126,14 +1133,14 @@ void AstPrinter::PrintLabelsIndented(ZoneList<const AstRawString*>* labels) {
|
|
|
|
|
| void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) {
|
| - IndentedScope indent(this, s);
|
| + IndentedScope indent(this, s, node->position());
|
| Visit(node);
|
| }
|
|
|
|
|
| const char* AstPrinter::PrintProgram(FunctionLiteral* program) {
|
| Init();
|
| - { IndentedScope indent(this, "FUNC");
|
| + { IndentedScope indent(this, "FUNC", program->position());
|
| PrintLiteralIndented("NAME", program->name(), true);
|
| PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true);
|
| PrintParameters(program->scope());
|
| @@ -1182,7 +1189,7 @@ void AstPrinter::PrintArguments(ZoneList<Expression*>* arguments) {
|
| void AstPrinter::VisitBlock(Block* node) {
|
| const char* block_txt =
|
| node->ignore_completion_value() ? "BLOCK NOCOMPLETIONS" : "BLOCK";
|
| - IndentedScope indent(this, block_txt);
|
| + IndentedScope indent(this, block_txt, node->position());
|
| PrintStatements(node->statements());
|
| }
|
|
|
| @@ -1206,26 +1213,26 @@ void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
|
|
|
|
|
| void AstPrinter::VisitImportDeclaration(ImportDeclaration* node) {
|
| - IndentedScope indent(this, "IMPORT");
|
| + IndentedScope indent(this, "IMPORT", node->position());
|
| PrintLiteralIndented("NAME", node->proxy()->name(), true);
|
| PrintLiteralIndented("FROM", node->module_specifier()->string(), true);
|
| }
|
|
|
|
|
| void AstPrinter::VisitExportDeclaration(ExportDeclaration* node) {
|
| - IndentedScope indent(this, "EXPORT ");
|
| + IndentedScope indent(this, "EXPORT", node->position());
|
| PrintLiteral(node->proxy()->name(), true);
|
| }
|
|
|
|
|
| void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) {
|
| - IndentedScope indent(this, "EXPRESSION STATEMENT");
|
| + IndentedScope indent(this, "EXPRESSION STATEMENT", node->position());
|
| Visit(node->expression());
|
| }
|
|
|
|
|
| void AstPrinter::VisitEmptyStatement(EmptyStatement* node) {
|
| - IndentedScope indent(this, "EMPTY");
|
| + IndentedScope indent(this, "EMPTY", node->position());
|
| }
|
|
|
|
|
| @@ -1236,7 +1243,7 @@ void AstPrinter::VisitSloppyBlockFunctionStatement(
|
|
|
|
|
| void AstPrinter::VisitIfStatement(IfStatement* node) {
|
| - IndentedScope indent(this, "IF");
|
| + IndentedScope indent(this, "IF", node->position());
|
| PrintIndentedVisit("CONDITION", node->condition());
|
| PrintIndentedVisit("THEN", node->then_statement());
|
| if (node->HasElseStatement()) {
|
| @@ -1246,32 +1253,32 @@ void AstPrinter::VisitIfStatement(IfStatement* node) {
|
|
|
|
|
| void AstPrinter::VisitContinueStatement(ContinueStatement* node) {
|
| - IndentedScope indent(this, "CONTINUE");
|
| + IndentedScope indent(this, "CONTINUE", node->position());
|
| PrintLabelsIndented(node->target()->labels());
|
| }
|
|
|
|
|
| void AstPrinter::VisitBreakStatement(BreakStatement* node) {
|
| - IndentedScope indent(this, "BREAK");
|
| + IndentedScope indent(this, "BREAK", node->position());
|
| PrintLabelsIndented(node->target()->labels());
|
| }
|
|
|
|
|
| void AstPrinter::VisitReturnStatement(ReturnStatement* node) {
|
| - IndentedScope indent(this, "RETURN");
|
| + IndentedScope indent(this, "RETURN", node->position());
|
| Visit(node->expression());
|
| }
|
|
|
|
|
| void AstPrinter::VisitWithStatement(WithStatement* node) {
|
| - IndentedScope indent(this, "WITH");
|
| + IndentedScope indent(this, "WITH", node->position());
|
| PrintIndentedVisit("OBJECT", node->expression());
|
| PrintIndentedVisit("BODY", node->statement());
|
| }
|
|
|
|
|
| void AstPrinter::VisitSwitchStatement(SwitchStatement* node) {
|
| - IndentedScope indent(this, "SWITCH");
|
| + IndentedScope indent(this, "SWITCH", node->position());
|
| PrintLabelsIndented(node->labels());
|
| PrintIndentedVisit("TAG", node->tag());
|
| for (int i = 0; i < node->cases()->length(); i++) {
|
| @@ -1282,10 +1289,10 @@ void AstPrinter::VisitSwitchStatement(SwitchStatement* node) {
|
|
|
| void AstPrinter::VisitCaseClause(CaseClause* clause) {
|
| if (clause->is_default()) {
|
| - IndentedScope indent(this, "DEFAULT");
|
| + IndentedScope indent(this, "DEFAULT", clause->position());
|
| PrintStatements(clause->statements());
|
| } else {
|
| - IndentedScope indent(this, "CASE");
|
| + IndentedScope indent(this, "CASE", clause->position());
|
| Visit(clause->label());
|
| PrintStatements(clause->statements());
|
| }
|
| @@ -1293,7 +1300,7 @@ void AstPrinter::VisitCaseClause(CaseClause* clause) {
|
|
|
|
|
| void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) {
|
| - IndentedScope indent(this, "DO");
|
| + IndentedScope indent(this, "DO", node->position());
|
| PrintLabelsIndented(node->labels());
|
| PrintIndentedVisit("BODY", node->body());
|
| PrintIndentedVisit("COND", node->cond());
|
| @@ -1301,7 +1308,7 @@ void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) {
|
|
|
|
|
| void AstPrinter::VisitWhileStatement(WhileStatement* node) {
|
| - IndentedScope indent(this, "WHILE");
|
| + IndentedScope indent(this, "WHILE", node->position());
|
| PrintLabelsIndented(node->labels());
|
| PrintIndentedVisit("COND", node->cond());
|
| PrintIndentedVisit("BODY", node->body());
|
| @@ -1309,7 +1316,7 @@ void AstPrinter::VisitWhileStatement(WhileStatement* node) {
|
|
|
|
|
| void AstPrinter::VisitForStatement(ForStatement* node) {
|
| - IndentedScope indent(this, "FOR");
|
| + IndentedScope indent(this, "FOR", node->position());
|
| PrintLabelsIndented(node->labels());
|
| if (node->init()) PrintIndentedVisit("INIT", node->init());
|
| if (node->cond()) PrintIndentedVisit("COND", node->cond());
|
| @@ -1319,7 +1326,7 @@ void AstPrinter::VisitForStatement(ForStatement* node) {
|
|
|
|
|
| void AstPrinter::VisitForInStatement(ForInStatement* node) {
|
| - IndentedScope indent(this, "FOR IN");
|
| + IndentedScope indent(this, "FOR IN", node->position());
|
| PrintIndentedVisit("FOR", node->each());
|
| PrintIndentedVisit("IN", node->enumerable());
|
| PrintIndentedVisit("BODY", node->body());
|
| @@ -1327,7 +1334,7 @@ void AstPrinter::VisitForInStatement(ForInStatement* node) {
|
|
|
|
|
| void AstPrinter::VisitForOfStatement(ForOfStatement* node) {
|
| - IndentedScope indent(this, "FOR OF");
|
| + IndentedScope indent(this, "FOR OF", node->position());
|
| PrintIndentedVisit("FOR", node->each());
|
| PrintIndentedVisit("OF", node->iterable());
|
| PrintIndentedVisit("BODY", node->body());
|
| @@ -1335,7 +1342,7 @@ void AstPrinter::VisitForOfStatement(ForOfStatement* node) {
|
|
|
|
|
| void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
|
| - IndentedScope indent(this, "TRY CATCH");
|
| + IndentedScope indent(this, "TRY CATCH", node->position());
|
| PrintIndentedVisit("TRY", node->try_block());
|
| PrintLiteralWithModeIndented("CATCHVAR",
|
| node->variable(),
|
| @@ -1345,19 +1352,19 @@ void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
|
|
|
|
|
| void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
|
| - IndentedScope indent(this, "TRY finalLY");
|
| + IndentedScope indent(this, "TRY FINALLY", node->position());
|
| PrintIndentedVisit("TRY", node->try_block());
|
| PrintIndentedVisit("FINALLY", node->finally_block());
|
| }
|
|
|
|
|
| void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) {
|
| - IndentedScope indent(this, "DEBUGGER");
|
| + IndentedScope indent(this, "DEBUGGER", node->position());
|
| }
|
|
|
|
|
| void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
|
| - IndentedScope indent(this, "FUNC LITERAL");
|
| + IndentedScope indent(this, "FUNC LITERAL", node->position());
|
| PrintLiteralIndented("NAME", node->name(), false);
|
| PrintLiteralIndented("INFERRED NAME", node->inferred_name(), false);
|
| PrintParameters(node->scope());
|
| @@ -1369,7 +1376,7 @@ void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
|
|
|
|
|
| void AstPrinter::VisitClassLiteral(ClassLiteral* node) {
|
| - IndentedScope indent(this, "CLASS LITERAL");
|
| + IndentedScope indent(this, "CLASS LITERAL", node->position());
|
| if (node->raw_name() != nullptr) {
|
| PrintLiteralIndented("NAME", node->name(), false);
|
| }
|
| @@ -1416,13 +1423,13 @@ void AstPrinter::PrintProperties(
|
|
|
|
|
| void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
|
| - IndentedScope indent(this, "NATIVE FUNC LITERAL");
|
| + IndentedScope indent(this, "NATIVE FUNC LITERAL", node->position());
|
| PrintLiteralIndented("NAME", node->name(), false);
|
| }
|
|
|
|
|
| void AstPrinter::VisitConditional(Conditional* node) {
|
| - IndentedScope indent(this, "CONDITIONAL");
|
| + IndentedScope indent(this, "CONDITIONAL", node->position());
|
| PrintIndentedVisit("CONDITION", node->condition());
|
| PrintIndentedVisit("THEN", node->then_expression());
|
| PrintIndentedVisit("ELSE", node->else_expression());
|
| @@ -1436,7 +1443,7 @@ void AstPrinter::VisitLiteral(Literal* node) {
|
|
|
|
|
| void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
|
| - IndentedScope indent(this, "REGEXP LITERAL");
|
| + IndentedScope indent(this, "REGEXP LITERAL", node->position());
|
| EmbeddedVector<char, 128> buf;
|
| SNPrintF(buf, "literal_index = %d\n", node->literal_index());
|
| PrintIndented(buf.start());
|
| @@ -1446,7 +1453,7 @@ void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
|
|
|
|
|
| void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
|
| - IndentedScope indent(this, "OBJ LITERAL");
|
| + IndentedScope indent(this, "OBJ LITERAL", node->position());
|
| EmbeddedVector<char, 128> buf;
|
| SNPrintF(buf, "literal_index = %d\n", node->literal_index());
|
| PrintIndented(buf.start());
|
| @@ -1455,13 +1462,13 @@ void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
|
|
|
|
|
| void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) {
|
| - IndentedScope indent(this, "ARRAY LITERAL");
|
| + IndentedScope indent(this, "ARRAY LITERAL", node->position());
|
|
|
| EmbeddedVector<char, 128> buf;
|
| SNPrintF(buf, "literal_index = %d\n", node->literal_index());
|
| PrintIndented(buf.start());
|
| if (node->values()->length() > 0) {
|
| - IndentedScope indent(this, "VALUES");
|
| + IndentedScope indent(this, "VALUES", node->position());
|
| for (int i = 0; i < node->values()->length(); i++) {
|
| Visit(node->values()->at(i));
|
| }
|
| @@ -1499,20 +1506,20 @@ void AstPrinter::VisitVariableProxy(VariableProxy* node) {
|
|
|
|
|
| void AstPrinter::VisitAssignment(Assignment* node) {
|
| - IndentedScope indent(this, Token::Name(node->op()));
|
| + IndentedScope indent(this, Token::Name(node->op()), node->position());
|
| Visit(node->target());
|
| Visit(node->value());
|
| }
|
|
|
|
|
| void AstPrinter::VisitYield(Yield* node) {
|
| - IndentedScope indent(this, "YIELD");
|
| + IndentedScope indent(this, "YIELD", node->position());
|
| Visit(node->expression());
|
| }
|
|
|
|
|
| void AstPrinter::VisitThrow(Throw* node) {
|
| - IndentedScope indent(this, "THROW");
|
| + IndentedScope indent(this, "THROW", node->position());
|
| Visit(node->exception());
|
| }
|
|
|
| @@ -1520,7 +1527,7 @@ void AstPrinter::VisitThrow(Throw* node) {
|
| void AstPrinter::VisitProperty(Property* node) {
|
| EmbeddedVector<char, 128> buf;
|
| FormatICSlotNode(&buf, node, "PROPERTY", node->PropertyFeedbackSlot());
|
| - IndentedScope indent(this, buf.start());
|
| + IndentedScope indent(this, buf.start(), node->position());
|
|
|
| Visit(node->obj());
|
| Literal* literal = node->key()->AsLiteral();
|
| @@ -1543,7 +1550,7 @@ void AstPrinter::VisitCall(Call* node) {
|
|
|
|
|
| void AstPrinter::VisitCallNew(CallNew* node) {
|
| - IndentedScope indent(this, "CALL NEW");
|
| + IndentedScope indent(this, "CALL NEW", node->position());
|
| Visit(node->expression());
|
| PrintArguments(node->arguments());
|
| }
|
| @@ -1552,13 +1559,13 @@ void AstPrinter::VisitCallNew(CallNew* node) {
|
| void AstPrinter::VisitCallRuntime(CallRuntime* node) {
|
| EmbeddedVector<char, 128> buf;
|
| SNPrintF(buf, "CALL RUNTIME %s", node->debug_name());
|
| - IndentedScope indent(this, buf.start());
|
| + IndentedScope indent(this, buf.start(), node->position());
|
| PrintArguments(node->arguments());
|
| }
|
|
|
|
|
| void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
|
| - IndentedScope indent(this, Token::Name(node->op()));
|
| + IndentedScope indent(this, Token::Name(node->op()), node->position());
|
| Visit(node->expression());
|
| }
|
|
|
| @@ -1567,48 +1574,48 @@ void AstPrinter::VisitCountOperation(CountOperation* node) {
|
| EmbeddedVector<char, 128> buf;
|
| SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"),
|
| Token::Name(node->op()));
|
| - IndentedScope indent(this, buf.start());
|
| + IndentedScope indent(this, buf.start(), node->position());
|
| Visit(node->expression());
|
| }
|
|
|
|
|
| void AstPrinter::VisitBinaryOperation(BinaryOperation* node) {
|
| - IndentedScope indent(this, Token::Name(node->op()));
|
| + IndentedScope indent(this, Token::Name(node->op()), node->position());
|
| Visit(node->left());
|
| Visit(node->right());
|
| }
|
|
|
|
|
| void AstPrinter::VisitCompareOperation(CompareOperation* node) {
|
| - IndentedScope indent(this, Token::Name(node->op()));
|
| + IndentedScope indent(this, Token::Name(node->op()), node->position());
|
| Visit(node->left());
|
| Visit(node->right());
|
| }
|
|
|
|
|
| void AstPrinter::VisitSpread(Spread* node) {
|
| - IndentedScope indent(this, "...");
|
| + IndentedScope indent(this, "...", node->position());
|
| Visit(node->expression());
|
| }
|
|
|
|
|
| void AstPrinter::VisitEmptyParentheses(EmptyParentheses* node) {
|
| - IndentedScope indent(this, "()");
|
| + IndentedScope indent(this, "()", node->position());
|
| }
|
|
|
|
|
| void AstPrinter::VisitThisFunction(ThisFunction* node) {
|
| - IndentedScope indent(this, "THIS-FUNCTION");
|
| + IndentedScope indent(this, "THIS-FUNCTION", node->position());
|
| }
|
|
|
|
|
| void AstPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) {
|
| - IndentedScope indent(this, "SUPER-PROPERTY-REFERENCE");
|
| + IndentedScope indent(this, "SUPER-PROPERTY-REFERENCE", node->position());
|
| }
|
|
|
|
|
| void AstPrinter::VisitSuperCallReference(SuperCallReference* node) {
|
| - IndentedScope indent(this, "SUPER-CALL-REFERENCE");
|
| + IndentedScope indent(this, "SUPER-CALL-REFERENCE", node->position());
|
| }
|
|
|
|
|
|
|