vala r1849 - in trunk: . gobject vala



Author: juergbi
Date: Fri Oct 17 12:15:33 2008
New Revision: 1849
URL: http://svn.gnome.org/viewvc/vala?rev=1849&view=rev

Log:
2008-10-17  JÃrg Billeter  <j bitron ch>

	* vala/valabinaryexpression.vala:
	* vala/valaexpression.vala:
	* vala/valamemberaccess.vala:
	* vala/valastringliteral.vala:
	* gobject/valaccodegenerator.vala:

	Extend non-null check when managing memory, fixes bug 530422


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodegenerator.vala
   trunk/vala/valabinaryexpression.vala
   trunk/vala/valaexpression.vala
   trunk/vala/valamemberaccess.vala
   trunk/vala/valastringliteral.vala

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Fri Oct 17 12:15:33 2008
@@ -3151,7 +3151,7 @@
 
 		var ccall = new CCodeFunctionCall (dupexpr);
 
-		if (expr is StringLiteral) {
+		if (expr != null && expr.is_non_null ()) {
 			// expression is non-null
 			ccall.add_argument ((CCodeExpression) expr.ccodenode);
 			

Modified: trunk/vala/valabinaryexpression.vala
==============================================================================
--- trunk/vala/valabinaryexpression.vala	(original)
+++ trunk/vala/valabinaryexpression.vala	Fri Oct 17 12:15:33 2008
@@ -133,6 +133,10 @@
 	public override bool is_pure () {
 		return left.is_pure () && right.is_pure ();
 	}
+
+	public override bool is_non_null () {
+		return left.is_non_null () && right.is_non_null ();
+	}
 }
 
 public enum Vala.BinaryOperator {

Modified: trunk/vala/valaexpression.vala
==============================================================================
--- trunk/vala/valaexpression.vala	(original)
+++ trunk/vala/valaexpression.vala	Fri Oct 17 12:15:33 2008
@@ -73,4 +73,11 @@
 	 * is free of side-effects.
 	 */
 	public abstract bool is_pure ();
+
+	/**
+	 * Returns whether this expression is guaranteed to be non-null.
+	 */
+	public virtual bool is_non_null () {
+		return false;
+	}
 }

Modified: trunk/vala/valamemberaccess.vala
==============================================================================
--- trunk/vala/valamemberaccess.vala	(original)
+++ trunk/vala/valamemberaccess.vala	Fri Oct 17 12:15:33 2008
@@ -169,4 +169,13 @@
 			return false;
 		}
 	}
+
+	public override bool is_non_null () {
+		var c = symbol_reference as Constant;
+		if (c != null) {
+			return !c.type_reference.nullable;
+		} else {
+			return false;
+		}
+	}
 }

Modified: trunk/vala/valastringliteral.vala
==============================================================================
--- trunk/vala/valastringliteral.vala	(original)
+++ trunk/vala/valastringliteral.vala	Fri Oct 17 12:15:33 2008
@@ -69,6 +69,10 @@
 		return true;
 	}
 
+	public override bool is_non_null () {
+		return true;
+	}
+
 	public override string to_string () {
 		return value;
 	}



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