Changes in src/Validate/Autogen.cpp [8913de4:bccd70a]
- File:
-
- 1 edited
-
src/Validate/Autogen.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/Autogen.cpp
r8913de4 rbccd70a 44 44 #include "CompilationState.h" 45 45 46 // TODO: The other new ast function should be moved over to this file. 47 #include "SymTab/Autogen.h" 48 46 49 namespace Validate { 47 50 … … 93 96 94 97 const CodeLocation& getLocation() const { return getDecl()->location; } 95 ast::FunctionDecl * genProto( std::string&& name,98 ast::FunctionDecl * genProto( const std::string& name, 96 99 std::vector<ast::ptr<ast::DeclWithType>>&& params, 97 100 std::vector<ast::ptr<ast::DeclWithType>>&& returns ) const; … … 334 337 } 335 338 336 void replaceAll( std::vector<ast::ptr<ast::DeclWithType>> & dwts,337 const ast::DeclReplacer::TypeMap & map ) {338 for ( auto & dwt : dwts ) {339 dwt = strict_dynamic_cast<const ast::DeclWithType *>(340 ast::DeclReplacer::replace( dwt, map ) );341 }342 }343 344 339 /// Generates a basic prototype function declaration. 345 ast::FunctionDecl * FuncGenerator::genProto( std::string&& name,340 ast::FunctionDecl * FuncGenerator::genProto( const std::string& name, 346 341 std::vector<ast::ptr<ast::DeclWithType>>&& params, 347 342 std::vector<ast::ptr<ast::DeclWithType>>&& returns ) const { … … 349 344 // Handle generic prameters and assertions, if any. 350 345 auto const & old_type_params = getGenericParams( type ); 351 ast::DeclReplacer::TypeMap oldToNew;352 346 std::vector<ast::ptr<ast::TypeDecl>> type_params; 353 347 std::vector<ast::ptr<ast::DeclWithType>> assertions; 354 348 for ( auto & old_param : old_type_params ) { 355 349 ast::TypeDecl * decl = ast::deepCopy( old_param ); 356 decl->init = nullptr; 357 splice( assertions, decl->assertions ); 358 oldToNew.emplace( std::make_pair( old_param, decl ) ); 350 for ( auto assertion : decl->assertions ) { 351 assertions.push_back( assertion ); 352 } 353 decl->assertions.clear(); 359 354 type_params.push_back( decl ); 360 355 } 361 replaceAll( params, oldToNew );362 replaceAll( returns, oldToNew );363 replaceAll( assertions, oldToNew );356 // TODO: The values in params and returns still may point at the old 357 // generic params, that does not appear to be an issue but perhaps it 358 // should be addressed. 364 359 365 360 ast::FunctionDecl * decl = new ast::FunctionDecl( 366 361 // Auto-generated routines use the type declaration's location. 367 362 getLocation(), 368 std::move( name ),363 name, 369 364 std::move( type_params ), 370 365 std::move( assertions ),
Note:
See TracChangeset
for help on using the changeset viewer.