-/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2015 Jay Freeman (saurik)
+/* Cycript - The Truly Universal Scripting Language
+ * Copyright (C) 2009-2016 Jay Freeman (saurik)
*/
/* GNU Affero General Public License, Version 3 {{{ */
}
void CYImplementationField::Output(CYOutput &out) const {
+ type_->Output(out, name_);
+ out.Terminate();
+ out << '\n';
}
void CYInstanceLiteral::Output(CYOutput &out, CYFlags flags) const {
CYForEach (parameter, parameters_)
if (parameter->name_ != NULL) {
out << ' ' << *parameter->name_;
- if (parameter->type_ != NULL)
- out << ':' << *parameter->type_->identifier_;
+ // XXX: this is off somehow
+ if (parameter->identifier_ != NULL) {
+ out << ':';
+ if (parameter->type_ != NULL)
+ out << '(' << *parameter->type_ << ')';
+ out << *parameter->identifier_;
+ }
}
out << code_;
value_->Output(out, Precedence(), CYRight(flags));
}
+void CYObjCArray::Output(CYOutput &out, CYFlags flags) const {
+ out << '@' << '[' << elements_ << ']';
+}
+
+void CYObjCDictionary::Output(CYOutput &out, CYFlags flags) const {
+ unsigned count(0);
+ CYForEach (pair, pairs_)
+ ++count;
+ bool large(count > 8);
+
+ out << '@' << '{';
+ if (large) {
+ out << '\n';
+ ++out.indent_;
+ }
+
+ bool comma(false);
+ CYForEach (pair, pairs_) {
+ if (!comma)
+ comma = true;
+ else {
+ out << ',';
+ if (large)
+ out << '\n';
+ else
+ out << ' ';
+ }
+
+ if (large)
+ out << '\t';
+
+ pair->key_->Output(out, CYAssign::Precedence_, CYNoFlags);
+ out << ':' << ' ';
+ pair->value_->Output(out, CYAssign::Precedence_, CYNoFlags);
+ }
+
+ if (large && out.pretty_)
+ out << ',';
+
+ if (large) {
+ out << '\n';
+ --out.indent_;
+ }
+
+ out << '\t' << '}';
+}
+
void CYObjCBlock::Output(CYOutput &out, CYFlags flags) const {
- // XXX: this is seriously wrong
- out << "^(";
- out << ")";
- out << "{";
- out << "}";
+ out << '^' << ' ' << *typed_ << ' ' << '(';
+
+ bool comma(false);
+ CYForEach (parameter, parameters_) {
+ if (comma)
+ out << ',' << ' ';
+ else
+ comma = true;
+ parameter->type_->Output(out, parameter->name_);
+ }
+
+ out << ')' << ' ' << '{' << '\n';
+ ++out.indent_;
+ out << code_;
+ --out.indent_;
+ out << '\t' << '}';
}
void CYProtocol::Output(CYOutput &out) const {