vala r2091 - in trunk: . ccode vala



Author: juergbi
Date: Sun Nov 30 08:34:15 2008
New Revision: 2091
URL: http://svn.gnome.org/viewvc/vala?rev=2091&view=rev

Log:
2008-11-30  JÃrg Billeter  <j bitron ch>

	* vala/valaforeachstatement.vala:
	* ccode/valaccodebinaryexpression.vala:
	* ccode/valaccodecastexpression.vala:
	* ccode/valaccodeelementaccess.vala:
	* ccode/valaccodeexpression.vala:
	* ccode/valaccodememberaccess.vala:
	* ccode/valaccodeunaryexpression.vala:

	Fix generated parentheses


Modified:
   trunk/ChangeLog
   trunk/ccode/valaccodebinaryexpression.vala
   trunk/ccode/valaccodecastexpression.vala
   trunk/ccode/valaccodeelementaccess.vala
   trunk/ccode/valaccodeexpression.vala
   trunk/ccode/valaccodememberaccess.vala
   trunk/ccode/valaccodeunaryexpression.vala
   trunk/vala/valaforeachstatement.vala

Modified: trunk/ccode/valaccodebinaryexpression.vala
==============================================================================
--- trunk/ccode/valaccodebinaryexpression.vala	(original)
+++ trunk/ccode/valaccodebinaryexpression.vala	Sun Nov 30 08:34:15 2008
@@ -48,7 +48,7 @@
 	}
 	
 	public override void write (CCodeWriter writer) {
-		left.write (writer);
+		left.write_inner (writer);
 
 		writer.write_string (" ");
 		if (operator == CCodeBinaryOperator.PLUS) {
@@ -91,7 +91,13 @@
 
 		writer.write_string (" ");
 
-		right.write (writer);
+		right.write_inner (writer);
+	}
+
+	public override void write_inner (CCodeWriter writer) {
+		writer.write_string ("(");
+		this.write (writer);
+		writer.write_string (")");
 	}
 }
 

Modified: trunk/ccode/valaccodecastexpression.vala
==============================================================================
--- trunk/ccode/valaccodecastexpression.vala	(original)
+++ trunk/ccode/valaccodecastexpression.vala	Sun Nov 30 08:34:15 2008
@@ -42,12 +42,16 @@
 	}
 	
 	public override void write (CCodeWriter writer) {
-		writer.write_string ("((");
+		writer.write_string ("(");
 		writer.write_string (type_name);
 		writer.write_string (") ");
 
+		inner.write_inner (writer);
+	}
+
+	public override void write_inner (CCodeWriter writer) {
 		writer.write_string ("(");
-		inner.write (writer);
-		writer.write_string ("))");
+		this.write (writer);
+		writer.write_string (")");
 	}
 }

Modified: trunk/ccode/valaccodeelementaccess.vala
==============================================================================
--- trunk/ccode/valaccodeelementaccess.vala	(original)
+++ trunk/ccode/valaccodeelementaccess.vala	Sun Nov 30 08:34:15 2008
@@ -1,7 +1,7 @@
 /* valaccodememberaccess.vala
  *
  * Copyright (C) 2006  Raffaele Sandrini
- * Copyright (C) 2006  JÃrg Billeter
+ * Copyright (C) 2006-2008  JÃrg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -45,7 +45,7 @@
 	}
 	
 	public override void write (CCodeWriter writer) {
-		container.write (writer);
+		container.write_inner (writer);
 		writer.write_string ("[");
 		index.write (writer);
 		writer.write_string ("]");

Modified: trunk/ccode/valaccodeexpression.vala
==============================================================================
--- trunk/ccode/valaccodeexpression.vala	(original)
+++ trunk/ccode/valaccodeexpression.vala	Sun Nov 30 08:34:15 2008
@@ -1,6 +1,6 @@
 /* valaccodeexpression.vala
  *
- * Copyright (C) 2006  JÃrg Billeter
+ * Copyright (C) 2006-2008  JÃrg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,4 +26,7 @@
  * Represents an expression node in the C code tree.
  */
 public abstract class Vala.CCodeExpression : CCodeNode {
+	public virtual void write_inner (CCodeWriter writer) {
+		this.write (writer);
+	}
 }

Modified: trunk/ccode/valaccodememberaccess.vala
==============================================================================
--- trunk/ccode/valaccodememberaccess.vala	(original)
+++ trunk/ccode/valaccodememberaccess.vala	Sun Nov 30 08:34:15 2008
@@ -1,6 +1,6 @@
 /* valaccodememberaccess.vala
  *
- * Copyright (C) 2006  JÃrg Billeter
+ * Copyright (C) 2006-2008  JÃrg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -54,7 +54,7 @@
 	}
 	
 	public override void write (CCodeWriter writer) {
-		inner.write (writer);
+		inner.write_inner (writer);
 		if (is_pointer) {
 			writer.write_string ("->");
 		} else {

Modified: trunk/ccode/valaccodeunaryexpression.vala
==============================================================================
--- trunk/ccode/valaccodeunaryexpression.vala	(original)
+++ trunk/ccode/valaccodeunaryexpression.vala	Sun Nov 30 08:34:15 2008
@@ -51,7 +51,7 @@
 		} else if (operator == CCodeUnaryOperator.BITWISE_COMPLEMENT) {
 			writer.write_string ("~");
 		} else if (operator == CCodeUnaryOperator.POINTER_INDIRECTION) {
-			writer.write_string ("(*");
+			writer.write_string ("*");
 		} else if (operator == CCodeUnaryOperator.ADDRESS_OF) {
 			writer.write_string ("&");
 		} else if (operator == CCodeUnaryOperator.PREFIX_INCREMENT) {
@@ -60,16 +60,20 @@
 			writer.write_string ("--");
 		}
 
-		inner.write (writer);
+		inner.write_inner (writer);
 
 		if (operator == CCodeUnaryOperator.POSTFIX_INCREMENT) {
 			writer.write_string ("++");
 		} else if (operator == CCodeUnaryOperator.POSTFIX_DECREMENT) {
 			writer.write_string ("--");
-		} else if (operator == CCodeUnaryOperator.POINTER_INDIRECTION) {
-			writer.write_string (")");
 		}
 	}
+
+	public override void write_inner (CCodeWriter writer) {
+		writer.write_string ("(");
+		this.write (writer);
+		writer.write_string (")");
+	}
 }
 
 public enum Vala.CCodeUnaryOperator {

Modified: trunk/vala/valaforeachstatement.vala
==============================================================================
--- trunk/vala/valaforeachstatement.vala	(original)
+++ trunk/vala/valaforeachstatement.vala	Sun Nov 30 08:34:15 2008
@@ -256,11 +256,11 @@
 		var iterator_call = new MethodCall (new MemberAccess (collection, "iterator"));
 		add_statement (new DeclarationStatement (new LocalVariable (iterator_type, "%s_it".printf (variable_name), iterator_call, source_reference), source_reference));
 
-		var next_call = new MethodCall (new MemberAccess (new MemberAccess.simple ("%s_it".printf (variable_name)), "next"));
-		var loop = new WhileStatement (next_call, body);
+		var next_call = new MethodCall (new MemberAccess (new MemberAccess.simple ("%s_it".printf (variable_name), source_reference), "next", source_reference), source_reference);
+		var loop = new WhileStatement (next_call, body, source_reference);
 		add_statement (loop);
 
-		var get_call = new MethodCall (new MemberAccess (new MemberAccess.simple ("%s_it".printf (variable_name)), "get"));
+		var get_call = new MethodCall (new MemberAccess (new MemberAccess.simple ("%s_it".printf (variable_name), source_reference), "get", source_reference), source_reference);
 		body.insert_statement (0, new DeclarationStatement (new LocalVariable (type_reference, variable_name, get_call, source_reference), source_reference));
 
 		checked = false;



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