- Timestamp:
- Jul 23, 2020, 2:42:23 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- d1ee9ec
- Parents:
- a8ed717
- Location:
- src/AST
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Fwd.hpp
ra8ed717 r923d25a 10 10 // Created On : Wed May 8 16:05:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 24 09:48:00 201913 // Update Count : 112 // Last Modified On : Thr Jul 23 14:15:00 2020 13 // Update Count : 2 14 14 // 15 15 … … 108 108 class FunctionType; 109 109 class ReferenceToType; 110 class StructInstType; 111 class UnionInstType; 112 class EnumInstType; 110 template<typename decl_t> class SueInstType; 111 using StructInstType = SueInstType<StructDecl>; 112 using UnionInstType = SueInstType<UnionDecl>; 113 using EnumInstType = SueInstType<EnumDecl>; 113 114 class TraitInstType; 114 115 class TypeInstType; -
src/AST/Type.cpp
ra8ed717 r923d25a 9 9 // Author : Aaron B. Moss 10 10 // Created On : Mon May 13 15:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Dec 15 16:56:28 201913 // Update Count : 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jul 23 14:16:00 2020 13 // Update Count : 5 14 14 // 15 15 … … 148 148 } 149 149 150 // --- StructInstType 151 152 StructInstType::StructInstType( 153 const StructDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 150 // --- SueInstType (StructInstType, UnionInstType, EnumInstType) 151 152 template<typename decl_t> 153 SueInstType<decl_t>::SueInstType( 154 const decl_t * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 154 155 : ReferenceToType( b->name, q, move(as) ), base( b ) {} 155 156 156 bool StructInstType::isComplete() const { return base ? base->body : false; } 157 158 // --- UnionInstType 159 160 UnionInstType::UnionInstType( 161 const UnionDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 162 : ReferenceToType( b->name, q, move(as) ), base( b ) {} 163 164 bool UnionInstType::isComplete() const { return base ? base->body : false; } 165 166 // --- EnumInstType 167 168 EnumInstType::EnumInstType( 169 const EnumDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 170 : ReferenceToType( b->name, q, move(as) ), base( b ) {} 171 172 bool EnumInstType::isComplete() const { return base ? base->body : false; } 157 template<typename decl_t> 158 bool SueInstType<decl_t>::isComplete() const { 159 return base ? base->body : false; 160 } 161 162 template class SueInstType<StructDecl>; 163 template class SueInstType<UnionDecl>; 164 template class SueInstType<EnumDecl>; 173 165 174 166 // --- TraitInstType -
src/AST/Type.hpp
ra8ed717 r923d25a 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Dec 11 21:56:46 201913 // Update Count : 511 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jul 23 14:15:00 2020 13 // Update Count : 6 14 14 // 15 15 … … 354 354 }; 355 355 356 /// instance of struct type 357 class StructInstType final : public ReferenceToType { 358 public: 359 readonly<StructDecl> base; 360 361 StructInstType( 356 // Common implementation for the SUE instance types. Not to be used directly. 357 template<typename decl_t> 358 class SueInstType final : public ReferenceToType { 359 public: 360 using base_type = decl_t; 361 readonly<decl_t> base; 362 363 SueInstType( 362 364 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 363 365 : ReferenceToType( n, q, std::move(as) ), base() {} 364 366 365 S tructInstType(366 const StructDecl* b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} );367 SueInstType( 368 const decl_t * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 367 369 368 370 bool isComplete() const override; 369 371 370 const StructDecl * aggr() const override { return base; } 371 372 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 373 private: 374 StructInstType * clone() const override { return new StructInstType{ *this }; } 375 MUTATE_FRIEND 376 }; 377 378 /// instance of union type 379 class UnionInstType final : public ReferenceToType { 380 public: 381 readonly<UnionDecl> base; 382 383 UnionInstType( 384 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 385 : ReferenceToType( n, q, std::move(as) ), base() {} 386 387 UnionInstType( 388 const UnionDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 389 390 bool isComplete() const override; 391 392 const UnionDecl * aggr() const override { return base; } 393 394 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 395 private: 396 UnionInstType * clone() const override { return new UnionInstType{ *this }; } 397 MUTATE_FRIEND 398 }; 399 400 /// instance of enum type 401 class EnumInstType final : public ReferenceToType { 402 public: 403 readonly<EnumDecl> base; 404 405 EnumInstType( 406 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 407 : ReferenceToType( n, q, std::move(as) ), base() {} 408 409 EnumInstType( 410 const EnumDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 411 412 bool isComplete() const override; 413 414 const EnumDecl * aggr() const override { return base; } 415 416 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 417 private: 418 EnumInstType * clone() const override { return new EnumInstType{ *this }; } 419 MUTATE_FRIEND 420 }; 421 422 /// instance of trait type 372 const decl_t * aggr() const override { return base; } 373 374 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 375 private: 376 SueInstType<decl_t> * clone() const override { return new SueInstType<decl_t>{ *this }; } 377 MUTATE_FRIEND 378 }; 379 380 /// An instance of a struct type. 381 using StructInstType = SueInstType<StructDecl>; 382 383 /// An instance of a union type. 384 using UnionInstType = SueInstType<UnionDecl>; 385 386 /// An instance of an enum type. 387 using EnumInstType = SueInstType<EnumDecl>; 388 389 /// An instance of a trait type. 423 390 class TraitInstType final : public ReferenceToType { 424 391 public:
Note: See TracChangeset
for help on using the changeset viewer.