[vala] codegen: Drop CCodeModule



commit 449a0c01538b445b3d3c1dca1a94aa5b5b1fb24e
Author: Jürg Billeter <j bitron ch>
Date:   Sat Aug 7 22:01:51 2010 +0200

    codegen: Drop CCodeModule

 codegen/Makefile.am                      |    2 -
 codegen/valaccodearraymodule.vala        |   10 +-
 codegen/valaccodeassignmentmodule.vala   |   14 +-
 codegen/valaccodebasemodule.vala         |  206 ++++++++++-----
 codegen/valaccodecontrolflowmodule.vala  |   34 +--
 codegen/valaccodedelegatemodule.vala     |   18 +-
 codegen/valaccodegenerator.vala          |  394 --------------------------
 codegen/valaccodememberaccessmodule.vala |   12 +-
 codegen/valaccodemethodcallmodule.vala   |   18 +-
 codegen/valaccodemethodmodule.vala       |   18 +-
 codegen/valaccodemodule.vala             |  441 ------------------------------
 codegen/valaccodestructmodule.vala       |   10 +-
 codegen/valadbusclientmodule.vala        |   38 ++--
 codegen/valadbusmodule.vala              |    4 -
 codegen/valadbusservermodule.vala        |   10 +-
 codegen/valadovaarraymodule.vala         |    6 +-
 codegen/valadovaassignmentmodule.vala    |    6 +-
 codegen/valadovabasemodule.vala          |   67 +++---
 codegen/valadovacontrolflowmodule.vala   |   18 +-
 codegen/valadovadelegatemodule.vala      |    8 +-
 codegen/valadovaerrormodule.vala         |   18 +-
 codegen/valadovamemberaccessmodule.vala  |   15 +-
 codegen/valadovamethodcallmodule.vala    |    6 +-
 codegen/valadovamethodmodule.vala        |    6 +-
 codegen/valadovaobjectmodule.vala        |   28 +-
 codegen/valadovastructmodule.vala        |    8 +-
 codegen/valadovavaluemodule.vala         |    8 +-
 codegen/valagasyncmodule.vala            |    6 +-
 codegen/valagdbusclientmodule.vala       |   12 +-
 codegen/valagdbusmodule.vala             |    4 -
 codegen/valagdbusservermodule.vala       |   10 +-
 codegen/valagerrormodule.vala            |   16 +-
 codegen/valagobjectmodule.vala           |   16 +-
 codegen/valagsignalmodule.vala           |   14 +-
 codegen/valagtypemodule.vala             |   34 +--
 codegen/valagvariantmodule.vala          |    4 -
 compiler/valacompiler.vala               |   12 +-
 37 files changed, 334 insertions(+), 1217 deletions(-)
---
diff --git a/codegen/Makefile.am b/codegen/Makefile.am
index e9f661e..3bb5b5b 100644
--- a/codegen/Makefile.am
+++ b/codegen/Makefile.am
@@ -22,11 +22,9 @@ libvala_la_VALASOURCES = \
 	valaccodecontrolflowmodule.vala \
 	valaccodedeclarationspace.vala \
 	valaccodedelegatemodule.vala \
-	valaccodegenerator.vala \
 	valaccodememberaccessmodule.vala \
 	valaccodemethodcallmodule.vala \
 	valaccodemethodmodule.vala \
-	valaccodemodule.vala \
 	valaccodestructmodule.vala \
 	valaclassregisterfunction.vala \
 	valactype.vala \
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 9d67ff3..cf36479 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -27,10 +27,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 	int next_array_dup_id = 0;
 	int next_array_add_id = 0;
 
-	public CCodeArrayModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	void append_initializer_list (CCodeCommaExpression ce, CCodeExpression name_cnode, InitializerList initializer_list, int rank, ref int i) {
 		foreach (Expression e in initializer_list.get_initializers ()) {
 			if (rank > 1) {
@@ -411,7 +407,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 			var memberaccess = expr.container as MemberAccess;
 			if (lit != null && memberaccess != null) {
 				int dim = lit.value.to_int ();
-				expr.ccodenode = head.get_array_length_cexpression (memberaccess.inner, dim + 1);
+				expr.ccodenode = get_array_length_cexpression (memberaccess.inner, dim + 1);
 			} else {
 				Report.error (expr.source_reference, "only integer literals supported as index");
 			}
@@ -430,7 +426,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 		} else {
 			// access to element in an array
 			for (int i = 1; i < rank; i++) {
-				var cmul = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, cindex, head.get_array_length_cexpression (expr.container, i + 1));
+				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);
 			}
 			expr.ccodenode = new CCodeElementAccess (ccontainer, cindex);
@@ -1039,7 +1035,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 			}
 			
 			for (int dim = 1; dim <= array_type.rank; dim++) {
-				var cparam = new CCodeFormalParameter (head.get_array_length_cname (get_variable_cname (param.name), dim), length_ctype);
+				var cparam = new CCodeFormalParameter (get_array_length_cname (get_variable_cname (param.name), dim), length_ctype);
 				cparam_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), cparam);
 				if (carg_map != null) {
 					carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), get_variable_cexpression (cparam.name));
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index 1e6b921..c1009b2 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -28,10 +28,6 @@ using GLib;
  * The link between an assignment and generated code.
  */
 public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
-	public CCodeAssignmentModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	CCodeExpression emit_property_assignment (Assignment assignment) {
 		var ma = assignment.left as MemberAccess;
 
@@ -50,7 +46,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 		}
 
 		if (prop.set_accessor.construction && current_type_symbol is Class && current_class.is_subtype_of (gobject_type) && in_creation_method) {
-			return head.get_construct_property_assignment (prop.get_canonical_cconstant (), prop.property_type, (CCodeExpression) assignment.right.ccodenode);
+			return get_construct_property_assignment (prop.get_canonical_cconstant (), prop.property_type, (CCodeExpression) assignment.right.ccodenode);
 		} else {
 			CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode;
 
@@ -150,8 +146,8 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 			if (array) {
 				var array_type = (ArrayType) assignment.left.value_type;
 				for (int dim = 1; dim <= array_type.rank; dim++) {
-					var lhs_array_len = head.get_array_length_cexpression (assignment.left, dim);
-					var rhs_array_len = head.get_array_length_cexpression (assignment.right, dim);
+					var lhs_array_len = get_array_length_cexpression (assignment.left, dim);
+					var rhs_array_len = get_array_length_cexpression (assignment.right, dim);
 					ccomma.append_expression (new CCodeAssignment (lhs_array_len, rhs_array_len));
 				}
 				if (array_type.rank == 1) {
@@ -159,8 +155,8 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 					var array_local = array_var as LocalVariable;
 					if (array_var != null && array_var.is_internal_symbol ()
 					    && ((array_var is LocalVariable && !array_local.captured) || array_var is Field)) {
-						var lhs_array_size = head.get_array_size_cexpression (assignment.left);
-						var rhs_array_len = head.get_array_length_cexpression (assignment.left, 1);
+						var lhs_array_size = get_array_size_cexpression (assignment.left);
+						var rhs_array_len = get_array_length_cexpression (assignment.left, 1);
 						ccomma.append_expression (new CCodeAssignment (lhs_array_size, rhs_array_len));
 					}
 				}
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0905507..95a190c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -26,7 +26,7 @@
 /**
  * Code visitor generating C Code.
  */
-public class Vala.CCodeBaseModule : CCodeModule {
+public class Vala.CCodeBaseModule : CodeGenerator {
 	public CodeContext context { get; set; }
 
 	public Symbol root_symbol;
@@ -216,9 +216,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
 	public Map<string,string> variable_name_map = new HashMap<string,string> (str_hash, str_equal);
 
-	public CCodeBaseModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-
+	public CCodeBaseModule () {
 		predefined_marshal_set = new HashSet<string> (str_hash, str_equal);
 		predefined_marshal_set.add ("VOID:VOID");
 		predefined_marshal_set.add ("VOID:BOOLEAN");
@@ -375,7 +373,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		var source_files = context.get_source_files ();
 		foreach (SourceFile file in source_files) {
 			if (!file.external_package) {
-				file.accept (codegen);
+				file.accept (this);
 			}
 		}
 
@@ -477,7 +475,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		}
 	}
 
-	public override CCodeIdentifier get_value_setter_function (DataType type_reference) {
+	public CCodeIdentifier get_value_setter_function (DataType type_reference) {
 		var array_type = type_reference as ArrayType;
 		if (type_reference.data_type != null) {
 			return new CCodeIdentifier (type_reference.data_type.get_set_value_function ());
@@ -489,7 +487,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		}
 	}
 
-	public override CCodeIdentifier get_value_taker_function (DataType type_reference) {
+	public CCodeIdentifier get_value_taker_function (DataType type_reference) {
 		var array_type = type_reference as ArrayType;
 		if (type_reference.data_type != null) {
 			return new CCodeIdentifier (type_reference.data_type.get_take_value_function ());
@@ -588,7 +586,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 			source_declarations.add_include ("glib-object.h");
 		}
 
-		source_file.accept_children (codegen);
+		source_file.accept_children (this);
 
 		if (context.report.get_errors () > 0) {
 			return;
@@ -693,7 +691,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					flag_shift += 1;
 				}
 			} else {
-				ev.value.emit (codegen);
+				ev.value.emit (this);
 				c_ev = new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode);
 			}
 			c_ev.deprecated = ev.deprecated;
@@ -728,7 +726,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 	}
 
 	public override void visit_enum (Enum en) {
-		en.accept_children (codegen);
+		en.accept_children (this);
 
 		if (en.comment != null) {
 			source_type_member_definition.append (new CCodeComment (en.comment.content));
@@ -744,7 +742,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		}
 	}
 
-	public override void visit_member (Symbol m) {
+	public void visit_member (Symbol m) {
 		/* stuff meant for all lockable members */
 		if (m is Lockable && ((Lockable) m).get_lock_used ()) {
 			CCodeExpression l = new CCodeIdentifier ("self");
@@ -785,7 +783,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		if (!c.external) {
 			generate_type_declaration (c.type_reference, decl_space);
 
-			c.value.emit (codegen);
+			c.value.emit (this);
 
 			var initializer_list = c.value as InitializerList;
 			if (initializer_list != null) {
@@ -874,7 +872,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					var len_type = int_type.copy ();
 
 					cdecl = new CCodeDeclaration (len_type.get_cname ());
-					cdecl.add_declarator (new CCodeVariableDeclarator (head.get_array_length_cname (f.get_cname (), dim)));
+					cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (f.get_cname (), dim)));
 					if (f.is_private_symbol ()) {
 						cdecl.modifiers = CCodeModifiers.STATIC;
 					} else {
@@ -917,7 +915,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		check_type (f.variable_type);
 
 		if (f.initializer != null) {
-			f.initializer.emit (codegen);
+			f.initializer.emit (this);
 		}
 
 		var cl = f.parent_symbol as Class;
@@ -953,14 +951,14 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					
 					List<Expression> sizes = ((ArrayCreationExpression) f.initializer).get_sizes ();
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						var array_len_lhs = head.get_array_length_cexpression (ma, dim);
+						var array_len_lhs = get_array_length_cexpression (ma, dim);
 						var size = sizes[dim - 1];
 						instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode)));
 					}
 
 					if (array_type.rank == 1 && f.is_internal_symbol ()) {
-						var lhs_array_size = head.get_array_size_cexpression (ma);
-						var rhs_array_len = head.get_array_length_cexpression (ma, 1);
+						var lhs_array_size = get_array_size_cexpression (ma);
+						var rhs_array_len = get_array_length_cexpression (ma, 1);
 						instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (lhs_array_size, rhs_array_len)));
 					}
 				}
@@ -1066,7 +1064,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 						var len_type = int_type.copy ();
 
 						var len_def = new CCodeDeclaration (len_type.get_cname ());
-						len_def.add_declarator (new CCodeVariableDeclarator (head.get_array_length_cname (f.get_cname (), dim), new CCodeConstant ("0")));
+						len_def.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (f.get_cname (), dim), new CCodeConstant ("0")));
 						if (!f.is_private_symbol ()) {
 							len_def.modifiers = CCodeModifiers.EXTERN;
 						} else {
@@ -1079,7 +1077,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 						var len_type = int_type.copy ();
 
 						var cdecl = new CCodeDeclaration (len_type.get_cname ());
-						cdecl.add_declarator (new CCodeVariableDeclarator (head.get_array_size_cname (f.get_cname ()), new CCodeConstant ("0")));
+						cdecl.add_declarator (new CCodeVariableDeclarator (get_array_size_cname (f.get_cname ()), new CCodeConstant ("0")));
 						cdecl.modifiers = CCodeModifiers.STATIC;
 						source_declarations.add_type_member_declaration (cdecl);
 					}
@@ -1144,7 +1142,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					
 							List<Expression> sizes = ((ArrayCreationExpression) f.initializer).get_sizes ();
 							for (int dim = 1; dim <= array_type.rank; dim++) {
-								var array_len_lhs = head.get_array_length_cexpression (ma, dim);
+								var array_len_lhs = get_array_length_cexpression (ma, dim);
 								var size = sizes[dim - 1];
 								class_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode)));
 							}
@@ -1235,7 +1233,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		temp_ref_vars = new ArrayList<LocalVariable> ();
 		variable_name_map = new HashMap<string,string> (str_hash, str_equal);
 
-		prop.accept_children (codegen);
+		prop.accept_children (this);
 
 		next_temp_var_id = old_next_temp_var_id;
 		temp_vars = old_temp_vars;
@@ -1342,7 +1340,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 			}
 
 			for (int dim = 1; dim <= array_type.rank; dim++) {
-				function.add_parameter (new CCodeFormalParameter (head.get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
+				function.add_parameter (new CCodeFormalParameter (get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
 			}
 		} else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
 			function.add_parameter (new CCodeFormalParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
@@ -1369,11 +1367,11 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		bool returns_real_struct = acc.readable && prop.property_type.is_real_non_null_struct_type ();
 
 		if (acc.result_var != null) {
-			acc.result_var.accept (codegen);
+			acc.result_var.accept (this);
 		}
 
 		if (acc.body != null) {
-			acc.body.emit (codegen);
+			acc.body.emit (this);
 		}
 
 		var t = (TypeSymbol) prop.parent_symbol;
@@ -1440,7 +1438,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 				}
 
 				for (int dim = 1; dim <= array_type.rank; dim++) {
-					function.add_parameter (new CCodeFormalParameter (head.get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
+					function.add_parameter (new CCodeFormalParameter (get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
 				}
 			} else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
 				function.add_parameter (new CCodeFormalParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
@@ -1477,7 +1475,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 						var array_type = (ArrayType) acc.value_type;
 
 						for (int dim = 1; dim <= array_type.rank; dim++) {
-							var len_expr = new CCodeIdentifier (head.get_array_length_cname ("result", dim));
+							var len_expr = new CCodeIdentifier (get_array_length_cname ("result", dim));
 							vcall.add_argument (len_expr);
 						}
 					}
@@ -1493,7 +1491,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					var array_type = (ArrayType) acc.value_type;
 
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						var len_expr = new CCodeIdentifier (head.get_array_length_cname ("value", dim));
+						var len_expr = new CCodeIdentifier (get_array_length_cname ("value", dim));
 						vcall.add_argument (len_expr);
 					}
 				}
@@ -1551,7 +1549,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 				}
 
 				for (int dim = 1; dim <= array_type.rank; dim++) {
-					function.add_parameter (new CCodeFormalParameter (head.get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
+					function.add_parameter (new CCodeFormalParameter (get_array_length_cname (acc.readable ? "result" : "value", dim), length_ctype));
 				}
 			} else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
 				function.add_parameter (new CCodeFormalParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
@@ -1620,7 +1618,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		bool old_method_inner_error = current_method_inner_error;
 		current_method_inner_error = false;
 
-		d.body.emit (codegen);
+		d.body.emit (this);
 
 		if (d.binding == MemberBinding.STATIC && !in_plugin) {
 			Report.error (d.source_reference, "static destructors are only supported for dynamic types");
@@ -1712,11 +1710,10 @@ public class Vala.CCodeBaseModule : CCodeModule {
 	}
 
 	public override void visit_block (Block b) {
-		var old_symbol = current_symbol;
-		current_symbol = b;
+		emit_context.push_symbol (b);
 
 		foreach (Statement stmt in b.get_statements ()) {
-			stmt.emit (codegen);
+			stmt.emit (this);
 		}
 
 		var local_vars = b.get_local_variables ();
@@ -1944,7 +1941,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
 		b.ccodenode = cblock;
 
-		current_symbol = old_symbol;
+		emit_context.pop_symbol ();
 	}
 
 	public override void visit_empty_statement (EmptyStatement stmt) {
@@ -1952,7 +1949,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 	}
 
 	public override void visit_declaration_statement (DeclarationStatement stmt) {
-		stmt.declaration.accept (codegen);
+		stmt.declaration.accept (this);
 
 		stmt.ccodenode = stmt.declaration.ccodenode;
 
@@ -2014,7 +2011,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		check_type (local.variable_type);
 
 		if (local.initializer != null) {
-			local.initializer.emit (codegen);
+			local.initializer.emit (this);
 
 			visit_end_full_expression (local.initializer);
 		}
@@ -2028,12 +2025,12 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
 				if (!array_type.fixed_length) {
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						var len_var = new LocalVariable (int_type.copy (), head.get_array_length_cname (get_variable_cname (local.name), dim));
+						var len_var = new LocalVariable (int_type.copy (), get_array_length_cname (get_variable_cname (local.name), dim));
 						temp_vars.add (len_var);
 					}
 
 					if (array_type.rank == 1) {
-						var size_var = new LocalVariable (int_type.copy (), head.get_array_size_cname (get_variable_cname (local.name)));
+						var size_var = new LocalVariable (int_type.copy (), get_array_size_cname (get_variable_cname (local.name)));
 						temp_vars.add (size_var);
 					}
 				}
@@ -2073,13 +2070,13 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (temp_var.name), rhs));
 
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						var lhs_array_len = head.get_array_length_cexpression (ma, dim);
-						var rhs_array_len = head.get_array_length_cexpression (local.initializer, dim);
+						var lhs_array_len = get_array_length_cexpression (ma, dim);
+						var rhs_array_len = get_array_length_cexpression (local.initializer, dim);
 						ccomma.append_expression (new CCodeAssignment (lhs_array_len, rhs_array_len));
 					}
 					if (array_type.rank == 1 && !local.captured) {
-						var lhs_array_size = head.get_array_size_cexpression (ma);
-						var rhs_array_len = head.get_array_length_cexpression (ma, 1);
+						var lhs_array_size = get_array_size_cexpression (ma);
+						var rhs_array_len = get_array_length_cexpression (ma, 1);
 						ccomma.append_expression (new CCodeAssignment (lhs_array_size, rhs_array_len));
 					}
 				
@@ -2133,7 +2130,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					var ccomma = new CCodeCommaExpression ();
 
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (head.get_array_length_cname (get_variable_cname (local.name), dim)), new CCodeConstant ("0")));
+						ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (get_array_length_cname (get_variable_cname (local.name), dim)), new CCodeConstant ("0")));
 					}
 
 					ccomma.append_expression (rhs);
@@ -2217,7 +2214,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		}
 
 		if (local.initializer != null && local.initializer.tree_can_fail) {
-			head.add_simple_check (local.initializer, cfrag);
+			add_simple_check (local.initializer, cfrag);
 		}
 
 		local.ccodenode = cfrag;
@@ -3019,10 +3016,10 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					bool first = true;
 					for (int dim = 1; dim <= array_type.rank; dim++) {
 						if (first) {
-							csizeexpr = head.get_array_length_cexpression (expr, dim);
+							csizeexpr = get_array_length_cexpression (expr, dim);
 							first = false;
 						} else {
-							csizeexpr = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, csizeexpr, head.get_array_length_cexpression (expr, dim));
+							csizeexpr = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, csizeexpr, get_array_length_cexpression (expr, dim));
 						}
 					}
 
@@ -3220,7 +3217,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
 		if (stmt.tree_can_fail && stmt.expression.tree_can_fail) {
 			// simple case, no node breakdown necessary
-			head.add_simple_check (stmt.expression, cfrag);
+			add_simple_check (stmt.expression, cfrag);
 		}
 
 		stmt.ccodenode = cfrag;
@@ -3383,11 +3380,11 @@ public class Vala.CCodeBaseModule : CCodeModule {
 			var array_type = (ArrayType) current_return_type;
 
 			for (int dim = 1; dim <= array_type.rank; dim++) {
-				var len_l = get_result_cexpression (head.get_array_length_cname ("result", dim));
+				var len_l = get_result_cexpression (get_array_length_cname ("result", dim));
 				if (current_method == null || !current_method.coroutine) {
 					len_l = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, len_l);
 				}
-				var len_r = head.get_array_length_cexpression (stmt.return_expression, dim);
+				var len_r = get_array_length_cexpression (stmt.return_expression, dim);
 				ccomma.append_expression (new CCodeAssignment (len_l, len_r));
 			}
 
@@ -3958,10 +3955,10 @@ public class Vala.CCodeBaseModule : CCodeModule {
 				CCodeExpression csizeexpr = null;
 				for (int dim = 1; dim <= array_type.rank; dim++) {
 					if (first) {
-						csizeexpr = head.get_array_length_cexpression (expr, dim);
+						csizeexpr = get_array_length_cexpression (expr, dim);
 						first = false;
 					} else {
-						csizeexpr = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, csizeexpr, head.get_array_length_cexpression (expr, dim));
+						csizeexpr = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, csizeexpr, get_array_length_cexpression (expr, dim));
 					}
 				}
 
@@ -4246,7 +4243,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 						if (!param.no_array_length && param.variable_type is ArrayType) {
 							var array_type = (ArrayType) param.variable_type;
 							for (int dim = 1; dim <= array_type.rank; dim++) {
-								carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), head.get_array_length_cexpression (arg, dim));
+								carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), get_array_length_cexpression (arg, dim));
 							}
 						} else if (param.variable_type is DelegateType) {
 							var deleg_type = (DelegateType) param.variable_type;
@@ -4294,7 +4291,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 				/* evaluate default expression here as the code
 				 * generator might not have visited the formal
 				 * parameter yet */
-				param.initializer.emit (codegen);
+				param.initializer.emit (this);
 			
 				carg_map.set (get_param_pos (param.cparameter_position), (CCodeExpression) param.initializer.ccodenode);
 				i++;
@@ -4340,7 +4337,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
 			// cast the return value of the creation method back to the intended type if
 			// it requested a special C return type
-			if (head.get_custom_creturn_type (m) != null) {
+			if (get_custom_creturn_type (m) != null) {
 				creation_expr = new CCodeCastExpression (creation_expr, expr.type_reference.get_cname ());
 			}
 		} else if (expr.symbol_reference is ErrorCode) {
@@ -4398,11 +4395,11 @@ public class Vala.CCodeBaseModule : CCodeModule {
 						var array_type = (ArrayType) f.variable_type;
 						for (int dim = 1; dim <= array_type.rank; dim++) {
 							if (expr.type_reference.data_type is Struct) {
-								lhs = new CCodeMemberAccess (typed_inst, head.get_array_length_cname (f.get_cname (), dim));
+								lhs = new CCodeMemberAccess (typed_inst, get_array_length_cname (f.get_cname (), dim));
 							} else {
-								lhs = new CCodeMemberAccess.pointer (typed_inst, head.get_array_length_cname (f.get_cname (), dim));
+								lhs = new CCodeMemberAccess.pointer (typed_inst, get_array_length_cname (f.get_cname (), dim));
 							}
-							var rhs_array_len = head.get_array_length_cexpression (init.initializer, dim);
+							var rhs_array_len = get_array_length_cexpression (init.initializer, dim);
 							ccomma.append_expression (new CCodeAssignment (lhs, rhs_array_len));
 						}
 					} else if (f.variable_type is DelegateType && !f.no_delegate_target) {
@@ -4577,7 +4574,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 				temp_vars.add (temp_decl);
 
 				ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (temp_decl.name)));
-				cfunc.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("result", dim), "int*"));
+				cfunc.add_parameter (new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*"));
 				expr.append_array_size (new CCodeIdentifier (temp_decl.name));
 			}
 		}
@@ -5012,7 +5009,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		temp_vars = new ArrayList<LocalVariable> ();
 		temp_ref_vars = new ArrayList<LocalVariable> ();
 
-		l.accept_children (codegen);
+		l.accept_children (this);
 
 		temp_vars = old_temp_vars;
 		temp_ref_vars = old_temp_ref_vars;
@@ -5109,9 +5106,9 @@ public class Vala.CCodeBaseModule : CCodeModule {
 					var ccomma = new CCodeCommaExpression ();
 					ccomma.append_expression (cexpr);
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						var len_decl = new LocalVariable (int_type.copy (), head.get_array_length_cname (decl.name, dim));
+						var len_decl = new LocalVariable (int_type.copy (), get_array_length_cname (decl.name, dim));
 						temp_vars.add (len_decl);
-						ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (len_decl.name), head.get_array_length_cexpression (expr, dim)));
+						ccomma.append_expression (new CCodeAssignment (get_variable_cexpression (len_decl.name), get_array_length_cexpression (expr, dim)));
 					}
 					ccomma.append_expression (get_variable_cexpression (decl.name));
 					cexpr = ccomma;
@@ -5200,8 +5197,8 @@ public class Vala.CCodeBaseModule : CCodeModule {
 				var array_type = (ArrayType) expression_type;
 
 				for (int dim = 1; dim <= array_type.rank; dim++) {
-					ccall.add_argument (head.get_array_length_cexpression (expr, dim));
-					cfunc.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("value", dim), "gint"));
+					ccall.add_argument (get_array_length_cexpression (expr, dim));
+					cfunc.add_parameter (new CCodeFormalParameter (get_array_length_cname ("value", dim), "gint"));
 				}
 			}
 
@@ -5328,7 +5325,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 			}
 
 			if (prop is DynamicProperty) {
-				set_func = head.get_dynamic_property_setter_cname ((DynamicProperty) prop);
+				set_func = get_dynamic_property_setter_cname ((DynamicProperty) prop);
 			} else {
 				generate_property_accessor_declaration (base_property.set_accessor, source_declarations);
 				set_func = base_property.set_accessor.get_cname ();
@@ -5389,7 +5386,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
 		if (array_type != null && !prop.no_array_length && rhs != null) {
 			for (int dim = 1; dim <= array_type.rank; dim++) {
-				ccall.add_argument (head.get_array_length_cexpression (rhs, dim));
+				ccall.add_argument (get_array_length_cexpression (rhs, dim));
 			}
 		} else if (prop.property_type is DelegateType && rhs != null) {
 			var delegate_type = (DelegateType) prop.property_type;
@@ -5575,7 +5572,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
 	public CCodeNode? get_ccodenode (CodeNode node) {
 		if (node.ccodenode == null) {
-			node.emit (codegen);
+			node.emit (this);
 		}
 		return node.ccodenode;
 	}
@@ -5719,6 +5716,85 @@ public class Vala.CCodeBaseModule : CCodeModule {
 		function.block = cblock;
 		source_type_member_definition.append (function);
 	}
+
+	public virtual string? get_custom_creturn_type (Method m) {
+		return null;
+	}
+
+	public virtual void generate_dynamic_method_wrapper (DynamicMethod method) {
+	}
+
+	public virtual bool method_has_wrapper (Method method) {
+		return false;
+	}
+
+	public virtual CCodeExpression get_construct_property_assignment (CCodeConstant canonical_cconstant, DataType property_type, CCodeExpression value) {
+		return new CCodeConstant ("");
+	}
+
+	public virtual CCodeFunctionCall get_param_spec (Property prop) {
+		return new CCodeFunctionCall (new CCodeIdentifier (""));
+	}
+
+	public virtual CCodeFunctionCall get_signal_creation (Signal sig, TypeSymbol type) {
+		return new CCodeFunctionCall (new CCodeIdentifier (""));
+	}
+
+	public virtual CCodeFragment register_dbus_info (ObjectTypeSymbol bindable) {
+		return new CCodeFragment ();
+	}
+
+	public virtual string get_dynamic_property_getter_cname (DynamicProperty node) {
+		Report.error (node.source_reference, "dynamic properties are not supported for %s".printf (node.dynamic_type.to_string ()));
+		return "";
+	}
+
+	public virtual string get_dynamic_property_setter_cname (DynamicProperty node) {
+		Report.error (node.source_reference, "dynamic properties are not supported for %s".printf (node.dynamic_type.to_string ()));
+		return "";
+	}
+
+	public virtual string get_dynamic_signal_cname (DynamicSignal node) {
+		return "";
+	}
+
+	public virtual string get_dynamic_signal_connect_wrapper_name (DynamicSignal node) {
+		return "";
+	}
+
+	public virtual string get_dynamic_signal_connect_after_wrapper_name (DynamicSignal node) {
+		return "";
+	}
+
+	public virtual string get_dynamic_signal_disconnect_wrapper_name (DynamicSignal node) {
+		return "";
+	}
+
+	public virtual void generate_marshaller (List<FormalParameter> params, DataType return_type, bool dbus = false) {
+	}
+
+	public virtual string get_marshaller_function (List<FormalParameter> params, DataType return_type, string? prefix = null, bool dbus = false) {
+		return "";
+	}
+
+	public virtual string get_array_length_cname (string array_cname, int dim) {
+		return "";
+	}
+
+	public virtual CCodeExpression get_array_length_cexpression (Expression array_expr, int dim = -1) {
+		return new CCodeConstant ("");
+	}
+
+	public virtual string get_array_size_cname (string array_cname) {
+		return "";
+	}
+
+	public virtual CCodeExpression get_array_size_cexpression (Expression array_expr) {
+		return new CCodeConstant ("");
+	}
+
+	public virtual void add_simple_check (CodeNode node, CCodeFragment cfrag, bool always_fails = false) {
+	}
 }
 
 // vim:sw=8 noet
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index 7b938f8..dc66708 100644
--- a/codegen/valaccodecontrolflowmodule.vala
+++ b/codegen/valaccodecontrolflowmodule.vala
@@ -25,14 +25,10 @@
 using GLib;
 
 public class Vala.CCodeControlFlowModule : CCodeMethodModule {
-	public CCodeControlFlowModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void visit_if_statement (IfStatement stmt) {
-		stmt.true_statement.emit (codegen);
+		stmt.true_statement.emit (this);
 		if (stmt.false_statement != null) {
-			stmt.false_statement.emit (codegen);
+			stmt.false_statement.emit (this);
 		}
 
 		if (stmt.false_statement != null) {
@@ -193,7 +189,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 
 	public override void visit_switch_statement (SwitchStatement stmt) {
 		foreach (SwitchSection section in stmt.get_sections ()) {
-			section.emit (codegen);
+			section.emit (this);
 		}
 
 		if (stmt.expression.value_type.compatible (string_type)) {
@@ -227,14 +223,14 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 
 	public override void visit_switch_label (SwitchLabel label) {
 		if (label.expression != null) {
-			label.expression.emit (codegen);
+			label.expression.emit (this);
 
-			codegen.visit_end_full_expression (label.expression);
+			visit_end_full_expression (label.expression);
 		}
 	}
 
 	public override void visit_loop (Loop stmt) {
-		stmt.body.emit (codegen);
+		stmt.body.emit (this);
 
 		if (context.profile == Profile.GOBJECT) {
 			stmt.ccodenode = new CCodeWhileStatement (new CCodeConstant ("TRUE"), (CCodeStatement) stmt.body.ccodenode);
@@ -245,7 +241,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 	}
 
 	public override void visit_foreach_statement (ForeachStatement stmt) {
-		stmt.body.emit (codegen);
+		stmt.body.emit (this);
 
 		visit_block (stmt);
 
@@ -280,22 +276,22 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 		if (stmt.tree_can_fail && stmt.collection.tree_can_fail) {
 			// exception handling
 			cfrag = new CCodeFragment ();
-			head.add_simple_check (stmt.collection, cfrag);
+			add_simple_check (stmt.collection, cfrag);
 			cblock.add_statement (cfrag);
 		}
 
 		if (stmt.collection.value_type is ArrayType) {
 			array_type = (ArrayType) stmt.collection.value_type;
 			
-			var array_len = head.get_array_length_cexpression (stmt.collection);
+			var array_len = get_array_length_cexpression (stmt.collection);
 
 			// store array length for use by _vala_array_free
 			if (current_method != null && current_method.coroutine) {
-				closure_struct.add_field ("int", head.get_array_length_cname (collection_backup.name, 1));
-				cblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (get_variable_cexpression (head.get_array_length_cname (collection_backup.name, 1)), array_len)));
+				closure_struct.add_field ("int", get_array_length_cname (collection_backup.name, 1));
+				cblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (get_variable_cexpression (get_array_length_cname (collection_backup.name, 1)), array_len)));
 			} else {
 				var clendecl = new CCodeDeclaration ("int");
-				clendecl.add_declarator (new CCodeVariableDeclarator (head.get_array_length_cname (collection_backup.name, 1), array_len));
+				clendecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (collection_backup.name, 1), array_len));
 				cblock.add_statement (clendecl);
 			}
 
@@ -336,11 +332,11 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
 				var inner_array_type = (ArrayType) stmt.type_reference;
 				for (int dim = 1; dim <= inner_array_type.rank; dim++) {
 					if (current_method != null && current_method.coroutine) {
-						closure_struct.add_field ("int", head.get_array_length_cname (stmt.variable_name, dim));
-						cbody.add_statement (new CCodeExpressionStatement (new CCodeAssignment (get_variable_cexpression (head.get_array_length_cname (stmt.variable_name, dim)), new CCodeConstant ("-1"))));
+						closure_struct.add_field ("int", get_array_length_cname (stmt.variable_name, dim));
+						cbody.add_statement (new CCodeExpressionStatement (new CCodeAssignment (get_variable_cexpression (get_array_length_cname (stmt.variable_name, dim)), new CCodeConstant ("-1"))));
 					} else {
 						var cdecl = new CCodeDeclaration ("int");
-						cdecl.add_declarator (new CCodeVariableDeclarator (head.get_array_length_cname (stmt.variable_name, dim), new CCodeConstant ("-1")));
+						cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (stmt.variable_name, dim), new CCodeConstant ("-1")));
 						cbody.add_statement (cdecl);
 					}
 				}
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index 706d8bf..e18b1fb 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -27,10 +27,6 @@
  * The link between an assignment and generated code.
  */
 public class Vala.CCodeDelegateModule : CCodeArrayModule {
-	public CCodeDelegateModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void generate_delegate_declaration (Delegate d, CCodeDeclarationSpace decl_space) {
 		if (decl_space.add_symbol_declaration (d, d.get_cname ())) {
 			return;
@@ -66,7 +62,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 				}
 				
 				for (int dim = 1; dim <= array_type.rank; dim++) {
-					var cparam = new CCodeFormalParameter (head.get_array_length_cname (get_variable_cname (param.name), dim), length_ctype);
+					var cparam = new CCodeFormalParameter (get_array_length_cname (get_variable_cname (param.name), dim), length_ctype);
 					cfundecl.add_parameter (cparam);
 				}
 			}
@@ -85,7 +81,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 			var array_type = (ArrayType) d.return_type;
 
 			for (int dim = 1; dim <= array_type.rank; dim++) {
-				var cparam = new CCodeFormalParameter (head.get_array_length_cname ("result", dim), "int*");
+				var cparam = new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*");
 				cfundecl.add_parameter (cparam);
 			}
 		} else if (d.return_type is DelegateType) {
@@ -116,7 +112,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 	}
 
 	public override void visit_delegate (Delegate d) {
-		d.accept_children (codegen);
+		d.accept_children (this);
 
 		generate_delegate_declaration (d, source_declarations);
 
@@ -356,7 +352,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 		var sig = d.parent_symbol as Signal;
 		var dynamic_sig = sig as DynamicSignal;
 		if (dynamic_sig != null) {
-			delegate_name = head.get_dynamic_signal_cname (dynamic_sig);
+			delegate_name = get_dynamic_signal_cname (dynamic_sig);
 		} else if (sig != null) {
 			delegate_name = sig.parent_symbol.get_lower_case_cprefix () + sig.get_cname ();
 		} else {
@@ -412,7 +408,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 			var array_type = (ArrayType) d.return_type;
 
 			for (int dim = 1; dim <= array_type.rank; dim++) {
-				var cparam = new CCodeFormalParameter (head.get_array_length_cname ("result", dim), "int*");
+				var cparam = new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*");
 				cparam_map.set (get_param_pos (d.carray_length_parameter_position + 0.01 * dim), cparam);
 			}
 		} else if (d.return_type is DelegateType) {
@@ -501,7 +497,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 					} else if (d_params.get (i).no_array_length) {
 						clength = new CCodeConstant ("-1");
 					} else {
-						clength = new CCodeIdentifier (head.get_array_length_cname (d_params.get (i).name, dim));
+						clength = new CCodeIdentifier (get_array_length_cname (d_params.get (i).name, dim));
 					}
 					carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), clength);
 				}
@@ -523,7 +519,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 				if (d.no_array_length) {
 					clength = new CCodeConstant ("NULL");
 				} else {
-					clength = new CCodeIdentifier (head.get_array_length_cname ("result", dim));
+					clength = new CCodeIdentifier (get_array_length_cname ("result", dim));
 				}
 				carg_map.set (get_param_pos (m.carray_length_parameter_position + 0.01 * dim), clength);
 			}
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index f71a5dc..d96a8a7 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -22,13 +22,7 @@
  *	Raffaele Sandrini <raffaele sandrini ch>
  */
 
-using GLib;
-
 public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
-	public CCodeMemberAccessModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void visit_member_access (MemberAccess expr) {
 		CCodeExpression pub_inst = null;
 	
@@ -69,7 +63,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			}
 
 			if (m.base_method != null) {
-				if (!head.method_has_wrapper (m.base_method)) {
+				if (!method_has_wrapper (m.base_method)) {
 					var inst = pub_inst;
 					if (expr.inner != null && !expr.inner.is_pure ()) {
 						// instance expression has side-effects
@@ -98,7 +92,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			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 = head.get_array_length_cexpression (expr.inner, 1);
+			expr.ccodenode = 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) {
@@ -249,7 +243,7 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				}
 				string getter_cname;
 				if (prop is DynamicProperty) {
-					getter_cname = head.get_dynamic_property_getter_cname ((DynamicProperty) prop);
+					getter_cname = get_dynamic_property_getter_cname ((DynamicProperty) prop);
 				} else {
 					getter_cname = base_property.get_accessor.get_cname ();
 				}
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index ec2b139..c3a03e7 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -25,10 +25,6 @@
 using GLib;
 
 public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
-	public CCodeMethodCallModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void visit_method_call (MethodCall expr) {
 		// the bare function call
 		var ccall = new CCodeFunctionCall ((CCodeExpression) expr.call.ccodenode);
@@ -282,9 +278,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 				param_nr++;
 			}
 			foreach (FormalParameter param in m.get_parameters ()) {
-				param.accept (codegen);
+				param.accept (this);
 			}
-			head.generate_dynamic_method_wrapper ((DynamicMethod) m);
+			generate_dynamic_method_wrapper ((DynamicMethod) m);
 		} else if (m is CreationMethod && context.profile == Profile.GOBJECT && m.parent_symbol is Class) {
 			ccall_expr = new CCodeAssignment (new CCodeIdentifier ("self"), new CCodeCastExpression (ccall, current_class.get_cname () + "*"));
 
@@ -364,17 +360,17 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 									}
 
 									comma.append_expression (ccall_expr);
-									comma.append_expression (new CCodeAssignment (get_variable_cexpression (head.get_array_length_cname (((UnaryExpression) arg).inner.to_string (), dim)), new CCodeCastExpression (get_variable_cexpression (temp_array_length.name), int_type.get_cname ())));
+									comma.append_expression (new CCodeAssignment (get_variable_cexpression (get_array_length_cname (((UnaryExpression) arg).inner.to_string (), dim)), new CCodeCastExpression (get_variable_cexpression (temp_array_length.name), int_type.get_cname ())));
 
 									if (temp_result != null) {
 										comma.append_expression (get_variable_cexpression (temp_result.name));
 									}
 									ccall_expr = comma;
 								} else {
-									array_length_expr = new CCodeCastExpression (head.get_array_length_cexpression (arg, dim), param.array_length_type);
+									array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), param.array_length_type);
 								}
 							} else {
-								array_length_expr = head.get_array_length_cexpression (arg, dim);
+								array_length_expr = get_array_length_cexpression (arg, dim);
 							}
 							carg_map.set (get_param_pos (param.carray_length_parameter_position + 0.01 * dim), array_length_expr);
 						}
@@ -772,7 +768,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			/* memset needs string.h */
 			source_declarations.add_include ("string.h");
 
-			var clen = head.get_array_length_cexpression (ma.inner, 1);
+			var clen = get_array_length_cexpression (ma.inner, 1);
 			var celems = (CCodeExpression) ma.inner.ccodenode;
 			var array_type = (ArrayType) ma.inner.value_type;
 			var csizeof = new CCodeIdentifier ("sizeof (%s)".printf (array_type.element_type.get_cname ()));
@@ -788,7 +784,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 			ccomma.append_expression (new CCodeAssignment (temp_ref, new_size));
 			ccomma.append_expression ((CCodeExpression) expr.ccodenode);
 			ccomma.append_expression (new CCodeConditionalExpression (ccheck, czero, new CCodeConstant ("NULL")));
-			ccomma.append_expression (new CCodeAssignment (head.get_array_length_cexpression (ma.inner, 1), temp_ref));
+			ccomma.append_expression (new CCodeAssignment (get_array_length_cexpression (ma.inner, 1), temp_ref));
 
 			expr.ccodenode = ccomma;
 		}
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index f7a223c..8df7ca4 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -27,10 +27,6 @@ using GLib;
  * The link between a method and generated code.
  */
 public class Vala.CCodeMethodModule : CCodeStructModule {
-	public CCodeMethodModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override bool method_has_wrapper (Method method) {
 		return (method.get_attribute ("NoWrapper") == null);
 	}
@@ -94,7 +90,7 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
 			var array_type = (ArrayType) m.return_type;
 
 			for (int dim = 1; dim <= array_type.rank; dim++) {
-				var cparam = new CCodeFormalParameter (head.get_array_length_cname ("result", dim), "int*");
+				var cparam = new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*");
 				cparam_map.set (get_param_pos (m.carray_length_parameter_position + 0.01 * dim), cparam);
 				if (carg_map != null) {
 					carg_map.set (get_param_pos (m.carray_length_parameter_position + 0.01 * dim), get_variable_cexpression (cparam.name));
@@ -319,23 +315,23 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
 
 
 		foreach (FormalParameter param in m.get_parameters ()) {
-			param.accept (codegen);
+			param.accept (this);
 		}
 
 		if (m.result_var != null) {
-			m.result_var.accept (codegen);
+			m.result_var.accept (this);
 		}
 
 		foreach (Expression precondition in m.get_preconditions ()) {
-			precondition.emit (codegen);
+			precondition.emit (this);
 		}
 
 		foreach (Expression postcondition in m.get_postconditions ()) {
-			postcondition.emit (codegen);
+			postcondition.emit (this);
 		}
 
 		if (m.body != null) {
-			m.body.emit (codegen);
+			m.body.emit (this);
 		}
 
 
@@ -1081,7 +1077,7 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
 	public override void visit_creation_method (CreationMethod m) {
 		bool visible = !m.is_private_symbol ();
 
-		head.visit_method (m);
+		visit_method (m);
 
 		DataType creturn_type;
 		if (current_type_symbol is Class) {
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index 16aaf14..fc0810b 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -25,10 +25,6 @@
 using GLib;
 
 public class Vala.CCodeStructModule : CCodeBaseModule {
-	public CCodeStructModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void generate_struct_declaration (Struct st, CCodeDeclarationSpace decl_space) {
 		if (decl_space.add_symbol_declaration (st, st.get_cname ())) {
 			return;
@@ -83,11 +79,11 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
 						var len_type = int_type.copy ();
 
 						for (int dim = 1; dim <= array_type.rank; dim++) {
-							instance_struct.add_field (len_type.get_cname (), head.get_array_length_cname (f.name, dim));
+							instance_struct.add_field (len_type.get_cname (), get_array_length_cname (f.name, dim));
 						}
 
 						if (array_type.rank == 1 && f.is_internal_symbol ()) {
-							instance_struct.add_field (len_type.get_cname (), head.get_array_size_cname (f.name));
+							instance_struct.add_field (len_type.get_cname (), get_array_size_cname (f.name));
 						}
 					}
 				} else if (f.variable_type is DelegateType) {
@@ -158,7 +154,7 @@ public class Vala.CCodeStructModule : CCodeBaseModule {
 			generate_struct_declaration (st, internal_header_declarations);
 		}
 
-		st.accept_children (codegen);
+		st.accept_children (this);
 
 		if (context.profile == Profile.GOBJECT && !st.is_boolean_type () && !st.is_integer_type () && !st.is_floating_type ()) {
 			if (st.is_disposable ()) {
diff --git a/codegen/valadbusclientmodule.vala b/codegen/valadbusclientmodule.vala
index 9593ff6..3d8703a 100644
--- a/codegen/valadbusclientmodule.vala
+++ b/codegen/valadbusclientmodule.vala
@@ -30,10 +30,6 @@ using GLib;
 public class Vala.DBusClientModule : DBusModule {
 	int dynamic_property_id;
 
-	public DBusClientModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	string get_dynamic_dbus_name (string vala_name) {
 		// TODO switch default to no transformation as soon as we have static D-Bus client support
 		// keep transformation by default for static D-Bus client and server support
@@ -270,7 +266,7 @@ public class Vala.DBusClientModule : DBusModule {
 						cdecl = new CCodeDeclaration ("GPtrArray*");
 
 						array_construct = new CCodeFunctionCall (new CCodeIdentifier ("g_ptr_array_sized_new"));
-						array_construct.add_argument (new CCodeIdentifier (head.get_array_length_cname (param.name, 1)));
+						array_construct.add_argument (new CCodeIdentifier (get_array_length_cname (param.name, 1)));
 					} else {
 						cdecl = new CCodeDeclaration ("GArray*");
 
@@ -289,16 +285,16 @@ public class Vala.DBusClientModule : DBusModule {
 						var memcpy_call = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
 						memcpy_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dbus_%s".printf (param.name)), "pdata"));
 						memcpy_call.add_argument (new CCodeIdentifier (param.name));
-						memcpy_call.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeIdentifier (head.get_array_length_cname (param.name, 1)), sizeof_call));
+						memcpy_call.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeIdentifier (get_array_length_cname (param.name, 1)), sizeof_call));
 						block.add_statement (new CCodeExpressionStatement (memcpy_call));
 
-						var len_assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dbus_%s".printf (param.name)), "len"), new CCodeIdentifier (head.get_array_length_cname (param.name, 1)));
+						var len_assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("dbus_%s".printf (param.name)), "len"), new CCodeIdentifier (get_array_length_cname (param.name, 1)));
 						block.add_statement (new CCodeExpressionStatement (len_assignment));
 					} else {
 						var cappend_call = new CCodeFunctionCall (new CCodeIdentifier ("g_array_append_vals"));
 						cappend_call.add_argument (new CCodeIdentifier ("dbus_%s".printf (param.name)));
 						cappend_call.add_argument (new CCodeIdentifier (param.name));
-						cappend_call.add_argument (new CCodeIdentifier (head.get_array_length_cname (param.name, 1)));
+						cappend_call.add_argument (new CCodeIdentifier (get_array_length_cname (param.name, 1)));
 						block.add_statement (new CCodeExpressionStatement (cappend_call));
 					}
 
@@ -857,12 +853,12 @@ public class Vala.DBusClientModule : DBusModule {
 	void generate_dbus_connect_wrapper (DynamicSignal sig, CCodeBlock block) {
 		var m = (Method) sig.handler.symbol_reference;
 
-		sig.accept (codegen);
+		sig.accept (this);
 
 		// FIXME should only be done once per marshaller
 		var register_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_object_register_marshaller"));
-		head.generate_marshaller (sig.get_parameters (), sig.return_type, true);
-		register_call.add_argument (new CCodeIdentifier (head.get_marshaller_function (sig.get_parameters (), sig.return_type, null, true)));
+		generate_marshaller (sig.get_parameters (), sig.return_type, true);
+		register_call.add_argument (new CCodeIdentifier (get_marshaller_function (sig.get_parameters (), sig.return_type, null, true)));
 		register_call.add_argument (new CCodeIdentifier ("G_TYPE_NONE"));
 
 		var add_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_proxy_add_signal"));
@@ -927,11 +923,11 @@ public class Vala.DBusClientModule : DBusModule {
 		Expression object_path = args.get (1);
 
 		var ccall = new CCodeFunctionCall (new CCodeIdentifier (type.type_symbol.get_lower_case_cprefix () + "dbus_proxy_new"));
-		connection.emit (codegen);
+		connection.emit (this);
 		ccall.add_argument ((CCodeExpression) connection.ccodenode);
-		bus_name.emit (codegen);
+		bus_name.emit (this);
 		ccall.add_argument ((CCodeExpression) bus_name.ccodenode);
-		object_path.emit (codegen);
+		object_path.emit (this);
 		ccall.add_argument ((CCodeExpression) object_path.ccodenode);
 		expr.ccodenode = ccall;
 	}
@@ -1413,11 +1409,11 @@ public class Vala.DBusClientModule : DBusModule {
 		if (proxy_get_all) {
 			var ma = expr.call as MemberAccess;
 			var instance = ma.inner;
-			instance.emit (codegen);
+			instance.emit (this);
 
 			var args = expr.get_argument_list ();
 			Expression interface_name = args.get (0);
-			interface_name.emit (codegen);
+			interface_name.emit (this);
 
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_get_all_function (mtype.method_symbol)));
 			ccall.add_argument ((CCodeExpression) instance.ccodenode);
@@ -1441,7 +1437,7 @@ public class Vala.DBusClientModule : DBusModule {
 		quark_call.add_argument (new CCodeConstant ("\"ValaDBusInterfaceProxyType\""));
 
 		var qdata_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_get_qdata"));
-		type.emit (codegen);
+		type.emit (this);
 		qdata_call.add_argument ((CCodeExpression) type.ccodenode);
 		qdata_call.add_argument (quark_call);
 
@@ -1450,16 +1446,16 @@ public class Vala.DBusClientModule : DBusModule {
 		var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_object_new"));
 		ccall.add_argument (get_type_call);
 		ccall.add_argument (new CCodeConstant ("\"connection\""));
-		connection.emit (codegen);
+		connection.emit (this);
 		ccall.add_argument ((CCodeExpression) connection.ccodenode);
 		ccall.add_argument (new CCodeConstant ("\"name\""));
-		bus_name.emit (codegen);
+		bus_name.emit (this);
 		ccall.add_argument ((CCodeExpression) bus_name.ccodenode);
 		ccall.add_argument (new CCodeConstant ("\"path\""));
-		object_path.emit (codegen);
+		object_path.emit (this);
 		ccall.add_argument ((CCodeExpression) object_path.ccodenode);
 		ccall.add_argument (new CCodeConstant ("\"interface\""));
-		interface_name.emit (codegen);
+		interface_name.emit (this);
 		ccall.add_argument ((CCodeExpression) interface_name.ccodenode);
 		ccall.add_argument (new CCodeConstant ("NULL"));
 		expr.ccodenode = ccall;
diff --git a/codegen/valadbusmodule.vala b/codegen/valadbusmodule.vala
index 65ce9b0..e1a1072 100644
--- a/codegen/valadbusmodule.vala
+++ b/codegen/valadbusmodule.vala
@@ -45,10 +45,6 @@ public class Vala.DBusModule : GAsyncModule {
 		{ "g", "SIGNATURE", "const char*", "G_TYPE_STRING", null, "g_value_take_string" }
 	};
 
-	public DBusModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	static bool is_string_marshalled_enum (TypeSymbol? symbol) {
 		if (symbol != null && symbol is Enum) {
 			var dbus = symbol.get_attribute ("DBus");
diff --git a/codegen/valadbusservermodule.vala b/codegen/valadbusservermodule.vala
index a872303..5a2ea3e 100644
--- a/codegen/valadbusservermodule.vala
+++ b/codegen/valadbusservermodule.vala
@@ -28,10 +28,6 @@ using GLib;
  * The link between a dynamic method and generated code.
  */
 public class Vala.DBusServerModule : DBusClientModule {
-	public DBusServerModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public static bool is_dbus_visible (CodeNode node) {
 		var dbus_attribute = node.get_attribute ("DBus");
 		if (dbus_attribute != null
@@ -499,7 +495,7 @@ public class Vala.DBusServerModule : DBusClientModule {
 			if (param.variable_type is ArrayType) {
 				var array_type = (ArrayType) param.variable_type;
 				for (int dim = 1; dim <= array_type.rank; dim++) {
-					function.add_parameter (new CCodeFormalParameter (head.get_array_length_cname (param.name, dim), "int"));
+					function.add_parameter (new CCodeFormalParameter (get_array_length_cname (param.name, dim), "int"));
 				}
 			}
 		}
@@ -1206,10 +1202,10 @@ public class Vala.DBusServerModule : DBusClientModule {
 				if (array_type != null) {
 					for (int dim = 1; dim <= array_type.rank; dim++) {
 						cdecl = new CCodeDeclaration ("int");
-						cdecl.add_declarator (new CCodeVariableDeclarator (head.get_array_length_cname ("value", dim)));
+						cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname ("value", dim)));
 						prefragment.append (cdecl);
 
-						ccall.add_argument (new CCodeIdentifier (head.get_array_length_cname ("value", dim)));
+						ccall.add_argument (new CCodeIdentifier (get_array_length_cname ("value", dim)));
 					}
 				}
 			}
diff --git a/codegen/valadovaarraymodule.vala b/codegen/valadovaarraymodule.vala
index 5d92720..5e3478f 100644
--- a/codegen/valadovaarraymodule.vala
+++ b/codegen/valadovaarraymodule.vala
@@ -20,11 +20,7 @@
  * 	Jürg Billeter <j bitron ch>
  */
 
-internal class Vala.DovaArrayModule : DovaMethodCallModule {
-	public DovaArrayModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+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));
diff --git a/codegen/valadovaassignmentmodule.vala b/codegen/valadovaassignmentmodule.vala
index 85171bc..dd49e86 100644
--- a/codegen/valadovaassignmentmodule.vala
+++ b/codegen/valadovaassignmentmodule.vala
@@ -23,11 +23,7 @@
 /**
  * The link between an assignment and generated code.
  */
-internal class Vala.DovaAssignmentModule : DovaMemberAccessModule {
-	public DovaAssignmentModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+public class Vala.DovaAssignmentModule : DovaMemberAccessModule {
 	CCodeExpression emit_property_assignment (Assignment assignment) {
 		var ma = assignment.left as MemberAccess;
 
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 248c51e..31499b5 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -25,7 +25,7 @@
 /**
  * Code visitor generating C Code.
  */
-internal class Vala.DovaBaseModule : CCodeModule {
+public class Vala.DovaBaseModule : CodeGenerator {
 	public CodeContext context { get; set; }
 
 	public Symbol root_symbol;
@@ -163,9 +163,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
 	public Map<string,string> variable_name_map = new HashMap<string,string> (str_hash, str_equal);
 
-	public DovaBaseModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-
+	public DovaBaseModule () {
 		reserved_identifiers = new HashSet<string> (str_hash, str_equal);
 
 		// C99 keywords
@@ -262,7 +260,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 		var source_files = context.get_source_files ();
 		foreach (SourceFile file in source_files) {
 			if (!file.external_package) {
-				file.accept (codegen);
+				file.accept (this);
 			}
 		}
 
@@ -338,7 +336,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 			writer.close ();
 		}
 
-		source_file.accept_children (codegen);
+		source_file.accept_children (this);
 
 		if (context.report.get_errors () > 0) {
 			return;
@@ -376,7 +374,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 			if (ev.value == null) {
 				cenum.add_value (new CCodeEnumValue (ev.get_cname ()));
 			} else {
-				ev.value.emit (codegen);
+				ev.value.emit (this);
 				cenum.add_value (new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode));
 			}
 		}
@@ -386,7 +384,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 	}
 
 	public override void visit_enum (Enum en) {
-		en.accept_children (codegen);
+		en.accept_children (this);
 
 		generate_enum_declaration (en, source_declarations);
 
@@ -401,7 +399,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 		}
 
 		if (!c.external) {
-			c.value.emit (codegen);
+			c.value.emit (this);
 
 			if (c.value is InitializerList) {
 				var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
@@ -457,7 +455,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
 	public override void visit_field (Field f) {
 		if (f.initializer != null) {
-			f.initializer.emit (codegen);
+			f.initializer.emit (this);
 		}
 
 		var cl = f.parent_symbol as Class;
@@ -605,7 +603,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 		temp_ref_vars = new ArrayList<LocalVariable> ();
 		variable_name_map = new HashMap<string,string> (str_hash, str_equal);
 
-		prop.accept_children (codegen);
+		prop.accept_children (this);
 
 		next_temp_var_id = old_next_temp_var_id;
 		temp_vars = old_temp_vars;
@@ -657,7 +655,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 	}
 
 	public override void visit_destructor (Destructor d) {
-		d.body.emit (codegen);
+		d.body.emit (this);
 
 		CCodeFragment cfrag = new CCodeFragment ();
 
@@ -705,11 +703,10 @@ internal class Vala.DovaBaseModule : CCodeModule {
 	}
 
 	public override void visit_block (Block b) {
-		var old_symbol = current_symbol;
-		current_symbol = b;
+		emit_context.push_symbol (b);
 
 		foreach (Statement stmt in b.get_statements ()) {
-			stmt.emit (codegen);
+			stmt.emit (this);
 		}
 
 		var local_vars = b.get_local_variables ();
@@ -916,7 +913,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
 		b.ccodenode = cblock;
 
-		current_symbol = old_symbol;
+		emit_context.pop_symbol ();
 	}
 
 	public override void visit_empty_statement (EmptyStatement stmt) {
@@ -924,7 +921,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 	}
 
 	public override void visit_declaration_statement (DeclarationStatement stmt) {
-		stmt.declaration.accept (codegen);
+		stmt.declaration.accept (this);
 
 		stmt.ccodenode = stmt.declaration.ccodenode;
 
@@ -958,7 +955,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
 	public override void visit_local_variable (LocalVariable local) {
 		if (local.initializer != null) {
-			local.initializer.emit (codegen);
+			local.initializer.emit (this);
 
 			visit_end_full_expression (local.initializer);
 		}
@@ -997,7 +994,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 		}
 
 		if (local.initializer != null && local.initializer.tree_can_fail) {
-			head.add_simple_check (local.initializer, cfrag);
+			add_simple_check (local.initializer, cfrag);
 		}
 
 		local.ccodenode = cfrag;
@@ -1338,7 +1335,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
 			cfrag.append (stmt.ccodenode);
 
-			head.add_simple_check (stmt.expression, cfrag);
+			add_simple_check (stmt.expression, cfrag);
 
 			stmt.ccodenode = cfrag;
 		}
@@ -1843,7 +1840,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 				/* evaluate default expression here as the code
 				 * generator might not have visited the formal
 				 * parameter yet */
-				param.initializer.emit (codegen);
+				param.initializer.emit (this);
 
 				creation_call.add_argument ((CCodeExpression) param.initializer.ccodenode);
 				i++;
@@ -1866,7 +1863,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
 			// cast the return value of the creation method back to the intended type if
 			// it requested a special C return type
-			if (head.get_custom_creturn_type (m) != null) {
+			if (get_custom_creturn_type (m) != null) {
 				creation_expr = new CCodeCastExpression (creation_expr, expr.type_reference.get_cname ());
 			}
 		} else {
@@ -2174,7 +2171,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 		temp_vars = new ArrayList<LocalVariable> ();
 		temp_ref_vars = new ArrayList<LocalVariable> ();
 
-		l.accept_children (codegen);
+		l.accept_children (this);
 
 		temp_vars = old_temp_vars;
 		temp_ref_vars = old_temp_ref_vars;
@@ -2353,12 +2350,8 @@ internal class Vala.DovaBaseModule : CCodeModule {
 			base_property = prop.base_interface_property;
 		}
 
-		if (prop is DynamicProperty) {
-			set_func = head.get_dynamic_property_setter_cname ((DynamicProperty) prop);
-		} else {
-			generate_property_accessor_declaration (base_property.set_accessor, source_declarations);
-			set_func = base_property.set_accessor.get_cname ();
-		}
+		generate_property_accessor_declaration (base_property.set_accessor, source_declarations);
+		set_func = base_property.set_accessor.get_cname ();
 
 		var ccall = new CCodeFunctionCall (new CCodeIdentifier (set_func));
 
@@ -2441,14 +2434,11 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
 	public CCodeNode? get_ccodenode (CodeNode node) {
 		if (node.ccodenode == null) {
-			node.emit (codegen);
+			node.emit (this);
 		}
 		return node.ccodenode;
 	}
 
-	public override void visit_class (Class cl) {
-	}
-
 	public DataType? get_this_type () {
 		if (current_method != null && current_method.binding == MemberBinding.INSTANCE) {
 			return current_method.this_parameter.variable_type;
@@ -2461,4 +2451,15 @@ internal class Vala.DovaBaseModule : CCodeModule {
 	public CCodeExpression generate_instance_cast (CCodeExpression expr, TypeSymbol type) {
 		return new CCodeCastExpression (expr, type.get_cname () + "*");
 	}
+
+	public virtual string? get_custom_creturn_type (Method m) {
+		return null;
+	}
+
+	public virtual bool method_has_wrapper (Method method) {
+		return false;
+	}
+
+	public virtual void add_simple_check (CodeNode node, CCodeFragment cfrag, bool always_fails = false) {
+	}
 }
diff --git a/codegen/valadovacontrolflowmodule.vala b/codegen/valadovacontrolflowmodule.vala
index f75368c..0fddf3f 100644
--- a/codegen/valadovacontrolflowmodule.vala
+++ b/codegen/valadovacontrolflowmodule.vala
@@ -20,15 +20,11 @@
  * 	Jürg Billeter <j bitron ch>
  */
 
-internal class Vala.DovaControlFlowModule : DovaMethodModule {
-	public DovaControlFlowModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+public class Vala.DovaControlFlowModule : DovaMethodModule {
 	public override void visit_if_statement (IfStatement stmt) {
-		stmt.true_statement.emit (codegen);
+		stmt.true_statement.emit (this);
 		if (stmt.false_statement != null) {
-			stmt.false_statement.emit (codegen);
+			stmt.false_statement.emit (this);
 		}
 
 		if (stmt.false_statement != null) {
@@ -42,7 +38,7 @@ internal class Vala.DovaControlFlowModule : DovaMethodModule {
 
 	public override void visit_switch_statement (SwitchStatement stmt) {
 		foreach (SwitchSection section in stmt.get_sections ()) {
-			section.emit (codegen);
+			section.emit (this);
 		}
 
 		var cswitch = new CCodeSwitchStatement ((CCodeExpression) stmt.expression.ccodenode);
@@ -75,14 +71,14 @@ internal class Vala.DovaControlFlowModule : DovaMethodModule {
 
 	public override void visit_switch_label (SwitchLabel label) {
 		if (label.expression != null) {
-			label.expression.emit (codegen);
+			label.expression.emit (this);
 
-			codegen.visit_end_full_expression (label.expression);
+			visit_end_full_expression (label.expression);
 		}
 	}
 
 	public override void visit_loop (Loop stmt) {
-		stmt.body.emit (codegen);
+		stmt.body.emit (this);
 
 		stmt.ccodenode = new CCodeWhileStatement (new CCodeConstant ("true"), (CCodeStatement) stmt.body.ccodenode);
 	}
diff --git a/codegen/valadovadelegatemodule.vala b/codegen/valadovadelegatemodule.vala
index b0d4ed0..3d4672f 100644
--- a/codegen/valadovadelegatemodule.vala
+++ b/codegen/valadovadelegatemodule.vala
@@ -24,11 +24,7 @@
 /**
  * The link between a delegate and generated code.
  */
-internal class Vala.DovaDelegateModule : DovaValueModule {
-	public DovaDelegateModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+public class Vala.DovaDelegateModule : DovaValueModule {
 	public override void generate_delegate_declaration (Delegate d, CCodeDeclarationSpace decl_space) {
 		if (decl_space.add_symbol_declaration (d, d.get_cname ())) {
 			return;
@@ -189,7 +185,7 @@ internal class Vala.DovaDelegateModule : DovaValueModule {
 	}
 
 	public override void visit_delegate (Delegate d) {
-		d.accept_children (codegen);
+		d.accept_children (this);
 
 		generate_delegate_declaration (d, source_declarations);
 
diff --git a/codegen/valadovaerrormodule.vala b/codegen/valadovaerrormodule.vala
index ecee398..8813760 100644
--- a/codegen/valadovaerrormodule.vala
+++ b/codegen/valadovaerrormodule.vala
@@ -21,17 +21,11 @@
  *	Thijs Vermeir <thijsvermeir gmail com>
  */
 
-using GLib;
-
-internal class Vala.DovaErrorModule : DovaDelegateModule {
+public class Vala.DovaErrorModule : DovaDelegateModule {
 	private int current_try_id = 0;
 	private int next_try_id = 0;
 	private bool is_in_catch = false;
 
-	public DovaErrorModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void visit_throw_statement (ThrowStatement stmt) {
 		var cfrag = new CCodeFragment ();
 
@@ -39,7 +33,7 @@ internal class Vala.DovaErrorModule : DovaDelegateModule {
 		var cassign = new CCodeAssignment (new CCodeIdentifier ("dova_error"), (CCodeExpression) stmt.error_expression.ccodenode);
 		cfrag.append (new CCodeExpressionStatement (cassign));
 
-		head.add_simple_check (stmt, cfrag, true);
+		add_simple_check (stmt, cfrag, true);
 
 		stmt.ccodenode = cfrag;
 
@@ -240,15 +234,15 @@ internal class Vala.DovaErrorModule : DovaDelegateModule {
 		}
 
 		if (stmt.finally_body != null) {
-			stmt.finally_body.emit (codegen);
+			stmt.finally_body.emit (this);
 		}
 
 		is_in_catch = false;
-		stmt.body.emit (codegen);
+		stmt.body.emit (this);
 		is_in_catch = true;
 
 		foreach (CatchClause clause in stmt.get_catch_clauses ()) {
-			clause.emit (codegen);
+			clause.emit (this);
 		}
 
 		current_try = old_try;
@@ -278,7 +272,7 @@ internal class Vala.DovaErrorModule : DovaDelegateModule {
 	public override void visit_catch_clause (CatchClause clause) {
 		generate_type_declaration (clause.error_type, source_declarations);
 
-		clause.body.emit (codegen);
+		clause.body.emit (this);
 
 		var cfrag = new CCodeFragment ();
 		cfrag.append (new CCodeLabel (clause.clabel_name));
diff --git a/codegen/valadovamemberaccessmodule.vala b/codegen/valadovamemberaccessmodule.vala
index 3e61873..2b8c621 100644
--- a/codegen/valadovamemberaccessmodule.vala
+++ b/codegen/valadovamemberaccessmodule.vala
@@ -22,11 +22,7 @@
 
 using GLib;
 
-internal class Vala.DovaMemberAccessModule : DovaControlFlowModule {
-	public DovaMemberAccessModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+public class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 	public override void visit_member_access (MemberAccess expr) {
 		CCodeExpression pub_inst = null;
 		DataType base_type = null;
@@ -69,7 +65,7 @@ internal class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 			}
 
 			if (m.base_method != null) {
-				if (!head.method_has_wrapper (m.base_method)) {
+				if (!method_has_wrapper (m.base_method)) {
 					var inst = pub_inst;
 					if (expr.inner != null && !expr.inner.is_pure ()) {
 						// instance expression has side-effects
@@ -183,12 +179,7 @@ internal class Vala.DovaMemberAccessModule : DovaControlFlowModule {
 			} else if (prop.base_interface_property != null) {
 				base_property = prop.base_interface_property;
 			}
-			string getter_cname;
-			if (prop is DynamicProperty) {
-				getter_cname = head.get_dynamic_property_getter_cname ((DynamicProperty) prop);
-			} else {
-				getter_cname = base_property.get_accessor.get_cname ();
-			}
+			string getter_cname = base_property.get_accessor.get_cname ();
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier (getter_cname));
 
 			if (prop.binding == MemberBinding.INSTANCE) {
diff --git a/codegen/valadovamethodcallmodule.vala b/codegen/valadovamethodcallmodule.vala
index 14ada21..40f56b4 100644
--- a/codegen/valadovamethodcallmodule.vala
+++ b/codegen/valadovamethodcallmodule.vala
@@ -20,11 +20,7 @@
  * 	Jürg Billeter <j bitron ch>
  */
 
-internal class Vala.DovaMethodCallModule : DovaAssignmentModule {
-	public DovaMethodCallModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+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);
diff --git a/codegen/valadovamethodmodule.vala b/codegen/valadovamethodmodule.vala
index 4be1b8d..3450941 100644
--- a/codegen/valadovamethodmodule.vala
+++ b/codegen/valadovamethodmodule.vala
@@ -23,11 +23,7 @@
 /**
  * The link between a method and generated code.
  */
-internal class Vala.DovaMethodModule : DovaStructModule {
-	public DovaMethodModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+public class Vala.DovaMethodModule : DovaStructModule {
 	public override bool method_has_wrapper (Method method) {
 		return (method.get_attribute ("NoWrapper") == null);
 	}
diff --git a/codegen/valadovaobjectmodule.vala b/codegen/valadovaobjectmodule.vala
index ed1f933..e944a0c 100644
--- a/codegen/valadovaobjectmodule.vala
+++ b/codegen/valadovaobjectmodule.vala
@@ -20,11 +20,7 @@
  * 	Jürg Billeter <j bitron ch>
  */
 
-internal class Vala.DovaObjectModule : DovaArrayModule {
-	public DovaObjectModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+public class Vala.DovaObjectModule : DovaArrayModule {
 	public override void generate_class_declaration (Class cl, CCodeDeclarationSpace decl_space) {
 		if (decl_space.add_symbol_declaration (cl, cl.get_cname ())) {
 			return;
@@ -807,7 +803,7 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
 			generate_class_declaration (cl, header_declarations);
 		}
 
-		cl.accept_children (codegen);
+		cl.accept_children (this);
 
 		var type_init_block = generate_type_get_function (cl, cl.base_class);
 
@@ -1074,7 +1070,7 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
 
 		source_type_member_definition.append (type_init_fun);
 
-		iface.accept_children (codegen);
+		iface.accept_children (this);
 
 		current_symbol = old_symbol;
 	}
@@ -1145,11 +1141,11 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
 		var prop = (Property) acc.prop;
 
 		if (acc.result_var != null) {
-			acc.result_var.accept (codegen);
+			acc.result_var.accept (this);
 		}
 
 		if (acc.body != null) {
-			acc.body.emit (codegen);
+			acc.body.emit (this);
 		}
 
 		// do not declare overriding properties and interface implementations
@@ -1391,23 +1387,23 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
 
 
 		foreach (FormalParameter param in m.get_parameters ()) {
-			param.accept (codegen);
+			param.accept (this);
 		}
 
 		if (m.result_var != null) {
-			m.result_var.accept (codegen);
+			m.result_var.accept (this);
 		}
 
 		foreach (Expression precondition in m.get_preconditions ()) {
-			precondition.emit (codegen);
+			precondition.emit (this);
 		}
 
 		foreach (Expression postcondition in m.get_postconditions ()) {
-			postcondition.emit (codegen);
+			postcondition.emit (this);
 		}
 
 		if (m.body != null) {
-			m.body.emit (codegen);
+			m.body.emit (this);
 		}
 
 
@@ -1741,7 +1737,7 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
 	public override void visit_creation_method (CreationMethod m) {
 		bool visible = !m.is_internal_symbol ();
 
-		head.visit_method (m);
+		visit_method (m);
 
 		DataType creturn_type;
 		if (current_type_symbol is Class) {
@@ -1940,7 +1936,7 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
 		if (array_type != null) {
 			// access to element in an array
 
-			expr.accept_children (codegen);
+			expr.accept_children (this);
 
 			List<Expression> indices = expr.get_indices ();
 			var cindex = (CCodeExpression) indices[0].ccodenode;
diff --git a/codegen/valadovastructmodule.vala b/codegen/valadovastructmodule.vala
index fa01e50..ddab46a 100644
--- a/codegen/valadovastructmodule.vala
+++ b/codegen/valadovastructmodule.vala
@@ -22,11 +22,7 @@
 
 using GLib;
 
-internal class Vala.DovaStructModule : DovaBaseModule {
-	public DovaStructModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+public class Vala.DovaStructModule : DovaBaseModule {
 	public override void generate_struct_declaration (Struct st, CCodeDeclarationSpace decl_space) {
 		if (decl_space.add_symbol_declaration (st, st.get_cname ())) {
 			return;
@@ -85,7 +81,7 @@ internal class Vala.DovaStructModule : DovaBaseModule {
 			generate_struct_declaration (st, header_declarations);
 		}
 
-		st.accept_children (codegen);
+		st.accept_children (this);
 
 		current_symbol = old_symbol;
 		instance_finalize_fragment = old_instance_finalize_fragment;
diff --git a/codegen/valadovavaluemodule.vala b/codegen/valadovavaluemodule.vala
index fece4fc..08e2ec7 100644
--- a/codegen/valadovavaluemodule.vala
+++ b/codegen/valadovavaluemodule.vala
@@ -20,11 +20,7 @@
  * 	Jürg Billeter <j bitron ch>
  */
 
-internal class Vala.DovaValueModule : DovaObjectModule {
-	public DovaValueModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
+public class Vala.DovaValueModule : DovaObjectModule {
 	public override void visit_creation_method (CreationMethod m) {
 		if (current_type_symbol is Class &&
 		    (current_class.base_class == null ||
@@ -508,7 +504,7 @@ internal class Vala.DovaValueModule : DovaObjectModule {
 
 		// handle method calls on generic types
 
-		expr.accept_children (codegen);
+		expr.accept_children (this);
 
 		if (ma.member_name == "hash") {
 			var val = ma.inner;
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index c2c1fd9..c554612 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -23,10 +23,6 @@
 using GLib;
 
 public class Vala.GAsyncModule : GSignalModule {
-	public GAsyncModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	CCodeStruct generate_data_struct (Method m) {
 		string dataname = Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data";
 		var data = new CCodeStruct ("_" + dataname);
@@ -590,7 +586,7 @@ public class Vala.GAsyncModule : GSignalModule {
 
 			cfrag.append (stmt.ccodenode);
 
-			head.add_simple_check (stmt.yield_expression, cfrag);
+			add_simple_check (stmt.yield_expression, cfrag);
 
 			stmt.ccodenode = cfrag;
 		}
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 6e19674..d11d9b5 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -22,10 +22,6 @@
  */
 
 public class Vala.GDBusClientModule : GDBusModule {
-	public GDBusClientModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public CCodeConstant get_dbus_timeout (Symbol symbol) {
 		int timeout = -1;
 
@@ -263,19 +259,19 @@ 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 (codegen);
+		cancellable.emit (this);
 		ccall.add_argument ((CCodeExpression) cancellable.ccodenode);
 		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 (codegen);
+		name.emit (this);
 		ccall.add_argument ((CCodeExpression) name.ccodenode);
 		ccall.add_argument (new CCodeConstant ("\"g-bus-type\""));
-		bus_type.emit (codegen);
+		bus_type.emit (this);
 		ccall.add_argument ((CCodeExpression) bus_type.ccodenode);
 		ccall.add_argument (new CCodeConstant ("\"g-object-path\""));
-		object_path.emit (codegen);
+		object_path.emit (this);
 		ccall.add_argument ((CCodeExpression) object_path.ccodenode);
 		ccall.add_argument (new CCodeConstant ("\"g-interface-name\""));
 		ccall.add_argument (new CCodeConstant ("\"%s\"".printf (get_dbus_name (iface))));
diff --git a/codegen/valagdbusmodule.vala b/codegen/valagdbusmodule.vala
index 82fc076..b5014e4 100644
--- a/codegen/valagdbusmodule.vala
+++ b/codegen/valagdbusmodule.vala
@@ -21,10 +21,6 @@
  */
 
 public class Vala.GDBusModule : GVariantModule {
-	public GDBusModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public static string? get_dbus_name (TypeSymbol symbol) {
 		var dbus = symbol.get_attribute ("DBus");
 		if (dbus == null) {
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index a5760e7..c924d93 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -21,10 +21,6 @@
  */
 
 public class Vala.GDBusServerModule : GDBusClientModule {
-	public GDBusServerModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public static bool is_dbus_visible (CodeNode node) {
 		var dbus_attribute = node.get_attribute ("DBus");
 		if (dbus_attribute != null
@@ -373,7 +369,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 			if (param.variable_type is ArrayType) {
 				var array_type = (ArrayType) param.variable_type;
 				for (int dim = 1; dim <= array_type.rank; dim++) {
-					function.add_parameter (new CCodeFormalParameter (head.get_array_length_cname (param.name, dim), "int"));
+					function.add_parameter (new CCodeFormalParameter (get_array_length_cname (param.name, dim), "int"));
 				}
 			}
 		}
@@ -552,10 +548,10 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 			if (array_type != null) {
 				for (int dim = 1; dim <= array_type.rank; dim++) {
 					cdecl = new CCodeDeclaration ("int");
-					cdecl.add_declarator (new CCodeVariableDeclarator (head.get_array_length_cname ("value", dim)));
+					cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname ("value", dim)));
 					prefragment.append (cdecl);
 
-					ccall.add_argument (new CCodeIdentifier (head.get_array_length_cname ("value", dim)));
+					ccall.add_argument (new CCodeIdentifier (get_array_length_cname ("value", dim)));
 				}
 			}
 		}
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index deca24b..dccb21b 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -28,10 +28,6 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 	private int next_try_id = 0;
 	private bool is_in_catch = false;
 
-	public GErrorModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void generate_error_domain_declaration (ErrorDomain edomain, CCodeDeclarationSpace decl_space) {
 		if (decl_space.add_symbol_declaration (edomain, edomain.get_cname ())) {
 			return;
@@ -43,7 +39,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 			if (ecode.value == null) {
 				cenum.add_value (new CCodeEnumValue (ecode.get_cname ()));
 			} else {
-				ecode.value.emit (codegen);
+				ecode.value.emit (this);
 				cenum.add_value (new CCodeEnumValue (ecode.get_cname (), (CCodeExpression) ecode.value.ccodenode));
 			}
 		}
@@ -92,7 +88,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 		var cassign = new CCodeAssignment (get_variable_cexpression ("_inner_error_"), (CCodeExpression) stmt.error_expression.ccodenode);
 		cfrag.append (new CCodeExpressionStatement (cassign));
 
-		head.add_simple_check (stmt, cfrag, true);
+		add_simple_check (stmt, cfrag, true);
 
 		stmt.ccodenode = cfrag;
 
@@ -331,15 +327,15 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 		}
 
 		if (stmt.finally_body != null) {
-			stmt.finally_body.emit (codegen);
+			stmt.finally_body.emit (this);
 		}
 
 		is_in_catch = false;
-		stmt.body.emit (codegen);
+		stmt.body.emit (this);
 		is_in_catch = true;
 
 		foreach (CatchClause clause in stmt.get_catch_clauses ()) {
-			clause.emit (codegen);
+			clause.emit (this);
 		}
 
 		current_try = old_try;
@@ -374,7 +370,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 			generate_error_domain_declaration (error_type.error_domain, source_declarations);
 		}
 
-		clause.body.emit (codegen);
+		clause.body.emit (this);
 
 		var cfrag = new CCodeFragment ();
 		cfrag.append (new CCodeLabel (clause.clabel_name));
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 33a828a..59ef5ee 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -27,10 +27,6 @@ public class Vala.GObjectModule : GTypeModule {
 	int dynamic_property_id;
 	int signal_wrapper_id;
 
-	public GObjectModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void visit_class (Class cl) {
 		base.visit_class (cl);
 
@@ -152,7 +148,7 @@ public class Vala.GObjectModule : GTypeModule {
 				var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_install_property"));
 				cinst.add_argument (ccall);
 				cinst.add_argument (new CCodeConstant (prop.get_upper_case_cname ()));
-				cinst.add_argument (head.get_param_spec (prop));
+				cinst.add_argument (get_param_spec (prop));
 			
 				init_block.add_statement (new CCodeExpressionStatement (cinst));
 			}
@@ -238,7 +234,7 @@ public class Vala.GObjectModule : GTypeModule {
 				cswitch.add_statement (new CCodeExpressionStatement (ccall));
 
 				var csetcall = new CCodeFunctionCall ();
-				csetcall.call = head.get_value_setter_function (prop.property_type);
+				csetcall.call = get_value_setter_function (prop.property_type);
 				csetcall.add_argument (new CCodeIdentifier ("value"));
 				csetcall.add_argument (boxed_addr);
 				cswitch.add_statement (new CCodeExpressionStatement (csetcall));
@@ -262,9 +258,9 @@ public class Vala.GObjectModule : GTypeModule {
 				}
 				var csetcall = new CCodeFunctionCall ();
 				if (prop.get_accessor.value_type.value_owned) {
-					csetcall.call = head.get_value_taker_function (prop.property_type);
+					csetcall.call = get_value_taker_function (prop.property_type);
 				} else {
-					csetcall.call = head.get_value_setter_function (prop.property_type);
+					csetcall.call = get_value_setter_function (prop.property_type);
 				}
 				csetcall.add_argument (new CCodeIdentifier ("value"));
 				csetcall.add_argument (ccall);
@@ -458,7 +454,7 @@ public class Vala.GObjectModule : GTypeModule {
 		} else {
 			in_constructor = true;
 		}
-		c.body.emit (codegen);
+		c.body.emit (this);
 		in_static_or_class_context = false;
 
 		in_constructor = false;
@@ -705,7 +701,7 @@ public class Vala.GObjectModule : GTypeModule {
 	void generate_gobject_connect_wrapper (DynamicSignal sig, CCodeBlock block, bool after) {
 		var m = (Method) sig.handler.symbol_reference;
 
-		sig.accept (codegen);
+		sig.accept (this);
 
 		string connect_func = "g_signal_connect_object";
 		if (m.binding != MemberBinding.INSTANCE) {
diff --git a/codegen/valagsignalmodule.vala b/codegen/valagsignalmodule.vala
index 7765c7b..e36f5f2 100644
--- a/codegen/valagsignalmodule.vala
+++ b/codegen/valagsignalmodule.vala
@@ -24,10 +24,6 @@
 
 
 public class Vala.GSignalModule : GObjectModule {
-	public GSignalModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	private string get_marshaller_type_name (DataType t, bool dbus = false) {
 		if (t is PointerType || t.type_parameter != null) {
 			return ("POINTER");
@@ -172,7 +168,7 @@ public class Vala.GSignalModule : GObjectModule {
 			}
 		}
 
-		sig.accept_children (codegen);
+		sig.accept_children (this);
 
 		// declare parameter type
 		foreach (FormalParameter p in sig.get_parameters ()) {
@@ -404,7 +400,7 @@ public class Vala.GSignalModule : GObjectModule {
 		csignew.add_argument (new CCodeConstant ("NULL"));
 		csignew.add_argument (new CCodeConstant ("NULL"));
 
-		string marshaller = head.get_marshaller_function (sig.get_parameters (), sig.return_type);
+		string marshaller = get_marshaller_function (sig.get_parameters (), sig.return_type);
 
 		var marshal_arg = new CCodeIdentifier (marshaller);
 		csignew.add_argument (marshal_arg);
@@ -581,9 +577,9 @@ public class Vala.GSignalModule : GObjectModule {
 			// connect
 			if (sig is DynamicSignal) {
 				if (!after)
-					connect_func = head.get_dynamic_signal_connect_wrapper_name ((DynamicSignal) sig);
+					connect_func = get_dynamic_signal_connect_wrapper_name ((DynamicSignal) sig);
 				else
-					connect_func = head.get_dynamic_signal_connect_after_wrapper_name ((DynamicSignal) sig);
+					connect_func = get_dynamic_signal_connect_after_wrapper_name ((DynamicSignal) sig);
 			} else {
 				if (m.closure) {
 					connect_func = "g_signal_connect_data";
@@ -597,7 +593,7 @@ public class Vala.GSignalModule : GObjectModule {
 		} else {
 			// disconnect
 			if (sig is DynamicSignal) {
-				connect_func = head.get_dynamic_signal_disconnect_wrapper_name ((DynamicSignal) sig);
+				connect_func = get_dynamic_signal_disconnect_wrapper_name ((DynamicSignal) sig);
 			} else {
 				connect_func = "g_signal_handlers_disconnect_matched";
 			}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index ca61a3a..2480f0b 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -24,10 +24,6 @@
 
 
 public class Vala.GTypeModule : GErrorModule {
-	public GTypeModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	public override void generate_parameter (FormalParameter param, CCodeDeclarationSpace decl_space, Map<int,CCodeFormalParameter> cparam_map, Map<int,CCodeExpression>? carg_map) {
 		if (!(param.variable_type is ObjectType)) {
 			base.generate_parameter (param, decl_space, cparam_map, carg_map);
@@ -268,7 +264,7 @@ public class Vala.GTypeModule : GErrorModule {
 				var array_type = prop.property_type as ArrayType;
 				if (array_type != null) {
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						vdeclarator.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("result", dim), "int*"));
+						vdeclarator.add_parameter (new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*"));
 					}
 				}
 
@@ -291,7 +287,7 @@ public class Vala.GTypeModule : GErrorModule {
 				var array_type = prop.property_type as ArrayType;
 				if (array_type != null) {
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						vdeclarator.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("value", dim), "int"));
+						vdeclarator.add_parameter (new CCodeFormalParameter (get_array_length_cname ("value", dim), "int"));
 					}
 				}
 
@@ -320,11 +316,11 @@ public class Vala.GTypeModule : GErrorModule {
 							var len_type = int_type.copy ();
 
 							for (int dim = 1; dim <= array_type.rank; dim++) {
-								instance_struct.add_field (len_type.get_cname (), head.get_array_length_cname (f.name, dim));
+								instance_struct.add_field (len_type.get_cname (), get_array_length_cname (f.name, dim));
 							}
 
 							if (array_type.rank == 1 && f.is_internal_symbol ()) {
-								instance_struct.add_field (len_type.get_cname (), head.get_array_size_cname (f.name));
+								instance_struct.add_field (len_type.get_cname (), get_array_size_cname (f.name));
 							}
 						}
 					} else if (f.variable_type is DelegateType) {
@@ -421,11 +417,11 @@ public class Vala.GTypeModule : GErrorModule {
 
 						if (!array_type.fixed_length) {
 							for (int dim = 1; dim <= array_type.rank; dim++) {
-								instance_priv_struct.add_field (len_type.get_cname (), head.get_array_length_cname (f.name, dim));
+								instance_priv_struct.add_field (len_type.get_cname (), get_array_length_cname (f.name, dim));
 							}
 
 							if (array_type.rank == 1 && f.is_internal_symbol ()) {
-								instance_priv_struct.add_field (len_type.get_cname (), head.get_array_size_cname (f.name));
+								instance_priv_struct.add_field (len_type.get_cname (), get_array_size_cname (f.name));
 							}
 						}
 					} else if (f.variable_type is DelegateType) {
@@ -536,7 +532,7 @@ public class Vala.GTypeModule : GErrorModule {
 			generate_class_struct_declaration (cl, internal_header_declarations);
 		}
 
-		cl.accept_children (codegen);
+		cl.accept_children (this);
 
 		if (is_gtypeinstance) {
 			if (is_fundamental) {
@@ -1302,11 +1298,11 @@ public class Vala.GTypeModule : GErrorModule {
 				if (sig.comment != null) {
 					init_block.add_statement (new CCodeComment (sig.comment.content));
 				}
-				init_block.add_statement (new CCodeExpressionStatement (head.get_signal_creation (sig, cl)));
+				init_block.add_statement (new CCodeExpressionStatement (get_signal_creation (sig, cl)));
 			}
 		}
 
-		init_block.add_statement (head.register_dbus_info (cl));
+		init_block.add_statement (register_dbus_info (cl));
 		init_block.add_statement (class_init_fragment);
 
 		source_type_member_definition.append (class_init);
@@ -1878,7 +1874,7 @@ public class Vala.GTypeModule : GErrorModule {
 				var array_type = prop.property_type as ArrayType;
 				if (array_type != null) {
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						vdeclarator.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("result", dim), "int*"));
+						vdeclarator.add_parameter (new CCodeFormalParameter (get_array_length_cname ("result", dim), "int*"));
 					}
 				}
 
@@ -1900,7 +1896,7 @@ public class Vala.GTypeModule : GErrorModule {
 				var array_type = prop.property_type as ArrayType;
 				if (array_type != null) {
 					for (int dim = 1; dim <= array_type.rank; dim++) {
-						vdeclarator.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("value", dim), "int"));
+						vdeclarator.add_parameter (new CCodeFormalParameter (get_array_length_cname ("value", dim), "int"));
 					}
 				}
 
@@ -1935,7 +1931,7 @@ public class Vala.GTypeModule : GErrorModule {
 			generate_interface_declaration (iface, internal_header_declarations);
 		}
 
-		iface.accept_children (codegen);
+		iface.accept_children (this);
 
 		add_interface_base_init_function (iface);
 
@@ -1987,7 +1983,7 @@ public class Vala.GTypeModule : GErrorModule {
 
 					var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_interface_install_property"));
 					cinst.add_argument (new CCodeIdentifier ("iface"));
-					cinst.add_argument (head.get_param_spec (prop));
+					cinst.add_argument (get_param_spec (prop));
 
 					init_block.add_statement (new CCodeExpressionStatement (cinst));
 				}
@@ -1999,7 +1995,7 @@ public class Vala.GTypeModule : GErrorModule {
 			if (sig.comment != null) {
 				init_block.add_statement (new CCodeComment (sig.comment.content));
 			}
-			init_block.add_statement (new CCodeExpressionStatement (head.get_signal_creation (sig, iface)));
+			init_block.add_statement (new CCodeExpressionStatement (get_signal_creation (sig, iface)));
 		}
 
 		// connect default implementations
@@ -2011,7 +2007,7 @@ public class Vala.GTypeModule : GErrorModule {
 			}
 		}
 
-		init_block.add_statement (head.register_dbus_info (iface));
+		init_block.add_statement (register_dbus_info (iface));
 
 		source_type_member_definition.append (base_init);
 	}
diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala
index e44c495..f7ae8c1 100644
--- a/codegen/valagvariantmodule.vala
+++ b/codegen/valagvariantmodule.vala
@@ -42,10 +42,6 @@ public class Vala.GVariantModule : GAsyncModule {
 		{ "g", "signature", true }
 	};
 
-	public GVariantModule (CCodeGenerator codegen, CCodeModule? next) {
-		base (codegen, next);
-	}
-
 	static bool is_string_marshalled_enum (TypeSymbol? symbol) {
 		if (symbol != null && symbol is Enum) {
 			var dbus = symbol.get_attribute ("DBus");
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 674d5ce..5539965 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -313,7 +313,17 @@ class Vala.Compiler {
 			}
 		}
 
-		context.codegen = new CCodeGenerator ();
+		if (context.profile == Profile.GOBJECT) {
+			if (context.has_package ("dbus-glib-1")) {
+				context.codegen = new DBusServerModule ();
+			} else {
+				context.codegen = new GDBusServerModule ();
+			}
+		} else if (context.profile == Profile.DOVA) {
+			context.codegen = new DovaErrorModule ();
+		} else {
+			context.codegen = new CCodeDelegateModule ();
+		}
 
 		if (packages != null) {
 			foreach (string package in packages) {



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