- Timestamp:
- May 21, 2019, 4:33:30 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- a1b154d, b869ec5
- Parents:
- a83044fb
- Location:
- src/AST
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
ra83044fb r514a791 50 50 ConverterNewToOld & visitor; 51 51 52 template<typename U >53 T * accept1( const ast::ptr <U> & ptr ) {52 template<typename U, enum ast::Node::ref_type R> 53 T * accept1( const ast::ptr_base<U, R> & ptr ) { 54 54 if ( ! ptr ) return nullptr; 55 55 ptr->accept( visitor ); … … 95 95 96 96 template<typename NewT, typename OldT> 97 NewT * cached( OldT * old ) { 98 auto it = cache.find( old ); 99 // doesn't update cache, that should be handled by the accept function 100 ast::Node * nw = it == cache.end() ? getAccept1< NewT >( old ) : it->second; 101 return strict_dynamic_cast< NewT * >( nw ); 97 NewT * cached( const OldT & old ) { 98 auto it = cache.find( old.get() ); 99 if ( it == cache.end() ) { 100 // doesn't update cache, that should be handled by the accept function 101 return get< NewT >().accept1( old ); 102 } else { 103 return strict_dynamic_cast< NewT * >( it->second ); 104 } 102 105 } 103 106 … … 797 800 ty->parameters = get<DeclarationWithType>().acceptL( node->params ); 798 801 ty->forall = get<TypeDecl>().acceptL( node->forall ); 799 node = ty;802 this->node = ty; 800 803 return nullptr; 801 804 } … … 1679 1682 1680 1683 virtual void visit( TypeInstType * old ) override final { 1681 auto ty = new ast::TypeInstType{ 1682 cached< ast::TypeDecl >( old->baseStruct ), 1683 cv( old ), 1684 GET_ACCEPT_V( attributes, Attribute ) 1685 }; 1684 ast::TypeInstType * ty; 1685 if ( old->baseType ) { 1686 ty = new ast::TypeInstType{ 1687 old->name, 1688 cached< ast::TypeDecl >( old->baseType ), 1689 cv( old ), 1690 GET_ACCEPT_V( attributes, Attribute ) 1691 }; 1692 } else { 1693 ty = new ast::TypeInstType{ 1694 old->name, 1695 old->isFtype ? ast::TypeVar::Ftype : ast::TypeVar::Dtype, 1696 cv( old ), 1697 GET_ACCEPT_V( attributes, Attribute ) 1698 }; 1699 } 1686 1700 postvisit( old, ty ); 1687 1701 this->node = ty; -
src/AST/Type.cpp
ra83044fb r514a791 141 141 bool EnumInstType::isComplete() const { return base ? base->body : false; } 142 142 143 // --- TraitInstType 144 145 TraitInstType::TraitInstType( const TraitDecl * b, CV::Qualifiers q, 146 std::vector<ptr<Attribute>>&& as ) 147 : ReferenceToType( b->name, q, std::move(as) ), base( b ) {} 148 143 149 // --- TypeInstType 144 150
Note: See TracChangeset
for help on using the changeset viewer.