Changeset 2890212 for src/AST/TypeSubstitution.hpp
- Timestamp:
- Jul 31, 2019, 3:23:04 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- ae265b55, f49b3fc
- Parents:
- 504eb72
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/TypeSubstitution.hpp
r504eb72 r2890212 44 44 TypeSubstitution &operator=( const TypeSubstitution &other ); 45 45 46 template< typename SynTreeClass > int apply( const SynTreeClass *& input ) const; 47 template< typename SynTreeClass > int applyFree( const SynTreeClass *& input ) const; 46 template< typename SynTreeClass > 47 struct ApplyResult { 48 const SynTreeClass * node; 49 int count; 50 }; 51 52 template< typename SynTreeClass > ApplyResult<SynTreeClass> apply( const SynTreeClass * input ) const; 53 template< typename SynTreeClass > ApplyResult<SynTreeClass> applyFree( const SynTreeClass * input ) const; 48 54 49 55 template< typename node_t, enum Node::ref_type ref_t > 50 56 int apply( ptr_base< node_t, ref_t > & input ) const { 51 57 const node_t * p = input.get(); 52 intret = apply(p);53 input = p;54 return ret ;58 auto ret = apply(p); 59 input = ret.node; 60 return ret.count; 55 61 } 56 62 … … 58 64 int applyFree( ptr_base< node_t, ref_t > & input ) const { 59 65 const node_t * p = input.get(); 60 intret = applyFree(p);61 input = p;62 return ret ;66 auto ret = applyFree(p); 67 input = ret.node; 68 return ret.count; 63 69 } 64 70 … … 175 181 176 182 template< typename SynTreeClass > 177 int TypeSubstitution::apply( const SynTreeClass *&input ) const {183 TypeSubstitution::ApplyResult<SynTreeClass> TypeSubstitution::apply( const SynTreeClass * input ) const { 178 184 assert( input ); 179 185 Pass<Substituter> sub( *this, false ); 180 186 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) ); 181 /// std::cerr << "substitution result is: "; 182 /// newType->print( std::cerr ); 183 /// std::cerr << std::endl; 184 return sub.pass.subCount; 187 return { input, sub.pass.subCount }; 185 188 } 186 189 187 190 template< typename SynTreeClass > 188 int TypeSubstitution::applyFree( const SynTreeClass *&input ) const {191 TypeSubstitution::ApplyResult<SynTreeClass> TypeSubstitution::applyFree( const SynTreeClass * input ) const { 189 192 assert( input ); 190 193 Pass<Substituter> sub( *this, true ); 191 194 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) ); 192 /// std::cerr << "substitution result is: "; 193 /// newType->print( std::cerr ); 194 /// std::cerr << std::endl; 195 return sub.pass.subCount; 195 return { input, sub.pass.subCount }; 196 196 } 197 197
Note: See TracChangeset
for help on using the changeset viewer.