-void CYIf::Output(std::ostream &out) const {
- out << "if(";
- test_->Output(out, CYNoFlags);
- out << ')';
- true_->Output(out, true);
+void CYForInComprehension::Output(CYOutput &out) const {
+ out << "for" << ' ' << '(' << *name_ << ' ' << "in" << ' ' << *set_ << ')';
+}
+
+void CYFunction::Output(CYOutput &out, CYFlags flags) const {
+ // XXX: one could imagine using + here to save a byte
+ bool protect((flags & CYNoFunction) != 0);
+ if (protect)
+ out << '(';
+ out << "function";
+ if (name_ != NULL)
+ out << ' ' << *name_;
+ out << '(' << parameters_ << ')';
+ out << ' ' << code_;
+ if (protect)
+ out << ')';
+}
+
+void CYFunctionExpression::Output(CYOutput &out, CYFlags flags) const {
+ CYFunction::Output(out, flags);
+}
+
+void CYFunctionStatement::Output(CYOutput &out, CYFlags flags) const {
+ CYFunction::Output(out, flags);
+}
+
+void CYFunctionParameter::Output(CYOutput &out) const {
+ initialiser_->Output(out, CYNoFlags);
+ if (next_ != NULL)
+ out << ',' << ' ' << *next_;
+}
+
+const char *CYIdentifier::Word() const {
+ return replace_ == NULL || replace_ == this ? CYWord::Word() : replace_->Word();
+}
+
+void CYIf::Output(CYOutput &out, CYFlags flags) const {
+ bool protect(false);
+ if (false_ == NULL && (flags & CYNoDangle) != 0) {
+ protect = true;
+ out << '{';
+ }
+
+ out << "if" << ' ' << '(' << *test_ << ')';
+
+ CYFlags right(protect ? CYNoFlags : CYRight(flags));
+
+ CYFlags jacks(CYNoDangle);
+ if (false_ == NULL)
+ jacks |= right;
+ else
+ jacks |= protect ? CYNoFlags : CYCenter(flags);
+
+ true_->Single(out, jacks);
+