vala r1110 - in trunk: . gobject vala



Author: juergbi
Date: Sat Mar  8 16:55:29 2008
New Revision: 1110
URL: http://svn.gnome.org/viewvc/vala?rev=1110&view=rev

Log:
2008-03-08  Juerg Billeter  <j bitron ch>

	* vala/valaclass.vala, vala/valaproperty.vala,
	  vala/valapropertyaccessor.vala, vala/valasemanticanalyzer.vala,
	  gobject/valaccodegeneratormemberaccess.vala: optimize access to
	  automatic properties, patch by Rob Taylor


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodegeneratormemberaccess.vala
   trunk/vala/valaclass.vala
   trunk/vala/valaproperty.vala
   trunk/vala/valapropertyaccessor.vala
   trunk/vala/valasemanticanalyzer.vala

Modified: trunk/gobject/valaccodegeneratormemberaccess.vala
==============================================================================
--- trunk/gobject/valaccodegeneratormemberaccess.vala	(original)
+++ trunk/gobject/valaccodegeneratormemberaccess.vala	Sat Mar  8 16:55:29 2008
@@ -105,7 +105,13 @@
 		} else if (expr.symbol_reference is Property) {
 			var prop = (Property) expr.symbol_reference;
 
-			if (!prop.no_accessor_method) {
+			if (prop.get_accessor != null &&
+			    prop.get_accessor.automatic_body &&
+			    current_type_symbol == prop.parent_symbol) {
+				CCodeExpression inst;
+				inst = new CCodeMemberAccess.pointer (pub_inst, "priv");
+				expr.ccodenode = new CCodeMemberAccess.pointer (inst, prop.field.get_cname());
+			} else if (!prop.no_accessor_method) {
 				var base_property = prop;
 				if (prop.base_property != null) {
 					base_property = prop.base_property;

Modified: trunk/vala/valaclass.vala
==============================================================================
--- trunk/vala/valaclass.vala	(original)
+++ trunk/vala/valaclass.vala	Sat Mar  8 16:55:29 2008
@@ -263,6 +263,7 @@
 				var field_type = prop.type_reference.copy ();
 				var f = new Field ("_%s".printf (prop.name), field_type, prop.default_expression, prop.source_reference);
 				f.access = SymbolAccessibility.PRIVATE;
+				prop.field = f;
 				add_field (f);
 			}
 		}

Modified: trunk/vala/valaproperty.vala
==============================================================================
--- trunk/vala/valaproperty.vala	(original)
+++ trunk/vala/valaproperty.vala	Sat Mar  8 16:55:29 2008
@@ -90,6 +90,11 @@
 	public bool overrides { get; set; }
 
 	/**
+	 * Reference the the Field that holds this property
+	 */
+	public Field field { get; set; }
+
+	/**
 	 * Specifies whether this field may only be accessed with an instance of
 	 * the contained type.
 	 */

Modified: trunk/vala/valapropertyaccessor.vala
==============================================================================
--- trunk/vala/valapropertyaccessor.vala	(original)
+++ trunk/vala/valapropertyaccessor.vala	Sat Mar  8 16:55:29 2008
@@ -62,6 +62,11 @@
 	public BasicBlock exit_block { get; set; }
 
 	/**
+	 * True if the body was automatically generated
+	 */
+	public bool automatic_body { get; set; }
+
+	/**
 	 * Represents the generated value parameter in a set accessor.
 	 */
 	public FormalParameter value_parameter { get; set; }

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Sat Mar  8 16:55:29 2008
@@ -650,7 +650,7 @@
 					Report.error (acc.source_reference, "Automatic properties can't be used in interfaces");
 					return;
 				}
-
+				acc.automatic_body = true;
 				acc.body = new Block ();
 				if (acc.readable) {
 					acc.body.add_statement (new ReturnStatement (new MemberAccess.simple ("_%s".printf (acc.prop.name)), acc.source_reference));



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