girparser: Guess virtual method wrapper variant when possible
[vala-lang.git] / vala / valamemberinitializer.vala
blobc5e5d8255b755ecc8063b4f0b9e5cff8d6dd1882
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
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using GLib;
25 /**
26 * Represents a member initializer, i.e. an element of an object initializer, in
27 * the source code.
29 public class Vala.MemberInitializer : CodeNode {
30 /**
31 * Member name.
33 public string name { get; set; }
35 /**
36 * Initializer expression.
38 public Expression initializer {
39 get { return _initializer; }
40 set {
41 _initializer = value;
42 _initializer.parent_node = this;
46 /**
47 * The symbol this expression refers to.
49 public weak Symbol symbol_reference { get; set; }
51 Expression _initializer;
53 /**
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;
64 this.name = name;
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;