[vala] codegen: Fix preconditions
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Fix preconditions
- Date: Sun, 10 Oct 2010 20:31:28 +0000 (UTC)
commit fc5d9b60abfb12ed8fee90019a622a92f994c1af
Author: Jürg Billeter <j bitron ch>
Date: Sun Oct 10 22:30:26 2010 +0200
codegen: Fix preconditions
codegen/valaccodebasemodule.vala | 2 ++
codegen/valaccodemethodmodule.vala | 10 ++--------
2 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 564af4a..61eb626 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 3b462c8..484e267 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]