1
// This file is part of the AspectC++ compiler 'ac++'.
2
// Copyright (C) 1999-2003 The 'ac++' developers (see aspectc.org)
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License as
6
// published by the Free Software Foundation; either version 2 of
7
// the License, or (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public
15
// License along with this program; if not, write to the Free
16
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19
#ifndef __MatchTypeInfos_h__
20
#define __MatchTypeInfos_h__
28
#include "MatchType.h"
29
#include "MatchName.h"
31
// functions without result type (conversion operators) have this type
32
class MTUndefined : public MatchType {
36
virtual TID type () const;
38
virtual MTUndefined *clone () const;
39
virtual void print (ostream &, const char* = 0, bool = false) const;
40
virtual bool matches (const MatchType &type) const;
43
// commonalities of all types made by declarators
44
class MTDeclarator : public MatchType {
49
virtual TID type () const;
50
// only derived types may construct/destruct a declarator type
51
MTDeclarator (MatchType *b) : _base (b) {}
52
MTDeclarator (const MTDeclarator ©) { *this = copy; }
53
MTDeclarator &operator = (const MTDeclarator ©) {
54
_base = copy._base->clone ();
57
~MTDeclarator () { delete _base; }
60
// set and get the base type
61
virtual MatchType *base () const { return _base; }
62
// adjust the argument types according to �8.3.5.2 and �8.3.5.3 of ISO C++
63
virtual void adjust_args (bool &f, bool &a, bool &q, bool &v) {
64
_base->adjust_args (f, a, q, v);
69
class MTPointer : public MTDeclarator, public MTQual {
73
virtual TID type () const;
76
MTPointer (MatchType *b = 0) : MTDeclarator (b) {}
77
// print the string representation of this type
78
virtual MTPointer *clone () const;
79
virtual void print (ostream &, const char* = 0, bool = false) const;
80
virtual void mangle (ostream &) const;
81
virtual bool matches (const MatchType &type) const;
82
virtual MTQual *qualified () { return this; }
83
virtual const MTQual *qualified () const { return this; }
86
// member pointer types
87
class MTMembPointer : public MTPointer {
89
mutable MatchName _memb_ptr_scope;
92
virtual TID type () const;
95
MTMembPointer (const MatchName &mps, MatchType *b = 0) :
96
MTPointer (b), _memb_ptr_scope (mps) {}
97
virtual MTMembPointer *clone () const;
98
// print the string representation of this type
99
virtual void print (ostream &, const char* = 0, bool = false) const;
100
virtual void mangle (ostream &) const;
101
virtual bool matches (const MatchType &type) const;
106
class MTReference : public MTDeclarator {
110
virtual TID type () const;
113
MTReference (MatchType *b = 0) : MTDeclarator (b) {}
114
virtual MTReference *clone () const;
115
// print the string representation of this type
116
virtual void print (ostream &, const char* = 0, bool = false) const;
117
virtual void mangle (ostream &) const;
118
virtual bool matches (const MatchType &type) const;
119
virtual bool is_reference () const { return true; }
123
class MTFunction : public MTDeclarator, public MTQual {
125
vector<MatchTypeRef> _arg_types;
129
virtual TID type () const;
132
MTFunction (MatchType *b = 0) : MTDeclarator (b), _varargs (false) {}
133
MTFunction (const vector<MatchTypeRef> &args, bool va, MatchType *b) :
134
MTDeclarator (b), _arg_types (args), _varargs (va) {}
135
// virtual ~MTFunction ();
136
virtual MTFunction *clone () const;
137
// print the string representation of this type
138
virtual void print (ostream &, const char* = 0, bool = false) const;
139
// print the 'mangled' string representation of this type
140
virtual void mangle (ostream &os) const;
141
virtual bool is_function () const { return true; }
142
void varargs () { _varargs = true; }
143
bool varargs () const { return _varargs; }
144
int args () const { return (int)_arg_types.size (); }
145
void arg (MatchTypeRef a) { _arg_types.push_back (a); }
146
const MatchTypeRef &arg (int index) const { return _arg_types[index]; }
147
// perform a type match
148
virtual bool matches (const MatchType &type) const;
149
// adjust the argument types according to �8.3.5.2 and �8.3.5.3 of ISO C++
150
virtual void adjust_args (bool &f, bool &a, bool &q, bool &v);
151
virtual MTQual *qualified () { return this; }
152
virtual const MTQual *qualified () const { return this; }
156
class MTArray : public MTDeclarator {
162
virtual TID type () const;
165
MTArray (MatchType *b) : MTDeclarator (b), _dim (0uL),
167
MTArray (unsigned long dim, MatchType *b) : MTDeclarator (b), _dim (dim),
169
virtual MTArray *clone () const;
170
// print the string representation of this type
171
virtual void print (ostream &, const char* = 0, bool = false) const;
172
// print the 'mangled' string representation of this type
173
virtual void mangle (ostream &os) const;
174
void dimension (unsigned long d) { _dim = d; }
175
unsigned long dimension () const { return _dim; }
176
void any_size () { _any_size = true; }
177
bool any_size () const { return _any_size; }
178
virtual bool matches (const MatchType &type) const;
179
virtual bool is_array () const { return true; }
182
// user-defined names types
183
class MTNamed : public MatchType, public MTQual {
184
mutable MatchName _name;
187
virtual TID type () const;
189
MTNamed (const MatchName &mn) : _name (mn) {}
190
virtual MTNamed *clone () const;
191
// print the string representation of this type
192
virtual void print (ostream &, const char* = 0, bool = false) const;
193
// print the 'mangled' string representation of this type
194
virtual void mangle (ostream &os) const;
195
const MatchName &name () const { return _name; }
196
// perform a type match
197
virtual bool matches (const MatchType &type) const;
198
virtual MTQual *qualified () { return this; }
199
virtual const MTQual *qualified () const { return this; }
200
// check whether this type mattern can only match a single name type
201
virtual bool is_trivial_match () const { return _name.is_trivial(); }
204
//! commonalities of all primitive types
205
class MTPrim : public MatchType, public MTQual {
207
//! print the string representation of this type
208
virtual void print (ostream &, const char* = 0, bool = false) const;
209
virtual MTQual *qualified () { return this; }
210
virtual const MTQual *qualified () const { return this; }
211
virtual bool is_primitive () const { return true; }
212
// print the 'mangled' string representation of this type
213
virtual void mangle (ostream &os) const;
216
// type <any> (used for matching types>
217
class MTAny : public MTPrim {
220
virtual TID type () const;
222
virtual MTAny *clone () const;
223
// perform a type match
224
virtual bool matches (const MatchType &type) const;
225
virtual void mangle (ostream &os) const;
229
class MTBool : public MTPrim {
232
virtual MTBool *clone () const;
233
virtual TID type () const;
234
virtual bool matches (const MatchType &type) const;
235
virtual void mangle (ostream &os) const;
239
class MTSignedChar : public MTPrim {
242
virtual MTSignedChar *clone () const;
243
virtual TID type () const;
244
virtual bool matches (const MatchType &type) const;
245
virtual void mangle (ostream &os) const;
249
class MTUnsignedChar : public MTPrim {
252
virtual MTUnsignedChar *clone () const;
253
virtual TID type () const;
254
virtual bool matches (const MatchType &type) const;
255
virtual void mangle (ostream &os) const;
259
class MTChar : public MTPrim {
262
virtual MTChar *clone () const;
263
virtual TID type () const;
264
virtual bool matches (const MatchType &type) const;
265
virtual void mangle (ostream &os) const;
268
// type unsigned short
269
class MTUnsignedShort : public MTPrim {
272
virtual MTUnsignedShort *clone () const;
273
virtual TID type () const;
274
virtual bool matches (const MatchType &type) const;
275
virtual void mangle (ostream &os) const;
279
class MTShort : public MTPrim {
282
virtual MTShort *clone () const;
283
virtual TID type () const;
284
virtual bool matches (const MatchType &type) const;
285
virtual void mangle (ostream &os) const;
289
class MTUnsignedInt : public MTPrim {
292
virtual MTUnsignedInt *clone () const;
293
virtual TID type () const;
294
virtual bool matches (const MatchType &type) const;
295
virtual void mangle (ostream &os) const;
299
class MTInt : public MTPrim {
302
virtual MTInt *clone () const;
303
virtual TID type () const;
304
virtual bool matches (const MatchType &type) const;
305
virtual void mangle (ostream &os) const;
309
class MTWCharT : public MTPrim {
312
virtual MTWCharT *clone () const;
313
virtual TID type () const;
314
virtual bool matches (const MatchType &type) const;
315
virtual void mangle (ostream &os) const;
318
// type unsigned long
319
class MTUnsignedLong : public MTPrim {
322
virtual MTUnsignedLong *clone () const;
323
virtual TID type () const;
324
virtual bool matches (const MatchType &type) const;
325
virtual void mangle (ostream &os) const;
329
class MTLong : public MTPrim {
332
virtual MTLong *clone () const;
333
virtual TID type () const;
334
virtual bool matches (const MatchType &type) const;
335
virtual void mangle (ostream &os) const;
338
// type unsigned long long
339
class MTUnsignedLongLong : public MTPrim {
342
virtual MTUnsignedLongLong *clone () const;
343
virtual TID type () const;
344
virtual bool matches (const MatchType &type) const;
345
virtual void mangle (ostream &os) const;
349
class MTLongLong : public MTPrim {
352
virtual MTLongLong *clone () const;
353
virtual TID type () const;
354
virtual bool matches (const MatchType &type) const;
355
virtual void mangle (ostream &os) const;
359
class MTFloat : public MTPrim {
362
virtual MTFloat *clone () const;
363
virtual TID type () const;
364
virtual bool matches (const MatchType &type) const;
365
virtual void mangle (ostream &os) const;
369
class MTDouble : public MTPrim {
372
virtual MTDouble *clone () const;
373
virtual TID type () const;
374
virtual bool matches (const MatchType &type) const;
375
virtual void mangle (ostream &os) const;
379
class MTLongDouble : public MTPrim {
382
virtual MTLongDouble *clone () const;
383
virtual TID type () const;
384
virtual bool matches (const MatchType &type) const;
385
virtual void mangle (ostream &os) const;
389
class MTVoid : public MTPrim {
392
virtual MTVoid *clone () const;
393
virtual TID type () const;
394
virtual bool matches (const MatchType &type) const;
395
virtual bool is_void () const { return true; }
396
virtual void mangle (ostream &os) const;
399
#endif // __MatchTypeInfos_h__