Changeset db19e1d for src


Ignore:
Timestamp:
Sep 3, 2024, 12:08:09 PM (5 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
737bf73
Parents:
cdbb909
Message:

Changed the interpritation of () to be no parameters instead of any parameters. This had a lot of little changes because of this and some nearby clean-up. This includes some changes, including changing some generated functions to be fixed-args instead of variable-args, stripping out the place holder void parameter earlier, but it still shows up earlier in some cases that examine the parser directly. Also had to update the function generation tools. Have only tested with one --arch. Hopefully this all works out.

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cpp

    rcdbb909 rdb19e1d  
    180180
    181181        if ( 0 == decl->params.size() ) {
    182                 if ( decl->type->isVarArgs ) {
     182                if ( !decl->type->isVarArgs ) {
     183                        acc << "(void)";
     184                } else if ( options.genC ) {
    183185                        acc << "()";
    184186                } else {
    185                         acc << "(void)";
     187                        acc << "(...)";
    186188                }
    187189        } else {
  • src/CodeGen/GenType.cpp

    rcdbb909 rdb19e1d  
    168168
    169169        if ( type->params.empty() ) {
    170                 if ( type->isVarArgs ) {
     170                if ( !type->isVarArgs ) {
     171                        os << "(void)";
     172                } else if ( options.genC ) {
    171173                        os << "()";
    172174                } else {
    173                         os << "(void)";
     175                        os << "(...)";
    174176                }
    175177        } else {
  • src/Concurrency/Keywords.cpp

    rcdbb909 rdb19e1d  
    15101510
    15111511ast::ptr<ast::Type> MutexKeyword::generic_func =
    1512         new ast::FunctionType( ast::VariableArgs );
     1512        new ast::FunctionType( ast::FixedArgs );
    15131513
    15141514// --------------------------------------------------------------------------
  • src/Concurrency/Waitfor.cpp

    rcdbb909 rdb19e1d  
    302302        const ast::ObjectDecl * monitors = declMonitors( out, clause );
    303303        ast::Type * fptr_t = new ast::PointerType(
    304                         new ast::FunctionType( ast::VariableArgs ) );
     304                        new ast::FunctionType( ast::FixedArgs ) );
    305305
    306306        const ast::VariableExpr * variableExpr =
  • src/Parser/TypeData.cpp

    rcdbb909 rdb19e1d  
    15411541
    15421542// The argument flag (is/is not var-args) of a computed property.
    1543 static ast::ArgumentFlag argumentFlag( const TypeData * td ) {
     1543static ast::ArgumentFlag buildArgumentFlag( const TypeData * td ) {
    15441544        assert( td->kind == TypeData::Function );
    1545         bool isVaArgs = !td->function.params || td->function.params->hasEllipsis;
    1546         return (isVaArgs) ? ast::VariableArgs : ast::FixedArgs;
    1547 } // argumentFlag
     1545        bool isVarArgs = !td->function.params || td->function.params->hasEllipsis;
     1546        return (isVarArgs) ? ast::VariableArgs : ast::FixedArgs;
     1547}
     1548
     1549
     1550// Wrapper to convert the void parameter into the empty explicit list.
     1551static void buildParamList( DeclarationNode * decl,
     1552                std::vector<ast::ptr<ast::DeclWithType>> & params ) {
     1553        buildList( decl, params );
     1554        if ( 1 == params.size() && params[0]->get_type()->isVoid() ) {
     1555                params.pop_back();
     1556        }
     1557}
    15481558
    15491559
     
    15621572        std::vector<ast::ptr<ast::DeclWithType>> params;
    15631573        std::vector<ast::ptr<ast::DeclWithType>> returns;
    1564         buildList( td->function.params, params );
     1574        buildParamList( td->function.params, params );
    15651575        buildForall( td->forall, forall );
    15661576        // Functions do not store their assertions there anymore.
     
    16101620                std::move( attributes ),
    16111621                funcSpec,
    1612                 argumentFlag( td )
     1622                buildArgumentFlag( td )
    16131623        );
    16141624        buildList( td->function.withExprs, decl->withExprs );
     
    16621672        assert( td->kind == TypeData::Function );
    16631673        ast::FunctionType * ft = new ast::FunctionType(
    1664                 argumentFlag( td ),
     1674                buildArgumentFlag( td ),
    16651675                buildQualifiers( td )
    16661676        );
  • src/Parser/parser.yy

    rcdbb909 rdb19e1d  
    28892889parameter_list_ellipsis_opt:
    28902890        // empty
    2891                 { $$ = nullptr; }
     2891                { $$ = DeclarationNode::newFromTypeData( build_basic_type( TypeData::Void ) ); }
    28922892        | ELLIPSIS
    28932893                { $$ = nullptr; }
Note: See TracChangeset for help on using the changeset viewer.