source: src/SynTree/Type.h @ 9236060

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 9236060 was 9236060, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Merge branch 'master' into references

  • Property mode set to 100644
File size: 24.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 : 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 "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        typedef std::list<TypeDecl *> ForallList;
130
131        Qualifiers tq;
132        ForallList forall;
133        std::list< Attribute * > attributes;
134
135        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
136        Type( const Type & other );
137        virtual ~Type();
138
139        Qualifiers & get_qualifiers() { return tq; }
140        bool get_const() { return tq.is_const; }
141        bool get_volatile() { return tq.is_volatile; }
142        bool get_restrict() { return tq.is_restrict; }
143        bool get_lvalue() { return tq.is_lvalue; }
144        bool get_mutex() { return tq.is_mutex; }
145        bool get_atomic() { return tq.is_atomic; }
146        void set_const( bool newValue ) { tq.is_const = newValue; }
147        void set_volatile( bool newValue ) { tq.is_volatile = newValue; }
148        void set_restrict( bool newValue ) { tq.is_restrict = newValue; }
149        void set_lvalue( bool newValue ) { tq.is_lvalue = newValue; }
150        void set_mutex( bool newValue ) { tq.is_mutex = newValue; }
151        void set_atomic( bool newValue ) { tq.is_atomic = newValue; }
152
153        ForallList& get_forall() { return forall; }
154
155        std::list< Attribute * >& get_attributes() { return attributes; }
156        const std::list< Attribute * >& get_attributes() const { return attributes; }
157
158        /// How many elemental types are represented by this type
159        virtual unsigned size() const { return 1; };
160        virtual bool isVoid() const { return size() == 0; }
161        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; }
162
163        /// return type without outer pointers and arrays
164        Type * stripDeclarator();
165
166        /// return type without outer references
167        Type * stripReferences();
168
169        /// return the number of references occuring consecutively on the outermost layer of this type (i.e. do not count references nested within other types)
170        virtual int referenceDepth() const;
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 bool isComplete() const { return ! isVarLen; }
265
266        virtual PointerType *clone() const { return new PointerType( *this ); }
267        virtual void accept( Visitor & v ) { v.visit( this ); }
268        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
269        virtual void print( std::ostream & os, int indent = 0 ) const;
270};
271
272class ArrayType : public Type {
273  public:
274        Type *base;
275        Expression *dimension;
276        bool isVarLen;
277        bool isStatic;
278
279        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
280        ArrayType( const ArrayType& );
281        virtual ~ArrayType();
282
283        Type *get_base() { return base; }
284        void set_base( Type *newValue ) { base = newValue; }
285        Expression *get_dimension() { return dimension; }
286        void set_dimension( Expression *newValue ) { dimension = newValue; }
287        bool get_isVarLen() { return isVarLen; }
288        void set_isVarLen( bool newValue ) { isVarLen = newValue; }
289        bool get_isStatic() { return isStatic; }
290        void set_isStatic( bool newValue ) { isStatic = newValue; }
291
292        virtual bool isComplete() const { return ! isVarLen; }
293
294        virtual ArrayType *clone() const { return new ArrayType( *this ); }
295        virtual void accept( Visitor & v ) { v.visit( this ); }
296        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
297        virtual void print( std::ostream & os, int indent = 0 ) const;
298};
299
300class ReferenceType : public Type {
301public:
302        Type *base;
303
304        ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
305        ReferenceType( const ReferenceType & );
306        virtual ~ReferenceType();
307
308        Type *get_base() { return base; }
309        void set_base( Type *newValue ) { base = newValue; }
310
311        virtual int referenceDepth() const;
312
313        virtual ReferenceType *clone() const { return new ReferenceType( *this ); }
314        virtual void accept( Visitor & v ) { v.visit( this ); }
315        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
316        virtual void print( std::ostream & os, int indent = 0 ) const;
317};
318
319class FunctionType : public Type {
320  public:
321        std::list<DeclarationWithType*> returnVals;
322        std::list<DeclarationWithType*> parameters;
323
324        // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
325        // This could be because of
326        // - an ellipsis in a prototype declaration
327        // - an unprototyped declaration
328        bool isVarArgs;
329
330        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
331        FunctionType( const FunctionType& );
332        virtual ~FunctionType();
333
334        std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
335        std::list<DeclarationWithType*> & get_parameters() { return parameters; }
336        bool get_isVarArgs() const { return isVarArgs; }
337        void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
338        bool isTtype() const;
339
340        virtual FunctionType *clone() const { return new FunctionType( *this ); }
341        virtual void accept( Visitor & v ) { v.visit( this ); }
342        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
343        virtual void print( std::ostream & os, int indent = 0 ) const;
344};
345
346class ReferenceToType : public Type {
347  public:
348        std::list< Expression* > parameters;
349        std::string name;
350        bool hoistType;
351
352        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
353        ReferenceToType( const ReferenceToType & other );
354        virtual ~ReferenceToType();
355
356        const std::string & get_name() const { return name; }
357        void set_name( std::string newValue ) { name = newValue; }
358        std::list< Expression* >& get_parameters() { return parameters; }
359        bool get_hoistType() const { return hoistType; }
360        void set_hoistType( bool newValue ) { hoistType = newValue; }
361
362        virtual ReferenceToType *clone() const = 0;
363        virtual void accept( Visitor & v ) = 0;
364        virtual Type *acceptMutator( Mutator & m ) = 0;
365        virtual void print( std::ostream & os, int indent = 0 ) const;
366
367        virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {}
368  protected:
369        virtual std::string typeString() const = 0;
370};
371
372class StructInstType : public ReferenceToType {
373        typedef ReferenceToType Parent;
374  public:
375        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
376        // where the structure used in this type is actually defined
377        StructDecl *baseStruct;
378
379        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
380        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
381        StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}
382
383        StructDecl *get_baseStruct() const { return baseStruct; }
384        void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; }
385
386        /// Accesses generic parameters of base struct (NULL if none such)
387        std::list<TypeDecl*> * get_baseParameters();
388
389        virtual bool isComplete() const;
390
391        /// Looks up the members of this struct 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 StructInstType *clone() const { return new StructInstType( *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
404class UnionInstType : public ReferenceToType {
405        typedef ReferenceToType Parent;
406  public:
407        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
408        // where the union used in this type is actually defined
409        UnionDecl *baseUnion;
410
411        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
412        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
413        UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}
414
415        UnionDecl *get_baseUnion() const { return baseUnion; }
416        void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }
417
418        /// Accesses generic parameters of base union (NULL if none such)
419        std::list< TypeDecl * > * get_baseParameters();
420
421        virtual bool isComplete() const;
422
423        /// looks up the members of this union named "name" and places them into "foundDecls"
424        /// Clones declarations into "foundDecls", caller responsible for freeing
425        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
426
427        virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
428        virtual void accept( Visitor & v ) { v.visit( this ); }
429        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
430
431        virtual void print( std::ostream & os, int indent = 0 ) const;
432  private:
433        virtual std::string typeString() const;
434};
435
436class EnumInstType : public ReferenceToType {
437        typedef ReferenceToType Parent;
438  public:
439        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
440        // where the union used in this type is actually defined
441        EnumDecl *baseEnum = nullptr;
442
443        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
444        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
445        EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}
446
447        EnumDecl *get_baseEnum() const { return baseEnum; }
448        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
449
450        virtual bool isComplete() const;
451
452        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
453        virtual void accept( Visitor & v ) { v.visit( this ); }
454        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
455  private:
456        virtual std::string typeString() const;
457};
458
459class TraitInstType : public ReferenceToType {
460        typedef ReferenceToType Parent;
461  public:
462        // this member is filled in by the validate pass, which instantiates the members of the correponding
463        // aggregate with the actual type parameters specified for this use of the context
464        std::list< Declaration* > members;
465
466        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
467        TraitInstType( const TraitInstType & other );
468        ~TraitInstType();
469
470        std::list< Declaration* >& get_members() { return members; }
471
472        virtual bool isComplete() const;
473
474        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
475        virtual void accept( Visitor & v ) { v.visit( this ); }
476        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
477  private:
478        virtual std::string typeString() const;
479};
480
481class TypeInstType : public ReferenceToType {
482        typedef ReferenceToType Parent;
483  public:
484        // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
485        // where the type used here is actually defined
486        TypeDecl *baseType;
487        bool isFtype;
488
489        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
490        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
491        TypeInstType( const TypeInstType & other );
492        ~TypeInstType();
493
494        TypeDecl *get_baseType() const { return baseType; }
495        void set_baseType( TypeDecl *newValue );
496        bool get_isFtype() const { return isFtype; }
497        void set_isFtype( bool newValue ) { isFtype = newValue; }
498
499        virtual bool isComplete() const;
500
501        virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
502        virtual void accept( Visitor & v ) { v.visit( this ); }
503        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
504        virtual void print( std::ostream & os, int indent = 0 ) const;
505  private:
506        virtual std::string typeString() const;
507};
508
509class TupleType : public Type {
510  public:
511        std::list<Type *> types;
512        std::list<Declaration *> members;
513
514        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
515        TupleType( const TupleType& );
516        virtual ~TupleType();
517
518        typedef std::list<Type*> value_type;
519        typedef value_type::iterator iterator;
520
521        std::list<Type *> & get_types() { return types; }
522        virtual unsigned size() const { return types.size(); };
523
524        // For now, this is entirely synthetic -- tuple types always have unnamed members.
525        // Eventually, we may allow named tuples, in which case members should subsume types
526        std::list<Declaration *> & get_members() { return members; }
527
528        iterator begin() { return types.begin(); }
529        iterator end() { return types.end(); }
530
531        virtual Type * getComponent( unsigned i ) {
532                assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", i, size() );
533                return *(begin()+i);
534        }
535
536        // virtual bool isComplete() const { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness
537
538        virtual TupleType *clone() const { return new TupleType( *this ); }
539        virtual void accept( Visitor & v ) { v.visit( this ); }
540        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
541        virtual void print( std::ostream & os, int indent = 0 ) const;
542};
543
544class TypeofType : public Type {
545  public:
546        Expression *expr;
547
548        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
549        TypeofType( const TypeofType& );
550        virtual ~TypeofType();
551
552        Expression *get_expr() const { return expr; }
553        void set_expr( Expression *newValue ) { expr = newValue; }
554
555        virtual bool isComplete() const { assert( false ); return false; }
556
557        virtual TypeofType *clone() const { return new TypeofType( *this ); }
558        virtual void accept( Visitor & v ) { v.visit( this ); }
559        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
560        virtual void print( std::ostream & os, int indent = 0 ) const;
561};
562
563class AttrType : public Type {
564  public:
565        std::string name;
566        Expression *expr;
567        Type *type;
568        bool isType;
569
570        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
571        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
572        AttrType( const AttrType& );
573        virtual ~AttrType();
574
575        const std::string & get_name() const { return name; }
576        void set_name( const std::string & newValue ) { name = newValue; }
577        Expression *get_expr() const { return expr; }
578        void set_expr( Expression *newValue ) { expr = newValue; }
579        Type *get_type() const { return type; }
580        void set_type( Type *newValue ) { type = newValue; }
581        bool get_isType() const { return isType; }
582        void set_isType( bool newValue ) { isType = newValue; }
583
584        virtual bool isComplete() const { assert( false ); } // xxx - not sure what to do here
585
586        virtual AttrType *clone() const { return new AttrType( *this ); }
587        virtual void accept( Visitor & v ) { v.visit( this ); }
588        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
589        virtual void print( std::ostream & os, int indent = 0 ) const;
590};
591
592/// Represents the GCC built-in varargs type
593class VarArgsType : public Type {
594  public:
595        VarArgsType();
596        VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
597
598        virtual bool isComplete() const{ return true; } // xxx - is this right?
599
600        virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
601        virtual void accept( Visitor & v ) { v.visit( this ); }
602        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
603        virtual void print( std::ostream & os, int indent = 0 ) const;
604};
605
606/// Represents a zero constant
607class ZeroType : public Type {
608  public:
609        ZeroType();
610        ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
611
612        virtual ZeroType *clone() const { return new ZeroType( *this ); }
613        virtual void accept( Visitor & v ) { v.visit( this ); }
614        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
615        virtual void print( std::ostream & os, int indent = 0 ) const;
616};
617
618/// Represents a one constant
619class OneType : public Type {
620  public:
621        OneType();
622        OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
623
624        virtual OneType *clone() const { return new OneType( *this ); }
625        virtual void accept( Visitor & v ) { v.visit( this ); }
626        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
627        virtual void print( std::ostream & os, int indent = 0 ) const;
628};
629
630std::ostream & operator<<( std::ostream & out, const Type * type );
631
632// Local Variables: //
633// tab-width: 4 //
634// mode: c++ //
635// compile-command: "make install" //
636// End: //
Note: See TracBrowser for help on using the repository browser.