Changeset b965774


Ignore:
Timestamp:
Aug 26, 2024, 10:54:57 AM (2 hours ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Parents:
075c6d5
Message:

Isolated the logic to decide if a function is a var-args function or not.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.cpp

    r075c6d5 rb965774  
    15401540
    15411541
     1542// The argument flag (is/is not var-args) of a computed property.
     1543static ast::ArgumentFlag argumentFlag( const TypeData * td ) {
     1544        assert( td->kind == TypeData::Function );
     1545        bool isVaArgs = !td->function.params || td->function.params->hasEllipsis;
     1546        return (isVaArgs) ? ast::VariableArgs : ast::FixedArgs;
     1547} // argumentFlag
     1548
     1549
    15421550ast::FunctionDecl * buildFunctionDecl(
    15431551                const TypeData * td,
     
    15491557                std::vector<ast::ptr<ast::Attribute>> && attributes ) {
    15501558        assert( td->kind == TypeData::Function );
    1551         // For some reason FunctionDecl takes a bool instead of an ArgumentFlag.
    1552         bool isVarArgs = !td->function.params || td->function.params->hasEllipsis;
    15531559        ast::CV::Qualifiers cvq = buildQualifiers( td );
    15541560        std::vector<ast::ptr<ast::TypeDecl>> forall;
     
    16041610                std::move( attributes ),
    16051611                funcSpec,
    1606                 (isVarArgs) ? ast::VariableArgs : ast::FixedArgs
     1612                argumentFlag( td )
    16071613        );
    16081614        buildList( td->function.withExprs, decl->withExprs );
     
    16561662        assert( td->kind == TypeData::Function );
    16571663        ast::FunctionType * ft = new ast::FunctionType(
    1658                 ( !td->function.params || td->function.params->hasEllipsis )
    1659                         ? ast::VariableArgs : ast::FixedArgs,
     1664                argumentFlag( td ),
    16601665                buildQualifiers( td )
    16611666        );
Note: See TracChangeset for help on using the changeset viewer.