1 /* valapointertype.vala
3 * Copyright (C) 2007-2009 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>
29 public class Vala
.PointerType
: DataType
{
31 * The base type the pointer is referring to.
33 public DataType base_type
{
34 get { return _base_type
; }
37 _base_type
.parent_node
= this
;
41 private DataType _base_type
;
43 public PointerType (DataType base_type
, SourceReference? source_reference
= null) {
44 this
.base_type
= base_type
;
46 this
.source_reference
= source_reference
;
49 public override string to_qualified_string (Scope? scope
) {
50 return base_type
.to_qualified_string (scope
) + "*";
53 public override string?
get_cname () {
54 if (base_type
.data_type
!= null && base_type
.data_type
.is_reference_type ()) {
55 return base_type
.get_cname ();
57 return base_type
.get_cname () + "*";
61 public override DataType
copy () {
62 return new
PointerType (base_type
.copy ());
65 public override bool compatible (DataType target_type
) {
66 if (target_type is PointerType
|| (target_type
.data_type
!= null && target_type
.data_type
.get_attribute ("PointerType") != null)) {
70 /* temporarily ignore type parameters */
71 if (target_type
.type_parameter
!= null) {
75 if (base_type
.is_reference_type_or_type_parameter ()) {
76 // Object* is compatible with Object if Object is a reference type
77 return base_type
.compatible (target_type
);
83 public override Symbol?
get_pointer_member (string member_name
) {
84 Symbol base_symbol
= base_type
.data_type
;
86 if (base_symbol
== null) {
90 return SemanticAnalyzer
.symbol_lookup_inherited (base_symbol
, member_name
);
93 public override Gee
.List
<Symbol
> get_symbols () {
94 return base_type
.get_symbols ();
97 public override string?
get_type_id () {
98 return "G_TYPE_POINTER";
101 public override void accept_children (CodeVisitor visitor
) {
102 base_type
.accept (visitor
);
105 public override void replace_type (DataType old_type
, DataType new_type
) {
106 if (base_type
== old_type
) {
107 base_type
= new_type
;
111 public override bool is_disposable () {
115 public override bool check (SemanticAnalyzer analyzer
) {
116 error
= !base_type
.check (analyzer
);