+2008-10-31 Jürg Billeter <j@bitron.ch>
+
+ * vala/valacodenode.vala:
+ * vala/valaformalparameter.vala:
+ * vala/valasemanticanalyzer.vala:
+ * vala/valasourcefile.vala:
+
+ Check parameters when checking arguments
+
2008-10-31 Jürg Billeter <j@bitron.ch>
* vala/valaformalparameter.vala:
}
}
+ public bool checked { get; set; }
+
/**
* Specifies whether a fatal error has been detected in this code node.
*/
get { return _error_types != null && _error_types.size > 0; }
}
- bool checked;
private Gee.List<DataType> _error_types;
private static Gee.List<DataType> _empty_type_list;
}
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) {
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;
}
}
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;
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;
}
}
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;
bool ellipsis = false;
int i = 0;
foreach (FormalParameter param in params) {
+ if (!param.check (this)) {
+ return false;
+ }
+
if (param.ellipsis) {
ellipsis = true;
break;
* 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
*/
* 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
*/