Changeset 2a301ff for src/GenPoly
- Timestamp:
- Aug 31, 2023, 11:31:15 PM (2 years ago)
- Branches:
- master, stuck-waitfor-destruct
- Children:
- 950c58e
- Parents:
- 92355883 (diff), 686912c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/GenPoly
- Files:
-
- 4 edited
-
Box.cc (modified) (1 diff)
-
ErasableScopedMap.h (modified) (2 diffs)
-
ScopedSet.h (modified) (8 diffs)
-
SpecializeNew.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r92355883 r2a301ff 1538 1538 } 1539 1539 1540 /// Checks if memberDecl matches the decl from an aggregate. 1541 bool isMember( DeclarationWithType *memberDecl, Declaration * decl ) { 1542 if ( memberDecl->get_name() != decl->get_name() ) 1543 return false; 1544 1545 if ( memberDecl->get_name().empty() ) { 1546 // Plan-9 Field: match on unique_id. 1547 return ( memberDecl->get_uniqueId() == decl->get_uniqueId() ); 1548 } 1549 1550 DeclarationWithType *declWithType = strict_dynamic_cast< DeclarationWithType* >( decl ); 1551 1552 if ( memberDecl->get_mangleName().empty() || declWithType->get_mangleName().empty() ) { 1553 // Tuple-Element Field: expect neither had mangled name; accept match on simple name (like field_2) only. 1554 assert( memberDecl->get_mangleName().empty() && declWithType->get_mangleName().empty() ); 1555 return true; 1556 } 1557 1558 // Ordinary Field: Use full name to accommodate overloading. 1559 return ( memberDecl->get_mangleName() == declWithType->get_mangleName() ); 1560 } 1561 1540 1562 /// Finds the member in the base list that matches the given declaration; returns its index, or -1 if not present 1541 1563 long findMember( DeclarationWithType *memberDecl, std::list< Declaration* > &baseDecls ) { 1542 1564 for ( auto pair : enumerate( baseDecls ) ) { 1543 Declaration * decl = pair.val; 1544 size_t i = pair.idx; 1545 if ( memberDecl->get_name() != decl->get_name() ) 1546 continue; 1547 1548 if ( memberDecl->get_name().empty() ) { 1549 // plan-9 field: match on unique_id 1550 if ( memberDecl->get_uniqueId() == decl->get_uniqueId() ) 1551 return i; 1552 else 1553 continue; 1554 } 1555 1556 DeclarationWithType *declWithType = strict_dynamic_cast< DeclarationWithType* >( decl ); 1557 1558 if ( memberDecl->get_mangleName().empty() || declWithType->get_mangleName().empty() ) { 1559 // tuple-element field: expect neither had mangled name; accept match on simple name (like field_2) only 1560 assert( memberDecl->get_mangleName().empty() && declWithType->get_mangleName().empty() ); 1561 return i; 1562 } 1563 1564 // ordinary field: use full name to accommodate overloading 1565 if ( memberDecl->get_mangleName() == declWithType->get_mangleName() ) 1566 return i; 1567 else 1568 continue; 1565 if ( isMember( memberDecl, pair.val ) ) { 1566 return pair.idx; 1567 } 1569 1568 } 1570 1569 return -1; -
src/GenPoly/ErasableScopedMap.h
r92355883 r2a301ff 57 57 /// Starts a new scope 58 58 void beginScope() { 59 Scope scope; 60 scopes.push_back(scope); 59 scopes.emplace_back(); 61 60 } 62 61 … … 145 144 public std::iterator< std::bidirectional_iterator_tag, value_type > { 146 145 friend class ErasableScopedMap; 147 typedef typename std::map< Key, Value >::iterator wrapped_iterator; 148 typedef typename std::vector< std::map< Key, Value > > scope_list; 149 typedef typename scope_list::size_type size_type; 146 typedef typename Scope::iterator wrapped_iterator; 147 typedef typename ScopeList::size_type size_type; 150 148 151 149 /// Checks if this iterator points to a valid item -
src/GenPoly/ScopedSet.h
r92355883 r2a301ff 47 47 /// Starts a new scope 48 48 void beginScope() { 49 Scope scope; 50 scopes.push_back(scope); 49 scopes.emplace_back(); 51 50 } 52 51 … … 85 84 iterator findNext( const_iterator &it, const Value &key ) { 86 85 if ( it.i == 0 ) return end(); 87 for ( size_type i = it.i - 1; ; --i ) {86 for ( size_type i = it.i - 1; ; --i ) { 88 87 typename Scope::iterator val = scopes[i].find( key ); 89 88 if ( val != scopes[i].end() ) return iterator( scopes, val, i ); … … 112 111 friend class ScopedSet; 113 112 friend class const_iterator; 114 typedef typename std::set< Value >::iterator wrapped_iterator; 115 typedef typename std::vector< std::set< Value > > scope_list; 116 typedef typename scope_list::size_type size_type; 113 typedef typename Scope::iterator wrapped_iterator; 114 typedef typename ScopeList::size_type size_type; 117 115 118 116 /// Checks if this iterator points to a valid item … … 133 131 } 134 132 135 iterator( scope_list const &_scopes, const wrapped_iterator &_it, size_type _i)133 iterator(ScopeList const &_scopes, const wrapped_iterator &_it, size_type _i) 136 134 : scopes(&_scopes), it(_it), i(_i) {} 137 135 public: … … 176 174 177 175 private: 178 scope_list const *scopes;176 ScopeList const *scopes; 179 177 wrapped_iterator it; 180 178 size_type i; … … 185 183 public std::iterator< std::bidirectional_iterator_tag, value_type > { 186 184 friend class ScopedSet; 187 typedef typename std::set< Value >::iterator wrapped_iterator; 188 typedef typename std::set< Value >::const_iterator wrapped_const_iterator; 189 typedef typename std::vector< std::set< Value > > scope_list; 190 typedef typename scope_list::size_type size_type; 185 typedef typename Scope::iterator wrapped_iterator; 186 typedef typename Scope::const_iterator wrapped_const_iterator; 187 typedef typename ScopeList::size_type size_type; 191 188 192 189 /// Checks if this iterator points to a valid item … … 207 204 } 208 205 209 const_iterator( scope_list const &_scopes, const wrapped_const_iterator &_it, size_type _i)206 const_iterator(ScopeList const &_scopes, const wrapped_const_iterator &_it, size_type _i) 210 207 : scopes(&_scopes), it(_it), i(_i) {} 211 208 public: … … 255 252 256 253 private: 257 scope_list const *scopes;254 ScopeList const *scopes; 258 255 wrapped_const_iterator it; 259 256 size_type i; -
src/GenPoly/SpecializeNew.cpp
r92355883 r2a301ff 104 104 105 105 bool needsPolySpecialization( 106 const ast::Type * formalType,106 const ast::Type * /*formalType*/, 107 107 const ast::Type * actualType, 108 108 const ast::TypeSubstitution * subs ) { … … 126 126 if ( closedVars.find( *inst ) == closedVars.end() ) { 127 127 return true; 128 } 129 else { 128 } else { 130 129 assertf(false, "closed: %s", inst->name.c_str()); 131 130 }
Note:
See TracChangeset
for help on using the changeset viewer.