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>
28 public class Vala
.PointerType
: DataType
{
30 * The base type the pointer is referring to.
32 public DataType base_type
{
33 get { return _base_type
; }
36 _base_type
.parent_node
= this
;
40 private DataType _base_type
;
42 public PointerType (DataType base_type
, SourceReference? source_reference
= null) {
43 this
.base_type
= base_type
;
45 this
.source_reference
= source_reference
;
48 public override string to_qualified_string (Scope? scope
) {
49 return base_type
.to_qualified_string (scope
) + "*";
52 public override string?
get_cname () {
53 if (base_type
.data_type
!= null && base_type
.data_type
.is_reference_type ()) {
54 return base_type
.get_cname ();
56 return base_type
.get_cname () + "*";
60 public override DataType
copy () {
61 return new
PointerType (base_type
.copy ());
64 public override bool compatible (DataType target_type
) {
65 if (target_type is PointerType
|| (target_type
.data_type
!= null && target_type
.data_type
.get_attribute ("PointerType") != null)) {
69 /* temporarily ignore type parameters */
70 if (target_type
.type_parameter
!= null) {
74 if (base_type
.is_reference_type_or_type_parameter ()) {
75 // Object* is compatible with Object if Object is a reference type
76 return base_type
.compatible (target_type
);
82 public override Symbol?
get_pointer_member (string member_name
) {
83 Symbol base_symbol
= base_type
.data_type
;
85 if (base_symbol
== null) {
89 return SemanticAnalyzer
.symbol_lookup_inherited (base_symbol
, member_name
);
92 public override List
<Symbol
> get_symbols () {
93 return base_type
.get_symbols ();
96 public override string?
get_type_id () {
97 return "G_TYPE_POINTER";
100 public override void accept_children (CodeVisitor visitor
) {
101 base_type
.accept (visitor
);
104 public override void replace_type (DataType old_type
, DataType new_type
) {
105 if (base_type
== old_type
) {
106 base_type
= new_type
;
110 public override bool is_disposable () {
114 public override bool check (SemanticAnalyzer analyzer
) {
115 error
= !base_type
.check (analyzer
);