]> git.saurik.com Git - cycript.git/blobdiff - List.hpp
Also use CXType walker to for function prototypes.
[cycript.git] / List.hpp
index 4caa5361e35db6eceb83f1232c23e078f3b7c7ab..d2acedf63e26a327e11ce5f4359e6a27fc6d5b24 100644 (file)
--- a/List.hpp
+++ b/List.hpp
@@ -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 {{{ */
 */
 
 /* GNU Affero General Public License, Version 3 {{{ */
@@ -22,6 +22,8 @@
 #ifndef CYCRIPT_LIST_HPP
 #define CYCRIPT_LIST_HPP
 
 #ifndef CYCRIPT_LIST_HPP
 #define CYCRIPT_LIST_HPP
 
+#include "Exception.hpp"
+
 template <typename Type_>
 struct CYNext {
     Type_ *next_;
 template <typename Type_>
 struct CYNext {
     Type_ *next_;
@@ -68,12 +70,24 @@ struct CYList {
     Type_ *first_;
     Type_ *last_;
 
     Type_ *first_;
     Type_ *last_;
 
-    CYList(Type_ *first = NULL) :
+    CYList() :
+        first_(NULL),
+        last_(NULL)
+    {
+    }
+
+    CYList(Type_ *first) :
         first_(first),
         last_(CYGetLast(first))
     {
     }
 
         first_(first),
         last_(CYGetLast(first))
     {
     }
 
+    CYList(Type_ *first, Type_ *last) :
+        first_(first),
+        last_(last)
+    {
+    }
+
     operator Type_ *() const {
         return first_;
     }
     operator Type_ *() const {
         return first_;
     }
@@ -87,12 +101,11 @@ struct CYList {
             if (first_ == NULL) {
                 first_ = next;
                 last_ = next;
             if (first_ == NULL) {
                 first_ = next;
                 last_ = next;
-            } else for (;; last_ = last_->next_)
-                if (last_->next_ == NULL) {
-                    last_->next_ = next;
-                    last_ = next;
-                    break;
-                }
+            } else {
+                _assert(last_->next_ == NULL);
+                last_->next_ = next;
+                last_ = next;
+            }
         return *this;
     }
 
         return *this;
     }