3 * Copyright (C) 2006-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
20 * Jürg Billeter <j@bitron.ch>
25 * Represents an access to base class members in the source code.
27 public class Vala
.BaseAccess
: Expression
{
29 * Creates a new base access expression.
31 * @param source reference to source code
32 * @return newly created base access expression
34 public BaseAccess (SourceReference? source
= null) {
35 source_reference
= source
;
38 public override void accept (CodeVisitor visitor
) {
39 visitor
.visit_base_access (this
);
41 visitor
.visit_expression (this
);
44 public override string to_string () {
48 public override bool is_pure () {
52 public override bool check (CodeContext context
) {
59 if (!context
.analyzer
.is_in_instance_method ()) {
61 Report
.error (source_reference
, "Base access invalid outside of instance methods");
65 if (context
.analyzer
.current_class
== null) {
66 if (context
.analyzer
.current_struct
== null) {
68 Report
.error (source_reference
, "Base access invalid outside of class and struct");
70 } else if (context
.analyzer
.current_struct
.base_type
== null) {
72 Report
.error (source_reference
, "Base access invalid without base type");
75 value_type
= context
.analyzer
.current_struct
.base_type
;
76 } else if (context
.analyzer
.current_class
.base_class
== null) {
78 Report
.error (source_reference
, "Base access invalid without base class");
81 foreach (var base_type
in context
.analyzer
.current_class
.get_base_types ()) {
82 if (base_type
.data_type is Class
) {
83 value_type
= base_type
.copy ();
84 value_type
.value_owned
= false;
89 symbol_reference
= value_type
.data_type
;
94 public override void emit (CodeGenerator codegen
) {
95 codegen
.visit_base_access (this
);
97 codegen
.visit_expression (this
);