source: src/SynTree/Type.h @ d180746

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 d180746 was 65cdc1e, checked in by Andrew Beach <ajbeach@…>, 7 years ago

Syntax Nodes give public access to the fields with effective public access.X

  • 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 : 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        virtual bool isComplete() const { return true; }
167
168        virtual Type *clone() const = 0;
169        virtual void accept( Visitor & v ) = 0;
170        virtual Type *acceptMutator( Mutator & m ) = 0;
171        virtual void print( std::ostream & os, int indent = 0 ) const;
172};
173
174extern const Type::FuncSpecifiers noFuncSpecifiers;
175extern const Type::StorageClasses noStorageClasses;
176extern const Type::Qualifiers noQualifiers;                     // no qualifiers on constants
177
178class VoidType : public Type {
179  public:
180        VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
181
182        virtual unsigned size() const { return 0; };
183        virtual bool isComplete() const { return false; }
184
185        virtual VoidType *clone() const { return new VoidType( *this ); }
186        virtual void accept( Visitor & v ) { v.visit( this ); }
187        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
188        virtual void print( std::ostream & os, int indent = 0 ) const;
189};
190
191class BasicType : public Type {
192  public:
193        enum Kind {
194                Bool,
195                Char,
196                SignedChar,
197                UnsignedChar,
198                ShortSignedInt,
199                ShortUnsignedInt,
200                SignedInt,
201                UnsignedInt,
202                LongSignedInt,
203                LongUnsignedInt,
204                LongLongSignedInt,
205                LongLongUnsignedInt,
206                Float,
207                Double,
208                LongDouble,
209                FloatComplex,
210                DoubleComplex,
211                LongDoubleComplex,
212                FloatImaginary,
213                DoubleImaginary,
214                LongDoubleImaginary,
215                NUMBER_OF_BASIC_TYPES
216        } kind;
217
218        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
219
220        BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
221
222        Kind get_kind() { return kind; }
223        void set_kind( Kind newValue ) { kind = newValue; }
224
225        virtual BasicType *clone() const { return new BasicType( *this ); }
226        virtual void accept( Visitor & v ) { v.visit( this ); }
227        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
228        virtual void print( std::ostream & os, int indent = 0 ) const;
229
230        bool isInteger() const;
231};
232
233class PointerType : public Type {
234  public:
235        Type *base;
236
237        // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
238        Expression *dimension;
239        bool isVarLen;
240        bool isStatic;
241
242        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
243        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
244        PointerType( const PointerType& );
245        virtual ~PointerType();
246
247        Type *get_base() { return base; }
248        void set_base( Type *newValue ) { base = newValue; }
249        Expression *get_dimension() { return dimension; }
250        void set_dimension( Expression *newValue ) { dimension = newValue; }
251        bool get_isVarLen() { return isVarLen; }
252        void set_isVarLen( bool newValue ) { isVarLen = newValue; }
253        bool get_isStatic() { return isStatic; }
254        void set_isStatic( bool newValue ) { isStatic = newValue; }
255
256        bool is_array() const { return isStatic || isVarLen || dimension; }
257
258        virtual PointerType *clone() const { return new PointerType( *this ); }
259        virtual void accept( Visitor & v ) { v.visit( this ); }
260        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
261        virtual void print( std::ostream & os, int indent = 0 ) const;
262};
263
264class ArrayType : public Type {
265  public:
266        Type *base;
267        Expression *dimension;
268        bool isVarLen;
269        bool isStatic;
270
271        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
272        ArrayType( const ArrayType& );
273        virtual ~ArrayType();
274
275        Type *get_base() { return base; }
276        void set_base( Type *newValue ) { base = newValue; }
277        Expression *get_dimension() { return dimension; }
278        void set_dimension( Expression *newValue ) { dimension = newValue; }
279        bool get_isVarLen() { return isVarLen; }
280        void set_isVarLen( bool newValue ) { isVarLen = newValue; }
281        bool get_isStatic() { return isStatic; }
282        void set_isStatic( bool newValue ) { isStatic = newValue; }
283
284        virtual bool isComplete() const { return ! isVarLen; }
285
286        virtual ArrayType *clone() const { return new ArrayType( *this ); }
287        virtual void accept( Visitor & v ) { v.visit( this ); }
288        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
289        virtual void print( std::ostream & os, int indent = 0 ) const;
290};
291
292class FunctionType : public Type {
293  public:
294        std::list<DeclarationWithType*> returnVals;
295        std::list<DeclarationWithType*> parameters;
296
297        // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
298        // This could be because of
299        // - an ellipsis in a prototype declaration
300        // - an unprototyped declaration
301        bool isVarArgs;
302
303        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
304        FunctionType( const FunctionType& );
305        virtual ~FunctionType();
306
307        std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
308        std::list<DeclarationWithType*> & get_parameters() { return parameters; }
309        bool get_isVarArgs() const { return isVarArgs; }
310        void set_isVarArgs( bool newValue ) { isVarArgs = newValue; }
311        bool isTtype() const;
312
313        virtual FunctionType *clone() const { return new FunctionType( *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 ReferenceToType : public Type {
320  public:
321        std::list< Expression* > parameters;
322        std::string name;
323        bool hoistType;
324
325        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
326        ReferenceToType( const ReferenceToType & other );
327        virtual ~ReferenceToType();
328
329        const std::string & get_name() const { return name; }
330        void set_name( std::string newValue ) { name = newValue; }
331        std::list< Expression* >& get_parameters() { return parameters; }
332        bool get_hoistType() const { return hoistType; }
333        void set_hoistType( bool newValue ) { hoistType = newValue; }
334
335        virtual ReferenceToType *clone() const = 0;
336        virtual void accept( Visitor & v ) = 0;
337        virtual Type *acceptMutator( Mutator & m ) = 0;
338        virtual void print( std::ostream & os, int indent = 0 ) const;
339
340        virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {}
341  protected:
342        virtual std::string typeString() const = 0;
343};
344
345class StructInstType : public ReferenceToType {
346        typedef ReferenceToType Parent;
347  public:
348        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
349        // where the structure used in this type is actually defined
350        StructDecl *baseStruct;
351
352        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
353        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
354        StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}
355
356        StructDecl *get_baseStruct() const { return baseStruct; }
357        void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; }
358
359        /// Accesses generic parameters of base struct (NULL if none such)
360        std::list<TypeDecl*> * get_baseParameters();
361
362        virtual bool isComplete() const;
363
364        /// Looks up the members of this struct named "name" and places them into "foundDecls".
365        /// Clones declarations into "foundDecls", caller responsible for freeing
366        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
367
368        virtual StructInstType *clone() const { return new StructInstType( *this ); }
369        virtual void accept( Visitor & v ) { v.visit( this ); }
370        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
371
372        virtual void print( std::ostream & os, int indent = 0 ) const;
373  private:
374        virtual std::string typeString() const;
375};
376
377class UnionInstType : public ReferenceToType {
378        typedef ReferenceToType Parent;
379  public:
380        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
381        // where the union used in this type is actually defined
382        UnionDecl *baseUnion;
383
384        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
385        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
386        UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}
387
388        UnionDecl *get_baseUnion() const { return baseUnion; }
389        void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }
390
391        /// Accesses generic parameters of base union (NULL if none such)
392        std::list< TypeDecl * > * get_baseParameters();
393
394        virtual bool isComplete() const;
395
396        /// looks up the members of this union 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 UnionInstType *clone() const { return new UnionInstType( *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 EnumInstType : 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        EnumDecl *baseEnum = nullptr;
415
416        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
417        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
418        EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}
419
420        EnumDecl *get_baseEnum() const { return baseEnum; }
421        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
422
423        virtual bool isComplete() const;
424
425        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
426        virtual void accept( Visitor & v ) { v.visit( this ); }
427        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
428  private:
429        virtual std::string typeString() const;
430};
431
432class TraitInstType : public ReferenceToType {
433        typedef ReferenceToType Parent;
434  public:
435        // this member is filled in by the validate pass, which instantiates the members of the correponding
436        // aggregate with the actual type parameters specified for this use of the context
437        std::list< Declaration* > members;
438
439        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
440        TraitInstType( const TraitInstType & other );
441        ~TraitInstType();
442
443        std::list< Declaration* >& get_members() { return members; }
444
445        virtual bool isComplete() const;
446
447        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
448        virtual void accept( Visitor & v ) { v.visit( this ); }
449        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
450  private:
451        virtual std::string typeString() const;
452};
453
454class TypeInstType : public ReferenceToType {
455        typedef ReferenceToType Parent;
456  public:
457        // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
458        // where the type used here is actually defined
459        TypeDecl *baseType;
460        bool isFtype;
461
462        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
463        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
464        TypeInstType( const TypeInstType & other );
465        ~TypeInstType();
466
467        TypeDecl *get_baseType() const { return baseType; }
468        void set_baseType( TypeDecl *newValue );
469        bool get_isFtype() const { return isFtype; }
470        void set_isFtype( bool newValue ) { isFtype = newValue; }
471
472        virtual bool isComplete() const;
473
474        virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
475        virtual void accept( Visitor & v ) { v.visit( this ); }
476        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
477        virtual void print( std::ostream & os, int indent = 0 ) const;
478  private:
479        virtual std::string typeString() const;
480};
481
482class TupleType : public Type {
483  public:
484        std::list<Type *> types;
485        std::list<Declaration *> members;
486
487        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
488        TupleType( const TupleType& );
489        virtual ~TupleType();
490
491        typedef std::list<Type*> value_type;
492        typedef value_type::iterator iterator;
493
494        std::list<Type *> & get_types() { return types; }
495        virtual unsigned size() const { return types.size(); };
496
497        // For now, this is entirely synthetic -- tuple types always have unnamed members.
498        // Eventually, we may allow named tuples, in which case members should subsume types
499        std::list<Declaration *> & get_members() { return members; }
500
501        iterator begin() { return types.begin(); }
502        iterator end() { return types.end(); }
503
504        virtual Type * getComponent( unsigned i ) {
505                assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", i, size() );
506                return *(begin()+i);
507        }
508
509        // virtual bool isComplete() const { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness
510
511        virtual TupleType *clone() const { return new TupleType( *this ); }
512        virtual void accept( Visitor & v ) { v.visit( this ); }
513        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
514        virtual void print( std::ostream & os, int indent = 0 ) const;
515};
516
517class TypeofType : public Type {
518  public:
519        Expression *expr;
520
521        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
522        TypeofType( const TypeofType& );
523        virtual ~TypeofType();
524
525        Expression *get_expr() const { return expr; }
526        void set_expr( Expression *newValue ) { expr = newValue; }
527
528        virtual bool isComplete() const { assert( false ); return false; }
529
530        virtual TypeofType *clone() const { return new TypeofType( *this ); }
531        virtual void accept( Visitor & v ) { v.visit( this ); }
532        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
533        virtual void print( std::ostream & os, int indent = 0 ) const;
534};
535
536class AttrType : public Type {
537  public:
538        std::string name;
539        Expression *expr;
540        Type *type;
541        bool isType;
542
543        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
544        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
545        AttrType( const AttrType& );
546        virtual ~AttrType();
547
548        const std::string & get_name() const { return name; }
549        void set_name( const std::string & newValue ) { name = newValue; }
550        Expression *get_expr() const { return expr; }
551        void set_expr( Expression *newValue ) { expr = newValue; }
552        Type *get_type() const { return type; }
553        void set_type( Type *newValue ) { type = newValue; }
554        bool get_isType() const { return isType; }
555        void set_isType( bool newValue ) { isType = newValue; }
556
557        virtual bool isComplete() const { assert( false ); } // xxx - not sure what to do here
558
559        virtual AttrType *clone() const { return new AttrType( *this ); }
560        virtual void accept( Visitor & v ) { v.visit( this ); }
561        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
562        virtual void print( std::ostream & os, int indent = 0 ) const;
563};
564
565/// Represents the GCC built-in varargs type
566class VarArgsType : public Type {
567  public:
568        VarArgsType();
569        VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
570
571        virtual bool isComplete() const{ return true; } // xxx - is this right?
572
573        virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
574        virtual void accept( Visitor & v ) { v.visit( this ); }
575        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
576        virtual void print( std::ostream & os, int indent = 0 ) const;
577};
578
579/// Represents a zero constant
580class ZeroType : public Type {
581  public:
582        ZeroType();
583        ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
584
585        virtual ZeroType *clone() const { return new ZeroType( *this ); }
586        virtual void accept( Visitor & v ) { v.visit( this ); }
587        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
588        virtual void print( std::ostream & os, int indent = 0 ) const;
589};
590
591/// Represents a one constant
592class OneType : public Type {
593  public:
594        OneType();
595        OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
596
597        virtual OneType *clone() const { return new OneType( *this ); }
598        virtual void accept( Visitor & v ) { v.visit( this ); }
599        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
600        virtual void print( std::ostream & os, int indent = 0 ) const;
601};
602
603std::ostream & operator<<( std::ostream & out, const Type * type );
604
605// Local Variables: //
606// tab-width: 4 //
607// mode: c++ //
608// compile-command: "make install" //
609// End: //
Note: See TracBrowser for help on using the repository browser.