[vala/emit-let: 4/4] codegen: Add convenience load_this_parameter method.
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/emit-let: 4/4] codegen: Add convenience load_this_parameter method.
- Date: Wed, 19 Jan 2011 23:38:22 +0000 (UTC)
commit 7326ee1d98916d0826ae5836c5e77e9fc5ffb27b
Author: Luca Bruno <lucabru src gnome org>
Date: Tue Jan 18 23:46:44 2011 +0100
codegen: Add convenience load_this_parameter method.
codegen/valaccodebasemodule.vala | 23 ++++++-----------------
codegen/valaccodememberaccessmodule.vala | 16 ++++++++++++++++
2 files changed, 22 insertions(+), 17 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index f56f7d4..e8971d7 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1001,23 +1001,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (requires_destroy (f.variable_type) && instance_finalize_context != null) {
push_context (instance_finalize_context);
-
- var this_access = new MemberAccess.simple ("this");
- this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
-
- var field_st = f.parent_symbol as Struct;
- if (field_st != null && !field_st.is_simple_type ()) {
- set_cvalue (this_access, new CCodeIdentifier ("(*self)"));
- } else {
- set_cvalue (this_access, new CCodeIdentifier ("self"));
- }
-
- var ma = new MemberAccess (this_access, f.name);
- ma.symbol_reference = f;
- ma.value_type = f.variable_type.copy ();
- visit_member_access (ma);
- ccode.add_expression (get_unref_expression (lhs, f.variable_type, ma));
-
+ var type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
+ ccode.add_expression (get_unref_expression_ (f, load_this_parameter (type)));
pop_context ();
}
} else if (f.binding == MemberBinding.CLASS) {
@@ -3492,6 +3477,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
}
+ public virtual TargetValue load_this_parameter (DataType type) {
+ assert_not_reached ();
+ }
+
public virtual TargetValue get_variable_cvalue (Variable variable, TargetValue? inner = null, bool not_in_coroutine = false) {
assert_not_reached ();
}
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index ad6155f..f2b66c5 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -790,4 +790,20 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.value_type.value_owned = false;
return load_variable (field, result);
}
+
+ public override TargetValue load_this_parameter (DataType type) {
+ var result = new GLibValue (type);
+ if (is_in_coroutine ()) {
+ // use closure
+ result.cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "self");
+ } else {
+ var st = type.data_type as Struct;
+ if (st != null && !st.is_simple_type ()) {
+ result.cvalue = new CCodeIdentifier ("(*self)");
+ } else {
+ result.cvalue = new CCodeIdentifier ("self");
+ }
+ }
+ return result;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]