Fix gtk_text_iter_forward_find_char binding, patch by Nicolas Joseph,
[vala-lang.git] / vala / valaunresolvedtype.vala
bloba651c47d496346d86be2ae560afede68ff247cb8
1 /* valaunresolvedtype.vala
3 * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini
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>
21 * Raffaele Sandrini <raffaele@sandrini.ch>
24 using GLib;
25 using Gee;
27 /**
28 * An unresolved reference to a data type.
30 public class Vala.UnresolvedType : DataType {
31 /**
32 * The unresolved reference to a type symbol.
34 public UnresolvedSymbol unresolved_symbol { get; set; }
36 public UnresolvedType () {
39 /**
40 * Creates a new type reference.
42 * @param symbol unresolved type symbol
43 * @param source reference to source code
44 * @return newly created type reference
46 public UnresolvedType.from_symbol (UnresolvedSymbol symbol, SourceReference? source = null) {
47 this.unresolved_symbol = symbol;
48 source_reference = source;
51 /**
52 * Creates a new type reference from a code expression.
54 * @param expr member access expression
55 * @param source reference to source code
56 * @return newly created type reference
58 public static UnresolvedType? new_from_expression (Expression expr) {
59 if (expr is MemberAccess) {
60 UnresolvedType type_ref = null;
62 MemberAccess ma = (MemberAccess) expr;
63 if (ma.inner != null) {
64 if (ma.inner is MemberAccess) {
65 var simple = (MemberAccess) ma.inner;
66 type_ref = new UnresolvedType.from_symbol (new UnresolvedSymbol (new UnresolvedSymbol (null, simple.member_name, ma.source_reference), ma.member_name, ma.source_reference), ma.source_reference);
68 } else {
69 type_ref = new UnresolvedType.from_symbol (new UnresolvedSymbol (null, ma.member_name, ma.source_reference), ma.source_reference);
72 if (type_ref != null) {
73 type_ref.value_owned = true;
75 var type_args = ma.get_type_arguments ();
76 foreach (DataType arg in type_args) {
77 type_ref.add_type_argument (arg);
80 return type_ref;
84 Report.error (expr.source_reference, "Type reference must be simple name or member access expression");
85 return null;
88 public override DataType copy () {
89 var result = new UnresolvedType ();
90 result.source_reference = source_reference;
91 result.value_owned = value_owned;
92 result.nullable = nullable;
93 result.is_dynamic = is_dynamic;
94 result.unresolved_symbol = unresolved_symbol.copy ();
96 foreach (DataType arg in get_type_arguments ()) {
97 result.add_type_argument (arg.copy ());
100 return result;
103 public override string to_qualified_string (Scope? scope) {
104 return unresolved_symbol.to_string ();