- Timestamp:
- Nov 21, 2023, 11:34:47 AM (14 months ago)
- Branches:
- master
- Children:
- 4883712
- Parents:
- 0da9475
- Location:
- src/AST
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
r0da9475 r6a0b043 361 361 362 362 /// With statement `with (...) ...` 363 /// This is a statement lexically, but a Decl is needed for the SymbolTable. 363 364 class WithStmt final : public Decl { 364 365 public: -
src/AST/SymbolTable.cpp
r0da9475 r6a0b043 76 76 ret = new MemberExpr{loc, id, referenceToRvalueConversion( base, cost )}; 77 77 ret->env = subs; 78 } 79 else { 78 } else { 80 79 ret = new MemberExpr{ loc, id, referenceToRvalueConversion( baseExpr, cost ) }; 81 80 } 82 } 83 else { 81 } else { 84 82 ret = new VariableExpr{ loc, id }; 85 83 } … … 193 191 } 194 192 } 195 } 196 else { 193 } else { 197 194 ++*num_lookup_with_key; 198 195 ++*stats().map_lookups; … … 294 291 } 295 292 296 bool SymbolTable::addedDeclConflicts( 293 bool SymbolTable::addedDeclConflicts( 297 294 const AggregateDecl * existing, const AggregateDecl * added ) const { 298 295 if ( ! existing->body ) { … … 480 477 if (dynamic_cast<const PointerType *>(base)) return Mangle::Encoding::pointer; 481 478 return Mangle::mangle( base, Mangle::Type | Mangle::NoGenericParams ); 482 } 483 else484 return Mangle::mangle( base );479 } else { 480 return Mangle::mangle( base ); 481 } 485 482 } 486 483 … … 556 553 if ( ! alreadyUserDefinedFunc ) for ( const auto& entry : deleted ) { 557 554 ++*stats().map_mutations; 558 mangleTable = mangleTable->set( entry.first, IdData{ entry.second, function });555 mangleTable = mangleTable->set( entry.first, entry.second.withDeleter( function ) ); 559 556 } 560 557 } else if ( dataIsUserDefinedFunc ) { … … 586 583 for ( const auto& entry : deleted ) { 587 584 ++*stats().map_mutations; 588 mangleTable = mangleTable->set( entry.first, IdData{ entry.second, function });585 mangleTable = mangleTable->set( entry.first, entry.second.withDeleter( function ) ); 589 586 } 590 587 } else if ( function->linkage != Linkage::Intrinsic ) { … … 690 687 if (kind == NUMBER_OF_KINDS) { // not a special decl 691 688 addIdToTable(decl, decl->name, idTable, handleConflicts, baseExpr, deleter); 692 } 693 else { 689 } else { 694 690 std::string key; 695 691 if (auto func = dynamic_cast<const FunctionDecl *>(decl)) { 696 692 key = getOtypeKey(func->type); 697 } 698 else if (auto obj = dynamic_cast<const ObjectDecl *>(decl)) { 693 } else if (auto obj = dynamic_cast<const ObjectDecl *>(decl)) { 699 694 key = getOtypeKey(obj->type.strict_as<PointerType>()->base.strict_as<FunctionType>()); 700 } 701 else { 695 } else { 702 696 assertf(false, "special decl with non-function type"); 703 697 } … … 755 749 if ( existing != mangleTable->end() 756 750 && existing->second.scope == scope 757 && existing->second.id ) { 758 if ( addedIdConflicts( existing->second, decl, handleConflicts, deleter ) ) { 759 if ( handleConflicts.mode == OnConflict::Delete ) { 760 // set delete expression for conflicting identifier 761 lazyInitScope(); 762 *stats().map_mutations += 2; 763 table = table->set( 764 lookupKey, 765 mangleTable->set( 766 mangleName, 767 IdData{ existing->second, handleConflicts.deleter } ) ); 768 } 769 return; 751 && existing->second.id 752 && addedIdConflicts( existing->second, decl, handleConflicts, deleter ) ) { 753 if ( handleConflicts.mode == OnConflict::Delete ) { 754 // set delete expression for conflicting identifier 755 lazyInitScope(); 756 *stats().map_mutations += 2; 757 table = table->set( 758 lookupKey, 759 mangleTable->set( 760 mangleName, 761 existing->second.withDeleter( handleConflicts.deleter ) ) ); 770 762 } 763 return; 771 764 } 772 765 } -
src/AST/SymbolTable.hpp
r0da9475 r6a0b043 48 48 : id( i ), baseExpr( base ), deleter( del ), scope( s ) {} 49 49 50 /// Modify an existing node with a new deleter 51 IdData( const IdData & o, const Decl * del ) 52 : id( o.id ), baseExpr( o.baseExpr ), deleter( del ), scope( o.scope ) {} 50 /// Create a new IdData, updating the deleter value. 51 IdData withDeleter( const Decl * decl ) const { 52 return IdData( id, baseExpr, decl, scope ); 53 } 53 54 54 55 /// Constructs an expression referring to this identifier.
Note: See TracChangeset
for help on using the changeset viewer.