Changeset 5625427
- Timestamp:
- Nov 13, 2023, 3:41:02 PM (13 months ago)
- Branches:
- master
- Children:
- 8d182b1
- Parents:
- 6ea85b22
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/SpecCost.cc
r6ea85b22 r5625427 16 16 #include <cassert> 17 17 #include <limits> 18 #include <list>19 18 #include <type_traits> 20 19 … … 25 24 26 25 namespace { 26 27 const ast::Type * expr_result( const ast::ptr< ast::Expr > & expr ) { 28 return expr->result.get(); 29 } 30 31 const ast::Type * type_deref( const ast::ptr< ast::Type > & type ) { 32 return type.get(); 33 } 34 27 35 /// The specialization counter inner class. 28 36 class SpecCounter : public ast::WithShortCircuiting, public ast::WithVisitorRef<SpecCounter> { … … 38 46 typename std::add_pointer<ast::Type const *(typename T::value_type const &)>::type; 39 47 40 #warning Should use a standard maybe_accept41 void maybe_accept( ast::Type const * type ) {42 if ( type ) {43 auto node = type->accept( *visitor );44 assert( node == nullptr || node == type );45 }46 }47 48 48 // Update the minimum to the new lowest non-none value. 49 49 template<typename T> … … 51 51 for ( const auto & node : list ) { 52 52 count = -1; 53 maybe_accept( mapper( node ) ); 53 54 if ( ast::Type const * type = mapper( node ) ) { 55 ast::Type const * newType = type->accept( *visitor ); 56 assert( newType == nullptr || newType == type ); 57 } 58 54 59 if ( count != -1 && count < minimum ) minimum = count; 55 60 } … … 62 67 updateMinimumPresent( minCount, list, mapper ); 63 68 return toNoneOrInc( minCount ); 64 }65 66 // The three mappers:67 static const ast::Type * decl_type( const ast::ptr< ast::DeclWithType > & decl ) {68 return decl->get_type();69 }70 static const ast::Type * expr_result( const ast::ptr< ast::Expr > & expr ) {71 return expr->result;72 }73 static const ast::Type * type_deref( const ast::ptr< ast::Type > & type ) {74 return type.get();75 69 } 76 70 … … 122 116 123 117 int specCost( const ast::Type * type ) { 124 if ( nullptr == type ) { 125 return 0; 126 } 127 return ast::Pass<SpecCounter>::read( type ); 118 return ( nullptr == type ) ? 0 : ast::Pass<SpecCounter>::read( type ); 128 119 } 129 120
Note: See TracChangeset
for help on using the changeset viewer.