remove obsolete ref modifier and callback keyword
[vala-lang.git] / vala / valalambdaexpression.vala
blob7d8241ec9ea223a8ec95d313c2879bbae42947e6
1 /* valalambdaexpression.vala
3 * Copyright (C) 2006-2007 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using GLib;
25 /**
26 * Represents a lambda expression in the source code. Lambda expressions are
27 * anonymous methods with implicitly typed parameters.
29 public class Vala.LambdaExpression : Expression {
30 /**
31 * The expression body of this lambda expression. Only one of
32 * expression_body or statement_body may be set.
34 public Expression expression_body { get; set; }
36 /**
37 * The statement body of this lambda expression. Only one of
38 * expression_body or statement_body may be set.
40 public Block statement_body { get; set; }
42 /**
43 * The generated method.
45 public Method method { get; set; }
47 private List<string> parameters;
49 /**
50 * Creates a new lambda expression.
52 * @param body expression body
53 * @param source reference to source code
54 * @return newly created lambda expression
56 public LambdaExpression (Expression! body, SourceReference source) {
57 expression_body = body;
58 source_reference = source;
61 /**
62 * Creates a new lambda expression with statement body.
64 * @param body statement body
65 * @param source reference to source code
66 * @return newly created lambda expression
68 public LambdaExpression.with_statement_body (Block! body, SourceReference source) {
69 statement_body = body;
70 source_reference = source;
73 /**
74 * Appends implicitly typed parameter.
76 * @param param parameter name
78 public void add_parameter (string! param) {
79 parameters.append (param);
82 /**
83 * Returns copy of parameter list.
85 * @return parameter list
87 public List<weak string> get_parameters () {
88 return parameters.copy ();
91 public override void accept (CodeVisitor! visitor) {
92 visitor.visit_begin_lambda_expression (this);
94 if (method == null) {
95 if (expression_body != null) {
96 expression_body.accept (visitor);
97 visitor.visit_end_full_expression (expression_body);
98 } else if (statement_body != null) {
99 statement_body.accept (visitor);
103 visitor.visit_end_lambda_expression (this);
105 if (method != null) {
106 method.accept (visitor);