2021-10-31 15:06:48 +01:00
|
|
|
#include <hex/pattern_language/log_console.hpp>
|
|
|
|
|
|
|
|
#include <hex/pattern_language/ast_node.hpp>
|
|
|
|
|
|
|
|
namespace hex::pl {
|
|
|
|
|
|
|
|
void LogConsole::log(Level level, const std::string &message) {
|
2022-01-24 00:45:46 +01:00
|
|
|
this->m_consoleLog.emplace_back(level, message);
|
2021-10-31 15:06:48 +01:00
|
|
|
}
|
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
[[noreturn]] void LogConsole::abortEvaluation(const std::string &message) {
|
2022-01-31 14:37:12 +01:00
|
|
|
throw PatternLanguageError(0, message);
|
2021-10-31 15:06:48 +01:00
|
|
|
}
|
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
[[noreturn]] void LogConsole::abortEvaluation(const std::string &message, const ASTNode *node) {
|
2022-01-30 15:18:45 +01:00
|
|
|
if (node == nullptr)
|
|
|
|
abortEvaluation(message);
|
|
|
|
else
|
2022-01-31 14:37:12 +01:00
|
|
|
throw PatternLanguageError(node->getLineNumber(), message);
|
2021-10-31 15:06:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void LogConsole::clear() {
|
|
|
|
this->m_consoleLog.clear();
|
2022-01-24 20:53:17 +01:00
|
|
|
this->m_lastHardError = {};
|
2021-10-31 15:06:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|