Changeset bbbc067


Ignore:
Timestamp:
Jan 29, 2019, 4:30:46 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
no_list
Children:
8d25360
Parents:
bee0694
Message:

Changed std::list<Initializer> to vector

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    rbee0694 rbbbc067  
    621621                        ),
    622622                        new ListInit(
    623                                 map_range < std::list<Initializer*> > ( args, [](DeclarationWithType * var ){
     623                                map_range < std::vector< Initializer * > > ( args, [](DeclarationWithType * var ){
    624624                                        Type * type = var->get_type()->clone();
    625625                                        type->set_mutex( false );
  • src/Concurrency/Waitfor.cc

    rbee0694 rbbbc067  
    371371                        ),
    372372                        new ListInit(
    373                                 map_range < std::list<Initializer*> > ( clause.target.arguments, [this](Expression * expr ){
     373                                map_range < std::vector< Initializer * > > ( clause.target.arguments, [this](Expression * expr ){
    374374                                        Expression * init = new CastExpr(
    375375                                                new UntypedExpr(
  • src/GenPoly/Box.cc

    rbee0694 rbbbc067  
    18231823
    18241824                                        // build initializer list for offset array
    1825                                         std::list< Initializer* > inits;
     1825                                        std::vector< Initializer * > inits;
    18261826                                        for ( std::list< Declaration* >::const_iterator member = baseMembers.begin(); member != baseMembers.end(); ++member ) {
    18271827                                                if ( DeclarationWithType *memberDecl = dynamic_cast< DeclarationWithType* >( *member ) ) {
  • src/Parser/InitializerNode.cc

    rbee0694 rbbbc067  
    9696                        designlist.push_back( new Designation( desList ) );
    9797                } // for
    98                 std::list< Initializer * > initlist;
     98                std::vector< Initializer * > initlist;
    9999                buildList< Initializer, InitializerNode >( next_init(), initlist );
    100100                return new ListInit( initlist, designlist, maybeConstructed );
  • src/ResolvExpr/Resolver.cc

    rbee0694 rbbbc067  
    8080                void previsit( ConstructorInit *ctorInit );
    8181          private:
    82                 typedef std::list< Initializer * >::iterator InitIterator;
     82                typedef std::vector< Initializer * >::iterator InitIterator;
    8383
    8484                template< typename PtrType >
     
    235235                                winner.cost = winner.cvtCost;
    236236                        }
    237                        
     237
    238238                        // produce ambiguous errors, if applicable
    239239                        if ( winners.size() != 1 ) {
     
    255255
    256256                        // xxx - check for ambiguous expressions
    257                        
     257
    258258                        // output selected choice
    259259                        alt = std::move( choice );
     
    402402
    403403        void Resolver::previsit( ObjectDecl *objectDecl ) {
    404                 // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 
    405                 // class-variable initContext is changed multiple time because the LHS is analysed twice. 
    406                 // The second analysis changes initContext because of a function type can contain object 
    407                 // declarations in the return and parameter types. So each value of initContext is 
     404                // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that
     405                // class-variable initContext is changed multiple time because the LHS is analysed twice.
     406                // The second analysis changes initContext because of a function type can contain object
     407                // declarations in the return and parameter types. So each value of initContext is
    408408                // retained, so the type on the first analysis is preserved and used for selecting the RHS.
    409409                GuardValue( currentObject );
     
    442442
    443443        void Resolver::postvisit( FunctionDecl *functionDecl ) {
    444                 // default value expressions have an environment which shouldn't be there and trips up 
     444                // default value expressions have an environment which shouldn't be there and trips up
    445445                // later passes.
    446                 // xxx - it might be necessary to somehow keep the information from this environment, but I 
     446                // xxx - it might be necessary to somehow keep the information from this environment, but I
    447447                // can't currently see how it's useful.
    448448                for ( Declaration * d : functionDecl->type->parameters ) {
     
    795795                initExpr->expr = nullptr;
    796796                std::swap( initExpr->env, newExpr->env );
    797                 // InitExpr may have inferParams in the case where the expression specializes a function 
    798                 // pointer, and newExpr may already have inferParams of its own, so a simple swap is not 
     797                // InitExpr may have inferParams in the case where the expression specializes a function
     798                // pointer, and newExpr may already have inferParams of its own, so a simple swap is not
    799799                // sufficient.
    800800                newExpr->spliceInferParams( initExpr );
    801801                delete initExpr;
    802802
    803                 // get the actual object's type (may not exactly match what comes back from the resolver 
     803                // get the actual object's type (may not exactly match what comes back from the resolver
    804804                // due to conversions)
    805805                Type * initContext = currentObject.getCurrentType();
     
    814814                                        if ( isCharType( pt->get_base() ) ) {
    815815                                                if ( CastExpr *ce = dynamic_cast< CastExpr * >( newExpr ) ) {
    816                                                         // strip cast if we're initializing a char[] with a char *, 
     816                                                        // strip cast if we're initializing a char[] with a char *,
    817817                                                        // e.g.  char x[] = "hello";
    818818                                                        newExpr = ce->get_arg();
     
    837837                // move cursor into brace-enclosed initializer-list
    838838                currentObject.enterListInit();
    839                 // xxx - fix this so that the list isn't copied, iterator should be used to change current 
     839                // xxx - fix this so that the list isn't copied, iterator should be used to change current
    840840                // element
    841841                std::list<Designation *> newDesignations;
    842842                for ( auto p : group_iterate(listInit->get_designations(), listInit->get_initializers()) ) {
    843                         // iterate designations and initializers in pairs, moving the cursor to the current 
     843                        // iterate designations and initializers in pairs, moving the cursor to the current
    844844                        // designated object and resolving the initializer against that object.
    845845                        Designation * des = std::get<0>(p);
  • src/SymTab/Validate.cc

    rbee0694 rbbbc067  
    12261226                        TupleType * tupleType = strict_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) );
    12271227                        // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false.
    1228                         ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );
     1228                        ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::vector< Initializer * >(), noDesignators, false ) );
    12291229                        deleteAll( retVals );
    12301230                        retVals.clear();
  • src/SynTree/Initializer.cc

    rbee0694 rbbbc067  
    7070
    7171
    72 ListInit::ListInit( const std::list<Initializer*> &inits, const std::list<Designation *> &des, bool maybeConstructed )
     72ListInit::ListInit( const std::vector< Initializer * > &inits, const std::list<Designation *> &des, bool maybeConstructed )
    7373        : Initializer( maybeConstructed ), initializers( inits ), designations( des ) {
    7474                // handle the common case where a ListInit is created without designations by making a list of empty designations with the same length as the initializer
  • src/SynTree/Initializer.h

    rbee0694 rbbbc067  
    1818#include <iosfwd>            // for ostream
    1919#include <list>              // for list, list<>::const_iterator, list<>::it...
     20#include <vector>
    2021
    2122#include "BaseSyntaxNode.h"  // for BaseSyntaxNode
     
    8586class ListInit : public Initializer {
    8687  public:
    87         std::list<Initializer *> initializers;  // order *is* important
     88        std::vector< Initializer * > initializers;  // order *is* important
    8889        std::list<Designation *> designations;  // order/length is consistent with initializers
    8990
    90         ListInit( const std::list<Initializer*> &initializers,
     91        ListInit( const std::vector< Initializer * > &initializers,
    9192                          const std::list<Designation *> &designators = {}, bool maybeConstructed = false );
    9293        ListInit( const ListInit & other );
     
    9495
    9596        std::list<Designation *> & get_designations() { return designations; }
    96         std::list<Initializer *> & get_initializers() { return initializers; }
     97        std::vector< Initializer * > & get_initializers() { return initializers; }
    9798
    98         typedef std::list<Initializer*>::iterator iterator;
    99         typedef std::list<Initializer*>::const_iterator const_iterator;
     99        typedef std::vector< Initializer * >::iterator iterator;
     100        typedef std::vector< Initializer * >::const_iterator const_iterator;
    100101        iterator begin() { return initializers.begin(); }
    101102        iterator end() { return initializers.end(); }
  • src/Tuples/TupleExpansion.cc

    rbee0694 rbbbc067  
    271271                        // as a distinct part of its initializer - the produced compound literal may be used as part of
    272272                        // another expression
    273                         std::list< Initializer * > inits;
     273                        std::vector< Initializer * > inits;
    274274                        for ( Expression * expr : exprs ) {
    275275                                inits.push_back( new SingleInit( expr ) );
Note: See TracChangeset for help on using the changeset viewer.