This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
#include "Diagnostics.hpp"
|
||||
|
||||
vector<Diagnostic> Diagnostics::GetDiagnostics() {
|
||||
return _diagnostics;
|
||||
}
|
||||
|
||||
void Diagnostics::Log(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
_diagnostics.emplace_back(severity, code, start, length);
|
||||
if (severity >= DiagnosticSeverity::Error){
|
||||
_hasErrors = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Diagnostics::LogError(DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
Log(DiagnosticSeverity::Error, code, start, length);
|
||||
}
|
||||
|
||||
void Diagnostics::LogWarning(DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
Log(DiagnosticSeverity::Warning, code, start, length);
|
||||
}
|
||||
|
||||
void Diagnostics::LogInfo(DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
Log(DiagnosticSeverity::Info, code, start, length);
|
||||
}
|
||||
|
||||
bool Diagnostics::HasErrors() {
|
||||
return _hasErrors;
|
||||
}
|
||||
|
||||
int Diagnostics::DiagnosticsCount() {
|
||||
return _diagnostics.size();
|
||||
}
|
||||
|
||||
Diagnostic *Diagnostics::GetDiagnosticAt(int position) {
|
||||
return &_diagnostics[position];
|
||||
}
|
||||
|
||||
extern "C" int GetDiagnosticsCount (Diagnostics* diagnostics){
|
||||
return diagnostics->DiagnosticsCount();
|
||||
}
|
||||
|
||||
extern "C" Diagnostic* GetDiagnosticAt(Diagnostics* diagnostics, int position){
|
||||
return diagnostics->GetDiagnosticAt(position);
|
||||
}
|
||||
|
||||
45
src/Diagnostics/DiagnosticsHolder.cpp
Normal file
45
src/Diagnostics/DiagnosticsHolder.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "DiagnosticsHolder.hpp"
|
||||
|
||||
vector<Diagnostic> DiagnosticsHolder::GetDiagnostics() {
|
||||
return _diagnostics;
|
||||
}
|
||||
|
||||
void DiagnosticsHolder::Log(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
_diagnostics.emplace_back(severity, code, start, length);
|
||||
if (severity >= DiagnosticSeverity::Error){
|
||||
_hasErrors = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DiagnosticsHolder::LogError(DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
Log(DiagnosticSeverity::Error, code, start, length);
|
||||
}
|
||||
|
||||
void DiagnosticsHolder::LogWarning(DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
Log(DiagnosticSeverity::Warning, code, start, length);
|
||||
}
|
||||
|
||||
void DiagnosticsHolder::LogInfo(DiagnosticCode code, unsigned int start, unsigned int length) {
|
||||
Log(DiagnosticSeverity::Info, code, start, length);
|
||||
}
|
||||
|
||||
bool DiagnosticsHolder::HasErrors() {
|
||||
return _hasErrors;
|
||||
}
|
||||
|
||||
int DiagnosticsHolder::DiagnosticsCount() {
|
||||
return _diagnostics.size();
|
||||
}
|
||||
|
||||
Diagnostic *DiagnosticsHolder::GetDiagnosticAt(int position) {
|
||||
return &_diagnostics[position];
|
||||
}
|
||||
|
||||
extern "C" int GetDiagnosticsCount (DiagnosticsHolder* diagnostics){
|
||||
return diagnostics->DiagnosticsCount();
|
||||
}
|
||||
|
||||
extern "C" Diagnostic* GetDiagnosticAt(DiagnosticsHolder* diagnostics, int position){
|
||||
return diagnostics->GetDiagnosticAt(position);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#ifndef PORYGONLANG_DIAGNOSTICS_HPP
|
||||
#define PORYGONLANG_DIAGNOSTICS_HPP
|
||||
#ifndef PORYGONLANG_DIAGNOSTICSHOLDER_HPP
|
||||
#define PORYGONLANG_DIAGNOSTICSHOLDER_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "DiagnosticSeverity.hpp"
|
||||
@@ -9,15 +9,15 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Diagnostics {
|
||||
class DiagnosticsHolder {
|
||||
bool _hasErrors;
|
||||
vector<Diagnostic> _diagnostics;
|
||||
public:
|
||||
Diagnostics(){
|
||||
DiagnosticsHolder(){
|
||||
_hasErrors = false;
|
||||
}
|
||||
|
||||
~Diagnostics(){
|
||||
~DiagnosticsHolder(){
|
||||
_diagnostics.clear();
|
||||
}
|
||||
|
||||
@@ -36,4 +36,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#endif //PORYGONLANG_DIAGNOSTICS_HPP
|
||||
#endif //PORYGONLANG_DIAGNOSTICSHOLDER_HPP
|
||||
Reference in New Issue
Block a user