]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix preconditions
authorJürg Billeter <j@bitron.ch>
Sun, 10 Oct 2010 20:30:26 +0000 (22:30 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 10 Oct 2010 20:30:26 +0000 (22:30 +0200)
codegen/valaccodebasemodule.vala
codegen/valaccodemethodmodule.vala

index 564af4abacbf2748eb0fb0d734d6e1d3b26543f2..61eb626ec3083c34c0a9de9a94328c8f7e54276f 100644 (file)
@@ -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);
index 3b462c8a2b35606b0b7d9e7a03489ba9de4e2b36..484e2678599bce9a5576eff3813daf00b74cbe36 100644 (file)
@@ -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) {