[vala] codegen: Add get_cvalue and set_cvalue helper methods



commit 3bbb4054ee13a069a866b429893b08a4bd4f9ad1
Author: Jürg Billeter <j bitron ch>
Date:   Thu Aug 26 12:51:15 2010 +0200

    codegen: Add get_cvalue and set_cvalue helper methods

 codegen/valaccodearraymodule.vala        |   36 +++---
 codegen/valaccodeassignmentmodule.vala   |   12 +-
 codegen/valaccodebasemodule.vala         |  210 +++++++++++++++--------------
 codegen/valaccodecontrolflowmodule.vala  |   14 +-
 codegen/valaccodememberaccessmodule.vala |   84 ++++++------
 codegen/valaccodemethodcallmodule.vala   |   30 ++--
 codegen/valaccodemethodmodule.vala       |    2 +-
 codegen/valaccodestructmodule.vala       |    2 +-
 codegen/valadbusclientmodule.vala        |   28 ++--
 codegen/valadbusservermodule.vala        |   10 +-
 codegen/valadovaarraymodule.vala         |   14 +-
 codegen/valadovaassignmentmodule.vala    |   12 +-
 codegen/valadovabasemodule.vala          |  122 +++++++++--------
 codegen/valadovacontrolflowmodule.vala   |    6 +-
 codegen/valadovaerrormodule.vala         |    2 +-
 codegen/valadovamemberaccessmodule.vala  |   64 +++++-----
 codegen/valadovamethodcallmodule.vala    |   18 ++--
 codegen/valadovaobjectmodule.vala        |   16 +-
 codegen/valadovavaluemodule.vala         |   32 +++---
 codegen/valagasyncmodule.vala            |    2 +-
 codegen/valagdbusclientmodule.vala       |   12 +-
 codegen/valagdbusservermodule.vala       |    8 +-
 codegen/valagerrormodule.vala            |    4 +-
 codegen/valagobjectmodule.vala           |    4 +-
 codegen/valagsignalmodule.vala           |   22 ++--
 codegen/valagtypemodule.vala             |    2 +-
 26 files changed, 392 insertions(+), 376 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 255d2eb..2fb6dc4 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -32,7 +32,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 			if (rank > 1) {
 				append_initializer_list (ce, name_cnode, (InitializerList) e, rank - 1, ref i);
 			} else {
-				ce.append_expression (new CCodeAssignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), (CCodeExpression) e.ccodenode));
+				ce.append_expression (new CCodeAssignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), get_cvalue (e)));
 				i++;
 			}
 		}
@@ -54,7 +54,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
 			ce.append_expression (name_cnode);
 
-			expr.ccodenode = ce;
+			set_cvalue (expr, ce);
 
 			return;
 		}
@@ -73,12 +73,12 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
 		// iterate over each dimension
 		foreach (Expression size in expr.get_sizes ()) {
-			CCodeExpression csize = (CCodeExpression) size.ccodenode;
+			CCodeExpression csize = get_cvalue (size);
 
 			if (!is_pure_ccode_expression (csize)) {
 				var temp_var = get_temp_variable (int_type, false, expr);
 				var name_cnode = get_variable_cexpression (temp_var.name);
-				size.ccodenode = name_cnode;
+				set_cvalue (size, name_cnode);
 
 				emit_temp_var (temp_var);
 
@@ -120,9 +120,9 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 			
 			ce.append_expression (name_cnode);
 			
-			expr.ccodenode = ce;
+			set_cvalue (expr, ce);
 		} else {
-			expr.ccodenode = gnew;
+			set_cvalue (expr, gnew);
 		}
 	}
 
@@ -405,15 +405,15 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 		List<Expression> indices = expr.get_indices ();
 		int rank = indices.size;
 
-		var ccontainer = (CCodeExpression) expr.container.ccodenode;
-		var cindex = (CCodeExpression) indices[0].ccodenode;
+		var ccontainer = get_cvalue (expr.container);
+		var cindex = get_cvalue (indices[0]);
 		if (expr.container.symbol_reference is ArrayLengthField) {
 			/* Figure if cindex is a constant expression and calculate dim...*/
 			var lit = indices[0] as IntegerLiteral;
 			var memberaccess = expr.container as MemberAccess;
 			if (lit != null && memberaccess != null) {
 				int dim = lit.value.to_int ();
-				expr.ccodenode = get_array_length_cexpression (memberaccess.inner, dim + 1);
+				set_cvalue (expr, get_array_length_cexpression (memberaccess.inner, dim + 1));
 			} else {
 				Report.error (expr.source_reference, "only integer literals supported as index");
 			}
@@ -421,16 +421,16 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 			// access to element in an array
 			for (int i = 1; i < rank; i++) {
 				var cmul = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, cindex, get_array_length_cexpression (expr.container, i + 1));
-				cindex = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cmul, (CCodeExpression) indices[i].ccodenode);
+				cindex = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cmul, get_cvalue (indices[i]));
 			}
-			expr.ccodenode = new CCodeElementAccess (ccontainer, cindex);
+			set_cvalue (expr, new CCodeElementAccess (ccontainer, cindex));
 		}
 	}
 
 	public override void visit_slice_expression (SliceExpression expr) {
-		var ccontainer = (CCodeExpression) expr.container.ccodenode;
-		var cstart = (CCodeExpression) expr.start.ccodenode;
-		var cstop = (CCodeExpression) expr.stop.ccodenode;
+		var ccontainer = get_cvalue (expr.container);
+		var cstart = get_cvalue (expr.start);
+		var cstop = get_cvalue (expr.stop);
 
 		var ccomma = new CCodeCommaExpression ();
 
@@ -462,7 +462,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
 		ccomma.append_expression (get_variable_cexpression (slice_var.name));
 
-		expr.ccodenode = ccomma;
+		set_cvalue (expr, ccomma);
 		expr.append_array_size (get_variable_cexpression (len_var.name));
 	}
 
@@ -963,12 +963,12 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 		var value_param = new FormalParameter ("value", element.target_type);
 
 		var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_array_add_wrapper (array_type)));
-		ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, (CCodeExpression) array.ccodenode));
+		ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue (array)));
 		ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_length_cexpression (array)));
 		ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_array_size_cexpression (array)));
-		ccall.add_argument (handle_struct_argument (value_param, element, (CCodeExpression) element.ccodenode));
+		ccall.add_argument (handle_struct_argument (value_param, element, get_cvalue (element)));
 
-		assignment.ccodenode = ccall;
+		set_cvalue (assignment, ccall);
 
 		var array_var = assignment.left.symbol_reference;
 		var array_local = array_var as LocalVariable;
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index a403ada..525c8f6 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -45,7 +45,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 			}
 		}
 
-		CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode;
+		CCodeExpression cexpr = get_cvalue (assignment.right);
 
 		if (!prop.no_accessor_method) {
 			if (prop.property_type.is_real_non_null_struct_type ()) {
@@ -96,7 +96,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 	}
 
 	CCodeExpression emit_simple_assignment (Assignment assignment) {
-		CCodeExpression rhs = (CCodeExpression) assignment.right.ccodenode;
+		CCodeExpression rhs = get_cvalue (assignment.right);
 		CCodeExpression lhs = (CCodeExpression) get_ccodenode (assignment.left);
 		CCodeCommaExpression outer_ccomma = null;
 
@@ -205,7 +205,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 	}
 
 	CCodeExpression emit_fixed_length_array_assignment (Assignment assignment, ArrayType array_type) {
-		CCodeExpression rhs = (CCodeExpression) assignment.right.ccodenode;
+		CCodeExpression rhs = get_cvalue (assignment.right);
 		CCodeExpression lhs = (CCodeExpression) get_ccodenode (assignment.left);
 
 		cfile.add_include ("string.h");
@@ -230,13 +230,13 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 		}
 
 		if (assignment.left.symbol_reference is Property) {
-			assignment.ccodenode = emit_property_assignment (assignment);
+			set_cvalue (assignment, emit_property_assignment (assignment));
 		} else {
 			var array_type = assignment.left.value_type as ArrayType;
 			if (array_type != null && array_type.fixed_length) {
-				assignment.ccodenode = emit_fixed_length_array_assignment (assignment, array_type);
+				set_cvalue (assignment, emit_fixed_length_array_assignment (assignment, array_type));
 			} else {
-				assignment.ccodenode = emit_simple_assignment (assignment);
+				set_cvalue (assignment, emit_simple_assignment (assignment));
 			}
 		}
 	}
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 5c06956..4acbaa1 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -674,7 +674,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				}
 			} else {
 				ev.value.emit (this);
-				c_ev = new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode);
+				c_ev = new CCodeEnumValue (ev.get_cname (), get_cvalue (ev.value));
 			}
 			c_ev.deprecated = ev.deprecated;
 			cenum.add_value (c_ev);
@@ -779,7 +779,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 					arr = "[%d]".printf (initializer_list.size);
 				}
 
-				var cinitializer = (CCodeExpression) c.value.ccodenode;
+				var cinitializer = get_cvalue (c.value);
 				if (!definition) {
 					// never output value in header
 					// special case needed as this method combines declaration and definition
@@ -795,7 +795,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 				decl_space.add_constant_declaration (cdecl);
 			} else {
-				var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.value.ccodenode);
+				var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), get_cvalue (c.value));
 				decl_space.add_type_member_declaration (cdefine);
 			}
 		}
@@ -922,7 +922,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 				f.initializer.emit (this);
 
-				var rhs = (CCodeExpression) f.initializer.ccodenode;
+				var rhs = get_cvalue (f.initializer);
 
 				ccode.add_expression (new CCodeAssignment (lhs, rhs));
 
@@ -931,7 +931,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 					var array_type = (ArrayType) f.variable_type;
 					var this_access = new MemberAccess.simple ("this");
 					this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
-					this_access.ccodenode = new CCodeIdentifier ("self");
+					set_cvalue (this_access, new CCodeIdentifier ("self"));
 					var ma = new MemberAccess (this_access, f.name);
 					ma.symbol_reference = f;
 					
@@ -939,7 +939,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 					for (int dim = 1; dim <= array_type.rank; dim++) {
 						var array_len_lhs = get_array_length_cexpression (ma, dim);
 						var size = sizes[dim - 1];
-						ccode.add_expression (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode));
+						ccode.add_expression (new CCodeAssignment (array_len_lhs, get_cvalue (size)));
 					}
 
 					if (array_type.rank == 1 && f.is_internal_symbol ()) {
@@ -969,9 +969,9 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 				var field_st = f.parent_symbol as Struct;
 				if (field_st != null && !field_st.is_simple_type ()) {
-					this_access.ccodenode = new CCodeIdentifier ("(*self)");
+					set_cvalue (this_access, new CCodeIdentifier ("(*self)"));
 				} else {
-					this_access.ccodenode = new CCodeIdentifier ("self");
+					set_cvalue (this_access, new CCodeIdentifier ("self"));
 				}
 
 				var ma = new MemberAccess (this_access, f.name);
@@ -1001,7 +1001,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 				f.initializer.emit (this);
 
-				var rhs = (CCodeExpression) f.initializer.ccodenode;
+				var rhs = get_cvalue (f.initializer);
 
 				ccode.add_expression (new CCodeAssignment (lhs, rhs));
 
@@ -1040,7 +1040,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			if (f.initializer != null) {
 				f.initializer.emit (this);
 
-				var init = (CCodeExpression) f.initializer.ccodenode;
+				var init = get_cvalue (f.initializer);
 				if (is_constant_ccode_expression (init)) {
 					var_decl.initializer = init;
 				}
@@ -1111,7 +1111,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			}
 
 			if (f.initializer != null) {
-				var rhs = (CCodeExpression) f.initializer.ccodenode;
+				var rhs = get_cvalue (f.initializer);
 				if (!is_constant_ccode_expression (rhs)) {
 					if (f.parent_symbol is Class) {
 						if (f.initializer is InitializerList) {
@@ -1139,7 +1139,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 							for (int dim = 1; dim <= array_type.rank; dim++) {
 								var array_len_lhs = get_array_length_cexpression (ma, dim);
 								var size = sizes[dim - 1];
-								ccode.add_expression (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode));
+								ccode.add_expression (new CCodeAssignment (array_len_lhs, get_cvalue (size)));
 							}
 						}
 					} else {
@@ -1969,12 +1969,12 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		}
 	
 		CCodeExpression rhs = null;
-		if (local.initializer != null && local.initializer.ccodenode != null) {
+		if (local.initializer != null && get_cvalue (local.initializer) != null) {
 			var ma = new MemberAccess.simple (local.name);
 			ma.symbol_reference = local;
 			ma.value_type = local.variable_type.copy ();
 
-			rhs = (CCodeExpression) local.initializer.ccodenode;
+			rhs = get_cvalue (local.initializer);
 
 			if (local.variable_type is ArrayType) {
 				var array_type = (ArrayType) local.variable_type;
@@ -2122,7 +2122,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 				var ccopy = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
 				ccopy.add_argument (get_variable_cexpression (local.name));
-				ccopy.add_argument ((CCodeExpression) local.initializer.ccodenode);
+				ccopy.add_argument (get_cvalue (local.initializer));
 				ccopy.add_argument (size);
 				ccode.add_expression (ccopy);
 			}
@@ -2155,7 +2155,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 						}
 					}
 
-					var cexpr = (CCodeExpression) expr.ccodenode;
+					var cexpr = get_cvalue (expr);
 
 					string ctype = field.get_ctype ();
 					if (ctype != null) {
@@ -2165,7 +2165,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 					clist.append (cexpr);
 				}
 
-				list.ccodenode = clist;
+				set_cvalue (list, clist);
 			} else {
 				// used as expression
 				var temp_decl = get_temp_variable (list.target_type, false, list);
@@ -2187,7 +2187,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 						}
 					}
 
-					var cexpr = (CCodeExpression) expr.ccodenode;
+					var cexpr = get_cvalue (expr);
 
 					string ctype = field.get_ctype ();
 					if (ctype != null) {
@@ -2199,14 +2199,14 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				}
 
 				ccomma.append_expression (instance);
-				list.ccodenode = ccomma;
+				set_cvalue (list, ccomma);
 			}
 		} else {
 			var clist = new CCodeInitializerList ();
 			foreach (Expression expr in list.get_initializers ()) {
-				clist.append ((CCodeExpression) expr.ccodenode);
+				clist.append (get_cvalue (expr));
 			}
-			list.ccodenode = clist;
+			set_cvalue (list, clist);
 		}
 	}
 
@@ -3006,7 +3006,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 		var local_decl = expr.parent_node as LocalVariable;
 		if (local_decl != null && has_simple_struct_initializer (local_decl)) {
-			expr_list.append_expression ((CCodeExpression) expr.ccodenode);
+			expr_list.append_expression (get_cvalue (expr));
 		} else {
 			var expr_type = expr.value_type;
 			if (expr.target_type != null) {
@@ -3016,7 +3016,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			full_expr_var = get_temp_variable (expr_type, true, expr, false);
 			emit_temp_var (full_expr_var);
 		
-			expr_list.append_expression (new CCodeAssignment (get_variable_cexpression (full_expr_var.name), (CCodeExpression) expr.ccodenode));
+			expr_list.append_expression (new CCodeAssignment (get_variable_cexpression (full_expr_var.name), get_cvalue (expr)));
 		}
 		
 		foreach (LocalVariable local in temp_ref_vars) {
@@ -3030,7 +3030,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			expr_list.append_expression (get_variable_cexpression (full_expr_var.name));
 		}
 
-		expr.ccodenode = expr_list;
+		set_cvalue (expr, expr_list);
 		
 		temp_ref_vars.clear ();
 	}
@@ -3095,7 +3095,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			return;
 		}
 
-		ccode.add_expression ((CCodeExpression) stmt.expression.ccodenode);
+		ccode.add_expression (get_cvalue (stmt.expression));
 
 		/* free temporary objects and handle errors */
 
@@ -3238,7 +3238,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			var return_expr_decl = get_temp_variable (stmt.return_expression.value_type, true, stmt, false);
 
 			var ccomma = new CCodeCommaExpression ();
-			ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (return_expr_decl.name), (CCodeExpression) stmt.return_expression.ccodenode));
+			ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (return_expr_decl.name), get_cvalue (stmt.return_expression)));
 
 			var array_type = (ArrayType) current_return_type;
 
@@ -3253,7 +3253,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 			ccomma.append_expression (get_variable_cexpression (return_expr_decl.name));
 
-			stmt.return_expression.ccodenode = ccomma;
+			set_cvalue (stmt.return_expression, ccomma);
 			emit_temp_var (return_expr_decl);
 		} else if ((current_method != null || current_property_accessor != null) && current_return_type is DelegateType) {
 			var delegate_type = (DelegateType) current_return_type;
@@ -3261,7 +3261,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				var return_expr_decl = get_temp_variable (stmt.return_expression.value_type, true, stmt, false);
 
 				var ccomma = new CCodeCommaExpression ();
-				ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (return_expr_decl.name), (CCodeExpression) stmt.return_expression.ccodenode));
+				ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (return_expr_decl.name), get_cvalue (stmt.return_expression)));
 
 				var target_l = get_result_cexpression (get_delegate_target_cname ("result"));
 				if (current_method == null || !current_method.coroutine) {
@@ -3280,7 +3280,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 				ccomma.append_expression (get_variable_cexpression (return_expr_decl.name));
 
-				stmt.return_expression.ccodenode = ccomma;
+				set_cvalue (stmt.return_expression, ccomma);
 				emit_temp_var (return_expr_decl);
 			}
 		}
@@ -3291,7 +3291,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			if (current_return_type.is_real_non_null_struct_type () && (current_method == null || !current_method.coroutine)) {
 				result_lhs = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, result_lhs);
 			}
-			ccode.add_expression (new CCodeAssignment (result_lhs, (CCodeExpression) stmt.return_expression.ccodenode));
+			ccode.add_expression (new CCodeAssignment (result_lhs, get_cvalue (stmt.return_expression)));
 		}
 
 		// free local variables
@@ -3333,9 +3333,9 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			if (inner_node  == null) {
 				l = new CCodeIdentifier ("self");
 			} else if (resource.symbol_reference.parent_symbol != current_type_symbol) {
-				l = generate_instance_cast ((CCodeExpression) inner_node.ccodenode, parent);
+				l = generate_instance_cast (get_cvalue (inner_node), parent);
 			} else {
-				l = (CCodeExpression) inner_node.ccodenode;
+				l = get_cvalue (inner_node);
 			}
 
 			l = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (l, "priv"), get_symbol_lock_name (resource.symbol_reference.name));
@@ -3388,28 +3388,28 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		}
 
 		var ccall = new CCodeFunctionCall (get_destroy_func_expression (type));
-		ccall.add_argument ((CCodeExpression) stmt.expression.ccodenode);
+		ccall.add_argument (get_cvalue (stmt.expression));
 		ccode.add_expression (ccall);
 	}
 
 	public override void visit_expression (Expression expr) {
-		if (expr.ccodenode != null && !expr.lvalue) {
+		if (get_cvalue (expr) != null && !expr.lvalue) {
 			if (expr.formal_value_type is GenericType && !(expr.value_type is GenericType)) {
 				var st = expr.formal_value_type.type_parameter.parent_symbol.parent_symbol as Struct;
 				if (expr.formal_value_type.type_parameter.parent_symbol != garray_type &&
 				    (st == null || st.get_cname () != "va_list")) {
 					// GArray and va_list don't use pointer-based generics
-					expr.ccodenode = convert_from_generic_pointer ((CCodeExpression) expr.ccodenode, expr.value_type);
+					set_cvalue (expr, convert_from_generic_pointer (get_cvalue (expr), expr.value_type));
 				}
 			}
 
 			// memory management, implicit casts, and boxing/unboxing
-			expr.ccodenode = transform_expression ((CCodeExpression) expr.ccodenode, expr.value_type, expr.target_type, expr);
+			set_cvalue (expr, transform_expression (get_cvalue (expr), expr.value_type, expr.target_type, expr));
 
 			if (expr.formal_target_type is GenericType && !(expr.target_type is GenericType)) {
 				if (expr.formal_target_type.type_parameter.parent_symbol != garray_type) {
 					// GArray doesn't use pointer-based generics
-					expr.ccodenode = convert_to_generic_pointer ((CCodeExpression) expr.ccodenode, expr.target_type);
+					set_cvalue (expr, convert_to_generic_pointer (get_cvalue (expr), expr.target_type));
 				}
 			}
 		}
@@ -3417,23 +3417,23 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 	public override void visit_boolean_literal (BooleanLiteral expr) {
 		if (context.profile == Profile.GOBJECT) {
-			expr.ccodenode = new CCodeConstant (expr.value ? "TRUE" : "FALSE");
+			set_cvalue (expr, new CCodeConstant (expr.value ? "TRUE" : "FALSE"));
 		} else {
 			cfile.add_include ("stdbool.h");
-			expr.ccodenode = new CCodeConstant (expr.value ? "true" : "false");
+			set_cvalue (expr, new CCodeConstant (expr.value ? "true" : "false"));
 		}
 	}
 
 	public override void visit_character_literal (CharacterLiteral expr) {
 		if (expr.get_char () >= 0x20 && expr.get_char () < 0x80) {
-			expr.ccodenode = new CCodeConstant (expr.value);
+			set_cvalue (expr, new CCodeConstant (expr.value));
 		} else {
-			expr.ccodenode = new CCodeConstant ("%uU".printf (expr.get_char ()));
+			set_cvalue (expr, new CCodeConstant ("%uU".printf (expr.get_char ())));
 		}
 	}
 
 	public override void visit_integer_literal (IntegerLiteral expr) {
-		expr.ccodenode = new CCodeConstant (expr.value + expr.type_suffix);
+		set_cvalue (expr, new CCodeConstant (expr.value + expr.type_suffix));
 	}
 
 	public override void visit_real_literal (RealLiteral expr) {
@@ -3450,11 +3450,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				c_literal += ".";
 			}
 		}
-		expr.ccodenode = new CCodeConstant (c_literal);
+		set_cvalue (expr, new CCodeConstant (c_literal));
 	}
 
 	public override void visit_string_literal (StringLiteral expr) {
-		expr.ccodenode = new CCodeConstant.string (expr.value.replace ("\n", "\\n"));
+		set_cvalue (expr, new CCodeConstant.string (expr.value.replace ("\n", "\\n")));
 	}
 
 	public override void visit_regex_literal (RegexLiteral expr) {
@@ -3520,14 +3520,14 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		var regex_const = new CCodeConstant ("_thread_safe_regex_init (&%s, \"%s\", %s)".printf (cname, re, flags));
 
 		cfile.add_constant_declaration (cdecl);
-		expr.ccodenode = regex_const;
+		set_cvalue (expr, regex_const);
 	}
 
 	public override void visit_null_literal (NullLiteral expr) {
 		if (context.profile != Profile.GOBJECT) {
 			cfile.add_include ("stddef.h");
 		}
-		expr.ccodenode = new CCodeConstant ("NULL");
+		set_cvalue (expr, new CCodeConstant ("NULL"));
 	}
 
 	public virtual string get_delegate_target_cname (string delegate_cname) {
@@ -3551,7 +3551,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			this_access = new CCodeIdentifier ("self");
 		}
 
-		expr.ccodenode = generate_instance_cast (this_access, expr.value_type.data_type);
+		set_cvalue (expr, generate_instance_cast (this_access, expr.value_type.data_type));
 	}
 
 	public override void visit_postfix_expression (PostfixExpression expr) {
@@ -3565,7 +3565,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			// assign current value to temp variable
 			var temp_decl = get_temp_variable (prop.property_type, true, expr, false);
 			emit_temp_var (temp_decl);
-			ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_decl.name), (CCodeExpression) expr.inner.ccodenode));
+			ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_decl.name), get_cvalue (expr.inner)));
 			
 			// increment/decrement property
 			var op = expr.increment ? CCodeBinaryOperator.PLUS : CCodeBinaryOperator.MINUS;
@@ -3576,13 +3576,13 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			// return previous value
 			ccomma.append_expression (get_variable_cexpression (temp_decl.name));
 			
-			expr.ccodenode = ccomma;
+			set_cvalue (expr, ccomma);
 			return;
 		}
 	
 		var op = expr.increment ? CCodeUnaryOperator.POSTFIX_INCREMENT : CCodeUnaryOperator.POSTFIX_DECREMENT;
 	
-		expr.ccodenode = new CCodeUnaryExpression (op, (CCodeExpression) expr.inner.ccodenode);
+		set_cvalue (expr, new CCodeUnaryExpression (op, get_cvalue (expr.inner)));
 	}
 	
 	private MemberAccess? find_property_access (Expression expr) {
@@ -3770,7 +3770,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		if (!(expression_type is ArrayType) && expr != null && expr.is_non_null ()
 		    && !is_ref_function_void (expression_type)) {
 			// expression is non-null
-			ccall.add_argument ((CCodeExpression) expr.ccodenode);
+			ccall.add_argument (get_cvalue (expr));
 			
 			return ccall;
 		} else {
@@ -4019,7 +4019,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		} else if (expr.type_reference.data_type == glist_type ||
 		           expr.type_reference.data_type == gslist_type) {
 			// NULL is an empty list
-			expr.ccodenode = new CCodeConstant ("NULL");
+			set_cvalue (expr, new CCodeConstant ("NULL"));
 		} else if (expr.symbol_reference is Method) {
 			// use creation method
 			var m = (Method) expr.symbol_reference;
@@ -4078,7 +4078,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			int arg_pos;
 			Iterator<FormalParameter> params_it = params.iterator ();
 			foreach (Expression arg in expr.get_argument_list ()) {
-				CCodeExpression cexpr = (CCodeExpression) arg.ccodenode;
+				CCodeExpression cexpr = get_cvalue (arg);
 				FormalParameter param = null;
 				if (params_it.next ()) {
 					param = params_it.get ();
@@ -4140,7 +4140,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				 * parameter yet */
 				param.initializer.emit (this);
 			
-				carg_map.set (get_param_pos (param.cparameter_position), (CCodeExpression) param.initializer.ccodenode);
+				carg_map.set (get_param_pos (param.cparameter_position), get_cvalue (param.initializer));
 				i++;
 			}
 
@@ -4204,7 +4204,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			creation_call.add_argument (new CCodeIdentifier (ecode.get_cname ()));
 
 			foreach (Expression arg in expr.get_argument_list ()) {
-				creation_call.add_argument ((CCodeExpression) arg.ccodenode);
+				creation_call.add_argument (get_cvalue (arg));
 			}
 
 			creation_expr = creation_call;
@@ -4215,7 +4215,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		var local = expr.parent_node as LocalVariable;
 		if (local != null && has_simple_struct_initializer (local)) {
 			// no comma expression necessary
-			expr.ccodenode = creation_expr;
+			set_cvalue (expr, creation_expr);
 		} else if (instance != null) {
 			var ccomma = new CCodeCommaExpression ();
 
@@ -4236,7 +4236,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 					} else {
 						lhs = new CCodeMemberAccess.pointer (typed_inst, f.get_cname ());
 					}
-					ccomma.append_expression (new CCodeAssignment (lhs, (CCodeExpression) init.initializer.ccodenode));
+					ccomma.append_expression (new CCodeAssignment (lhs, get_cvalue (init.initializer)));
 
 					if (f.variable_type is ArrayType && !f.no_array_length) {
 						var array_type = (ArrayType) f.variable_type;
@@ -4267,17 +4267,17 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				} else if (init.symbol_reference is Property) {
 					var inst_ma = new MemberAccess.simple ("new");
 					inst_ma.value_type = expr.type_reference;
-					inst_ma.ccodenode = instance;
+					set_cvalue (inst_ma, instance);
 					var ma = new MemberAccess (inst_ma, init.name);
-					ccomma.append_expression (get_property_set_call ((Property) init.symbol_reference, ma, (CCodeExpression) init.initializer.ccodenode));
+					ccomma.append_expression (get_property_set_call ((Property) init.symbol_reference, ma, get_cvalue (init.initializer)));
 				}
 			}
 
 			ccomma.append_expression (instance);
 
-			expr.ccodenode = ccomma;
+			set_cvalue (expr, ccomma);
 		} else if (creation_expr != null) {
-			expr.ccodenode = creation_expr;
+			set_cvalue (expr, creation_expr);
 		}
 	}
 
@@ -4323,11 +4323,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 		var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
 		csizeof.add_argument (new CCodeIdentifier (expr.type_reference.get_cname ()));
-		expr.ccodenode = csizeof;
+		set_cvalue (expr, csizeof);
 	}
 
 	public override void visit_typeof_expression (TypeofExpression expr) {
-		expr.ccodenode = get_type_id_expression (expr.type_reference);
+		set_cvalue (expr, get_type_id_expression (expr.type_reference));
 	}
 
 	public override void visit_unary_expression (UnaryExpression expr) {
@@ -4351,7 +4351,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		} else {
 			assert_not_reached ();
 		}
-		expr.ccodenode = new CCodeUnaryExpression (op, (CCodeExpression) expr.inner.ccodenode);
+		set_cvalue (expr, new CCodeUnaryExpression (op, get_cvalue (expr.inner)));
 	}
 
 	public CCodeExpression? try_cast_value_to_type (CCodeExpression ccodeexpr, DataType from, DataType to, Expression? expr = null) {
@@ -4458,15 +4458,15 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 	}
 
 	public override void visit_cast_expression (CastExpression expr) {
-		var valuecast = try_cast_value_to_type ((CCodeExpression) expr.inner.ccodenode, expr.inner.value_type, expr.type_reference, expr);
+		var valuecast = try_cast_value_to_type (get_cvalue (expr.inner), expr.inner.value_type, expr.type_reference, expr);
 		if (valuecast != null) {
-			expr.ccodenode = valuecast;
+			set_cvalue (expr, valuecast);
 			return;
 		}
 
-		var variantcast = try_cast_variant_to_type ((CCodeExpression) expr.inner.ccodenode, expr.inner.value_type, expr.type_reference, expr);
+		var variantcast = try_cast_variant_to_type (get_cvalue (expr.inner), expr.inner.value_type, expr.type_reference, expr);
 		if (variantcast != null) {
-			expr.ccodenode = variantcast;
+			set_cvalue (expr, variantcast);
 			return;
 		}
 
@@ -4483,7 +4483,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				emit_temp_var (temp_decl);
 
 				var ctemp = get_variable_cexpression (temp_decl.name);
-				var cinit = new CCodeAssignment (ctemp, (CCodeExpression) expr.inner.ccodenode);
+				var cinit = new CCodeAssignment (ctemp, get_cvalue (expr.inner));
 				var ccheck = create_type_check (ctemp, expr.type_reference);
 				var ccast = new CCodeCastExpression (ctemp, expr.type_reference.get_cname ());
 				var cnull = new CCodeConstant ("NULL");
@@ -4491,9 +4491,9 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				ccomma.append_expression (cinit);
 				ccomma.append_expression (new CCodeConditionalExpression (ccheck, ccast, cnull));
 	
-				expr.ccodenode = ccomma;
+				set_cvalue (expr, ccomma);
 			} else {
-				expr.ccodenode = generate_instance_cast ((CCodeExpression) expr.inner.ccodenode, expr.type_reference.data_type);
+				set_cvalue (expr, generate_instance_cast (get_cvalue (expr.inner), expr.type_reference.data_type));
 			}
 		} else {
 			if (expr.is_silent_cast) {
@@ -4510,33 +4510,33 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				}
 			}
 
-			var innercexpr = (CCodeExpression) expr.inner.ccodenode;
+			var innercexpr = get_cvalue (expr.inner);
 			if (expr.type_reference.data_type is Struct && !expr.type_reference.nullable &&
 				expr.inner.value_type.data_type is Struct && expr.inner.value_type.nullable) {
 				// nullable integer or float or boolean or struct cast to non-nullable
 				innercexpr = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, innercexpr);
 			}
-			expr.ccodenode = new CCodeCastExpression (innercexpr, expr.type_reference.get_cname ());
+			set_cvalue (expr, new CCodeCastExpression (innercexpr, expr.type_reference.get_cname ()));
 		}
 	}
 	
 	public override void visit_named_argument (NamedArgument expr) {
-		expr.ccodenode = expr.inner.ccodenode;
+		set_cvalue (expr, get_cvalue (expr.inner));
 	}
 
 	public override void visit_pointer_indirection (PointerIndirection expr) {
-		expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, (CCodeExpression) expr.inner.ccodenode);
+		set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, get_cvalue (expr.inner)));
 	}
 
 	public override void visit_addressof_expression (AddressofExpression expr) {
-		if (expr.inner.ccodenode is CCodeCommaExpression) {
-			var ccomma = expr.inner.ccodenode as CCodeCommaExpression;
+		if (get_cvalue (expr.inner) is CCodeCommaExpression) {
+			var ccomma = get_cvalue (expr.inner) as CCodeCommaExpression;
 			var inner = ccomma.get_inner ();
 			var last = inner.get (inner.size - 1);
 			ccomma.set_expression (inner.size - 1, new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, (CCodeExpression) last));
-			expr.ccodenode = ccomma;
+			set_cvalue (expr, ccomma);
 		} else {
-			expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, (CCodeExpression) expr.inner.ccodenode);
+			set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue (expr.inner)));
 		}
 	}
 
@@ -4547,15 +4547,15 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		emit_temp_var (temp_decl);
 		var cvar = get_variable_cexpression (temp_decl.name);
 
-		ccomma.append_expression (new CCodeAssignment (cvar, (CCodeExpression) expr.inner.ccodenode));
-		ccomma.append_expression (new CCodeAssignment ((CCodeExpression) expr.inner.ccodenode, new CCodeConstant ("NULL")));
+		ccomma.append_expression (new CCodeAssignment (cvar, get_cvalue (expr.inner)));
+		ccomma.append_expression (new CCodeAssignment (get_cvalue (expr.inner), new CCodeConstant ("NULL")));
 		ccomma.append_expression (cvar);
-		expr.ccodenode = ccomma;
+		set_cvalue (expr, ccomma);
 	}
 
 	public override void visit_binary_expression (BinaryExpression expr) {
-		var cleft = (CCodeExpression) expr.left.ccodenode;
-		var cright = (CCodeExpression) expr.right.ccodenode;
+		var cleft = get_cvalue (expr.left);
+		var cright = get_cvalue (expr.right);
 
 		CCodeExpression? left_chain = null;
 		if (expr.chained) {
@@ -4565,11 +4565,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			emit_temp_var (temp_decl);
 			var cvar = get_variable_cexpression (temp_decl.name);
 			var ccomma = new CCodeCommaExpression ();
-			var clbe = (CCodeBinaryExpression) lbe.ccodenode;
+			var clbe = (CCodeBinaryExpression) get_cvalue (lbe);
 			if (lbe.chained) {
 				clbe = (CCodeBinaryExpression) clbe.right;
 			}
-			ccomma.append_expression (new CCodeAssignment (cvar, (CCodeExpression)lbe.right.ccodenode));
+			ccomma.append_expression (new CCodeAssignment (cvar, get_cvalue (lbe.right)));
 			clbe.right = get_variable_cexpression (temp_decl.name);
 			ccomma.append_expression (cleft);
 			cleft = cvar;
@@ -4591,14 +4591,14 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				var ccall = new CCodeFunctionCall (new CCodeIdentifier ("fmod"));
 				ccall.add_argument (cleft);
 				ccall.add_argument (cright);
-				expr.ccodenode = ccall;
+				set_cvalue (expr, ccall);
 				return;
 			} else if (expr.value_type.equals (float_type)) {
 				cfile.add_include ("math.h");
 				var ccall = new CCodeFunctionCall (new CCodeIdentifier ("fmodf"));
 				ccall.add_argument (cleft);
 				ccall.add_argument (cright);
-				expr.ccodenode = ccall;
+				set_cvalue (expr, ccall);
 				return;
 			} else {
 				op = CCodeBinaryOperator.MOD;
@@ -4640,9 +4640,9 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				} else {
 					node.add_argument (cleft);
 				}
-				expr.ccodenode = node;
+				set_cvalue (expr, node);
 			} else {
-				expr.ccodenode = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeBinaryExpression (CCodeBinaryOperator.BITWISE_AND, cright, cleft), cleft);
+				set_cvalue (expr, new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeBinaryExpression (CCodeBinaryOperator.BITWISE_AND, cright, cleft), cleft));
 			}
 			return;
 		} else {
@@ -4697,7 +4697,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 						assert_not_reached ();
 					}
 
-					expr.ccodenode = new CCodeConstant ("%s %s".printf (left, right));
+					set_cvalue (expr, new CCodeConstant ("%s %s".printf (left, right)));
 					return;
 				} else {
 					if (context.profile == Profile.POSIX) {
@@ -4719,14 +4719,14 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 						strcat.add_argument(strcpy);
 						strcat.add_argument(cright);
-						expr.ccodenode = strcat;
+						set_cvalue (expr, strcat);
 					} else {
 						// convert to g_strconcat (a, b, NULL)
 						var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_strconcat"));
 						ccall.add_argument (cleft);
 						ccall.add_argument (cright);
 						ccall.add_argument (new CCodeConstant("NULL"));
-						expr.ccodenode = ccall;
+						set_cvalue (expr, ccall);
 					}
 					return;
 				}
@@ -4745,9 +4745,9 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 			}
 		}
 
-		expr.ccodenode = new CCodeBinaryExpression (op, cleft, cright);
+		set_cvalue (expr, new CCodeBinaryExpression (op, cleft, cright));
 		if (left_chain != null) {
-			expr.ccodenode = new CCodeBinaryExpression (CCodeBinaryOperator.AND, left_chain, (CCodeExpression) expr.ccodenode);
+			set_cvalue (expr, new CCodeBinaryExpression (CCodeBinaryOperator.AND, left_chain, get_cvalue (expr)));
 		}
 	}
 
@@ -4848,8 +4848,8 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 	public override void visit_type_check (TypeCheck expr) {
 		generate_type_declaration (expr.type_reference, cfile);
 
-		expr.ccodenode = create_type_check (expr.expression.ccodenode, expr.type_reference);
-		if (expr.ccodenode is CCodeInvalidExpression) {
+		set_cvalue (expr, create_type_check (get_cvalue (expr.expression), expr.type_reference));
+		if (get_cvalue (expr) is CCodeInvalidExpression) {
 			Report.error (expr.source_reference, "type check expressions not supported for compact classes, structs, and enums");
 		}
 	}
@@ -4861,7 +4861,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 		l.accept_children (this);
 
-		l.ccodenode = new CCodeIdentifier (l.method.get_cname ());
+		set_cvalue (l, new CCodeIdentifier (l.method.get_cname ()));
 	}
 
 	public CCodeExpression convert_from_generic_pointer (CCodeExpression cexpr, DataType actual_type) {
@@ -5435,6 +5435,14 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 		}
 	}
 
+	public CCodeExpression? get_cvalue (Expression expr) {
+		return (CCodeExpression) expr.ccodenode;
+	}
+
+	public void set_cvalue (Expression expr, CCodeExpression? cvalue) {
+		expr.ccodenode = cvalue;
+	}
+
 	public CCodeNode? get_ccodenode (CodeNode node) {
 		if (node.ccodenode == null) {
 			node.emit (this);
@@ -5448,7 +5456,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 	public void create_postcondition_statement (Expression postcondition) {
 		var cassert = new CCodeFunctionCall (new CCodeIdentifier ("g_warn_if_fail"));
 
-		cassert.add_argument ((CCodeExpression) postcondition.ccodenode);
+		cassert.add_argument (get_cvalue (postcondition));
 
 		ccode.add_expression (cassert);
 	}
@@ -5490,7 +5498,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 
 					var this_access = new MemberAccess.simple ("this");
 					this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
-					this_access.ccodenode = new CCodeIdentifier ("(*self)");
+					set_cvalue (this_access, new CCodeIdentifier ("(*self)"));
 
 					var ma = new MemberAccess (this_access, f.name);
 					ma.symbol_reference = f;
@@ -5527,7 +5535,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
 				if (requires_copy (f.variable_type))  {
 					var this_access = new MemberAccess.simple ("this");
 					this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
-					this_access.ccodenode = new CCodeIdentifier ("(*self)");
+					set_cvalue (this_access, new CCodeIdentifier ("(*self)"));
 					var ma = new MemberAccess (this_access, f.name);
 					ma.symbol_reference = f;
 					copy = get_ref_cexpression (f.variable_type, copy, ma, f);
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index 0793d33..46a4b43 100644
--- a/codegen/valaccodecontrolflowmodule.vala
+++ b/codegen/valaccodecontrolflowmodule.vala
@@ -26,7 +26,7 @@ using GLib;
 
 public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 	public override void visit_if_statement (IfStatement stmt) {
-		ccode.open_if ((CCodeExpression) stmt.condition.ccodenode);
+		ccode.open_if (get_cvalue (stmt.condition));
 
 		stmt.true_statement.emit (this);
 
@@ -44,7 +44,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 		emit_temp_var (temp_var);
 
 		var ctemp = get_variable_cexpression (temp_var.name);
-		var cinit = new CCodeAssignment (ctemp, (CCodeExpression) stmt.expression.ccodenode);
+		var cinit = new CCodeAssignment (ctemp, get_cvalue (stmt.expression));
 		var czero = new CCodeConstant ("0");
 
 		var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
@@ -68,7 +68,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 
 			foreach (SwitchLabel label in section.get_labels ()) {
 				label.expression.emit (this);
-				var cexpr = (CCodeExpression) label.expression.ccodenode;
+				var cexpr = get_cvalue (label.expression);
 
 				if (is_constant_ccode_expression (cexpr)) {
 					var cname = "%s_label%d".printf (temp_var.name, label_count++);
@@ -104,7 +104,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 			CCodeBinaryExpression cor = null;
 			foreach (SwitchLabel label in section.get_labels ()) {
 				label.expression.emit (this);
-				var cexpr = (CCodeExpression) label.expression.ccodenode;
+				var cexpr = get_cvalue (label.expression);
 
 				if (is_constant_ccode_expression (cexpr)) {
 					var cname = new CCodeIdentifier ("%s_label%d".printf (temp_var.name, label_count++));
@@ -168,7 +168,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 			return;
 		}
 
-		ccode.open_switch ((CCodeExpression) stmt.expression.ccodenode);
+		ccode.open_switch (get_cvalue (stmt.expression));
 
 		foreach (SwitchSection section in stmt.get_sections ()) {
 			if (section.has_default_label ()) {
@@ -190,7 +190,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 
 			visit_end_full_expression (label.expression);
 
-			ccode.add_case ((CCodeExpression) label.expression.ccodenode);
+			ccode.add_case (get_cvalue (label.expression));
 		}
 	}
 
@@ -225,7 +225,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 			var ccolvardecl = new CCodeVariableDeclarator (collection_backup.name);
 			ccode.add_declaration (collection_type.get_cname (), ccolvardecl);
 		}
-		ccode.add_expression (new CCodeAssignment (get_variable_cexpression (collection_backup.name), (CCodeExpression) stmt.collection.ccodenode));
+		ccode.add_expression (new CCodeAssignment (get_variable_cexpression (collection_backup.name), get_cvalue (stmt.collection)));
 		
 		if (stmt.tree_can_fail && stmt.collection.tree_can_fail) {
 			// exception handling
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index fbdbbe5..9b20ebe 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -27,7 +27,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 		CCodeExpression pub_inst = null;
 	
 		if (expr.inner != null) {
-			pub_inst = (CCodeExpression) expr.inner.ccodenode;
+			pub_inst = get_cvalue (expr.inner);
 		}
 
 		if (expr.symbol_reference is Method) {
@@ -51,13 +51,13 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 					var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
 					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
 					
-					expr.ccodenode = new CCodeMemberAccess.pointer (vcast, m.vfunc_name);
+					set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, m.vfunc_name));
 					return;
 				} else if (m.base_interface_method != null) {
 					var base_iface = (Interface) m.base_interface_method.parent_symbol;
 					string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
 
-					expr.ccodenode = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.vfunc_name);
+					set_cvalue (expr, new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.vfunc_name));
 					return;
 				}
 			}
@@ -72,27 +72,27 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 						emit_temp_var (temp_var);
 						var ctemp = get_variable_cexpression (temp_var.name);
 						inst = new CCodeAssignment (ctemp, pub_inst);
-						expr.inner.ccodenode = ctemp;
+						set_cvalue (expr.inner, ctemp);
 					}
 					var base_class = (Class) m.base_method.parent_symbol;
 					var vclass = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (base_class.get_upper_case_cname (null))));
 					vclass.add_argument (inst);
-					expr.ccodenode = new CCodeMemberAccess.pointer (vclass, m.name);
+					set_cvalue (expr, new CCodeMemberAccess.pointer (vclass, m.name));
 				} else {
-					expr.ccodenode = new CCodeIdentifier (m.base_method.get_cname ());
+					set_cvalue (expr, new CCodeIdentifier (m.base_method.get_cname ()));
 				}
 			} else if (m.base_interface_method != null) {
-				expr.ccodenode = new CCodeIdentifier (m.base_interface_method.get_cname ());
+				set_cvalue (expr, new CCodeIdentifier (m.base_interface_method.get_cname ()));
 			} else if (m is CreationMethod) {
-				expr.ccodenode = new CCodeIdentifier (m.get_real_cname ());
+				set_cvalue (expr, new CCodeIdentifier (m.get_real_cname ()));
 			} else {
-				expr.ccodenode = new CCodeIdentifier (m.get_cname ());
+				set_cvalue (expr, new CCodeIdentifier (m.get_cname ()));
 			}
 		} else if (expr.symbol_reference is ArrayLengthField) {
 			if (expr.value_type is ArrayType && !(expr.parent_node is ElementAccess)) {
 				Report.error (expr.source_reference, "unsupported use of length field of multi-dimensional array");
 			}
-			expr.ccodenode = get_array_length_cexpression (expr.inner, 1);
+			set_cvalue (expr, get_array_length_cexpression (expr.inner, 1));
 		} else if (expr.symbol_reference is Field) {
 			var f = (Field) expr.symbol_reference;
 			if (f.binding == MemberBinding.INSTANCE) {
@@ -111,16 +111,16 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 					inst = pub_inst;
 				}
 				if (instance_target_type.data_type.is_reference_type () || (expr.inner != null && expr.inner.value_type is PointerType)) {
-					expr.ccodenode = new CCodeMemberAccess.pointer (inst, f.get_cname ());
+					set_cvalue (expr, new CCodeMemberAccess.pointer (inst, f.get_cname ()));
 				} else {
 					if (inst is CCodeCommaExpression) {
 						var ccomma = inst as CCodeCommaExpression;
 						var inner = ccomma.get_inner ();
 						var last = inner.get (inner.size - 1);
 						ccomma.set_expression (inner.size - 1, new CCodeMemberAccess (last, f.get_cname ()));
-						expr.ccodenode = ccomma;
+						set_cvalue (expr, ccomma);
 					} else {
-						expr.ccodenode = new CCodeMemberAccess (inst, f.get_cname ());
+						set_cvalue (expr, new CCodeMemberAccess (inst, f.get_cname ()));
 					}
 				}
 			} else if (f.binding == MemberBinding.CLASS) {
@@ -141,7 +141,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				} else {
 					// Accessing the field of an instance
 					var k = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_GET_CLASS"));
-					k.add_argument ((CCodeExpression) expr.inner.ccodenode);
+					k.add_argument (get_cvalue (expr.inner));
 					klass = k;
 				}
 				cast.add_argument (klass);
@@ -149,22 +149,22 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				if (f.access == SymbolAccessibility.PRIVATE) {
 					var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS_PRIVATE".printf (cl.get_upper_case_cname ())));
 					ccall.add_argument (klass);
-					expr.ccodenode = new CCodeMemberAccess.pointer (ccall, f.get_cname ());
+					set_cvalue (expr, new CCodeMemberAccess.pointer (ccall, f.get_cname ()));
 				} else {
-					expr.ccodenode = new CCodeMemberAccess.pointer (cast, f.get_cname ());
+					set_cvalue (expr, new CCodeMemberAccess.pointer (cast, f.get_cname ()));
 				}
 
 			} else {
 				generate_field_declaration (f, cfile);
 
-				expr.ccodenode = new CCodeIdentifier (f.get_cname ());
+				set_cvalue (expr, new CCodeIdentifier (f.get_cname ()));
 			}
 		} else if (expr.symbol_reference is EnumValue) {
 			var ev = (EnumValue) expr.symbol_reference;
 
 			generate_enum_declaration ((Enum) ev.parent_symbol, cfile);
 
-			expr.ccodenode = new CCodeConstant (ev.get_cname ());
+			set_cvalue (expr, new CCodeConstant (ev.get_cname ()));
 		} else if (expr.symbol_reference is Constant) {
 			var c = (Constant) expr.symbol_reference;
 
@@ -175,18 +175,18 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			string fn = c.get_full_name ();
 			if (fn == "GLib.Log.FILE") {
 				string s = Path.get_basename (expr.source_reference.file.filename);
-				expr.ccodenode = new CCodeConstant ("\"%s\"".printf (s));
+				set_cvalue (expr, new CCodeConstant ("\"%s\"".printf (s)));
 			} else if (fn == "GLib.Log.LINE") {
 				int i = expr.source_reference.first_line;
-				expr.ccodenode = new CCodeConstant ("%d".printf (i));
+				set_cvalue (expr, new CCodeConstant ("%d".printf (i)));
 			} else if (fn == "GLib.Log.METHOD") {
 				string s = "";
 				if (current_method != null) {
 					s = current_method.get_full_name ();
 				}
-				expr.ccodenode = new CCodeConstant ("\"%s\"".printf (s));
+				set_cvalue (expr, new CCodeConstant ("\"%s\"".printf (s)));
 			} else {
-				expr.ccodenode = new CCodeIdentifier (c.get_cname ());
+				set_cvalue (expr, new CCodeIdentifier (c.get_cname ()));
 			}
 		} else if (expr.symbol_reference is Property) {
 			var prop = (Property) expr.symbol_reference;
@@ -210,16 +210,16 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
 					
 					var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "get_%s".printf (prop.name)));
-					ccall.add_argument ((CCodeExpression) expr.inner.ccodenode);
-					expr.ccodenode = ccall;
+					ccall.add_argument (get_cvalue (expr.inner));
+					set_cvalue (expr, ccall);
 					return;
 				} else if (prop.base_interface_property != null) {
 					var base_iface = (Interface) prop.base_interface_property.parent_symbol;
 					string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
 
 					var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), "get_%s".printf (prop.name)));
-					ccall.add_argument ((CCodeExpression) expr.inner.ccodenode);
-					expr.ccodenode = ccall;
+					ccall.add_argument (get_cvalue (expr.inner));
+					set_cvalue (expr, ccall);
 					return;
 				}
 			}
@@ -233,7 +233,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			    !(prop.property_type is ArrayType || prop.property_type is DelegateType)) {
 				CCodeExpression inst;
 				inst = new CCodeMemberAccess.pointer (pub_inst, "priv");
-				expr.ccodenode = new CCodeMemberAccess.pointer (inst, prop.field.get_cname());
+				set_cvalue (expr, new CCodeMemberAccess.pointer (inst, prop.field.get_cname()));
 			} else if (!prop.no_accessor_method) {
 				var base_property = prop;
 				if (prop.base_property != null) {
@@ -285,7 +285,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 					ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
 					ccomma.append_expression (ccall);
 					ccomma.append_expression (ctemp);
-					expr.ccodenode = ccomma;
+					set_cvalue (expr, ccomma);
 				} else {
 					var array_type = base_property.property_type as ArrayType;
 					if (array_type != null && !base_property.no_array_length) {
@@ -307,7 +307,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 						}
 					}
 
-					expr.ccodenode = ccall;
+					set_cvalue (expr, ccall);
 				}
 			} else {
 				var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_object_get"));
@@ -337,7 +337,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				ccall.add_argument (new CCodeConstant ("NULL"));
 				ccomma.append_expression (ccall);
 				ccomma.append_expression (ctemp);
-				expr.ccodenode = ccomma;
+				set_cvalue (expr, ccomma);
 			}
 		} else if (expr.symbol_reference is LocalVariable) {
 			var local = (LocalVariable) expr.symbol_reference;
@@ -345,16 +345,16 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				// used in postconditions
 				// structs are returned as out parameter
 				if (local.variable_type != null && local.variable_type.is_real_non_null_struct_type ()) {
-					expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result"));
+					set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("result")));
 				} else {
-					expr.ccodenode = new CCodeIdentifier ("result");
+					set_cvalue (expr, new CCodeIdentifier ("result"));
 				}
 			} else if (local.captured) {
 				// captured variables are stored on the heap
 				var block = (Block) local.parent_symbol;
-				expr.ccodenode = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (local.name));
+				set_cvalue (expr, new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (local.name)));
 			} else {
-				expr.ccodenode = get_variable_cexpression (local.name);
+				set_cvalue (expr, get_variable_cexpression (local.name));
 
 				if (expr.parent_node is ReturnStatement &&
 				    current_return_type.value_owned &&
@@ -375,13 +375,13 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			if (p.name == "this") {
 				if (current_method != null && current_method.coroutine) {
 					// use closure
-					expr.ccodenode = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "self");
+					set_cvalue (expr, new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "self"));
 				} else {
 					var st = current_type_symbol as Struct;
 					if (st != null && !st.is_simple_type ()) {
-						expr.ccodenode = new CCodeIdentifier ("(*self)");
+						set_cvalue (expr, new CCodeIdentifier ("(*self)"));
 					} else {
-						expr.ccodenode = new CCodeIdentifier ("self");
+						set_cvalue (expr, new CCodeIdentifier ("self"));
 					}
 				}
 			} else {
@@ -391,15 +391,15 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 					if (block == null) {
 						block = ((Method) p.parent_symbol).body;
 					}
-					expr.ccodenode = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (p.name));
+					set_cvalue (expr, new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (p.name)));
 				} else if (current_method != null && current_method.coroutine) {
 					// use closure
-					expr.ccodenode = get_variable_cexpression (p.name);
+					set_cvalue (expr, get_variable_cexpression (p.name));
 				} else {
 					var type_as_struct = p.variable_type.data_type as Struct;
 					if (p.direction != ParameterDirection.IN
 					    || (type_as_struct != null && !type_as_struct.is_simple_type () && !p.variable_type.nullable)) {
-						expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier (get_variable_cname (p.name)));
+						set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier (get_variable_cname (p.name))));
 					} else {
 						// Property setters of non simple structs shall replace all occurences
 						// of the "value" formal parameter with a dereferencing version of that
@@ -409,9 +409,9 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 						    current_property_accessor.value_parameter == p &&
 						    current_property_accessor.prop.property_type.is_real_struct_type () &&
 						    !current_property_accessor.prop.property_type.nullable) {
-							expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("value"));
+							set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("value")));
 						} else {
-							expr.ccodenode = get_variable_cexpression (p.name);
+							set_cvalue (expr, get_variable_cexpression (p.name));
 						}
 					}
 				}
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index b480a71..5c6d483 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -27,7 +27,7 @@ using GLib;
 public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 	public override void visit_method_call (MethodCall expr) {
 		// the bare function call
-		var ccall = new CCodeFunctionCall ((CCodeExpression) expr.call.ccodenode);
+		var ccall = new CCodeFunctionCall (get_cvalue (expr.call));
 
 		CCodeFunctionCall async_call = null;
 
@@ -53,7 +53,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			if (ma != null && ma.inner is BaseAccess && sig_type.signal_symbol.is_virtual) {
 				m = sig_type.signal_symbol.default_handler;
 			} else {
-				ccall = (CCodeFunctionCall) expr.call.ccodenode;
+				ccall = (CCodeFunctionCall) get_cvalue (expr.call);
 			}
 		} else if (itype is ObjectType) {
 			// constructor
@@ -178,11 +178,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			in_arg_map.set (get_param_pos (m.cinstance_parameter_position), instance);
 			out_arg_map.set (get_param_pos (m.cinstance_parameter_position), instance);
 		} else if (m != null && m.binding == MemberBinding.INSTANCE && !(m is CreationMethod)) {
-			instance = (CCodeExpression) ma.inner.ccodenode;
+			instance = get_cvalue (ma.inner);
 
 			if ((ma.member_name == "begin" || ma.member_name == "end") && ma.inner.symbol_reference == ma.symbol_reference) {
 				var inner_ma = (MemberAccess) ma.inner;
-				instance = (CCodeExpression) inner_ma.inner.ccodenode;
+				instance = get_cvalue (inner_ma.inner);
 			}
 
 			var st = m.parent_symbol as Struct;
@@ -228,7 +228,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			} else {
 				// Accessing the method of an instance
 				var k = new CCodeFunctionCall (new CCodeIdentifier ("G_OBJECT_GET_CLASS"));
-				k.add_argument ((CCodeExpression) ma.inner.ccodenode);
+				k.add_argument (get_cvalue (ma.inner));
 				klass = k;
 			}
 
@@ -327,7 +327,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 		int arg_pos;
 		Iterator<FormalParameter> params_it = params.iterator ();
 		foreach (Expression arg in expr.get_argument_list ()) {
-			CCodeExpression cexpr = (CCodeExpression) arg.ccodenode;
+			CCodeExpression cexpr = get_cvalue (arg);
 
 			var carg_map = in_arg_map;
 
@@ -456,7 +456,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
 						if (param.direction == ParameterDirection.REF) {
 							var crefcomma = new CCodeCommaExpression ();
-							crefcomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_var.name), (CCodeExpression) unary.inner.ccodenode));
+							crefcomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_var.name), get_cvalue (unary.inner)));
 							crefcomma.append_expression (cexpr);
 							cexpr = crefcomma;
 						}
@@ -480,12 +480,12 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 						cassign_comma.append_expression (new CCodeAssignment (get_variable_cexpression (assign_temp_var.name), transform_expression (get_variable_cexpression (temp_var.name), param.variable_type, unary.inner.value_type, arg)));
 
 						// unref old value
-						cassign_comma.append_expression (get_unref_expression ((CCodeExpression) unary.inner.ccodenode, arg.value_type, arg));
+						cassign_comma.append_expression (get_unref_expression (get_cvalue (unary.inner), arg.value_type, arg));
 
 						cassign_comma.append_expression (get_variable_cexpression (assign_temp_var.name));
 
 						// assign new value
-						ccomma.append_expression (new CCodeAssignment ((CCodeExpression) unary.inner.ccodenode, cassign_comma));
+						ccomma.append_expression (new CCodeAssignment (get_cvalue (unary.inner), cassign_comma));
 
 						// return value
 						if (ret_temp_var != null) {
@@ -740,9 +740,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 		}
 
 		if (m != null && m.binding == MemberBinding.INSTANCE && m.returns_modified_pointer) {
-			expr.ccodenode = new CCodeAssignment (instance, ccall_expr);
+			set_cvalue (expr, new CCodeAssignment (instance, ccall_expr));
 		} else {
-			expr.ccodenode = ccall_expr;
+			set_cvalue (expr, ccall_expr);
 		}
 
 		if (expr.is_yield_expression) {
@@ -759,7 +759,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			// FIXME: size expression must not be evaluated twice at runtime (potential side effects)
 			Iterator<Expression> arg_it = expr.get_argument_list ().iterator ();
 			arg_it.next ();
-			var new_size = (CCodeExpression) arg_it.get ().ccodenode;
+			var new_size = get_cvalue (arg_it.get ());
 
 			var temp_decl = get_temp_variable (int_type);
 			var temp_ref = get_variable_cexpression (temp_decl.name);
@@ -770,7 +770,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			cfile.add_include ("string.h");
 
 			var clen = get_array_length_cexpression (ma.inner, 1);
-			var celems = (CCodeExpression) ma.inner.ccodenode;
+			var celems = get_cvalue (ma.inner);
 			var array_type = (ArrayType) ma.inner.value_type;
 			var csizeof = new CCodeIdentifier ("sizeof (%s)".printf (array_type.element_type.get_cname ()));
 			var cdelta = new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, temp_ref, clen);
@@ -783,11 +783,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
 			var ccomma = new CCodeCommaExpression ();
 			ccomma.append_expression (new CCodeAssignment (temp_ref, new_size));
-			ccomma.append_expression ((CCodeExpression) expr.ccodenode);
+			ccomma.append_expression (get_cvalue (expr));
 			ccomma.append_expression (new CCodeConditionalExpression (ccheck, czero, new CCodeConstant ("NULL")));
 			ccomma.append_expression (new CCodeAssignment (get_array_length_cexpression (ma.inner, 1), temp_ref));
 
-			expr.ccodenode = ccomma;
+			set_cvalue (expr, ccomma);
 		}
 	}
 
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 7d850a9..55c31e4 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -953,7 +953,7 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
 	private void create_precondition_statement (CodeNode method_node, DataType ret_type, Expression precondition) {
 		var ccheck = new CCodeFunctionCall ();
 
-		ccheck.add_argument ((CCodeExpression) precondition.ccodenode);
+		ccheck.add_argument (get_cvalue (precondition));
 
 		if (method_node is CreationMethod) {
 			ccheck.call = new CCodeIdentifier ("g_return_val_if_fail");
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 424ab72..07f7525 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -259,7 +259,7 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
 				if (requires_copy (f.variable_type))  {
 					var this_access = new MemberAccess.simple ("this");
 					this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
-					this_access.ccodenode = new CCodeIdentifier ("(*self)");
+					set_cvalue (this_access, new CCodeIdentifier ("(*self)"));
 					var ma = new MemberAccess (this_access, f.name);
 					ma.symbol_reference = f;
 					copy = get_ref_cexpression (f.variable_type, copy, ma, f);
diff --git a/codegen/valadbusclientmodule.vala b/codegen/valadbusclientmodule.vala
index 89bcc76..cae3dc9 100644
--- a/codegen/valadbusclientmodule.vala
+++ b/codegen/valadbusclientmodule.vala
@@ -161,7 +161,7 @@ public class Vala.DBusClientModule : DBusModule {
 			cend_call.add_argument (new CCodeIdentifier ("proxy"));
 			cend_call.add_argument (new CCodeIdentifier ("call"));
 			cend_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("error")));
-			var creply_call = new CCodeFunctionCall ((CCodeExpression) callback.ccodenode);
+			var creply_call = new CCodeFunctionCall (get_cvalue (callback));
 			if (reply_method.binding != MemberBinding.STATIC) {
 				creply_call.add_argument (new CCodeIdentifier ("user_data"));
 			}
@@ -924,12 +924,12 @@ public class Vala.DBusClientModule : DBusModule {
 
 		var ccall = new CCodeFunctionCall (new CCodeIdentifier (type.type_symbol.get_lower_case_cprefix () + "dbus_proxy_new"));
 		connection.emit (this);
-		ccall.add_argument ((CCodeExpression) connection.ccodenode);
+		ccall.add_argument (get_cvalue (connection));
 		bus_name.emit (this);
-		ccall.add_argument ((CCodeExpression) bus_name.ccodenode);
+		ccall.add_argument (get_cvalue (bus_name));
 		object_path.emit (this);
-		ccall.add_argument ((CCodeExpression) object_path.ccodenode);
-		expr.ccodenode = ccall;
+		ccall.add_argument (get_cvalue (object_path));
+		set_cvalue (expr, ccall);
 	}
 
 	void generate_proxy_interface_init (Interface main_iface, Interface iface) {
@@ -1416,13 +1416,13 @@ public class Vala.DBusClientModule : DBusModule {
 			interface_name.emit (this);
 
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_get_all_function (mtype.method_symbol)));
-			ccall.add_argument ((CCodeExpression) instance.ccodenode);
-			ccall.add_argument ((CCodeExpression) interface_name.ccodenode);
+			ccall.add_argument (get_cvalue (instance));
+			ccall.add_argument (get_cvalue (interface_name));
 
 			current_method_inner_error = true;
 			ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression ("_inner_error_")));
 
-			expr.ccodenode = ccall;
+			set_cvalue (expr, ccall);
 			return;
 		}
 
@@ -1438,7 +1438,7 @@ public class Vala.DBusClientModule : DBusModule {
 
 		var qdata_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_get_qdata"));
 		type.emit (this);
-		qdata_call.add_argument ((CCodeExpression) type.ccodenode);
+		qdata_call.add_argument (get_cvalue (type));
 		qdata_call.add_argument (quark_call);
 
 		var get_type_call = new CCodeFunctionCall (new CCodeCastExpression (qdata_call, "GType (*)(void)"));
@@ -1447,18 +1447,18 @@ public class Vala.DBusClientModule : DBusModule {
 		ccall.add_argument (get_type_call);
 		ccall.add_argument (new CCodeConstant ("\"connection\""));
 		connection.emit (this);
-		ccall.add_argument ((CCodeExpression) connection.ccodenode);
+		ccall.add_argument (get_cvalue (connection));
 		ccall.add_argument (new CCodeConstant ("\"name\""));
 		bus_name.emit (this);
-		ccall.add_argument ((CCodeExpression) bus_name.ccodenode);
+		ccall.add_argument (get_cvalue (bus_name));
 		ccall.add_argument (new CCodeConstant ("\"path\""));
 		object_path.emit (this);
-		ccall.add_argument ((CCodeExpression) object_path.ccodenode);
+		ccall.add_argument (get_cvalue (object_path));
 		ccall.add_argument (new CCodeConstant ("\"interface\""));
 		interface_name.emit (this);
-		ccall.add_argument ((CCodeExpression) interface_name.ccodenode);
+		ccall.add_argument (get_cvalue (interface_name));
 		ccall.add_argument (new CCodeConstant ("NULL"));
-		expr.ccodenode = ccall;
+		set_cvalue (expr, ccall);
 	}
 
 	void generate_proxy_filter_function (Interface iface) {
diff --git a/codegen/valadbusservermodule.vala b/codegen/valadbusservermodule.vala
index e1325a5..cbf770d 100644
--- a/codegen/valadbusservermodule.vala
+++ b/codegen/valadbusservermodule.vala
@@ -1636,7 +1636,7 @@ public class Vala.DBusServerModule : DBusClientModule {
 		var ma = (MemberAccess) expr.call;
 
 		var raw_conn = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_connection_get_connection"));
-		raw_conn.add_argument ((CCodeExpression) ma.inner.ccodenode);
+		raw_conn.add_argument (get_cvalue (ma.inner));
 
 		var args_it = expr.get_argument_list ().iterator ();
 		args_it.next ();
@@ -1648,11 +1648,11 @@ public class Vala.DBusServerModule : DBusClientModule {
 		if (mtype.method_symbol.get_cname () == "dbus_g_connection_register_g_object") {
 			cregister.add_argument (raw_conn);
 		} else {
-			cregister.add_argument ((CCodeExpression) ma.inner.ccodenode);
+			cregister.add_argument (get_cvalue (ma.inner));
 		}
-		cregister.add_argument ((CCodeExpression) path_arg.ccodenode);
-		cregister.add_argument ((CCodeExpression) obj_arg.ccodenode);
-		expr.ccodenode = cregister;
+		cregister.add_argument (get_cvalue (path_arg));
+		cregister.add_argument (get_cvalue (obj_arg));
+		set_cvalue (expr, cregister);
 	}
 
 	bool type_implements_dbus_interface (ObjectTypeSymbol sym) {
diff --git a/codegen/valadovaarraymodule.vala b/codegen/valadovaarraymodule.vala
index 182ffce..ff9fd60 100644
--- a/codegen/valadovaarraymodule.vala
+++ b/codegen/valadovaarraymodule.vala
@@ -23,7 +23,7 @@
 public class Vala.DovaArrayModule : DovaMethodCallModule {
 	void append_initializer_list (CCodeCommaExpression ce, CCodeExpression name_cnode, InitializerList initializer_list, ref int i) {
 		foreach (Expression e in initializer_list.get_initializers ()) {
-			ce.append_expression (new CCodeAssignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), (CCodeExpression) e.ccodenode));
+			ce.append_expression (new CCodeAssignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), get_cvalue (e)));
 			i++;
 		}
 	}
@@ -44,7 +44,7 @@ public class Vala.DovaArrayModule : DovaMethodCallModule {
 
 			ce.append_expression (name_cnode);
 
-			expr.ccodenode = ce;
+			set_cvalue (expr, ce);
 
 			return;
 		}
@@ -55,18 +55,18 @@ public class Vala.DovaArrayModule : DovaMethodCallModule {
 		array_new.add_argument (get_type_id_expression (expr.element_type));
 
 		// length of new array
-		array_new.add_argument ((CCodeExpression) expr.get_sizes ().get (0).ccodenode);
+		array_new.add_argument (get_cvalue (expr.get_sizes ().get (0)));
 
-		expr.ccodenode = array_new;
+		set_cvalue (expr, array_new);
 	}
 
 	public override void visit_element_access (ElementAccess expr) {
 		List<Expression> indices = expr.get_indices ();
 
-		var ccontainer = (CCodeExpression) expr.container.ccodenode;
-		var cindex = (CCodeExpression) indices[0].ccodenode;
+		var ccontainer = get_cvalue (expr.container);
+		var cindex = get_cvalue (indices[0]);
 
 		// access to element in an array
-		expr.ccodenode = new CCodeElementAccess (ccontainer, cindex);
+		set_cvalue (expr, new CCodeElementAccess (ccontainer, cindex));
 	}
 }
diff --git a/codegen/valadovaassignmentmodule.vala b/codegen/valadovaassignmentmodule.vala
index 1219a44..2e9480d 100644
--- a/codegen/valadovaassignmentmodule.vala
+++ b/codegen/valadovaassignmentmodule.vala
@@ -41,7 +41,7 @@ public class Vala.DovaAssignmentModule : DovaMemberAccessModule {
 			}
 		}
 
-		CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode;
+		CCodeExpression cexpr = get_cvalue (assignment.right);
 
 		if (assignment.operator != AssignmentOperator.SIMPLE) {
 			CCodeBinaryOperator cop;
@@ -86,7 +86,7 @@ public class Vala.DovaAssignmentModule : DovaMemberAccessModule {
 	}
 
 	CCodeExpression emit_simple_assignment (Assignment assignment) {
-		CCodeExpression rhs = (CCodeExpression) assignment.right.ccodenode;
+		CCodeExpression rhs = get_cvalue (assignment.right);
 		CCodeExpression lhs = (CCodeExpression) get_ccodenode (assignment.left);
 		CCodeCommaExpression outer_ccomma = null;
 
@@ -154,7 +154,7 @@ public class Vala.DovaAssignmentModule : DovaMemberAccessModule {
 	}
 
 	CCodeExpression emit_fixed_length_array_assignment (Assignment assignment, ArrayType array_type) {
-		CCodeExpression rhs = (CCodeExpression) assignment.right.ccodenode;
+		CCodeExpression rhs = get_cvalue (assignment.right);
 		CCodeExpression lhs = (CCodeExpression) get_ccodenode (assignment.left);
 
 		// it is necessary to use memcpy for fixed-length (stack-allocated) arrays
@@ -177,13 +177,13 @@ public class Vala.DovaAssignmentModule : DovaMemberAccessModule {
 		}
 
 		if (assignment.left.symbol_reference is Property) {
-			assignment.ccodenode = emit_property_assignment (assignment);
+			set_cvalue (assignment, emit_property_assignment (assignment));
 		} else {
 			var array_type = assignment.left.value_type as ArrayType;
 			if (array_type != null && array_type.fixed_length) {
-				assignment.ccodenode = emit_fixed_length_array_assignment (assignment, array_type);
+				set_cvalue (assignment, emit_fixed_length_array_assignment (assignment, array_type));
 			} else {
-				assignment.ccodenode = emit_simple_assignment (assignment);
+				set_cvalue (assignment, emit_simple_assignment (assignment));
 			}
 		}
 	}
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 22603f2..4c55c25 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -375,7 +375,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 				cenum.add_value (new CCodeEnumValue (ev.get_cname ()));
 			} else {
 				ev.value.emit (this);
-				cenum.add_value (new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode));
+				cenum.add_value (new CCodeEnumValue (ev.get_cname (), get_cvalue (ev.value)));
 			}
 		}
 
@@ -407,12 +407,12 @@ public class Vala.DovaBaseModule : CodeGenerator {
 				if (c.type_reference is ArrayType) {
 					arr = "[]";
 				}
-				cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.value.ccodenode));
+				cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), get_cvalue (c.value)));
 				cdecl.modifiers = CCodeModifiers.STATIC;
 
 				decl_space.add_constant_declaration (cdecl);
 			} else {
-				var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.value.ccodenode);
+				var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), get_cvalue (c.value));
 				decl_space.add_type_member_declaration (cdefine);
 			}
 		}
@@ -853,8 +853,8 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		generate_type_declaration (local.variable_type, cfile);
 
 		CCodeExpression rhs = null;
-		if (local.initializer != null && local.initializer.ccodenode != null) {
-			rhs = (CCodeExpression) local.initializer.ccodenode;
+		if (local.initializer != null && get_cvalue (local.initializer) != null) {
+			rhs = get_cvalue (local.initializer);
 		}
 
 		if (local.captured) {
@@ -902,7 +902,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 					}
 				}
 
-				var cexpr = (CCodeExpression) expr.ccodenode;
+				var cexpr = get_cvalue (expr);
 
 				string ctype = field.get_ctype ();
 				if (ctype != null) {
@@ -912,13 +912,13 @@ public class Vala.DovaBaseModule : CodeGenerator {
 				clist.append (cexpr);
 			}
 
-			list.ccodenode = clist;
+			set_cvalue (list, clist);
 		} else {
 			var clist = new CCodeInitializerList ();
 			foreach (Expression expr in list.get_initializers ()) {
-				clist.append ((CCodeExpression) expr.ccodenode);
+				clist.append (get_cvalue (expr));
 			}
-			list.ccodenode = clist;
+			set_cvalue (list, clist);
 		}
 	}
 
@@ -1114,7 +1114,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		emit_temp_var (full_expr_var);
 
 		var expr_list = new CCodeCommaExpression ();
-		expr_list.append_expression (new CCodeAssignment (get_variable_cexpression (full_expr_var.name), (CCodeExpression) expr.ccodenode));
+		expr_list.append_expression (new CCodeAssignment (get_variable_cexpression (full_expr_var.name), get_cvalue (expr)));
 
 		foreach (LocalVariable local in temp_ref_vars) {
 			var ma = new MemberAccess.simple (local.name);
@@ -1124,7 +1124,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 
 		expr_list.append_expression (get_variable_cexpression (full_expr_var.name));
 
-		expr.ccodenode = expr_list;
+		set_cvalue (expr, expr_list);
 
 		temp_ref_vars.clear ();
 	}
@@ -1184,7 +1184,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 			return;
 		}
 
-		ccode.add_expression ((CCodeExpression) stmt.expression.ccodenode);
+		ccode.add_expression (get_cvalue (stmt.expression));
 		/* free temporary objects and handle errors */
 
 		foreach (LocalVariable local in temp_ref_vars) {
@@ -1297,31 +1297,31 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		}
 
 		var ccall = new CCodeFunctionCall (get_destroy_func_expression (type));
-		ccall.add_argument ((CCodeExpression) stmt.expression.ccodenode);
+		ccall.add_argument (get_cvalue (stmt.expression));
 		ccode.add_expression (ccall);
 	}
 
 	public override void visit_expression (Expression expr) {
-		if (expr.ccodenode != null && !expr.lvalue) {
+		if (get_cvalue (expr) != null && !expr.lvalue) {
 			// memory management, implicit casts, and boxing/unboxing
-			expr.ccodenode = transform_expression ((CCodeExpression) expr.ccodenode, expr.value_type, expr.target_type, expr);
+			set_cvalue (expr, transform_expression (get_cvalue (expr), expr.value_type, expr.target_type, expr));
 		}
 	}
 
 	public override void visit_boolean_literal (BooleanLiteral expr) {
-		expr.ccodenode = new CCodeConstant (expr.value ? "true" : "false");
+		set_cvalue (expr, new CCodeConstant (expr.value ? "true" : "false"));
 	}
 
 	public override void visit_character_literal (CharacterLiteral expr) {
 		if (expr.get_char () >= 0x20 && expr.get_char () < 0x80) {
-			expr.ccodenode = new CCodeConstant (expr.value);
+			set_cvalue (expr, new CCodeConstant (expr.value));
 		} else {
-			expr.ccodenode = new CCodeConstant ("%uU".printf (expr.get_char ()));
+			set_cvalue (expr, new CCodeConstant ("%uU".printf (expr.get_char ())));
 		}
 	}
 
 	public override void visit_integer_literal (IntegerLiteral expr) {
-		expr.ccodenode = new CCodeConstant (expr.value);
+		set_cvalue (expr, new CCodeConstant (expr.value));
 	}
 
 	public override void visit_real_literal (RealLiteral expr) {
@@ -1338,7 +1338,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 				c_literal += ".";
 			}
 		}
-		expr.ccodenode = new CCodeConstant (c_literal);
+		set_cvalue (expr, new CCodeConstant (c_literal));
 	}
 
 	public override void visit_string_literal (StringLiteral expr) {
@@ -1346,16 +1346,16 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		var cliteral = new CCodeConstant ("\"\\0\" " + expr.value);
 
 		var cbinary = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cliteral, new CCodeConstant ("1"));
-		expr.ccodenode = new CCodeCastExpression (cbinary, "string_t");
+		set_cvalue (expr, new CCodeCastExpression (cbinary, "string_t"));
 	}
 
 	public override void visit_null_literal (NullLiteral expr) {
-		expr.ccodenode = new CCodeConstant ("NULL");
+		set_cvalue (expr, new CCodeConstant ("NULL"));
 	}
 
 	public override void visit_base_access (BaseAccess expr) {
 		generate_type_declaration (expr.value_type, cfile);
-		expr.ccodenode = new CCodeCastExpression (new CCodeIdentifier ("this"), expr.value_type.get_cname ());
+		set_cvalue (expr, new CCodeCastExpression (new CCodeIdentifier ("this"), expr.value_type.get_cname ()));
 	}
 
 	public override void visit_postfix_expression (PostfixExpression expr) {
@@ -1369,7 +1369,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 			// assign current value to temp variable
 			var temp_decl = get_temp_variable (prop.property_type, true, expr);
 			emit_temp_var (temp_decl);
-			ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_decl.name), (CCodeExpression) expr.inner.ccodenode));
+			ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_decl.name), get_cvalue (expr.inner)));
 
 			// increment/decrement property
 			var op = expr.increment ? CCodeBinaryOperator.PLUS : CCodeBinaryOperator.MINUS;
@@ -1380,13 +1380,13 @@ public class Vala.DovaBaseModule : CodeGenerator {
 			// return previous value
 			ccomma.append_expression (new CCodeIdentifier (temp_decl.name));
 
-			expr.ccodenode = ccomma;
+			set_cvalue (expr, ccomma);
 			return;
 		}
 
 		var op = expr.increment ? CCodeUnaryOperator.POSTFIX_INCREMENT : CCodeUnaryOperator.POSTFIX_DECREMENT;
 
-		expr.ccodenode = new CCodeUnaryExpression (op, (CCodeExpression) expr.inner.ccodenode);
+		set_cvalue (expr, new CCodeUnaryExpression (op, get_cvalue (expr.inner)));
 	}
 
 	private MemberAccess? find_property_access (Expression expr) {
@@ -1499,7 +1499,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		if (expr != null && expr.is_non_null ()
 		    && !is_ref_function_void (expression_type)) {
 			// expression is non-null
-			ccall.add_argument ((CCodeExpression) expr.ccodenode);
+			ccall.add_argument (get_cvalue (expr));
 
 			return ccall;
 		} else {
@@ -1613,7 +1613,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 			int i = 1;
 			Iterator<FormalParameter> params_it = params.iterator ();
 			foreach (Expression arg in expr.get_argument_list ()) {
-				CCodeExpression cexpr = (CCodeExpression) arg.ccodenode;
+				CCodeExpression cexpr = get_cvalue (arg);
 				FormalParameter param = null;
 				if (params_it.next ()) {
 					param = params_it.get ();
@@ -1645,7 +1645,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 				 * parameter yet */
 				param.initializer.emit (this);
 
-				creation_call.add_argument ((CCodeExpression) param.initializer.ccodenode);
+				creation_call.add_argument (get_cvalue (param.initializer));
 				i++;
 			}
 
@@ -1693,21 +1693,21 @@ public class Vala.DovaBaseModule : CodeGenerator {
 					} else {
 						lhs = new CCodeMemberAccess.pointer (typed_inst, f.get_cname ());
 					}
-					ccomma.append_expression (new CCodeAssignment (lhs, (CCodeExpression) init.initializer.ccodenode));
+					ccomma.append_expression (new CCodeAssignment (lhs, get_cvalue (init.initializer)));
 				} else if (init.symbol_reference is Property) {
 					var inst_ma = new MemberAccess.simple ("new");
 					inst_ma.value_type = expr.type_reference;
-					inst_ma.ccodenode = instance;
+					set_cvalue (inst_ma, instance);
 					var ma = new MemberAccess (inst_ma, init.name);
-					ccomma.append_expression (get_property_set_call ((Property) init.symbol_reference, ma, (CCodeExpression) init.initializer.ccodenode));
+					ccomma.append_expression (get_property_set_call ((Property) init.symbol_reference, ma, get_cvalue (init.initializer)));
 				}
 			}
 
 			ccomma.append_expression (instance);
 
-			expr.ccodenode = ccomma;
+			set_cvalue (expr, ccomma);
 		} else if (creation_expr != null) {
-			expr.ccodenode = creation_expr;
+			set_cvalue (expr, creation_expr);
 		}
 	}
 
@@ -1742,11 +1742,11 @@ public class Vala.DovaBaseModule : CodeGenerator {
 	public override void visit_sizeof_expression (SizeofExpression expr) {
 		var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
 		csizeof.add_argument (new CCodeIdentifier (expr.type_reference.get_cname ()));
-		expr.ccodenode = csizeof;
+		set_cvalue (expr, csizeof);
 	}
 
 	public override void visit_typeof_expression (TypeofExpression expr) {
-		expr.ccodenode = get_type_id_expression (expr.type_reference);
+		set_cvalue (expr, get_type_id_expression (expr.type_reference));
 	}
 
 	public override void visit_unary_expression (UnaryExpression expr) {
@@ -1770,7 +1770,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		} else {
 			assert_not_reached ();
 		}
-		expr.ccodenode = new CCodeUnaryExpression (op, (CCodeExpression) expr.inner.ccodenode);
+		set_cvalue (expr, new CCodeUnaryExpression (op, get_cvalue (expr.inner)));
 	}
 
 	public override void visit_cast_expression (CastExpression expr) {
@@ -1782,7 +1782,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 				emit_temp_var (temp_decl);
 
 				var ctemp = get_variable_cexpression (temp_decl.name);
-				var cinit = new CCodeAssignment (ctemp, (CCodeExpression) expr.inner.ccodenode);
+				var cinit = new CCodeAssignment (ctemp, get_cvalue (expr.inner));
 				var ccheck = create_type_check (ctemp, expr.type_reference);
 				var ccast = new CCodeCastExpression (ctemp, expr.type_reference.get_cname ());
 				var cnull = new CCodeConstant ("NULL");
@@ -1790,7 +1790,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 				ccomma.append_expression (cinit);
 				ccomma.append_expression (new CCodeConditionalExpression (ccheck, ccast, cnull));
 
-				expr.ccodenode = ccomma;
+				set_cvalue (expr, ccomma);
 			} else {
 				expr.error = true;
 				Report.error (expr.source_reference, "Operation not supported for this type");
@@ -1805,7 +1805,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 			var cvar = get_variable_cexpression (temp_decl.name);
 
 			var ccomma = new CCodeCommaExpression ();
-			ccomma.append_expression (new CCodeAssignment (cvar, (CCodeExpression) expr.inner.ccodenode));
+			ccomma.append_expression (new CCodeAssignment (cvar, get_cvalue (expr.inner)));
 
 			var to_any  = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_value_to_any"));
 			to_any.add_argument (get_type_id_expression (expr.inner.value_type));
@@ -1813,7 +1813,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 			to_any.add_argument (new CCodeConstant ("0"));
 			ccomma.append_expression (to_any);
 
-			expr.ccodenode = ccomma;
+			set_cvalue (expr, ccomma);
 			return;
 		} else if (expr.inner.value_type.data_type != null && expr.inner.value_type.data_type.get_full_name () == "Dova.Value") {
 			// unbox value
@@ -1828,14 +1828,14 @@ public class Vala.DovaBaseModule : CodeGenerator {
 
 			var to_any  = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_value_from_any"));
 			to_any.add_argument (get_type_id_expression (expr.type_reference));
-			to_any.add_argument ((CCodeExpression) expr.inner.ccodenode);
+			to_any.add_argument (get_cvalue (expr.inner));
 			to_any.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cvar));
 			to_any.add_argument (new CCodeConstant ("0"));
 			ccomma.append_expression (to_any);
 
 			ccomma.append_expression (cvar);
 
-			expr.ccodenode = ccomma;
+			set_cvalue (expr, ccomma);
 			return;
 		}
 
@@ -1843,18 +1843,18 @@ public class Vala.DovaBaseModule : CodeGenerator {
 
 		if (expr.inner.value_type is GenericType && !(expr.type_reference is GenericType)) {
 			// generic types use an extra pointer, dereference that pointer
-			expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeCastExpression ((CCodeExpression) expr.inner.ccodenode, expr.type_reference.get_cname () + "*"));
+			set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeCastExpression (get_cvalue (expr.inner), expr.type_reference.get_cname () + "*")));
 		} else {
-			expr.ccodenode = new CCodeCastExpression ((CCodeExpression) expr.inner.ccodenode, expr.type_reference.get_cname ());
+			set_cvalue (expr, new CCodeCastExpression (get_cvalue (expr.inner), expr.type_reference.get_cname ()));
 		}
 	}
 
 	public override void visit_pointer_indirection (PointerIndirection expr) {
-		expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, (CCodeExpression) expr.inner.ccodenode);
+		set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, get_cvalue (expr.inner)));
 	}
 
 	public override void visit_addressof_expression (AddressofExpression expr) {
-		expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, (CCodeExpression) expr.inner.ccodenode);
+		set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue (expr.inner)));
 	}
 
 	public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) {
@@ -1864,15 +1864,15 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		emit_temp_var (temp_decl);
 		var cvar = get_variable_cexpression (temp_decl.name);
 
-		ccomma.append_expression (new CCodeAssignment (cvar, (CCodeExpression) expr.inner.ccodenode));
-		ccomma.append_expression (new CCodeAssignment ((CCodeExpression) expr.inner.ccodenode, new CCodeConstant ("NULL")));
+		ccomma.append_expression (new CCodeAssignment (cvar, get_cvalue (expr.inner)));
+		ccomma.append_expression (new CCodeAssignment (get_cvalue (expr.inner), new CCodeConstant ("NULL")));
 		ccomma.append_expression (cvar);
-		expr.ccodenode = ccomma;
+		set_cvalue (expr, ccomma);
 	}
 
 	public override void visit_binary_expression (BinaryExpression expr) {
-		var cleft = (CCodeExpression) expr.left.ccodenode;
-		var cright = (CCodeExpression) expr.right.ccodenode;
+		var cleft = get_cvalue (expr.left);
+		var cright = get_cvalue (expr.right);
 
 		CCodeBinaryOperator op;
 		if (expr.operator == BinaryOperator.PLUS) {
@@ -1912,7 +1912,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		} else if (expr.operator == BinaryOperator.OR) {
 			op = CCodeBinaryOperator.OR;
 		} else if (expr.operator == BinaryOperator.IN) {
-			expr.ccodenode = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeBinaryExpression (CCodeBinaryOperator.BITWISE_AND, cright, cleft), cleft);
+			set_cvalue (expr, new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeBinaryExpression (CCodeBinaryOperator.BITWISE_AND, cright, cleft), cleft));
 			return;
 		} else {
 			assert_not_reached ();
@@ -1949,7 +1949,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 			}
 		}
 
-		expr.ccodenode = new CCodeBinaryExpression (op, cleft, cright);
+		set_cvalue (expr, new CCodeBinaryExpression (op, cleft, cright));
 	}
 
 	CCodeExpression? create_type_check (CCodeNode ccodenode, DataType type) {
@@ -1962,8 +1962,8 @@ public class Vala.DovaBaseModule : CodeGenerator {
 	public override void visit_type_check (TypeCheck expr) {
 		generate_type_declaration (expr.type_reference, cfile);
 
-		expr.ccodenode = create_type_check (expr.expression.ccodenode, expr.type_reference);
-		if (expr.ccodenode is CCodeInvalidExpression) {
+		set_cvalue (expr, create_type_check (get_cvalue (expr.expression), expr.type_reference));
+		if (get_cvalue (expr) is CCodeInvalidExpression) {
 			Report.error (expr.source_reference, "type check expressions not supported for compact classes, structs, and enums");
 		}
 	}
@@ -1975,7 +1975,7 @@ public class Vala.DovaBaseModule : CodeGenerator {
 
 		l.accept_children (this);
 
-		l.ccodenode = new CCodeIdentifier (l.method.get_cname ());
+		set_cvalue (l, new CCodeIdentifier (l.method.get_cname ()));
 	}
 
 	// manage memory and implicit casts
@@ -2231,6 +2231,14 @@ public class Vala.DovaBaseModule : CodeGenerator {
 		return null;
 	}
 
+	public CCodeExpression? get_cvalue (Expression expr) {
+		return (CCodeExpression) expr.ccodenode;
+	}
+
+	public void set_cvalue (Expression expr, CCodeExpression? cvalue) {
+		expr.ccodenode = cvalue;
+	}
+
 	public CCodeNode? get_ccodenode (CodeNode node) {
 		if (node.ccodenode == null) {
 			node.emit (this);
diff --git a/codegen/valadovacontrolflowmodule.vala b/codegen/valadovacontrolflowmodule.vala
index 93894ed..ac17c14 100644
--- a/codegen/valadovacontrolflowmodule.vala
+++ b/codegen/valadovacontrolflowmodule.vala
@@ -22,7 +22,7 @@
 
 public class Vala.DovaControlFlowModule : DovaMethodModule {
 	public override void visit_if_statement (IfStatement stmt) {
-		ccode.open_if ((CCodeExpression) stmt.condition.ccodenode);
+		ccode.open_if (get_cvalue (stmt.condition));
 
 		stmt.true_statement.emit (this);
 
@@ -35,7 +35,7 @@ public class Vala.DovaControlFlowModule : DovaMethodModule {
 	}
 
 	public override void visit_switch_statement (SwitchStatement stmt) {
-		ccode.open_switch ((CCodeExpression) stmt.expression.ccodenode);
+		ccode.open_switch (get_cvalue (stmt.expression));
 
 		foreach (SwitchSection section in stmt.get_sections ()) {
 			if (section.has_default_label ()) {
@@ -53,7 +53,7 @@ public class Vala.DovaControlFlowModule : DovaMethodModule {
 
 			visit_end_full_expression (label.expression);
 
-			ccode.add_case ((CCodeExpression) label.expression.ccodenode);
+			ccode.add_case (get_cvalue (label.expression));
 		}
 	}
 
diff --git a/codegen/valadovaerrormodule.vala b/codegen/valadovaerrormodule.vala
index be2fcaf..f4d9d37 100644
--- a/codegen/valadovaerrormodule.vala
+++ b/codegen/valadovaerrormodule.vala
@@ -27,7 +27,7 @@ public class Vala.DovaErrorModule : DovaDelegateModule {
 	private bool is_in_catch = false;
 
 	public override void visit_throw_statement (ThrowStatement stmt) {
-		ccode.add_expression (new CCodeAssignment (new CCodeIdentifier ("dova_error"), (CCodeExpression) stmt.error_expression.ccodenode));
+		ccode.add_expression (new CCodeAssignment (new CCodeIdentifier ("dova_error"), get_cvalue (stmt.error_expression)));
 
 		add_simple_check (stmt, true);
 	}
diff --git a/codegen/valadovamemberaccessmodule.vala b/codegen/valadovamemberaccessmodule.vala
index 3e87b05..5e6f0d9 100644
--- a/codegen/valadovamemberaccessmodule.vala
+++ b/codegen/valadovamemberaccessmodule.vala
@@ -28,7 +28,7 @@ public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 		DataType base_type = null;
 
 		if (expr.inner != null) {
-			pub_inst = (CCodeExpression) expr.inner.ccodenode;
+			pub_inst = get_cvalue (expr.inner);
 
 			if (expr.inner.value_type != null) {
 				base_type = expr.inner.value_type;
@@ -54,12 +54,12 @@ public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 				if (m.base_method != null) {
 					var base_class = (Class) m.base_method.parent_symbol;
 
-					expr.ccodenode = new CCodeIdentifier ("%s_base_%s".printf (base_class.get_lower_case_cname (null), m.name));
+					set_cvalue (expr, new CCodeIdentifier ("%s_base_%s".printf (base_class.get_lower_case_cname (null), m.name)));
 					return;
 				} else if (m.base_interface_method != null) {
 					var base_iface = (Interface) m.base_interface_method.parent_symbol;
 
-					expr.ccodenode = new CCodeIdentifier ("%s_base_%s".printf (base_iface.get_lower_case_cname (null), m.name));
+					set_cvalue (expr, new CCodeIdentifier ("%s_base_%s".printf (base_iface.get_lower_case_cname (null), m.name)));
 					return;
 				}
 			}
@@ -74,28 +74,28 @@ public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 						emit_temp_var (temp_var);
 						var ctemp = new CCodeIdentifier (temp_var.name);
 						inst = new CCodeAssignment (ctemp, pub_inst);
-						expr.inner.ccodenode = ctemp;
+						set_cvalue (expr.inner, ctemp);
 					}
 					var base_class = (Class) m.base_method.parent_symbol;
 					var vclass = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (base_class.get_upper_case_cname (null))));
 					vclass.add_argument (inst);
-					expr.ccodenode = new CCodeMemberAccess.pointer (vclass, m.name);
+					set_cvalue (expr, new CCodeMemberAccess.pointer (vclass, m.name));
 				} else {
-					expr.ccodenode = new CCodeIdentifier (m.base_method.get_cname ());
+					set_cvalue (expr, new CCodeIdentifier (m.base_method.get_cname ()));
 				}
 			} else if (m.base_interface_method != null) {
-				expr.ccodenode = new CCodeIdentifier (m.base_interface_method.get_cname ());
+				set_cvalue (expr, new CCodeIdentifier (m.base_interface_method.get_cname ()));
 			} else if (m is CreationMethod) {
-				expr.ccodenode = new CCodeIdentifier (m.get_real_cname ());
+				set_cvalue (expr, new CCodeIdentifier (m.get_real_cname ()));
 			} else {
-				expr.ccodenode = new CCodeIdentifier (m.get_cname ());
+				set_cvalue (expr, new CCodeIdentifier (m.get_cname ()));
 			}
 		} else if (expr.symbol_reference is ArrayLengthField) {
 			generate_property_accessor_declaration (((Property) array_class.scope.lookup ("length")).get_accessor, cfile);
 
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier ("dova_array_get_length"));
 			ccall.add_argument (pub_inst);
-			expr.ccodenode = ccall;
+			set_cvalue (expr, ccall);
 		} else if (expr.symbol_reference is Field) {
 			var f = (Field) expr.symbol_reference;
 			if (f.binding == MemberBinding.INSTANCE) {
@@ -116,27 +116,27 @@ public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 					inst = pub_inst;
 				}
 				if (instance_target_type.data_type.is_reference_type () || (expr.inner != null && expr.inner.value_type is PointerType)) {
-					expr.ccodenode = new CCodeMemberAccess.pointer (inst, f.get_cname ());
+					set_cvalue (expr, new CCodeMemberAccess.pointer (inst, f.get_cname ()));
 				} else {
-					expr.ccodenode = new CCodeMemberAccess (inst, f.get_cname ());
+					set_cvalue (expr, new CCodeMemberAccess (inst, f.get_cname ()));
 				}
 			} else {
 				generate_field_declaration (f, cfile);
 
-				expr.ccodenode = new CCodeIdentifier (f.get_cname ());
+				set_cvalue (expr, new CCodeIdentifier (f.get_cname ()));
 			}
 		} else if (expr.symbol_reference is EnumValue) {
 			var ev = (EnumValue) expr.symbol_reference;
 
 			generate_enum_declaration ((Enum) ev.parent_symbol, cfile);
 
-			expr.ccodenode = new CCodeConstant (ev.get_cname ());
+			set_cvalue (expr, new CCodeConstant (ev.get_cname ()));
 		} else if (expr.symbol_reference is Constant) {
 			var c = (Constant) expr.symbol_reference;
 
 			generate_constant_declaration (c, cfile);
 
-			expr.ccodenode = new CCodeIdentifier (c.get_cname ());
+			set_cvalue (expr, new CCodeIdentifier (c.get_cname ()));
 		} else if (expr.symbol_reference is Property) {
 			var prop = (Property) expr.symbol_reference;
 
@@ -159,16 +159,16 @@ public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 					vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
 
 					var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "get_%s".printf (prop.name)));
-					ccall.add_argument ((CCodeExpression) expr.inner.ccodenode);
-					expr.ccodenode = ccall;
+					ccall.add_argument (get_cvalue (expr.inner));
+					set_cvalue (expr, ccall);
 					return;
 				} else if (prop.base_interface_property != null) {
 					var base_iface = (Interface) prop.base_interface_property.parent_symbol;
 					string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
 
 					var ccall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), "get_%s".printf (prop.name)));
-					ccall.add_argument ((CCodeExpression) expr.inner.ccodenode);
-					expr.ccodenode = ccall;
+					ccall.add_argument (get_cvalue (expr.inner));
+					set_cvalue (expr, ccall);
 					return;
 				}
 			}
@@ -186,31 +186,31 @@ public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 				ccall.add_argument (pub_inst);
 			}
 
-			expr.ccodenode = ccall;
+			set_cvalue (expr, ccall);
 		} else if (expr.symbol_reference is LocalVariable) {
 			var local = (LocalVariable) expr.symbol_reference;
 			if (local.is_result) {
 				// used in postconditions
-				expr.ccodenode = new CCodeIdentifier ("result");
+				set_cvalue (expr, new CCodeIdentifier ("result"));
 			} else if (local.captured) {
 				// captured variables are stored on the heap
 				var block = (Block) local.parent_symbol;
-				expr.ccodenode = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (local.name));
+				set_cvalue (expr, new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (local.name)));
 			} else {
-				expr.ccodenode = get_variable_cexpression (local.name);
+				set_cvalue (expr, get_variable_cexpression (local.name));
 			}
 		} else if (expr.symbol_reference is FormalParameter) {
 			var p = (FormalParameter) expr.symbol_reference;
 			if (p.name == "this") {
 				if (current_method != null && current_method.coroutine) {
 					// use closure
-					expr.ccodenode = new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "this");
+					set_cvalue (expr, new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "this"));
 				} else {
 					var st = current_type_symbol as Struct;
 					if (st != null && !st.is_boolean_type () && !st.is_integer_type () && !st.is_floating_type () && (!st.is_simple_type () || current_method is CreationMethod)) {
-						expr.ccodenode = new CCodeIdentifier ("(*this)");
+						set_cvalue (expr, new CCodeIdentifier ("(*this)"));
 					} else {
-						expr.ccodenode = new CCodeIdentifier ("this");
+						set_cvalue (expr, new CCodeIdentifier ("this"));
 					}
 				}
 			} else {
@@ -220,19 +220,19 @@ public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 					if (block == null) {
 						block = ((Method) p.parent_symbol).body;
 					}
-					expr.ccodenode = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (p.name));
+					set_cvalue (expr, new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (p.name)));
 				} else {
 					if (current_method != null && current_method.coroutine) {
 						// use closure
-						expr.ccodenode = get_variable_cexpression (p.name);
+						set_cvalue (expr, get_variable_cexpression (p.name));
 					} else {
 						var type_as_struct = p.variable_type.data_type as Struct;
 						if (p.direction != ParameterDirection.IN
 						    || (type_as_struct != null && !type_as_struct.is_simple_type () && !p.variable_type.nullable)) {
 							if (p.variable_type is GenericType) {
-								expr.ccodenode = get_variable_cexpression (p.name);
+								set_cvalue (expr, get_variable_cexpression (p.name));
 							} else {
-								expr.ccodenode = new CCodeIdentifier ("(*%s)".printf (get_variable_cname (p.name)));
+								set_cvalue (expr, new CCodeIdentifier ("(*%s)".printf (get_variable_cname (p.name))));
 							}
 						} else {
 							// Property setters of non simple structs shall replace all occurences
@@ -242,9 +242,9 @@ public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 							    current_property_accessor.writable &&
 							    current_property_accessor.value_parameter == p &&
 							    current_property_accessor.prop.property_type.is_real_struct_type ()) {
-								expr.ccodenode = new CCodeIdentifier ("(*value)");
+								set_cvalue (expr, new CCodeIdentifier ("(*value)"));
 							} else {
-								expr.ccodenode = get_variable_cexpression (p.name);
+								set_cvalue (expr, get_variable_cexpression (p.name));
 							}
 						}
 					}
diff --git a/codegen/valadovamethodcallmodule.vala b/codegen/valadovamethodcallmodule.vala
index 958aa26..852185e 100644
--- a/codegen/valadovamethodcallmodule.vala
+++ b/codegen/valadovamethodcallmodule.vala
@@ -23,7 +23,7 @@
 public class Vala.DovaMethodCallModule : DovaAssignmentModule {
 	public override void visit_method_call (MethodCall expr) {
 		// the bare function call
-		var ccall = new CCodeFunctionCall ((CCodeExpression) expr.call.ccodenode);
+		var ccall = new CCodeFunctionCall (get_cvalue (expr.call));
 
 		Method m = null;
 		Delegate deleg = null;
@@ -46,7 +46,7 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
 		} else if (itype is DelegateType) {
 			deleg = ((DelegateType) itype).delegate_symbol;
 			ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_invoke".printf (deleg.get_lower_case_cname ())));
-			ccall.add_argument ((CCodeExpression) expr.call.ccodenode);
+			ccall.add_argument (get_cvalue (expr.call));
 		}
 
 		if (m is CreationMethod) {
@@ -59,11 +59,11 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
 			}
 		} else if (m != null) {
 			if (m.binding == MemberBinding.INSTANCE) {
-				var instance = (CCodeExpression) ma.inner.ccodenode;
+				var instance = get_cvalue (ma.inner);
 
 				if (ma.member_name == "begin" && ma.inner.symbol_reference == ma.symbol_reference) {
 					var inner_ma = (MemberAccess) ma.inner;
-					instance = (CCodeExpression) inner_ma.inner.ccodenode;
+					instance = get_cvalue (inner_ma.inner);
 				}
 
 				var st = m.parent_symbol as Struct;
@@ -116,7 +116,7 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
 		int i = 1;
 		Iterator<FormalParameter> params_it = params.iterator ();
 		foreach (Expression arg in expr.get_argument_list ()) {
-			CCodeExpression cexpr = (CCodeExpression) arg.ccodenode;
+			CCodeExpression cexpr = get_cvalue (arg);
 
 			if (params_it.next ()) {
 				var param = params_it.get ();
@@ -140,7 +140,7 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
 
 						if (param.direction == ParameterDirection.REF) {
 							var crefcomma = new CCodeCommaExpression ();
-							crefcomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_var.name), (CCodeExpression) unary.inner.ccodenode));
+							crefcomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_var.name), get_cvalue (unary.inner)));
 							crefcomma.append_expression (cexpr);
 							cexpr = crefcomma;
 						}
@@ -163,12 +163,12 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
 						cassign_comma.append_expression (new CCodeAssignment (get_variable_cexpression (assign_temp_var.name), transform_expression (get_variable_cexpression (temp_var.name), param.variable_type, unary.inner.value_type, arg)));
 
 						// unref old value
-						cassign_comma.append_expression (get_unref_expression ((CCodeExpression) unary.inner.ccodenode, arg.value_type, arg));
+						cassign_comma.append_expression (get_unref_expression (get_cvalue (unary.inner), arg.value_type, arg));
 
 						cassign_comma.append_expression (get_variable_cexpression (assign_temp_var.name));
 
 						// assign new value
-						ccomma.append_expression (new CCodeAssignment ((CCodeExpression) unary.inner.ccodenode, cassign_comma));
+						ccomma.append_expression (new CCodeAssignment (get_cvalue (unary.inner), cassign_comma));
 
 						// return value
 						if (!(itype.get_return_type () is VoidType)) {
@@ -218,7 +218,7 @@ public class Vala.DovaMethodCallModule : DovaAssignmentModule {
 			ccall_expr = ccomma;
 		}
 
-		expr.ccodenode = ccall_expr;
+		set_cvalue (expr, ccall_expr);
 	}
 }
 
diff --git a/codegen/valadovaobjectmodule.vala b/codegen/valadovaobjectmodule.vala
index 768d9a2..7a0e7ba 100644
--- a/codegen/valadovaobjectmodule.vala
+++ b/codegen/valadovaobjectmodule.vala
@@ -783,9 +783,9 @@ public class Vala.DovaObjectModule : DovaArrayModule {
 
 					var field_st = f.parent_symbol as Struct;
 					if (field_st != null && !field_st.is_simple_type ()) {
-						this_access.ccodenode = new CCodeIdentifier ("(*this)");
+						set_cvalue (this_access, new CCodeIdentifier ("(*this)"));
 					} else {
-						this_access.ccodenode = new CCodeIdentifier ("this");
+						set_cvalue (this_access, new CCodeIdentifier ("this"));
 					}
 
 					var ma = new MemberAccess (this_access, f.name);
@@ -1945,24 +1945,24 @@ public class Vala.DovaObjectModule : DovaArrayModule {
 			expr.accept_children (this);
 
 			List<Expression> indices = expr.get_indices ();
-			var cindex = (CCodeExpression) indices[0].ccodenode;
+			var cindex = get_cvalue (indices[0]);
 
 			if (array_type.inline_allocated) {
-				expr.ccodenode = new CCodeElementAccess ((CCodeExpression) expr.container.ccodenode, cindex);
+				set_cvalue (expr, new CCodeElementAccess (get_cvalue (expr.container), cindex));
 			} else {
 				generate_property_accessor_declaration (((Property) array_class.scope.lookup ("data")).get_accessor, cfile);
 
 				var ccontainer = new CCodeFunctionCall (new CCodeIdentifier ("dova_array_get_data"));
-				ccontainer.add_argument ((CCodeExpression) expr.container.ccodenode);
+				ccontainer.add_argument (get_cvalue (expr.container));
 
 				if (array_type.element_type is GenericType) {
 					// generic array
 					// calculate offset in bytes based on value size
 					var value_size = new CCodeFunctionCall (new CCodeIdentifier ("dova_type_get_value_size"));
 					value_size.add_argument (get_type_id_expression (array_type.element_type));
-					expr.ccodenode = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeCastExpression (ccontainer, "char*"), new CCodeBinaryExpression (CCodeBinaryOperator.MUL, value_size, cindex));
+					set_cvalue (expr, new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeCastExpression (ccontainer, "char*"), new CCodeBinaryExpression (CCodeBinaryOperator.MUL, value_size, cindex)));
 				} else {
-					expr.ccodenode = new CCodeElementAccess (new CCodeCastExpression (ccontainer, "%s*".printf (array_type.element_type.get_cname ())), cindex);
+					set_cvalue (expr, new CCodeElementAccess (new CCodeCastExpression (ccontainer, "%s*".printf (array_type.element_type.get_cname ())), cindex));
 				}
 			}
 
@@ -1976,7 +1976,7 @@ public class Vala.DovaObjectModule : DovaArrayModule {
 			field.initializer.emit (this);
 
 			var lhs = new CCodeIdentifier (field.get_cname ());
-			var rhs = (CCodeExpression) field.initializer.ccodenode;
+			var rhs = get_cvalue (field.initializer);
 
 			ccode.add_expression (new CCodeAssignment (lhs, rhs));
 		}
diff --git a/codegen/valadovavaluemodule.vala b/codegen/valadovavaluemodule.vala
index d9eea58..5a056dd 100644
--- a/codegen/valadovavaluemodule.vala
+++ b/codegen/valadovavaluemodule.vala
@@ -312,7 +312,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 				if (requires_destroy (f.variable_type))  {
 					var this_access = new MemberAccess.simple ("this");
 					this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
-					this_access.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, dest);
+					set_cvalue (this_access, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, dest));
 					var ma = new MemberAccess (this_access, f.name);
 					ma.symbol_reference = f;
 					ma.value_type = f.variable_type.copy ();
@@ -349,7 +349,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 					if (requires_copy (f.variable_type))  {
 						var this_access = new MemberAccess.simple ("this");
 						this_access.value_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
-						this_access.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, src);
+						set_cvalue (this_access, new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, src));
 						var ma = new MemberAccess (this_access, f.name);
 						ma.symbol_reference = f;
 						copy = get_ref_cexpression (f.variable_type, copy, ma, f);
@@ -383,7 +383,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 
 		if (src is NullLiteral) {
 			// TODO destroy dest
-			assignment.ccodenode = new CCodeConstant ("0");
+			set_cvalue (assignment, new CCodeConstant ("0"));
 			return;
 		}
 
@@ -438,7 +438,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 		ccall.add_argument (dest_index);
 		ccall.add_argument (csrc);
 		ccall.add_argument (src_index);
-		assignment.ccodenode = ccall;
+		set_cvalue (assignment, ccall);
 	}
 
 	public override void visit_binary_expression (BinaryExpression expr) {
@@ -486,9 +486,9 @@ public class Vala.DovaValueModule : DovaObjectModule {
 		ccall.add_argument (right_index);
 
 		if (expr.operator == BinaryOperator.EQUALITY) {
-			expr.ccodenode = ccall;
+			set_cvalue (expr, ccall);
 		} else {
-			expr.ccodenode = new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, ccall);
+			set_cvalue (expr, new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, ccall));
 		}
 	}
 
@@ -527,7 +527,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 			ccall.add_argument (cval);
 			ccall.add_argument (val_index);
 
-			expr.ccodenode = ccall;
+			set_cvalue (expr, ccall);
 		}
 	}
 
@@ -550,7 +550,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 
 			int i = 0;
 			foreach (Expression e in expr.get_expressions ()) {
-				ce.append_expression (new CCodeAssignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), (CCodeExpression) e.ccodenode));
+				ce.append_expression (new CCodeAssignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), get_cvalue (e)));
 				i++;
 			}
 
@@ -562,7 +562,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 		list_creation.add_argument (new CCodeConstant (length.to_string ()));
 		list_creation.add_argument (ce);
 
-		expr.ccodenode = list_creation;
+		set_cvalue (expr, list_creation);
 	}
 
 	public override void visit_set_literal (SetLiteral expr) {
@@ -584,7 +584,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 
 			int i = 0;
 			foreach (Expression e in expr.get_expressions ()) {
-				ce.append_expression (new CCodeAssignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), (CCodeExpression) e.ccodenode));
+				ce.append_expression (new CCodeAssignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), get_cvalue (e)));
 				i++;
 			}
 
@@ -596,7 +596,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 		set_creation.add_argument (new CCodeConstant (length.to_string ()));
 		set_creation.add_argument (ce);
 
-		expr.ccodenode = set_creation;
+		set_cvalue (expr, set_creation);
 	}
 
 	public override void visit_map_literal (MapLiteral expr) {
@@ -629,8 +629,8 @@ public class Vala.DovaValueModule : DovaObjectModule {
 			emit_temp_var (value_temp_var);
 
 			for (int i = 0; i < length; i++) {
-				key_ce.append_expression (new CCodeAssignment (new CCodeElementAccess (key_name_cnode, new CCodeConstant (i.to_string ())), (CCodeExpression) expr.get_keys ().get (i).ccodenode));
-				value_ce.append_expression (new CCodeAssignment (new CCodeElementAccess (value_name_cnode, new CCodeConstant (i.to_string ())), (CCodeExpression) expr.get_values ().get (i).ccodenode));
+				key_ce.append_expression (new CCodeAssignment (new CCodeElementAccess (key_name_cnode, new CCodeConstant (i.to_string ())), get_cvalue (expr.get_keys ().get (i))));
+				value_ce.append_expression (new CCodeAssignment (new CCodeElementAccess (value_name_cnode, new CCodeConstant (i.to_string ())), get_cvalue (expr.get_values ().get (i))));
 			}
 
 			key_ce.append_expression (key_name_cnode);
@@ -644,7 +644,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 		map_creation.add_argument (key_ce);
 		map_creation.add_argument (value_ce);
 
-		expr.ccodenode = map_creation;
+		set_cvalue (expr, map_creation);
 	}
 
 	public override void visit_tuple (Tuple tuple) {
@@ -675,7 +675,7 @@ public class Vala.DovaValueModule : DovaObjectModule {
 
 			type_ce.append_expression (new CCodeAssignment (new CCodeElementAccess (type_name_cnode, new CCodeConstant (i.to_string ())), get_type_id_expression (element_type)));
 
-			var cexpr = (CCodeExpression) e.ccodenode;
+			var cexpr = get_cvalue (e);
 
 			var unary = cexpr as CCodeUnaryExpression;
 			if (unary != null && unary.operator == CCodeUnaryOperator.POINTER_INDIRECTION) {
@@ -706,6 +706,6 @@ public class Vala.DovaValueModule : DovaObjectModule {
 		tuple_creation.add_argument (type_ce);
 		tuple_creation.add_argument (ce);
 
-		tuple.ccodenode = tuple_creation;
+		set_cvalue (tuple, tuple_creation);
 	}
 }
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index d347f5b..f6401ca 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -555,7 +555,7 @@ public class Vala.GAsyncModule : GSignalModule {
 			return;
 		}
 
-		ccode.add_expression ((CCodeExpression) stmt.yield_expression.ccodenode);
+		ccode.add_expression (get_cvalue (stmt.yield_expression));
 
 		if (stmt.tree_can_fail && stmt.yield_expression.tree_can_fail) {
 			// simple case, no node breakdown necessary
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index a1ebeb4..d4d038e 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -266,31 +266,31 @@ public class Vala.GDBusClientModule : GDBusModule {
 		var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_initable_new"));
 		ccall.add_argument (new CCodeIdentifier ("%s_PROXY".printf (iface.get_type_id ())));
 		cancellable.emit (this);
-		ccall.add_argument ((CCodeExpression) cancellable.ccodenode);
+		ccall.add_argument (get_cvalue (cancellable));
 		ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression ("_inner_error_")));
 		ccall.add_argument (new CCodeConstant ("\"g-flags\""));
 		ccall.add_argument (new CCodeConstant ("G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES"));
 		ccall.add_argument (new CCodeConstant ("\"g-name\""));
 		name.emit (this);
-		ccall.add_argument ((CCodeExpression) name.ccodenode);
+		ccall.add_argument (get_cvalue (name));
 		if (bus_get_proxy_sync) {
 			Expression bus_type = args.get (0);
 			ccall.add_argument (new CCodeConstant ("\"g-bus-type\""));
 			bus_type.emit (this);
-			ccall.add_argument ((CCodeExpression) bus_type.ccodenode);
+			ccall.add_argument (get_cvalue (bus_type));
 		} else {
 			Expression connection = ((MemberAccess) expr.call).inner;
 			ccall.add_argument (new CCodeConstant ("\"g-connection\""));
 			connection.emit (this);
-			ccall.add_argument ((CCodeExpression) connection.ccodenode);
+			ccall.add_argument (get_cvalue (connection));
 		}
 		ccall.add_argument (new CCodeConstant ("\"g-object-path\""));
 		object_path.emit (this);
-		ccall.add_argument ((CCodeExpression) object_path.ccodenode);
+		ccall.add_argument (get_cvalue (object_path));
 		ccall.add_argument (new CCodeConstant ("\"g-interface-name\""));
 		ccall.add_argument (new CCodeConstant ("\"%s\"".printf (get_dbus_name (iface))));
 		ccall.add_argument (new CCodeConstant ("NULL"));
-		expr.ccodenode = ccall;
+		set_cvalue (expr, ccall);
 	}
 
 	string generate_dbus_signal_handler (Signal sig, ObjectTypeSymbol sym) {
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 01f7fa2..9ac6487 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -1049,11 +1049,11 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 		current_method_inner_error = true;
 
 		var cregister = new CCodeFunctionCall (new CCodeIdentifier ("%sregister_object".printf (type_arg.type_symbol.get_lower_case_cprefix ())));
-		cregister.add_argument ((CCodeExpression) obj_arg.ccodenode);
-		cregister.add_argument ((CCodeExpression) ma.inner.ccodenode);
-		cregister.add_argument ((CCodeExpression) path_arg.ccodenode);
+		cregister.add_argument (get_cvalue (obj_arg));
+		cregister.add_argument (get_cvalue (ma.inner));
+		cregister.add_argument (get_cvalue (path_arg));
 		cregister.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression ("_inner_error_")));
-		expr.ccodenode = cregister;
+		set_cvalue (expr, cregister);
 	}
 
 	public override void generate_class_declaration (Class cl, CCodeFile decl_space) {
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index b08b825..ec0d56f 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -40,7 +40,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 				cenum.add_value (new CCodeEnumValue (ecode.get_cname ()));
 			} else {
 				ecode.value.emit (this);
-				cenum.add_value (new CCodeEnumValue (ecode.get_cname (), (CCodeExpression) ecode.value.ccodenode));
+				cenum.add_value (new CCodeEnumValue (ecode.get_cname (), get_cvalue (ecode.value)));
 			}
 		}
 
@@ -87,7 +87,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 	public override void visit_throw_statement (ThrowStatement stmt) {
 		// method will fail
 		current_method_inner_error = true;
-		ccode.add_expression (new CCodeAssignment (get_variable_cexpression ("_inner_error_"), (CCodeExpression) stmt.error_expression.ccodenode));
+		ccode.add_expression (new CCodeAssignment (get_variable_cexpression ("_inner_error_"), get_cvalue (stmt.error_expression)));
 
 		add_simple_check (stmt, true);
 	}
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index ed52d85..f30077c 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -748,7 +748,7 @@ public class Vala.GObjectModule : GTypeModule {
 				var ccomma = new CCodeCommaExpression ();
 				var temp_var = get_temp_variable (expr.value_type, false, expr, false);
 				emit_temp_var (temp_var);
-				ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_var.name), (CCodeExpression) expr.ccodenode));
+				ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_var.name), get_cvalue (expr)));
 
 				var initiallyunowned_ccall = new CCodeFunctionCall (new CCodeIdentifier ("G_IS_INITIALLY_UNOWNED"));
 				initiallyunowned_ccall.add_argument (get_variable_cexpression (temp_var.name));
@@ -756,7 +756,7 @@ public class Vala.GObjectModule : GTypeModule {
 				sink_ref_ccall.add_argument (get_variable_cexpression (temp_var.name));
 				ccomma.append_expression (new CCodeConditionalExpression (initiallyunowned_ccall, sink_ref_ccall, get_variable_cexpression (temp_var.name)));
 
-				expr.ccodenode = ccomma;
+				set_cvalue (expr, ccomma);
 				return;
 			} else if (ma.symbol_reference == gobject_type) {
 				// Object (...) chain up
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 8b90ef4..5dcd326 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -169,7 +169,7 @@ public class Vala.GSignalModule : GObjectModule {
 
 		var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_strconcat"));
 		ccall.add_argument (sig.get_canonical_cconstant (""));
-		ccall.add_argument ((CCodeExpression) detail_expr.ccodenode);
+		ccall.add_argument (get_cvalue (detail_expr));
 		ccall.add_argument (new CCodeConstant ("NULL"));
 
 		var ccomma = new CCodeCommaExpression ();
@@ -491,11 +491,11 @@ public class Vala.GSignalModule : GObjectModule {
 			var signal_name_cexpr = get_signal_name_cexpression (sig, detail_expr, expr);
 			
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_emit_by_name"));
-			ccall.add_argument ((CCodeExpression) ma.inner.ccodenode);
+			ccall.add_argument (get_cvalue (ma.inner));
 			if (signal_name_cexpr != null) {
 				ccall.add_argument (signal_name_cexpr);
 			}
-			expr.ccodenode = ccall;
+			set_cvalue (expr, ccall);
 		} else {
 			base.visit_element_access (expr);
 		}
@@ -535,7 +535,7 @@ public class Vala.GSignalModule : GObjectModule {
 				return;
 			}
 
-			assignment.ccodenode = emit_signal_assignment (assignment);
+			set_cvalue (assignment, emit_signal_assignment (assignment));
 		} else {
 			base.visit_assignment (assignment);
 		}
@@ -546,7 +546,7 @@ public class Vala.GSignalModule : GObjectModule {
 			CCodeExpression pub_inst = null;
 	
 			if (expr.inner != null) {
-				pub_inst = (CCodeExpression) expr.inner.ccodenode;
+				pub_inst = get_cvalue (expr.inner);
 			}
 
 			var sig = (Signal) expr.symbol_reference;
@@ -558,7 +558,7 @@ public class Vala.GSignalModule : GObjectModule {
 				var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
 				vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
 				
-				expr.ccodenode = new CCodeMemberAccess.pointer (vcast, m.name);
+				set_cvalue (expr, new CCodeMemberAccess.pointer (vcast, m.name));
 				return;
 			}
 
@@ -566,14 +566,14 @@ public class Vala.GSignalModule : GObjectModule {
 				var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (cl.get_lower_case_cname (null), sig.name)));
 
 				ccall.add_argument (pub_inst);
-				expr.ccodenode = ccall;
+				set_cvalue (expr, ccall);
 			} else {
 				var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_emit_by_name"));
 				ccall.add_argument (pub_inst);
 
 				ccall.add_argument (sig.get_canonical_cconstant ());
 				
-				expr.ccodenode = ccall;
+				set_cvalue (expr, ccall);
 			}
 		} else {
 			base.visit_member_access (expr);
@@ -596,7 +596,7 @@ public class Vala.GSignalModule : GObjectModule {
 		bool disconnect = (method_type.method_symbol.name == "disconnect");
 		bool after = (method_type.method_symbol.name == "connect_after");
 
-		expr.ccodenode = connect_signal (sig, signal_access, handler, disconnect, after, expr);
+		set_cvalue (expr, connect_signal (sig, signal_access, handler, disconnect, after, expr));
 	}
 
 	CCodeExpression? connect_signal (Signal sig, Expression signal_access, Expression handler, bool disconnect, bool after, CodeNode expr) {
@@ -711,7 +711,7 @@ public class Vala.GSignalModule : GObjectModule {
 		}
 
 		// third resp. sixth argument: handler
-		ccall.add_argument (new CCodeCastExpression ((CCodeExpression) handler.ccodenode, "GCallback"));
+		ccall.add_argument (new CCodeCastExpression (get_cvalue (handler), "GCallback"));
 
 		if (m.closure) {
 			// g_signal_connect_data
@@ -736,7 +736,7 @@ public class Vala.GSignalModule : GObjectModule {
 			if (handler is MemberAccess) {
 				var right_ma = (MemberAccess) handler;
 				if (right_ma.inner != null) {
-					ccall.add_argument ((CCodeExpression) right_ma.inner.ccodenode);
+					ccall.add_argument (get_cvalue (right_ma.inner));
 				} else {
 					ccall.add_argument (get_result_cexpression ("self"));
 				}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index a09551f..bca6263 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -2116,7 +2116,7 @@ public class Vala.GTypeModule : GErrorModule {
 		ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_var.name), get_value));
 		var is_null_value = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_variable_cexpression (temp_var.name), new CCodeIdentifier ("NULL"));
 		ccomma.append_expression (new CCodeConditionalExpression (is_null_value, new CCodeMemberAccess.pointer (get_variable_cexpression (temp_var.name), "value_name"), new CCodeIdentifier ("NULL")));
-		expr.ccodenode = ccomma;
+		set_cvalue (expr, ccomma);
 	}
 
 	public override void visit_property (Property prop) {



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