From: Jürg Billeter Date: Fri, 31 Oct 2008 09:37:07 +0000 (+0000) Subject: Check parameters when checking arguments X-Git-Tag: VALA_0_5_1~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8fc44061afe8dfbb2c3c9ab85733d61a6bfc683;p=thirdparty%2Fvala.git Check parameters when checking arguments 2008-10-31 Jürg Billeter * vala/valacodenode.vala: * vala/valaformalparameter.vala: * vala/valasemanticanalyzer.vala: * vala/valasourcefile.vala: Check parameters when checking arguments svn path=/trunk/; revision=1944 --- diff --git a/ChangeLog b/ChangeLog index 722c03cee..8efc14f90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-10-31 Jürg Billeter + + * vala/valacodenode.vala: + * vala/valaformalparameter.vala: + * vala/valasemanticanalyzer.vala: + * vala/valasourcefile.vala: + + Check parameters when checking arguments + 2008-10-31 Jürg Billeter * vala/valaformalparameter.vala: diff --git a/vala/valacodenode.vala b/vala/valacodenode.vala index 145e425c8..920eecfe3 100644 --- a/vala/valacodenode.vala +++ b/vala/valacodenode.vala @@ -64,6 +64,8 @@ public abstract class Vala.CodeNode { } } + public bool checked { get; set; } + /** * Specifies whether a fatal error has been detected in this code node. */ @@ -76,7 +78,6 @@ public abstract class Vala.CodeNode { get { return _error_types != null && _error_types.size > 0; } } - bool checked; private Gee.List _error_types; private static Gee.List _empty_type_list; diff --git a/vala/valaformalparameter.vala b/vala/valaformalparameter.vala index b24f42b2b..a4e3adecb 100644 --- a/vala/valaformalparameter.vala +++ b/vala/valaformalparameter.vala @@ -168,6 +168,20 @@ public class Vala.FormalParameter : Symbol { } public override bool check (SemanticAnalyzer analyzer) { + if (checked) { + return !error; + } + + checked = true; + + 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 = parent_symbol; + accept_children (analyzer); if (analyzer.context.non_null && default_expression != null) { @@ -192,7 +206,6 @@ public class Vala.FormalParameter : Symbol { if (!analyzer.is_type_accessible (this, parameter_type)) { error = true; Report.error (source_reference, "parameter type `%s` is less accessible than method `%s`".printf (parameter_type.to_string (), parent_symbol.get_full_name ())); - return false; } } @@ -201,7 +214,6 @@ public class Vala.FormalParameter : Symbol { if (!(parent_symbol is CreationMethod)) { error = true; Report.error (source_reference, "construct parameters are only allowed in type creation methods"); - return false; } var method_body = ((CreationMethod) parent_symbol).body; @@ -211,7 +223,10 @@ public class Vala.FormalParameter : Symbol { method_body.add_statement (new ExpressionStatement (new Assignment (left, right), source_reference)); } - return true; + analyzer.current_source_file = old_source_file; + analyzer.current_symbol = old_symbol; + + return !error; } } diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index bb89fe294..b4c35c087 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -31,7 +31,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { public CodeContext context { get; set; } Symbol root_symbol; - Symbol current_symbol; + public Symbol current_symbol { get; set; } public SourceFile current_source_file { get; set; } DataType current_return_type; Class current_class; @@ -2186,6 +2186,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor { bool ellipsis = false; int i = 0; foreach (FormalParameter param in params) { + if (!param.check (this)) { + return false; + } + if (param.ellipsis) { ellipsis = true; break; diff --git a/vala/valasourcefile.vala b/vala/valasourcefile.vala index b38a717f6..89a08e198 100644 --- a/vala/valasourcefile.vala +++ b/vala/valasourcefile.vala @@ -265,6 +265,9 @@ public class Vala.SourceFile { * Adds the specified symbol to the list of symbols code in this source * file depends on. * + * TODO Move source and header file dependency analysis to + * code generator. + * * @param sym a symbol * @param dep_type type of dependency */ @@ -328,6 +331,9 @@ public class Vala.SourceFile { * Adds the symbols that define the specified type to the list of * symbols code in this source file depends on. * + * TODO Move source and header file dependency analysis to + * code generator. + * * @param type a data type * @param dep_type type of dependency */