Changes in src/ResolvExpr/Resolver.cc [ad51cc2:60914351]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
rad51cc2 r60914351 82 82 void previsit( ConstructorInit *ctorInit ); 83 83 private: 84 84 typedef std::list< Initializer * >::iterator InitIterator; 85 85 86 86 template< typename PtrType > 87 87 void handlePtrType( PtrType * type ); 88 88 89 void resolveAggrInit( ReferenceToType *, InitIterator &, InitIterator & ); 90 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator &, TypeSubstitution sub ); 91 void fallbackInit( ConstructorInit * ctorInit ); 89 void resolveWithExprs( std::list< Expression * > & withExprs, std::list< Statement * > & newStmts ); 90 void fallbackInit( ConstructorInit * ctorInit ); 92 91 93 92 Type * functionReturn = nullptr; … … 269 268 std::cerr << std::endl; 270 269 #endif 271 Type *new_type = resolveTypeof( functionDecl-> get_type(), indexer );270 Type *new_type = resolveTypeof( functionDecl->type, indexer ); 272 271 functionDecl->set_type( new_type ); 273 272 GuardValue( functionReturn ); 274 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 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 } 275 284 } 276 285 … … 279 288 // xxx - it might be necessary to somehow keep the information from this environment, but I can't currently 280 289 // see how it's useful. 281 for ( Declaration * d : functionDecl-> get_functionType()->get_parameters()) {290 for ( Declaration * d : functionDecl->type->parameters ) { 282 291 if ( ObjectDecl * obj = dynamic_cast< ObjectDecl * >( d ) ) { 283 if ( SingleInit * init = dynamic_cast< SingleInit * >( obj-> get_init()) ) {284 delete init-> get_value()->get_env();285 init-> get_value()->set_env( nullptr );292 if ( SingleInit * init = dynamic_cast< SingleInit * >( obj->init ) ) { 293 delete init->value->env; 294 init->value->env = nullptr; 286 295 } 287 296 } … … 584 593 } 585 594 586 587 void Resolver::previsit( WithStmt * withStmt ) { 588 for ( Expression *& expr : withStmt->exprs ) { 595 void Resolver::resolveWithExprs( std::list< Expression * > & withExprs, std::list< Statement * > & newStmts ) { 596 for ( Expression *& expr : withExprs ) { 589 597 // only struct- and union-typed expressions are viable candidates 590 598 findKindExpression( expr, indexer, "with statement", isStructOrUnion ); … … 595 603 ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), expr->result->clone(), new SingleInit( expr ) ); 596 604 expr = new VariableExpr( tmp ); 597 stmtsToAddBefore.push_back( new DeclStmt( tmp ) );605 newStmts.push_back( new DeclStmt( tmp ) ); 598 606 if ( InitTweak::isConstructable( tmp->type ) ) { 599 607 // generate ctor/dtor and resolve them … … 603 611 } 604 612 } 613 } 614 615 void Resolver::previsit( WithStmt * withStmt ) { 616 resolveWithExprs( withStmt->exprs, stmtsToAddBefore ); 605 617 } 606 618 … … 716 728 PassVisitor<Resolver> resolver( indexer ); 717 729 stmtExpr->accept( resolver ); 730 stmtExpr->computeResult(); 718 731 } 719 732
Note: See TracChangeset
for help on using the changeset viewer.