[vala] codegen: Use set_delegate_target for field access
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Use set_delegate_target for field access
- Date: Sat, 9 Oct 2010 17:08:22 +0000 (UTC)
commit c4d0b969b19fd697b5cfed3e8a27dd7b2dc9e08d
Author: Jürg Billeter <j bitron ch>
Date: Sat Oct 9 18:22:29 2010 +0200
codegen: Use set_delegate_target for field access
codegen/valaccodedelegatemodule.vala | 51 +-----------------------------
codegen/valaccodememberaccessmodule.vala | 28 ++++++++++++++++
2 files changed, 29 insertions(+), 50 deletions(-)
---
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index 2b698f1..834b982 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -154,7 +154,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
}
return get_delegate_target (delegate_expr);
} else if (delegate_expr.symbol_reference != null) {
- if (delegate_expr.symbol_reference is FormalParameter || delegate_expr.symbol_reference is LocalVariable) {
+ if (delegate_expr.symbol_reference is FormalParameter || delegate_expr.symbol_reference is LocalVariable || delegate_expr.symbol_reference is Field) {
if (get_delegate_target_destroy_notify (delegate_expr) != null) {
delegate_target_destroy_notify = get_delegate_target_destroy_notify (delegate_expr);
}
@@ -168,55 +168,6 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
} else {
return target_expr;
}
- } else if (delegate_expr.symbol_reference is Field) {
- var field = (Field) delegate_expr.symbol_reference;
- string target_cname = get_delegate_target_cname (field.get_cname ());
- string target_destroy_notify_cname = get_delegate_target_destroy_notify_cname (field.get_cname ());
-
- var ma = (MemberAccess) delegate_expr;
-
- CCodeExpression target_expr = null;
-
- if (field.no_delegate_target) {
- return new CCodeConstant ("NULL");
- }
-
- if (field.binding == MemberBinding.INSTANCE) {
- var instance_expression_type = ma.inner.value_type;
- var instance_target_type = get_data_type_for_symbol ((TypeSymbol) field.parent_symbol);
-
- var pub_inst = (CCodeExpression) get_ccodenode (ma.inner);
- CCodeExpression typed_inst = transform_expression (pub_inst, instance_expression_type, instance_target_type);
-
- CCodeExpression inst;
- if (field.access == SymbolAccessibility.PRIVATE) {
- inst = new CCodeMemberAccess.pointer (typed_inst, "priv");
- } else {
- inst = typed_inst;
- }
- if (((TypeSymbol) field.parent_symbol).is_reference_type ()) {
- target_expr = new CCodeMemberAccess.pointer (inst, target_cname);
- if (expr_owned) {
- delegate_target_destroy_notify = new CCodeMemberAccess.pointer (inst, target_destroy_notify_cname);
- }
- } else {
- target_expr = new CCodeMemberAccess (inst, target_cname);
- if (expr_owned) {
- delegate_target_destroy_notify = new CCodeMemberAccess (inst, target_destroy_notify_cname);
- }
- }
- } else {
- target_expr = new CCodeIdentifier (target_cname);
- if (expr_owned) {
- delegate_target_destroy_notify = new CCodeIdentifier (target_destroy_notify_cname);
- }
- }
-
- if (is_out) {
- return new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, target_expr);
- } else {
- return target_expr;
- }
} else if (delegate_expr.symbol_reference is Method) {
var m = (Method) delegate_expr.symbol_reference;
var ma = (MemberAccess) delegate_expr;
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index a0d6115..5f5a50d 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -175,6 +175,25 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
append_array_size (expr, length_expr);
}
}
+ } else if (field.variable_type is DelegateType) {
+ string target_cname = get_delegate_target_cname (field.get_cname ());
+ string target_destroy_notify_cname = get_delegate_target_destroy_notify_cname (field.get_cname ());
+
+ if (field.no_delegate_target) {
+ set_delegate_target (expr, new CCodeConstant ("NULL"));
+ } else {
+ if (((TypeSymbol) field.parent_symbol).is_reference_type ()) {
+ set_delegate_target (expr, new CCodeMemberAccess.pointer (inst, target_cname));
+ if (expr.value_type.value_owned) {
+ set_delegate_target_destroy_notify (expr, new CCodeMemberAccess.pointer (inst, target_destroy_notify_cname));
+ }
+ } else {
+ set_delegate_target (expr, new CCodeMemberAccess (inst, target_cname));
+ if (expr.value_type.value_owned) {
+ set_delegate_target_destroy_notify (expr, new CCodeMemberAccess (inst, target_destroy_notify_cname));
+ }
+ }
+ }
}
} else if (field.binding == MemberBinding.CLASS) {
var cl = (Class) field.parent_symbol;
@@ -227,6 +246,15 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
}
}
+ } else if (field.variable_type is DelegateType) {
+ if (field.no_delegate_target) {
+ set_delegate_target (expr, new CCodeConstant ("NULL"));
+ } else {
+ set_delegate_target (expr, new CCodeIdentifier (get_delegate_target_cname (field.get_cname ())));
+ if (expr.value_type.value_owned) {
+ set_delegate_target_destroy_notify (expr, new CCodeIdentifier (get_delegate_target_destroy_notify_cname (field.get_cname ())));
+ }
+ }
}
}
} else if (expr.symbol_reference is EnumValue) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]