sys: Get rid of SharedData struct and cleanup code structure (#411)

* sys: Initial refactoring of the SharedData class

* sys/pattern: More refactoring, make every provider have its own patterns

* sys: Finished up refactoring. No more SharedData!

* sys: Fixed compile on Unix

* tests: Fixed unit tests

* sys: Moved view and lang files

* pattern: Added assignment operator support to for loops

* tests: Fixed compile issue
This commit is contained in:
WerWolv
2022-02-01 18:09:40 +01:00
committed by GitHub
parent 61fc479c79
commit 1991afb87b
110 changed files with 1592 additions and 1259 deletions

View File

@@ -1,5 +1,5 @@
#include <hex/helpers/crypto.hpp>
#include "hex/helpers/logger.hpp"
#include <hex/helpers/logger.hpp>
#include <hex/test/test_provider.hpp>
#include <hex/test/tests.hpp>

View File

@@ -29,7 +29,7 @@ namespace hex::test {
template<typename T>
static T *create(const std::string &typeName, const std::string &varName, auto... args) {
auto pattern = new T(args...);
auto pattern = new T(nullptr, args...);
pattern->setTypeName(typeName);
pattern->setVariableName(varName);

View File

@@ -58,8 +58,8 @@ int test(int argc, char **argv) {
addFunctions();
// Check if compilation succeeded
auto patterns = language.executeString(provider, testPatterns[testName]->getSourceCode());
if (!patterns.has_value()) {
auto result = language.executeString(provider, testPatterns[testName]->getSourceCode());
if (!result) {
hex::log::fatal("Error during compilation!");
if (auto error = language.getError(); error.has_value())
@@ -76,20 +76,20 @@ int test(int argc, char **argv) {
}
ON_SCOPE_EXIT {
for (auto &pattern : *patterns)
for (auto &pattern : language.getPatterns())
delete pattern;
};
// Check if the right number of patterns have been produced
if (patterns->size() != currTest->getPatterns().size() && !currTest->getPatterns().empty()) {
if (language.getPatterns().size() != currTest->getPatterns().size() && !currTest->getPatterns().empty()) {
hex::log::fatal("Source didn't produce expected number of patterns");
return EXIT_FAILURE;
}
// Check if the produced patterns are the ones expected
for (u32 i = 0; i < currTest->getPatterns().size(); i++) {
auto &evaluatedPattern = *patterns->at(i);
auto &controlPattern = *currTest->getPatterns().at(i);
auto &evaluatedPattern = *language.getPatterns()[i];
auto &controlPattern = *currTest->getPatterns()[i];
if (evaluatedPattern != controlPattern) {
hex::log::fatal("Pattern with name {}:{} didn't match template", evaluatedPattern.getTypeName(), evaluatedPattern.getVariableName());