X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/6009702382b8710a9abf6fd62c1f30e991d6986e..b120443db34edddcdb016b2f9218355b2dd8ced6:/Output.cpp diff --git a/Output.cpp b/Output.cpp index 3bf157f..3794c49 100644 --- a/Output.cpp +++ b/Output.cpp @@ -118,8 +118,7 @@ void CYArgument::Output(CYOutput &out) const { if (value_ != NULL) value_->Output(out, CYAssign::Precedence_, CYNoFlags); if (next_ != NULL) { - if (next_->name_ == NULL) - out << ','; + out << ','; out << ' ' << *next_; } } @@ -194,19 +193,13 @@ void CYComment::Output(CYOutput &out, CYFlags flags) const { } void CYCompound::Output(CYOutput &out, CYFlags flags) const { - if (CYExpression *expression = expressions_) - if (CYExpression *next = expression->next_) { - expression->Output(out, CYLeft(flags)); - CYFlags center(CYCenter(flags)); - while (next != NULL) { - expression = next; - out << ',' << ' '; - next = expression->next_; - CYFlags right(next != NULL ? center : CYRight(flags)); - expression->Output(out, right); - } - } else - expression->Output(out, flags); + if (next_ == NULL) + expression_->Output(out, flags); + else { + expression_->Output(out, CYLeft(flags)); + out << ',' << ' '; + next_->Output(out, CYRight(flags)); + } } void CYCondition::Output(CYOutput &out, CYFlags flags) const { @@ -329,7 +322,7 @@ void CYExpression::Output(CYOutput &out) const { Output(out, CYNoFlags); } -void CYExpression::Output(CYOutput &out, unsigned precedence, CYFlags flags) const { +void CYExpression::Output(CYOutput &out, int precedence, CYFlags flags) const { if (precedence < Precedence() || (flags & CYNoRightHand) != 0 && RightHand()) out << '(' << *this << ')'; else @@ -474,9 +467,67 @@ void CYLabel::Output(CYOutput &out, CYFlags flags) const { statement_->Single(out, CYRight(flags)); } +void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const { + next_->Output(out, Precedence(), identifier); + out << '['; + out << size_; + out << ']'; +} + +void CYTypeBlockWith::Output(CYOutput &out, CYIdentifier *identifier) const { + out << '(' << '^'; + next_->Output(out, Precedence(), identifier); + out << ')' << '(' << parameters_ << ')'; +} + +void CYTypeConstant::Output(CYOutput &out, CYIdentifier *identifier) const { + out << "const"; + next_->Output(out, Precedence(), identifier); +} + +void CYTypeFunctionWith::Output(CYOutput &out, CYIdentifier *identifier) const { + next_->Output(out, Precedence(), identifier); + out << '(' << parameters_ << ')'; +} + +void CYTypePointerTo::Output(CYOutput &out, CYIdentifier *identifier) const { + out << '*'; + next_->Output(out, Precedence(), identifier); +} + +void CYTypeVolatile::Output(CYOutput &out, CYIdentifier *identifier) const { + out << "volatile"; + next_->Output(out, Precedence(), identifier); +} + +void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identifier) const { + if (this == NULL) { + out << identifier; + return; + } + + bool protect(precedence > Precedence()); + + if (protect) + out << '('; + Output(out, identifier); + if (protect) + out << ')'; +} + void CYTypedIdentifier::Output(CYOutput &out) const { - // XXX: this is clearly wrong - out << "XXX"; + specifier_->Output(out); + modifier_->Output(out, 0, identifier_); +} + +void CYEncodedType::Output(CYOutput &out, CYFlags flags) const { + out << "@encode(" << typed_ << ")"; +} + +void CYTypedParameter::Output(CYOutput &out) const { + out << typed_; + if (next_ != NULL) + out << ',' << ' ' << next_; } void CYLambda::Output(CYOutput &out, CYFlags flags) const { @@ -690,6 +741,34 @@ void Try::Output(CYOutput &out, CYFlags flags) const { } } +void CYTypeError::Output(CYOutput &out) const { + out << "@error"; +} + +void CYTypeLong::Output(CYOutput &out) const { + out << "long" << specifier_; +} + +void CYTypeShort::Output(CYOutput &out) const { + out << "short" << specifier_; +} + +void CYTypeSigned::Output(CYOutput &out) const { + out << "signed" << specifier_; +} + +void CYTypeUnsigned::Output(CYOutput &out) const { + out << "unsigned" << specifier_; +} + +void CYTypeVariable::Output(CYOutput &out) const { + out << *name_; +} + +void CYTypeVoid::Output(CYOutput &out) const { + out << "void"; +} + void CYVar::Output(CYOutput &out, CYFlags flags) const { out << "var"; declarations_->Output(out, flags);