]> git.saurik.com Git - cycript.git/blobdiff - Parser.hpp
Expose Objective-C class names to tab completion.
[cycript.git] / Parser.hpp
index 0b9099adfa8059009323d8f016a7451e68a40c49..24b356418841b41cded8075e1a5d183b6549fc56 100644 (file)
@@ -19,8 +19,8 @@
 **/
 /* }}} */
 
-#ifndef CYPARSER_HPP
-#define CYPARSER_HPP
+#ifndef CYCRIPT_PARSER_HPP
+#define CYCRIPT_PARSER_HPP
 
 #include <iostream>
 
 #include <cstdlib>
 
 #include "location.hh"
+
+#include "List.hpp"
 #include "Pooling.hpp"
 #include "Options.hpp"
 
 class CYContext;
 
-template <typename Type_>
-struct CYNext {
-    Type_ *next_;
-
-    CYNext() :
-        next_(NULL)
-    {
-    }
-
-    CYNext(Type_ *next) :
-        next_(next)
-    {
-    }
-
-    void SetNext(Type_ *next) {
-        next_ = next;
-    }
-};
-
-template <typename Type_>
-void CYSetLast(Type_ *&list, Type_ *item) {
-    if (list == NULL)
-        list = item;
-    else {
-        Type_ *next(list);
-        while (next->next_ != NULL)
-            next = next->next_;
-        next->next_ = item;
-    }
-}
-
-#define CYForEach(value, list) \
-    for (__typeof__(*list) *value(list); value != NULL; value = value->next_)
-
 struct CYThing {
     virtual ~CYThing() {
     }
@@ -149,6 +117,34 @@ enum CYFlags {
     CYNoBF =         (CYNoBrace | CYNoFunction),
 };
 
+_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));
+}
+
 struct CYStatement :
     CYNext<CYStatement>
 {
@@ -335,6 +331,7 @@ struct CYScope {
     CYIdentifierValueSet identifiers_;
 
     CYScope(CYScopeType type, CYContext &context, CYStatement *&statements);
+    virtual ~CYScope();
 
     void Close();
 
@@ -386,7 +383,7 @@ struct CYContext {
     void ReplaceAll(Type_ *&values) {
         Type_ **last(&values);
         CYForEach (next, values) {
-            Replace(*last);
+            Replace(*last = next);
             last = &(*last)->next_;
         }
     }
@@ -1873,4 +1870,4 @@ CYAssignment_("&=", BitwiseAnd)
 CYAssignment_("^=", BitwiseXOr)
 CYAssignment_("|=", BitwiseOr)
 
-#endif/*CYPARSER_HPP*/
+#endif/*CYCRIPT_PARSER_HPP*/