Changes in src/SynTree/AggregateDecl.cc [50377a4:0690350]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AggregateDecl.cc
r50377a4 r0690350 86 86 std::string TraitDecl::typeString() const { return "trait"; } 87 87 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 // can be -1, +1, etc. 95 // } else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( expr ) ) { 96 // if ( untypedExpr-> ) 97 } else { 98 assertf( false, "Unhandled expression type in getConstValue for enumerators: %s", toString( expr ).c_str() ); 99 } 100 } 101 } 102 103 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) { 104 if ( enumValues.empty() ) { 105 long long int currentValue = 0; 106 for ( Declaration * member : members ) { 107 ObjectDecl * field = strict_dynamic_cast< ObjectDecl * >( member ); 108 if ( field->init ) { 109 SingleInit * init = strict_dynamic_cast< SingleInit * >( field->init ); 110 currentValue = getConstValue( init->value ); 111 } 112 assertf( enumValues.count( field->name ) == 0, "Enum %s has multiple members with the name %s", name.c_str(), field->name.c_str() ); 113 enumValues[ field->name ] = currentValue; 114 ++currentValue; 115 } 116 } 117 if ( enumValues.count( enumerator->name ) ) { 118 value = enumValues[ enumerator->name ]; 119 return true; 120 } 121 return false; 122 } 123 88 124 // Local Variables: // 89 125 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.