Changeset 99614c2


Ignore:
Timestamp:
Feb 14, 2019, 4:27:49 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
no_list
Children:
43e0949
Parents:
80eefcb
Message:

InitAlternatives? are now in vectors

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CurrentObject.cc

    r80eefcb r99614c2  
    6565                virtual void setPosition( std::list< Expression * > & designators ) = 0;
    6666
    67                 /// retrieve the list of possible Type/Designaton pairs for the current position in the currect object
    68                 virtual std::list<InitAlternative> operator*() const = 0;
     67                /// retrieve the vector of possible Type/Designaton pairs for the current position in the currect object
     68                virtual std::vector<InitAlternative> operator*() const = 0;
    6969
    7070                /// true if the iterator is not currently at the end
     
    8888                /// helper for operator*; aggregates must add designator to each init alternative, but
    8989                /// adding designators in operator* creates duplicates.
    90                 virtual std::list<InitAlternative> first() const = 0; // should be protected
     90                virtual std::vector<InitAlternative> first() const = 0; // should be protected
    9191        };
    9292
     
    109109                }
    110110
    111                 virtual std::list<InitAlternative> operator*() const { return first(); }
     111                virtual std::vector<InitAlternative> operator*() const { return first(); }
    112112                virtual operator bool() const { return type; }
    113113
     
    127127
    128128        protected:
    129                 virtual std::list<InitAlternative> first() const {
    130                         if ( type ) return std::list<InitAlternative>{ { type->clone(), new Designation( {} ) } };
    131                         else return std::list<InitAlternative>{};
     129                virtual std::vector<InitAlternative> first() const {
     130                        if ( type ) return std::vector<InitAlternative>{ { type->clone(), new Designation( {} ) } };
     131                        else return std::vector<InitAlternative>{};
    132132                }
    133133        private:
     
    192192                }
    193193
    194                 virtual std::list<InitAlternative> operator*() const {
     194                virtual std::vector<InitAlternative> operator*() const {
    195195                        return first();
    196196                }
     
    223223                virtual Type * getNext() { return base; }
    224224
    225                 virtual std::list<InitAlternative> first() const {
     225                virtual std::vector<InitAlternative> first() const {
    226226                        PRINT( std::cerr << "first in ArrayIterator (" << index << "/" << size << ")" << std::endl; )
    227227                        if ( memberIter && *memberIter ) {
    228                                 std::list<InitAlternative> ret = memberIter->first();
     228                                std::vector<InitAlternative> ret = memberIter->first();
    229229                                for ( InitAlternative & alt : ret ) {
    230230                                        alt.designation->get_designators().push_front( new ConstantExpr( Constant::from_ulong( index ) ) );
     
    232232                                return ret;
    233233                        }
    234                         return std::list<InitAlternative>();
     234                        return std::vector<InitAlternative>();
    235235                }
    236236
     
    288288                }
    289289
    290                 virtual std::list<InitAlternative> operator*() const {
     290                virtual std::vector<InitAlternative> operator*() const {
    291291                        if (memberIter && *memberIter) {
    292                                 std::list<InitAlternative> ret = memberIter->first();
     292                                std::vector<InitAlternative> ret = memberIter->first();
    293293                                PRINT( std::cerr << "sub: " << sub << std::endl; )
    294294                                for ( InitAlternative & alt : ret ) {
     
    302302                                return ret;
    303303                        }
    304                         return std::list<InitAlternative>();
     304                        return std::vector<InitAlternative>();
    305305                }
    306306
     
    346346                }
    347347
    348                 virtual std::list<InitAlternative> first() const {
    349                         std::list<InitAlternative> ret;
     348                virtual std::vector<InitAlternative> first() const {
     349                        std::vector<InitAlternative> ret;
    350350                        PRINT( std::cerr << "first " << kind << std::endl; )
    351351                        if ( memberIter && *memberIter ) { // might not need *memberIter??
     
    361361                                // only add self if at the very beginning of the structure
    362362                                PRINT( std::cerr << "adding self" << std::endl; )
    363                                 ret.push_front( { inst->clone(), new Designation( {} ) } );
     363                                ret.insert(ret.begin(), { inst->clone(), new Designation( {} ) } );
    364364                        }
    365365                        return ret;
     
    566566        }
    567567
    568         std::list< InitAlternative > CurrentObject::getOptions() {
     568        std::vector< InitAlternative > CurrentObject::getOptions() {
    569569                PRINT( std::cerr << "____getting current options" << std::endl; )
    570570                assertf( ! objStack.empty(), "objstack empty in getOptions" );
  • src/ResolvExpr/CurrentObject.h

    r80eefcb r99614c2  
    1616#pragma once
    1717
    18 #include <list>   // for list
     18#include <vector> // for vector
    1919#include <stack>  // for stack
    2020
     
    4343                void exitListInit();
    4444                /// produces a list of alternatives (Type *, Designation *) for the current sub-object's initializer
    45                 std::list< InitAlternative > getOptions();
     45                std::vector< InitAlternative > getOptions();
    4646                /// produces the type of the current object but no subobjects
    4747                Type * getCurrentType();
  • src/ResolvExpr/Resolver.cc

    r80eefcb r99614c2  
    513513        void Resolver::previsit( CaseStmt *caseStmt ) {
    514514                if ( caseStmt->condition ) {
    515                         std::list< InitAlternative > initAlts = currentObject.getOptions();
     515                        const auto & initAlts = currentObject.getOptions();
    516516                        assertf( initAlts.size() == 1, "SwitchStmt did not correctly resolve an integral expression." );
    517517                        // must remove cast from case statement because RangeExpr cannot be cast.
  • src/SynTree/Expression.cc

    r80eefcb r99614c2  
    698698}
    699699
    700 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
     700UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::vector<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
    701701UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
    702702UntypedInitExpr::~UntypedInitExpr() {
  • src/SynTree/Expression.h

    r80eefcb r99614c2  
    6262        InferredParams inferParams;       ///< Post-resolution inferred parameter slots
    6363        std::vector<UniqueId> resnSlots;  ///< Pre-resolution inferred parameter slots
    64        
     64
    6565        // xxx - should turn inferParams+resnSlots into a union to save some memory
    6666
     
    813813public:
    814814        Expression * expr;
    815         std::list<InitAlternative> initAlts;
    816 
    817         UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
     815        std::vector<InitAlternative> initAlts;
     816
     817        UntypedInitExpr( Expression * expr, const std::vector<InitAlternative> & initAlts );
    818818        UntypedInitExpr( const UntypedInitExpr & other );
    819819        ~UntypedInitExpr();
     
    822822        UntypedInitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; }
    823823
    824         std::list<InitAlternative> & get_initAlts() { return initAlts; }
     824        std::vector<InitAlternative> & get_initAlts() { return initAlts; }
    825825
    826826        virtual UntypedInitExpr * clone() const { return new UntypedInitExpr( * this ); }
Note: See TracChangeset for help on using the changeset viewer.