source: src/SynTree/Type.h @ 8bafacc

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 8bafacc was ea6332d, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Big header cleaning pass - commit 3

  • Property mode set to 100644
File size: 23.7 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// Type.h --
8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By : Andrew Beach
12// Last Modified On : Wed Aug  9 14:25:00 2017
13// Update Count     : 152
14//
15
16#pragma once
17
18#include <strings.h>         // for ffs
19#include <cassert>           // for assert, assertf
20#include <list>              // for list, _List_iterator
21#include <ostream>           // for ostream, operator<<, basic_ostream
22#include <string>            // for string
23
24#include "BaseSyntaxNode.h"  // for BaseSyntaxNode
25#include "Common/utility.h"  // for operator+
26#include "Mutator.h"         // for Mutator
27#include "SynTree.h"         // for AST nodes
28#include "Visitor.h"         // for Visitor
29
30class Type : public BaseSyntaxNode {
31  public:
32        // Simulate inheritance because union does not allow it.
33        // Bug in g++-4.9 prevents static field in union
34        //static const char * Names[];
35        #define BFCommon( BFType, N ) \
36                bool operator[]( unsigned int i ) const { return val & (1 << i); } \
37                bool any() const { return val != 0; } \
38                void reset() { val = 0; } \
39                int ffs() { return ::ffs( val ) - 1; } \
40                BFType operator&=( BFType other ) { \
41                        val &= other.val; return *this; \
42                } \
43                BFType operator&( BFType other ) const { \
44                        BFType q = other; \
45                        q &= *this; \
46                        return q; \
47                } \
48                BFType operator|=( BFType other ) { \
49                        val |= other.val; return *this; \
50                } \
51                BFType operator|( BFType other ) const { \
52                        BFType q = other; \
53                        q |= *this; \
54                        return q; \
55                } \
56                BFType operator-=( BFType other ) { \
57                        val &= ~other.val; return *this; \
58                } \
59                void print( std::ostream & os ) const { \
60                        if ( (*this).any() ) { \
61                                for ( unsigned int i = 0; i < N; i += 1 ) { \
62                                        if ( (*this)[i] ) { \
63                                                os << BFType##Names[i] << ' '; \
64                                        } \
65                                } \
66                        } \
67                }
68
69        // enum must remain in the same order as the corresponding bit fields.
70
71        enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 };
72        static const char * FuncSpecifiersNames[];
73        union FuncSpecifiers {
74                unsigned int val;
75                struct {
76                        bool is_inline : 1;
77                        bool is_noreturn : 1;
78                        bool is_fortran : 1;
79                };
80                FuncSpecifiers() : val( 0 ) {}
81                FuncSpecifiers( unsigned int val ) : val( val ) {}
82                // equality (==, !=) works implicitly on first field "val", relational operations are undefined.
83                BFCommon( FuncSpecifiers, NumFuncSpecifier )
84        }; // FuncSpecifiers
85
86        enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 };
87        static const char * StorageClassesNames[];
88        union StorageClasses {
89                unsigned int val;
90                struct {
91                        bool is_extern : 1;
92                        bool is_static : 1;
93                        bool is_auto : 1;
94                        bool is_register : 1;
95                        bool is_threadlocal : 1;
96                };
97
98                StorageClasses() : val( 0 ) {}
99                StorageClasses( unsigned int val ) : val( val ) {}
100                // equality (==, !=) works implicitly on first field "val", relational operations are undefined.
101                BFCommon( StorageClasses, NumStorageClass )
102        }; // StorageClasses
103
104        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 };
105        static const char * QualifiersNames[];
106        union Qualifiers {
107                enum { Mask = ~(Restrict | Lvalue) };
108                unsigned int val;
109                struct {
110                        bool is_const : 1;
111                        bool is_restrict : 1;
112                        bool is_volatile : 1;
113                        bool is_lvalue : 1;
114                        bool is_mutex : 1;
115                        bool is_atomic : 1;
116                };
117
118                Qualifiers() : val( 0 ) {}
119                Qualifiers( unsigned int val ) : val( val ) {}
120                // Complex comparisons provide implicit qualifier downcasting, e.g., T downcast to const T.
121                bool operator==( Qualifiers other ) const { return (val & Mask) == (other.val & Mask); }
122                bool operator!=( Qualifiers other ) const { return (val & Mask) != (other.val & Mask); }
123                bool operator<=( Qualifiers other ) const {
124                        return is_const    <= other.is_const        //Any non-const converts to const without cost
125                                        && is_volatile <= other.is_volatile     //Any non-volatile converts to volatile without cost
126                                        && is_mutex    >= other.is_mutex        //Any mutex converts to non-mutex without cost
127                                        && is_atomic   == other.is_atomic;      //No conversion from atomic to non atomic is free
128                }
129                bool operator<( Qualifiers other ) const { return *this != other && *this <= other; }
130                bool operator>=( Qualifiers other ) const { return ! (*this < other); }
131                bool operator>( Qualifiers other ) const { return *this != other && *this >= other; }
132                BFCommon( Qualifiers, NumTypeQualifier )
133        }; // Qualifiers
134
135        typedef std::list<TypeDecl *> ForallList;
136
137        Qualifiers tq;
138        ForallList forall;
139        std::list< Attribute * > attributes;
140
141        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
142        Type( const Type & other );
143        virtual ~Type();
144
145        Qualifiers & get_qualifiers() { return tq; }
146        bool get_const() { return tq.is_const; }
147        bool get_volatile() { return tq.is_volatile; }
148        bool get_restrict() { return tq.is_restrict; }
149        bool get_lvalue() { return tq.is_lvalue; }
150        bool get_mutex() { return tq.is_mutex; }
151        bool get_atomic() { return tq.is_atomic; }
152        void set_const( bool newValue ) { tq.is_const = newValue; }
153        void set_volatile( bool newValue ) { tq.is_volatile = newValue; }
154        void set_restrict( bool newValue ) { tq.is_restrict = newValue; }
155        void set_lvalue( bool newValue ) { tq.is_lvalue = newValue; }
156        void set_mutex( bool newValue ) { tq.is_mutex = newValue; }
157        void set_atomic( bool newValue ) { tq.is_atomic = newValue; }
158
159        ForallList& get_forall() { return forall; }
160
161        std::list< Attribute * >& get_attributes() { return attributes; }
162        const std::list< Attribute * >& get_attributes() const { return attributes; }
163
164        /// How many elemental types are represented by this type
165        virtual unsigned size() const { return 1; };
166        virtual bool isVoid() const { return size() == 0; }
167        virtual Type * getComponent( unsigned i ) { assertf( size() == 1 && i == 0, "Type::getComponent was called with size %d and index %d\n", size(), i ); return this; }
168
169        /// return type without outer pointers and arrays
170        Type *stripDeclarator();
171
172        virtual bool isComplete() const { return true; }
173
174        virtual Type *clone() const = 0;
175        virtual void accept( Visitor & v ) = 0;
176        virtual Type *acceptMutator( Mutator & m ) = 0;
177        virtual void print( std::ostream & os, int indent = 0 ) const;
178};
179
180extern const Type::FuncSpecifiers noFuncSpecifiers;
181extern const Type::StorageClasses noStorageClasses;
182extern const Type::Qualifiers noQualifiers;                     // no qualifiers on constants
183
184class VoidType : public Type {
185  public:
186        VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
187
188        virtual unsigned size() const { return 0; };
189        virtual bool isComplete() const { return false; }
190
191        virtual VoidType *clone() const { return new VoidType( *this ); }
192        virtual void accept( Visitor & v ) { v.visit( this ); }
193        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
194        virtual void print( std::ostream & os, int indent = 0 ) const;
195};
196
197class BasicType : public Type {
198  public:
199        enum Kind {
200                Bool,
201                Char,
202                SignedChar,
203                UnsignedChar,
204                ShortSignedInt,
205                ShortUnsignedInt,
206                SignedInt,
207                UnsignedInt,
208                LongSignedInt,
209                LongUnsignedInt,
210                LongLongSignedInt,
211                LongLongUnsignedInt,
212                Float,
213                Double,
214                LongDouble,
215                FloatComplex,
216                DoubleComplex,
217                LongDoubleComplex,
218                FloatImaginary,
219                DoubleImaginary,
220                LongDoubleImaginary,
221                NUMBER_OF_BASIC_TYPES
222        } kind;
223
224        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
225
226        BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
227
228        Kind get_kind() { return kind; }
229        void set_kind( Kind newValue ) { kind = newValue; }
230
231        virtual BasicType *clone() const { return new BasicType( *this ); }
232        virtual void accept( Visitor & v ) { v.visit( this ); }
233        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
234        virtual void print( std::ostream & os, int indent = 0 ) const;
235
236        bool isInteger() const;
237};
238
239class PointerType : public Type {
240  public:
241        Type *base;
242
243        // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
244        Expression *dimension;
245        bool isVarLen;
246        bool isStatic;
247
248        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
249        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
250        PointerType( const PointerType& );
251        virtual ~PointerType();
252
253        Type *get_base() { return base; }
254        void set_base( Type *newValue ) { base = newValue; }
255        Expression *get_dimension() { return dimension; }
256        void set_dimension( Expression *newValue ) { dimension = newValue; }
257        bool get_isVarLen() { return isVarLen; }
258        void set_isVarLen( bool newValue ) { isVarLen = newValue; }
259        bool get_isStatic() { return isStatic; }
260        void set_isStatic( bool newValue ) { isStatic = newValue; }
261
262        bool is_array() const { return isStatic || isVarLen || dimension; }
263
264        virtual PointerType *clone() const { return new PointerType( *this ); }
265        virtual void accept( Visitor & v ) { v.visit( this ); }
266        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
267        virtual void print( std::ostream & os, int indent = 0 ) const;
268};
269
270class ArrayType : public Type {
271  public:
272        Type *base;
273        Expression *dimension;
274        bool isVarLen;
275        bool isStatic;
276
277        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
278        ArrayType( const ArrayType& );
279        virtual ~ArrayType();
280
281        Type *get_base() { return base; }
282        void set_base( Type *newValue ) { base = newValue; }
283        Expression *get_dimension() { return dimension; }
284        void set_dimension( Expression *newValue ) { dimension = newValue; }
285        bool get_isVarLen() { return isVarLen; }
286        void set_isVarLen( bool newValue ) { isVarLen = newValue; }
287        bool get_isStatic() { return isStatic; }
288        void set_isStatic( bool newValue ) { isStatic = newValue; }
289
290        virtual bool isComplete() const { return ! isVarLen; }
291
292        virtual ArrayType *clone() const { return new ArrayType( *this ); }
293        virtual void accept( Visitor & v ) { v.visit( this ); }
294        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
295        virtual void print( std::ostream & os, int indent = 0 ) const;
296};
297
298class FunctionType : public Type {
299  public:
300        std::list<DeclarationWithType*> returnVals;
301        std::list<DeclarationWithType*> parameters;
302
303        // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
304        // This could be because of
305        // - an ellipsis in a prototype declaration
306        // - an unprototyped declaration
307        bool isVarArgs;
308
309        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
310        FunctionType( const FunctionType& );
311        virtual ~FunctionType();
312
313        std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
314        std::list<DeclarationWithType*> & get_parameters() { return parameters; }
315        bool get_isVarArgs() const { return isVarArgs; }
316        void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
317        bool isTtype() const;
318
319        virtual FunctionType *clone() const { return new FunctionType( *this ); }
320        virtual void accept( Visitor & v ) { v.visit( this ); }
321        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
322        virtual void print( std::ostream & os, int indent = 0 ) const;
323};
324
325class ReferenceToType : public Type {
326  public:
327        std::list< Expression* > parameters;
328        std::string name;
329        bool hoistType;
330
331        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
332        ReferenceToType( const ReferenceToType & other );
333        virtual ~ReferenceToType();
334
335        const std::string & get_name() const { return name; }
336        void set_name( std::string newValue ) { name = newValue; }
337        std::list< Expression* >& get_parameters() { return parameters; }
338        bool get_hoistType() const { return hoistType; }
339        void set_hoistType( bool newValue ) { hoistType = newValue; }
340
341        virtual ReferenceToType *clone() const = 0;
342        virtual void accept( Visitor & v ) = 0;
343        virtual Type *acceptMutator( Mutator & m ) = 0;
344        virtual void print( std::ostream & os, int indent = 0 ) const;
345
346        virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {}
347  protected:
348        virtual std::string typeString() const = 0;
349};
350
351class StructInstType : public ReferenceToType {
352        typedef ReferenceToType Parent;
353  public:
354        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
355        // where the structure used in this type is actually defined
356        StructDecl *baseStruct;
357
358        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
359        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
360        StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}
361
362        StructDecl *get_baseStruct() const { return baseStruct; }
363        void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; }
364
365        /// Accesses generic parameters of base struct (NULL if none such)
366        std::list<TypeDecl*> * get_baseParameters();
367
368        virtual bool isComplete() const;
369
370        /// Looks up the members of this struct named "name" and places them into "foundDecls".
371        /// Clones declarations into "foundDecls", caller responsible for freeing
372        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
373
374        virtual StructInstType *clone() const { return new StructInstType( *this ); }
375        virtual void accept( Visitor & v ) { v.visit( this ); }
376        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
377
378        virtual void print( std::ostream & os, int indent = 0 ) const;
379  private:
380        virtual std::string typeString() const;
381};
382
383class UnionInstType : public ReferenceToType {
384        typedef ReferenceToType Parent;
385  public:
386        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
387        // where the union used in this type is actually defined
388        UnionDecl *baseUnion;
389
390        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
391        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
392        UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}
393
394        UnionDecl *get_baseUnion() const { return baseUnion; }
395        void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }
396
397        /// Accesses generic parameters of base union (NULL if none such)
398        std::list< TypeDecl * > * get_baseParameters();
399
400        virtual bool isComplete() const;
401
402        /// looks up the members of this union named "name" and places them into "foundDecls"
403        /// Clones declarations into "foundDecls", caller responsible for freeing
404        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
405
406        virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
407        virtual void accept( Visitor & v ) { v.visit( this ); }
408        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
409
410        virtual void print( std::ostream & os, int indent = 0 ) const;
411  private:
412        virtual std::string typeString() const;
413};
414
415class EnumInstType : public ReferenceToType {
416        typedef ReferenceToType Parent;
417  public:
418        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
419        // where the union used in this type is actually defined
420        EnumDecl *baseEnum = nullptr;
421
422        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
423        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
424        EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}
425
426        EnumDecl *get_baseEnum() const { return baseEnum; }
427        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
428
429        virtual bool isComplete() const;
430
431        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
432        virtual void accept( Visitor & v ) { v.visit( this ); }
433        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
434  private:
435        virtual std::string typeString() const;
436};
437
438class TraitInstType : public ReferenceToType {
439        typedef ReferenceToType Parent;
440  public:
441        // this member is filled in by the validate pass, which instantiates the members of the correponding
442        // aggregate with the actual type parameters specified for this use of the context
443        std::list< Declaration* > members;
444
445        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
446        TraitInstType( const TraitInstType & other );
447        ~TraitInstType();
448
449        std::list< Declaration* >& get_members() { return members; }
450
451        virtual bool isComplete() const;
452
453        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
454        virtual void accept( Visitor & v ) { v.visit( this ); }
455        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
456  private:
457        virtual std::string typeString() const;
458};
459
460class TypeInstType : public ReferenceToType {
461        typedef ReferenceToType Parent;
462  public:
463        // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
464        // where the type used here is actually defined
465        TypeDecl *baseType;
466        bool isFtype;
467
468        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
469        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
470        TypeInstType( const TypeInstType & other );
471        ~TypeInstType();
472
473        TypeDecl *get_baseType() const { return baseType; }
474        void set_baseType( TypeDecl *newValue );
475        bool get_isFtype() const { return isFtype; }
476        void set_isFtype( bool newValue ) { isFtype = newValue; }
477
478        virtual bool isComplete() const;
479
480        virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
481        virtual void accept( Visitor & v ) { v.visit( this ); }
482        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
483        virtual void print( std::ostream & os, int indent = 0 ) const;
484  private:
485        virtual std::string typeString() const;
486};
487
488class TupleType : public Type {
489  public:
490        std::list<Type *> types;
491        std::list<Declaration *> members;
492
493        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
494        TupleType( const TupleType& );
495        virtual ~TupleType();
496
497        typedef std::list<Type*> value_type;
498        typedef value_type::iterator iterator;
499
500        std::list<Type *> & get_types() { return types; }
501        virtual unsigned size() const { return types.size(); };
502
503        // For now, this is entirely synthetic -- tuple types always have unnamed members.
504        // Eventually, we may allow named tuples, in which case members should subsume types
505        std::list<Declaration *> & get_members() { return members; }
506
507        iterator begin() { return types.begin(); }
508        iterator end() { return types.end(); }
509
510        virtual Type * getComponent( unsigned i ) {
511                assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", i, size() );
512                return *(begin()+i);
513        }
514
515        // virtual bool isComplete() const { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness
516
517        virtual TupleType *clone() const { return new TupleType( *this ); }
518        virtual void accept( Visitor & v ) { v.visit( this ); }
519        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
520        virtual void print( std::ostream & os, int indent = 0 ) const;
521};
522
523class TypeofType : public Type {
524  public:
525        Expression *expr;
526
527        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
528        TypeofType( const TypeofType& );
529        virtual ~TypeofType();
530
531        Expression *get_expr() const { return expr; }
532        void set_expr( Expression *newValue ) { expr = newValue; }
533
534        virtual bool isComplete() const { assert( false ); return false; }
535
536        virtual TypeofType *clone() const { return new TypeofType( *this ); }
537        virtual void accept( Visitor & v ) { v.visit( this ); }
538        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
539        virtual void print( std::ostream & os, int indent = 0 ) const;
540};
541
542class AttrType : public Type {
543  public:
544        std::string name;
545        Expression *expr;
546        Type *type;
547        bool isType;
548
549        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
550        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
551        AttrType( const AttrType& );
552        virtual ~AttrType();
553
554        const std::string & get_name() const { return name; }
555        void set_name( const std::string & newValue ) { name = newValue; }
556        Expression *get_expr() const { return expr; }
557        void set_expr( Expression *newValue ) { expr = newValue; }
558        Type *get_type() const { return type; }
559        void set_type( Type *newValue ) { type = newValue; }
560        bool get_isType() const { return isType; }
561        void set_isType( bool newValue ) { isType = newValue; }
562
563        virtual bool isComplete() const { assert( false ); } // xxx - not sure what to do here
564
565        virtual AttrType *clone() const { return new AttrType( *this ); }
566        virtual void accept( Visitor & v ) { v.visit( this ); }
567        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
568        virtual void print( std::ostream & os, int indent = 0 ) const;
569};
570
571/// Represents the GCC built-in varargs type
572class VarArgsType : public Type {
573  public:
574        VarArgsType();
575        VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
576
577        virtual bool isComplete() const{ return true; } // xxx - is this right?
578
579        virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
580        virtual void accept( Visitor & v ) { v.visit( this ); }
581        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
582        virtual void print( std::ostream & os, int indent = 0 ) const;
583};
584
585/// Represents a zero constant
586class ZeroType : public Type {
587  public:
588        ZeroType();
589        ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
590
591        virtual ZeroType *clone() const { return new ZeroType( *this ); }
592        virtual void accept( Visitor & v ) { v.visit( this ); }
593        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
594        virtual void print( std::ostream & os, int indent = 0 ) const;
595};
596
597/// Represents a one constant
598class OneType : public Type {
599  public:
600        OneType();
601        OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
602
603        virtual OneType *clone() const { return new OneType( *this ); }
604        virtual void accept( Visitor & v ) { v.visit( this ); }
605        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
606        virtual void print( std::ostream & os, int indent = 0 ) const;
607};
608
609std::ostream & operator<<( std::ostream & out, const Type * type );
610
611// Local Variables: //
612// tab-width: 4 //
613// mode: c++ //
614// compile-command: "make install" //
615// End: //
Note: See TracBrowser for help on using the repository browser.