Line data Source code
1 : /* valaunresolvedsymbol.vala
2 : *
3 : * Copyright (C) 2008-2009 Jürg Billeter
4 : *
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.
9 :
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.
14 :
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
18 : *
19 : * Author:
20 : * Jürg Billeter <j@bitron.ch>
21 : */
22 :
23 : /**
24 : * An unresolved reference to a symbol.
25 : */
26 31158914 : public class Vala.UnresolvedSymbol : Symbol {
27 : /**
28 : * The parent of the symbol or null.
29 : */
30 96568602 : public UnresolvedSymbol? inner { get; set; }
31 :
32 : /**
33 : * Qualified access to global symbol.
34 : */
35 21272364 : public bool qualified { get; set; }
36 :
37 93448683 : public UnresolvedSymbol (UnresolvedSymbol? inner, string name, SourceReference? source_reference = null) {
38 31149561 : base (name, source_reference);
39 31149561 : this.inner = inner;
40 : }
41 :
42 15630 : public UnresolvedSymbol.from_expression (MemberAccess ma) {
43 7815 : base (ma.member_name, ma.source_reference);
44 7815 : if (ma.inner is MemberAccess) {
45 0 : inner = new UnresolvedSymbol.from_expression ((MemberAccess) ma.inner);
46 7815 : } else if (ma.inner != null) {
47 0 : Report.error (ma.source_reference, "Type reference must be simple name or member access expression");
48 : }
49 : }
50 :
51 276 : public override string to_string () {
52 276 : if (inner == null) {
53 440 : return name;
54 : } else {
55 56 : return "%s.%s".printf (inner.to_string (), name);
56 : }
57 : }
58 :
59 1446024 : public UnresolvedSymbol copy () {
60 1446024 : return new UnresolvedSymbol (inner, name, source_reference);
61 : }
62 : }
63 :
|