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