-/* 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 {{{ */
test_->Output(out, Precedence() - 1, CYLeft(flags));
out << ' ' << '?' << ' ';
if (true_ != NULL)
- true_->Output(out, CYAssign::Precedence_, CYNoFlags);
+ true_->Output(out, CYAssign::Precedence_, CYNoColon);
out << ' ' << ':' << ' ';
false_->Output(out, CYAssign::Precedence_, CYRight(flags));
}
void CYClause::Output(CYOutput &out) const {
out << '\t';
- if (value_ != NULL)
- out << "case" << ' ' << *value_;
- else
+ if (value_ == NULL)
out << "default";
+ else {
+ out << "case" << ' ';
+ value_->Output(out, CYNoColon);
+ }
out << ':' << '\n';
++out.indent_;
out << code_;
Output(out, flags);
}
-void CYExternal::Output(CYOutput &out, CYFlags flags) const {
- out << "extern" << abi_ << typed_;
+void CYExtend::Output(CYOutput &out, CYFlags flags) const {
+ lhs_->Output(out, CYLeft(flags));
+ out << ' ' << object_;
+}
+
+void CYExternalDefinition::Output(CYOutput &out, CYFlags flags) const {
+ out << "extern" << ' ' << abi_ << ' ' << typed_;
out.Terminate();
}
+void CYExternalExpression::Output(CYOutput &out, CYFlags flags) const {
+ out << '(' << "extern" << ' ' << abi_ << ' ' << typed_ << ')';
+}
+
void CYFatArrow::Output(CYOutput &out, CYFlags flags) const {
out << '(' << parameters_ << ')' << ' ' << "=>" << ' ' << '{' << code_ << '}';
}
}
void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const {
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, false);
out << '[';
out << size_;
out << ']';
void CYTypeBlockWith::Output(CYOutput &out, CYIdentifier *identifier) const {
out << '(' << '^';
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, false);
out << ')' << '(' << parameters_ << ')';
}
void CYTypeConstant::Output(CYOutput &out, CYIdentifier *identifier) const {
- out << "const" << ' ';
- next_->Output(out, Precedence(), identifier);
+ out << "const";
+ next_->Output(out, Precedence(), identifier, false);
}
void CYTypeFunctionWith::Output(CYOutput &out, CYIdentifier *identifier) const {
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, false);
out << '(' << parameters_;
if (variadic_) {
if (parameters_ != NULL)
void CYTypePointerTo::Output(CYOutput &out, CYIdentifier *identifier) const {
out << '*';
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, false);
}
void CYTypeVolatile::Output(CYOutput &out, CYIdentifier *identifier) const {
out << "volatile";
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, true);
}
-void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identifier) const {
+void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identifier, bool space) const {
+ if (this == NULL && identifier == NULL)
+ return;
+ else if (space)
+ out << ' ';
+
if (this == NULL) {
out << identifier;
return;
void CYTypedIdentifier::Output(CYOutput &out) const {
specifier_->Output(out);
- modifier_->Output(out, 0, identifier_);
+ modifier_->Output(out, 0, identifier_, true);
}
void CYEncodedType::Output(CYOutput &out, CYFlags flags) const {
out << Value();
}
+void CYResolveMember::Output(CYOutput &out, CYFlags flags) const {
+ object_->Output(out, Precedence(), CYLeft(flags));
+ if (const char *word = property_->Word())
+ out << "::" << word;
+ else
+ out << "::" << '[' << *property_ << ']';
+}
+
void CYReturn::Output(CYOutput &out, CYFlags flags) const {
out << "return";
if (value_ != NULL)
}
void CYRubyBlock::Output(CYOutput &out, CYFlags flags) const {
- call_->Output(out, CYLeft(flags));
+ lhs_->Output(out, CYLeft(flags));
out << ' ';
proc_->Output(out, CYRight(flags));
}
out << '\t' << '}';
}
+void CYSubscriptMember::Output(CYOutput &out, CYFlags flags) const {
+ object_->Output(out, Precedence(), CYLeft(flags));
+ out << "." << '[' << *property_ << ']';
+}
+
void CYStatement::Multiple(CYOutput &out, CYFlags flags) const {
bool first(true);
CYForEach (next, this) {
out << '\n';
}
--out.indent_;
- out << '}';
+ out << '\t' << '}';
}
void CYSuperAccess::Output(CYOutput &out, CYFlags flags) const {
out << '\t' << '}';
}
+void CYSymbol::Output(CYOutput &out, CYFlags flags) const {
+ bool protect((flags & CYNoColon) != 0);
+ if (protect)
+ out << '(';
+ out << ':' << name_;
+ if (protect)
+ out << ')';
+}
+
void CYThis::Output(CYOutput &out, CYFlags flags) const {
out << "this";
}