]> git.saurik.com Git - cycript.git/blobdiff - Output.cpp
Factored out the execution engine from the compiler.
[cycript.git] / Output.cpp
index 9ffc4f67037e790067db5ce971bd00d503f0eb94..04f893c9299d74671fb812a04a1975ed40ee2980 100644 (file)
@@ -85,14 +85,24 @@ CYOutput &CYOutput::operator <<(char rhs) {
             for (unsigned i(0); i != indent_; ++i)
                 out_ << "    ";
         else goto done;
-    else goto work;
+    else if (rhs == '\r') {
+        if (right_) {
+            out_ << '\n';
+            right_ = false;
+            goto mode;
+        }
+    } else goto work;
 
+    right_ = true;
+  mode:
     mode_ = NoMode;
     goto done;
 
   work:
-    if (mode_ == Terminated && rhs != '}')
+    if (mode_ == Terminated && rhs != '}') {
+        right_ = true;
         out_ << ';';
+    }
 
     if (rhs == ';') {
         if (pretty_)
@@ -116,6 +126,7 @@ CYOutput &CYOutput::operator <<(char rhs) {
     } else none:
         mode_ = NoMode;
 
+    right_ = true;
     out_ << rhs;
   done:
     return *this;
@@ -141,6 +152,7 @@ CYOutput &CYOutput::operator <<(const char *rhs) {
     else
         mode_ = NoMode;
 
+    right_ = true;
     out_ << rhs;
     return *this;
 }
@@ -222,6 +234,12 @@ void Catch::Output(CYOutput &out) const {
 
 } }
 
+void CYComment::Output(CYOutput &out, CYFlags flags) const {
+    out << '\r';
+    out << value_;
+    out << '\r';
+}
+
 void CYCompound::Output(CYOutput &out, CYFlags flags) const {
     if (CYExpression *expression = expressions_)
         if (CYExpression *next = expression->next_) {