Changeset 99614c2
- Timestamp:
- Feb 14, 2019, 4:27:49 PM (6 years ago)
- Branches:
- no_list
- Children:
- 43e0949
- Parents:
- 80eefcb
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CurrentObject.cc
r80eefcb r99614c2 65 65 virtual void setPosition( std::list< Expression * > & designators ) = 0; 66 66 67 /// retrieve the listof possible Type/Designaton pairs for the current position in the currect object68 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; 69 69 70 70 /// true if the iterator is not currently at the end … … 88 88 /// helper for operator*; aggregates must add designator to each init alternative, but 89 89 /// adding designators in operator* creates duplicates. 90 virtual std:: list<InitAlternative> first() const = 0; // should be protected90 virtual std::vector<InitAlternative> first() const = 0; // should be protected 91 91 }; 92 92 … … 109 109 } 110 110 111 virtual std:: list<InitAlternative> operator*() const { return first(); }111 virtual std::vector<InitAlternative> operator*() const { return first(); } 112 112 virtual operator bool() const { return type; } 113 113 … … 127 127 128 128 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>{}; 132 132 } 133 133 private: … … 192 192 } 193 193 194 virtual std:: list<InitAlternative> operator*() const {194 virtual std::vector<InitAlternative> operator*() const { 195 195 return first(); 196 196 } … … 223 223 virtual Type * getNext() { return base; } 224 224 225 virtual std:: list<InitAlternative> first() const {225 virtual std::vector<InitAlternative> first() const { 226 226 PRINT( std::cerr << "first in ArrayIterator (" << index << "/" << size << ")" << std::endl; ) 227 227 if ( memberIter && *memberIter ) { 228 std:: list<InitAlternative> ret = memberIter->first();228 std::vector<InitAlternative> ret = memberIter->first(); 229 229 for ( InitAlternative & alt : ret ) { 230 230 alt.designation->get_designators().push_front( new ConstantExpr( Constant::from_ulong( index ) ) ); … … 232 232 return ret; 233 233 } 234 return std:: list<InitAlternative>();234 return std::vector<InitAlternative>(); 235 235 } 236 236 … … 288 288 } 289 289 290 virtual std:: list<InitAlternative> operator*() const {290 virtual std::vector<InitAlternative> operator*() const { 291 291 if (memberIter && *memberIter) { 292 std:: list<InitAlternative> ret = memberIter->first();292 std::vector<InitAlternative> ret = memberIter->first(); 293 293 PRINT( std::cerr << "sub: " << sub << std::endl; ) 294 294 for ( InitAlternative & alt : ret ) { … … 302 302 return ret; 303 303 } 304 return std:: list<InitAlternative>();304 return std::vector<InitAlternative>(); 305 305 } 306 306 … … 346 346 } 347 347 348 virtual std:: list<InitAlternative> first() const {349 std:: list<InitAlternative> ret;348 virtual std::vector<InitAlternative> first() const { 349 std::vector<InitAlternative> ret; 350 350 PRINT( std::cerr << "first " << kind << std::endl; ) 351 351 if ( memberIter && *memberIter ) { // might not need *memberIter?? … … 361 361 // only add self if at the very beginning of the structure 362 362 PRINT( std::cerr << "adding self" << std::endl; ) 363 ret. push_front({ inst->clone(), new Designation( {} ) } );363 ret.insert(ret.begin(), { inst->clone(), new Designation( {} ) } ); 364 364 } 365 365 return ret; … … 566 566 } 567 567 568 std:: list< InitAlternative > CurrentObject::getOptions() {568 std::vector< InitAlternative > CurrentObject::getOptions() { 569 569 PRINT( std::cerr << "____getting current options" << std::endl; ) 570 570 assertf( ! objStack.empty(), "objstack empty in getOptions" ); -
src/ResolvExpr/CurrentObject.h
r80eefcb r99614c2 16 16 #pragma once 17 17 18 #include < list> // for list18 #include <vector> // for vector 19 19 #include <stack> // for stack 20 20 … … 43 43 void exitListInit(); 44 44 /// produces a list of alternatives (Type *, Designation *) for the current sub-object's initializer 45 std:: list< InitAlternative > getOptions();45 std::vector< InitAlternative > getOptions(); 46 46 /// produces the type of the current object but no subobjects 47 47 Type * getCurrentType(); -
src/ResolvExpr/Resolver.cc
r80eefcb r99614c2 513 513 void Resolver::previsit( CaseStmt *caseStmt ) { 514 514 if ( caseStmt->condition ) { 515 std::list< InitAlternative >initAlts = currentObject.getOptions();515 const auto & initAlts = currentObject.getOptions(); 516 516 assertf( initAlts.size() == 1, "SwitchStmt did not correctly resolve an integral expression." ); 517 517 // must remove cast from case statement because RangeExpr cannot be cast. -
src/SynTree/Expression.cc
r80eefcb r99614c2 698 698 } 699 699 700 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std:: list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}700 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::vector<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {} 701 701 UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {} 702 702 UntypedInitExpr::~UntypedInitExpr() { -
src/SynTree/Expression.h
r80eefcb r99614c2 62 62 InferredParams inferParams; ///< Post-resolution inferred parameter slots 63 63 std::vector<UniqueId> resnSlots; ///< Pre-resolution inferred parameter slots 64 64 65 65 // xxx - should turn inferParams+resnSlots into a union to save some memory 66 66 … … 813 813 public: 814 814 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 ); 818 818 UntypedInitExpr( const UntypedInitExpr & other ); 819 819 ~UntypedInitExpr(); … … 822 822 UntypedInitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } 823 823 824 std:: list<InitAlternative> & get_initAlts() { return initAlts; }824 std::vector<InitAlternative> & get_initAlts() { return initAlts; } 825 825 826 826 virtual UntypedInitExpr * clone() const { return new UntypedInitExpr( * this ); }
Note: See TracChangeset
for help on using the changeset viewer.