]> git.saurik.com Git - cycript.git/blobdiff - Output.cpp
Do not convert exceptions to CYON before display.
[cycript.git] / Output.cpp
index d5d403c30118dba1cd765ff7d1661d8c89e387cc..c97474451d17285acdcd36743577828de96a2453 100644 (file)
 
 #include <sstream>
 
-_finline CYFlags operator ~(CYFlags rhs) {
-    return static_cast<CYFlags>(~static_cast<unsigned>(rhs));
-}
-
-_finline CYFlags operator &(CYFlags lhs, CYFlags rhs) {
-    return static_cast<CYFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs));
-}
-
-_finline CYFlags operator |(CYFlags lhs, CYFlags rhs) {
-    return static_cast<CYFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
-}
-
-_finline CYFlags &operator |=(CYFlags &lhs, CYFlags rhs) {
-    return lhs = lhs | rhs;
-}
-
-_finline CYFlags CYLeft(CYFlags flags) {
-    return flags & ~(CYNoDangle | CYNoInteger);
-}
-
-_finline CYFlags CYRight(CYFlags flags) {
-    return flags & ~CYNoBF;
-}
-
-_finline CYFlags CYCenter(CYFlags flags) {
-    return CYLeft(CYRight(flags));
-}
-
 void CYOutput::Terminate() {
     out_ << ';';
     mode_ = NoMode;
@@ -144,7 +116,7 @@ void CYArgument::Output(CYOutput &out) const {
             out << ':' << ' ';
     }
     if (value_ != NULL)
-        value_->Output(out, CYPA, CYNoFlags);
+        value_->Output(out, CYAssign::Precedence_, CYNoFlags);
     if (next_ != NULL) {
         if (next_->name_ == NULL)
             out << ',';
@@ -241,9 +213,9 @@ void CYCondition::Output(CYOutput &out, CYFlags flags) const {
     test_->Output(out, Precedence() - 1, CYLeft(flags));
     out << ' ' << '?' << ' ';
     if (true_ != NULL)
-        true_->Output(out, CYPA, CYNoFlags);
+        true_->Output(out, CYAssign::Precedence_, CYNoFlags);
     out << ' ' << ':' << ' ';
-    false_->Output(out, CYPA, CYRight(flags));
+    false_->Output(out, CYAssign::Precedence_, CYRight(flags));
 }
 
 void CYContinue::Output(CYOutput &out, CYFlags flags) const {
@@ -278,7 +250,7 @@ void CYDeclaration::Output(CYOutput &out, CYFlags flags) const {
     //out.out_ << ':' << identifier_->usage_ << '#' << identifier_->offset_;
     if (initialiser_ != NULL) {
         out << ' ' << '=' << ' ';
-        initialiser_->Output(out, CYPA, CYRight(flags));
+        initialiser_->Output(out, CYAssign::Precedence_, CYRight(flags));
     }
 }
 
@@ -323,7 +295,7 @@ void CYDoWhile::Output(CYOutput &out, CYFlags flags) const {
 
 void CYElement::Output(CYOutput &out) const {
     if (value_ != NULL)
-        value_->Output(out, CYPA, CYNoFlags);
+        value_->Output(out, CYAssign::Precedence_, CYNoFlags);
     if (next_ != NULL || value_ == NULL) {
         out << ',';
         if (next_ != NULL && next_->value_ != NULL)
@@ -343,7 +315,7 @@ void CYExpress::Output(CYOutput &out, CYFlags flags) const {
 }
 
 void CYExpression::ClassName(CYOutput &out, bool object) const {
-    Output(out, CYPA, CYNoFlags);
+    Output(out, CYAssign::Precedence_, CYNoFlags);
 }
 
 const char *CYExpression::ForEachIn() const {
@@ -378,8 +350,12 @@ void CYFor::Output(CYOutput &out, CYFlags flags) const {
     if (initialiser_ != NULL)
         initialiser_->For(out);
     out.Terminate();
+    if (test_ != NULL)
+        out << ' ';
     out << test_;
     out.Terminate();
+    if (increment_ != NULL)
+        out << ' ';
     out << increment_;
     out << ')';
     code_->Single(out, CYRight(flags));
@@ -460,7 +436,7 @@ void CYIf::Output(CYOutput &out, CYFlags flags) const {
     true_->Single(out, jacks);
 
     if (false_ != NULL) {
-        out << "else";
+        out << '\t' << "else";
         false_->Single(out, right);
     }
 
@@ -549,7 +525,7 @@ void CYObject::Output(CYOutput &out, CYFlags flags) const {
 
 void CYOptionalFunctionParameter::Output(CYOutput &out) const {
     out << *name_ << '=';
-    initializer_->Output(out, CYPA, CYNoFlags);
+    initializer_->Output(out, CYAssign::Precedence_, CYNoFlags);
     if (next_ != NULL)
         out << ',' << ' ' << *next_;
 }
@@ -576,7 +552,7 @@ void CYProperty::Output(CYOutput &out) const {
     out << '\t';
     name_->PropertyName(out);
     out << ':' << ' ';
-    value_->Output(out, CYPA, CYNoFlags);
+    value_->Output(out, CYAssign::Precedence_, CYNoFlags);
     if (next_ != NULL)
         out << ',' << '\n' << *next_;
     else
@@ -607,7 +583,7 @@ void CYRubyProc::Output(CYOutput &out, CYFlags flags) const {
 
 void CYStatement::Multiple(CYOutput &out, CYFlags flags) const {
     bool first(true);
-    for (const CYStatement *next(this); next != NULL; next = next->next_) {
+    CYForEach (next, this) {
         bool last(next->next_ == NULL);
         CYFlags jacks(first ? last ? flags : CYLeft(flags) : last ? CYRight(flags) : CYCenter(flags));
         first = false;