[vala/wip/attributes: 4/27] codegen: Add CCodeAttribute cache



commit a75c72131894a18f0ed4d95040c2135a52f0c197
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Jun 26 17:02:08 2011 +0200

    codegen: Add CCodeAttribute cache

 codegen/valaccodebasemodule.vala |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index efef181..877e5c8 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -305,6 +305,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
 	public Map<string,string> variable_name_map { get { return emit_context.variable_name_map; } }
 
+	public static int ccode_attribute_hash = CodeNode.get_attribute_hash ();
+
 	public CCodeBaseModule () {
 		predefined_marshal_set = new HashSet<string> (str_hash, str_equal);
 		predefined_marshal_set.add ("VOID:VOID");
@@ -5544,6 +5546,15 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return get_cvalue (node);
 	}
 
+	public static CCodeAttribute get_ccode_attribute (CodeNode node) {
+		var attr = node.get_attribute_cache (ccode_attribute_hash);
+		if (attr == null) {
+			attr = new CCodeAttribute (node);
+			node.set_attribute_cache (ccode_attribute_hash, attr);
+		}
+		return (CCodeAttribute) attr;
+	}
+
 	public override void visit_class (Class cl) {
 	}
 
@@ -5871,3 +5882,11 @@ public class Vala.GLibValue : TargetValue {
 		return result;
 	}
 }
+
+public class Vala.CCodeAttribute : AttributeCache {
+	public weak CodeNode node;
+
+	public CCodeAttribute (CodeNode node) {
+		this.node = node;
+	}
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]