Ignore:
Timestamp:
Feb 22, 2019, 10:43:29 AM (5 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
no_list
Parents:
43e0949
Message:

Parameters and return value of functions are now vectors (and some related clean-up)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r43e0949 r2f42718  
    410410                                }
    411411
    412                                 assert( ! func->get_functionType()->get_parameters().empty() );
    413                                 ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->get_parameters().front() );
     412                                assert( ! func->get_functionType()->parameters.empty() );
     413                                ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->parameters.front() );
    414414                                ObjectDecl * srcParam = nullptr;
    415                                 if ( func->get_functionType()->get_parameters().size() == 2 ) {
    416                                         srcParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->get_parameters().back() );
     415                                if ( func->get_functionType()->parameters.size() == 2 ) {
     416                                        srcParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->parameters.back() );
    417417                                }
    418418
     
    429429        void StructFuncGenerator::makeFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func ) {
    430430                FunctionType * ftype = func->type;
    431                 std::list<DeclarationWithType*> & params = ftype->parameters;
     431                auto & params = ftype->parameters;
    432432                assert( params.size() >= 2 );  // should not call this function for default ctor, etc.
    433433
     
    435435                ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( params.front() );
    436436                assert( dstParam );
    437                 std::list<DeclarationWithType*>::iterator parameter = params.begin()+1;
     437                auto parameter = params.begin()+1;
    438438                for ( ; member != end; ++member ) {
    439439                        if ( DeclarationWithType * field = dynamic_cast<DeclarationWithType*>( *member ) ) {
     
    656656        void makeTupleFunctionBody( FunctionDecl * function ) {
    657657                FunctionType * ftype = function->get_functionType();
    658                 assertf( ftype->get_parameters().size() == 1 || ftype->get_parameters().size() == 2, "too many parameters in generated tuple function" );
     658                assertf( ftype->parameters.size() == 1 || ftype->parameters.size() == 2, "too many parameters in generated tuple function" );
    659659
    660660                UntypedExpr * untyped = new UntypedExpr( new NameExpr( function->get_name() ) );
    661661
    662662                /// xxx - &* is used to make this easier for later passes to handle
    663                 untyped->get_args().push_back( new AddressExpr( UntypedExpr::createDeref( new VariableExpr( ftype->get_parameters().front() ) ) ) );
    664                 if ( ftype->get_parameters().size() == 2 ) {
    665                         untyped->get_args().push_back( new VariableExpr( ftype->get_parameters().back() ) );
    666                 }
    667                 function->get_statements()->get_kids().push_back( new ExprStmt( untyped ) );
    668                 function->get_statements()->get_kids().push_back( new ReturnStmt( UntypedExpr::createDeref( new VariableExpr( ftype->get_parameters().front() ) ) ) );
     663                untyped->get_args().push_back( new AddressExpr( UntypedExpr::createDeref( new VariableExpr( ftype->parameters.front() ) ) ) );
     664                if ( ftype->parameters.size() == 2 ) {
     665                        untyped->get_args().push_back( new VariableExpr( ftype->parameters.back() ) );
     666                }
     667                function->statements->get_kids().push_back( new ExprStmt( untyped ) );
     668                function->statements->get_kids().push_back( new ReturnStmt( UntypedExpr::createDeref( new VariableExpr( ftype->parameters.front() ) ) ) );
    669669        }
    670670
     
    691691                                        TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), Type::StorageClasses(), nullptr, TypeDecl::Dtype, true );
    692692                                        TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl );
    693                                         newDecl->get_assertions().push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr,
     693                                        newDecl->assertions.push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr,
    694694                                                                                                                                                   std::vector< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) );
    695                                         newDecl->get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
     695                                        newDecl->assertions.push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
    696696                                                                                                                                                   std::vector< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) );
    697                                         newDecl->get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr,
     697                                        newDecl->assertions.push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr,
    698698                                                                                                                                                   std::vector< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) );
    699                                         newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
     699                                        newDecl->assertions.push_back( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
    700700                                                                                                                                                   std::vector< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) );
    701701                                        typeParams.push_back( newDecl );
Note: See TracChangeset for help on using the changeset viewer.