ADT
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
      
| Line |  | 
|---|
| 1 | // | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo | 
|---|
| 3 | // | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
| 5 | // file "LICENCE" distributed with Cforall. | 
|---|
| 6 | // | 
|---|
| 7 | // AssertAcyclic.cpp -- Check that ast::ptr does not form a cycle. | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Andrew Beach | 
|---|
| 10 | // Created On       : Thu Jun 06 15:00:00 2019 | 
|---|
| 11 | // Last Modified By : Andrew Beach | 
|---|
| 12 | // Last Modified On : Fri Jun 07 14:32:00 2019 | 
|---|
| 13 | // Update Count     : 1 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #include "AssertAcyclic.hpp" | 
|---|
| 17 |  | 
|---|
| 18 | #include "AST/Pass.hpp" | 
|---|
| 19 |  | 
|---|
| 20 | namespace { | 
|---|
| 21 |  | 
|---|
| 22 | class NoStrongCyclesCore { | 
|---|
| 23 | std::vector<const ast::Node *> parents; | 
|---|
| 24 | public: | 
|---|
| 25 | void previsit( const ast::Node * node ) { | 
|---|
| 26 | for (auto & parent : parents) { | 
|---|
| 27 | assert(parent != node); | 
|---|
| 28 | } | 
|---|
| 29 | parents.push_back(node); | 
|---|
| 30 | } | 
|---|
| 31 | void postvisit( const ast::Node * ) { | 
|---|
| 32 | parents.pop_back(); | 
|---|
| 33 | } | 
|---|
| 34 | }; | 
|---|
| 35 |  | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | namespace ast { | 
|---|
| 39 |  | 
|---|
| 40 | void assertAcyclic( const std::list< ast::ptr< ast::Decl > > & translationUnit ) { | 
|---|
| 41 | Pass<NoStrongCyclesCore> visitor; | 
|---|
| 42 | for ( auto & decl : translationUnit ) { | 
|---|
| 43 | decl->accept( visitor ); | 
|---|
| 44 | } | 
|---|
| 45 | } | 
|---|
| 46 |  | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | // Local Variables: // | 
|---|
| 50 | // tab-width: 4 // | 
|---|
| 51 | // mode: c++ // | 
|---|
| 52 | // compile-command: "make install" // | 
|---|
| 53 | // End: // | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.