Changeset 373d0b5
- Timestamp:
- Dec 1, 2017, 2:49:52 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 81644e0
- Parents:
- a378ca7
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/InstantiateGeneric.cc
ra378ca7 r373d0b5 453 453 return false; 454 454 } 455 456 AggregateDecl * getAggr( Type * t ) {457 if ( StructInstType * inst = dynamic_cast< StructInstType * >( t ) ) {458 return inst->baseStruct;459 } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( t ) ) {460 return inst->baseUnion;461 }462 assertf( false, "Non-aggregate type: %s", toString( t ).c_str() );463 }464 455 } 465 456 … … 469 460 if ( isGenericType( memberExpr->aggregate->result ) ) { 470 461 // find the location of the member 471 AggregateDecl * aggr = getAggr( memberExpr->aggregate->result);462 AggregateDecl * aggr = memberExpr->aggregate->result->getAggr(); 472 463 std::list< Declaration * > & members = aggr->members; 473 464 memberIndex = std::distance( members.begin(), std::find( members.begin(), members.end(), memberExpr->member ) ); … … 479 470 if ( memberIndex != -1 ) { 480 471 // using the location from the generic type, find the member in the instantiation and rebuild the member expression 481 AggregateDecl * aggr = getAggr( memberExpr->aggregate->result);472 AggregateDecl * aggr = memberExpr->aggregate->result->getAggr(); 482 473 assertf( memberIndex < (int)aggr->members.size(), "Instantiation somehow has fewer members than the generic type." ); 483 474 Declaration * member = *std::next( aggr->members.begin(), memberIndex ); -
src/SynTree/ReferenceToType.cc
ra378ca7 r373d0b5 70 70 bool StructInstType::isComplete() const { return baseStruct ? baseStruct->has_body() : false; } 71 71 72 AggregateDecl * StructInstType::getAggr() { return baseStruct; } 73 72 74 void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 73 75 assert( baseStruct ); … … 101 103 102 104 bool UnionInstType::isComplete() const { return baseUnion ? baseUnion->has_body() : false; } 105 106 AggregateDecl * UnionInstType::getAggr() { return baseUnion; } 103 107 104 108 void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { -
src/SynTree/Type.h
ra378ca7 r373d0b5 178 178 virtual bool isComplete() const { return true; } 179 179 180 virtual AggregateDecl * getAggr() { assertf( false, "Non-aggregate type: %s", toString( this ).c_str() ); } 181 180 182 virtual Type *clone() const = 0; 181 183 virtual void accept( Visitor & v ) = 0; … … 405 407 virtual bool isComplete() const override; 406 408 409 virtual AggregateDecl * getAggr() override; 410 407 411 /// Looks up the members of this struct named "name" and places them into "foundDecls". 408 412 /// Clones declarations into "foundDecls", caller responsible for freeing … … 436 440 437 441 virtual bool isComplete() const override; 442 443 virtual AggregateDecl * getAggr() override; 438 444 439 445 /// looks up the members of this union named "name" and places them into "foundDecls"
Note: See TracChangeset
for help on using the changeset viewer.