]> git.saurik.com Git - cycript.git/blobdiff - Output.cpp
Move non-RegEx lexer hacks from Scanner to Parser.
[cycript.git] / Output.cpp
index e43d038e8d64388a025a9d6b7d18e2b67d25a11d..22e2149dd85a47702d2b6348bb70fb42132b67db 100644 (file)
@@ -268,11 +268,6 @@ void CYDebugger::Output(CYOutput &out, CYFlags flags) const {
     out << "debugger" << ';';
 }
 
-void CYDeclaration::ForIn(CYOutput &out, CYFlags flags) const {
-    out << "var" << ' ';
-    Output(out, CYRight(flags));
-}
-
 void CYDeclaration::Output(CYOutput &out, CYFlags flags) const {
     out << *identifier_;
     //out.out_ << ':' << identifier_->usage_ << '#' << identifier_->offset_;
@@ -282,11 +277,6 @@ void CYDeclaration::Output(CYOutput &out, CYFlags flags) const {
     }
 }
 
-void CYForDeclarations::Output(CYOutput &out, CYFlags flags) const {
-    out << "var" << ' ';
-    declarations_->Output(out, CYRight(flags));
-}
-
 void CYDeclarations::Output(CYOutput &out) const {
     Output(out, CYNoFlags);
 }
@@ -353,15 +343,15 @@ void CYEmpty::Output(CYOutput &out, CYFlags flags) const {
     out.Terminate();
 }
 
+void CYEval::Output(CYOutput &out, CYFlags flags) const {
+    _assert(false);
+}
+
 void CYExpress::Output(CYOutput &out, CYFlags flags) const {
     expression_->Output(out, flags | CYNoBFC);
     out << ';';
 }
 
-void CYExpression::ForIn(CYOutput &out, CYFlags flags) const {
-    Output(out, flags | CYNoRightHand);
-}
-
 void CYExpression::Output(CYOutput &out) const {
     Output(out, CYNoFlags);
 }
@@ -406,31 +396,47 @@ void CYFor::Output(CYOutput &out, CYFlags flags) const {
     code_->Single(out, CYRight(flags), CYCompactShort);
 }
 
-void CYForOf::Output(CYOutput &out, CYFlags flags) const {
-    out << "for" << ' ' << "each" << ' ' << '(';
-    initialiser_->ForIn(out, CYNoIn);
+void CYForLexical::Output(CYOutput &out, CYFlags flags) const {
+    out << (constant_ ? "const" : "let") << ' ';
+    declaration_->Output(out, CYRight(flags));
+}
+
+void CYForIn::Output(CYOutput &out, CYFlags flags) const {
+    out << "for" << ' ' << '(';
+    initialiser_->Output(out, CYNoIn | CYNoRightHand);
     out << ' ' << "in" << ' ' << *set_ << ')';
     code_->Single(out, CYRight(flags), CYCompactShort);
 }
 
-void CYForOfComprehension::Output(CYOutput &out) const {
-    out << "for" << ' ' << "each" << ' ' << '(';
-    declaration_->Output(out, CYNoIn);
-    out << ' ' << "in" << ' ' << *set_ << ')' << next_;
+void CYForInitialized::Output(CYOutput &out, CYFlags flags) const {
+    out << "for" << ' ' << '(' << "var" << ' ';
+    declaration_->Output(out, CYNoIn | CYNoRightHand);
+    out << ' ' << "in" << ' ' << *set_ << ')';
+    code_->Single(out, CYRight(flags), CYCompactShort);
 }
 
-void CYForIn::Output(CYOutput &out, CYFlags flags) const {
+void CYForInComprehension::Output(CYOutput &out) const {
     out << "for" << ' ' << '(';
-    if (initialiser_ != NULL)
-        initialiser_->ForIn(out, CYNoIn);
+    declaration_->Output(out, CYNoIn | CYNoRightHand);
     out << ' ' << "in" << ' ' << *set_ << ')';
+}
+
+void CYForOf::Output(CYOutput &out, CYFlags flags) const {
+    out << "for" << ' ' << '(';
+    initialiser_->Output(out, CYNoRightHand);
+    out << ' ' << "of" << ' ' << *set_ << ')';
     code_->Single(out, CYRight(flags), CYCompactShort);
 }
 
-void CYForInComprehension::Output(CYOutput &out) const {
+void CYForOfComprehension::Output(CYOutput &out) const {
     out << "for" << ' ' << '(';
-    declaration_->Output(out, CYNoIn);
-    out << ' ' << "in" << ' ' << *set_ << ')';
+    declaration_->Output(out, CYNoRightHand);
+    out << ' ' << "of" << ' ' << *set_ << ')' << next_;
+}
+
+void CYForVariable::Output(CYOutput &out, CYFlags flags) const {
+    out << "var" << ' ';
+    declaration_->Output(out, CYRight(flags));
 }
 
 void CYFunction::Output(CYOutput &out) const {
@@ -467,7 +473,7 @@ void CYFunctionParameter::Output(CYOutput &out) const {
 }
 
 const char *CYIdentifier::Word() const {
-    return replace_ == NULL || replace_ == this ? CYWord::Word() : replace_->Word();
+    return next_ == NULL || next_ == this ? CYWord::Word() : next_->Word();
 }
 
 void CYIf::Output(CYOutput &out, CYFlags flags) const {
@@ -513,6 +519,11 @@ void CYImport::Output(CYOutput &out, CYFlags flags) const {
     out << "@import";
 }
 
+void CYIndirect::Output(CYOutput &out, CYFlags flags) const {
+    out << "*";
+    rhs_->Output(out, Precedence(), CYRight(flags));
+}
+
 void CYIndirectMember::Output(CYOutput &out, CYFlags flags) const {
     object_->Output(out, Precedence(), CYLeft(flags));
     if (const char *word = property_->Word())