vala r1028 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1028 - in trunk: . gobject vala
- Date: Thu, 21 Feb 2008 21:45:32 +0000 (GMT)
Author: juergbi
Date: Thu Feb 21 21:45:32 2008
New Revision: 1028
URL: http://svn.gnome.org/viewvc/vala?rev=1028&view=rev
Log:
2008-02-21 Juerg Billeter <j bitron ch>
* vala/valamemorymanager.vala, vala/valaparenthesizedexpression.vala,
vala/valasemanticanalyzer.vala, vala/valasymbolresolver.vala,
gobject/valaccodegenerator.vala: support delegate parameters in
creation methods, fixes bug 513273
Modified:
trunk/ChangeLog
trunk/gobject/valaccodegenerator.vala
trunk/vala/valamemorymanager.vala
trunk/vala/valaparenthesizedexpression.vala
trunk/vala/valasemanticanalyzer.vala
trunk/vala/valasymbolresolver.vala
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Thu Feb 21 21:45:32 2008
@@ -2220,6 +2220,8 @@
}
public override void visit_parenthesized_expression (ParenthesizedExpression! expr) {
+ expr.accept_children (this);
+
expr.ccodenode = new CCodeParenthesizedExpression ((CCodeExpression) expr.inner.ccodenode);
visit_expression (expr);
@@ -2373,6 +2375,12 @@
if (delegate_expr is InvocationExpression) {
var invocation_expr = (InvocationExpression) delegate_expr;
return invocation_expr.delegate_target;
+ } else if (delegate_expr is LambdaExpression) {
+ if ((current_method != null && current_method.instance) || in_constructor) {
+ return new CCodeIdentifier ("self");
+ } else {
+ return new CCodeConstant ("NULL");
+ }
} else if (delegate_expr.symbol_reference != null) {
if (delegate_expr.symbol_reference is FormalParameter) {
var param = (FormalParameter) delegate_expr.symbol_reference;
@@ -2710,8 +2718,9 @@
Iterator<FormalParameter> params_it = params.iterator ();
foreach (Expression arg in expr.get_argument_list ()) {
CCodeExpression cexpr = (CCodeExpression) arg.ccodenode;
+ FormalParameter param = null;
if (params_it.next ()) {
- var param = params_it.get ();
+ param = params_it.get ();
ellipsis = param.ellipsis;
if (!param.ellipsis) {
cexpr = get_implicit_cast_expression (cexpr, arg.static_type, param.type_reference);
@@ -2727,6 +2736,15 @@
}
creation_call.add_argument (cexpr);
+
+ if (param != null && param.type_reference is DelegateType) {
+ var deleg_type = (DelegateType) param.type_reference;
+ var d = deleg_type.delegate_symbol;
+ if (d.instance) {
+ creation_call.add_argument (get_delegate_target_cexpression (arg));
+ }
+ }
+
i++;
}
while (params_it.next ()) {
Modified: trunk/vala/valamemorymanager.vala
==============================================================================
--- trunk/vala/valamemorymanager.vala (original)
+++ trunk/vala/valamemorymanager.vala Thu Feb 21 21:45:32 2008
@@ -221,6 +221,10 @@
}
}
+ public override void visit_parenthesized_expression (ParenthesizedExpression! expr) {
+ expr.accept_children (this);
+ }
+
public override void visit_member_access (MemberAccess! expr) {
if (expr.inner != null) {
visit_possibly_leaked_expression (expr.inner);
Modified: trunk/vala/valaparenthesizedexpression.vala
==============================================================================
--- trunk/vala/valaparenthesizedexpression.vala (original)
+++ trunk/vala/valaparenthesizedexpression.vala Thu Feb 21 21:45:32 2008
@@ -1,6 +1,6 @@
/* valaparenthesizedexpression.vala
*
- * Copyright (C) 2006-2007 JÃrg Billeter
+ * Copyright (C) 2006-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -54,11 +54,13 @@
}
public override void accept (CodeVisitor! visitor) {
- inner.accept (visitor);
-
visitor.visit_parenthesized_expression (this);
}
+ public override void accept_children (CodeVisitor! visitor) {
+ inner.accept (visitor);
+ }
+
public override void replace_expression (Expression! old_node, Expression! new_node) {
if (inner == old_node) {
inner = new_node;
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Thu Feb 21 21:45:32 2008
@@ -1358,6 +1358,10 @@
}
public override void visit_parenthesized_expression (ParenthesizedExpression! expr) {
+ expr.inner.expected_type = expr.expected_type;
+
+ expr.accept_children (this);
+
if (expr.inner.error) {
// ignore inner error
expr.error = true;
@@ -2044,7 +2048,9 @@
}
public override void visit_object_creation_expression (ObjectCreationExpression! expr) {
- expr.accept_children (this);
+ if (expr.member_name != null) {
+ expr.member_name.accept (this);
+ }
Typesymbol type = null;
@@ -2153,7 +2159,27 @@
if (expr.symbol_reference is Method) {
var m = (Method) expr.symbol_reference;
- check_arguments (expr, new MethodType (m), m.get_parameters (), expr.get_argument_list ());
+
+ var args = expr.get_argument_list ();
+ Iterator<Expression> arg_it = args.iterator ();
+ foreach (FormalParameter param in m.get_parameters ()) {
+ if (param.ellipsis) {
+ break;
+ }
+
+ if (arg_it.next ()) {
+ Expression arg = arg_it.get ();
+
+ /* store expected type for callback parameters */
+ arg.expected_type = param.type_reference;
+ }
+ }
+
+ foreach (Expression arg in args) {
+ arg.accept (this);
+ }
+
+ check_arguments (expr, new MethodType (m), m.get_parameters (), args);
expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().size > 0);
} else if (type is Enum) {
@@ -2173,6 +2199,8 @@
}
foreach (MemberInitializer init in expr.get_object_initializer ()) {
+ init.accept (this);
+
init.symbol_reference = symbol_lookup_inherited (expr.type_reference.data_type, init.name);
if (!(init.symbol_reference is Field || init.symbol_reference is Property)) {
expr.error = true;
Modified: trunk/vala/valasymbolresolver.vala
==============================================================================
--- trunk/vala/valasymbolresolver.vala (original)
+++ trunk/vala/valasymbolresolver.vala Thu Feb 21 21:45:32 2008
@@ -378,6 +378,10 @@
e.accept_children (this);
}
+ public override void visit_parenthesized_expression (ParenthesizedExpression! expr) {
+ expr.accept_children (this);
+ }
+
public override void visit_invocation_expression (InvocationExpression! expr) {
expr.accept_children (this);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]