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
20 * Jürg Billeter <j@bitron.ch>
26 * Represents an access to base class members in the source code.
28 public class Vala
.BaseAccess
: Expression
{
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 () {
49 public override bool is_pure () {
53 public override bool check (SemanticAnalyzer analyzer
) {
60 if (!analyzer
.is_in_instance_method ()) {
62 Report
.error (source_reference
, "Base access invalid outside of instance methods");
66 if (analyzer
.current_class
== null) {
67 if (analyzer
.current_struct
== null) {
69 Report
.error (source_reference
, "Base access invalid outside of class and struct");
71 } else if (analyzer
.current_struct
.get_base_types ().size
!= 1) {
73 Report
.error (source_reference
, "Base access invalid without base type %d".printf (analyzer
.current_struct
.get_base_types ().size
));
76 Iterator
<DataType
> base_type_it
= analyzer
.current_struct
.get_base_types ().iterator ();
78 value_type
= base_type_it
.get ();
79 } else if (analyzer
.current_class
.base_class
== null) {
81 Report
.error (source_reference
, "Base access invalid without base class");
84 value_type
= new
ObjectType (analyzer
.current_class
.base_class
);
87 symbol_reference
= value_type
.data_type
;