Ignore:
Timestamp:
Oct 17, 2023, 2:14:34 PM (9 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
ca995e3
Parents:
37ceccb
Message:

Work on the box pass, fixing up the FunctionDecl? update.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/BoxNew.cpp

    r37ceccb r5e0bba5  
    3939
    4040namespace {
    41 
    42 // TODO: Could this be a common helper somewhere?
    43 ast::FunctionType * makeFunctionType( ast::FunctionDecl const * decl ) {
    44         ast::FunctionType * type = new ast::FunctionType(
    45                 decl->type->isVarArgs, decl->type->qualifiers
    46         );
    47         for ( auto type_param : decl->type_params ) {
    48                 type->forall.emplace_back( new ast::TypeInstType( type_param ) );
    49         }
    50         for ( auto assertion : decl->assertions ) {
    51                 type->assertions.emplace_back( new ast::VariableExpr(
    52                         assertion->location, assertion ) );
    53         }
    54         for ( auto param : decl->params ) {
    55                 type->params.emplace_back( param->get_type() );
    56         }
    57         for ( auto retval : decl->returns ) {
    58                 type->returns.emplace_back( retval->get_type() );
    59         }
    60         return type;
    61 }
    6241
    6342// --------------------------------------------------------------------------
     
    14341413                        layoutParams.emplace_back( alignParam );
    14351414                }
    1436                 // TODO: These should possibly all be gone.
    1437                 // More all assertions into parameter list.
    1438                 for ( ast::ptr<ast::DeclWithType> & assert : mutParam->assertions ) {
    1439                         // Assertion parameters may not be used in body,
    1440                         // pass along with unused attribute.
    1441                         assert.get_and_mutate()->attributes.push_back(
    1442                                 new ast::Attribute( "unused" ) );
    1443                         inferredParams.push_back( assert );
    1444                 }
    1445                 mutParam->assertions.clear();
     1415                // Assertions should be stored in the main list.
     1416                assert( mutParam->assertions.empty() );
    14461417                typeParam = mutParam;
    14471418        }
    1448         // TODO: New version of inner loop.
    14491419        for ( ast::ptr<ast::DeclWithType> & assert : mutDecl->assertions ) {
    14501420                // Assertion parameters may not be used in body,
     
    14611431        spliceBegin( mutDecl->params, layoutParams );
    14621432        addAdapters( mutDecl, localTypeVars );
     1433
     1434        // Now have to update the type to match the declaration.
     1435        ast::FunctionType * type = new ast::FunctionType(
     1436                mutDecl->type->isVarArgs, mutDecl->type->qualifiers );
     1437        for ( auto type_param : mutDecl->type_params ) {
     1438                type->forall.emplace_back( new ast::TypeInstType( type_param ) );
     1439        }
     1440        for ( auto param : mutDecl->params ) {
     1441                type->params.emplace_back( param->get_type() );
     1442        }
     1443        for ( auto retval : mutDecl->returns ) {
     1444                type->returns.emplace_back( retval->get_type() );
     1445        }
     1446        mutDecl->type = type;
    14631447
    14641448        return mutDecl;
     
    14941478                }
    14951479        }
    1496         // TODO: Can this be updated as we go along?
    1497         mutDecl->type = makeFunctionType( mutDecl );
    14981480        return mutDecl;
    14991481}
Note: See TracChangeset for help on using the changeset viewer.