X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/7341eedbaf526ef2f0986b576c656906050e270a..95be164556de14834c2040ac7bea1632b63e5764:/Output.cpp diff --git a/Output.cpp b/Output.cpp index dc1f7f9..1552304 100644 --- a/Output.cpp +++ b/Output.cpp @@ -457,11 +457,15 @@ void CYExtend::Output(CYOutput &out, CYFlags flags) const { out << ' ' << object_; } -void CYExternal::Output(CYOutput &out, CYFlags flags) const { - out << "extern" << abi_ << typed_; +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_ << '}'; } @@ -665,7 +669,7 @@ void CYTemplate::Output(CYOutput &out, CYFlags flags) const { } void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const { - next_->Output(out, Precedence(), identifier); + next_->Output(out, Precedence(), identifier, false); out << '['; out << size_; out << ']'; @@ -673,17 +677,17 @@ void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const { 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) @@ -695,15 +699,20 @@ void CYTypeFunctionWith::Output(CYOutput &out, CYIdentifier *identifier) const { 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; @@ -719,8 +728,8 @@ void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identif } void CYTypedIdentifier::Output(CYOutput &out) const { - specifier_->Output(out); - modifier_->Output(out, 0, identifier_); + out << *specifier_; + modifier_->Output(out, 0, identifier_, true); } void CYEncodedType::Output(CYOutput &out, CYFlags flags) const { @@ -990,7 +999,7 @@ void CYStructTail::Output(CYOutput &out) const { out << '\n'; } --out.indent_; - out << '}'; + out << '\t' << '}'; } void CYSuperAccess::Output(CYOutput &out, CYFlags flags) const { @@ -1058,10 +1067,49 @@ void CYTypeCharacter::Output(CYOutput &out) 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" << ' '; @@ -1083,7 +1131,13 @@ void CYTypeStruct::Output(CYOutput &out) const { } 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 {