Changeset fa2c005 for src/AST/SymbolTable.cpp
- Timestamp:
- Jun 8, 2023, 3:19:43 PM (3 years ago)
- Branches:
- ADT
- Parents:
- 044ae62
- File:
-
- 1 edited
-
src/AST/SymbolTable.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/SymbolTable.cpp
r044ae62 rfa2c005 218 218 } 219 219 220 const AdtDecl * SymbolTable::lookupAdt( const std::string &id ) const { 221 ++*stats().lookup_calls; 222 if ( ! adtTable ) return nullptr; 223 auto it = adtTable->find( id ); 224 return it == adtTable->end() ? nullptr : it->second.decl; 225 } 226 220 227 const EnumDecl * SymbolTable::lookupEnum( const std::string &id ) const { 221 228 ++*stats().lookup_calls; … … 339 346 } 340 347 341 void SymbolTable::addEnum( const EnumDecl *decl ) { 342 ++*stats().add_calls; 343 const std::string &id = decl->name; 344 345 if ( ! enumTable ) { 346 enumTable = EnumTable::new_ptr(); 347 } else { 348 ++*stats().map_lookups; 349 auto existing = enumTable->find( id ); 350 if ( existing != enumTable->end() 351 && existing->second.scope == scope 352 && addedDeclConflicts( existing->second.decl, decl ) ) return; 353 } 354 355 lazyInitScope(); 356 ++*stats().map_mutations; 357 enumTable = enumTable->set( id, scoped<EnumDecl>{ decl, scope } ); 348 void SymbolTable::addAdt( const std::string &id ) { 349 addAdt( new AdtDecl( CodeLocation(), id ) ); 358 350 } 359 351 … … 377 369 adtTable = adtTable->set( id, scoped<AdtDecl>{ decl, scope }); 378 370 } 371 372 void SymbolTable::addEnum( const EnumDecl *decl ) { 373 ++*stats().add_calls; 374 const std::string &id = decl->name; 375 376 if ( ! enumTable ) { 377 enumTable = EnumTable::new_ptr(); 378 } else { 379 ++*stats().map_lookups; 380 auto existing = enumTable->find( id ); 381 if ( existing != enumTable->end() 382 && existing->second.scope == scope 383 && addedDeclConflicts( existing->second.decl, decl ) ) return; 384 } 385 386 lazyInitScope(); 387 ++*stats().map_mutations; 388 enumTable = enumTable->set( id, scoped<EnumDecl>{ decl, scope } ); 389 } 390 379 391 380 392 void SymbolTable::addUnion( const std::string &id ) {
Note:
See TracChangeset
for help on using the changeset viewer.