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

Side by Side Diff: src/prettyprinter.cc

Issue 1377833002: Make AstPrinter print position information. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | no next file » | 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/prettyprinter.h" 5 #include "src/prettyprinter.h"
6 6
7 #include <stdarg.h> 7 #include <stdarg.h>
8 8
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 1056
1057 class IndentedScope BASE_EMBEDDED { 1057 class IndentedScope BASE_EMBEDDED {
1058 public: 1058 public:
1059 IndentedScope(AstPrinter* printer, const char* txt) 1059 IndentedScope(AstPrinter* printer, const char* txt)
1060 : ast_printer_(printer) { 1060 : ast_printer_(printer) {
1061 ast_printer_->PrintIndented(txt); 1061 ast_printer_->PrintIndented(txt);
1062 ast_printer_->Print("\n"); 1062 ast_printer_->Print("\n");
1063 ast_printer_->inc_indent(); 1063 ast_printer_->inc_indent();
1064 } 1064 }
1065 1065
1066 IndentedScope(AstPrinter* printer, const char* txt, int pos)
1067 : ast_printer_(printer) {
1068 ast_printer_->PrintIndented(txt);
1069 ast_printer_->Print(" at %d\n", pos);
1070 ast_printer_->inc_indent();
1071 }
1072
1066 virtual ~IndentedScope() { 1073 virtual ~IndentedScope() {
1067 ast_printer_->dec_indent(); 1074 ast_printer_->dec_indent();
1068 } 1075 }
1069 1076
1070 private: 1077 private:
1071 AstPrinter* ast_printer_; 1078 AstPrinter* ast_printer_;
1072 }; 1079 };
1073 1080
1074 1081
1075 //----------------------------------------------------------------------------- 1082 //-----------------------------------------------------------------------------
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 1126
1120 void AstPrinter::PrintLabelsIndented(ZoneList<const AstRawString*>* labels) { 1127 void AstPrinter::PrintLabelsIndented(ZoneList<const AstRawString*>* labels) {
1121 if (labels == NULL || labels->length() == 0) return; 1128 if (labels == NULL || labels->length() == 0) return;
1122 PrintIndented("LABELS "); 1129 PrintIndented("LABELS ");
1123 PrintLabels(labels); 1130 PrintLabels(labels);
1124 Print("\n"); 1131 Print("\n");
1125 } 1132 }
1126 1133
1127 1134
1128 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { 1135 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) {
1129 IndentedScope indent(this, s); 1136 IndentedScope indent(this, s, node->position());
1130 Visit(node); 1137 Visit(node);
1131 } 1138 }
1132 1139
1133 1140
1134 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { 1141 const char* AstPrinter::PrintProgram(FunctionLiteral* program) {
1135 Init(); 1142 Init();
1136 { IndentedScope indent(this, "FUNC"); 1143 { IndentedScope indent(this, "FUNC", program->position());
1137 PrintLiteralIndented("NAME", program->name(), true); 1144 PrintLiteralIndented("NAME", program->name(), true);
1138 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true); 1145 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true);
1139 PrintParameters(program->scope()); 1146 PrintParameters(program->scope());
1140 PrintDeclarations(program->scope()->declarations()); 1147 PrintDeclarations(program->scope()->declarations());
1141 PrintStatements(program->body()); 1148 PrintStatements(program->body());
1142 } 1149 }
1143 return Output(); 1150 return Output();
1144 } 1151 }
1145 1152
1146 1153
(...skipping 28 matching lines...) Expand all
1175 void AstPrinter::PrintArguments(ZoneList<Expression*>* arguments) { 1182 void AstPrinter::PrintArguments(ZoneList<Expression*>* arguments) {
1176 for (int i = 0; i < arguments->length(); i++) { 1183 for (int i = 0; i < arguments->length(); i++) {
1177 Visit(arguments->at(i)); 1184 Visit(arguments->at(i));
1178 } 1185 }
1179 } 1186 }
1180 1187
1181 1188
1182 void AstPrinter::VisitBlock(Block* node) { 1189 void AstPrinter::VisitBlock(Block* node) {
1183 const char* block_txt = 1190 const char* block_txt =
1184 node->ignore_completion_value() ? "BLOCK NOCOMPLETIONS" : "BLOCK"; 1191 node->ignore_completion_value() ? "BLOCK NOCOMPLETIONS" : "BLOCK";
1185 IndentedScope indent(this, block_txt); 1192 IndentedScope indent(this, block_txt, node->position());
1186 PrintStatements(node->statements()); 1193 PrintStatements(node->statements());
1187 } 1194 }
1188 1195
1189 1196
1190 // TODO(svenpanne) Start with IndentedScope. 1197 // TODO(svenpanne) Start with IndentedScope.
1191 void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) { 1198 void AstPrinter::VisitVariableDeclaration(VariableDeclaration* node) {
1192 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()), 1199 PrintLiteralWithModeIndented(Variable::Mode2String(node->mode()),
1193 node->proxy()->var(), 1200 node->proxy()->var(),
1194 node->proxy()->name()); 1201 node->proxy()->name());
1195 } 1202 }
1196 1203
1197 1204
1198 // TODO(svenpanne) Start with IndentedScope. 1205 // TODO(svenpanne) Start with IndentedScope.
1199 void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) { 1206 void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {
1200 PrintIndented("FUNCTION "); 1207 PrintIndented("FUNCTION ");
1201 PrintLiteral(node->proxy()->name(), true); 1208 PrintLiteral(node->proxy()->name(), true);
1202 Print(" = function "); 1209 Print(" = function ");
1203 PrintLiteral(node->fun()->name(), false); 1210 PrintLiteral(node->fun()->name(), false);
1204 Print("\n"); 1211 Print("\n");
1205 } 1212 }
1206 1213
1207 1214
1208 void AstPrinter::VisitImportDeclaration(ImportDeclaration* node) { 1215 void AstPrinter::VisitImportDeclaration(ImportDeclaration* node) {
1209 IndentedScope indent(this, "IMPORT"); 1216 IndentedScope indent(this, "IMPORT", node->position());
1210 PrintLiteralIndented("NAME", node->proxy()->name(), true); 1217 PrintLiteralIndented("NAME", node->proxy()->name(), true);
1211 PrintLiteralIndented("FROM", node->module_specifier()->string(), true); 1218 PrintLiteralIndented("FROM", node->module_specifier()->string(), true);
1212 } 1219 }
1213 1220
1214 1221
1215 void AstPrinter::VisitExportDeclaration(ExportDeclaration* node) { 1222 void AstPrinter::VisitExportDeclaration(ExportDeclaration* node) {
1216 IndentedScope indent(this, "EXPORT "); 1223 IndentedScope indent(this, "EXPORT", node->position());
1217 PrintLiteral(node->proxy()->name(), true); 1224 PrintLiteral(node->proxy()->name(), true);
1218 } 1225 }
1219 1226
1220 1227
1221 void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) { 1228 void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) {
1222 IndentedScope indent(this, "EXPRESSION STATEMENT"); 1229 IndentedScope indent(this, "EXPRESSION STATEMENT", node->position());
1223 Visit(node->expression()); 1230 Visit(node->expression());
1224 } 1231 }
1225 1232
1226 1233
1227 void AstPrinter::VisitEmptyStatement(EmptyStatement* node) { 1234 void AstPrinter::VisitEmptyStatement(EmptyStatement* node) {
1228 IndentedScope indent(this, "EMPTY"); 1235 IndentedScope indent(this, "EMPTY", node->position());
1229 } 1236 }
1230 1237
1231 1238
1232 void AstPrinter::VisitSloppyBlockFunctionStatement( 1239 void AstPrinter::VisitSloppyBlockFunctionStatement(
1233 SloppyBlockFunctionStatement* node) { 1240 SloppyBlockFunctionStatement* node) {
1234 Visit(node->statement()); 1241 Visit(node->statement());
1235 } 1242 }
1236 1243
1237 1244
1238 void AstPrinter::VisitIfStatement(IfStatement* node) { 1245 void AstPrinter::VisitIfStatement(IfStatement* node) {
1239 IndentedScope indent(this, "IF"); 1246 IndentedScope indent(this, "IF", node->position());
1240 PrintIndentedVisit("CONDITION", node->condition()); 1247 PrintIndentedVisit("CONDITION", node->condition());
1241 PrintIndentedVisit("THEN", node->then_statement()); 1248 PrintIndentedVisit("THEN", node->then_statement());
1242 if (node->HasElseStatement()) { 1249 if (node->HasElseStatement()) {
1243 PrintIndentedVisit("ELSE", node->else_statement()); 1250 PrintIndentedVisit("ELSE", node->else_statement());
1244 } 1251 }
1245 } 1252 }
1246 1253
1247 1254
1248 void AstPrinter::VisitContinueStatement(ContinueStatement* node) { 1255 void AstPrinter::VisitContinueStatement(ContinueStatement* node) {
1249 IndentedScope indent(this, "CONTINUE"); 1256 IndentedScope indent(this, "CONTINUE", node->position());
1250 PrintLabelsIndented(node->target()->labels()); 1257 PrintLabelsIndented(node->target()->labels());
1251 } 1258 }
1252 1259
1253 1260
1254 void AstPrinter::VisitBreakStatement(BreakStatement* node) { 1261 void AstPrinter::VisitBreakStatement(BreakStatement* node) {
1255 IndentedScope indent(this, "BREAK"); 1262 IndentedScope indent(this, "BREAK", node->position());
1256 PrintLabelsIndented(node->target()->labels()); 1263 PrintLabelsIndented(node->target()->labels());
1257 } 1264 }
1258 1265
1259 1266
1260 void AstPrinter::VisitReturnStatement(ReturnStatement* node) { 1267 void AstPrinter::VisitReturnStatement(ReturnStatement* node) {
1261 IndentedScope indent(this, "RETURN"); 1268 IndentedScope indent(this, "RETURN", node->position());
1262 Visit(node->expression()); 1269 Visit(node->expression());
1263 } 1270 }
1264 1271
1265 1272
1266 void AstPrinter::VisitWithStatement(WithStatement* node) { 1273 void AstPrinter::VisitWithStatement(WithStatement* node) {
1267 IndentedScope indent(this, "WITH"); 1274 IndentedScope indent(this, "WITH", node->position());
1268 PrintIndentedVisit("OBJECT", node->expression()); 1275 PrintIndentedVisit("OBJECT", node->expression());
1269 PrintIndentedVisit("BODY", node->statement()); 1276 PrintIndentedVisit("BODY", node->statement());
1270 } 1277 }
1271 1278
1272 1279
1273 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { 1280 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) {
1274 IndentedScope indent(this, "SWITCH"); 1281 IndentedScope indent(this, "SWITCH", node->position());
1275 PrintLabelsIndented(node->labels()); 1282 PrintLabelsIndented(node->labels());
1276 PrintIndentedVisit("TAG", node->tag()); 1283 PrintIndentedVisit("TAG", node->tag());
1277 for (int i = 0; i < node->cases()->length(); i++) { 1284 for (int i = 0; i < node->cases()->length(); i++) {
1278 Visit(node->cases()->at(i)); 1285 Visit(node->cases()->at(i));
1279 } 1286 }
1280 } 1287 }
1281 1288
1282 1289
1283 void AstPrinter::VisitCaseClause(CaseClause* clause) { 1290 void AstPrinter::VisitCaseClause(CaseClause* clause) {
1284 if (clause->is_default()) { 1291 if (clause->is_default()) {
1285 IndentedScope indent(this, "DEFAULT"); 1292 IndentedScope indent(this, "DEFAULT", clause->position());
1286 PrintStatements(clause->statements()); 1293 PrintStatements(clause->statements());
1287 } else { 1294 } else {
1288 IndentedScope indent(this, "CASE"); 1295 IndentedScope indent(this, "CASE", clause->position());
1289 Visit(clause->label()); 1296 Visit(clause->label());
1290 PrintStatements(clause->statements()); 1297 PrintStatements(clause->statements());
1291 } 1298 }
1292 } 1299 }
1293 1300
1294 1301
1295 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) { 1302 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) {
1296 IndentedScope indent(this, "DO"); 1303 IndentedScope indent(this, "DO", node->position());
1297 PrintLabelsIndented(node->labels()); 1304 PrintLabelsIndented(node->labels());
1298 PrintIndentedVisit("BODY", node->body()); 1305 PrintIndentedVisit("BODY", node->body());
1299 PrintIndentedVisit("COND", node->cond()); 1306 PrintIndentedVisit("COND", node->cond());
1300 } 1307 }
1301 1308
1302 1309
1303 void AstPrinter::VisitWhileStatement(WhileStatement* node) { 1310 void AstPrinter::VisitWhileStatement(WhileStatement* node) {
1304 IndentedScope indent(this, "WHILE"); 1311 IndentedScope indent(this, "WHILE", node->position());
1305 PrintLabelsIndented(node->labels()); 1312 PrintLabelsIndented(node->labels());
1306 PrintIndentedVisit("COND", node->cond()); 1313 PrintIndentedVisit("COND", node->cond());
1307 PrintIndentedVisit("BODY", node->body()); 1314 PrintIndentedVisit("BODY", node->body());
1308 } 1315 }
1309 1316
1310 1317
1311 void AstPrinter::VisitForStatement(ForStatement* node) { 1318 void AstPrinter::VisitForStatement(ForStatement* node) {
1312 IndentedScope indent(this, "FOR"); 1319 IndentedScope indent(this, "FOR", node->position());
1313 PrintLabelsIndented(node->labels()); 1320 PrintLabelsIndented(node->labels());
1314 if (node->init()) PrintIndentedVisit("INIT", node->init()); 1321 if (node->init()) PrintIndentedVisit("INIT", node->init());
1315 if (node->cond()) PrintIndentedVisit("COND", node->cond()); 1322 if (node->cond()) PrintIndentedVisit("COND", node->cond());
1316 PrintIndentedVisit("BODY", node->body()); 1323 PrintIndentedVisit("BODY", node->body());
1317 if (node->next()) PrintIndentedVisit("NEXT", node->next()); 1324 if (node->next()) PrintIndentedVisit("NEXT", node->next());
1318 } 1325 }
1319 1326
1320 1327
1321 void AstPrinter::VisitForInStatement(ForInStatement* node) { 1328 void AstPrinter::VisitForInStatement(ForInStatement* node) {
1322 IndentedScope indent(this, "FOR IN"); 1329 IndentedScope indent(this, "FOR IN", node->position());
1323 PrintIndentedVisit("FOR", node->each()); 1330 PrintIndentedVisit("FOR", node->each());
1324 PrintIndentedVisit("IN", node->enumerable()); 1331 PrintIndentedVisit("IN", node->enumerable());
1325 PrintIndentedVisit("BODY", node->body()); 1332 PrintIndentedVisit("BODY", node->body());
1326 } 1333 }
1327 1334
1328 1335
1329 void AstPrinter::VisitForOfStatement(ForOfStatement* node) { 1336 void AstPrinter::VisitForOfStatement(ForOfStatement* node) {
1330 IndentedScope indent(this, "FOR OF"); 1337 IndentedScope indent(this, "FOR OF", node->position());
1331 PrintIndentedVisit("FOR", node->each()); 1338 PrintIndentedVisit("FOR", node->each());
1332 PrintIndentedVisit("OF", node->iterable()); 1339 PrintIndentedVisit("OF", node->iterable());
1333 PrintIndentedVisit("BODY", node->body()); 1340 PrintIndentedVisit("BODY", node->body());
1334 } 1341 }
1335 1342
1336 1343
1337 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { 1344 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
1338 IndentedScope indent(this, "TRY CATCH"); 1345 IndentedScope indent(this, "TRY CATCH", node->position());
1339 PrintIndentedVisit("TRY", node->try_block()); 1346 PrintIndentedVisit("TRY", node->try_block());
1340 PrintLiteralWithModeIndented("CATCHVAR", 1347 PrintLiteralWithModeIndented("CATCHVAR",
1341 node->variable(), 1348 node->variable(),
1342 node->variable()->name()); 1349 node->variable()->name());
1343 PrintIndentedVisit("CATCH", node->catch_block()); 1350 PrintIndentedVisit("CATCH", node->catch_block());
1344 } 1351 }
1345 1352
1346 1353
1347 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { 1354 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
1348 IndentedScope indent(this, "TRY finalLY"); 1355 IndentedScope indent(this, "TRY FINALLY", node->position());
1349 PrintIndentedVisit("TRY", node->try_block()); 1356 PrintIndentedVisit("TRY", node->try_block());
1350 PrintIndentedVisit("FINALLY", node->finally_block()); 1357 PrintIndentedVisit("FINALLY", node->finally_block());
1351 } 1358 }
1352 1359
1353 1360
1354 void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) { 1361 void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) {
1355 IndentedScope indent(this, "DEBUGGER"); 1362 IndentedScope indent(this, "DEBUGGER", node->position());
1356 } 1363 }
1357 1364
1358 1365
1359 void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) { 1366 void AstPrinter::VisitFunctionLiteral(FunctionLiteral* node) {
1360 IndentedScope indent(this, "FUNC LITERAL"); 1367 IndentedScope indent(this, "FUNC LITERAL", node->position());
1361 PrintLiteralIndented("NAME", node->name(), false); 1368 PrintLiteralIndented("NAME", node->name(), false);
1362 PrintLiteralIndented("INFERRED NAME", node->inferred_name(), false); 1369 PrintLiteralIndented("INFERRED NAME", node->inferred_name(), false);
1363 PrintParameters(node->scope()); 1370 PrintParameters(node->scope());
1364 // We don't want to see the function literal in this case: it 1371 // We don't want to see the function literal in this case: it
1365 // will be printed via PrintProgram when the code for it is 1372 // will be printed via PrintProgram when the code for it is
1366 // generated. 1373 // generated.
1367 // PrintStatements(node->body()); 1374 // PrintStatements(node->body());
1368 } 1375 }
1369 1376
1370 1377
1371 void AstPrinter::VisitClassLiteral(ClassLiteral* node) { 1378 void AstPrinter::VisitClassLiteral(ClassLiteral* node) {
1372 IndentedScope indent(this, "CLASS LITERAL"); 1379 IndentedScope indent(this, "CLASS LITERAL", node->position());
1373 if (node->raw_name() != nullptr) { 1380 if (node->raw_name() != nullptr) {
1374 PrintLiteralIndented("NAME", node->name(), false); 1381 PrintLiteralIndented("NAME", node->name(), false);
1375 } 1382 }
1376 if (node->extends() != nullptr) { 1383 if (node->extends() != nullptr) {
1377 PrintIndentedVisit("EXTENDS", node->extends()); 1384 PrintIndentedVisit("EXTENDS", node->extends());
1378 } 1385 }
1379 PrintProperties(node->properties()); 1386 PrintProperties(node->properties());
1380 } 1387 }
1381 1388
1382 1389
(...skipping 26 matching lines...) Expand all
1409 SNPrintF(buf, "PROPERTY%s - %s", property->is_static() ? " - STATIC" : "", 1416 SNPrintF(buf, "PROPERTY%s - %s", property->is_static() ? " - STATIC" : "",
1410 prop_kind); 1417 prop_kind);
1411 IndentedScope prop(this, buf.start()); 1418 IndentedScope prop(this, buf.start());
1412 PrintIndentedVisit("KEY", properties->at(i)->key()); 1419 PrintIndentedVisit("KEY", properties->at(i)->key());
1413 PrintIndentedVisit("VALUE", properties->at(i)->value()); 1420 PrintIndentedVisit("VALUE", properties->at(i)->value());
1414 } 1421 }
1415 } 1422 }
1416 1423
1417 1424
1418 void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) { 1425 void AstPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) {
1419 IndentedScope indent(this, "NATIVE FUNC LITERAL"); 1426 IndentedScope indent(this, "NATIVE FUNC LITERAL", node->position());
1420 PrintLiteralIndented("NAME", node->name(), false); 1427 PrintLiteralIndented("NAME", node->name(), false);
1421 } 1428 }
1422 1429
1423 1430
1424 void AstPrinter::VisitConditional(Conditional* node) { 1431 void AstPrinter::VisitConditional(Conditional* node) {
1425 IndentedScope indent(this, "CONDITIONAL"); 1432 IndentedScope indent(this, "CONDITIONAL", node->position());
1426 PrintIndentedVisit("CONDITION", node->condition()); 1433 PrintIndentedVisit("CONDITION", node->condition());
1427 PrintIndentedVisit("THEN", node->then_expression()); 1434 PrintIndentedVisit("THEN", node->then_expression());
1428 PrintIndentedVisit("ELSE", node->else_expression()); 1435 PrintIndentedVisit("ELSE", node->else_expression());
1429 } 1436 }
1430 1437
1431 1438
1432 // TODO(svenpanne) Start with IndentedScope. 1439 // TODO(svenpanne) Start with IndentedScope.
1433 void AstPrinter::VisitLiteral(Literal* node) { 1440 void AstPrinter::VisitLiteral(Literal* node) {
1434 PrintLiteralIndented("LITERAL", node->value(), true); 1441 PrintLiteralIndented("LITERAL", node->value(), true);
1435 } 1442 }
1436 1443
1437 1444
1438 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { 1445 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
1439 IndentedScope indent(this, "REGEXP LITERAL"); 1446 IndentedScope indent(this, "REGEXP LITERAL", node->position());
1440 EmbeddedVector<char, 128> buf; 1447 EmbeddedVector<char, 128> buf;
1441 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); 1448 SNPrintF(buf, "literal_index = %d\n", node->literal_index());
1442 PrintIndented(buf.start()); 1449 PrintIndented(buf.start());
1443 PrintLiteralIndented("PATTERN", node->pattern(), false); 1450 PrintLiteralIndented("PATTERN", node->pattern(), false);
1444 PrintLiteralIndented("FLAGS", node->flags(), false); 1451 PrintLiteralIndented("FLAGS", node->flags(), false);
1445 } 1452 }
1446 1453
1447 1454
1448 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { 1455 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
1449 IndentedScope indent(this, "OBJ LITERAL"); 1456 IndentedScope indent(this, "OBJ LITERAL", node->position());
1450 EmbeddedVector<char, 128> buf; 1457 EmbeddedVector<char, 128> buf;
1451 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); 1458 SNPrintF(buf, "literal_index = %d\n", node->literal_index());
1452 PrintIndented(buf.start()); 1459 PrintIndented(buf.start());
1453 PrintProperties(node->properties()); 1460 PrintProperties(node->properties());
1454 } 1461 }
1455 1462
1456 1463
1457 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) { 1464 void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) {
1458 IndentedScope indent(this, "ARRAY LITERAL"); 1465 IndentedScope indent(this, "ARRAY LITERAL", node->position());
1459 1466
1460 EmbeddedVector<char, 128> buf; 1467 EmbeddedVector<char, 128> buf;
1461 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); 1468 SNPrintF(buf, "literal_index = %d\n", node->literal_index());
1462 PrintIndented(buf.start()); 1469 PrintIndented(buf.start());
1463 if (node->values()->length() > 0) { 1470 if (node->values()->length() > 0) {
1464 IndentedScope indent(this, "VALUES"); 1471 IndentedScope indent(this, "VALUES", node->position());
1465 for (int i = 0; i < node->values()->length(); i++) { 1472 for (int i = 0; i < node->values()->length(); i++) {
1466 Visit(node->values()->at(i)); 1473 Visit(node->values()->at(i));
1467 } 1474 }
1468 } 1475 }
1469 } 1476 }
1470 1477
1471 1478
1472 void AstPrinter::VisitVariableProxy(VariableProxy* node) { 1479 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
1473 Variable* var = node->var(); 1480 Variable* var = node->var();
1474 EmbeddedVector<char, 128> buf; 1481 EmbeddedVector<char, 128> buf;
(...skipping 17 matching lines...) Expand all
1492 break; 1499 break;
1493 case VariableLocation::LOOKUP: 1500 case VariableLocation::LOOKUP:
1494 SNPrintF(buf + pos, " lookup"); 1501 SNPrintF(buf + pos, " lookup");
1495 break; 1502 break;
1496 } 1503 }
1497 PrintLiteralWithModeIndented(buf.start(), var, node->name()); 1504 PrintLiteralWithModeIndented(buf.start(), var, node->name());
1498 } 1505 }
1499 1506
1500 1507
1501 void AstPrinter::VisitAssignment(Assignment* node) { 1508 void AstPrinter::VisitAssignment(Assignment* node) {
1502 IndentedScope indent(this, Token::Name(node->op())); 1509 IndentedScope indent(this, Token::Name(node->op()), node->position());
1503 Visit(node->target()); 1510 Visit(node->target());
1504 Visit(node->value()); 1511 Visit(node->value());
1505 } 1512 }
1506 1513
1507 1514
1508 void AstPrinter::VisitYield(Yield* node) { 1515 void AstPrinter::VisitYield(Yield* node) {
1509 IndentedScope indent(this, "YIELD"); 1516 IndentedScope indent(this, "YIELD", node->position());
1510 Visit(node->expression()); 1517 Visit(node->expression());
1511 } 1518 }
1512 1519
1513 1520
1514 void AstPrinter::VisitThrow(Throw* node) { 1521 void AstPrinter::VisitThrow(Throw* node) {
1515 IndentedScope indent(this, "THROW"); 1522 IndentedScope indent(this, "THROW", node->position());
1516 Visit(node->exception()); 1523 Visit(node->exception());
1517 } 1524 }
1518 1525
1519 1526
1520 void AstPrinter::VisitProperty(Property* node) { 1527 void AstPrinter::VisitProperty(Property* node) {
1521 EmbeddedVector<char, 128> buf; 1528 EmbeddedVector<char, 128> buf;
1522 FormatICSlotNode(&buf, node, "PROPERTY", node->PropertyFeedbackSlot()); 1529 FormatICSlotNode(&buf, node, "PROPERTY", node->PropertyFeedbackSlot());
1523 IndentedScope indent(this, buf.start()); 1530 IndentedScope indent(this, buf.start(), node->position());
1524 1531
1525 Visit(node->obj()); 1532 Visit(node->obj());
1526 Literal* literal = node->key()->AsLiteral(); 1533 Literal* literal = node->key()->AsLiteral();
1527 if (literal != NULL && literal->value()->IsInternalizedString()) { 1534 if (literal != NULL && literal->value()->IsInternalizedString()) {
1528 PrintLiteralIndented("NAME", literal->value(), false); 1535 PrintLiteralIndented("NAME", literal->value(), false);
1529 } else { 1536 } else {
1530 PrintIndentedVisit("KEY", node->key()); 1537 PrintIndentedVisit("KEY", node->key());
1531 } 1538 }
1532 } 1539 }
1533 1540
1534 1541
1535 void AstPrinter::VisitCall(Call* node) { 1542 void AstPrinter::VisitCall(Call* node) {
1536 EmbeddedVector<char, 128> buf; 1543 EmbeddedVector<char, 128> buf;
1537 FormatICSlotNode(&buf, node, "CALL", node->CallFeedbackICSlot()); 1544 FormatICSlotNode(&buf, node, "CALL", node->CallFeedbackICSlot());
1538 IndentedScope indent(this, buf.start()); 1545 IndentedScope indent(this, buf.start());
1539 1546
1540 Visit(node->expression()); 1547 Visit(node->expression());
1541 PrintArguments(node->arguments()); 1548 PrintArguments(node->arguments());
1542 } 1549 }
1543 1550
1544 1551
1545 void AstPrinter::VisitCallNew(CallNew* node) { 1552 void AstPrinter::VisitCallNew(CallNew* node) {
1546 IndentedScope indent(this, "CALL NEW"); 1553 IndentedScope indent(this, "CALL NEW", node->position());
1547 Visit(node->expression()); 1554 Visit(node->expression());
1548 PrintArguments(node->arguments()); 1555 PrintArguments(node->arguments());
1549 } 1556 }
1550 1557
1551 1558
1552 void AstPrinter::VisitCallRuntime(CallRuntime* node) { 1559 void AstPrinter::VisitCallRuntime(CallRuntime* node) {
1553 EmbeddedVector<char, 128> buf; 1560 EmbeddedVector<char, 128> buf;
1554 SNPrintF(buf, "CALL RUNTIME %s", node->debug_name()); 1561 SNPrintF(buf, "CALL RUNTIME %s", node->debug_name());
1555 IndentedScope indent(this, buf.start()); 1562 IndentedScope indent(this, buf.start(), node->position());
1556 PrintArguments(node->arguments()); 1563 PrintArguments(node->arguments());
1557 } 1564 }
1558 1565
1559 1566
1560 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) { 1567 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) {
1561 IndentedScope indent(this, Token::Name(node->op())); 1568 IndentedScope indent(this, Token::Name(node->op()), node->position());
1562 Visit(node->expression()); 1569 Visit(node->expression());
1563 } 1570 }
1564 1571
1565 1572
1566 void AstPrinter::VisitCountOperation(CountOperation* node) { 1573 void AstPrinter::VisitCountOperation(CountOperation* node) {
1567 EmbeddedVector<char, 128> buf; 1574 EmbeddedVector<char, 128> buf;
1568 SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"), 1575 SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"),
1569 Token::Name(node->op())); 1576 Token::Name(node->op()));
1570 IndentedScope indent(this, buf.start()); 1577 IndentedScope indent(this, buf.start(), node->position());
1571 Visit(node->expression()); 1578 Visit(node->expression());
1572 } 1579 }
1573 1580
1574 1581
1575 void AstPrinter::VisitBinaryOperation(BinaryOperation* node) { 1582 void AstPrinter::VisitBinaryOperation(BinaryOperation* node) {
1576 IndentedScope indent(this, Token::Name(node->op())); 1583 IndentedScope indent(this, Token::Name(node->op()), node->position());
1577 Visit(node->left()); 1584 Visit(node->left());
1578 Visit(node->right()); 1585 Visit(node->right());
1579 } 1586 }
1580 1587
1581 1588
1582 void AstPrinter::VisitCompareOperation(CompareOperation* node) { 1589 void AstPrinter::VisitCompareOperation(CompareOperation* node) {
1583 IndentedScope indent(this, Token::Name(node->op())); 1590 IndentedScope indent(this, Token::Name(node->op()), node->position());
1584 Visit(node->left()); 1591 Visit(node->left());
1585 Visit(node->right()); 1592 Visit(node->right());
1586 } 1593 }
1587 1594
1588 1595
1589 void AstPrinter::VisitSpread(Spread* node) { 1596 void AstPrinter::VisitSpread(Spread* node) {
1590 IndentedScope indent(this, "..."); 1597 IndentedScope indent(this, "...", node->position());
1591 Visit(node->expression()); 1598 Visit(node->expression());
1592 } 1599 }
1593 1600
1594 1601
1595 void AstPrinter::VisitEmptyParentheses(EmptyParentheses* node) { 1602 void AstPrinter::VisitEmptyParentheses(EmptyParentheses* node) {
1596 IndentedScope indent(this, "()"); 1603 IndentedScope indent(this, "()", node->position());
1597 } 1604 }
1598 1605
1599 1606
1600 void AstPrinter::VisitThisFunction(ThisFunction* node) { 1607 void AstPrinter::VisitThisFunction(ThisFunction* node) {
1601 IndentedScope indent(this, "THIS-FUNCTION"); 1608 IndentedScope indent(this, "THIS-FUNCTION", node->position());
1602 } 1609 }
1603 1610
1604 1611
1605 void AstPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) { 1612 void AstPrinter::VisitSuperPropertyReference(SuperPropertyReference* node) {
1606 IndentedScope indent(this, "SUPER-PROPERTY-REFERENCE"); 1613 IndentedScope indent(this, "SUPER-PROPERTY-REFERENCE", node->position());
1607 } 1614 }
1608 1615
1609 1616
1610 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { 1617 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) {
1611 IndentedScope indent(this, "SUPER-CALL-REFERENCE"); 1618 IndentedScope indent(this, "SUPER-CALL-REFERENCE", node->position());
1612 } 1619 }
1613 1620
1614 1621
1615 #endif // DEBUG 1622 #endif // DEBUG
1616 1623
1617 } // namespace internal 1624 } // namespace internal
1618 } // namespace v8 1625 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698