Changeset b1e21da


Ignore:
Timestamp:
Jun 16, 2023, 6:40:44 PM (11 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
0e0f25d5
Parents:
64727bd
Message:

Removed duplicate substution code in Autogen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/Autogen.cpp

    r64727bd rb1e21da  
    321321void FuncGenerator::produceDecl( const ast::FunctionDecl * decl ) {
    322322        assert( nullptr != decl->stmts );
    323         const auto & oldParams = getGenericParams(type);
    324         assert( decl->type_params.size() == oldParams.size());
    325 
    326         /*
    327         ast::DeclReplacer::TypeMap typeMap;
    328         for (auto it = oldParams.begin(), jt = decl->type_params.begin(); it != oldParams.end(); ++it, ++jt) {
    329                 typeMap.emplace(*it, *jt);
    330         }
    331 
    332         const ast::FunctionDecl * mut = strict_dynamic_cast<const ast::FunctionDecl *>(ast::DeclReplacer::replace(decl, typeMap));
    333         assert (mut == decl);
    334         */
     323        assert( decl->type_params.size() == getGenericParams( type ).size() );
    335324
    336325        definitions.push_back( decl );
     
    364353        std::vector<ast::ptr<ast::TypeDecl>> type_params;
    365354        std::vector<ast::ptr<ast::DeclWithType>> assertions;
    366 
    367         ast::DeclReplacer::TypeMap typeMap;
    368355        for ( auto & old_param : old_type_params ) {
    369356                ast::TypeDecl * decl = ast::deepCopy( old_param );
    370357                decl->init = nullptr;
    371358                splice( assertions, decl->assertions );
    372                 oldToNew.emplace( std::make_pair( old_param, decl ) );
     359                oldToNew.emplace( old_param, decl );
    373360                type_params.push_back( decl );
    374                 typeMap.emplace(old_param, decl);
    375         }
    376 
    377         for (auto & param : params) {
    378                 param = ast::DeclReplacer::replace(param, typeMap);
    379         }
    380         for (auto & param : returns) {
    381                 param = ast::DeclReplacer::replace(param, typeMap);
    382361        }
    383362        replaceAll( params, oldToNew );
Note: See TracChangeset for help on using the changeset viewer.