Changeset 90152a4 for src/SynTree/AggregateDecl.cc
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AggregateDecl.cc
rf9feab8 r90152a4 86 86 std::string TraitDecl::typeString() const { return "trait"; } 87 87 88 bool EnumDecl::valueOf( Declaration * enumerator, long long int & value ) { 89 if ( enumValues.empty() ) { 90 long long int currentValue = 0; 91 for ( Declaration * member : members ) { 92 ObjectDecl * field = strict_dynamic_cast< ObjectDecl * >( member ); 93 if ( field->init ) { 94 SingleInit * init = strict_dynamic_cast< SingleInit * >( field->init ); 95 auto result = eval( init->value ); 96 if ( ! result.second ) SemanticError( init->location, toString( "Non-constexpr in initialization of enumerator: ", field ) ); 97 currentValue = result.first; 98 } 99 assertf( enumValues.count( field->name ) == 0, "Enum %s has multiple members with the name %s", name.c_str(), field->name.c_str() ); 100 enumValues[ field->name ] = currentValue; 101 ++currentValue; 102 } 103 } 104 if ( enumValues.count( enumerator->name ) ) { 105 value = enumValues[ enumerator->name ]; 106 return true; 107 } 108 return false; 109 } 110 88 111 // Local Variables: // 89 112 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.