SOURCES: vala-0.5.1-2004.patch (NEW) - added, updates to svn 2004

aredridel aredridel at pld-linux.org
Sun Nov 9 20:44:09 CET 2008


Author: aredridel                    Date: Sun Nov  9 19:44:09 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- added, updates to svn 2004

---- Files affected:
SOURCES:
   vala-0.5.1-2004.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/vala-0.5.1-2004.patch
diff -u /dev/null SOURCES/vala-0.5.1-2004.patch:1.1
--- /dev/null	Sun Nov  9 20:44:09 2008
+++ SOURCES/vala-0.5.1-2004.patch	Sun Nov  9 20:44:04 2008
@@ -0,0 +1,10306 @@
+Index: vala/valablock.vala
+===================================================================
+--- vala/valablock.vala	(revision 1971)
++++ vala/valablock.vala	(revision 2004)
+@@ -90,4 +90,29 @@
+ 			stmt.accept (visitor);
+ 		}
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		owner = analyzer.current_symbol.scope;
++		analyzer.current_symbol = this;
++
++		accept_children (analyzer);
++
++		foreach (LocalVariable local in get_local_variables ()) {
++			local.active = false;
++		}
++
++		foreach (Statement stmt in get_statements()) {
++			add_error_types (stmt.get_error_types ());
++		}
++
++		analyzer.current_symbol = analyzer.current_symbol.parent_symbol;
++
++		return !error;
++	}
+ }
+Index: vala/valalocalvariable.vala
+===================================================================
+--- vala/valalocalvariable.vala	(revision 1971)
++++ vala/valalocalvariable.vala	(revision 2004)
+@@ -98,4 +98,96 @@
+ 			variable_type = new_type;
+ 		}
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		if (initializer != null) {
++			initializer.target_type = variable_type;
++		}
++
++		accept_children (analyzer);
++
++		if (variable_type == null) {
++			/* var type */
++
++			if (initializer == null) {
++				error = true;
++				Report.error (source_reference, "var declaration not allowed without initializer");
++				return false;
++			}
++			if (initializer.value_type == null) {
++				error = true;
++				Report.error (source_reference, "var declaration not allowed with non-typed initializer");
++				return false;
++			}
++
++			variable_type = initializer.value_type.copy ();
++			variable_type.value_owned = true;
++			variable_type.floating_reference = false;
++
++			initializer.target_type = variable_type;
++		}
++
++		if (initializer != null) {
++			if (initializer.value_type == null) {
++				if (!(initializer is MemberAccess) && !(initializer is LambdaExpression)) {
++					error = true;
++					Report.error (source_reference, "expression type not allowed as initializer");
++					return false;
++				}
++
++				if (initializer.symbol_reference is Method &&
++				    variable_type is DelegateType) {
++					var m = (Method) initializer.symbol_reference;
++					var dt = (DelegateType) variable_type;
++					var cb = dt.delegate_symbol;
++
++					/* check whether method matches callback type */
++					if (!cb.matches_method (m)) {
++						error = true;
++						Report.error (source_reference, "declaration of method `%s' doesn't match declaration of callback `%s'".printf (m.get_full_name (), cb.get_full_name ()));
++						return false;
++					}
++
++					initializer.value_type = variable_type;
++				} else {
++					error = true;
++					Report.error (source_reference, "expression type not allowed as initializer");
++					return false;
++				}
++			}
++
++			if (!initializer.value_type.compatible (variable_type)) {
++				error = true;
++				Report.error (source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf (initializer.value_type.to_string (), variable_type.to_string ()));
++				return false;
++			}
++
++			if (initializer.value_type.is_disposable ()) {
++				/* rhs transfers ownership of the expression */
++				if (!(variable_type is PointerType) && !variable_type.value_owned) {
++					/* lhs doesn't own the value */
++					error = true;
++					Report.error (source_reference, "Invalid assignment from owned expression to unowned variable");
++					return false;
++				}
++			}
++		}
++
++		analyzer.current_source_file.add_type_dependency (variable_type, SourceFileDependencyType.SOURCE);
++
++		analyzer.current_symbol.scope.add (name, this);
++
++		var block = (Block) analyzer.current_symbol;
++		block.add_local_variable (this);
++
++		active = true;
++
++		return !error;
++	}
+ }
+Index: vala/valainterface.vala
+===================================================================
+--- vala/valainterface.vala	(revision 1971)
++++ vala/valainterface.vala	(revision 2004)
+@@ -540,4 +540,61 @@
+ 
+ 		return null;
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		process_attributes ();
++
++		var old_source_file = analyzer.current_source_file;
++		var old_symbol = analyzer.current_symbol;
++
++		if (source_reference != null) {
++			analyzer.current_source_file = source_reference.file;
++		}
++		analyzer.current_symbol = this;
++
++		foreach (DataType prerequisite_reference in get_prerequisites ()) {
++			// check whether prerequisite is at least as accessible as the interface
++			if (!analyzer.is_type_accessible (this, prerequisite_reference)) {
++				error = true;
++				Report.error (source_reference, "prerequisite `%s` is less accessible than interface `%s`".printf (prerequisite_reference.to_string (), get_full_name ()));
++				return false;
++			}
++
++			analyzer.current_source_file.add_type_dependency (prerequisite_reference, SourceFileDependencyType.HEADER_FULL);
++		}
++
++		/* check prerequisites */
++		Class prereq_class;
++		foreach (DataType prereq in get_prerequisites ()) {
++			TypeSymbol class_or_interface = prereq.data_type;
++			/* skip on previous errors */
++			if (class_or_interface == null) {
++				error = true;
++				continue;
++			}
++			/* interfaces are not allowed to have multiple instantiable prerequisites */
++			if (class_or_interface is Class) {
++				if (prereq_class != null) {
++					error = true;
++					Report.error (source_reference, "%s: Interfaces cannot have multiple instantiable prerequisites (`%s' and `%s')".printf (get_full_name (), class_or_interface.get_full_name (), prereq_class.get_full_name ()));
++					return false;
++				}
++
++				prereq_class = (Class) class_or_interface;
++			}
++		}
++
++		accept_children (analyzer);
++
++		analyzer.current_source_file = old_source_file;
++		analyzer.current_symbol = old_symbol;
++
++		return !error;
++	}
+ }
+Index: vala/valamethod.vala
+===================================================================
+--- vala/valamethod.vala	(revision 1971)
++++ vala/valamethod.vala	(revision 2004)
+@@ -594,4 +594,152 @@
+ 			}
+ 		}
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		process_attributes ();
++
++		if (is_abstract) {
++			if (parent_symbol is Class) {
++				var cl = (Class) parent_symbol;
++				if (!cl.is_abstract) {
++					error = true;
++					Report.error (source_reference, "Abstract methods may not be declared in non-abstract classes");
++					return false;
++				}
++			} else if (!(parent_symbol is Interface)) {
++				error = true;
++				Report.error (source_reference, "Abstract methods may not be declared outside of classes and interfaces");
++				return false;
++			}
++		} else if (is_virtual) {
++			if (!(parent_symbol is Class) && !(parent_symbol is Interface)) {
++				error = true;
++				Report.error (source_reference, "Virtual methods may not be declared outside of classes and interfaces");
++				return false;
++			}
++
++			if (parent_symbol is Class) {
++				var cl = (Class) parent_symbol;
++				if (cl.is_compact) {
++					Report.error (source_reference, "Virtual methods may not be declared in compact classes");
++					return false;
++				}
++			}
++		} else if (overrides) {
++			if (!(parent_symbol is Class)) {
++				error = true;
++				Report.error (source_reference, "Methods may not be overridden outside of classes");
++				return false;
++			}
++		}
++
++		if (is_abstract && body != null) {
++			Report.error (source_reference, "Abstract methods cannot have bodies");
++		} else if (external && body != null) {
++			Report.error (source_reference, "Extern methods cannot have bodies");
++		} else if (!is_abstract && !external && !external_package && body == null) {
++			Report.error (source_reference, "Non-abstract, non-extern methods must have bodies");
++		}
++
++		var old_symbol = analyzer.current_symbol;
++		var old_return_type = analyzer.current_return_type;
++		analyzer.current_symbol = this;
++		analyzer.current_return_type = return_type;
++
++		var init_attr = get_attribute ("ModuleInit");
++		if (init_attr != null) {
++			source_reference.file.context.module_init_method = this;
++		}
++
++		if (!is_internal_symbol ()) {
++			if (return_type is ValueType) {
++				analyzer.current_source_file.add_type_dependency (return_type, SourceFileDependencyType.HEADER_FULL);
++			} else {
++				analyzer.current_source_file.add_type_dependency (return_type, SourceFileDependencyType.HEADER_SHALLOW);
++			}
++		}
++		analyzer.current_source_file.add_type_dependency (return_type, SourceFileDependencyType.SOURCE);
++
++		accept_children (analyzer);
++
++		analyzer.current_symbol = old_symbol;
++		analyzer.current_return_type = old_return_type;
++
++		if (analyzer.current_symbol.parent_symbol is Method) {
++			/* lambda expressions produce nested methods */
++			var up_method = (Method) analyzer.current_symbol.parent_symbol;
++			analyzer.current_return_type = up_method.return_type;
++		}
++
++		if (analyzer.current_symbol is Struct) {
++			if (is_abstract || is_virtual || overrides) {
++				Report.error (source_reference, "A struct member `%s' cannot be marked as override, virtual, or abstract".printf (get_full_name ()));
++				return false;
++			}
++		} else if (overrides && base_method == null) {
++			Report.error (source_reference, "%s: no suitable method found to override".printf (get_full_name ()));
++		}
++
++		// check whether return type is at least as accessible as the method
++		if (!analyzer.is_type_accessible (this, return_type)) {
++			error = true;
++			Report.error (source_reference, "return type `%s` is less accessible than method `%s`".printf (return_type.to_string (), get_full_name ()));
++			return false;
++		}
++
++		foreach (Expression precondition in get_preconditions ()) {
++			if (precondition.error) {
++				// if there was an error in the precondition, skip this check
++				error = true;
++				return false;
++			}
++
++			if (!precondition.value_type.compatible (analyzer.bool_type)) {
++				error = true;
++				Report.error (precondition.source_reference, "Precondition must be boolean");
++				return false;
++			}
++		}
++
++		foreach (Expression postcondition in get_postconditions ()) {
++			if (postcondition.error) {
++				// if there was an error in the postcondition, skip this check
++				error = true;
++				return false;
++			}
++
++			if (!postcondition.value_type.compatible (analyzer.bool_type)) {
++				error = true;
++				Report.error (postcondition.source_reference, "Postcondition must be boolean");
++				return false;
++			}
++		}
++
++		if (tree_can_fail && name == "main") {
++			Report.error (source_reference, "\"main\" method cannot throw errors");
++		}
++
++		// check that all errors that can be thrown in the method body are declared
++		if (body != null) { 
++			foreach (DataType body_error_type in body.get_error_types ()) {
++				bool can_propagate_error = false;
++				foreach (DataType method_error_type in get_error_types ()) {
++					if (body_error_type.compatible (method_error_type)) {
++						can_propagate_error = true;
++					}
++				}
++				if (!can_propagate_error) {
++					Report.warning (body_error_type.source_reference, "unhandled error `%s'".printf (body_error_type.to_string()));
++				}
++			}
++		}
++
++		return !error;
++	}
+ }
+Index: vala/valafield.vala
+===================================================================
+--- vala/valafield.vala	(revision 1971)
++++ vala/valafield.vala	(revision 2004)
+@@ -195,4 +195,44 @@
+ 		}
+ 		attr.add_argument ("type", new StringLiteral ("\"%s\"".printf (ctype)));
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		process_attributes ();
++
++		if (initializer != null) {
++			initializer.target_type = field_type;
++		}
++
++		accept_children (analyzer);
++
++		if (binding == MemberBinding.INSTANCE && parent_symbol is Interface) {
++			error = true;
++			Report.error (source_reference, "Interfaces may not have instance fields");
++			return false;
++		}
++
++		if (!is_internal_symbol ()) {
++			if (field_type is ValueType) {
++				analyzer.current_source_file.add_type_dependency (field_type, SourceFileDependencyType.HEADER_FULL);
++			} else {
++				analyzer.current_source_file.add_type_dependency (field_type, SourceFileDependencyType.HEADER_SHALLOW);
++			}
++		} else {
++			if (parent_symbol is Namespace) {
++				error = true;
++				Report.error (source_reference, "Namespaces may not have private members");
++				return false;
++			}
++
++			analyzer.current_source_file.add_type_dependency (field_type, SourceFileDependencyType.SOURCE);
++		}
++
++		return !error;
++	}
+ }
+Index: vala/valadostatement.vala
+===================================================================
+--- vala/valadostatement.vala	(revision 1971)
++++ vala/valadostatement.vala	(revision 2004)
+@@ -86,4 +86,31 @@
+ 			condition = new_node;
+ 		}
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		accept_children (analyzer);
++
++		if (condition.error) {
++			/* if there was an error in the condition, skip this check */
++			error = true;
++			return false;
++		}
++
++		if (!condition.value_type.compatible (analyzer.bool_type)) {
++			error = true;
++			Report.error (condition.source_reference, "Condition must be boolean");
++			return false;
++		}
++
++		add_error_types (condition.get_error_types ());
++		add_error_types (body.get_error_types ());
++
++		return !error;
++	}
+ }
+Index: vala/valanamespace.vala
+===================================================================
+--- vala/valanamespace.vala	(revision 1971)
++++ vala/valanamespace.vala	(revision 2004)
+@@ -515,4 +515,16 @@
+ 			}
+ 		}
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		process_attributes ();
++
++		return !error;
++	}
+ }
+Index: vala/valawhilestatement.vala
+===================================================================
+--- vala/valawhilestatement.vala	(revision 1971)
++++ vala/valawhilestatement.vala	(revision 2004)
+@@ -86,4 +86,31 @@
+ 			condition = new_node;
+ 		}
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		accept_children (analyzer);
++
++		if (condition.error) {
++			/* if there was an error in the condition, skip this check */
++			error = true;
++			return false;
++		}
++
++		if (!condition.value_type.compatible (analyzer.bool_type)) {
++			error = true;
++			Report.error (condition.source_reference, "Condition must be boolean");
++			return false;
++		}
++
++		add_error_types (condition.get_error_types ());
++		add_error_types (body.get_error_types ());
++
++		return !error;
++	}
+ }
+Index: vala/valaconstant.vala
+===================================================================
+--- vala/valaconstant.vala	(revision 1971)
++++ vala/valaconstant.vala	(revision 2004)
+@@ -150,4 +150,29 @@
+ 			}
+ 		}
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		process_attributes ();
++
++		type_reference.accept (analyzer);
++
++		if (!external_package) {
++			if (initializer == null) {
++				error = true;
++				Report.error (source_reference, "A const field requires a initializer to be provided");
++			} else {
++				initializer.target_type = type_reference;
++
++				initializer.accept (analyzer);
++			}
++		}
++
++		return !error;
++	}
+ }
+Index: vala/valadynamicproperty.vala
+===================================================================
+--- vala/valadynamicproperty.vala	(revision 1971)
++++ vala/valadynamicproperty.vala	(revision 2004)
+@@ -40,4 +40,7 @@
+ 		return new ArrayList<string> ();
+ 	}
+ 
++	public override bool check (SemanticAnalyzer analyzer) {
++		return true;
++	}
+ }
+Index: vala/valaforeachstatement.vala
+===================================================================
+--- vala/valaforeachstatement.vala	(revision 1971)
++++ vala/valaforeachstatement.vala	(revision 2004)
+@@ -134,4 +134,119 @@
+ 			type_reference = new_type;
+ 		}
+ 	}
++
++	public override bool check (SemanticAnalyzer analyzer) {
++		if (checked) {
++			return !error;
++		}
++
++		checked = true;
++
++		// analyze collection expression first, used for type inference
++		collection.accept (analyzer);
++
++		if (collection.error) {
++			// ignore inner error
++			error = true;
++			return false;
++		} else if (collection.value_type == null) {
++			Report.error (collection.source_reference, "invalid collection expression");
++			error = true;
++			return false;
++		}
++
++		var collection_type = collection.value_type.copy ();
++		collection.target_type = collection_type.copy ();
++		
++		DataType element_data_type = null;
++		bool element_owned = false;
++
++		if (collection_type.is_array ()) {
++			var array_type = (ArrayType) collection_type;
++			element_data_type = array_type.element_type;
++		} else if (collection_type.compatible (analyzer.glist_type) || collection_type.compatible (analyzer.gslist_type)) {
++			if (collection_type.get_type_arguments ().size > 0) {
++				element_data_type = (DataType) collection_type.get_type_arguments ().get (0);
++			}
++		} else if (analyzer.iterable_type != null && collection_type.compatible (analyzer.iterable_type)) {
++			element_owned = true;
++
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list