Changeset 2b7f6f0
- Timestamp:
- Sep 9, 2020, 3:04:55 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 1c01c58
- Parents:
- 14d8a9b (diff), e6b42e7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.hpp
r14d8a9b r2b7f6f0 67 67 // | WithSymbolTable - provides symbol table functionality 68 68 // | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation 69 // 70 // Other Special Members: 71 // | result - Either a method that takes no parameters or a field. If a method (or 72 // callable field) get_result calls it, otherwise the value is returned. 69 73 //------------------------------------------------------------------------------------------------- 70 74 template< typename core_t > … … 89 93 virtual ~Pass() = default; 90 94 95 /// Storage for the actual pass. 96 core_t core; 97 98 /// If the core defines a result, call it if possible, otherwise return it. 99 inline auto get_result() -> decltype( __pass::get_result( core, '0' ) ) { 100 return __pass::get_result( core, '0' ); 101 } 102 91 103 /// Construct and run a pass on a translation unit. 92 104 template< typename... Args > … … 96 108 } 97 109 98 template< typename... Args > 110 /// Contruct and run a pass on a pointer to extract a value. 111 template< typename node_type, typename... Args > 112 static auto read( node_type const * node, Args&&... args ) { 113 Pass<core_t> visitor( std::forward<Args>( args )... ); 114 node_type const * temp = node->accept( visitor ); 115 assert( temp == node ); 116 return visitor.get_result(); 117 } 118 119 // Versions of the above for older compilers. 99 120 static void run( std::list< ptr<Decl> > & decls ) { 100 121 Pass<core_t> visitor; … … 102 123 } 103 124 104 /// Storage for the actual pass 105 core_t core; 125 static auto read( Node const * node ) { 126 Pass<core_t> visitor; 127 Node const * temp = node->accept( visitor ); 128 assert( temp == node ); 129 return visitor.get_result(); 130 } 106 131 107 132 /// Visit function declarations -
src/AST/Pass.proto.hpp
r14d8a9b r2b7f6f0 421 421 422 422 } // namespace forall 423 424 template<typename core_t> 425 static inline auto get_result( core_t & core, char ) -> decltype( core.result() ) { 426 return core.result(); 427 } 428 429 template<typename core_t> 430 static inline auto get_result( core_t & core, int ) -> decltype( core.result ) { 431 return core.result; 432 } 433 434 template<typename core_t> 435 static inline void get_result( core_t &, long ) {} 423 436 } // namespace __pass 424 437 } // namespace ast -
src/ResolvExpr/ConversionCost.cc
r14d8a9b r2b7f6f0 520 520 return convertToReferenceCost( src, refType, srcIsLvalue, symtab, env, localPtrsAssignable ); 521 521 } else { 522 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost ); 523 src->accept( converter ); 524 return converter.core.cost; 522 return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost ); 525 523 } 526 524 } … … 563 561 } 564 562 } else { 565 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost ); 566 src->accept( converter ); 567 return converter.core.cost; 563 return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost ); 568 564 } 569 565 } else { -
src/ResolvExpr/ConversionCost.h
r14d8a9b r2b7f6f0 88 88 static size_t traceId; 89 89 Cost cost; 90 Cost result() { return cost; } 90 91 91 92 ConversionCost_new( const ast::Type * dst, bool srcIsLvalue, const ast::SymbolTable & symtab, -
src/ResolvExpr/Resolver.cc
r14d8a9b r2b7f6f0 965 965 /// Finds deleted expressions in an expression tree 966 966 struct DeleteFinder_new final : public ast::WithShortCircuiting { 967 const ast::DeletedExpr * delExpr= nullptr;967 const ast::DeletedExpr * result = nullptr; 968 968 969 969 void previsit( const ast::DeletedExpr * expr ) { 970 if ( delExpr) { visit_children = false; }971 else { delExpr= expr; }970 if ( result ) { visit_children = false; } 971 else { result = expr; } 972 972 } 973 973 974 974 void previsit( const ast::Expr * ) { 975 if ( delExpr) { visit_children = false; }975 if ( result ) { visit_children = false; } 976 976 } 977 977 }; … … 980 980 /// Check if this expression is or includes a deleted expression 981 981 const ast::DeletedExpr * findDeletedExpr( const ast::Expr * expr ) { 982 ast::Pass<DeleteFinder_new> finder; 983 expr->accept( finder ); 984 return finder.core.delExpr; 982 return ast::Pass<DeleteFinder_new>::read( expr ); 985 983 } 986 984
Note: See TracChangeset
for help on using the changeset viewer.