Changeset 933667d


Ignore:
Timestamp:
Jan 13, 2016, 5:00:46 PM (9 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
1194734
Parents:
52bbd67
Message:

Bugfixes for ScopedMap?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/ScopedMap.h

    r52bbd67 r933667d  
    176176                const_iterator cend() const { return const_iterator(scopes, scopes[0].end(), 0); }
    177177
     178                /// Gets the index of the current scope (counted from 1)
     179                size_type currentScope() const { return scopes.size(); }
     180
    178181                /// Finds the given key in the outermost scope it occurs; returns end() for none such
    179182                iterator find( const Key &key ) {
    180                         for ( size_type i = scopes.size() - 1; i > 0; --i ) {
     183                        for ( size_type i = scopes.size() - 1; ; --i ) {
    181184                                typename Scope::iterator val = scopes[i].find( key );
    182185                                if ( val != scopes[i].end() ) return iterator( scopes, val, i );
     186                                if ( i == 0 ) break;
    183187                        }
    184188                        return end();
     
    189193                iterator findNext( const_iterator &it, const Key &key ) {
    190194                        if ( it.i == 0 ) return end();
    191                         for ( size_type i = it.i - 1; i > 0; --i ) {
     195                        for ( size_type i = it.i - 1; ; --i ) {
    192196                                typename Scope::iterator val = scopes[i].find( key );
    193197                                if ( val != scopes[i].end() ) return iterator( scopes, val, i );
     198                                if ( i == 0 ) break;
    194199                        }
    195200                        return end();
Note: See TracChangeset for help on using the changeset viewer.