[0dd3a2f] | 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 | // |
---|
[ae63a18] | 7 | // Type.h -- |
---|
[0dd3a2f] | 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
[3315e3d] | 11 | // Last Modified By : Andrew Beach |
---|
| 12 | // Last Modified On : Wed Sep 4 09:58:00 2019 |
---|
| 13 | // Update Count : 170 |
---|
[0dd3a2f] | 14 | // |
---|
| 15 | |
---|
[6b0b624] | 16 | #pragma once |
---|
[51b7345] | 17 | |
---|
[ea6332d] | 18 | #include <strings.h> // for ffs |
---|
| 19 | #include <cassert> // for assert, assertf |
---|
| 20 | #include <list> // for list, _List_iterator |
---|
| 21 | #include <ostream> // for ostream, operator<<, basic_ostream |
---|
| 22 | #include <string> // for string |
---|
| 23 | |
---|
| 24 | #include "BaseSyntaxNode.h" // for BaseSyntaxNode |
---|
| 25 | #include "Common/utility.h" // for operator+ |
---|
| 26 | #include "Mutator.h" // for Mutator |
---|
| 27 | #include "SynTree.h" // for AST nodes |
---|
| 28 | #include "Visitor.h" // for Visitor |
---|
[51b7345] | 29 | |
---|
[138e29e] | 30 | class Type : public BaseSyntaxNode { |
---|
[c8ffe20b] | 31 | public: |
---|
[6f95000] | 32 | // Simulate inheritance because union does not allow it. |
---|
[615a096] | 33 | // Bug in g++-4.9 prevents static field in union |
---|
| 34 | //static const char * Names[]; |
---|
[6f95000] | 35 | #define BFCommon( BFType, N ) \ |
---|
[d6d747d] | 36 | bool operator[]( unsigned int i ) const { return val & (1 << i); } \ |
---|
| 37 | bool any() const { return val != 0; } \ |
---|
[6f95000] | 38 | void reset() { val = 0; } \ |
---|
| 39 | int ffs() { return ::ffs( val ) - 1; } \ |
---|
| 40 | BFType operator&=( BFType other ) { \ |
---|
| 41 | val &= other.val; return *this; \ |
---|
| 42 | } \ |
---|
| 43 | BFType operator&( BFType other ) const { \ |
---|
| 44 | BFType q = other; \ |
---|
| 45 | q &= *this; \ |
---|
| 46 | return q; \ |
---|
| 47 | } \ |
---|
| 48 | BFType operator|=( BFType other ) { \ |
---|
| 49 | val |= other.val; return *this; \ |
---|
| 50 | } \ |
---|
| 51 | BFType operator|( BFType other ) const { \ |
---|
| 52 | BFType q = other; \ |
---|
| 53 | q |= *this; \ |
---|
| 54 | return q; \ |
---|
| 55 | } \ |
---|
| 56 | BFType operator-=( BFType other ) { \ |
---|
| 57 | val &= ~other.val; return *this; \ |
---|
| 58 | } \ |
---|
[d6d747d] | 59 | void print( std::ostream & os ) const { \ |
---|
| 60 | if ( (*this).any() ) { \ |
---|
| 61 | for ( unsigned int i = 0; i < N; i += 1 ) { \ |
---|
| 62 | if ( (*this)[i] ) { \ |
---|
[615a096] | 63 | os << BFType##Names[i] << ' '; \ |
---|
[d6d747d] | 64 | } \ |
---|
| 65 | } \ |
---|
| 66 | } \ |
---|
| 67 | } |
---|
| 68 | |
---|
[68fe077a] | 69 | // enum must remain in the same order as the corresponding bit fields. |
---|
| 70 | |
---|
[ddfd945] | 71 | enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; |
---|
[615a096] | 72 | static const char * FuncSpecifiersNames[]; |
---|
[ddfd945] | 73 | union FuncSpecifiers { |
---|
| 74 | unsigned int val; |
---|
| 75 | struct { |
---|
| 76 | bool is_inline : 1; |
---|
| 77 | bool is_noreturn : 1; |
---|
| 78 | bool is_fortran : 1; |
---|
| 79 | }; |
---|
| 80 | FuncSpecifiers() : val( 0 ) {} |
---|
| 81 | FuncSpecifiers( unsigned int val ) : val( val ) {} |
---|
[615a096] | 82 | // equality (==, !=) works implicitly on first field "val", relational operations are undefined. |
---|
[6f95000] | 83 | BFCommon( FuncSpecifiers, NumFuncSpecifier ) |
---|
[ddfd945] | 84 | }; // FuncSpecifiers |
---|
| 85 | |
---|
[68fe077a] | 86 | enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; |
---|
[615a096] | 87 | static const char * StorageClassesNames[]; |
---|
[68fe077a] | 88 | union StorageClasses { |
---|
| 89 | unsigned int val; |
---|
| 90 | struct { |
---|
| 91 | bool is_extern : 1; |
---|
| 92 | bool is_static : 1; |
---|
| 93 | bool is_auto : 1; |
---|
| 94 | bool is_register : 1; |
---|
| 95 | bool is_threadlocal : 1; |
---|
| 96 | }; |
---|
| 97 | |
---|
| 98 | StorageClasses() : val( 0 ) {} |
---|
| 99 | StorageClasses( unsigned int val ) : val( val ) {} |
---|
[615a096] | 100 | // equality (==, !=) works implicitly on first field "val", relational operations are undefined. |
---|
[6f95000] | 101 | BFCommon( StorageClasses, NumStorageClass ) |
---|
[68fe077a] | 102 | }; // StorageClasses |
---|
| 103 | |
---|
[b4f8808] | 104 | enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Mutex = 1 << 3, Atomic = 1 << 4, NumTypeQualifier = 5 }; |
---|
[615a096] | 105 | static const char * QualifiersNames[]; |
---|
[bf4ac09] | 106 | union Qualifiers { |
---|
[b4f8808] | 107 | enum { Mask = ~Restrict }; |
---|
[bf4ac09] | 108 | unsigned int val; |
---|
| 109 | struct { |
---|
[615a096] | 110 | bool is_const : 1; |
---|
| 111 | bool is_restrict : 1; |
---|
| 112 | bool is_volatile : 1; |
---|
| 113 | bool is_mutex : 1; |
---|
| 114 | bool is_atomic : 1; |
---|
[bf4ac09] | 115 | }; |
---|
[6e8bd43] | 116 | |
---|
[bf4ac09] | 117 | Qualifiers() : val( 0 ) {} |
---|
| 118 | Qualifiers( unsigned int val ) : val( val ) {} |
---|
[615a096] | 119 | // Complex comparisons provide implicit qualifier downcasting, e.g., T downcast to const T. |
---|
| 120 | bool operator==( Qualifiers other ) const { return (val & Mask) == (other.val & Mask); } |
---|
| 121 | bool operator!=( Qualifiers other ) const { return (val & Mask) != (other.val & Mask); } |
---|
[d6d747d] | 122 | bool operator<=( Qualifiers other ) const { |
---|
[e04b636] | 123 | return is_const <= other.is_const //Any non-const converts to const without cost |
---|
| 124 | && is_volatile <= other.is_volatile //Any non-volatile converts to volatile without cost |
---|
| 125 | && is_mutex >= other.is_mutex //Any mutex converts to non-mutex without cost |
---|
| 126 | && is_atomic == other.is_atomic; //No conversion from atomic to non atomic is free |
---|
[bf4ac09] | 127 | } |
---|
[6f95000] | 128 | bool operator<( Qualifiers other ) const { return *this != other && *this <= other; } |
---|
| 129 | bool operator>=( Qualifiers other ) const { return ! (*this < other); } |
---|
| 130 | bool operator>( Qualifiers other ) const { return *this != other && *this >= other; } |
---|
| 131 | BFCommon( Qualifiers, NumTypeQualifier ) |
---|
[3315e3d] | 132 | |
---|
| 133 | Qualifiers unify( Qualifiers const & other ) const { |
---|
| 134 | int or_flags = Mask & (val | other.val); |
---|
| 135 | int and_flags = val & other.val; |
---|
| 136 | return Qualifiers( or_flags | and_flags ); |
---|
| 137 | } |
---|
[bf4ac09] | 138 | }; // Qualifiers |
---|
[0dd3a2f] | 139 | |
---|
[65cdc1e] | 140 | typedef std::list<TypeDecl *> ForallList; |
---|
| 141 | |
---|
| 142 | Qualifiers tq; |
---|
| 143 | ForallList forall; |
---|
| 144 | std::list< Attribute * > attributes; |
---|
| 145 | |
---|
[f2e40a9f] | 146 | Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); |
---|
| 147 | Type( const Type & other ); |
---|
[0dd3a2f] | 148 | virtual ~Type(); |
---|
| 149 | |
---|
[f2e40a9f] | 150 | Qualifiers & get_qualifiers() { return tq; } |
---|
[7870799] | 151 | bool get_const() const { return tq.is_const; } |
---|
| 152 | bool get_volatile() const { return tq.is_volatile; } |
---|
| 153 | bool get_restrict() const { return tq.is_restrict; } |
---|
| 154 | bool get_mutex() const { return tq.is_mutex; } |
---|
| 155 | bool get_atomic() const { return tq.is_atomic; } |
---|
[615a096] | 156 | void set_const( bool newValue ) { tq.is_const = newValue; } |
---|
| 157 | void set_volatile( bool newValue ) { tq.is_volatile = newValue; } |
---|
| 158 | void set_restrict( bool newValue ) { tq.is_restrict = newValue; } |
---|
| 159 | void set_mutex( bool newValue ) { tq.is_mutex = newValue; } |
---|
| 160 | void set_atomic( bool newValue ) { tq.is_atomic = newValue; } |
---|
[8c49c0e] | 161 | |
---|
| 162 | ForallList& get_forall() { return forall; } |
---|
[0dd3a2f] | 163 | |
---|
[c0aa336] | 164 | std::list< Attribute * >& get_attributes() { return attributes; } |
---|
| 165 | const std::list< Attribute * >& get_attributes() const { return attributes; } |
---|
| 166 | |
---|
[906e24d] | 167 | /// How many elemental types are represented by this type |
---|
| 168 | virtual unsigned size() const { return 1; }; |
---|
| 169 | virtual bool isVoid() const { return size() == 0; } |
---|
[7933351] | 170 | 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; } |
---|
[906e24d] | 171 | |
---|
[142cf5d] | 172 | /// return type without outer pointers and arrays |
---|
[0698aa1] | 173 | Type * stripDeclarator(); |
---|
| 174 | |
---|
| 175 | /// return type without outer references |
---|
| 176 | Type * stripReferences(); |
---|
[85dac33] | 177 | const Type * stripReferences() const; |
---|
[6f95000] | 178 | |
---|
[e6cee92] | 179 | /// return the number of references occuring consecutively on the outermost layer of this type (i.e. do not count references nested within other types) |
---|
| 180 | virtual int referenceDepth() const; |
---|
| 181 | |
---|
[4a9ccc3] | 182 | virtual bool isComplete() const { return true; } |
---|
| 183 | |
---|
[0b3b2ae] | 184 | virtual AggregateDecl * getAggr() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); } |
---|
[9bfc9da] | 185 | |
---|
| 186 | virtual TypeSubstitution genericSubstitution() const; |
---|
[373d0b5] | 187 | |
---|
[0dd3a2f] | 188 | virtual Type *clone() const = 0; |
---|
[f2e40a9f] | 189 | virtual void accept( Visitor & v ) = 0; |
---|
[7870799] | 190 | virtual void accept( Visitor & v ) const = 0; |
---|
[f2e40a9f] | 191 | virtual Type *acceptMutator( Mutator & m ) = 0; |
---|
[50377a4] | 192 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
[51b7345] | 193 | }; |
---|
| 194 | |
---|
[65cdc1e] | 195 | extern const Type::FuncSpecifiers noFuncSpecifiers; |
---|
| 196 | extern const Type::StorageClasses noStorageClasses; |
---|
| 197 | extern const Type::Qualifiers noQualifiers; // no qualifiers on constants |
---|
[4cb935e] | 198 | |
---|
[c8ffe20b] | 199 | class VoidType : public Type { |
---|
| 200 | public: |
---|
[f2e40a9f] | 201 | VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[51b7345] | 202 | |
---|
[d67cdb7] | 203 | virtual unsigned size() const override { return 0; }; |
---|
| 204 | virtual bool isComplete() const override { return false; } |
---|
[906e24d] | 205 | |
---|
[d67cdb7] | 206 | virtual VoidType *clone() const override { return new VoidType( *this ); } |
---|
| 207 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 208 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 209 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 210 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[51b7345] | 211 | }; |
---|
| 212 | |
---|
[c8ffe20b] | 213 | class BasicType : public Type { |
---|
| 214 | public: |
---|
[ada4575] | 215 | // GENERATED START, DO NOT EDIT |
---|
[6fd1955] | 216 | // GENERATED BY BasicTypes-gen.cc |
---|
[cdcddfe1] | 217 | enum Kind { |
---|
[e15853c] | 218 | Bool, |
---|
[cdcddfe1] | 219 | Char, |
---|
| 220 | SignedChar, |
---|
| 221 | UnsignedChar, |
---|
| 222 | ShortSignedInt, |
---|
| 223 | ShortUnsignedInt, |
---|
| 224 | SignedInt, |
---|
| 225 | UnsignedInt, |
---|
| 226 | LongSignedInt, |
---|
| 227 | LongUnsignedInt, |
---|
| 228 | LongLongSignedInt, |
---|
| 229 | LongLongUnsignedInt, |
---|
| 230 | SignedInt128, |
---|
| 231 | UnsignedInt128, |
---|
[e15853c] | 232 | uFloat16, |
---|
| 233 | uFloat16Complex, |
---|
| 234 | uFloat32, |
---|
| 235 | uFloat32Complex, |
---|
[cdcddfe1] | 236 | Float, |
---|
| 237 | FloatComplex, |
---|
[e15853c] | 238 | uFloat32x, |
---|
| 239 | uFloat32xComplex, |
---|
| 240 | uFloat64, |
---|
| 241 | uFloat64Complex, |
---|
[cdcddfe1] | 242 | Double, |
---|
| 243 | DoubleComplex, |
---|
[e15853c] | 244 | uFloat64x, |
---|
| 245 | uFloat64xComplex, |
---|
| 246 | uuFloat80, |
---|
| 247 | uFloat128, |
---|
| 248 | uFloat128Complex, |
---|
| 249 | uuFloat128, |
---|
[cdcddfe1] | 250 | LongDouble, |
---|
| 251 | LongDoubleComplex, |
---|
[e15853c] | 252 | uFloat128x, |
---|
| 253 | uFloat128xComplex, |
---|
[0dd3a2f] | 254 | NUMBER_OF_BASIC_TYPES |
---|
[65cdc1e] | 255 | } kind; |
---|
[ada4575] | 256 | // GENERATED END |
---|
[0dd3a2f] | 257 | |
---|
[59db689] | 258 | static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind |
---|
[0dd3a2f] | 259 | |
---|
[f2e40a9f] | 260 | BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[0dd3a2f] | 261 | |
---|
[85dac33] | 262 | Kind get_kind() const { return kind; } |
---|
[0dd3a2f] | 263 | void set_kind( Kind newValue ) { kind = newValue; } |
---|
| 264 | |
---|
[d67cdb7] | 265 | virtual BasicType *clone() const override { return new BasicType( *this ); } |
---|
| 266 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 267 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 268 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 269 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[0dd3a2f] | 270 | |
---|
| 271 | bool isInteger() const; |
---|
[51b7345] | 272 | }; |
---|
| 273 | |
---|
[c8ffe20b] | 274 | class PointerType : public Type { |
---|
| 275 | public: |
---|
[65cdc1e] | 276 | Type *base; |
---|
| 277 | |
---|
| 278 | // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] ) |
---|
| 279 | Expression *dimension; |
---|
| 280 | bool isVarLen; |
---|
| 281 | bool isStatic; |
---|
| 282 | |
---|
[f2e40a9f] | 283 | PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
| 284 | PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[0dd3a2f] | 285 | PointerType( const PointerType& ); |
---|
| 286 | virtual ~PointerType(); |
---|
| 287 | |
---|
| 288 | Type *get_base() { return base; } |
---|
| 289 | void set_base( Type *newValue ) { base = newValue; } |
---|
| 290 | Expression *get_dimension() { return dimension; } |
---|
| 291 | void set_dimension( Expression *newValue ) { dimension = newValue; } |
---|
| 292 | bool get_isVarLen() { return isVarLen; } |
---|
| 293 | void set_isVarLen( bool newValue ) { isVarLen = newValue; } |
---|
| 294 | bool get_isStatic() { return isStatic; } |
---|
| 295 | void set_isStatic( bool newValue ) { isStatic = newValue; } |
---|
| 296 | |
---|
[ed8a0d2] | 297 | bool is_array() const { return isStatic || isVarLen || dimension; } |
---|
| 298 | |
---|
[d67cdb7] | 299 | virtual bool isComplete() const override { return ! isVarLen; } |
---|
[ce8c12f] | 300 | |
---|
[d67cdb7] | 301 | virtual PointerType *clone() const override { return new PointerType( *this ); } |
---|
| 302 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 303 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 304 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 305 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[65cdc1e] | 306 | }; |
---|
[ae63a18] | 307 | |
---|
[65cdc1e] | 308 | class ArrayType : public Type { |
---|
| 309 | public: |
---|
| 310 | Type *base; |
---|
[0dd3a2f] | 311 | Expression *dimension; |
---|
| 312 | bool isVarLen; |
---|
| 313 | bool isStatic; |
---|
[51b7345] | 314 | |
---|
[f2e40a9f] | 315 | ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[0dd3a2f] | 316 | ArrayType( const ArrayType& ); |
---|
| 317 | virtual ~ArrayType(); |
---|
| 318 | |
---|
| 319 | Type *get_base() { return base; } |
---|
| 320 | void set_base( Type *newValue ) { base = newValue; } |
---|
| 321 | Expression *get_dimension() { return dimension; } |
---|
| 322 | void set_dimension( Expression *newValue ) { dimension = newValue; } |
---|
| 323 | bool get_isVarLen() { return isVarLen; } |
---|
| 324 | void set_isVarLen( bool newValue ) { isVarLen = newValue; } |
---|
| 325 | bool get_isStatic() { return isStatic; } |
---|
| 326 | void set_isStatic( bool newValue ) { isStatic = newValue; } |
---|
| 327 | |
---|
[99b7d4fc] | 328 | // array types are complete if they have a dimension expression or are |
---|
| 329 | // VLAs ('*' in parameter declaration), and incomplete otherwise. |
---|
| 330 | // See 6.7.6.2 |
---|
| 331 | virtual bool isComplete() const override { return dimension || isVarLen; } |
---|
[4a9ccc3] | 332 | |
---|
[d67cdb7] | 333 | virtual ArrayType *clone() const override { return new ArrayType( *this ); } |
---|
| 334 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 335 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 336 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 337 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[51b7345] | 338 | }; |
---|
| 339 | |
---|
[c5d7701] | 340 | class QualifiedType : public Type { |
---|
| 341 | public: |
---|
[c194661] | 342 | Type * parent; |
---|
| 343 | Type * child; |
---|
[c5d7701] | 344 | |
---|
[c194661] | 345 | QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child ); |
---|
[c5d7701] | 346 | QualifiedType( const QualifiedType & tq ); |
---|
| 347 | virtual ~QualifiedType(); |
---|
| 348 | |
---|
| 349 | virtual QualifiedType *clone() const override { return new QualifiedType( *this ); } |
---|
| 350 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 351 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[c5d7701] | 352 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
| 353 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
| 354 | }; |
---|
| 355 | |
---|
[ce8c12f] | 356 | class ReferenceType : public Type { |
---|
| 357 | public: |
---|
[9236060] | 358 | Type *base; |
---|
| 359 | |
---|
[ce8c12f] | 360 | ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
| 361 | ReferenceType( const ReferenceType & ); |
---|
| 362 | virtual ~ReferenceType(); |
---|
| 363 | |
---|
| 364 | Type *get_base() { return base; } |
---|
| 365 | void set_base( Type *newValue ) { base = newValue; } |
---|
| 366 | |
---|
[d67cdb7] | 367 | virtual int referenceDepth() const override; |
---|
[e6cee92] | 368 | |
---|
[5ccb10d] | 369 | // Since reference types act like value types, their size is the size of the base. |
---|
| 370 | // This makes it simple to cast the empty tuple to a reference type, since casts that increase |
---|
| 371 | // the number of values are disallowed. |
---|
[d67cdb7] | 372 | virtual unsigned size() const override { return base->size(); } |
---|
[5ccb10d] | 373 | |
---|
[9bfc9da] | 374 | virtual TypeSubstitution genericSubstitution() const override; |
---|
| 375 | |
---|
[d67cdb7] | 376 | virtual ReferenceType *clone() const override { return new ReferenceType( *this ); } |
---|
| 377 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 378 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 379 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 380 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[ce8c12f] | 381 | }; |
---|
| 382 | |
---|
[c8ffe20b] | 383 | class FunctionType : public Type { |
---|
| 384 | public: |
---|
[65cdc1e] | 385 | std::list<DeclarationWithType*> returnVals; |
---|
| 386 | std::list<DeclarationWithType*> parameters; |
---|
| 387 | |
---|
| 388 | // Does the function accept a variable number of arguments following the arguments specified in the parameters list. |
---|
| 389 | // This could be because of |
---|
| 390 | // - an ellipsis in a prototype declaration |
---|
| 391 | // - an unprototyped declaration |
---|
| 392 | bool isVarArgs; |
---|
| 393 | |
---|
[f2e40a9f] | 394 | FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[0dd3a2f] | 395 | FunctionType( const FunctionType& ); |
---|
| 396 | virtual ~FunctionType(); |
---|
| 397 | |
---|
[cf16f94] | 398 | std::list<DeclarationWithType*> & get_returnVals() { return returnVals; } |
---|
| 399 | std::list<DeclarationWithType*> & get_parameters() { return parameters; } |
---|
[8bf784a] | 400 | bool get_isVarArgs() const { return isVarArgs; } |
---|
[0dd3a2f] | 401 | void set_isVarArgs( bool newValue ) { isVarArgs = newValue; } |
---|
[8bf784a] | 402 | bool isTtype() const; |
---|
| 403 | |
---|
[8aa474a] | 404 | bool isUnprototyped() const { return isVarArgs && parameters.size() == 0; } |
---|
| 405 | |
---|
[d67cdb7] | 406 | virtual FunctionType *clone() const override { return new FunctionType( *this ); } |
---|
| 407 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 408 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 409 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 410 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[51b7345] | 411 | }; |
---|
| 412 | |
---|
[c8ffe20b] | 413 | class ReferenceToType : public Type { |
---|
| 414 | public: |
---|
[65cdc1e] | 415 | std::list< Expression* > parameters; |
---|
| 416 | std::string name; |
---|
| 417 | bool hoistType; |
---|
| 418 | |
---|
[f2e40a9f] | 419 | ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); |
---|
| 420 | ReferenceToType( const ReferenceToType & other ); |
---|
[0dd3a2f] | 421 | virtual ~ReferenceToType(); |
---|
| 422 | |
---|
[f2e40a9f] | 423 | const std::string & get_name() const { return name; } |
---|
[0dd3a2f] | 424 | void set_name( std::string newValue ) { name = newValue; } |
---|
| 425 | std::list< Expression* >& get_parameters() { return parameters; } |
---|
[43c89a7] | 426 | bool get_hoistType() const { return hoistType; } |
---|
| 427 | void set_hoistType( bool newValue ) { hoistType = newValue; } |
---|
[ae63a18] | 428 | |
---|
[d67cdb7] | 429 | virtual ReferenceToType *clone() const override = 0; |
---|
| 430 | virtual void accept( Visitor & v ) override = 0; |
---|
| 431 | virtual Type *acceptMutator( Mutator & m ) override = 0; |
---|
[50377a4] | 432 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[6013bd7] | 433 | |
---|
[b3c36f4] | 434 | virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {} |
---|
[c8ffe20b] | 435 | protected: |
---|
[0dd3a2f] | 436 | virtual std::string typeString() const = 0; |
---|
[51b7345] | 437 | }; |
---|
| 438 | |
---|
[c8ffe20b] | 439 | class StructInstType : public ReferenceToType { |
---|
[0dd3a2f] | 440 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 441 | public: |
---|
[65cdc1e] | 442 | // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree, |
---|
| 443 | // where the structure used in this type is actually defined |
---|
| 444 | StructDecl *baseStruct; |
---|
| 445 | |
---|
[f2e40a9f] | 446 | StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} |
---|
| 447 | StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
| 448 | StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {} |
---|
[51b7345] | 449 | |
---|
[0dd3a2f] | 450 | StructDecl *get_baseStruct() const { return baseStruct; } |
---|
| 451 | void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; } |
---|
[37a3b8f9] | 452 | |
---|
[ed94eac] | 453 | /// Accesses generic parameters of base struct (NULL if none such) |
---|
[839ccbb] | 454 | std::list<TypeDecl*> * get_baseParameters(); |
---|
[9bfc9da] | 455 | const std::list<TypeDecl*> * get_baseParameters() const; |
---|
[ae63a18] | 456 | |
---|
[d67cdb7] | 457 | virtual bool isComplete() const override; |
---|
[4a9ccc3] | 458 | |
---|
[0b3b2ae] | 459 | virtual AggregateDecl * getAggr() const override; |
---|
[373d0b5] | 460 | |
---|
[9bfc9da] | 461 | virtual TypeSubstitution genericSubstitution() const override; |
---|
| 462 | |
---|
[37a3b8f9] | 463 | /// Looks up the members of this struct named "name" and places them into "foundDecls". |
---|
| 464 | /// Clones declarations into "foundDecls", caller responsible for freeing |
---|
[d67cdb7] | 465 | void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override; |
---|
[51b7345] | 466 | |
---|
[d67cdb7] | 467 | virtual StructInstType *clone() const override { return new StructInstType( *this ); } |
---|
| 468 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 469 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 470 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[5d125e4] | 471 | |
---|
[50377a4] | 472 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[c8ffe20b] | 473 | private: |
---|
[d67cdb7] | 474 | virtual std::string typeString() const override; |
---|
[51b7345] | 475 | }; |
---|
| 476 | |
---|
[c8ffe20b] | 477 | class UnionInstType : public ReferenceToType { |
---|
[0dd3a2f] | 478 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 479 | public: |
---|
[65cdc1e] | 480 | // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, |
---|
| 481 | // where the union used in this type is actually defined |
---|
| 482 | UnionDecl *baseUnion; |
---|
| 483 | |
---|
[f2e40a9f] | 484 | UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} |
---|
| 485 | UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
| 486 | UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {} |
---|
[0dd3a2f] | 487 | |
---|
| 488 | UnionDecl *get_baseUnion() const { return baseUnion; } |
---|
[c0aa336] | 489 | void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; } |
---|
[37a3b8f9] | 490 | |
---|
[ed94eac] | 491 | /// Accesses generic parameters of base union (NULL if none such) |
---|
[9bfc9da] | 492 | std::list<TypeDecl*> * get_baseParameters(); |
---|
| 493 | const std::list<TypeDecl*> * get_baseParameters() const; |
---|
[ae63a18] | 494 | |
---|
[d67cdb7] | 495 | virtual bool isComplete() const override; |
---|
[4a9ccc3] | 496 | |
---|
[0b3b2ae] | 497 | virtual AggregateDecl * getAggr() const override; |
---|
[373d0b5] | 498 | |
---|
[9bfc9da] | 499 | virtual TypeSubstitution genericSubstitution() const override; |
---|
| 500 | |
---|
[37a3b8f9] | 501 | /// looks up the members of this union named "name" and places them into "foundDecls" |
---|
| 502 | /// Clones declarations into "foundDecls", caller responsible for freeing |
---|
[d67cdb7] | 503 | void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override; |
---|
[0dd3a2f] | 504 | |
---|
[d67cdb7] | 505 | virtual UnionInstType *clone() const override { return new UnionInstType( *this ); } |
---|
| 506 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 507 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 508 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[5d125e4] | 509 | |
---|
[50377a4] | 510 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[c8ffe20b] | 511 | private: |
---|
[d67cdb7] | 512 | virtual std::string typeString() const override; |
---|
[51b7345] | 513 | }; |
---|
| 514 | |
---|
[c8ffe20b] | 515 | class EnumInstType : public ReferenceToType { |
---|
[0dd3a2f] | 516 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 517 | public: |
---|
[65cdc1e] | 518 | // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, |
---|
| 519 | // where the union used in this type is actually defined |
---|
| 520 | EnumDecl *baseEnum = nullptr; |
---|
| 521 | |
---|
[f2e40a9f] | 522 | EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} |
---|
| 523 | EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
| 524 | EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {} |
---|
[51b7345] | 525 | |
---|
[c0aa336] | 526 | EnumDecl *get_baseEnum() const { return baseEnum; } |
---|
| 527 | void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; } |
---|
| 528 | |
---|
[d67cdb7] | 529 | virtual bool isComplete() const override; |
---|
[4a9ccc3] | 530 | |
---|
[2dc6621] | 531 | virtual AggregateDecl * getAggr() const override; |
---|
[0b3b2ae] | 532 | |
---|
[d67cdb7] | 533 | virtual EnumInstType *clone() const override { return new EnumInstType( *this ); } |
---|
| 534 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 535 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 536 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[6137fbb] | 537 | |
---|
| 538 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[c8ffe20b] | 539 | private: |
---|
[d67cdb7] | 540 | virtual std::string typeString() const override; |
---|
[51b7345] | 541 | }; |
---|
| 542 | |
---|
[4040425] | 543 | class TraitInstType : public ReferenceToType { |
---|
[0dd3a2f] | 544 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 545 | public: |
---|
[be9036d] | 546 | // this decl is not "owned" by the trait inst; it is merely a pointer to elsewhere in the tree, |
---|
| 547 | // where the trait used in this type is actually defined |
---|
| 548 | TraitDecl * baseTrait = nullptr; |
---|
[65cdc1e] | 549 | |
---|
[be9036d] | 550 | TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} |
---|
| 551 | TraitInstType( const Type::Qualifiers & tq, TraitDecl * baseTrait, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[f2e40a9f] | 552 | TraitInstType( const TraitInstType & other ); |
---|
[4040425] | 553 | ~TraitInstType(); |
---|
[51b7345] | 554 | |
---|
[d67cdb7] | 555 | virtual bool isComplete() const override; |
---|
[4a9ccc3] | 556 | |
---|
[d67cdb7] | 557 | virtual TraitInstType *clone() const override { return new TraitInstType( *this ); } |
---|
| 558 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 559 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 560 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[c8ffe20b] | 561 | private: |
---|
[d67cdb7] | 562 | virtual std::string typeString() const override; |
---|
[51b7345] | 563 | }; |
---|
| 564 | |
---|
[c8ffe20b] | 565 | class TypeInstType : public ReferenceToType { |
---|
[0dd3a2f] | 566 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 567 | public: |
---|
[65cdc1e] | 568 | // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree, |
---|
| 569 | // where the type used here is actually defined |
---|
| 570 | TypeDecl *baseType; |
---|
| 571 | bool isFtype; |
---|
| 572 | |
---|
[f2e40a9f] | 573 | TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
| 574 | TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
| 575 | TypeInstType( const TypeInstType & other ); |
---|
[1e8b02f5] | 576 | ~TypeInstType(); |
---|
[0dd3a2f] | 577 | |
---|
| 578 | TypeDecl *get_baseType() const { return baseType; } |
---|
| 579 | void set_baseType( TypeDecl *newValue ); |
---|
| 580 | bool get_isFtype() const { return isFtype; } |
---|
| 581 | void set_isFtype( bool newValue ) { isFtype = newValue; } |
---|
[ae63a18] | 582 | |
---|
[d67cdb7] | 583 | virtual bool isComplete() const override; |
---|
[4a9ccc3] | 584 | |
---|
[d67cdb7] | 585 | virtual TypeInstType *clone() const override { return new TypeInstType( *this ); } |
---|
| 586 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 587 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 588 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 589 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[c8ffe20b] | 590 | private: |
---|
[d67cdb7] | 591 | virtual std::string typeString() const override; |
---|
[51b7345] | 592 | }; |
---|
| 593 | |
---|
[c8ffe20b] | 594 | class TupleType : public Type { |
---|
| 595 | public: |
---|
[65cdc1e] | 596 | std::list<Type *> types; |
---|
| 597 | std::list<Declaration *> members; |
---|
| 598 | |
---|
[62423350] | 599 | TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[0dd3a2f] | 600 | TupleType( const TupleType& ); |
---|
| 601 | virtual ~TupleType(); |
---|
[51b7345] | 602 | |
---|
[0362d42] | 603 | typedef std::list<Type*> value_type; |
---|
| 604 | typedef value_type::iterator iterator; |
---|
| 605 | |
---|
[62423350] | 606 | std::list<Type *> & get_types() { return types; } |
---|
[d67cdb7] | 607 | virtual unsigned size() const override { return types.size(); }; |
---|
[51b7345] | 608 | |
---|
[62423350] | 609 | // For now, this is entirely synthetic -- tuple types always have unnamed members. |
---|
| 610 | // Eventually, we may allow named tuples, in which case members should subsume types |
---|
| 611 | std::list<Declaration *> & get_members() { return members; } |
---|
| 612 | |
---|
[0362d42] | 613 | iterator begin() { return types.begin(); } |
---|
| 614 | iterator end() { return types.end(); } |
---|
| 615 | |
---|
[d67cdb7] | 616 | virtual Type * getComponent( unsigned i ) override { |
---|
[7933351] | 617 | assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", i, size() ); |
---|
| 618 | return *(begin()+i); |
---|
| 619 | } |
---|
| 620 | |
---|
[d67cdb7] | 621 | // virtual bool isComplete() const override { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness |
---|
[4a9ccc3] | 622 | |
---|
[d67cdb7] | 623 | virtual TupleType *clone() const override { return new TupleType( *this ); } |
---|
| 624 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 625 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 626 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 627 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[51b7345] | 628 | }; |
---|
| 629 | |
---|
[c8ffe20b] | 630 | class TypeofType : public Type { |
---|
| 631 | public: |
---|
[f441c88] | 632 | Expression *expr; ///< expression to take the type of |
---|
| 633 | bool is_basetypeof; ///< true iff is basetypeof type |
---|
[65cdc1e] | 634 | |
---|
[f441c88] | 635 | TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[7870799] | 636 | TypeofType( const Type::Qualifiers & tq, Expression *expr, bool is_basetypeof, |
---|
[f441c88] | 637 | const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[0dd3a2f] | 638 | TypeofType( const TypeofType& ); |
---|
| 639 | virtual ~TypeofType(); |
---|
[51b7345] | 640 | |
---|
[0dd3a2f] | 641 | Expression *get_expr() const { return expr; } |
---|
| 642 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
[51b7345] | 643 | |
---|
[d67cdb7] | 644 | virtual bool isComplete() const override { assert( false ); return false; } |
---|
[4a9ccc3] | 645 | |
---|
[d67cdb7] | 646 | virtual TypeofType *clone() const override { return new TypeofType( *this ); } |
---|
| 647 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 648 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 649 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 650 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[51b7345] | 651 | }; |
---|
| 652 | |
---|
[c8ffe20b] | 653 | class AttrType : public Type { |
---|
| 654 | public: |
---|
[65cdc1e] | 655 | std::string name; |
---|
| 656 | Expression *expr; |
---|
| 657 | Type *type; |
---|
| 658 | bool isType; |
---|
| 659 | |
---|
[f2e40a9f] | 660 | AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
| 661 | AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[0dd3a2f] | 662 | AttrType( const AttrType& ); |
---|
| 663 | virtual ~AttrType(); |
---|
| 664 | |
---|
[f2e40a9f] | 665 | const std::string & get_name() const { return name; } |
---|
| 666 | void set_name( const std::string & newValue ) { name = newValue; } |
---|
[0dd3a2f] | 667 | Expression *get_expr() const { return expr; } |
---|
| 668 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
| 669 | Type *get_type() const { return type; } |
---|
| 670 | void set_type( Type *newValue ) { type = newValue; } |
---|
| 671 | bool get_isType() const { return isType; } |
---|
| 672 | void set_isType( bool newValue ) { isType = newValue; } |
---|
| 673 | |
---|
[d67cdb7] | 674 | virtual bool isComplete() const override { assert( false ); } // xxx - not sure what to do here |
---|
[4a9ccc3] | 675 | |
---|
[d67cdb7] | 676 | virtual AttrType *clone() const override { return new AttrType( *this ); } |
---|
| 677 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 678 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 679 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 680 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[51b7345] | 681 | }; |
---|
| 682 | |
---|
[44b7088] | 683 | /// Represents the GCC built-in varargs type |
---|
| 684 | class VarArgsType : public Type { |
---|
[90c3b1c] | 685 | public: |
---|
[44b7088] | 686 | VarArgsType(); |
---|
[c0aa336] | 687 | VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[44b7088] | 688 | |
---|
[d67cdb7] | 689 | virtual bool isComplete() const override{ return true; } // xxx - is this right? |
---|
[4a9ccc3] | 690 | |
---|
[d67cdb7] | 691 | virtual VarArgsType *clone() const override { return new VarArgsType( *this ); } |
---|
| 692 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 693 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 694 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 695 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[44b7088] | 696 | }; |
---|
| 697 | |
---|
[89e6ffc] | 698 | /// Represents a zero constant |
---|
| 699 | class ZeroType : public Type { |
---|
| 700 | public: |
---|
| 701 | ZeroType(); |
---|
[c0aa336] | 702 | ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[89e6ffc] | 703 | |
---|
[d67cdb7] | 704 | virtual ZeroType *clone() const override { return new ZeroType( *this ); } |
---|
| 705 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 706 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 707 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 708 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[89e6ffc] | 709 | }; |
---|
| 710 | |
---|
| 711 | /// Represents a one constant |
---|
| 712 | class OneType : public Type { |
---|
| 713 | public: |
---|
| 714 | OneType(); |
---|
[c0aa336] | 715 | OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); |
---|
[89e6ffc] | 716 | |
---|
[d67cdb7] | 717 | virtual OneType *clone() const override { return new OneType( *this ); } |
---|
| 718 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 719 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[d67cdb7] | 720 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
[50377a4] | 721 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
[89e6ffc] | 722 | }; |
---|
| 723 | |
---|
[47498bd] | 724 | class GlobalScopeType : public Type { |
---|
| 725 | public: |
---|
| 726 | GlobalScopeType(); |
---|
| 727 | |
---|
| 728 | virtual GlobalScopeType *clone() const override { return new GlobalScopeType( *this ); } |
---|
| 729 | virtual void accept( Visitor & v ) override { v.visit( this ); } |
---|
[7870799] | 730 | virtual void accept( Visitor & v ) const override { v.visit( this ); } |
---|
[47498bd] | 731 | virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } |
---|
| 732 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
| 733 | }; |
---|
| 734 | |
---|
[0dd3a2f] | 735 | // Local Variables: // |
---|
| 736 | // tab-width: 4 // |
---|
| 737 | // mode: c++ // |
---|
| 738 | // compile-command: "make install" // |
---|
| 739 | // End: // |
---|