Changeset 4aaac8a


Ignore:
Timestamp:
Aug 28, 2023, 12:35:26 PM (10 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
0926487
Parents:
8f2aa3c
Message:

Cleaning old box pass for easier translation. Factored out a helper function that is slightly simpler as a helper instead of in the larger function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r8f2aa3c r4aaac8a  
    15381538                }
    15391539
     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
    15401562                /// Finds the member in the base list that matches the given declaration; returns its index, or -1 if not present
    15411563                long findMember( DeclarationWithType *memberDecl, std::list< Declaration* > &baseDecls ) {
    15421564                        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                                }
    15691568                        }
    15701569                        return -1;
Note: See TracChangeset for help on using the changeset viewer.