]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add attributes cache to code nodes
authorLuca Bruno <lucabru@src.gnome.org>
Wed, 6 Jul 2011 08:21:18 +0000 (10:21 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Mon, 1 Aug 2011 16:17:04 +0000 (18:17 +0200)
vala/valacodenode.vala

index b5f637ca76f30ee62f99a7b588b4b43bae6059af..8426cea3e3d3a9e487287a5cceda65452e1e0934 100644 (file)
@@ -67,8 +67,10 @@ public abstract class Vala.CodeNode {
 
        private List<DataType> _error_types;
        private static List<DataType> _empty_type_list;
+       private AttributeCache[] attributes_cache;
 
        static int last_temp_nr = 0;
+       static int next_attribute_cache_index = 0;
 
        /**
         * Specifies the exceptions that can be thrown by this node or a child node
@@ -147,10 +149,36 @@ public abstract class Vala.CodeNode {
                                return a;
                        }
                }
-               
+
                return null;
        }
 
+       /**
+        * Returns the attribute cache at the specified index.
+        *
+        * @param index attribute cache index
+        * @return      attribute cache
+        */
+       public AttributeCache? get_attribute_cache (int index) {
+               if (index >= attributes_cache.length) {
+                       return null;
+               }
+               return attributes_cache[index];
+       }
+
+       /**
+        * Sets the specified attribute cache to this code node.
+        *
+        * @param index attribute cache index
+        * @param cache attribute cache
+        */
+       public void set_attribute_cache (int index, AttributeCache cache) {
+               if (index >= attributes_cache.length) {
+                       attributes_cache.resize (index * 2 + 1);
+               }
+               attributes_cache[index] = cache;
+       }
+
        /**
         * Returns a string that represents this code node.
         *
@@ -177,4 +205,16 @@ public abstract class Vala.CodeNode {
        public static string get_temp_name () {
                return "." + (++last_temp_nr).to_string ();
        }
+
+       /**
+        * Returns a new cache index for accessing the attributes cache of code nodes
+        *
+        * @return a new cache index
+        */
+       public static int get_attribute_cache_index () {
+               return next_attribute_cache_index++;
+       }
+}
+
+public class Vala.AttributeCache {
 }