-/* 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 {{{ */
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_ << ' ';
+ type_->Output(out, name_);
out.Terminate();
}
+void CYExternalExpression::Output(CYOutput &out, CYFlags flags) const {
+ out << '(' << "extern" << ' ' << abi_ << ' ';
+ type_->Output(out, name_);
+ out << ')';
+}
+
void CYFatArrow::Output(CYOutput &out, CYFlags flags) const {
out << '(' << parameters_ << ')' << ' ' << "=>" << ' ' << '{' << code_ << '}';
}
_assert(false);
}
-void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const {
- next_->Output(out, Precedence(), identifier);
+void CYTypeArrayOf::Output(CYOutput &out, CYPropertyName *name) const {
+ next_->Output(out, Precedence(), name, false);
out << '[';
out << size_;
out << ']';
}
-void CYTypeBlockWith::Output(CYOutput &out, CYIdentifier *identifier) const {
+void CYTypeBlockWith::Output(CYOutput &out, CYPropertyName *name) const {
out << '(' << '^';
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), name, false);
out << ')' << '(' << parameters_ << ')';
}
-void CYTypeConstant::Output(CYOutput &out, CYIdentifier *identifier) const {
- out << "const" << ' ';
- next_->Output(out, Precedence(), identifier);
+void CYTypeConstant::Output(CYOutput &out, CYPropertyName *name) const {
+ out << "const";
+ next_->Output(out, Precedence(), name, false);
}
-void CYTypeFunctionWith::Output(CYOutput &out, CYIdentifier *identifier) const {
- next_->Output(out, Precedence(), identifier);
+void CYTypeFunctionWith::Output(CYOutput &out, CYPropertyName *name) const {
+ next_->Output(out, Precedence(), name, false);
out << '(' << parameters_;
if (variadic_) {
if (parameters_ != NULL)
out << ')';
}
-void CYTypePointerTo::Output(CYOutput &out, CYIdentifier *identifier) const {
+void CYTypePointerTo::Output(CYOutput &out, CYPropertyName *name) const {
out << '*';
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), name, false);
}
-void CYTypeVolatile::Output(CYOutput &out, CYIdentifier *identifier) const {
+void CYTypeVolatile::Output(CYOutput &out, CYPropertyName *name) const {
out << "volatile";
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), name, true);
}
-void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identifier) const {
+void CYTypeModifier::Output(CYOutput &out, int precedence, CYPropertyName *name, bool space) const {
+ if (this == NULL && name == NULL)
+ return;
+ else if (space)
+ out << ' ';
+
if (this == NULL) {
- out << identifier;
+ name->PropertyName(out);
return;
}
if (protect)
out << '(';
- Output(out, identifier);
+ Output(out, name);
if (protect)
out << ')';
}
-void CYTypedIdentifier::Output(CYOutput &out) const {
- specifier_->Output(out);
- modifier_->Output(out, 0, identifier_);
+void CYType::Output(CYOutput &out, CYPropertyName *name) const {
+ out << *specifier_;
+ modifier_->Output(out, 0, name, true);
+}
+
+void CYType::Output(CYOutput &out) const {
+ Output(out, NULL);
}
void CYEncodedType::Output(CYOutput &out, CYFlags flags) const {
}
void CYTypedParameter::Output(CYOutput &out) const {
- out << typed_;
+ type_->Output(out, name_);
if (next_ != NULL)
out << ',' << ' ' << next_;
}
}
void CYTypeDefinition::Output(CYOutput &out, CYFlags flags) const {
- out << "typedef" << ' ' << *typed_;
+ out << "typedef" << ' ';
+ type_->Output(out, name_);
out.Terminate();
}
}
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_;
CYForEach (field, fields_) {
- out << '\t' << *field->typed_;
+ out << '\t';
+ field->type_->Output(out, field->name_);
out.Terminate();
out << '\n';
}
--out.indent_;
- out << '}';
+ out << '\t' << '}';
}
void CYSuperAccess::Output(CYOutput &out, CYFlags flags) const {
out << "char";
}
+void CYTypeEnum::Output(CYOutput &out) const {
+ out << "enum" << ' ';
+ if (name_ != NULL)
+ out << *name_;
+ else {
+ if (specifier_ != NULL)
+ out << ':' << ' ' << *specifier_ << ' ';
+
+ out << '{' << '\n';
+ ++out.indent_;
+ bool comma(false);
+
+ CYForEach (constant, constants_) {
+ if (comma)
+ out << ',' << '\n';
+ else
+ comma = true;
+ out << '\t' << constant->name_;
+ out << ' ' << '=' << ' ' << constant->value_;
+ }
+
+ if (out.pretty_)
+ out << ',';
+ out << '\n';
+ --out.indent_;
+ out << '\t' << '}';
+ }
+}
+
void CYTypeError::Output(CYOutput &out) const {
out << "@error";
}
+void CYTypeInt128::Output(CYOutput &out) const {
+ switch (signing_) {
+ case CYTypeNeutral: break;
+ case CYTypeSigned: out << "signed" << ' '; break;
+ case CYTypeUnsigned: out << "unsigned" << ' '; break;
+ }
+
+ out << "__int128";
+}
+
void CYTypeIntegral::Output(CYOutput &out) const {
if (signing_ == CYTypeUnsigned)
out << "unsigned" << ' ';
}
void CYTypeReference::Output(CYOutput &out) const {
- out << "struct" << ' ' << *name_;
+ switch (kind_) {
+ case CYTypeReferenceStruct: out << "struct"; break;
+ case CYTypeReferenceEnum: out << "enum"; break;
+ default: _assert(false);
+ }
+
+ out << ' ' << *name_;
}
void CYTypeVariable::Output(CYOutput &out) const {