Changeset e45215c
- Timestamp:
- Jul 15, 2015, 3:06:49 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- d60ccbf
- Parents:
- 145f1fc
- Location:
- src/CodeGen
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r145f1fc re45215c 186 186 } 187 187 188 void CodeGenerator::printDesignators( std::list< Expression * > & designators ) { 189 typedef std::list< Expression * > DesignatorList; 190 if ( designators.size() == 0 ) return; 191 for ( DesignatorList::iterator iter = designators.begin(); iter != designators.end(); ++iter ) { 192 // if expression is a name, then initializing aggregate member, if constant expression then array 193 if ( NameExpr * nm = dynamic_cast< NameExpr * >( *iter ) ) { 194 if ( nm->get_name() == "0" || nm->get_name() == "1" ) { 195 // except if name is 0 or 1... 196 output << "["; 197 nm->accept( *this ); 198 output << "]"; 199 } else { 200 output << "."; 201 nm->accept( *this ); 202 } 203 } else if ( dynamic_cast< ConstantExpr * >( *iter ) ) { 204 output << "["; 205 (*iter)->accept( *this ); 206 output << "]"; 207 } else { 208 assert(0); 209 } 210 } 211 output << " = "; 212 } 213 188 214 void CodeGenerator::visit( SingleInit *init ) { 215 printDesignators( init->get_designators() ); 189 216 init->get_value()->accept( *this ); 190 217 } 191 218 192 219 void CodeGenerator::visit( ListInit *init ) { 220 printDesignators( init->get_designators() ); 193 221 output << "{ "; 194 222 genCommaList( init->begin_initializers(), init->end_initializers() ); -
src/CodeGen/CodeGenerator.h
r145f1fc re45215c 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Thu Jun 11 13:24:23201513 // Update Count : 2 312 // Last Modified On : Wed Jun 17 11:10:58 2015 13 // Update Count : 25 14 14 // 15 15 … … 93 93 std::ostream &output; 94 94 95 void printDesignators( std::list< Expression * > & ); 95 96 static std::string printLabels ( std::list < Label > & ); 96 97 void handleStorageClass( Declaration *decl );
Note: See TracChangeset
for help on using the changeset viewer.