Changeset 561354f for src/SymTab


Ignore:
Timestamp:
May 17, 2023, 1:33:39 AM (3 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT
Children:
d6c464d
Parents:
28f8f15
Message:

Save progress

Location:
src/SymTab
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    r28f8f15 r561354f  
    606606        }
    607607
     608        void Indexer::addAdt( const AdtDecl * decl ) {
     609                ++*stats().add_calls;
     610                const std::string & id = decl->name;
     611
     612                if ( ! adtTable ) {
     613                        adtTable = AdtTable::new_ptr();
     614                } else {
     615                        ++* stats().map_lookups;
     616                        auto existing = adtTable->find( id );
     617                        if ( existing != adtTable->end()
     618                                && existing->second.scope == scope
     619                                && addedDeclConflicts( existing->second.decl, decl ) ) return;
     620
     621                }
     622
     623                lazyInitScope();
     624                ++* stats().map_mutations;
     625                adtTable = adtTable->set( id, Scoped<AdtDecl>{ decl, scope} );
     626        }
     627
    608628        void Indexer::addUnion( const std::string & id ) {
    609629                addUnion( new UnionDecl( id ) );
  • src/SymTab/Indexer.h

    r28f8f15 r561354f  
    8989                void addStruct( const StructDecl * decl );
    9090                void addEnum( const EnumDecl * decl );
     91                void addAdt( const AdtDecl * decl );
    9192                void addUnion( const std::string & id );
    9293                void addUnion( const UnionDecl * decl );
     
    124125                using UnionTable = PersistentMap< std::string, Scoped<UnionDecl> >;
    125126                using TraitTable = PersistentMap< std::string, Scoped<TraitDecl> >;
     127                using AdtTable = PersistentMap< std::string, Scoped<AdtDecl> >;
    126128
    127129                IdTable::Ptr idTable;          ///< identifier namespace
     
    131133                UnionTable::Ptr unionTable;    ///< union namespace
    132134                TraitTable::Ptr traitTable;    ///< trait namespace
     135                AdtTable::Ptr adtTable;            ///< adt namespace
    133136
    134137                Ptr prevScope;                 ///< reference to indexer for parent scope
Note: See TracChangeset for help on using the changeset viewer.