/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2013 Jay Freeman (saurik)
+ * Copyright (C) 2009-2015 Jay Freeman (saurik)
*/
-/* GNU General Public License, Version 3 {{{ */
+/* GNU Affero General Public License, Version 3 {{{ */
/*
- * Cycript is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, either version 3 of the License,
- * or (at your option) any later version.
- *
- * Cycript is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
/* }}} */
rhs_->Output(out, Precedence(), CYRight(flags));
}
-void CYBlock::Output(CYOutput &out) const {
+void CYBlock::Output(CYOutput &out, CYFlags flags) const {
out << '{' << '\n';
++out.indent_;
- if (statements_ != NULL)
- statements_->Multiple(out);
+ out << code_;
--out.indent_;
out << '\t' << '}';
}
-void CYBlock::Output(CYOutput &out, CYFlags flags) const {
- if (statements_ == NULL)
- out.Terminate();
- else if (statements_->next_ == NULL)
- statements_->Single(out, flags);
- else
- Output(out);
-}
-
void CYBoolean::Output(CYOutput &out, CYFlags flags) const {
out << (Value() ? "true" : "false");
}
namespace Syntax {
void Catch::Output(CYOutput &out) const {
- out << ' ' << "catch" << ' ' << '(' << *name_ << ')' << ' ' << code_;
+ out << ' ' << "catch" << ' ' << '(' << *name_ << ')' << ' ';
+ out << '{' << '\n';
+ ++out.indent_;
+ out << code_;
+ --out.indent_;
+ out << '\t' << '}';
}
} }
else
out << "default";
out << ':' << '\n';
- if (statements_ != NULL)
- statements_->Multiple(out);
+ out << code_;
out << next_;
}
void CYForDeclarations::Output(CYOutput &out, CYFlags flags) const {
out << "var";
- Output(out, CYRight(flags));
+ declarations_->Output(out, CYRight(flags));
}
void CYDeclarations::Output(CYOutput &out) const {
Output(out, flags);
}
+void CYExternal::Output(CYOutput &out, CYFlags flags) const {
+ out << "extern" << abi_ << typed_ << ';';
+}
+
void CYFatArrow::Output(CYOutput &out, CYFlags flags) const {
- out << '(' << parameters_ << ')' << ' ' << "=>" << ' ' << code_;
+ out << '(' << parameters_ << ')' << ' ' << "=>" << ' ' << '{' << code_ << '}';
}
void CYFinally::Output(CYOutput &out) const {
- out << ' ' << "finally" << ' ' << code_;
+ out << ' ' << "finally" << ' ';
+ out << '{' << '\n';
+ ++out.indent_;
+ out << code_;
+ --out.indent_;
+ out << '\t' << '}';
}
void CYFor::Output(CYOutput &out, CYFlags flags) const {
out << "function";
if (name_ != NULL)
out << ' ' << *name_;
- out << '(' << parameters_ << ')';
- out << ' ' << code_;
+ out << '(' << parameters_ << ')' << ' ';
+ out << '{' << '\n';
+ ++out.indent_;
+ out << code_;
+ --out.indent_;
+ out << '\t' << '}';
if (protect)
out << ')';
}
out << "if" << ' ' << '(' << *test_ << ')' << next_;
}
+void CYImport::Output(CYOutput &out, CYFlags flags) const {
+ out << "@import";
+}
+
void CYIndirectMember::Output(CYOutput &out, CYFlags flags) const {
object_->Output(out, Precedence(), CYLeft(flags));
if (const char *word = property_->Word())
statement_->Single(out, CYRight(flags));
}
+void CYParenthetical::Output(CYOutput &out, CYFlags flags) const {
+ out << '(';
+ expression_->Output(out, CYCompound::Precedence_, CYNoFlags);
+ out << ')';
+}
+
+void CYStatement::Output(CYOutput &out) const {
+ Multiple(out);
+}
+
void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const {
next_->Output(out, Precedence(), identifier);
out << '[';
code_->Single(out, CYRight(flags));
}
+void CYModule::Output(CYOutput &out) const {
+ out << part_;
+ if (next_ != NULL)
+ out << '.' << next_;
+}
+
namespace cy {
namespace Syntax {
}
void CYProgram::Output(CYOutput &out) const {
- if (statements_ != NULL)
- statements_->Multiple(out);
+ out << code_;
}
void CYProperty::Output(CYOutput &out) const {
void CYRubyProc::Output(CYOutput &out, CYFlags flags) const {
// XXX: this is not outputting the parameters
+ out << '{' << '\n';
+ ++out.indent_;
out << code_;
+ --out.indent_;
+ out << '\t' << '}';
}
void CYStatement::Multiple(CYOutput &out, CYFlags flags) const {
}
void Try::Output(CYOutput &out, CYFlags flags) const {
- out << "try" << ' ' << code_ << catch_ << finally_;
+ out << "try" << ' ';
+ out << '{' << '\n';
+ ++out.indent_;
+ out << code_;
+ --out.indent_;
+ out << '\t' << '}';
+ out << catch_ << finally_;
}
} }