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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.