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