Changeset 3f681b1 for src/AST/Util.cpp
- Timestamp:
- May 11, 2022, 11:33:21 AM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 7675f58
- Parents:
- e6bb667
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Util.cpp
re6bb667 r3f681b1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Util. hpp -- General utilities for working with the AST.7 // Util.cpp -- General utilities for working with the AST. 8 8 // 9 9 // Author : Andrew Beach 10 10 // Created On : Wed Jan 19 9:46:00 2022 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 11 18:07:00 202213 // Update Count : 112 // Last Modified On : Wed May 4 15:50:00 2022 13 // Update Count : 2 14 14 // 15 15 … … 46 46 47 47 /// Check that every note that can has a set CodeLocation. 48 struct SetCodeLocationsCore { 49 void previsit( const ParseNode * node ) { 50 assert( node->location.isSet() ); 48 void isCodeLocationSet( const ParseNode * node ) { 49 assert( node->location.isSet() ); 50 } 51 52 /// Make sure the reference counts are in a valid combination. 53 void isStable( const Node * node ) { 54 assert( node->isStable() ); 55 } 56 57 /// Check that a FunctionDecl is synchronized with it's FunctionType. 58 void functionDeclMatchesType( const FunctionDecl * decl ) { 59 // The type is a cache of sorts, if it is missing that is only a 60 // problem if isTypeFixed is set. 61 if ( decl->isTypeFixed ) { 62 assert( decl->type ); 63 } else if ( !decl->type ) { 64 return; 51 65 } 52 }; 66 67 const FunctionType * type = decl->type; 68 69 // Check that `type->forall` corresponds with `decl->type_params`. 70 assert( type->forall.size() == decl->type_params.size() ); 71 // Check that `type->assertions` corresponds with `decl->assertions`. 72 assert( type->assertions.size() == decl->assertions.size() ); 73 // Check that `type->params` corresponds with `decl->params`. 74 assert( type->params.size() == decl->params.size() ); 75 // Check that `type->returns` corresponds with `decl->returns`. 76 assert( type->returns.size() == decl->returns.size() ); 77 } 53 78 54 79 struct InvariantCore { … … 56 81 // None of the passes should make changes so ordering doesn't matter. 57 82 NoStrongCyclesCore no_strong_cycles; 58 SetCodeLocationsCore set_code_locations;59 83 60 84 void previsit( const Node * node ) { 61 85 no_strong_cycles.previsit( node ); 86 isStable( node ); 62 87 } 63 88 64 89 void previsit( const ParseNode * node ) { 65 no_strong_cycles.previsit( node ); 66 set_code_locations.previsit( node ); 90 previsit( (const Node *)node ); 91 isCodeLocationSet( node ); 92 } 93 94 void previsit( const FunctionDecl * node ) { 95 previsit( (const ParseNode *)node ); 96 functionDeclMatchesType( node ); 67 97 } 68 98
Note: See TracChangeset
for help on using the changeset viewer.