Rename Diagnostics
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2019-06-06 19:01:54 +02:00
parent 89ada09272
commit ada2690dcd
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
5 changed files with 54 additions and 54 deletions

View File

@ -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);
}

View 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);
}

View File

@ -1,6 +1,6 @@
#ifndef PORYGONLANG_DIAGNOSTICS_HPP #ifndef PORYGONLANG_DIAGNOSTICSHOLDER_HPP
#define PORYGONLANG_DIAGNOSTICS_HPP #define PORYGONLANG_DIAGNOSTICSHOLDER_HPP
#include <vector> #include <vector>
#include "DiagnosticSeverity.hpp" #include "DiagnosticSeverity.hpp"
@ -9,15 +9,15 @@
using namespace std; using namespace std;
class Diagnostics { class DiagnosticsHolder {
bool _hasErrors; bool _hasErrors;
vector<Diagnostic> _diagnostics; vector<Diagnostic> _diagnostics;
public: public:
Diagnostics(){ DiagnosticsHolder(){
_hasErrors = false; _hasErrors = false;
} }
~Diagnostics(){ ~DiagnosticsHolder(){
_diagnostics.clear(); _diagnostics.clear();
} }
@ -36,4 +36,4 @@ public:
}; };
#endif //PORYGONLANG_DIAGNOSTICS_HPP #endif //PORYGONLANG_DIAGNOSTICSHOLDER_HPP

View File

@ -14,7 +14,7 @@ Script* Script::Create(string script) {
} }
Script::Script() { Script::Script() {
Diagnostics = new class Diagnostics(); Diagnostics = new DiagnosticsHolder();
_evaluator = new Evaluator(this); _evaluator = new Evaluator(this);
_boundScript = nullptr; _boundScript = nullptr;
_scriptVariables = new unordered_map<int, shared_ptr<EvalValue>>(0); _scriptVariables = new unordered_map<int, shared_ptr<EvalValue>>(0);

View File

@ -4,7 +4,7 @@
#include <utility> #include <utility>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include "Diagnostics/Diagnostics.hpp" #include "Diagnostics/DiagnosticsHolder.hpp"
#include "Binder/BoundStatements/BoundStatement.hpp" #include "Binder/BoundStatements/BoundStatement.hpp"
class Script; class Script;
class Evaluator; class Evaluator;
@ -25,7 +25,7 @@ class Script {
void Parse(string script); void Parse(string script);
public: public:
static Script* Create(string script); static Script* Create(string script);
Diagnostics* Diagnostics; DiagnosticsHolder* Diagnostics;
~Script(); ~Script();