Changes in src/ResolvExpr/Resolver.cc [60914351:ad51cc2]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r60914351 rad51cc2 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 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 ); 91 92 92 93 Type * functionReturn = nullptr; … … 268 269 std::cerr << std::endl; 269 270 #endif 270 Type *new_type = resolveTypeof( functionDecl-> type, indexer );271 Type *new_type = resolveTypeof( functionDecl->get_type(), indexer ); 271 272 functionDecl->set_type( new_type ); 272 273 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() ); 284 275 } 285 276 … … 288 279 // xxx - it might be necessary to somehow keep the information from this environment, but I can't currently 289 280 // see how it's useful. 290 for ( Declaration * d : functionDecl-> type->parameters) {281 for ( Declaration * d : functionDecl->get_functionType()->get_parameters() ) { 291 282 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 ); 295 286 } 296 287 } … … 593 584 } 594 585 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 ) { 597 589 // only struct- and union-typed expressions are viable candidates 598 590 findKindExpression( expr, indexer, "with statement", isStructOrUnion ); … … 603 595 ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), expr->result->clone(), new SingleInit( expr ) ); 604 596 expr = new VariableExpr( tmp ); 605 newStmts.push_back( new DeclStmt( tmp ) );597 stmtsToAddBefore.push_back( new DeclStmt( tmp ) ); 606 598 if ( InitTweak::isConstructable( tmp->type ) ) { 607 599 // generate ctor/dtor and resolve them … … 611 603 } 612 604 } 613 }614 615 void Resolver::previsit( WithStmt * withStmt ) {616 resolveWithExprs( withStmt->exprs, stmtsToAddBefore );617 605 } 618 606 … … 728 716 PassVisitor<Resolver> resolver( indexer ); 729 717 stmtExpr->accept( resolver ); 730 stmtExpr->computeResult();731 718 } 732 719
Note: See TracChangeset
for help on using the changeset viewer.