Changeset b6838214 for src/SynTree/AggregateDecl.cc
- Timestamp:
- Jan 23, 2018, 5:46:43 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 258e6ad5
- Parents:
- b158d8f (diff), 15d248e (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
rb158d8f rb6838214 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.