ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 365da371 was
138e29e,
checked in by Thierry Delisle <tdelisle@…>, 8 years ago
|
Implemented filename and linenumber errors in most cases, only missing constructor errors apparently
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Line | |
---|
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 | // SemanticError.h -- |
---|
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 : Sat Sep 24 15:13:42 2016 |
---|
13 | // Update Count : 5 |
---|
14 | // |
---|
15 | |
---|
16 | #ifndef SEMANTICERROR_H |
---|
17 | #define SEMANTICERROR_H |
---|
18 | |
---|
19 | #include <exception> |
---|
20 | #include <string> |
---|
21 | #include <sstream> |
---|
22 | #include <list> |
---|
23 | #include <iostream> |
---|
24 | |
---|
25 | #include "utility.h" |
---|
26 | |
---|
27 | struct error { |
---|
28 | std::string description; |
---|
29 | CodeLocation location; |
---|
30 | |
---|
31 | error() = default; |
---|
32 | error( const std::string& str ) : description( str ) {} |
---|
33 | |
---|
34 | void maybeSet( const CodeLocation& location ) { |
---|
35 | if( this->location.linenumber < 0 ) { |
---|
36 | this->location = location; |
---|
37 | } |
---|
38 | } |
---|
39 | }; |
---|
40 | |
---|
41 | class SemanticError : public std::exception { |
---|
42 | public: |
---|
43 | SemanticError(); |
---|
44 | SemanticError( std::string error ); |
---|
45 | template< typename T > SemanticError( const std::string &error, const T *obj ); |
---|
46 | ~SemanticError() throw() {} |
---|
47 | |
---|
48 | void append( SemanticError &other ); |
---|
49 | void append( const std::string & ); |
---|
50 | bool isEmpty() const; |
---|
51 | void print( std::ostream &os ); |
---|
52 | |
---|
53 | void set_location( const CodeLocation& location ); |
---|
54 | // constructs an exception using the given message and the printed |
---|
55 | // representation of the obj (T must have a print method) |
---|
56 | private: |
---|
57 | std::list< error > errors; |
---|
58 | }; |
---|
59 | |
---|
60 | template< typename T > |
---|
61 | SemanticError::SemanticError( const std::string &error, const T *obj ) { |
---|
62 | append( toString( error, obj ) ); |
---|
63 | } |
---|
64 | |
---|
65 | #endif // SEMANTICERROR_H |
---|
66 | |
---|
67 | // Local Variables: // |
---|
68 | // tab-width: 4 // |
---|
69 | // mode: c++ // |
---|
70 | // compile-command: "make install" // |
---|
71 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.