Changeset 73973b6
- Timestamp:
- Jun 17, 2020, 5:02:14 PM (4 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:
- d2de1be9
- Parents:
- 5c9b20c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r5c9b20c r73973b6 1299 1299 // default value expressions have an environment which shouldn't be there and trips up 1300 1300 // later passes. 1301 ast::ptr< ast::FunctionDecl > ret = functionDecl; 1302 for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) { 1303 const ast::ptr< ast::DeclWithType > & d = functionDecl->type->params[i]; 1304 1305 if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) { 1306 if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) { 1307 if ( init->value->env == nullptr ) continue; 1308 // clone initializer minus the initializer environment 1309 ast::chain_mutate( ret ) 1310 ( &ast::FunctionDecl::type ) 1311 ( &ast::FunctionType::params )[i] 1312 ( &ast::ObjectDecl::init ) 1313 ( &ast::SingleInit::value )->env = nullptr; 1314 1315 assert( functionDecl != ret.get() || functionDecl->unique() ); 1316 assert( ! ret->type->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env ); 1317 } 1318 } 1319 } 1320 return ret.release(); 1301 1302 // ast::ptr< ast::FunctionDecl > ret = functionDecl; 1303 // assert(functionDecl->type->unique()); 1304 assert(functionDecl->unique()); 1305 1306 auto mutType = mutate(functionDecl->type.get()); 1307 1308 for ( unsigned i = 0; i < mutType->params.size(); ++i ) { 1309 const ast::ptr< ast::DeclWithType > & d = mutType->params[i]; 1310 if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) { 1311 if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) { 1312 if ( init->value->env == nullptr ) continue; 1313 // clone initializer minus the initializer environment 1314 // ast::FunctionDecl * mutDecl = mutate( functionDecl ); 1315 // auto mutType = mutate( mutDecl->type.get() ); 1316 auto mutParam = mutate( mutType->params[i].strict_as<ast::ObjectDecl>() ); 1317 auto mutInit = mutate( mutParam->init.strict_as<ast::SingleInit>() ); 1318 auto mutValue = mutate( mutInit->value.get() ); 1319 //ast::chain_mutate( ret ) 1320 // ( &ast::FunctionDecl::type ) 1321 // ( &ast::FunctionType::params )[i] 1322 // ( &ast::ObjectDecl::init ) 1323 // ( &ast::SingleInit::value )->env = nullptr; 1324 // assert( functionDecl != mutDecl || functionDecl->unique() ); 1325 mutValue->env = nullptr; 1326 mutInit->value = mutValue; 1327 mutParam->init = mutInit; 1328 mutType->params[i] = mutParam; 1329 // mutDecl->type = mutType; 1330 // functionDecl = mutDecl; 1331 assert( ! mutType->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env); 1332 } 1333 } 1334 } 1335 mutate_field(functionDecl, &ast::FunctionDecl::type, mutType); 1336 return functionDecl; 1321 1337 } 1322 1338
Note: See TracChangeset
for help on using the changeset viewer.