source: src/SynTree/Type.h @ cbce272

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 cbce272 was 6b0b624, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

change #ifndef to #pragma once

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