Ignore:
Timestamp:
Oct 18, 2022, 5:48:13 PM (21 months ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, master
Children:
5408b59
Parents:
a55472cc
Message:

Supports inline enums

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Validate/LinkReferenceToTypes.cpp

    ra55472cc r1e30df7  
    203203        }
    204204
     205        // The following section
     206        auto mut = ast::mutate( decl );
     207        std::vector<ast::ptr<ast::Decl>> buffer;
     208        for ( auto it = decl->members.begin(); it != decl->members.end(); ++it) {
     209                auto member = (*it).as<ast::ObjectDecl>();
     210                if ( member->enumInLine ) {
     211                        auto targetEnum = symtab.lookupEnum( member->name );
     212                        if (targetEnum) {                       
     213                                for (auto singleMamber : targetEnum->members) {
     214                                        auto tm = singleMamber.as<ast::ObjectDecl>();
     215                                        auto t = new ast::ObjectDecl(
     216                                                member->location, // use the "inline" location
     217                                                tm->name,
     218                                                new ast::EnumInstType( decl, ast::CV::Const ),
     219                                                // Construct a new EnumInstType as the type
     220                                                tm->init,
     221                                                tm->storage,
     222                                                tm->linkage,
     223                                                tm->bitfieldWidth,
     224                                                {}, // enum member doesn't have attribute
     225                                                tm->funcSpec
     226                                        );
     227                                        buffer.push_back(t);
     228                                }
     229                        }
     230                } else {
     231                        buffer.push_back( *it );
     232                }
     233        }
     234        mut->members = buffer;
     235        decl = mut;
     236
    205237        ForwardEnumsType::iterator fwds = forwardEnums.find( decl->name );
    206238        if ( fwds != forwardEnums.end() ) {
Note: See TracChangeset for help on using the changeset viewer.