Changeset e068c8a for src/ResolvExpr


Ignore:
Timestamp:
Jun 17, 2020, 5:32:02 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
1cf2a9b
Parents:
d2de1be9
Message:

Since my base solution introduced a lot of the mess, I decided to clean up the mess in the final solution.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    rd2de1be9 re068c8a  
    12991299                // default value expressions have an environment which shouldn't be there and trips up
    13001300                // later passes.
    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             }
     1301                assert( functionDecl->unique() );
     1302                ast::FunctionType * mutType = mutate( functionDecl->type.get() );
     1303
     1304                for ( unsigned i = 0 ; i < mutType->params.size() ; ++i ) {
     1305                        if ( const ast::ObjectDecl * obj = mutType->params[i].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                                        auto mutParam = mutate( mutType->params[i].strict_as< ast::ObjectDecl >() );
     1310                                        auto mutInit = mutate( mutParam->init.strict_as< ast::SingleInit >() );
     1311                                        auto mutValue = mutate( mutInit->value.get() );
     1312
     1313                                        mutValue->env = nullptr;
     1314                                        mutInit->value = mutValue;
     1315                                        mutParam->init = mutInit;
     1316                                        mutType->params[i] = mutParam;
     1317
     1318                                        assert( ! mutType->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env);
     1319                                }
     1320                        }
    13341321                }
    13351322                mutate_field(functionDecl, &ast::FunctionDecl::type, mutType);
Note: See TracChangeset for help on using the changeset viewer.