vala r1523 - in trunk: . compiler gobject vala



Author: juergbi
Date: Sat May 31 21:02:18 2008
New Revision: 1523
URL: http://svn.gnome.org/viewvc/vala?rev=1523&view=rev

Log:
2008-05-31  JÃrg Billeter  <j bitron ch>

	* vala/valasemanticanalyzer.vala:
	* vala/valasymbolresolver.vala:
	* vala/valaunaryexpression.vala:
	* gobject/valaccodegenerator.vala:
	* gobject/valaccodeinvocationexpressionbinding.vala:
	* compiler/valacompiler.vala:

	Fix memory management for ref and out arguments


Modified:
   trunk/ChangeLog
   trunk/compiler/valacompiler.vala
   trunk/gobject/valaccodegenerator.vala
   trunk/gobject/valaccodeinvocationexpressionbinding.vala
   trunk/vala/valasemanticanalyzer.vala
   trunk/vala/valasymbolresolver.vala
   trunk/vala/valaunaryexpression.vala

Modified: trunk/compiler/valacompiler.vala
==============================================================================
--- trunk/compiler/valacompiler.vala	(original)
+++ trunk/compiler/valacompiler.vala	Sat May 31 21:02:18 2008
@@ -55,27 +55,27 @@
 	private CodeContext context;
 
 	const OptionEntry[] options = {
-		{ "vapidir", 0, 0, OptionArg.FILENAME_ARRAY, out vapi_directories, "Look for package bindings in DIRECTORY", "DIRECTORY..." },
-		{ "pkg", 0, 0, OptionArg.STRING_ARRAY, out packages, "Include binding for PACKAGE", "PACKAGE..." },
-		{ "library", 0, 0, OptionArg.STRING, out library, "Library name", "NAME" },
-		{ "basedir", 'b', 0, OptionArg.FILENAME, out basedir, "Base source directory", "DIRECTORY" },
-		{ "directory", 'd', 0, OptionArg.FILENAME, out directory, "Output directory", "DIRECTORY" },
+		{ "vapidir", 0, 0, OptionArg.FILENAME_ARRAY, ref vapi_directories, "Look for package bindings in DIRECTORY", "DIRECTORY..." },
+		{ "pkg", 0, 0, OptionArg.STRING_ARRAY, ref packages, "Include binding for PACKAGE", "PACKAGE..." },
+		{ "library", 0, 0, OptionArg.STRING, ref library, "Library name", "NAME" },
+		{ "basedir", 'b', 0, OptionArg.FILENAME, ref basedir, "Base source directory", "DIRECTORY" },
+		{ "directory", 'd', 0, OptionArg.FILENAME, ref directory, "Output directory", "DIRECTORY" },
 		{ "version", 0, 0, OptionArg.NONE, ref version, "Display version number", null },
 		{ "ccode", 'C', 0, OptionArg.NONE, ref ccode_only, "Output C code", null },
 		{ "compile", 'c', 0, OptionArg.NONE, ref compile_only, "Compile but do not link", null },
-		{ "output", 'o', 0, OptionArg.FILENAME, out output, "Place output in file FILE", "FILE" },
+		{ "output", 'o', 0, OptionArg.FILENAME, ref output, "Place output in file FILE", "FILE" },
 		{ "debug", 'g', 0, OptionArg.NONE, ref debug, "Produce debug information", null },
 		{ "thread", 0, 0, OptionArg.NONE, ref thread, "Enable multithreading support", null },
-		{ "define", 'D', 0, OptionArg.STRING_ARRAY, out defines, "Define SYMBOL", "SYMBOL..." },
+		{ "define", 'D', 0, OptionArg.STRING_ARRAY, ref defines, "Define SYMBOL", "SYMBOL..." },
 		{ "disable-assert", 0, 0, OptionArg.NONE, ref disable_assert, "Disable assertions", null },
 		{ "disable-checking", 0, 0, OptionArg.NONE, ref disable_checking, "Disable run-time checks", null },
 		{ "disable-non-null", 0, 0, OptionArg.NONE, ref disable_non_null, "Disable non-null types", null },
 		{ "enable-non-null-experimental", 0, 0, OptionArg.NONE, ref non_null_experimental, "Enable experimental enhancements for non-null types", null },
-		{ "cc", 0, 0, OptionArg.STRING, out cc_command, "Use COMMAND as C compiler command", "COMMAND" },
-		{ "Xcc", 'X', 0, OptionArg.STRING_ARRAY, out cc_options, "Pass OPTION to the C compiler", "OPTION..." },
-		{ "save-temps", 0, 0, OptionArg.NONE, out save_temps, "Keep temporary files", null },
+		{ "cc", 0, 0, OptionArg.STRING, ref cc_command, "Use COMMAND as C compiler command", "COMMAND" },
+		{ "Xcc", 'X', 0, OptionArg.STRING_ARRAY, ref cc_options, "Pass OPTION to the C compiler", "OPTION..." },
+		{ "save-temps", 0, 0, OptionArg.NONE, ref save_temps, "Keep temporary files", null },
 		{ "quiet", 'q', 0, OptionArg.NONE, ref quiet_mode, "Do not print messages to the console", null },
-		{ "", 0, 0, OptionArg.FILENAME_ARRAY, out sources, null, "FILE..." },
+		{ "", 0, 0, OptionArg.FILENAME_ARRAY, ref sources, null, "FILE..." },
 		{ null }
 	};
 	

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Sat May 31 21:02:18 2008
@@ -3187,6 +3187,8 @@
 	}
 
 	public override void visit_unary_expression (UnaryExpression expr) {
+		expr.accept_children (this);
+
 		CCodeUnaryOperator op;
 		if (expr.operator == UnaryOperator.PLUS) {
 			op = CCodeUnaryOperator.PLUS;

Modified: trunk/gobject/valaccodeinvocationexpressionbinding.vala
==============================================================================
--- trunk/gobject/valaccodeinvocationexpressionbinding.vala	(original)
+++ trunk/gobject/valaccodeinvocationexpressionbinding.vala	Sat May 31 21:02:18 2008
@@ -223,7 +223,9 @@
 					}
 
 					// unref old value for non-null non-weak out arguments
-					if (param.direction == ParameterDirection.OUT && codegen.requires_destroy (param.parameter_type) && !(arg.value_type is NullType)) {
+					// disabled for arrays for now as that requires special handling
+					if (param.direction == ParameterDirection.OUT && codegen.requires_destroy (param.parameter_type)
+					    && !(arg.value_type is NullType || param.parameter_type is ArrayType)) {
 						var unary = (UnaryExpression) arg;
 
 						// (ret_tmp = call (&tmp), free (var1), var1 = tmp, ret_tmp)

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Sat May 31 21:02:18 2008
@@ -2632,6 +2632,13 @@
 	}
 
 	public override void visit_unary_expression (UnaryExpression expr) {
+		if (expr.operator == UnaryOperator.REF || expr.operator == UnaryOperator.OUT) {
+			expr.inner.lvalue = true;
+			expr.inner.target_type = expr.target_type;
+		}
+
+		expr.accept_children (this);
+
 		if (expr.inner.error) {
 			/* if there was an error in the inner expression, skip type check */
 			expr.error = true;

Modified: trunk/vala/valasymbolresolver.vala
==============================================================================
--- trunk/vala/valasymbolresolver.vala	(original)
+++ trunk/vala/valasymbolresolver.vala	Sat May 31 21:02:18 2008
@@ -365,6 +365,10 @@
 		expr.accept_children (this);
 	}
 
+	public override void visit_unary_expression (UnaryExpression expr) {
+		expr.accept_children (this);
+	}
+
 	public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) {
 		expr.accept_children (this);
 	}

Modified: trunk/vala/valaunaryexpression.vala
==============================================================================
--- trunk/vala/valaunaryexpression.vala	(original)
+++ trunk/vala/valaunaryexpression.vala	Sat May 31 21:02:18 2008
@@ -61,15 +61,17 @@
 		inner = _inner;
 		source_reference = source;
 	}
-	
+
 	public override void accept (CodeVisitor visitor) {
-		inner.accept (visitor);
-	
 		visitor.visit_unary_expression (this);
 
 		visitor.visit_expression (this);
 	}
 
+	public override void accept_children (CodeVisitor visitor) {
+		inner.accept (visitor);
+	}
+
 	public override void replace_expression (Expression old_node, Expression new_node) {
 		if (inner == old_node) {
 			inner = new_node;



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