Changeset be8518f


Ignore:
Timestamp:
Jun 7, 2019, 3:14:07 PM (5 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
05d55ff, 9856ca9
Parents:
ef75948
Message:

Fixed up AssertAcyclic?.

Location:
src/AST
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/AST/AssertAcyclic.cpp

    ref75948 rbe8518f  
    1010// Created On       : Thu Jun 06 15:00:00 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Jun 06 15:00:00 2019
    13 // Update Count     : 0
     12// Last Modified On : Fri Jun 07 14:32:00 2019
     13// Update Count     : 1
    1414//
    1515
     
    2020namespace {
    2121
    22 class NoStrongCyclesCore : public ast::WithGuards {
     22class NoStrongCyclesCore {
    2323    std::vector<const ast::Node *> parents;
    2424public:
    25         void previsit ( const ast::Node * node ) {
    26                 for (auto & p : parents) {
    27                         assert(p != node);
     25        void previsit( const ast::Node * node ) {
     26                for (auto & parent : parents) {
     27                        assert(parent != node);
    2828                }
    2929                parents.push_back(node);
    30                 GuardAction( [this]() { parents.pop_back(); } );
     30        }
     31        void postvisit( const ast::Node * ) {
     32                parents.pop_back();
    3133        }
    3234};
     
    3638namespace ast {
    3739
    38 void assertAcyclic( const std::list< ast::ptr< ast::Decl > > translationUnit ) {
     40void assertAcyclic( const std::list< ast::ptr< ast::Decl > > & translationUnit ) {
    3941        Pass<NoStrongCyclesCore> visitor;
    4042        for ( auto & decl : translationUnit ) {
  • src/AST/AssertAcyclic.hpp

    ref75948 rbe8518f  
    88//
    99// Author           : Andrew Beach
    10 // Created On       : Thr May 6 15:00:00 2019
     10// Created On       : Thr Jun 6 15:00:00 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr May 6 15:00:00 2019
    13 // Update Count     : 0
     12// Last Modified On : Fri Jun  7 14:32:00 2019
     13// Update Count     : 1
    1414//
    1515
     
    2525namespace ast {
    2626
    27 void assertAcyclic( const std::list< ast::ptr< ast::Decl > > translationUnit );
     27void assertAcyclic( const std::list< ast::ptr< ast::Decl > > & translationUnit );
    2828
    2929}
  • src/AST/Pass.hpp

    ref75948 rbe8518f  
    287287                at_cleanup( [func](void *) { func(); }, nullptr );
    288288        }
     289
     290        /// When this node is finished being visited, call a member of an object.
     291        template<typename T>
     292        void GuardMethod( T * obj, void (T::*method)() ) {
     293                at_cleanup( [ method ]( void * object ) {
     294                        static_cast< T * >( object )->method();
     295                }, static_cast< void * >( obj ) );
     296        }
    289297};
    290298
Note: See TracChangeset for help on using the changeset viewer.