Changeset 5fda7143 for src/Common
- Timestamp:
- Sep 7, 2016, 9:30:25 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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:
- 9f70ab57
- Parents:
- 1f75e2d (diff), f04a8b81 (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. - Location:
- src/Common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/SemanticError.cc
r1f75e2d r5fda7143 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // SemanticError.cc -- 7 // SemanticError.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 26 26 27 27 SemanticError::SemanticError( std::string error ) { 28 errors.push_back( std::string( "Error: " ) +error );28 append( error ); 29 29 } 30 30 31 31 void SemanticError::append( SemanticError &other ) { 32 errors.splice( errors.end(), other.errors ); 32 errors.splice( errors.end(), other.errors ); 33 } 34 35 void SemanticError::append( const std::string & msg ) { 36 errors.push_back( std::string( "Error: ") + msg ); 33 37 } 34 38 -
src/Common/SemanticError.h
r1f75e2d r5fda7143 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // SemanticError.h -- 7 // SemanticError.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 31 31 32 32 void append( SemanticError &other ); 33 void append( const std::string & ); 33 34 bool isEmpty() const; 34 35 void print( std::ostream &os ); … … 42 43 template< typename T > 43 44 SemanticError::SemanticError( const std::string &error, const T *obj ) { 44 std::ostringstream os; 45 os << "Error: " << error; 46 obj->print( os ); 47 errors.push_back( os.str() ); 45 append( toString( error, obj ) ); 48 46 } 47 49 48 50 49 #endif // SEMANTICERROR_H -
src/Common/utility.h
r1f75e2d r5fda7143 265 265 std::weak_ptr<ThisType> RefCountSingleton<ThisType>::global_instance; 266 266 267 // RAII object to regulate "save and restore" behaviour, e.g. 268 // void Foo::bar() { 269 // ValueGuard<int> guard(var); // var is a member of type Foo 270 // var = ...; 271 // } // var's original value is restored 272 template< typename T > 273 struct ValueGuard { 274 T old; 275 T& ref; 276 277 ValueGuard(T& inRef) : old(inRef), ref(inRef) {} 278 ~ValueGuard() { ref = old; } 279 }; 280 281 template< typename T > 282 struct reverseIterate_t { 283 T& ref; 284 285 reverseIterate_t( T & ref ) : ref(ref) {} 286 287 typedef typename T::reverse_iterator iterator; 288 iterator begin() { return ref.rbegin(); } 289 iterator end() { return ref.rend(); } 290 }; 291 292 template< typename T > 293 reverseIterate_t< T > reverseIterate( T & ref ) { 294 return reverseIterate_t< T >( ref ); 295 } 296 267 297 #endif // _UTILITY_H 268 298
Note: See TracChangeset
for help on using the changeset viewer.