From ada2690dcd37e69a18c93c2d0f53abe2e35deb3b Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 6 Jun 2019 19:01:54 +0200 Subject: [PATCH] Rename Diagnostics --- src/Diagnostics/Diagnostics.cpp | 45 ------------------- src/Diagnostics/DiagnosticsHolder.cpp | 45 +++++++++++++++++++ ...{Diagnostics.hpp => DiagnosticsHolder.hpp} | 12 ++--- src/Script.cpp | 2 +- src/Script.hpp | 4 +- 5 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 src/Diagnostics/Diagnostics.cpp create mode 100644 src/Diagnostics/DiagnosticsHolder.cpp rename src/Diagnostics/{Diagnostics.hpp => DiagnosticsHolder.hpp} (78%) diff --git a/src/Diagnostics/Diagnostics.cpp b/src/Diagnostics/Diagnostics.cpp deleted file mode 100644 index 9bf35f5..0000000 --- a/src/Diagnostics/Diagnostics.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "Diagnostics.hpp" - -vector 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); -} - diff --git a/src/Diagnostics/DiagnosticsHolder.cpp b/src/Diagnostics/DiagnosticsHolder.cpp new file mode 100644 index 0000000..6f2565c --- /dev/null +++ b/src/Diagnostics/DiagnosticsHolder.cpp @@ -0,0 +1,45 @@ +#include "DiagnosticsHolder.hpp" + +vector 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); +} + diff --git a/src/Diagnostics/Diagnostics.hpp b/src/Diagnostics/DiagnosticsHolder.hpp similarity index 78% rename from src/Diagnostics/Diagnostics.hpp rename to src/Diagnostics/DiagnosticsHolder.hpp index e305434..12d0258 100644 --- a/src/Diagnostics/Diagnostics.hpp +++ b/src/Diagnostics/DiagnosticsHolder.hpp @@ -1,6 +1,6 @@ -#ifndef PORYGONLANG_DIAGNOSTICS_HPP -#define PORYGONLANG_DIAGNOSTICS_HPP +#ifndef PORYGONLANG_DIAGNOSTICSHOLDER_HPP +#define PORYGONLANG_DIAGNOSTICSHOLDER_HPP #include #include "DiagnosticSeverity.hpp" @@ -9,15 +9,15 @@ using namespace std; -class Diagnostics { +class DiagnosticsHolder { bool _hasErrors; vector _diagnostics; public: - Diagnostics(){ + DiagnosticsHolder(){ _hasErrors = false; } - ~Diagnostics(){ + ~DiagnosticsHolder(){ _diagnostics.clear(); } @@ -36,4 +36,4 @@ public: }; -#endif //PORYGONLANG_DIAGNOSTICS_HPP +#endif //PORYGONLANG_DIAGNOSTICSHOLDER_HPP diff --git a/src/Script.cpp b/src/Script.cpp index c17ea7a..ea7636e 100644 --- a/src/Script.cpp +++ b/src/Script.cpp @@ -14,7 +14,7 @@ Script* Script::Create(string script) { } Script::Script() { - Diagnostics = new class Diagnostics(); + Diagnostics = new DiagnosticsHolder(); _evaluator = new Evaluator(this); _boundScript = nullptr; _scriptVariables = new unordered_map>(0); diff --git a/src/Script.hpp b/src/Script.hpp index 589dc37..c57691c 100644 --- a/src/Script.hpp +++ b/src/Script.hpp @@ -4,7 +4,7 @@ #include #include #include -#include "Diagnostics/Diagnostics.hpp" +#include "Diagnostics/DiagnosticsHolder.hpp" #include "Binder/BoundStatements/BoundStatement.hpp" class Script; class Evaluator; @@ -25,7 +25,7 @@ class Script { void Parse(string script); public: static Script* Create(string script); - Diagnostics* Diagnostics; + DiagnosticsHolder* Diagnostics; ~Script();