Changeset db19e1d for src/Parser


Ignore:
Timestamp:
Sep 3, 2024, 12:08:09 PM (8 days 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/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.