2022-08-08 21:23:52 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <hex/providers/provider.hpp>
|
|
|
|
|
|
|
|
#include <pl/pattern_language.hpp>
|
|
|
|
#include <hex/data_processor/attribute.hpp>
|
|
|
|
#include <hex/data_processor/node.hpp>
|
|
|
|
#include <hex/data_processor/link.hpp>
|
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
class ProviderExtraData {
|
|
|
|
public:
|
|
|
|
struct Data {
|
|
|
|
bool dataDirty = false;
|
|
|
|
|
2022-10-26 08:54:43 +02:00
|
|
|
struct PatternLanguage {
|
|
|
|
struct PatternVariable {
|
|
|
|
bool inVariable;
|
|
|
|
bool outVariable;
|
|
|
|
|
|
|
|
pl::core::Token::ValueType type;
|
|
|
|
pl::core::Token::Literal value;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class EnvVarType
|
|
|
|
{
|
|
|
|
Integer,
|
|
|
|
Float,
|
|
|
|
String,
|
|
|
|
Bool
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EnvVar {
|
|
|
|
u64 id;
|
|
|
|
std::string name;
|
|
|
|
pl::core::Token::Literal value;
|
|
|
|
EnvVarType type;
|
|
|
|
|
|
|
|
bool operator==(const EnvVar &other) const {
|
|
|
|
return this->id == other.id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-08 21:23:52 +02:00
|
|
|
std::string sourceCode;
|
2022-10-10 23:16:54 +02:00
|
|
|
std::mutex runtimeMutex;
|
2023-01-01 02:29:38 +01:00
|
|
|
std::unique_ptr<pl::PatternLanguage> runtime = std::make_unique<pl::PatternLanguage>();
|
2022-10-26 08:54:43 +02:00
|
|
|
std::vector<std::pair<pl::core::LogConsole::Level, std::string>> console;
|
2022-10-03 10:36:19 +02:00
|
|
|
bool executionDone = true;
|
2022-10-26 08:54:43 +02:00
|
|
|
|
|
|
|
std::optional<pl::core::err::PatternLanguageError> lastEvaluationError;
|
|
|
|
std::vector<std::pair<pl::core::LogConsole::Level, std::string>> lastEvaluationLog;
|
|
|
|
std::map<std::string, pl::core::Token::Literal> lastEvaluationOutVars;
|
|
|
|
std::map<std::string, PatternVariable> patternVariables;
|
2022-11-07 00:04:47 +01:00
|
|
|
std::map<u64, pl::api::Section> sections;
|
2022-10-26 08:54:43 +02:00
|
|
|
|
|
|
|
std::list<EnvVar> envVarEntries;
|
2022-08-08 21:23:52 +02:00
|
|
|
} patternLanguage;
|
|
|
|
|
|
|
|
std::list<ImHexApi::Bookmarks::Entry> bookmarks;
|
|
|
|
|
2022-10-26 08:54:43 +02:00
|
|
|
struct DataProcessor {
|
2022-08-08 21:23:52 +02:00
|
|
|
std::list<dp::Node*> endNodes;
|
|
|
|
std::list<std::unique_ptr<dp::Node>> nodes;
|
|
|
|
std::list<dp::Link> links;
|
|
|
|
|
|
|
|
std::vector<hex::prv::Overlay *> dataOverlays;
|
|
|
|
std::optional<dp::Node::NodeError> currNodeError;
|
|
|
|
} dataProcessor;
|
2022-09-18 16:22:08 +02:00
|
|
|
|
2022-10-26 08:54:43 +02:00
|
|
|
struct HexEditor {
|
2022-09-18 16:22:08 +02:00
|
|
|
std::optional<u64> selectionStart, selectionEnd;
|
|
|
|
float scrollPosition = 0.0F;
|
|
|
|
} editor;
|
2022-08-08 21:23:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static Data& getCurrent() {
|
|
|
|
return get(ImHexApi::Provider::get());
|
|
|
|
}
|
|
|
|
|
|
|
|
static Data& get(hex::prv::Provider *provider) {
|
|
|
|
return s_data[provider];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void erase(hex::prv::Provider *provider) {
|
|
|
|
s_data.erase(provider);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool markDirty() {
|
|
|
|
return getCurrent().dataDirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ProviderExtraData() = default;
|
|
|
|
static inline std::map<hex::prv::Provider*, Data> s_data = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|