[vala] dova: Fix closures in static methods



commit 63be9bcd2611af372428f231da15220db5b931a4
Author: Jürg Billeter <j bitron ch>
Date:   Sat Jun 26 21:48:52 2010 +0200

    dova: Fix closures in static methods

 codegen/valadovabasemodule.vala |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 77befcc..59b5fba 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -2234,21 +2234,23 @@ internal class Vala.DovaBaseModule : CCodeModule {
 		if (target_type is DelegateType && expression_type is MethodType) {
 			var deleg_type = (DelegateType) target_type;
 			var method_type = (MethodType) expression_type;
-			CCodeExpression delegate_target = new CCodeConstant ("NULL");
-			if (method_type.method_symbol.binding == MemberBinding.INSTANCE) {
-				if (expr is LambdaExpression) {
-					var lambda = (LambdaExpression) expr;
-					if (lambda.method.closure) {
-						int block_id = get_block_id (current_closure_block);
-						delegate_target = get_variable_cexpression ("_data%d_".printf (block_id));
-					} else if (get_this_type () != null) {
-						delegate_target = new CCodeIdentifier ("this");
-					} else {
-						delegate_target = new CCodeConstant ("NULL");
-					}
+			CCodeExpression delegate_target;
+			if (expr is LambdaExpression) {
+				var lambda = (LambdaExpression) expr;
+				if (lambda.method.closure) {
+					int block_id = get_block_id (current_closure_block);
+					delegate_target = get_variable_cexpression ("_data%d_".printf (block_id));
+				} else if (get_this_type () != null) {
+					delegate_target = new CCodeIdentifier ("this");
 				} else {
+					delegate_target = new CCodeConstant ("NULL");
+				}
+			} else {
+				if (method_type.method_symbol.binding == MemberBinding.INSTANCE) {
 					var ma = (MemberAccess) expr;
 					delegate_target = (CCodeExpression) get_ccodenode (ma.inner);
+				} else {
+					delegate_target = new CCodeConstant ("NULL");
 				}
 			}
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_new".printf (deleg_type.delegate_symbol.get_lower_case_cname ())));



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