[vala/emit-let: 2/5] codegen: Use TargetValue instead of Expression for field instance



commit d10ad9480650e416928f9bf30d06f99178da2a22
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Mar 6 16:38:32 2011 +0100

    codegen: Use TargetValue instead of Expression for field instance

 codegen/valaccodeassignmentmodule.vala   |    2 +-
 codegen/valaccodebasemodule.vala         |    8 ++++----
 codegen/valaccodememberaccessmodule.vala |   10 +++++-----
 codegen/valadovaassignmentmodule.vala    |    2 +-
 codegen/valadovamemberaccessmodule.vala  |    8 ++++----
 vala/valaassignment.vala                 |    4 ++--
 vala/valacodegenerator.vala              |    4 ++--
 7 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index 83552a6..b22cbaf 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -233,7 +233,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 		store_variable (param, get_parameter_cvalue (param), value, false);
 	}
 
-	public override void store_field (Field field, Expression? instance, TargetValue value) {
+	public override void store_field (Field field, TargetValue? instance, TargetValue value) {
 		if (requires_destroy (field.variable_type)) {
 			/* unref old value */
 			ccode.add_expression (destroy_field (field, instance));
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0522c03..3a464c4 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1012,7 +1012,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 					set_cvalue (this_access, new CCodeIdentifier ("self"));
 				}
 
-				ccode.add_expression (destroy_field (f, this_access));
+				ccode.add_expression (destroy_field (f, this_access.target_value));
 
 				pop_context ();
 			}
@@ -2981,7 +2981,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return destroy_variable (param, get_parameter_cvalue (param));
 	}
 
-	public CCodeExpression destroy_field (Field field, Expression? instance) {
+	public CCodeExpression destroy_field (Field field, TargetValue? instance) {
 		return destroy_variable (field, get_field_cvalue (field, instance));
 	}
 
@@ -3719,7 +3719,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
 	public abstract TargetValue get_parameter_cvalue (Parameter param);
 
-	public abstract TargetValue get_field_cvalue (Field field, Expression? instance);
+	public abstract TargetValue get_field_cvalue (Field field, TargetValue? instance);
 
 	public virtual string get_delegate_target_cname (string delegate_cname) {
 		assert_not_reached ();
@@ -5760,7 +5760,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 					this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
 					set_cvalue (this_access, new CCodeIdentifier ("(*self)"));
 
-					ccode.add_expression (destroy_field (f, this_access));
+					ccode.add_expression (destroy_field (f, this_access.target_value));
 				}
 			}
 		}
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 7ddad75..991319d 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -121,7 +121,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			set_cvalue (expr, get_array_length_cexpression (expr.inner, 1));
 		} else if (expr.symbol_reference is Field) {
 			var field = (Field) expr.symbol_reference;
-			expr.target_value = load_field (field, expr.inner);
+			expr.target_value = load_field (field, expr.inner != null ? expr.inner.target_value : null);
 		} else if (expr.symbol_reference is EnumValue) {
 			var ev = (EnumValue) expr.symbol_reference;
 
@@ -492,7 +492,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 	}
 
 	/* Returns lvalue access to the given field */
-	public override TargetValue get_field_cvalue (Field field, Expression? instance) {
+	public override TargetValue get_field_cvalue (Field field, TargetValue? instance) {
 		var result = new GLibValue (field.variable_type.copy ());
 
 		var array_type = field.variable_type as ArrayType;
@@ -501,7 +501,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			CCodeExpression pub_inst = null;
 
 			if (instance != null) {
-				pub_inst = get_cvalue (instance);
+				pub_inst = get_cvalue_ (instance);
 			}
 
 			var instance_target_type = get_data_type_for_symbol ((TypeSymbol) field.parent_symbol);
@@ -586,7 +586,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			} else {
 				// Accessing the field of an instance
 				var k = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_GET_CLASS"));
-				k.add_argument (get_cvalue (instance));
+				k.add_argument (get_cvalue_ (instance));
 				klass = k;
 			}
 			cast.add_argument (klass);
@@ -679,7 +679,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 	}
 
 	/* Returns unowned access to the given field */
-	public override TargetValue load_field (Field field, Expression? instance) {
+	public override TargetValue load_field (Field field, TargetValue? instance) {
 		return load_variable (field, get_field_cvalue (field, instance));
 	}
 }
diff --git a/codegen/valadovaassignmentmodule.vala b/codegen/valadovaassignmentmodule.vala
index e212314..831baa6 100644
--- a/codegen/valadovaassignmentmodule.vala
+++ b/codegen/valadovaassignmentmodule.vala
@@ -149,7 +149,7 @@ public class Vala.DovaAssignmentModule : DovaMemberAccessModule {
 		store_variable (param, get_parameter_cvalue (param), value, false);
 	}
 
-	public override void store_field (Field field, Expression? instance, TargetValue value) {
+	public override void store_field (Field field, TargetValue? instance, TargetValue value) {
 		store_variable (field, get_field_cvalue (field, instance), value, false);
 	}
 }
diff --git a/codegen/valadovamemberaccessmodule.vala b/codegen/valadovamemberaccessmodule.vala
index 8538db0..20629fb 100644
--- a/codegen/valadovamemberaccessmodule.vala
+++ b/codegen/valadovamemberaccessmodule.vala
@@ -98,7 +98,7 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 			set_cvalue (expr, ccall);
 		} else if (expr.symbol_reference is Field) {
 			var f = (Field) expr.symbol_reference;
-			expr.target_value = load_field (f, expr.inner);
+			expr.target_value = load_field (f, expr.inner != null ? expr.inner.target_value : null);
 		} else if (expr.symbol_reference is EnumValue) {
 			var ev = (EnumValue) expr.symbol_reference;
 
@@ -243,14 +243,14 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 		return result;
 	}
 
-	public TargetValue get_field_cvalue (Field f, Expression? instance) {
+	public TargetValue get_field_cvalue (Field f, TargetValue? instance) {
 		var result = new DovaValue (f.variable_type);
 
 		if (f.binding == MemberBinding.INSTANCE) {
 			CCodeExpression pub_inst = null;
 
 			if (instance != null) {
-				pub_inst = get_cvalue (instance);
+				pub_inst = get_cvalue_ (instance);
 			}
 
 			var instance_target_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
@@ -295,7 +295,7 @@ public abstract class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 		return load_variable (param, get_parameter_cvalue (param));
 	}
 
-	public override TargetValue load_field (Field field, Expression? instance) {
+	public override TargetValue load_field (Field field, TargetValue? instance) {
 		return load_variable (field, get_field_cvalue (field, instance));
 	}
 }
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 7d34ce5..1b9afa8 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -486,7 +486,7 @@ public class Vala.Assignment : Expression {
 				} else if (param != null) {
 					codegen.store_parameter (param, new_value);
 				} else if (field != null) {
-					codegen.store_field (field, instance ? ma.inner : null, new_value);
+					codegen.store_field (field, ma.inner != null ? ma.inner.target_value : null, new_value);
 				}
 
 				// when load_variable is changed to use temporary
@@ -497,7 +497,7 @@ public class Vala.Assignment : Expression {
 				} else if (param != null) {
 					target_value = codegen.load_parameter (param);
 				} else if (field != null) {
-					target_value = codegen.load_field (field, instance ? ma.inner : null);
+					target_value = codegen.load_field (field, ma.inner != null ? ma.inner.target_value : null);
 				}
 
 				codegen.visit_expression (this);
diff --git a/vala/valacodegenerator.vala b/vala/valacodegenerator.vala
index a768032..f76ea20 100644
--- a/vala/valacodegenerator.vala
+++ b/vala/valacodegenerator.vala
@@ -42,7 +42,7 @@ public abstract class Vala.CodeGenerator : CodeVisitor {
 
 	public abstract void store_parameter (Parameter param, TargetValue value);
 
-	public abstract TargetValue load_field (Field field, Expression? instance);
+	public abstract TargetValue load_field (Field field, TargetValue? instance);
 
-	public abstract void store_field (Field field, Expression? instance, TargetValue value);
+	public abstract void store_field (Field field, TargetValue? instance, TargetValue value);
 }



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