[vala] codegen: Add convenience load_this_parameter() method



commit 7c2667f988d74a2520f1b1eae94c4c1012e246a3
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Mar 6 16:49:07 2011 +0100

    codegen: Add convenience load_this_parameter() method

 codegen/valaccodebasemodule.vala         |    2 ++
 codegen/valaccodememberaccessmodule.vala |    8 +++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 3a464c4..83f96f4 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3721,6 +3721,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
 	public abstract TargetValue get_field_cvalue (Field field, TargetValue? instance);
 
+	public abstract TargetValue load_this_parameter (TypeSymbol sym);
+
 	public virtual string get_delegate_target_cname (string delegate_cname) {
 		assert_not_reached ();
 	}
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 991319d..285c09a 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -402,7 +402,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				// use closure
 				result.cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "self");
 			} else {
-				var st = current_type_symbol as Struct;
+				var st = result.value_type.data_type as Struct;
 				if (st != null && !st.is_simple_type ()) {
 					result.cvalue = new CCodeIdentifier ("(*self)");
 				} else {
@@ -678,6 +678,12 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 		return load_variable (param, get_parameter_cvalue (param));
 	}
 
+	/* Convenience method returning access to "this" */
+	public override TargetValue load_this_parameter (TypeSymbol sym) {
+		var param = new Parameter ("this", get_data_type_for_symbol (sym));
+		return load_parameter (param);
+	}
+
 	/* Returns unowned access to the given field */
 	public override TargetValue load_field (Field field, TargetValue? instance) {
 		return load_variable (field, get_field_cvalue (field, instance));



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