source: src/SynTree/Type.h @ 5ccb10d

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

Set reference size to base size, clean up debug code, remove more old-style NULLs from prelude

  • Property mode set to 100644
File size: 24.5 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        // Since reference types act like value types, their size is the size of the base.
314        // This makes it simple to cast the empty tuple to a reference type, since casts that increase
315        // the number of values are disallowed.
316        virtual unsigned size() const { return base->size(); }
317
318        virtual ReferenceType *clone() const { return new ReferenceType( *this ); }
319        virtual void accept( Visitor & v ) { v.visit( this ); }
320        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
321        virtual void print( std::ostream & os, int indent = 0 ) const;
322};
323
324class FunctionType : public Type {
325  public:
326        std::list<DeclarationWithType*> returnVals;
327        std::list<DeclarationWithType*> parameters;
328
329        // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
330        // This could be because of
331        // - an ellipsis in a prototype declaration
332        // - an unprototyped declaration
333        bool isVarArgs;
334
335        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
336        FunctionType( const FunctionType& );
337        virtual ~FunctionType();
338
339        std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
340        std::list<DeclarationWithType*> & get_parameters() { return parameters; }
341        bool get_isVarArgs() const { return isVarArgs; }
342        void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
343        bool isTtype() const;
344
345        virtual FunctionType *clone() const { return new FunctionType( *this ); }
346        virtual void accept( Visitor & v ) { v.visit( this ); }
347        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
348        virtual void print( std::ostream & os, int indent = 0 ) const;
349};
350
351class ReferenceToType : public Type {
352  public:
353        std::list< Expression* > parameters;
354        std::string name;
355        bool hoistType;
356
357        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
358        ReferenceToType( const ReferenceToType & other );
359        virtual ~ReferenceToType();
360
361        const std::string & get_name() const { return name; }
362        void set_name( std::string newValue ) { name = newValue; }
363        std::list< Expression* >& get_parameters() { return parameters; }
364        bool get_hoistType() const { return hoistType; }
365        void set_hoistType( bool newValue ) { hoistType = newValue; }
366
367        virtual ReferenceToType *clone() const = 0;
368        virtual void accept( Visitor & v ) = 0;
369        virtual Type *acceptMutator( Mutator & m ) = 0;
370        virtual void print( std::ostream & os, int indent = 0 ) const;
371
372        virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {}
373  protected:
374        virtual std::string typeString() const = 0;
375};
376
377class StructInstType : public ReferenceToType {
378        typedef ReferenceToType Parent;
379  public:
380        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
381        // where the structure used in this type is actually defined
382        StructDecl *baseStruct;
383
384        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
385        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
386        StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}
387
388        StructDecl *get_baseStruct() const { return baseStruct; }
389        void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; }
390
391        /// Accesses generic parameters of base struct (NULL if none such)
392        std::list<TypeDecl*> * get_baseParameters();
393
394        virtual bool isComplete() const;
395
396        /// Looks up the members of this struct named "name" and places them into "foundDecls".
397        /// Clones declarations into "foundDecls", caller responsible for freeing
398        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
399
400        virtual StructInstType *clone() const { return new StructInstType( *this ); }
401        virtual void accept( Visitor & v ) { v.visit( this ); }
402        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
403
404        virtual void print( std::ostream & os, int indent = 0 ) const;
405  private:
406        virtual std::string typeString() const;
407};
408
409class UnionInstType : public ReferenceToType {
410        typedef ReferenceToType Parent;
411  public:
412        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
413        // where the union used in this type is actually defined
414        UnionDecl *baseUnion;
415
416        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
417        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
418        UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}
419
420        UnionDecl *get_baseUnion() const { return baseUnion; }
421        void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }
422
423        /// Accesses generic parameters of base union (NULL if none such)
424        std::list< TypeDecl * > * get_baseParameters();
425
426        virtual bool isComplete() const;
427
428        /// looks up the members of this union named "name" and places them into "foundDecls"
429        /// Clones declarations into "foundDecls", caller responsible for freeing
430        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
431
432        virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
433        virtual void accept( Visitor & v ) { v.visit( this ); }
434        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
435
436        virtual void print( std::ostream & os, int indent = 0 ) const;
437  private:
438        virtual std::string typeString() const;
439};
440
441class EnumInstType : public ReferenceToType {
442        typedef ReferenceToType Parent;
443  public:
444        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
445        // where the union used in this type is actually defined
446        EnumDecl *baseEnum = nullptr;
447
448        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
449        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
450        EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}
451
452        EnumDecl *get_baseEnum() const { return baseEnum; }
453        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
454
455        virtual bool isComplete() const;
456
457        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
458        virtual void accept( Visitor & v ) { v.visit( this ); }
459        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
460  private:
461        virtual std::string typeString() const;
462};
463
464class TraitInstType : public ReferenceToType {
465        typedef ReferenceToType Parent;
466  public:
467        // this member is filled in by the validate pass, which instantiates the members of the correponding
468        // aggregate with the actual type parameters specified for this use of the context
469        std::list< Declaration* > members;
470
471        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
472        TraitInstType( const TraitInstType & other );
473        ~TraitInstType();
474
475        std::list< Declaration* >& get_members() { return members; }
476
477        virtual bool isComplete() const;
478
479        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
480        virtual void accept( Visitor & v ) { v.visit( this ); }
481        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
482  private:
483        virtual std::string typeString() const;
484};
485
486class TypeInstType : public ReferenceToType {
487        typedef ReferenceToType Parent;
488  public:
489        // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
490        // where the type used here is actually defined
491        TypeDecl *baseType;
492        bool isFtype;
493
494        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
495        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
496        TypeInstType( const TypeInstType & other );
497        ~TypeInstType();
498
499        TypeDecl *get_baseType() const { return baseType; }
500        void set_baseType( TypeDecl *newValue );
501        bool get_isFtype() const { return isFtype; }
502        void set_isFtype( bool newValue ) { isFtype = newValue; }
503
504        virtual bool isComplete() const;
505
506        virtual TypeInstType *clone() const { return new TypeInstType( *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        virtual std::string typeString() const;
512};
513
514class TupleType : public Type {
515  public:
516        std::list<Type *> types;
517        std::list<Declaration *> members;
518
519        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
520        TupleType( const TupleType& );
521        virtual ~TupleType();
522
523        typedef std::list<Type*> value_type;
524        typedef value_type::iterator iterator;
525
526        std::list<Type *> & get_types() { return types; }
527        virtual unsigned size() const { return types.size(); };
528
529        // For now, this is entirely synthetic -- tuple types always have unnamed members.
530        // Eventually, we may allow named tuples, in which case members should subsume types
531        std::list<Declaration *> & get_members() { return members; }
532
533        iterator begin() { return types.begin(); }
534        iterator end() { return types.end(); }
535
536        virtual Type * getComponent( unsigned i ) {
537                assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", i, size() );
538                return *(begin()+i);
539        }
540
541        // virtual bool isComplete() const { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness
542
543        virtual TupleType *clone() const { return new TupleType( *this ); }
544        virtual void accept( Visitor & v ) { v.visit( this ); }
545        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
546        virtual void print( std::ostream & os, int indent = 0 ) const;
547};
548
549class TypeofType : public Type {
550  public:
551        Expression *expr;
552
553        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
554        TypeofType( const TypeofType& );
555        virtual ~TypeofType();
556
557        Expression *get_expr() const { return expr; }
558        void set_expr( Expression *newValue ) { expr = newValue; }
559
560        virtual bool isComplete() const { assert( false ); return false; }
561
562        virtual TypeofType *clone() const { return new TypeofType( *this ); }
563        virtual void accept( Visitor & v ) { v.visit( this ); }
564        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
565        virtual void print( std::ostream & os, int indent = 0 ) const;
566};
567
568class AttrType : public Type {
569  public:
570        std::string name;
571        Expression *expr;
572        Type *type;
573        bool isType;
574
575        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
576        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
577        AttrType( const AttrType& );
578        virtual ~AttrType();
579
580        const std::string & get_name() const { return name; }
581        void set_name( const std::string & newValue ) { name = newValue; }
582        Expression *get_expr() const { return expr; }
583        void set_expr( Expression *newValue ) { expr = newValue; }
584        Type *get_type() const { return type; }
585        void set_type( Type *newValue ) { type = newValue; }
586        bool get_isType() const { return isType; }
587        void set_isType( bool newValue ) { isType = newValue; }
588
589        virtual bool isComplete() const { assert( false ); } // xxx - not sure what to do here
590
591        virtual AttrType *clone() const { return new AttrType( *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 the GCC built-in varargs type
598class VarArgsType : public Type {
599  public:
600        VarArgsType();
601        VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
602
603        virtual bool isComplete() const{ return true; } // xxx - is this right?
604
605        virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
606        virtual void accept( Visitor & v ) { v.visit( this ); }
607        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
608        virtual void print( std::ostream & os, int indent = 0 ) const;
609};
610
611/// Represents a zero constant
612class ZeroType : public Type {
613  public:
614        ZeroType();
615        ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
616
617        virtual ZeroType *clone() const { return new ZeroType( *this ); }
618        virtual void accept( Visitor & v ) { v.visit( this ); }
619        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
620        virtual void print( std::ostream & os, int indent = 0 ) const;
621};
622
623/// Represents a one constant
624class OneType : public Type {
625  public:
626        OneType();
627        OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
628
629        virtual OneType *clone() const { return new OneType( *this ); }
630        virtual void accept( Visitor & v ) { v.visit( this ); }
631        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
632        virtual void print( std::ostream & os, int indent = 0 ) const;
633};
634
635std::ostream & operator<<( std::ostream & out, const Type * type );
636
637// Local Variables: //
638// tab-width: 4 //
639// mode: c++ //
640// compile-command: "make install" //
641// End: //
Note: See TracBrowser for help on using the repository browser.