Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r60914351 rad51cc2  
    8282                void previsit( ConstructorInit *ctorInit );
    8383          private:
    84                 typedef std::list< Initializer * >::iterator InitIterator;
     84        typedef std::list< Initializer * >::iterator InitIterator;
    8585
    8686                template< typename PtrType >
    8787                void handlePtrType( PtrType * type );
    8888
    89                 void resolveWithExprs( std::list< Expression * > & withExprs, std::list< Statement * > & newStmts );
    90                 void fallbackInit( ConstructorInit * ctorInit );
     89          void resolveAggrInit( ReferenceToType *, InitIterator &, InitIterator & );
     90          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator &, TypeSubstitution sub );
     91          void fallbackInit( ConstructorInit * ctorInit );
    9192
    9293                Type * functionReturn = nullptr;
     
    268269                std::cerr << std::endl;
    269270#endif
    270                 Type *new_type = resolveTypeof( functionDecl->type, indexer );
     271                Type *new_type = resolveTypeof( functionDecl->get_type(), indexer );
    271272                functionDecl->set_type( new_type );
    272273                GuardValue( functionReturn );
    273                 functionReturn = ResolvExpr::extractResultType( functionDecl->type );
    274 
    275                 {
    276                         // resolve with-exprs with parameters in scope and add any newly generated declarations to the
    277                         // front of the function body.
    278                         auto guard = makeFuncGuard( [this]() { indexer.enterScope(); }, [this](){ indexer.leaveScope(); } );
    279                         indexer.addFunctionType( functionDecl->type );
    280                         std::list< Statement * > newStmts;
    281                         resolveWithExprs( functionDecl->withExprs, newStmts );
    282                         functionDecl->statements->kids.splice( functionDecl->statements->kids.begin(), newStmts );
    283                 }
     274                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
    284275        }
    285276
     
    288279                // xxx - it might be necessary to somehow keep the information from this environment, but I can't currently
    289280                // see how it's useful.
    290                 for ( Declaration * d : functionDecl->type->parameters ) {
     281                for ( Declaration * d : functionDecl->get_functionType()->get_parameters() ) {
    291282                        if ( ObjectDecl * obj = dynamic_cast< ObjectDecl * >( d ) ) {
    292                                 if ( SingleInit * init = dynamic_cast< SingleInit * >( obj->init ) ) {
    293                                         delete init->value->env;
    294                                         init->value->env = nullptr;
     283                                if ( SingleInit * init = dynamic_cast< SingleInit * >( obj->get_init() ) ) {
     284                                        delete init->get_value()->get_env();
     285                                        init->get_value()->set_env( nullptr );
    295286                                }
    296287                        }
     
    593584        }
    594585
    595         void Resolver::resolveWithExprs( std::list< Expression * > & withExprs, std::list< Statement * > & newStmts ) {
    596                 for ( Expression *& expr : withExprs )  {
     586
     587        void Resolver::previsit( WithStmt * withStmt ) {
     588                for ( Expression *& expr : withStmt->exprs )  {
    597589                        // only struct- and union-typed expressions are viable candidates
    598590                        findKindExpression( expr, indexer, "with statement", isStructOrUnion );
     
    603595                                ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), expr->result->clone(), new SingleInit( expr ) );
    604596                                expr = new VariableExpr( tmp );
    605                                 newStmts.push_back( new DeclStmt( tmp ) );
     597                                stmtsToAddBefore.push_back( new DeclStmt( tmp ) );
    606598                                if ( InitTweak::isConstructable( tmp->type ) ) {
    607599                                        // generate ctor/dtor and resolve them
     
    611603                        }
    612604                }
    613         }
    614 
    615         void Resolver::previsit( WithStmt * withStmt ) {
    616                 resolveWithExprs( withStmt->exprs, stmtsToAddBefore );
    617605        }
    618606
     
    728716                PassVisitor<Resolver> resolver( indexer );
    729717                stmtExpr->accept( resolver );
    730                 stmtExpr->computeResult();
    731718        }
    732719
Note: See TracChangeset for help on using the changeset viewer.