vala r1872 - in trunk: . vala



Author: juergbi
Date: Wed Oct 22 19:23:56 2008
New Revision: 1872
URL: http://svn.gnome.org/viewvc/vala?rev=1872&view=rev

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

	* vala/valaintegertype.vala:
	* vala/valasemanticanalyzer.vala:

	Fix leaked reference cycle


Modified:
   trunk/ChangeLog
   trunk/vala/valaintegertype.vala
   trunk/vala/valasemanticanalyzer.vala

Modified: trunk/vala/valaintegertype.vala
==============================================================================
--- trunk/vala/valaintegertype.vala	(original)
+++ trunk/vala/valaintegertype.vala	Wed Oct 22 19:23:56 2008
@@ -26,22 +26,24 @@
  * An integer type.
  */
 public class Vala.IntegerType : ValueType {
-	public IntegerLiteral literal { get; set; }
+	string literal_value;
+	string literal_type_name;
 
-	public IntegerType (TypeSymbol type_symbol) {
+	public IntegerType (TypeSymbol type_symbol, string literal_value, string literal_type_name) {
 		this.type_symbol = type_symbol;
 		data_type = type_symbol;
+		this.literal_value = literal_value;
+		this.literal_type_name = literal_type_name;
 	}
 
 	public override DataType copy () {
-		var type = new IntegerType (type_symbol);
-		type.literal = literal;
+		var type = new IntegerType (type_symbol, literal_value, literal_type_name);
 		type.is_type_argument = is_type_argument;
 		return type;
 	}
 
 	public override bool compatible (DataType target_type) {
-		if (target_type.data_type is Struct && literal.get_type_name () == "int") {
+		if (target_type.data_type is Struct && literal_type_name == "int") {
 			// int literals are implicitly convertible to integer types
 			// of a lower rank if the value of the literal is within
 			// the range of the target type
@@ -49,16 +51,16 @@
 			if (target_st.is_integer_type ()) {
 				var int_attr = target_st.get_attribute ("IntegerType");
 				if (int_attr != null && int_attr.has_argument ("min") && int_attr.has_argument ("max")) {
-					int val = literal.value.to_int ();
+					int val = literal_value.to_int ();
 					return (val >= int_attr.get_integer ("min") && val <= int_attr.get_integer ("max"));
 				} else {
 					// assume to be compatible if the target type doesn't specify limits
 					return true;
 				}
 			}
-		} else if (target_type.data_type is Enum && literal.get_type_name () == "int") {
+		} else if (target_type.data_type is Enum && literal_type_name == "int") {
 			// allow implicit conversion from 0 to enum and flags types
-			if (literal.value.to_int () == 0) {
+			if (literal_value.to_int () == 0) {
 				return true;
 			}
 		}

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Wed Oct 22 19:23:56 2008
@@ -1408,9 +1408,7 @@
 	}
 
 	public override void visit_integer_literal (IntegerLiteral expr) {
-		var int_type = new IntegerType ((TypeSymbol) root_symbol.scope.lookup (expr.get_type_name ()));
-		int_type.literal = expr;
-		expr.value_type = int_type;
+		expr.value_type = new IntegerType ((TypeSymbol) root_symbol.scope.lookup (expr.get_type_name ()), expr.value, expr.get_type_name ());
 	}
 
 	public override void visit_real_literal (RealLiteral expr) {



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