1 /* valapointerindirection.vala
3 * Copyright (C) 2007-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 a pointer indirection in the source code, e.g. `*pointer'.
28 public class Vala
.PointerIndirection
: Expression
{
30 * The pointer to dereference.
32 public Expression inner
{
38 _inner
.parent_node
= this
;
42 private Expression _inner
;
45 * Creates a new pointer indirection.
47 * @param inner pointer to be dereferenced
48 * @return newly created pointer indirection
50 public PointerIndirection (Expression inner
, SourceReference? source_reference
= null) {
51 this
.source_reference
= source_reference
;
55 public override void accept (CodeVisitor visitor
) {
56 inner
.accept (visitor
);
58 visitor
.visit_pointer_indirection (this
);
60 visitor
.visit_expression (this
);
63 public override void replace_expression (Expression old_node
, Expression new_node
) {
64 if (inner
== old_node
) {
69 public override bool is_pure () {
70 return inner
.is_pure ();
73 public override bool check (SemanticAnalyzer analyzer
) {
80 if (!inner
.check (analyzer
)) {
83 if (inner
.value_type
== null) {
85 Report
.error (source_reference
, "internal error: unknown type of inner expression");
88 if (inner
.value_type is PointerType
) {
89 var pointer_type
= (PointerType
) inner
.value_type
;
90 if (pointer_type
.base_type is ReferenceType
) {
92 Report
.error (source_reference
, "Pointer indirection not supported for this expression");
95 value_type
= pointer_type
.base_type
;
98 Report
.error (source_reference
, "Pointer indirection not supported for this expression");
105 public override void get_defined_variables (Collection
<LocalVariable
> collection
) {
106 inner
.get_defined_variables (collection
);
109 public override void get_used_variables (Collection
<LocalVariable
> collection
) {
110 inner
.get_used_variables (collection
);