Fix gtk_text_iter_forward_find_char binding, patch by Nicolas Joseph,
[vala-lang.git] / vala / valabaseaccess.vala
blob1de0c7a7849928383edc627f8717d9e6644bdfda
1 /* valabaseaccess.vala
3 * Copyright (C) 2006-2008 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 Gee;
25 /**
26 * Represents an access to base class members in the source code.
28 public class Vala.BaseAccess : Expression {
29 /**
30 * Creates a new base access expression.
32 * @param source reference to source code
33 * @return newly created base access expression
35 public BaseAccess (SourceReference? source = null) {
36 source_reference = source;
39 public override void accept (CodeVisitor visitor) {
40 visitor.visit_base_access (this);
42 visitor.visit_expression (this);
45 public override string to_string () {
46 return "base";
49 public override bool is_pure () {
50 return true;
53 public override bool check (SemanticAnalyzer analyzer) {
54 if (checked) {
55 return !error;
58 checked = true;
60 if (!analyzer.is_in_instance_method ()) {
61 error = true;
62 Report.error (source_reference, "Base access invalid outside of instance methods");
63 return false;
66 if (analyzer.current_class == null) {
67 if (analyzer.current_struct == null) {
68 error = true;
69 Report.error (source_reference, "Base access invalid outside of class and struct");
70 return false;
71 } else if (analyzer.current_struct.get_base_types ().size != 1) {
72 error = true;
73 Report.error (source_reference, "Base access invalid without base type %d".printf (analyzer.current_struct.get_base_types ().size));
74 return false;
76 Iterator<DataType> base_type_it = analyzer.current_struct.get_base_types ().iterator ();
77 base_type_it.next ();
78 value_type = base_type_it.get ();
79 } else if (analyzer.current_class.base_class == null) {
80 error = true;
81 Report.error (source_reference, "Base access invalid without base class");
82 return false;
83 } else {
84 value_type = new ObjectType (analyzer.current_class.base_class);
87 symbol_reference = value_type.data_type;
89 return !error;