Commit b90b3037 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

support lambda expressions in constructors remove extra printf argument

2007-03-04  Jürg Billeter  <j@bitron.ch>

	* vala/valasemanticanalyzer.vala: support lambda expressions in
	  constructors
	* tests/test-029.vala: remove extra printf argument

svn path=/trunk/; revision=217
parent 7d614d7c
2007-03-04 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: support lambda expressions in
constructors
* tests/test-029.vala: remove extra printf argument
2007-03-04 Raffaele Sandrini <rasa@gmx.ch>
* vala/valasemanticanalyzer.vala, vala/parser.y,
......
......@@ -17,7 +17,7 @@ class Maman.Foo {
stdout.printf (" %d", foo.p2);
stdout.printf (" %d", foo.p1);
stdout.printf (" 5\n", foo.p2);
stdout.printf (" 5\n");
return 0;
}
......
......@@ -1558,6 +1558,17 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
return null;
}
private bool is_in_constructor () {
var sym = current_symbol;
while (sym != null) {
if (sym.node is Constructor) {
return true;
}
sym = sym.parent_symbol;
}
return false;
}
public override void visit_begin_lambda_expression (LambdaExpression! l) {
if (l.expected_type == null || !(l.expected_type.data_type is Callback)) {
......@@ -1566,11 +1577,17 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return;
}
bool in_instance_method = false;
var current_method = find_current_method ();
if (current_method != null) {
in_instance_method = current_method.instance;
} else {
in_instance_method = is_in_constructor ();
}
var cb = (Callback) l.expected_type.data_type;
l.method = new Method (get_lambda_name (), cb.return_type);
l.method.instance = cb.instance && current_method.instance;
l.method.instance = cb.instance && in_instance_method;
l.method.symbol = new Symbol (l.method);
l.method.symbol.parent_symbol = current_symbol;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment