X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/15b88a33189cbd3da91900194d8e5c81252f8a4d..3f9ae37cb15f239389eeba110b3a7da0280a8381:/Output.cpp?ds=inline diff --git a/Output.cpp b/Output.cpp index cd04e2e..1feff42 100644 --- a/Output.cpp +++ b/Output.cpp @@ -1,5 +1,5 @@ /* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2010 Jay Freeman (saurik) + * Copyright (C) 2009-2012 Jay Freeman (saurik) */ /* GNU Lesser General Public License, Version 3 {{{ */ @@ -236,6 +236,10 @@ void CYClause::Output(CYOutput &out) const { out << next_; } +void CYDebugger::Output(CYOutput &out, CYFlags flags) const { + out << "debugger" << ';'; +} + void CYDeclaration::ForIn(CYOutput &out, CYFlags flags) const { out << "var"; Output(out, CYRight(flags)); @@ -262,16 +266,19 @@ void CYDeclarations::Output(CYOutput &out) const { void CYDeclarations::Output(CYOutput &out, CYFlags flags) const { const CYDeclarations *declaration(this); bool first(true); - output: - CYDeclarations *next(declaration->next_); - CYFlags jacks(first ? CYLeft(flags) : next == NULL ? CYRight(flags) : CYCenter(flags)); - first = false; - declaration->declaration_->Output(out, jacks); - if (next != NULL) { + for (;;) { + CYDeclarations *next(declaration->next_); + + CYFlags jacks(first ? CYLeft(flags) : next == NULL ? CYRight(flags) : CYCenter(flags)); + first = false; + declaration->declaration_->Output(out, jacks); + + if (next == NULL) + break; + out << ',' << ' '; declaration = next; - goto output; } } @@ -329,6 +336,10 @@ void CYExpression::Output(CYOutput &out, unsigned precedence, CYFlags flags) con Output(out, flags); } +void CYFatArrow::Output(CYOutput &out, CYFlags flags) const { + out << '(' << parameters_ << ')' << ' ' << "=>" << ' ' << code_; +} + void CYFinally::Output(CYOutput &out) const { out << ' ' << "finally" << ' ' << code_; } @@ -349,14 +360,14 @@ void CYFor::Output(CYOutput &out, CYFlags flags) const { code_->Single(out, CYRight(flags)); } -void CYForEachIn::Output(CYOutput &out, CYFlags flags) const { +void CYForOf::Output(CYOutput &out, CYFlags flags) const { out << "for" << ' ' << "each" << ' ' << '('; initialiser_->ForIn(out, CYNoIn); out << "in" << *set_ << ')'; code_->Single(out, CYRight(flags)); } -void CYForEachInComprehension::Output(CYOutput &out) const { +void CYForOfComprehension::Output(CYOutput &out) const { out << "for" << ' ' << "each" << ' ' << '(' << *name_ << ' ' << "in" << ' ' << *set_ << ')' << next_; } @@ -395,7 +406,7 @@ void CYFunctionStatement::Output(CYOutput &out, CYFlags flags) const { } void CYFunctionParameter::Output(CYOutput &out) const { - out << *name_; + initialiser_->Output(out, CYNoFlags); if (next_ != NULL) out << ',' << ' ' << *next_; } @@ -463,7 +474,7 @@ void CYLabel::Output(CYOutput &out, CYFlags flags) const { statement_->Single(out, CYRight(flags)); } -void CYLet::Output(CYOutput &out, CYFlags flags) const { +void CYLetStatement::Output(CYOutput &out, CYFlags flags) const { out << "let" << ' ' << '(' << *declarations_ << ')'; code_->Single(out, CYRight(flags)); } @@ -512,13 +523,6 @@ void CYObject::Output(CYOutput &out, CYFlags flags) const { out << ')'; } -void CYOptionalFunctionParameter::Output(CYOutput &out) const { - out << *name_ << '='; - initializer_->Output(out, CYAssign::Precedence_, CYNoFlags); - if (next_ != NULL) - out << ',' << ' ' << *next_; -} - void CYPostfix::Output(CYOutput &out, CYFlags flags) const { lhs_->Output(out, Precedence(), CYLeft(flags)); out << Operator(); @@ -583,6 +587,9 @@ void CYStatement::Multiple(CYOutput &out, CYFlags flags) const { } void CYStatement::Single(CYOutput &out, CYFlags flags) const { + if (this == NULL) + return out.Terminate(); + _assert(next_ == NULL); out << '\n'; ++out.indent_;