]> git.saurik.com Git - cycript.git/blobdiff - ObjectiveC/Output.cpp
Use class extension syntax as part of Object CYON.
[cycript.git] / ObjectiveC / Output.cpp
index 76838d8815431189cd9922a5a80e80dd69986dbd..17a426491aed7d4addfe23cd879636408f9eeddf 100644 (file)
@@ -1,5 +1,5 @@
-/* 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 {{{ */
@@ -49,6 +49,9 @@ void CYImplementation::Output(CYOutput &out, CYFlags flags) const {
 }
 
 void CYImplementationField::Output(CYOutput &out) const {
+    out << *typed_;
+    out.Terminate();
+    out << '\n';
 }
 
 void CYInstanceLiteral::Output(CYOutput &out, CYFlags flags) const {
@@ -60,8 +63,8 @@ void CYMessage::Output(CYOutput &out) const {
     out << (instance_ ? '-' : '+');
 
     CYForEach (parameter, parameters_)
-        if (parameter->tag_ != NULL) {
-            out << ' ' << *parameter->tag_;
+        if (parameter->name_ != NULL) {
+            out << ' ' << *parameter->name_;
             if (parameter->type_ != NULL)
                 out << ':' << *parameter->type_->identifier_;
         }
@@ -74,12 +77,31 @@ void CYBox::Output(CYOutput &out, CYFlags flags) const {
     value_->Output(out, Precedence(), CYRight(flags));
 }
 
+void CYObjCArray::Output(CYOutput &out, CYFlags flags) const {
+    out << '@' << '[' << elements_ << ']';
+}
+
+void CYObjCDictionary::Output(CYOutput &out, CYFlags flags) const {
+    out << '@' << '{' << '}';
+}
+
 void CYObjCBlock::Output(CYOutput &out, CYFlags flags) const {
-    // XXX: this is seriously wrong
-    out << "^(";
-    out << ")";
-    out << "{";
-    out << "}";
+    out << '^' << ' ' << *typed_ << ' ' << '(';
+
+    bool comma(false);
+    CYForEach (parameter, parameters_) {
+        if (comma)
+            out << ',' << ' ';
+        else
+            comma = true;
+        out << *parameter->typed_;
+    }
+
+    out << ')' << ' ' << '{' << '\n';
+    ++out.indent_;
+    out << code_;
+    --out.indent_;
+    out << '\n' << '}';
 }
 
 void CYProtocol::Output(CYOutput &out) const {
@@ -89,7 +111,7 @@ void CYProtocol::Output(CYOutput &out) const {
 }
 
 void CYSelector::Output(CYOutput &out, CYFlags flags) const {
-    out << "@selector" << '(' << name_ << ')';
+    out << "@selector" << '(' << parts_ << ')';
 }
 
 void CYSelectorPart::Output(CYOutput &out) const {