void PrettyPrinter::VisitRegExpLiteral(RegExpLiteral* node) { Print(" RegExp("); PrintLiteral(node->pattern(), false); Print(","); PrintLiteral(node->flags(), false); Print(") "); }
void PrettyPrinter::VisitModuleDeclaration(ModuleDeclaration* node) { Print("module "); PrintLiteral(node->proxy()->name(), false); Print(" = "); Visit(node->module()); Print(";"); }
void PrettyPrinter::VisitImportDeclaration(ImportDeclaration* node) { Print("import "); PrintLiteral(node->proxy()->name(), false); Print(" from "); Visit(node->module()); Print(";"); }
void PrettyPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) { Print("function "); PrintLiteral(node->proxy()->name(), false); Print(" = "); PrintFunctionLiteral(node->fun()); Print(";"); }
void PrettyPrinter::PrintParameters(Scope* scope) { Print("("); for (int i = 0; i < scope->num_parameters(); i++) { if (i > 0) Print(", "); PrintLiteral(scope->parameter(i)->name(), false); } Print(")"); }
void PrettyPrinter::PrintLabels(ZoneStringList* labels) { if (labels != NULL) { for (int i = 0; i < labels->length(); i++) { PrintLiteral(labels->at(i), false); Print(": "); } } }
void PrettyPrinter::PrintFunctionLiteral(FunctionLiteral* function) { Print("function "); PrintLiteral(function->name(), false); PrintParameters(function->scope()); Print(" { "); PrintDeclarations(function->scope()->declarations()); PrintStatements(function->body()); Print(" }"); }
void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) { Print("try "); Visit(node->try_block()); Print(" catch ("); const bool quote = false; PrintLiteral(node->variable()->name(), quote); Print(") "); Visit(node->catch_block()); }
void PrettyPrinter::VisitBreakStatement(BreakStatement* node) { Print("break"); ZoneStringList* labels = node->target()->labels(); if (labels != NULL) { Print(" "); ASSERT(labels->length() > 0); // guaranteed to have at least one entry PrintLiteral(labels->at(0), false); // any label from the list is fine } Print(";"); }
void PrettyPrinter::VisitProperty(Property* node) { Expression* key = node->key(); Literal* literal = key->AsLiteral(); if (literal != NULL && literal->value()->IsInternalizedString()) { Print("("); Visit(node->obj()); Print(")."); PrintLiteral(literal->value(), false); } else { Visit(node->obj()); Print("["); Visit(key); Print("]"); } }
void PrettyPrinter::VisitSlot(Slot* node) { switch (node->type()) { case Slot::PARAMETER: Print("parameter[%d]", node->index()); break; case Slot::LOCAL: Print("frame[%d]", node->index()); break; case Slot::CONTEXT: Print(".context[%d]", node->index()); break; case Slot::LOOKUP: Print(".context["); PrintLiteral(node->var()->name(), false); Print("]"); break; default: UNREACHABLE(); } }
void PrettyPrinter::VisitVariableProxy(VariableProxy* node) { PrintLiteral(node->name(), false); }
void PrettyPrinter::VisitCallRuntime(CallRuntime* node) { Print("%%"); PrintLiteral(node->name(), false); PrintArguments(node->arguments()); }
void PrettyPrinter::VisitLiteral(Literal* node) { PrintLiteral(node->value(), true); }
void PrettyPrinter::VisitNativeFunctionLiteral(NativeFunctionLiteral* node) { Print("("); PrintLiteral(node->name(), false); Print(")"); }
void PrettyPrinter::VisitModuleStatement(ModuleStatement* node) { Print("module "); PrintLiteral(node->proxy()->name(), false); Print(" "); Visit(node->body()); }
void PrettyPrinter::VisitModuleUrl(ModuleUrl* node) { Print("at "); PrintLiteral(node->url(), true); }
void PrettyPrinter::VisitModulePath(ModulePath* node) { Visit(node->module()); Print("."); PrintLiteral(node->name(), false); }
void PrettyPrinter::VisitExportDeclaration(ExportDeclaration* node) { Print("export "); PrintLiteral(node->proxy()->name(), false); Print(";"); }
void PrettyPrinter::VisitFunctionBoilerplateLiteral( FunctionBoilerplateLiteral* node) { Print("("); PrintLiteral(node->boilerplate(), true); Print(")"); }