1 /* valamemberinitializer.vala
3 * Copyright (C) 2007-2010 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.1 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
20 * Jürg Billeter <j@bitron.ch>
26 * Represents a member initializer, i.e. an element of an object initializer, in
29 public class Vala
.MemberInitializer
: CodeNode
{
33 public string name
{ get; set; }
36 * Initializer expression.
38 public Expression initializer
{
39 get { return _initializer
; }
42 _initializer
.parent_node
= this
;
47 * The symbol this expression refers to.
49 public weak Symbol symbol_reference
{ get; set; }
51 Expression _initializer
;
54 * Creates a new member initializer.
56 * @param name member name
57 * @param initializer initializer expression
58 * @param source_reference reference to source code
59 * @return newly created member initializer
61 public MemberInitializer (string name
, Expression initializer
, SourceReference? source_reference
= null) {
62 this
.initializer
= initializer
;
63 this
.source_reference
= source_reference
;
67 public override void accept (CodeVisitor visitor
) {
68 initializer
.accept (visitor
);
71 public override bool check (CodeContext context
) {
72 return initializer
.check (context
);
75 public override void emit (CodeGenerator codegen
) {
76 initializer
.emit (codegen
);
79 public override void replace_expression (Expression old_node
, Expression new_node
) {
80 if (initializer
== old_node
) {
81 initializer
= new_node
;