[vala/wip/attributes: 2/100] Add a cache structure in code nodes to be used by code generators
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 2/100] Add a cache structure in code nodes to be used by code generators
- Date: Sat, 2 Jul 2011 12:25:28 +0000 (UTC)
commit d9371deab801f7c48900d4eef206a7ea1d25e4bf
Author: Luca Bruno <lucabru src gnome org>
Date: Sat Jun 25 16:25:23 2011 +0200
Add a cache structure in code nodes to be used by code generators
vala/valacodenode.vala | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala
index b1fc30e..fbde238 100644
--- a/vala/valacodenode.vala
+++ b/vala/valacodenode.vala
@@ -67,8 +67,10 @@ public abstract class Vala.CodeNode {
private List<DataType> _error_types;
private static List<DataType> _empty_type_list;
+ private AttributeCache[] attribute_caches;
static int last_temp_nr = 0;
+ static int next_attribute_hash = 0;
/**
* Specifies the exceptions that can be thrown by this node or a child node
@@ -152,6 +154,32 @@ public abstract class Vala.CodeNode {
}
/**
+ * Returns the specified attribute cache.
+ *
+ * @param hash hash number
+ * @return attribute manager
+ */
+ public AttributeCache? get_attribute_cache (int hash) {
+ if (hash >= attribute_caches.length) {
+ return null;
+ }
+ return attribute_caches[hash];
+ }
+
+ /**
+ * Sets the specified attribute cache to this code node.
+ *
+ * @param hash hash number
+ * @param cache attribute cache
+ */
+ public void set_attribute_cache (int hash, AttributeCache cache) {
+ if (hash >= attribute_caches.length) {
+ attribute_caches.resize (hash * 2 + 1);
+ }
+ attribute_caches[hash] = cache;
+ }
+
+ /**
* Returns a string that represents this code node.
*
* @return a string representation
@@ -177,4 +205,16 @@ public abstract class Vala.CodeNode {
public static string get_temp_name () {
return "." + (++last_temp_nr).to_string ();
}
+
+ /**
+ * Returns a new hash number for accessing the attribute caches of code nodes
+ *
+ * @return a new hash number
+ */
+ public static int get_attribute_hash () {
+ return next_attribute_hash++;
+ }
+}
+
+public class Vala.AttributeCache {
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]