source: translator/Common/SemanticError.h @ 3848e0e

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 3848e0e was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[51b7345]1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: SemanticError.h,v 1.1 2002/04/27 19:57:10 rcbilson Exp $
5 *
6 */
7
8#ifndef SEMANTICERROR_H
9#define SEMANTICERROR_H
10
11#include <exception>
12#include <string>
13#include <strstream>
14#include <list>
15#include <iostream>
16
17class SemanticError : public std::exception
18{
19public:
20  SemanticError();
21  SemanticError( std::string error );
22  template< typename T > SemanticError( const std::string &error, const T *obj );
23  ~SemanticError() throw() {}
24
25  void append( SemanticError &other );
26  bool isEmpty() const;
27  void print( std::ostream &os );
28
29  // constructs an exception using the given message and the printed
30  // representation of the obj (T must have a print method)
31
32private:
33  std::list< std::string > errors;
34};
35
36template< typename T >
37SemanticError::SemanticError( const std::string &error, const T *obj )
38{
39  std::ostrstream os;
40  os << "Error: " << error;
41  obj->print( os );
42  errors.push_back( std::string( os.str(), os.pcount() ) );
43}
44
45#endif /* SEMANTICERROR_H */
Note: See TracBrowser for help on using the repository browser.