Changeset 0dd3a2f for translator/SynTree/Initializer.cc
- Timestamp:
- May 18, 2015, 11:20:23 AM (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:
- 51587aa
- Parents:
- a32b204
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SynTree/Initializer.cc
ra32b204 r0dd3a2f 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // Initializer.cc -- 8 // 9 // Author : Richard C. Bilson 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 09:02:45 2015 13 // Update Count : 2 14 // 15 1 16 #include "Initializer.h" 2 17 #include "Expression.h" 3 18 #include "utility.h" 4 5 19 6 20 Initializer::Initializer() {} … … 9 23 10 24 std::string Initializer::designator_name( Expression *des ) { 11 12 return n->get_name();13 14 throw 0;25 if ( NameExpr *n = dynamic_cast<NameExpr *>(des) ) 26 return n->get_name(); 27 else 28 throw 0; 15 29 } 16 30 … … 21 35 22 36 SingleInit::SingleInit( const SingleInit &other ) : value ( other.value ) { 23 37 cloneAll(other.designators, designators ); 24 38 } 25 39 … … 29 43 30 44 void SingleInit::print( std::ostream &os, int indent ) { 31 32 45 os << std::endl << std::string(indent, ' ' ) << "Simple Initializer: "; 46 value->print( os, indent+2 ); 33 47 34 35 os << std::endl << std::string(indent + 2, ' ' ) << "designated by: " ;36 for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ )37 38 } 48 if ( ! designators.empty() ) { 49 os << std::endl << std::string(indent + 2, ' ' ) << "designated by: " ; 50 for ( std::list < Expression * >::iterator i = designators.begin(); i != designators.end(); i++ ) 51 ( *i )->print(os, indent + 4 ); 52 } // if 39 53 } 40 54 41 55 ListInit::ListInit( std::list<Initializer*> &_initializers, std::list<Expression *> &_designators ) 42 56 : initializers( _initializers ), designators( _designators ) { 43 57 } 44 58 … … 46 60 47 61 ListInit *ListInit::clone() const { 48 62 return new ListInit( *this ); 49 63 } 50 64 51 65 void ListInit::print( std::ostream &os, int indent ) { 52 53 54 os << std::string(indent + 2, ' ' ) << "designated by: [";55 for ( std::list < Expression * >::iterator i = designators.begin();56 57 58 }66 os << std::endl << std::string(indent, ' ') << "Compound initializer: "; 67 if ( ! designators.empty() ) { 68 os << std::string(indent + 2, ' ' ) << "designated by: ["; 69 for ( std::list < Expression * >::iterator i = designators.begin(); 70 i != designators.end(); i++ ) { 71 ( *i )->print(os, indent + 4 ); 72 } // for 59 73 60 os << std::string(indent + 2, ' ' ) << "]";61 } 74 os << std::string(indent + 2, ' ' ) << "]"; 75 } // if 62 76 63 64 (*i)->print( os, indent + 2 );77 for ( std::list<Initializer *>::iterator i = initializers.begin(); i != initializers.end(); i++ ) 78 (*i)->print( os, indent + 2 ); 65 79 } 80 // Local Variables: // 81 // tab-width: 4 // 82 // mode: c++ // 83 // compile-command: "make install" // 84 // End: //
Note: See TracChangeset
for help on using the changeset viewer.