vala r1999 - in trunk: . vala



Author: juergbi
Date: Fri Nov  7 09:49:07 2008
New Revision: 1999
URL: http://svn.gnome.org/viewvc/vala?rev=1999&view=rev

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

	* vala/valadelegate.vala:
	* vala/valaenum.vala:
	* vala/valaenumvalue.vala:
	* vala/valaerrorcode.vala:
	* vala/valaerrordomain.vala:
	* vala/valainterface.vala:
	* vala/valanamespace.vala:
	* vala/valasemanticanalyzer.vala:
	* vala/valastruct.vala:

	Move type symbol checking to code nodes


Modified:
   trunk/ChangeLog
   trunk/vala/valadelegate.vala
   trunk/vala/valaenum.vala
   trunk/vala/valaenumvalue.vala
   trunk/vala/valaerrorcode.vala
   trunk/vala/valaerrordomain.vala
   trunk/vala/valainterface.vala
   trunk/vala/valanamespace.vala
   trunk/vala/valasemanticanalyzer.vala
   trunk/vala/valastruct.vala

Modified: trunk/vala/valadelegate.vala
==============================================================================
--- trunk/vala/valadelegate.vala	(original)
+++ trunk/vala/valadelegate.vala	Fri Nov  7 09:49:07 2008
@@ -327,4 +327,18 @@
 
 		return str;
 	}
+
+	public override bool check (SemanticAnalyzer analyzer) {
+		if (checked) {
+			return !error;
+		}
+
+		checked = true;
+
+		process_attributes ();
+
+		accept_children (analyzer);
+
+		return !error;
+	}
 }

Modified: trunk/vala/valaenum.vala
==============================================================================
--- trunk/vala/valaenum.vala	(original)
+++ trunk/vala/valaenum.vala	Fri Nov  7 09:49:07 2008
@@ -297,4 +297,18 @@
 			return "i";
 		}
 	}
+
+	public override bool check (SemanticAnalyzer analyzer) {
+		if (checked) {
+			return !error;
+		}
+
+		checked = true;
+
+		process_attributes ();
+
+		accept_children (analyzer);
+
+		return !error;
+	}
 }

Modified: trunk/vala/valaenumvalue.vala
==============================================================================
--- trunk/vala/valaenumvalue.vala	(original)
+++ trunk/vala/valaenumvalue.vala	Fri Nov  7 09:49:07 2008
@@ -128,4 +128,18 @@
 	public void set_cname (string cname) {
 		this.cname = cname;
 	}
+
+	public override bool check (SemanticAnalyzer analyzer) {
+		if (checked) {
+			return !error;
+		}
+
+		checked = true;
+
+		process_attributes ();
+
+		accept_children (analyzer);
+
+		return !error;
+	}
 }

Modified: trunk/vala/valaerrorcode.vala
==============================================================================
--- trunk/vala/valaerrorcode.vala	(original)
+++ trunk/vala/valaerrorcode.vala	Fri Nov  7 09:49:07 2008
@@ -72,4 +72,16 @@
 		}
 		return cname;
 	}
+
+	public override bool check (SemanticAnalyzer analyzer) {
+		if (checked) {
+			return !error;
+		}
+
+		checked = true;
+
+		accept_children (analyzer);
+
+		return !error;
+	}
 }

Modified: trunk/vala/valaerrordomain.vala
==============================================================================
--- trunk/vala/valaerrordomain.vala	(original)
+++ trunk/vala/valaerrordomain.vala	Fri Nov  7 09:49:07 2008
@@ -215,4 +215,18 @@
 	public override string? get_set_value_function () {
 		return "g_value_set_pointer";
 	}
+
+	public override bool check (SemanticAnalyzer analyzer) {
+		if (checked) {
+			return !error;
+		}
+
+		checked = true;
+
+		process_attributes ();
+
+		accept_children (analyzer);
+
+		return !error;
+	}
 }

Modified: trunk/vala/valainterface.vala
==============================================================================
--- trunk/vala/valainterface.vala	(original)
+++ trunk/vala/valainterface.vala	Fri Nov  7 09:49:07 2008
@@ -540,4 +540,54 @@
 
 		return null;
 	}
+
+	public override bool check (SemanticAnalyzer analyzer) {
+		if (checked) {
+			return !error;
+		}
+
+		checked = true;
+
+		process_attributes ();
+
+		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_symbol = analyzer.current_symbol.parent_symbol;
+
+		return !error;
+	}
 }

Modified: trunk/vala/valanamespace.vala
==============================================================================
--- trunk/vala/valanamespace.vala	(original)
+++ trunk/vala/valanamespace.vala	Fri Nov  7 09:49:07 2008
@@ -515,4 +515,16 @@
 			}
 		}
 	}
+
+	public override bool check (SemanticAnalyzer analyzer) {
+		if (checked) {
+			return !error;
+		}
+
+		checked = true;
+
+		process_attributes ();
+
+		return !error;
+	}
 }

Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala	(original)
+++ trunk/vala/valasemanticanalyzer.vala	Fri Nov  7 09:49:07 2008
@@ -139,7 +139,7 @@
 	}
 
 	public override void visit_namespace (Namespace ns) {
-		ns.process_attributes ();
+		ns.check (this);
 	}
 
 	public override void visit_class (Class cl) {
@@ -147,85 +147,31 @@
 	}
 
 	public override void visit_struct (Struct st) {
-		st.process_attributes ();
-
-		current_symbol = st;
-		current_struct = st;
-
-		st.accept_children (this);
-
-		if (!st.external && !st.external_package && st.get_base_types ().size == 0 && st.get_fields ().size == 0) {
-			Report.error (st.source_reference, "structs cannot be empty");
-		}
-
-		current_symbol = current_symbol.parent_symbol;
-		current_struct = null;
+		st.check (this);
 	}
 
 	public override void visit_interface (Interface iface) {
-		iface.process_attributes ();
-
-		current_symbol = iface;
-
-		foreach (DataType prerequisite_reference in iface.get_prerequisites ()) {
-			// check whether prerequisite is at least as accessible as the interface
-			if (!is_type_accessible (iface, prerequisite_reference)) {
-				iface.error = true;
-				Report.error (iface.source_reference, "prerequisite `%s` is less accessible than interface `%s`".printf (prerequisite_reference.to_string (), iface.get_full_name ()));
-				return;
-			}
-
-			current_source_file.add_type_dependency (prerequisite_reference, SourceFileDependencyType.HEADER_FULL);
-		}
-
-		/* check prerequisites */
-		Class prereq_class;
-		foreach (DataType prereq in iface.get_prerequisites ()) {
-			TypeSymbol class_or_interface = prereq.data_type;
-			/* skip on previous errors */
-			if (class_or_interface == null) {
-				iface.error = true;
-				continue;
-			}
-			/* interfaces are not allowed to have multiple instantiable prerequisites */
-			if (class_or_interface is Class) {
-				if (prereq_class != null) {
-					iface.error = true;
-					Report.error (iface.source_reference, "%s: Interfaces cannot have multiple instantiable prerequisites (`%s' and `%s')".printf (iface.get_full_name (), class_or_interface.get_full_name (), prereq_class.get_full_name ()));
-					return;
-				}
-
-				prereq_class = (Class) class_or_interface;
-			}
-		}
-
-		iface.accept_children (this);
-
-		current_symbol = current_symbol.parent_symbol;
+		iface.check (this);
 	}
 
 	public override void visit_enum (Enum en) {
-		en.process_attributes ();
-
-		en.accept_children (this);
+		en.check (this);
 	}
 
 	public override void visit_enum_value (EnumValue ev) {
-		ev.process_attributes ();
-
-		ev.accept_children (this);
+		ev.check (this);
 	}
 
 	public override void visit_error_domain (ErrorDomain ed) {
-		ed.process_attributes ();
+		ed.check (this);
+	}
 
-		ed.accept_children (this);
+	public override void visit_error_code (ErrorCode ec) {
+		ec.check (this);
 	}
 
 	public override void visit_delegate (Delegate d) {
-		d.process_attributes ();
-
-		d.accept_children (this);
+		d.check (this);
 	}
 
 	public override void visit_constant (Constant c) {

Modified: trunk/vala/valastruct.vala
==============================================================================
--- trunk/vala/valastruct.vala	(original)
+++ trunk/vala/valastruct.vala	Fri Nov  7 09:49:07 2008
@@ -605,4 +605,28 @@
 
 		return false;
 	}
+
+	public override bool check (SemanticAnalyzer analyzer) {
+		if (checked) {
+			return !error;
+		}
+
+		checked = true;
+
+		process_attributes ();
+
+		analyzer.current_symbol = this;
+		analyzer.current_struct = this;
+
+		accept_children (analyzer);
+
+		if (!external && !external_package && get_base_types ().size == 0 && get_fields ().size == 0) {
+			Report.error (source_reference, "structs cannot be empty");
+		}
+
+		analyzer.current_symbol = analyzer.current_symbol.parent_symbol;
+		analyzer.current_struct = null;
+
+		return !error;
+	}
 }



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