Changeset 7a36848 for src


Ignore:
Timestamp:
Apr 12, 2024, 4:40:06 PM (2 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
b1b3df5, dc58e5d
Parents:
90320ac
Message:

Further Pass template clean-up, reimplementing the translation unit getter with the standard tools. The only time we needed a mutable TranslationUnit/TranslationGlobal? it was implemented manually anyways.

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r90320ac r7a36848  
    406406template< typename core_t >
    407407inline void ast::accept_all( ast::TranslationUnit & unit, ast::Pass< core_t > & visitor ) {
    408         if ( auto ptr = __pass::translation_unit::get_cptr( visitor.core, 0 ) ) {
     408        if ( auto ptr = __pass::translationUnit( visitor.core, 0 ) ) {
    409409                ValueGuard<const TranslationUnit *> guard( *ptr );
    410410                *ptr = &unit;
  • src/AST/Pass.proto.hpp

    r90320ac r7a36848  
    257257        } else {
    258258                node = core.previsit( node );
    259                 assertf(node, "Previsit must not return NULL");
     259                assertf( node, "Previsit must not return nullptr." );
    260260        }
    261261}
     
    310310FIELD_PTR( at_cleanup, __pass::at_cleanup_t )
    311311FIELD_PTR( visitor, ast::Pass<core_t> * const )
     312FIELD_PTR( translationUnit, const TranslationUnit * )
    312313
    313314// Remove the macro to make sure we don't clash
     
    506507} // namespace forall
    507508
    508 // For passes that need access to the global context. Searches `translationUnit`
    509 namespace translation_unit {
    510         template<typename core_t>
    511         static inline auto get_cptr( core_t & core, int )
    512                         -> decltype( &core.translationUnit ) {
    513                 return &core.translationUnit;
    514         }
    515 
    516         template<typename core_t>
    517         static inline const TranslationUnit ** get_cptr( core_t &, long ) {
    518                 return nullptr;
    519         }
    520 }
    521 
    522509// For passes, usually utility passes, that have a result.
    523510namespace result {
Note: See TracChangeset for help on using the changeset viewer.