Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AggregateDecl.cc

    rfc9153d r50377a4  
    8686std::string TraitDecl::typeString() const { return "trait"; }
    8787
    88 namespace {
    89         long long int getConstValue( Expression * expr ) {
    90                 if ( CastExpr * castExpr = dynamic_cast< CastExpr * > ( expr ) ) {
    91                         return getConstValue( castExpr->arg );
    92                 } else if ( ConstantExpr * constExpr = dynamic_cast< ConstantExpr * >( expr ) ) {
    93                         return constExpr->intValue();
    94                 } else {
    95                         assertf( false, "Unhandled expression type in getConstValue for enumerators: %s", toString( expr ).c_str() );
    96                 }
    97         }
    98 }
    99 
    100 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) {
    101         if ( enumValues.empty() ) {
    102                 long long int currentValue = 0;
    103                 for ( Declaration * member : members ) {
    104                         ObjectDecl * field = strict_dynamic_cast< ObjectDecl * >( member );
    105                         if ( field->init ) {
    106                                 SingleInit * init = strict_dynamic_cast< SingleInit * >( field->init );
    107                                 currentValue = getConstValue( init->value );
    108                         }
    109                         assertf( enumValues.count( field->name ) == 0, "Enum %s has multiple members with the name %s", name.c_str(), field->name.c_str() );
    110                         enumValues[ field->name ] = currentValue;
    111                         ++currentValue;
    112                 }
    113         }
    114         if ( enumValues.count( enumerator->name ) ) {
    115                 value = enumValues[ enumerator->name ];
    116                 return true;
    117         }
    118         return false;
    119 }
    120 
    12188// Local Variables: //
    12289// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.