[vala/wip/transform2: 4/4] Move MethodCall transformation into emit()



commit dbc25cbba6daa4c7b98f61cdf02a333c8cf2f046
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Aug 28 20:52:10 2011 +0200

    Move MethodCall transformation into emit()

 vala/valamethodcall.vala |   54 +++++++++++++++++++++++----------------------
 1 files changed, 28 insertions(+), 26 deletions(-)
---
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 132cc67..2a4fcfd 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -588,8 +588,6 @@ public class Vala.MethodCall : Expression {
 		formal_value_type = ret_type;
 		value_type = formal_value_type.get_actual_type (target_object_type, call as MemberAccess, this);
 
-		bool may_throw = false;
-
 		if (mtype is MethodType) {
 			var m = ((MethodType) mtype).method_symbol;
 			if (is_yield_expression) {
@@ -698,6 +696,31 @@ public class Vala.MethodCall : Expression {
 			return false;
 		}
 
+		return !error;
+	}
+
+	public override void emit (CodeGenerator codegen) {
+		var method_type = call.value_type as MethodType;
+
+		if (method_type != null) {
+			// N_ and NC_ do not have any effect on the C code,
+			// they are only interpreted by xgettext
+			// this means that it is ok to use them in constant initializers
+			// however, we must avoid generating regular method call code
+			// as that may include temporary variables
+			if (method_type.method_symbol.get_full_name () == "GLib.N_") {
+				// first argument is string
+				argument_list[0].emit (codegen);
+				this.target_value = argument_list[0].target_value;
+				return;
+			} else if (method_type.method_symbol.get_full_name () == "GLib.NC_") {
+				// second argument is string
+				argument_list[1].emit (codegen);
+				this.target_value = argument_list[1].target_value;
+				return;
+			}
+		}
+
 		if (tree_can_fail) {
 			if (parent_node is LocalVariable || parent_node is ExpressionStatement) {
 				// simple statements, no side effects after method call
@@ -723,6 +746,7 @@ public class Vala.MethodCall : Expression {
 				// don't set initializer earlier as this changes parent_node and parent_statement
 				local.initializer = this;
 				decl.check (context);
+				decl.emit (context);
 
 				// move temp variable to insert block to ensure
 				// variable is in the same block as the declarat
@@ -733,30 +757,8 @@ public class Vala.MethodCall : Expression {
 
 				old_parent_node.replace_expression (this, temp_access);
 				temp_access.check (context);
-			}
-		}
-
-		return !error;
-	}
-
-	public override void emit (CodeGenerator codegen) {
-		var method_type = call.value_type as MethodType;
-
-		if (method_type != null) {
-			// N_ and NC_ do not have any effect on the C code,
-			// they are only interpreted by xgettext
-			// this means that it is ok to use them in constant initializers
-			// however, we must avoid generating regular method call code
-			// as that may include temporary variables
-			if (method_type.method_symbol.get_full_name () == "GLib.N_") {
-				// first argument is string
-				argument_list[0].emit (codegen);
-				this.target_value = argument_list[0].target_value;
-				return;
-			} else if (method_type.method_symbol.get_full_name () == "GLib.NC_") {
-				// second argument is string
-				argument_list[1].emit (codegen);
-				this.target_value = argument_list[1].target_value;
+				temp_access.emit (context);
+				target_value = temp_access.target_value;
 				return;
 			}
 		}



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