- Timestamp:
- Sep 10, 2020, 11:26:58 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- ae45007
- Parents:
- b9fa85b
- Location:
- src/AST
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rb9fa85b r98e8b3b 1162 1162 } 1163 1163 1164 const ast::Type * postvisit( const ast:: ReferenceToType * old, ReferenceToType * ty ) {1164 const ast::Type * postvisit( const ast::BaseInstType * old, ReferenceToType * ty ) { 1165 1165 ty->forall = get<TypeDecl>().acceptL( old->forall ); 1166 1166 ty->parameters = get<Expression>().acceptL( old->params ); … … 2521 2521 } 2522 2522 2523 void postvisit( const ReferenceToType * old, ast:: ReferenceToType * ty ) {2523 void postvisit( const ReferenceToType * old, ast::BaseInstType * ty ) { 2524 2524 ty->forall = GET_ACCEPT_V( forall, TypeDecl ); 2525 2525 ty->params = GET_ACCEPT_V( parameters, Expr ); -
src/AST/Fwd.hpp
rb9fa85b r98e8b3b 107 107 class QualifiedType; 108 108 class FunctionType; 109 class ReferenceToType;109 class BaseInstType; 110 110 template<typename decl_t> class SueInstType; 111 111 using StructInstType = SueInstType<StructDecl>; -
src/AST/GenericSubstitution.cpp
rb9fa85b r98e8b3b 42 42 private: 43 43 // make substitution for generic type 44 void makeSub( const ReferenceToType * ty ) {44 void makeSub( const BaseInstType * ty ) { 45 45 visit_children = false; 46 46 const AggregateDecl * aggr = ty->aggr(); -
src/AST/Node.cpp
rb9fa85b r98e8b3b 266 266 template class ast::ptr_base< ast::FunctionType, ast::Node::ref_type::weak >; 267 267 template class ast::ptr_base< ast::FunctionType, ast::Node::ref_type::strong >; 268 template class ast::ptr_base< ast:: ReferenceToType, ast::Node::ref_type::weak >;269 template class ast::ptr_base< ast:: ReferenceToType, ast::Node::ref_type::strong >;268 template class ast::ptr_base< ast::BaseInstType, ast::Node::ref_type::weak >; 269 template class ast::ptr_base< ast::BaseInstType, ast::Node::ref_type::strong >; 270 270 template class ast::ptr_base< ast::StructInstType, ast::Node::ref_type::weak >; 271 271 template class ast::ptr_base< ast::StructInstType, ast::Node::ref_type::strong >; -
src/AST/Print.cpp
rb9fa85b r98e8b3b 270 270 } 271 271 272 void preprint( const ast:: ReferenceToType * node ) {272 void preprint( const ast::BaseInstType * node ) { 273 273 print( node->forall ); 274 274 print( node->attributes ); -
src/AST/SymbolTable.cpp
rb9fa85b r98e8b3b 313 313 if ( ! expr->result ) continue; 314 314 const Type * resTy = expr->result->stripReferences(); 315 auto aggrType = dynamic_cast< const ReferenceToType * >( resTy );315 auto aggrType = dynamic_cast< const BaseInstType * >( resTy ); 316 316 assertf( aggrType, "WithStmt expr has non-aggregate type: %s", 317 317 toString( expr->result ).c_str() ); … … 654 654 if ( dwt->name == "" ) { 655 655 const Type * t = dwt->get_type()->stripReferences(); 656 if ( auto rty = dynamic_cast<const ReferenceToType *>( t ) ) {656 if ( auto rty = dynamic_cast<const BaseInstType *>( t ) ) { 657 657 if ( ! dynamic_cast<const StructInstType *>(rty) 658 658 && ! dynamic_cast<const UnionInstType *>(rty) ) continue; -
src/AST/Type.cpp
rb9fa85b r98e8b3b 124 124 } 125 125 126 // --- ReferenceToType127 128 void ReferenceToType::initWithSub( const ReferenceToType & o, Pass< ForallSubstitutor > & sub ) {126 // --- BaseInstType 127 128 void BaseInstType::initWithSub( const BaseInstType & o, Pass< ForallSubstitutor > & sub ) { 129 129 ParameterizedType::initWithSub( o, sub ); // initialize substitution 130 130 params = sub.core( o.params ); // apply to parameters 131 131 } 132 132 133 ReferenceToType::ReferenceToType( const ReferenceToType & o )133 BaseInstType::BaseInstType( const BaseInstType & o ) 134 134 : ParameterizedType( o.qualifiers, copy( o.attributes ) ), params(), name( o.name ), 135 135 hoistType( o.hoistType ) { … … 138 138 } 139 139 140 std::vector<readonly<Decl>> ReferenceToType::lookup( const std::string& name ) const {140 std::vector<readonly<Decl>> BaseInstType::lookup( const std::string& name ) const { 141 141 assertf( aggr(), "Must have aggregate to perform lookup" ); 142 142 … … 153 153 SueInstType<decl_t>::SueInstType( 154 154 const decl_t * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 155 : ReferenceToType( b->name, q, move(as) ), base( b ) {}155 : BaseInstType( b->name, q, move(as) ), base( b ) {} 156 156 157 157 template<typename decl_t> … … 168 168 TraitInstType::TraitInstType( 169 169 const TraitDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 170 : ReferenceToType( b->name, q, move(as) ), base( b ) {}170 : BaseInstType( b->name, q, move(as) ), base( b ) {} 171 171 172 172 // --- TypeInstType 173 173 174 174 TypeInstType::TypeInstType( const TypeInstType & o ) 175 : ReferenceToType( o.name, o.qualifiers, copy( o.attributes ) ), base(), kind( o.kind ) {175 : BaseInstType( o.name, o.qualifiers, copy( o.attributes ) ), base(), kind( o.kind ) { 176 176 Pass< ForallSubstitutor > sub; 177 177 initWithSub( o, sub ); // initialize substitution -
src/AST/Type.hpp
rb9fa85b r98e8b3b 329 329 330 330 /// base class for types that refer to types declared elsewhere (aggregates and typedefs) 331 class ReferenceToType : public ParameterizedType {331 class BaseInstType : public ParameterizedType { 332 332 protected: 333 333 /// Initializes forall and parameters based on substitutor 334 void initWithSub( const ReferenceToType & o, Pass< ForallSubstitutor > & sub );334 void initWithSub( const BaseInstType & o, Pass< ForallSubstitutor > & sub ); 335 335 public: 336 336 std::vector<ptr<Expr>> params; … … 338 338 bool hoistType = false; 339 339 340 ReferenceToType(340 BaseInstType( 341 341 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 342 342 : ParameterizedType(q, std::move(as)), params(), name(n) {} 343 343 344 ReferenceToType( const ReferenceToType & o );344 BaseInstType( const BaseInstType & o ); 345 345 346 346 /// Gets aggregate declaration this type refers to … … 350 350 351 351 private: 352 virtual ReferenceToType * clone() const override = 0;352 virtual BaseInstType * clone() const override = 0; 353 353 MUTATE_FRIEND 354 354 }; … … 356 356 // Common implementation for the SUE instance types. Not to be used directly. 357 357 template<typename decl_t> 358 class SueInstType final : public ReferenceToType {358 class SueInstType final : public BaseInstType { 359 359 public: 360 360 using base_type = decl_t; … … 363 363 SueInstType( 364 364 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 365 : ReferenceToType( n, q, std::move(as) ), base() {}365 : BaseInstType( n, q, std::move(as) ), base() {} 366 366 367 367 SueInstType( … … 388 388 389 389 /// An instance of a trait type. 390 class TraitInstType final : public ReferenceToType {390 class TraitInstType final : public BaseInstType { 391 391 public: 392 392 readonly<TraitDecl> base; … … 394 394 TraitInstType( 395 395 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 396 : ReferenceToType( n, q, std::move(as) ), base() {}396 : BaseInstType( n, q, std::move(as) ), base() {} 397 397 398 398 TraitInstType( … … 411 411 412 412 /// instance of named type alias (typedef or variable) 413 class TypeInstType final : public ReferenceToType {413 class TypeInstType final : public BaseInstType { 414 414 public: 415 415 readonly<TypeDecl> base; … … 419 419 const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 420 420 std::vector<ptr<Attribute>> && as = {} ) 421 : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {}421 : BaseInstType( n, q, std::move(as) ), base( b ), kind( b->kind ) {} 422 422 TypeInstType( const std::string& n, TypeDecl::Kind k, CV::Qualifiers q = {}, 423 423 std::vector<ptr<Attribute>> && as = {} ) 424 : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {}424 : BaseInstType( n, q, std::move(as) ), base(), kind( k ) {} 425 425 426 426 TypeInstType( const TypeInstType & o ); -
src/AST/TypeSubstitution.cpp
rb9fa85b r98e8b3b 176 176 } 177 177 178 void TypeSubstitution::Substituter::handleAggregateType( const ReferenceToType * type ) {178 void TypeSubstitution::Substituter::handleAggregateType( const BaseInstType * type ) { 179 179 GuardValue( boundVars ); 180 180 // bind type variables from forall-qualifiers -
src/AST/TypeSubstitution.hpp
rb9fa85b r98e8b3b 169 169 void previsit( const ParameterizedType * type ); 170 170 /// Records type variable bindings from forall-statements and instantiations of generic types 171 void handleAggregateType( const ReferenceToType * type );171 void handleAggregateType( const BaseInstType * type ); 172 172 173 173 void previsit( const StructInstType * aggregateUseType );
Note:
See TracChangeset
for help on using the changeset viewer.