vala r2439 - in trunk: . gobject



Author: ryanl
Date: Fri Feb 13 09:06:22 2009
New Revision: 2439
URL: http://svn.gnome.org/viewvc/vala?rev=2439&view=rev

Log:
2009-02-13  Ryan Lortie  <desrt desrt ca>

        * gobject/valamethodmodule.vala:

        Emit 'default:' label with g_assert_not_reached() for async state
        switch statement (to avoid GCC warning).  Don't emit virtual functions
        or vtable entries for synchronous functions when emitting async code.



Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodemethodmodule.vala

Modified: trunk/gobject/valaccodemethodmodule.vala
==============================================================================
--- trunk/gobject/valaccodemethodmodule.vala	(original)
+++ trunk/gobject/valaccodemethodmodule.vala	Fri Feb 13 09:06:22 2009
@@ -259,7 +259,7 @@
 		var cparam_map = new HashMap<int,CCodeFormalParameter> (direct_hash, direct_equal);
 
 		CCodeFunctionDeclarator vdeclarator = null;
-		if (m.is_abstract || m.is_virtual) {
+		if ((m.is_abstract || m.is_virtual) && !m.coroutine) {
 			var vdecl = new CCodeDeclaration (get_creturn_type (m, creturn_type.get_cname ()));
 			vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
 			vdecl.add_declarator (vdeclarator);
@@ -304,6 +304,10 @@
 
 					var cswitch = new CCodeSwitchStatement (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "state"));
 
+					// let gcc know that this can't happen
+					cswitch.add_statement (new CCodeLabel ("default"));
+					cswitch.add_statement (new CCodeExpressionStatement (new CCodeFunctionCall (new CCodeIdentifier ("g_assert_not_reached"))));
+
 					// initial coroutine state
 					cswitch.add_statement (new CCodeCaseStatement (new CCodeConstant ("0")));
 
@@ -319,7 +323,7 @@
 					source_type_member_definition.append (co_function);
 				}
 
-				if (m.parent_symbol is Class) {
+				if (m.parent_symbol is Class && !m.coroutine) {
 					var cl = (Class) m.parent_symbol;
 					if (m.overrides || (m.base_interface_method != null && !m.is_abstract && !m.is_virtual)) {
 						Method base_method;
@@ -530,7 +534,7 @@
 			}
 		}
 
-		if (m.is_abstract || m.is_virtual) {
+		if ((m.is_abstract || m.is_virtual) && !m.coroutine) {
 			cparam_map = new HashMap<int,CCodeFormalParameter> (direct_hash, direct_equal);
 			var carg_map = new HashMap<int,CCodeExpression> (direct_hash, direct_equal);
 



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