2008-03-08 Jürg 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
+
+2008-03-08 Jürg Billeter <j@bitron.ch>
+
* gobject/valaccodegenerator.vala: support foreach over
multi-dimensional arrays
} 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;
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);
}
}
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.
*/
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; }
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));