[vala] codegen: Fix line directives for ref_sink



commit 9dcec6bca12eb2bd76ce6cb1bab61d0903553506
Author: JÃrg Billeter <j bitron ch>
Date:   Sat Jun 23 16:23:23 2012 +0200

    codegen: Fix line directives for ref_sink
    
    Fixes bug 678237.

 codegen/valaccodebasemodule.vala |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 769722a..fd7fe17 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5291,14 +5291,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			var sink_func = (cl != null) ? get_ccode_ref_sink_function (cl) : "";
 
 			if (sink_func != "") {
+				if (type.nullable) {
+					var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeIdentifier ("NULL"));
+					ccode.open_if (is_not_null);
+				}
+
 				var csink = new CCodeFunctionCall (new CCodeIdentifier (sink_func));
 				csink.add_argument (result.cvalue);
+				ccode.add_expression (csink);
+
 				if (type.nullable) {
-					var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeIdentifier ("NULL"));
-					var csink_stat = new CCodeIfStatement (is_not_null, new CCodeExpressionStatement (csink));
-					ccode.add_statement (csink_stat);
-				} else {
-					ccode.add_expression (csink);
+					ccode.close ();
 				}
 			} else {
 				Report.error (null, "type `%s' does not support floating references".printf (type.data_type.name));



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