Changeset ac9ca96
- Timestamp:
- Oct 13, 2016, 11:19:23 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 7756647
- Parents:
- 65660bd
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/GenInit.cc
r65660bd rac9ca96 238 238 239 239 bool CtorDtor::isManaged( Type * type ) const { 240 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( type ) ) { 241 // tuple is also managed if any of its components are managed 242 if ( std::any_of( tupleType->get_types().begin(), tupleType->get_types().end(), [&](Type * type) { return isManaged( type ); }) ) { 243 return true; 244 } 245 } 240 246 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end(); 241 247 } … … 245 251 while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) { 246 252 type = at->get_base(); 247 }248 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( type ) ) {249 return std::any_of( tupleType->get_types().begin(), tupleType->get_types().end(), [&](Type * type) { return isManaged( type ); });250 253 } 251 254 return isManaged( type ); -
src/ResolvExpr/AlternativeFinder.cc
r65660bd rac9ca96 138 138 } 139 139 140 template< typename InputIterator >141 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {142 while ( begin != end ) {143 result.simpleCombine( (*begin++).env );144 }145 }146 147 140 void renameTypes( Expression *expr ) { 148 141 expr->get_result()->accept( global_renamer ); … … 216 209 template< typename StructOrUnionType > 217 210 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 218 219 // // member must be either a tuple expression or a name expr 220 // if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( memberExpr->get_member() ) ) { 221 // addAggMembers( structInst, agg->expr, agg->cost, nameExpr->get_name() ); 222 // } else { 223 // TupleExpr * tupleExpr = safe_dynamic_cast< TupleExpr * >( memberExpr->get_member() ); 224 // // xxx - ... 225 // assert( false ); 226 // } 227 // if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( memberExpr->get_member() ) ) { 228 229 // } 230 NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member ); 231 const std::string & name = nameExpr->get_name(); 232 std::list< Declaration* > members; 233 aggInst->lookup( name, members ); 234 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) { 235 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( *i ) ) { 236 alternatives.push_back( Alternative( new MemberExpr( dwt, expr->clone() ), env, newCost ) ); 237 renameTypes( alternatives.back().expr ); 238 } else { 239 assert( false ); 240 } 211 // member must be either a tuple expression or a name expr 212 if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) { 213 const std::string & name = nameExpr->get_name(); 214 std::list< Declaration* > members; 215 aggInst->lookup( name, members ); 216 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) { 217 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( *i ) ) { 218 alternatives.push_back( Alternative( new MemberExpr( dwt, expr->clone() ), env, newCost ) ); 219 renameTypes( alternatives.back().expr ); 220 } else { 221 assert( false ); 222 } 223 } 224 } else if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( member ) ) { 225 assert( false ); 226 } else { 227 // xxx - temporary 228 std::cerr << member << std::endl; 229 assertf( false, "reached unexpected case of addAggMembers" ); 241 230 } 242 231 } -
src/ResolvExpr/AlternativeFinder.h
r65660bd rac9ca96 113 113 114 114 Cost sumCost( const AltList &in ); 115 116 template< typename InputIterator > 117 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) { 118 while ( begin != end ) { 119 result.simpleCombine( (*begin++).env ); 120 } 121 } 115 122 } // namespace ResolvExpr 116 123 -
src/Tuples/TupleAssignment.cc
r65660bd rac9ca96 142 142 for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) { 143 143 ResolvExpr::AlternativeFinder finder( currentFinder.get_indexer(), currentFinder.get_environ() ); 144 finder.findWithAdjustment(*i); 144 try { 145 finder.findWithAdjustment(*i); 146 } catch (...) { 147 return; // xxx - no match should not mean failure, it just means this particular tuple assignment isn't valid 148 } 145 149 // prune expressions that don't coincide with 146 150 ResolvExpr::AltList alts = finder.get_alternatives(); … … 157 161 } 158 162 // xxx - need to do this?? 159 //TypeEnvironment compositeEnv;160 // simpleCombineEnvironments( i->begin(), i->end(), compositeEnv );161 currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new TupleAssignExpr(solved_assigns, matcher->tmpDecls), c urrentFinder.get_environ(), ResolvExpr::sumCost( current ) ) );163 ResolvExpr::TypeEnvironment compositeEnv; 164 simpleCombineEnvironments( current.begin(), current.end(), compositeEnv ); 165 currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new TupleAssignExpr(solved_assigns, matcher->tmpDecls), compositeEnv, ResolvExpr::sumCost( current ) ) ); 162 166 } 163 167
Note: See TracChangeset
for help on using the changeset viewer.