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