From: Jürg Billeter Date: Sun, 10 Oct 2010 20:30:26 +0000 (+0200) Subject: codegen: Fix preconditions X-Git-Tag: 0.11.1~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc5d9b60abfb12ed8fee90019a622a92f994c1af;p=thirdparty%2Fvala.git codegen: Fix preconditions --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 564af4aba..61eb626ec 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -5416,6 +5416,8 @@ public class Vala.CCodeBaseModule : CodeGenerator { public void create_postcondition_statement (Expression postcondition) { var cassert = new CCodeFunctionCall (new CCodeIdentifier ("g_warn_if_fail")); + postcondition.emit (this); + cassert.add_argument (get_cvalue (postcondition)); ccode.add_expression (cassert); diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 3b462c8a2..484e26785 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -300,14 +300,6 @@ public class Vala.CCodeMethodModule : CCodeStructModule { m.result_var.accept (this); } - foreach (Expression precondition in m.get_preconditions ()) { - precondition.emit (this); - } - - foreach (Expression postcondition in m.get_postconditions ()) { - postcondition.emit (this); - } - // do not declare overriding methods and interface implementations if (m.is_abstract || m.is_virtual || (m.base_method == null && m.base_interface_method == null)) { @@ -956,6 +948,8 @@ public class Vala.CCodeMethodModule : CCodeStructModule { private void create_precondition_statement (CodeNode method_node, DataType ret_type, Expression precondition) { var ccheck = new CCodeFunctionCall (); + precondition.emit (this); + ccheck.add_argument (get_cvalue (precondition)); if (method_node is CreationMethod) {