Changeset 90e683b for src/InitTweak


Ignore:
Timestamp:
Feb 3, 2025, 11:46:55 AM (2 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
54f70c6
Parents:
bbbff10
Message:

I set out to do a enum rework. It ended up being much the same and I unwound the core rework. But I hope the new names are a bit clearer and other minor fixes are helpful, so I am keeping those.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/InitTweak/GenInit.cpp

    rbbbff10 r90e683b  
    164164                                ast::ObjectDecl * arrayDimension = nullptr;
    165165
    166                                 const ast::TypeExpr * ty = dynamic_cast< const ast::TypeExpr * >( arrayType->dimension.get() );
    167                                 if ( ty ) {
     166                                if ( auto ty = dynamic_cast< const ast::TypeExpr * >( arrayType->dimension.get() ) ) {
    168167                                        auto inst = ty->type.as<ast::EnumInstType>();
    169                                         if ( inst ) {
    170                                                 if ( inst->base->isCfa ) {
    171                                                         arrayDimension = new ast::ObjectDecl(
     168                                        if ( inst && !inst->base->is_c_enum() ) {
     169                                                arrayDimension = new ast::ObjectDecl(
     170                                                        arrayType->dimension->location,
     171                                                        dimensionName.newName(),
     172                                                        new ast::BasicType( ast::BasicKind::UnsignedChar ),
     173                                                        new ast::SingleInit(
    172174                                                                arrayType->dimension->location,
    173                                                                 dimensionName.newName(),
    174                                                                 new ast::BasicType( ast::BasicKind::UnsignedChar ),
    175                                                                 new ast::SingleInit(
    176                                                                         arrayType->dimension->location,
    177                                                                         ast::ConstantExpr::from_int( arrayType->dimension->location, inst->base->members.size() )
    178                                                                 )
    179                                                         );
    180                                                         // return arrayType;
    181                                                 }
     175                                                                ast::ConstantExpr::from_int( arrayType->dimension->location, inst->base->members.size() )
     176                                                        )
     177                                                );
    182178                                        }
    183179                                }
Note: See TracChangeset for help on using the changeset viewer.