remove obsolete ref modifier and callback keyword
[vala-lang.git] / vala / valalocalvariabledeclaration.vala
blob1bcbf328813e8aa10976d7a0ed3289fd1ea08887
1 /* valalocalvariabledeclaration.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 local variable declaration in the source code.
28 public class Vala.LocalVariableDeclaration : CodeNode {
29 /**
30 * The type of the local variable.
32 public TypeReference type_reference { get; set; }
34 private List<VariableDeclarator> variable_declarators;
36 /**
37 * Creates a new local variable declaration.
39 * @param type type of the variable
40 * @param source reference to source code
41 * @return newly created local variable declaration
43 public LocalVariableDeclaration (TypeReference type, SourceReference source) {
44 type_reference = type;
45 source_reference = source;
48 /**
49 * Creates a new implicitly typed local variable declaration. The type
50 * of the variable is inferred from the expression used to initialize
51 * the variable.
53 * @param source reference to source code
54 * @return newly created local variable declaration
56 public LocalVariableDeclaration.var_type (SourceReference source) {
57 source_reference = source;
60 /**
61 * Add the specified variable declarator to this local variable
62 * declaration.
64 * @param declarator a variable declarator
66 public void add_declarator (VariableDeclarator! declarator) {
67 variable_declarators.append (declarator);
70 /**
71 * Returns a copy of the list of variable declarators.
73 * @return variable declarator list
75 public List<weak VariableDeclarator> get_variable_declarators () {
76 return variable_declarators.copy ();
79 public override void accept (CodeVisitor! visitor) {
80 if (type_reference != null) {
81 type_reference.accept (visitor);
84 foreach (VariableDeclarator decl in variable_declarators) {
85 decl.accept (visitor);
88 visitor.visit_local_variable_declaration (this);