| [51587aa] | 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 | // | 
|---|
| [3906301] | 7 | // SemanticError.cc -- | 
|---|
| [51587aa] | 8 | // | 
|---|
|  | 9 | // Author           : Richard C. Bilson | 
|---|
|  | 10 | // Created On       : Mon May 18 07:44:20 2015 | 
|---|
| [01aeade] | 11 | // Last Modified By : Peter A. Buhr | 
|---|
| [9ed4f94] | 12 | // Last Modified On : Tue Aug 29 18:17:35 2017 | 
|---|
|  | 13 | // Update Count     : 3 | 
|---|
| [51587aa] | 14 | // | 
|---|
| [51b73452] | 15 |  | 
|---|
| [9ed4f94] | 16 | #include <cstdio>                                                                               // for fileno, stderr | 
|---|
|  | 17 | #include <unistd.h>                                                                             // for isatty | 
|---|
|  | 18 | #include <iostream>                                                                             // for basic_ostream, operator<<, ostream | 
|---|
|  | 19 | #include <list>                                                                                 // for list, _List_iterator | 
|---|
|  | 20 | #include <string>                                                                               // for string, operator<<, operator+, to_string | 
|---|
| [51b73452] | 21 |  | 
|---|
| [9ed4f94] | 22 | #include "Common/utility.h"                                                             // for to_string, CodeLocation (ptr only) | 
|---|
| [51b73452] | 23 | #include "SemanticError.h" | 
|---|
|  | 24 |  | 
|---|
| [01aeade] | 25 | SemanticError::SemanticError() { | 
|---|
| [51b73452] | 26 | } | 
|---|
|  | 27 |  | 
|---|
| [01aeade] | 28 | SemanticError::SemanticError( std::string error ) { | 
|---|
| [138e29e] | 29 | append( error ); | 
|---|
| [51b73452] | 30 | } | 
|---|
|  | 31 |  | 
|---|
| [01aeade] | 32 | void SemanticError::append( SemanticError &other ) { | 
|---|
| [138e29e] | 33 | errors.splice( errors.end(), other.errors ); | 
|---|
| [3906301] | 34 | } | 
|---|
|  | 35 |  | 
|---|
|  | 36 | void SemanticError::append( const std::string & msg ) { | 
|---|
| [138e29e] | 37 | errors.emplace_back( error_str() + msg ); | 
|---|
| [51b73452] | 38 | } | 
|---|
|  | 39 |  | 
|---|
| [01aeade] | 40 | bool SemanticError::isEmpty() const { | 
|---|
|  | 41 | return errors.empty(); | 
|---|
| [51b73452] | 42 | } | 
|---|
|  | 43 |  | 
|---|
| [01aeade] | 44 | void SemanticError::print( std::ostream &os ) { | 
|---|
| [138e29e] | 45 | using std::to_string; | 
|---|
| [9ed4f94] | 46 | for( auto err : errors ) { | 
|---|
| [80ac42d] | 47 | os << err.location << err.description << std::endl; | 
|---|
| [138e29e] | 48 | } | 
|---|
| [51b73452] | 49 | } | 
|---|
| [01aeade] | 50 |  | 
|---|
| [294647b] | 51 | void SemanticError::set_location( const CodeLocation& location ) { | 
|---|
| [138e29e] | 52 | errors.begin()->maybeSet( location ); | 
|---|
| [294647b] | 53 | } | 
|---|
|  | 54 |  | 
|---|
| [51587aa] | 55 | // Local Variables: // | 
|---|
|  | 56 | // tab-width: 4 // | 
|---|
|  | 57 | // mode: c++ // | 
|---|
|  | 58 | // compile-command: "make install" // | 
|---|
|  | 59 | // End: // | 
|---|