Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r7ff3e522 r3090127  
    982982                ast::Pass<DeleteFinder_new> finder;
    983983                expr->accept( finder );
    984                 return finder.core.delExpr;
     984                return finder.pass.delExpr;
    985985        }
    986986
     
    10721072                /// Strips extraneous casts out of an expression
    10731073                struct StripCasts_new final {
    1074                         const ast::Expr * postvisit( const ast::CastExpr * castExpr ) {
     1074                        const ast::Expr * postmutate( const ast::CastExpr * castExpr ) {
    10751075                                if (
    1076                                         castExpr->isGenerated == ast::GeneratedCast
     1076                                        castExpr->isGenerated
    10771077                                        && typesCompatible( castExpr->arg->result, castExpr->result )
    10781078                                ) {
     
    11281128
    11291129                // set up and resolve expression cast to void
    1130                 ast::ptr< ast::CastExpr > untyped = new ast::CastExpr{ expr };
     1130                ast::CastExpr * untyped = new ast::CastExpr{ expr };
    11311131                CandidateRef choice = findUnfinishedKindExpression(
    11321132                        untyped, symtab, "", anyCandidate, ResolvMode::withAdjustment() );
     
    12361236
    12371237        public:
    1238                 static size_t traceId;
    12391238                Resolver_new() = default;
    12401239                Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; }
     
    12671266                const ast::ConstructorInit * previsit( const ast::ConstructorInit * );
    12681267        };
    1269         // size_t Resolver_new::traceId = Stats::Heap::new_stacktrace_id("Resolver");
    1270 
    1271         void resolve( std::list< ast::ptr< ast::Decl > >& translationUnit ) {
    1272                 ast::Pass< Resolver_new >::run( translationUnit );
     1268
     1269        void resolve( std::list< ast::ptr<ast::Decl> >& translationUnit ) {
     1270                ast::Pass< Resolver_new > resolver;
     1271                accept_all( translationUnit, resolver );
    12731272        }
    12741273
     
    13001299                // default value expressions have an environment which shouldn't be there and trips up
    13011300                // later passes.
    1302                 assert( functionDecl->unique() );
    1303                 ast::FunctionType * mutType = mutate( functionDecl->type.get() );
    1304 
    1305                 for ( unsigned i = 0 ; i < mutType->params.size() ; ++i ) {
    1306                         if ( const ast::ObjectDecl * obj = mutType->params[i].as< ast::ObjectDecl >() ) {
     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 >() ) {
    13071306                                if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) {
    13081307                                        if ( init->value->env == nullptr ) continue;
    13091308                                        // clone initializer minus the initializer environment
    1310                                         auto mutParam = mutate( mutType->params[i].strict_as< ast::ObjectDecl >() );
    1311                                         auto mutInit = mutate( mutParam->init.strict_as< ast::SingleInit >() );
    1312                                         auto mutValue = mutate( mutInit->value.get() );
    1313 
    1314                                         mutValue->env = nullptr;
    1315                                         mutInit->value = mutValue;
    1316                                         mutParam->init = mutInit;
    1317                                         mutType->params[i] = mutParam;
    1318 
    1319                                         assert( ! mutType->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env);
     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 );
    13201317                                }
    13211318                        }
    13221319                }
    1323                 mutate_field(functionDecl, &ast::FunctionDecl::type, mutType);
    1324                 return functionDecl;
     1320                return ret.get();
    13251321        }
    13261322
     
    13451341                // in case we decide to allow nested enums
    13461342                GuardValue( inEnumDecl );
    1347                 inEnumDecl = true;
     1343                inEnumDecl = false;
    13481344        }
    13491345
Note: See TracChangeset for help on using the changeset viewer.