From: Luca Bruno Date: Wed, 6 Jul 2011 08:21:18 +0000 (+0200) Subject: Add attributes cache to code nodes X-Git-Tag: 0.13.2~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2141316b23eb0b5004cd0a400eb0cedcb9d2925a;p=thirdparty%2Fvala.git Add attributes cache to code nodes --- diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala index b5f637ca7..8426cea3e 100644 --- a/vala/valacodenode.vala +++ b/vala/valacodenode.vala @@ -67,8 +67,10 @@ public abstract class Vala.CodeNode { private List _error_types; private static List _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 { }