vala r2010 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2010 - in trunk: . vala
- Date: Mon, 10 Nov 2008 22:01:52 +0000 (UTC)
Author: juergbi
Date: Mon Nov 10 22:01:51 2008
New Revision: 2010
URL: http://svn.gnome.org/viewvc/vala?rev=2010&view=rev
Log:
2008-11-10 JÃrg Billeter <j bitron ch>
* vala/valaaddressofexpression.vala:
* vala/valaarraycreationexpression.vala:
* vala/valaassignment.vala:
* vala/valabinaryexpression.vala:
* vala/valablock.vala:
* vala/valacastexpression.vala:
* vala/valacatchclause.vala:
* vala/valaclass.vala:
* vala/valaconditionalexpression.vala:
* vala/valaconstant.vala:
* vala/valaconstructor.vala:
* vala/valacreationmethod.vala:
* vala/valadeclarationstatement.vala:
* vala/valadelegate.vala:
* vala/valadeletestatement.vala:
* vala/valadestructor.vala:
* vala/valadostatement.vala:
* vala/valaelementaccess.vala:
* vala/valaenum.vala:
* vala/valaenumvalue.vala:
* vala/valaerrorcode.vala:
* vala/valaerrordomain.vala:
* vala/valaexpressionstatement.vala:
* vala/valafield.vala:
* vala/valaforeachstatement.vala:
* vala/valaformalparameter.vala:
* vala/valaforstatement.vala:
* vala/valaifstatement.vala:
* vala/valainitializerlist.vala:
* vala/valainterface.vala:
* vala/valainvocationexpression.vala:
* vala/valalambdaexpression.vala:
* vala/valalocalvariable.vala:
* vala/valalockstatement.vala:
* vala/valamemberaccess.vala:
* vala/valamemberinitializer.vala:
* vala/valamethod.vala:
* vala/valanamespace.vala:
* vala/valaobjectcreationexpression.vala:
* vala/valaparenthesizedexpression.vala:
* vala/valapointerindirection.vala:
* vala/valapostfixexpression.vala:
* vala/valaproperty.vala:
* vala/valapropertyaccessor.vala:
* vala/valareferencetransferexpression.vala:
* vala/valareturnstatement.vala:
* vala/valasemanticanalyzer.vala:
* vala/valasignal.vala:
* vala/valasizeofexpression.vala:
* vala/valasourcefile.vala:
* vala/valastruct.vala:
* vala/valaswitchlabel.vala:
* vala/valaswitchsection.vala:
* vala/valaswitchstatement.vala:
* vala/valathrowstatement.vala:
* vala/valatrystatement.vala:
* vala/valatypecheck.vala:
* vala/valatypeofexpression.vala:
* vala/valaunaryexpression.vala:
* vala/valawhilestatement.vala:
* vala/valayieldstatement.vala:
Remove unnecessary accept calls in semantic analyzer
Modified:
trunk/ChangeLog
trunk/vala/valaaddressofexpression.vala
trunk/vala/valaarraycreationexpression.vala
trunk/vala/valaassignment.vala
trunk/vala/valabinaryexpression.vala
trunk/vala/valablock.vala
trunk/vala/valacastexpression.vala
trunk/vala/valacatchclause.vala
trunk/vala/valaclass.vala
trunk/vala/valaconditionalexpression.vala
trunk/vala/valaconstant.vala
trunk/vala/valaconstructor.vala
trunk/vala/valacreationmethod.vala
trunk/vala/valadeclarationstatement.vala
trunk/vala/valadelegate.vala
trunk/vala/valadeletestatement.vala
trunk/vala/valadestructor.vala
trunk/vala/valadostatement.vala
trunk/vala/valaelementaccess.vala
trunk/vala/valaenum.vala
trunk/vala/valaenumvalue.vala
trunk/vala/valaerrorcode.vala
trunk/vala/valaerrordomain.vala
trunk/vala/valaexpressionstatement.vala
trunk/vala/valafield.vala
trunk/vala/valaforeachstatement.vala
trunk/vala/valaformalparameter.vala
trunk/vala/valaforstatement.vala
trunk/vala/valaifstatement.vala
trunk/vala/valainitializerlist.vala
trunk/vala/valainterface.vala
trunk/vala/valainvocationexpression.vala
trunk/vala/valalambdaexpression.vala
trunk/vala/valalocalvariable.vala
trunk/vala/valalockstatement.vala
trunk/vala/valamemberaccess.vala
trunk/vala/valamemberinitializer.vala
trunk/vala/valamethod.vala
trunk/vala/valanamespace.vala
trunk/vala/valaobjectcreationexpression.vala
trunk/vala/valaparenthesizedexpression.vala
trunk/vala/valapointerindirection.vala
trunk/vala/valapostfixexpression.vala
trunk/vala/valaproperty.vala
trunk/vala/valapropertyaccessor.vala
trunk/vala/valareferencetransferexpression.vala
trunk/vala/valareturnstatement.vala
trunk/vala/valasemanticanalyzer.vala
trunk/vala/valasignal.vala
trunk/vala/valasizeofexpression.vala
trunk/vala/valasourcefile.vala
trunk/vala/valastruct.vala
trunk/vala/valaswitchlabel.vala
trunk/vala/valaswitchsection.vala
trunk/vala/valaswitchstatement.vala
trunk/vala/valathrowstatement.vala
trunk/vala/valatrystatement.vala
trunk/vala/valatypecheck.vala
trunk/vala/valatypeofexpression.vala
trunk/vala/valaunaryexpression.vala
trunk/vala/valawhilestatement.vala
trunk/vala/valayieldstatement.vala
Modified: trunk/vala/valaaddressofexpression.vala
==============================================================================
--- trunk/vala/valaaddressofexpression.vala (original)
+++ trunk/vala/valaaddressofexpression.vala Mon Nov 10 22:01:51 2008
@@ -77,7 +77,8 @@
checked = true;
- if (inner.error) {
+ if (!inner.check (analyzer)) {
+ error = true;
return false;
}
if (!(inner.value_type is ValueType
Modified: trunk/vala/valaarraycreationexpression.vala
==============================================================================
--- trunk/vala/valaarraycreationexpression.vala (original)
+++ trunk/vala/valaarraycreationexpression.vala Mon Nov 10 22:01:51 2008
@@ -109,7 +109,7 @@
private int create_sizes_from_initializer_list (SemanticAnalyzer analyzer, InitializerList il, int rank, Gee.List<Literal> sl) {
var init = new IntegerLiteral (il.size.to_string (), il.source_reference);
- init.accept (analyzer);
+ init.check (analyzer);
sl.add (init);
int subsize = -1;
@@ -155,18 +155,18 @@
var initlist = initializer_list;
if (element_type != null) {
- element_type.accept (analyzer);
+ element_type.check (analyzer);
}
foreach (Expression e in size) {
- e.accept (analyzer);
+ e.check (analyzer);
}
var calc_sizes = new ArrayList<Literal> ();
if (initlist != null) {
initlist.target_type = new ArrayType (element_type, rank, source_reference);
- initlist.accept (analyzer);
+ initlist.check (analyzer);
var ret = create_sizes_from_initializer_list (analyzer, initlist, rank, calc_sizes);
if (ret == -1) {
Modified: trunk/vala/valaassignment.vala
==============================================================================
--- trunk/vala/valaassignment.vala (original)
+++ trunk/vala/valaassignment.vala Mon Nov 10 22:01:51 2008
@@ -107,9 +107,7 @@
left.lvalue = true;
- left.accept (analyzer);
-
- if (left.error) {
+ if (!left.check (analyzer)) {
// skip on error in inner expression
error = true;
return false;
@@ -161,9 +159,7 @@
return false;
}
- right.accept (analyzer);
-
- if (right.error) {
+ if (!right.check (analyzer)) {
// skip on error in inner expression
error = true;
return false;
@@ -207,7 +203,7 @@
}
right = bin;
- right.accept (analyzer);
+ right.check (analyzer);
operator = AssignmentOperator.SIMPLE;
}
@@ -365,7 +361,7 @@
* increment calls */
}
} else {
- return false;
+ return true;
}
if (left.value_type != null) {
Modified: trunk/vala/valabinaryexpression.vala
==============================================================================
--- trunk/vala/valabinaryexpression.vala (original)
+++ trunk/vala/valabinaryexpression.vala Mon Nov 10 22:01:51 2008
@@ -145,7 +145,7 @@
checked = true;
- if (left.error || right.error) {
+ if (!left.check (analyzer) || !right.check (analyzer)) {
/* if there were any errors in inner expressions, skip type check */
error = true;
return false;
Modified: trunk/vala/valablock.vala
==============================================================================
--- trunk/vala/valablock.vala (original)
+++ trunk/vala/valablock.vala Mon Nov 10 22:01:51 2008
@@ -101,13 +101,15 @@
owner = analyzer.current_symbol.scope;
analyzer.current_symbol = this;
- accept_children (analyzer);
+ foreach (Statement stmt in statement_list) {
+ stmt.check (analyzer);
+ }
foreach (LocalVariable local in get_local_variables ()) {
local.active = false;
}
- foreach (Statement stmt in get_statements()) {
+ foreach (Statement stmt in get_statements ()) {
add_error_types (stmt.get_error_types ());
}
Modified: trunk/vala/valacastexpression.vala
==============================================================================
--- trunk/vala/valacastexpression.vala (original)
+++ trunk/vala/valacastexpression.vala Mon Nov 10 22:01:51 2008
@@ -105,11 +105,13 @@
checked = true;
- if (inner.error) {
+ if (!inner.check (analyzer)) {
error = true;
return false;
}
+ type_reference.check (analyzer);
+
// FIXME: check whether cast is allowed
analyzer.current_source_file.add_type_dependency (type_reference, SourceFileDependencyType.SOURCE);
Modified: trunk/vala/valacatchclause.vala
==============================================================================
--- trunk/vala/valacatchclause.vala (original)
+++ trunk/vala/valacatchclause.vala Mon Nov 10 22:01:51 2008
@@ -113,7 +113,9 @@
error_type = new ErrorType (null, null, source_reference);
}
- accept_children (analyzer);
+ error_type.check (analyzer);
+
+ body.check (analyzer);
return !error;
}
Modified: trunk/vala/valaclass.vala
==============================================================================
--- trunk/vala/valaclass.vala (original)
+++ trunk/vala/valaclass.vala Mon Nov 10 22:01:51 2008
@@ -884,7 +884,66 @@
analyzer.current_source_file.add_type_dependency (base_type_reference, SourceFileDependencyType.HEADER_FULL);
}
- accept_children (analyzer);
+ foreach (DataType type in base_types) {
+ type.check (analyzer);
+ }
+
+ foreach (TypeParameter p in type_parameters) {
+ p.check (analyzer);
+ }
+
+ /* process enums first to avoid order problems in C code */
+ foreach (Enum en in enums) {
+ en.check (analyzer);
+ }
+
+ foreach (Field f in fields) {
+ f.check (analyzer);
+ }
+
+ foreach (Constant c in constants) {
+ c.check (analyzer);
+ }
+
+ foreach (Method m in methods) {
+ m.check (analyzer);
+ }
+
+ foreach (Property prop in properties) {
+ prop.check (analyzer);
+ }
+
+ foreach (Signal sig in signals) {
+ sig.check (analyzer);
+ }
+
+ if (constructor != null) {
+ constructor.check (analyzer);
+ }
+
+ if (class_constructor != null) {
+ class_constructor.check (analyzer);
+ }
+
+ if (static_constructor != null) {
+ static_constructor.check (analyzer);
+ }
+
+ if (destructor != null) {
+ destructor.check (analyzer);
+ }
+
+ foreach (Class cl in classes) {
+ cl.check (analyzer);
+ }
+
+ foreach (Struct st in structs) {
+ st.check (analyzer);
+ }
+
+ foreach (Delegate d in delegates) {
+ d.check (analyzer);
+ }
/* compact classes cannot implement interfaces */
if (is_compact) {
Modified: trunk/vala/valaconditionalexpression.vala
==============================================================================
--- trunk/vala/valaconditionalexpression.vala (original)
+++ trunk/vala/valaconditionalexpression.vala Mon Nov 10 22:01:51 2008
@@ -77,7 +77,7 @@
checked = true;
- if (condition.error || false_expression.error || true_expression.error) {
+ if (!condition.check (analyzer) || !false_expression.check (analyzer) || !true_expression.check (analyzer)) {
return false;
}
Modified: trunk/vala/valaconstant.vala
==============================================================================
--- trunk/vala/valaconstant.vala (original)
+++ trunk/vala/valaconstant.vala Mon Nov 10 22:01:51 2008
@@ -160,7 +160,7 @@
process_attributes ();
- type_reference.accept (analyzer);
+ type_reference.check (analyzer);
if (!external_package) {
if (initializer == null) {
@@ -169,7 +169,7 @@
} else {
initializer.target_type = type_reference;
- initializer.accept (analyzer);
+ initializer.check (analyzer);
}
}
Modified: trunk/vala/valaconstructor.vala
==============================================================================
--- trunk/vala/valaconstructor.vala (original)
+++ trunk/vala/valaconstructor.vala Mon Nov 10 22:01:51 2008
@@ -74,7 +74,9 @@
owner = analyzer.current_symbol.scope;
analyzer.current_symbol = this;
- accept_children (analyzer);
+ if (body != null) {
+ body.check (analyzer);
+ }
foreach (DataType body_error_type in body.get_error_types ()) {
Report.warning (body_error_type.source_reference, "unhandled error `%s'".printf (body_error_type.to_string()));
Modified: trunk/vala/valacreationmethod.vala
==============================================================================
--- trunk/vala/valacreationmethod.vala (original)
+++ trunk/vala/valacreationmethod.vala Mon Nov 10 22:01:51 2008
@@ -137,7 +137,17 @@
analyzer.current_symbol = this;
analyzer.current_return_type = return_type;
- accept_children (analyzer);
+ foreach (FormalParameter param in get_parameters()) {
+ param.check (analyzer);
+ }
+
+ foreach (DataType error_type in get_error_types ()) {
+ error_type.check (analyzer);
+ }
+
+ if (body != null) {
+ body.check (analyzer);
+ }
analyzer.current_symbol = old_symbol;
analyzer.current_return_type = old_return_type;
Modified: trunk/vala/valadeclarationstatement.vala
==============================================================================
--- trunk/vala/valadeclarationstatement.vala (original)
+++ trunk/vala/valadeclarationstatement.vala Mon Nov 10 22:01:51 2008
@@ -56,6 +56,8 @@
checked = true;
+ declaration.check (analyzer);
+
var local = declaration as LocalVariable;
if (local != null && local.initializer != null) {
foreach (DataType error_type in local.initializer.get_error_types ()) {
Modified: trunk/vala/valadelegate.vala
==============================================================================
--- trunk/vala/valadelegate.vala (original)
+++ trunk/vala/valadelegate.vala Mon Nov 10 22:01:51 2008
@@ -343,7 +343,15 @@
analyzer.current_source_file = source_reference.file;
}
- accept_children (analyzer);
+ foreach (TypeParameter p in type_parameters) {
+ p.check (analyzer);
+ }
+
+ return_type.check (analyzer);
+
+ foreach (FormalParameter param in parameters) {
+ param.check (analyzer);
+ }
analyzer.current_source_file = old_source_file;
Modified: trunk/vala/valadeletestatement.vala
==============================================================================
--- trunk/vala/valadeletestatement.vala (original)
+++ trunk/vala/valadeletestatement.vala Mon Nov 10 22:01:51 2008
@@ -51,9 +51,7 @@
checked = true;
- accept_children (analyzer);
-
- if (expression.error) {
+ if (!expression.check (analyzer)) {
// if there was an error in the inner expression, skip this check
return false;
}
Modified: trunk/vala/valadestructor.vala
==============================================================================
--- trunk/vala/valadestructor.vala (original)
+++ trunk/vala/valadestructor.vala Mon Nov 10 22:01:51 2008
@@ -71,7 +71,9 @@
owner = analyzer.current_symbol.scope;
analyzer.current_symbol = this;
- accept_children (analyzer);
+ if (body != null) {
+ body.check (analyzer);
+ }
analyzer.current_symbol = analyzer.current_symbol.parent_symbol;
Modified: trunk/vala/valadostatement.vala
==============================================================================
--- trunk/vala/valadostatement.vala (original)
+++ trunk/vala/valadostatement.vala Mon Nov 10 22:01:51 2008
@@ -94,9 +94,9 @@
checked = true;
- accept_children (analyzer);
+ body.check (analyzer);
- if (condition.error) {
+ if (!condition.check (analyzer)) {
/* if there was an error in the condition, skip this check */
error = true;
return false;
Modified: trunk/vala/valaelementaccess.vala
==============================================================================
--- trunk/vala/valaelementaccess.vala (original)
+++ trunk/vala/valaelementaccess.vala Mon Nov 10 22:01:51 2008
@@ -93,7 +93,7 @@
checked = true;
- container.accept (analyzer);
+ container.check (analyzer);
if (container.value_type == null) {
/* don't proceed if a child expression failed */
@@ -114,7 +114,7 @@
}
foreach (Expression index in get_indices ()) {
- index.accept (analyzer);
+ index.check (analyzer);
}
bool index_int_type_check = true;
Modified: trunk/vala/valaenum.vala
==============================================================================
--- trunk/vala/valaenum.vala (original)
+++ trunk/vala/valaenum.vala Mon Nov 10 22:01:51 2008
@@ -313,7 +313,13 @@
analyzer.current_source_file = source_reference.file;
}
- accept_children (analyzer);
+ foreach (EnumValue value in values) {
+ value.check (analyzer);
+ }
+
+ foreach (Method m in methods) {
+ m.check (analyzer);
+ }
analyzer.current_source_file = old_source_file;
Modified: trunk/vala/valaenumvalue.vala
==============================================================================
--- trunk/vala/valaenumvalue.vala (original)
+++ trunk/vala/valaenumvalue.vala Mon Nov 10 22:01:51 2008
@@ -138,7 +138,9 @@
process_attributes ();
- accept_children (analyzer);
+ if (value != null) {
+ value.check (analyzer);
+ }
return !error;
}
Modified: trunk/vala/valaerrorcode.vala
==============================================================================
--- trunk/vala/valaerrorcode.vala (original)
+++ trunk/vala/valaerrorcode.vala Mon Nov 10 22:01:51 2008
@@ -80,7 +80,9 @@
checked = true;
- accept_children (analyzer);
+ if (value != null) {
+ value.check (analyzer);
+ }
return !error;
}
Modified: trunk/vala/valaerrordomain.vala
==============================================================================
--- trunk/vala/valaerrordomain.vala (original)
+++ trunk/vala/valaerrordomain.vala Mon Nov 10 22:01:51 2008
@@ -225,7 +225,13 @@
process_attributes ();
- accept_children (analyzer);
+ foreach (ErrorCode ecode in codes) {
+ ecode.check (analyzer);
+ }
+
+ foreach (Method m in methods) {
+ m.check (analyzer);
+ }
return !error;
}
Modified: trunk/vala/valaexpressionstatement.vala
==============================================================================
--- trunk/vala/valaexpressionstatement.vala (original)
+++ trunk/vala/valaexpressionstatement.vala Mon Nov 10 22:01:51 2008
@@ -93,7 +93,7 @@
checked = true;
- if (expression.error) {
+ if (!expression.check (analyzer)) {
// ignore inner error
error = true;
return false;
Modified: trunk/vala/valafield.vala
==============================================================================
--- trunk/vala/valafield.vala (original)
+++ trunk/vala/valafield.vala Mon Nov 10 22:01:51 2008
@@ -211,7 +211,11 @@
initializer.target_type = field_type;
}
- accept_children (analyzer);
+ field_type.check (analyzer);
+
+ if (initializer != null) {
+ initializer.check (analyzer);
+ }
if (binding == MemberBinding.INSTANCE && parent_symbol is Interface) {
error = true;
Modified: trunk/vala/valaforeachstatement.vala
==============================================================================
--- trunk/vala/valaforeachstatement.vala (original)
+++ trunk/vala/valaforeachstatement.vala Mon Nov 10 22:01:51 2008
@@ -143,9 +143,7 @@
checked = true;
// analyze collection expression first, used for type inference
- collection.accept (analyzer);
-
- if (collection.error) {
+ if (!collection.check (analyzer)) {
// ignore inner error
error = true;
return false;
@@ -230,7 +228,7 @@
owner = analyzer.current_symbol.scope;
analyzer.current_symbol = this;
- body.accept (analyzer);
+ body.check (analyzer);
foreach (LocalVariable local in get_local_variables ()) {
local.active = false;
Modified: trunk/vala/valaformalparameter.vala
==============================================================================
--- trunk/vala/valaformalparameter.vala (original)
+++ trunk/vala/valaformalparameter.vala Mon Nov 10 22:01:51 2008
@@ -188,7 +188,13 @@
parameter_type.check (analyzer);
}
- accept_children (analyzer);
+ if (!ellipsis) {
+ parameter_type.check (analyzer);
+
+ if (default_expression != null) {
+ default_expression.check (analyzer);
+ }
+ }
if (analyzer.context.non_null && default_expression != null) {
if (default_expression is NullLiteral
Modified: trunk/vala/valaforstatement.vala
==============================================================================
--- trunk/vala/valaforstatement.vala (original)
+++ trunk/vala/valaforstatement.vala Mon Nov 10 22:01:51 2008
@@ -164,7 +164,19 @@
checked = true;
- accept_children (analyzer);
+ foreach (Expression init_expr in initializer) {
+ init_expr.check (analyzer);
+ }
+
+ if (condition != null) {
+ condition.check (analyzer);
+ }
+
+ foreach (Expression it_expr in iterator) {
+ it_expr.check (analyzer);
+ }
+
+ body.check (analyzer);
if (condition != null && condition.error) {
/* if there was an error in the condition, skip this check */
Modified: trunk/vala/valaifstatement.vala
==============================================================================
--- trunk/vala/valaifstatement.vala (original)
+++ trunk/vala/valaifstatement.vala Mon Nov 10 22:01:51 2008
@@ -94,7 +94,12 @@
checked = true;
- accept_children (analyzer);
+ condition.check (analyzer);
+
+ true_statement.check (analyzer);
+ if (false_statement != null) {
+ false_statement.check (analyzer);
+ }
if (condition.error) {
/* if there was an error in the condition, skip this check */
Modified: trunk/vala/valainitializerlist.vala
==============================================================================
--- trunk/vala/valainitializerlist.vala (original)
+++ trunk/vala/valainitializerlist.vala Mon Nov 10 22:01:51 2008
@@ -142,7 +142,9 @@
return false;
}
- accept_children (analyzer);
+ foreach (Expression expr in initializers) {
+ expr.check (analyzer);
+ }
bool error = false;
foreach (Expression e in get_initializers ()) {
Modified: trunk/vala/valainterface.vala
==============================================================================
--- trunk/vala/valainterface.vala (original)
+++ trunk/vala/valainterface.vala Mon Nov 10 22:01:51 2008
@@ -590,7 +590,45 @@
}
}
- accept_children (analyzer);
+ foreach (DataType type in prerequisites) {
+ type.check (analyzer);
+ }
+
+ foreach (TypeParameter p in type_parameters) {
+ p.check (analyzer);
+ }
+
+ foreach (Enum en in enums) {
+ en.check (analyzer);
+ }
+
+ foreach (Method m in methods) {
+ m.check (analyzer);
+ }
+
+ foreach (Field f in fields) {
+ f.check (analyzer);
+ }
+
+ foreach (Property prop in properties) {
+ prop.check (analyzer);
+ }
+
+ foreach (Signal sig in signals) {
+ sig.check (analyzer);
+ }
+
+ foreach (Class cl in classes) {
+ cl.check (analyzer);
+ }
+
+ foreach (Struct st in structs) {
+ st.check (analyzer);
+ }
+
+ foreach (Delegate d in delegates) {
+ d.check (analyzer);
+ }
analyzer.current_source_file = old_source_file;
analyzer.current_symbol = old_symbol;
Modified: trunk/vala/valainvocationexpression.vala
==============================================================================
--- trunk/vala/valainvocationexpression.vala (original)
+++ trunk/vala/valainvocationexpression.vala Mon Nov 10 22:01:51 2008
@@ -128,9 +128,7 @@
checked = true;
- call.accept (analyzer);
-
- if (call.error) {
+ if (!call.check (analyzer)) {
/* if method resolving didn't succeed, skip this check */
error = true;
return false;
@@ -172,7 +170,7 @@
struct_creation_expression.target_type = target_type;
analyzer.replaced_nodes.add (this);
parent_node.replace_expression (this, struct_creation_expression);
- struct_creation_expression.accept (analyzer);
+ struct_creation_expression.check (analyzer);
return false;
} else if (call is MemberAccess
&& call.symbol_reference is CreationMethod) {
@@ -360,7 +358,7 @@
}
foreach (Expression arg in get_argument_list ()) {
- arg.accept (analyzer);
+ arg.check (analyzer);
}
DataType ret_type;
Modified: trunk/vala/valalambdaexpression.vala
==============================================================================
--- trunk/vala/valalambdaexpression.vala (original)
+++ trunk/vala/valalambdaexpression.vala Mon Nov 10 22:01:51 2008
@@ -189,7 +189,15 @@
/* lambda expressions should be usable like MemberAccess of a method */
symbol_reference = method;
- accept_children (analyzer);
+ if (method == null) {
+ if (expression_body != null) {
+ expression_body.check (analyzer);
+ } else if (statement_body != null) {
+ statement_body.check (analyzer);
+ }
+ } else {
+ method.check (analyzer);
+ }
value_type = new MethodType (method);
Modified: trunk/vala/valalocalvariable.vala
==============================================================================
--- trunk/vala/valalocalvariable.vala (original)
+++ trunk/vala/valalocalvariable.vala Mon Nov 10 22:01:51 2008
@@ -110,7 +110,13 @@
initializer.target_type = variable_type;
}
- accept_children (analyzer);
+ if (initializer != null) {
+ initializer.check (analyzer);
+ }
+
+ if (variable_type != null) {
+ variable_type.check (analyzer);
+ }
if (variable_type == null) {
/* var type */
Modified: trunk/vala/valalockstatement.vala
==============================================================================
--- trunk/vala/valalockstatement.vala (original)
+++ trunk/vala/valalockstatement.vala Mon Nov 10 22:01:51 2008
@@ -55,6 +55,9 @@
checked = true;
+ resource.check (analyzer);
+ body.check (analyzer);
+
/* resource must be a member access and denote a Lockable */
if (!(resource is MemberAccess && resource.symbol_reference is Lockable)) {
error = true;
Modified: trunk/vala/valamemberaccess.vala
==============================================================================
--- trunk/vala/valamemberaccess.vala (original)
+++ trunk/vala/valamemberaccess.vala Mon Nov 10 22:01:51 2008
@@ -182,6 +182,14 @@
checked = true;
+ if (inner != null) {
+ inner.check (analyzer);
+ }
+
+ foreach (DataType type_arg in type_argument_list) {
+ type_arg.check (analyzer);
+ }
+
Symbol base_symbol = null;
FormalParameter this_parameter = null;
bool may_access_instance_members = false;
@@ -257,7 +265,7 @@
if (pointer_type != null && pointer_type.base_type is ValueType) {
// transform foo->bar to (*foo).bar
inner = new PointerIndirection (inner, source_reference);
- inner.accept (analyzer);
+ inner.check (analyzer);
pointer_member_access = false;
}
}
Modified: trunk/vala/valamemberinitializer.vala
==============================================================================
--- trunk/vala/valamemberinitializer.vala (original)
+++ trunk/vala/valamemberinitializer.vala Mon Nov 10 22:01:51 2008
@@ -59,5 +59,9 @@
public override void accept (CodeVisitor visitor) {
initializer.accept (visitor);
}
+
+ public override bool check (SemanticAnalyzer analyzer) {
+ return initializer.check (analyzer);
+ }
}
Modified: trunk/vala/valamethod.vala
==============================================================================
--- trunk/vala/valamethod.vala (original)
+++ trunk/vala/valamethod.vala Mon Nov 10 22:01:51 2008
@@ -668,7 +668,33 @@
}
analyzer.current_source_file.add_type_dependency (return_type, SourceFileDependencyType.SOURCE);
- accept_children (analyzer);
+ if (return_type != null) {
+ return_type.check (analyzer);
+ }
+
+ foreach (FormalParameter param in parameters) {
+ param.check (analyzer);
+ }
+
+ foreach (DataType error_type in get_error_types ()) {
+ error_type.check (analyzer);
+ }
+
+ if (result_var != null) {
+ result_var.variable_type.check (analyzer);
+ }
+
+ foreach (Expression precondition in preconditions) {
+ precondition.check (analyzer);
+ }
+
+ foreach (Expression postcondition in postconditions) {
+ postcondition.check (analyzer);
+ }
+
+ if (body != null) {
+ body.check (analyzer);
+ }
analyzer.current_symbol = old_symbol;
analyzer.current_return_type = old_return_type;
Modified: trunk/vala/valanamespace.vala
==============================================================================
--- trunk/vala/valanamespace.vala (original)
+++ trunk/vala/valanamespace.vala Mon Nov 10 22:01:51 2008
@@ -525,6 +525,10 @@
process_attributes ();
+ foreach (Namespace ns in namespaces) {
+ ns.check (analyzer);
+ }
+
return !error;
}
}
Modified: trunk/vala/valaobjectcreationexpression.vala
==============================================================================
--- trunk/vala/valaobjectcreationexpression.vala (original)
+++ trunk/vala/valaobjectcreationexpression.vala Mon Nov 10 22:01:51 2008
@@ -158,7 +158,7 @@
checked = true;
if (member_name != null) {
- member_name.accept (analyzer);
+ member_name.check (analyzer);
}
TypeSymbol type = null;
@@ -311,7 +311,7 @@
}
foreach (Expression arg in args) {
- arg.accept (analyzer);
+ arg.check (analyzer);
}
analyzer.check_arguments (this, new MethodType (m), m.get_parameters (), args);
@@ -324,7 +324,21 @@
add_error_type (call_error_type);
}
} else if (type_reference is ErrorType) {
- accept_children (analyzer);
+ if (type_reference != null) {
+ type_reference.check (analyzer);
+ }
+
+ if (member_name != null) {
+ member_name.check (analyzer);
+ }
+
+ foreach (Expression arg in argument_list) {
+ arg.check (analyzer);
+ }
+
+ foreach (MemberInitializer init in object_initializer) {
+ init.check (analyzer);
+ }
if (get_argument_list ().size == 0) {
error = true;
Modified: trunk/vala/valaparenthesizedexpression.vala
==============================================================================
--- trunk/vala/valaparenthesizedexpression.vala (original)
+++ trunk/vala/valaparenthesizedexpression.vala Mon Nov 10 22:01:51 2008
@@ -82,9 +82,7 @@
inner.target_type = target_type;
- accept_children (analyzer);
-
- if (inner.error) {
+ if (!inner.check (analyzer)) {
// ignore inner error
error = true;
return false;
Modified: trunk/vala/valapointerindirection.vala
==============================================================================
--- trunk/vala/valapointerindirection.vala (original)
+++ trunk/vala/valapointerindirection.vala Mon Nov 10 22:01:51 2008
@@ -77,7 +77,7 @@
checked = true;
- if (inner.error) {
+ if (!inner.check (analyzer)) {
return false;
}
if (inner.value_type == null) {
Modified: trunk/vala/valapostfixexpression.vala
==============================================================================
--- trunk/vala/valapostfixexpression.vala (original)
+++ trunk/vala/valapostfixexpression.vala Mon Nov 10 22:01:51 2008
@@ -69,6 +69,8 @@
checked = true;
+ inner.check (analyzer);
+
value_type = inner.value_type;
return !error;
Modified: trunk/vala/valaproperty.vala
==============================================================================
--- trunk/vala/valaproperty.vala (original)
+++ trunk/vala/valaproperty.vala Mon Nov 10 22:01:51 2008
@@ -424,14 +424,14 @@
property_type.check (analyzer);
if (get_accessor != null) {
- get_accessor.accept (analyzer);
+ get_accessor.check (analyzer);
}
if (set_accessor != null) {
- set_accessor.accept (analyzer);
+ set_accessor.check (analyzer);
}
if (default_expression != null) {
- default_expression.accept (analyzer);
+ default_expression.check (analyzer);
}
// check whether property type is at least as accessible as the property
Modified: trunk/vala/valapropertyaccessor.vala
==============================================================================
--- trunk/vala/valapropertyaccessor.vala (original)
+++ trunk/vala/valapropertyaccessor.vala Mon Nov 10 22:01:51 2008
@@ -176,7 +176,9 @@
}
}
- accept_children (analyzer);
+ if (body != null) {
+ body.check (analyzer);
+ }
analyzer.current_return_type = old_return_type;
Modified: trunk/vala/valareferencetransferexpression.vala
==============================================================================
--- trunk/vala/valareferencetransferexpression.vala (original)
+++ trunk/vala/valareferencetransferexpression.vala Mon Nov 10 22:01:51 2008
@@ -81,7 +81,7 @@
inner.lvalue = true;
- accept_children (analyzer);
+ inner.check (analyzer);
if (inner.error) {
/* if there was an error in the inner expression, skip type check */
Modified: trunk/vala/valareturnstatement.vala
==============================================================================
--- trunk/vala/valareturnstatement.vala (original)
+++ trunk/vala/valareturnstatement.vala Mon Nov 10 22:01:51 2008
@@ -82,9 +82,7 @@
return_expression.target_type = analyzer.current_return_type;
}
- accept_children (analyzer);
-
- if (return_expression != null && return_expression.error) {
+ if (return_expression != null && !return_expression.check (analyzer)) {
// ignore inner error
error = true;
return false;
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Mon Nov 10 22:01:51 2008
@@ -122,6 +122,7 @@
}
current_symbol = root_symbol;
+ context.root.check (this);
context.accept (this);
}
@@ -130,63 +131,7 @@
next_lambda_id = 0;
- file.accept_children (this);
- }
-
- public override void visit_namespace (Namespace ns) {
- ns.check (this);
- }
-
- public override void visit_class (Class cl) {
- cl.check (this);
- }
-
- public override void visit_struct (Struct st) {
- st.check (this);
- }
-
- public override void visit_interface (Interface iface) {
- iface.check (this);
- }
-
- public override void visit_enum (Enum en) {
- en.check (this);
- }
-
- public override void visit_enum_value (EnumValue ev) {
- ev.check (this);
- }
-
- public override void visit_error_domain (ErrorDomain ed) {
- ed.check (this);
- }
-
- public override void visit_error_code (ErrorCode ec) {
- ec.check (this);
- }
-
- public override void visit_delegate (Delegate d) {
- d.check (this);
- }
-
- public override void visit_constant (Constant c) {
- c.check (this);
- }
-
- public override void visit_field (Field f) {
- f.check (this);
- }
-
- public override void visit_method (Method m) {
- m.check (this);
- }
-
- public override void visit_creation_method (CreationMethod m) {
- m.check (this);
- }
-
- public override void visit_formal_parameter (FormalParameter p) {
- p.check (this);
+ file.check (this);
}
// check whether type is at least as accessible as the specified symbol
@@ -203,126 +148,6 @@
return true;
}
- public override void visit_property (Property prop) {
- prop.check (this);
- }
-
- public override void visit_property_accessor (PropertyAccessor acc) {
- acc.check (this);
- }
-
- public override void visit_signal (Signal sig) {
- sig.check (this);
- }
-
- public override void visit_constructor (Constructor c) {
- c.check (this);
- }
-
- public override void visit_destructor (Destructor d) {
- d.check (this);
- }
-
- public override void visit_block (Block b) {
- b.check (this);
- }
-
- public override void visit_declaration_statement (DeclarationStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_local_variable (LocalVariable local) {
- local.check (this);
- }
-
- public override void visit_initializer_list (InitializerList list) {
- list.check (this);
- }
-
- public override void visit_expression_statement (ExpressionStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_if_statement (IfStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_switch_section (SwitchSection section) {
- section.check (this);
- }
-
- public override void visit_while_statement (WhileStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_do_statement (DoStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_for_statement (ForStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_foreach_statement (ForeachStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_return_statement (ReturnStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_yield_statement (YieldStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_throw_statement (ThrowStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_try_statement (TryStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_catch_clause (CatchClause clause) {
- clause.check (this);
- }
-
- public override void visit_lock_statement (LockStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_delete_statement (DeleteStatement stmt) {
- stmt.check (this);
- }
-
- public override void visit_array_creation_expression (ArrayCreationExpression expr) {
- expr.check (this);
- }
-
- public override void visit_boolean_literal (BooleanLiteral expr) {
- expr.check (this);
- }
-
- public override void visit_character_literal (CharacterLiteral expr) {
- expr.check (this);
- }
-
- public override void visit_integer_literal (IntegerLiteral expr) {
- expr.check (this);
- }
-
- public override void visit_real_literal (RealLiteral expr) {
- expr.check (this);
- }
-
- public override void visit_string_literal (StringLiteral expr) {
- expr.check (this);
- }
-
- public override void visit_null_literal (NullLiteral expr) {
- expr.check (this);
- }
-
public DataType? get_value_type_for_symbol (Symbol sym, bool lvalue) {
if (sym is Field) {
var f = (Field) sym;
@@ -420,14 +245,6 @@
return null;
}
- public override void visit_parenthesized_expression (ParenthesizedExpression expr) {
- expr.check (this);
- }
-
- public override void visit_member_access (MemberAccess expr) {
- expr.check (this);
- }
-
public static DataType get_data_type_for_symbol (TypeSymbol sym) {
DataType type = null;
@@ -449,10 +266,6 @@
return type;
}
- public override void visit_invocation_expression (InvocationExpression expr) {
- expr.check (this);
- }
-
public bool check_arguments (Expression expr, DataType mtype, Gee.List<FormalParameter> params, Gee.List<Expression> args) {
Expression prev_arg = null;
Iterator<Expression> arg_it = args.iterator ();
@@ -750,10 +563,6 @@
return actual_type;
}
- public override void visit_element_access (ElementAccess expr) {
- expr.check (this);
- }
-
public bool is_in_instance_method () {
var sym = current_symbol;
while (sym != null) {
@@ -776,20 +585,8 @@
return false;
}
- public override void visit_base_access (BaseAccess expr) {
- expr.check (this);
- }
-
- public override void visit_postfix_expression (PostfixExpression expr) {
- expr.check (this);
- }
-
- public override void visit_object_creation_expression (ObjectCreationExpression expr) {
- expr.check (this);
- }
-
public void visit_member_initializer (MemberInitializer init, DataType type) {
- init.accept (this);
+ init.check (this);
init.symbol_reference = symbol_lookup_inherited (type.data_type, init.name);
if (!(init.symbol_reference is Field || init.symbol_reference is Property)) {
@@ -822,34 +619,6 @@
}
}
- public override void visit_sizeof_expression (SizeofExpression expr) {
- expr.check (this);
- }
-
- public override void visit_typeof_expression (TypeofExpression expr) {
- expr.check (this);
- }
-
- public override void visit_unary_expression (UnaryExpression expr) {
- expr.check (this);
- }
-
- public override void visit_cast_expression (CastExpression expr) {
- expr.check (this);
- }
-
- public override void visit_pointer_indirection (PointerIndirection expr) {
- expr.check (this);
- }
-
- public override void visit_addressof_expression (AddressofExpression expr) {
- expr.check (this);
- }
-
- public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) {
- expr.check (this);
- }
-
public DataType? get_arithmetic_result_type (DataType left_type, DataType right_type) {
if (!(left_type.data_type is Struct) || !(right_type.data_type is Struct)) {
// at least one operand not struct
@@ -882,18 +651,6 @@
}
}
- public override void visit_binary_expression (BinaryExpression expr) {
- expr.check (this);
- }
-
- public override void visit_type_check (TypeCheck expr) {
- expr.check (this);
- }
-
- public override void visit_conditional_expression (ConditionalExpression expr) {
- expr.check (this);
- }
-
public Method? find_current_method () {
var sym = current_symbol;
while (sym != null) {
@@ -915,12 +672,4 @@
}
return false;
}
-
- public override void visit_lambda_expression (LambdaExpression l) {
- l.check (this);
- }
-
- public override void visit_assignment (Assignment a) {
- a.check (this);
- }
}
Modified: trunk/vala/valasignal.vala
==============================================================================
--- trunk/vala/valasignal.vala (original)
+++ trunk/vala/valasignal.vala Mon Nov 10 22:01:51 2008
@@ -228,7 +228,11 @@
process_attributes ();
- accept_children (analyzer);
+ return_type.check (analyzer);
+
+ foreach (FormalParameter param in parameters) {
+ param.check (analyzer);
+ }
return !error;
}
Modified: trunk/vala/valasizeofexpression.vala
==============================================================================
--- trunk/vala/valasizeofexpression.vala (original)
+++ trunk/vala/valasizeofexpression.vala Mon Nov 10 22:01:51 2008
@@ -76,6 +76,8 @@
checked = true;
+ type_reference.check (analyzer);
+
value_type = analyzer.ulong_type;
return !error;
Modified: trunk/vala/valasourcefile.vala
==============================================================================
--- trunk/vala/valasourcefile.vala (original)
+++ trunk/vala/valasourcefile.vala Mon Nov 10 22:01:51 2008
@@ -487,6 +487,13 @@
return mapped_file.get_length ();
}
+
+ public bool check (SemanticAnalyzer analyzer) {
+ foreach (CodeNode node in nodes) {
+ node.check (analyzer);
+ }
+ return true;
+ }
}
public enum Vala.SourceFileDependencyType {
Modified: trunk/vala/valastruct.vala
==============================================================================
--- trunk/vala/valastruct.vala (original)
+++ trunk/vala/valastruct.vala Mon Nov 10 22:01:51 2008
@@ -625,7 +625,25 @@
analyzer.current_symbol = this;
analyzer.current_struct = this;
- accept_children (analyzer);
+ foreach (DataType type in base_types) {
+ type.check (analyzer);
+ }
+
+ foreach (TypeParameter p in type_parameters) {
+ p.check (analyzer);
+ }
+
+ foreach (Field f in fields) {
+ f.check (analyzer);
+ }
+
+ foreach (Constant c in constants) {
+ c.check (analyzer);
+ }
+
+ foreach (Method m in methods) {
+ m.check (analyzer);
+ }
if (!external && !external_package && get_base_types ().size == 0 && get_fields ().size == 0) {
Report.error (source_reference, "structs cannot be empty");
Modified: trunk/vala/valaswitchlabel.vala
==============================================================================
--- trunk/vala/valaswitchlabel.vala (original)
+++ trunk/vala/valaswitchlabel.vala Mon Nov 10 22:01:51 2008
@@ -62,4 +62,12 @@
visitor.visit_switch_label (this);
}
+
+ public override bool check (SemanticAnalyzer analyzer) {
+ if (expression != null) {
+ expression.check (analyzer);
+ }
+
+ return true;
+ }
}
Modified: trunk/vala/valaswitchsection.vala
==============================================================================
--- trunk/vala/valaswitchsection.vala (original)
+++ trunk/vala/valaswitchsection.vala Mon Nov 10 22:01:51 2008
@@ -89,14 +89,14 @@
checked = true;
foreach (SwitchLabel label in get_labels ()) {
- label.accept (analyzer);
+ label.check (analyzer);
}
owner = analyzer.current_symbol.scope;
analyzer.current_symbol = this;
foreach (Statement st in get_statements ()) {
- st.accept (analyzer);
+ st.check (analyzer);
}
foreach (LocalVariable local in get_local_variables ()) {
Modified: trunk/vala/valaswitchstatement.vala
==============================================================================
--- trunk/vala/valaswitchstatement.vala (original)
+++ trunk/vala/valaswitchstatement.vala Mon Nov 10 22:01:51 2008
@@ -91,4 +91,20 @@
expression = new_node;
}
}
+
+ public override bool check (SemanticAnalyzer analyzer) {
+ if (checked) {
+ return !error;
+ }
+
+ checked = true;
+
+ expression.check (analyzer);
+
+ foreach (SwitchSection section in sections) {
+ section.check (analyzer);
+ }
+
+ return !error;
+ }
}
Modified: trunk/vala/valathrowstatement.vala
==============================================================================
--- trunk/vala/valathrowstatement.vala (original)
+++ trunk/vala/valathrowstatement.vala Mon Nov 10 22:01:51 2008
@@ -83,7 +83,9 @@
error_expression.target_type = new ErrorType (null, null, source_reference);
error_expression.target_type.value_owned = true;
- accept_children (analyzer);
+ if (error_expression != null) {
+ error_expression.check (analyzer);
+ }
var error_type = error_expression.value_type.copy ();
error_type.source_reference = source_reference;
Modified: trunk/vala/valatrystatement.vala
==============================================================================
--- trunk/vala/valatrystatement.vala (original)
+++ trunk/vala/valatrystatement.vala Mon Nov 10 22:01:51 2008
@@ -94,7 +94,15 @@
checked = true;
- accept_children (analyzer);
+ body.check (analyzer);
+
+ foreach (CatchClause clause in catch_clauses) {
+ clause.check (analyzer);
+ }
+
+ if (finally_body != null) {
+ finally_body.check (analyzer);
+ }
return !error;
}
Modified: trunk/vala/valatypecheck.vala
==============================================================================
--- trunk/vala/valatypecheck.vala (original)
+++ trunk/vala/valatypecheck.vala Mon Nov 10 22:01:51 2008
@@ -85,6 +85,10 @@
checked = true;
+ expression.check (analyzer);
+
+ type_reference.check (analyzer);
+
if (type_reference.data_type == null) {
/* if type resolving didn't succeed, skip this check */
error = true;
Modified: trunk/vala/valatypeofexpression.vala
==============================================================================
--- trunk/vala/valatypeofexpression.vala (original)
+++ trunk/vala/valatypeofexpression.vala Mon Nov 10 22:01:51 2008
@@ -76,6 +76,8 @@
checked = true;
+ type_reference.check (analyzer);
+
value_type = analyzer.type_type;
return !error;
Modified: trunk/vala/valaunaryexpression.vala
==============================================================================
--- trunk/vala/valaunaryexpression.vala (original)
+++ trunk/vala/valaunaryexpression.vala Mon Nov 10 22:01:51 2008
@@ -148,9 +148,7 @@
inner.target_type = target_type;
}
- accept_children (analyzer);
-
- if (inner.error) {
+ if (!inner.check (analyzer)) {
/* if there was an error in the inner expression, skip type check */
error = true;
return false;
@@ -207,7 +205,7 @@
parenthexp.target_type = target_type;
analyzer.replaced_nodes.add (this);
parent_node.replace_expression (this, parenthexp);
- parenthexp.accept (analyzer);
+ parenthexp.check (analyzer);
return true;
} else if (operator == UnaryOperator.REF || operator == UnaryOperator.OUT) {
if (inner.symbol_reference is Field || inner.symbol_reference is FormalParameter || inner.symbol_reference is LocalVariable) {
Modified: trunk/vala/valawhilestatement.vala
==============================================================================
--- trunk/vala/valawhilestatement.vala (original)
+++ trunk/vala/valawhilestatement.vala Mon Nov 10 22:01:51 2008
@@ -94,7 +94,9 @@
checked = true;
- accept_children (analyzer);
+ condition.check (analyzer);
+
+ body.check (analyzer);
if (condition.error) {
/* if there was an error in the condition, skip this check */
Modified: trunk/vala/valayieldstatement.vala
==============================================================================
--- trunk/vala/valayieldstatement.vala (original)
+++ trunk/vala/valayieldstatement.vala Mon Nov 10 22:01:51 2008
@@ -71,7 +71,7 @@
public override bool check (SemanticAnalyzer analyzer) {
if (yield_expression != null) {
- yield_expression.accept (analyzer);
+ yield_expression.check (analyzer);
error = yield_expression.error;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]