[vala/wip/transform: 1/2] Analyze nodes after they are inserted into the tree



commit 99c35ef1fceb390b50d2278e08169bce36906d61
Author: Luca Bruno <lucabru src gnome org>
Date:   Fri Aug 5 17:22:18 2011 +0200

    Analyze nodes after they are inserted into the tree

 vala/valabinaryexpression.vala         |   12 ++++++++----
 vala/valaconditionalexpression.vala    |    6 +++---
 vala/valamethodcall.vala               |    2 +-
 vala/valaobjectcreationexpression.vala |    2 +-
 4 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index 07b3ee3..a73708a 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -157,7 +157,6 @@ public class Vala.BinaryExpression : Expression {
 
 			var local = new LocalVariable (context.analyzer.bool_type.copy (), get_temp_name (), null, source_reference);
 			var decl = new DeclarationStatement (local, source_reference);
-			decl.check (context);
 
 			var right_stmt = new ExpressionStatement (new Assignment (new MemberAccess.simple (local.name, right.source_reference), right, AssignmentOperator.SIMPLE, right.source_reference), right.source_reference);
 
@@ -179,6 +178,8 @@ public class Vala.BinaryExpression : Expression {
 			insert_statement (context.analyzer.insert_block, decl);
 			insert_statement (context.analyzer.insert_block, if_stmt);
 
+			decl.check (context);
+
 			if (!if_stmt.check (context)) {
 				error = true;
 				return false;
@@ -186,17 +187,17 @@ public class Vala.BinaryExpression : Expression {
 
 			var ma = new MemberAccess.simple (local.name, source_reference);
 			ma.target_type = target_type;
-			ma.check (context);
 
 			parent_node.replace_expression (this, ma);
 
+			ma.check (context);
+
 			return true;
 		}
 
 		if (operator == BinaryOperator.COALESCE) {
 			var local = new LocalVariable (null, get_temp_name (), left, source_reference);
 			var decl = new DeclarationStatement (local, source_reference);
-			decl.check (context);
 
 			var right_stmt = new ExpressionStatement (new Assignment (new MemberAccess.simple (local.name, right.source_reference), right, AssignmentOperator.SIMPLE, right.source_reference), right.source_reference);
 
@@ -211,6 +212,8 @@ public class Vala.BinaryExpression : Expression {
 			insert_statement (context.analyzer.insert_block, decl);
 			insert_statement (context.analyzer.insert_block, if_stmt);
 
+			decl.check (context);
+
 			if (!if_stmt.check (context)) {
 				error = true;
 				return false;
@@ -218,10 +221,11 @@ public class Vala.BinaryExpression : Expression {
 
 			var ma = new MemberAccess.simple (local.name, source_reference);
 			ma.target_type = target_type;
-			ma.check (context);
 
 			parent_node.replace_expression (this, ma);
 
+			ma.check (context);
+
 			return true;
 		}
 
diff --git a/vala/valaconditionalexpression.vala b/vala/valaconditionalexpression.vala
index 3ae003c..b86ee1f 100644
--- a/vala/valaconditionalexpression.vala
+++ b/vala/valaconditionalexpression.vala
@@ -169,20 +169,20 @@ public class Vala.ConditionalExpression : Expression {
 		false_expression.target_type = value_type;
 
 		var true_stmt = new ExpressionStatement (new Assignment (new MemberAccess.simple (local.name, true_expression.source_reference), true_expression, AssignmentOperator.SIMPLE, true_expression.source_reference), true_expression.source_reference);
-		true_stmt.check (context);
 
 		var false_stmt = new ExpressionStatement (new Assignment (new MemberAccess.simple (local.name, false_expression.source_reference), false_expression, AssignmentOperator.SIMPLE, false_expression.source_reference), false_expression.source_reference);
-		false_stmt.check (context);
 
 		true_block.replace_statement (true_decl, true_stmt);
 		false_block.replace_statement (false_decl, false_stmt);
+		true_stmt.check (context);
+		false_stmt.check (context);
 
 		var ma = new MemberAccess.simple (local.name, source_reference);
 		ma.formal_target_type = formal_target_type;
 		ma.target_type = target_type;
-		ma.check (context);
 
 		parent_node.replace_expression (this, ma);
+		ma.check (context);
 
 		return true;
 	}
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index c602142..cefe99e 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -737,7 +737,6 @@ public class Vala.MethodCall : Expression {
 				// don't set initializer earlier as this changes parent_node and parent_statement
 				local.initializer = this;
 				decl.check (context);
-				temp_access.check (context);
 
 				// move temp variable to insert block to ensure the
 				// variable is in the same block as the declaration
@@ -747,6 +746,7 @@ public class Vala.MethodCall : Expression {
 				context.analyzer.insert_block.add_local_variable (local);
 
 				old_parent_node.replace_expression (this, temp_access);
+				temp_access.check (context);
 			}
 		}
 
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index a274de0..dfb8ca2 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -414,7 +414,6 @@ public class Vala.ObjectCreationExpression : Expression {
 				// don't set initializer earlier as this changes parent_node and parent_statement
 				local.initializer = this;
 				decl.check (context);
-				temp_access.check (context);
 
 				// move temp variable to insert block to ensure the
 				// variable is in the same block as the declaration
@@ -424,6 +423,7 @@ public class Vala.ObjectCreationExpression : Expression {
 				context.analyzer.insert_block.add_local_variable (local);
 
 				old_parent_node.replace_expression (this, temp_access);
+				temp_access.check (context);
 			}
 		}
 



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