2020-11-19 11:36:52 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
2021-01-11 23:54:12 +01:00
|
|
|
#include <imgui.h>
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-01-13 17:28:27 +01:00
|
|
|
#include <hex/providers/provider.hpp>
|
2021-09-08 15:18:24 +02:00
|
|
|
#include <hex/pattern_language/token.hpp>
|
2021-10-02 15:22:38 +02:00
|
|
|
#include <hex/pattern_language/evaluator.hpp>
|
|
|
|
|
2021-01-13 17:28:27 +01:00
|
|
|
#include <hex/views/view.hpp>
|
2021-08-29 22:15:18 +02:00
|
|
|
#include <hex/helpers/utils.hpp>
|
|
|
|
#include <hex/helpers/fmt.hpp>
|
2021-08-30 19:12:19 +02:00
|
|
|
#include <hex/helpers/concepts.hpp>
|
2021-09-21 21:29:18 +02:00
|
|
|
#include <hex/helpers/logger.hpp>
|
2020-11-19 11:36:52 +01:00
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
#include <cstring>
|
2021-05-02 20:13:37 +02:00
|
|
|
#include <codecvt>
|
|
|
|
#include <locale>
|
2020-11-19 11:36:52 +01:00
|
|
|
#include <random>
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
#include <string>
|
2021-09-11 14:41:18 +02:00
|
|
|
#include <type_traits>
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
namespace hex::pl {
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2020-11-23 13:10:14 +01:00
|
|
|
using namespace ::std::literals::string_literals;
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
namespace {
|
|
|
|
|
2021-08-30 19:12:19 +02:00
|
|
|
template<hex::has_size<1> T>
|
2021-08-29 11:10:48 +02:00
|
|
|
std::string makeDisplayable(T *data, size_t size) {
|
2020-11-19 11:36:52 +01:00
|
|
|
std::string result;
|
2021-08-29 11:10:48 +02:00
|
|
|
for (T* c = data; c < (data + size); c++) {
|
2020-11-19 11:36:52 +01:00
|
|
|
if (iscntrl(*c) || *c > 0x7F)
|
|
|
|
result += " ";
|
|
|
|
else
|
2021-04-12 20:49:37 +02:00
|
|
|
result += static_cast<char>(*c);
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-27 14:02:14 +01:00
|
|
|
if (size != 0 && *(data + size - 1) == '\x00')
|
2021-01-07 21:16:34 +01:00
|
|
|
result.pop_back();
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
class Inlinable {
|
|
|
|
public:
|
|
|
|
[[nodiscard]] bool isInlined() const { return this->m_inlined; }
|
|
|
|
void setInlined(bool inlined) { this->m_inlined = inlined; }
|
|
|
|
private:
|
|
|
|
bool m_inlined = false;
|
|
|
|
};
|
|
|
|
|
2021-10-02 15:22:38 +02:00
|
|
|
class PatternCreationLimiter {
|
|
|
|
public:
|
|
|
|
explicit PatternCreationLimiter(Evaluator *evaluator) : m_evaluator(evaluator) {
|
2021-10-03 12:32:58 +02:00
|
|
|
if (this->m_evaluator == nullptr) return;
|
|
|
|
|
2021-10-02 15:22:38 +02:00
|
|
|
this->m_evaluator->patternCreated();
|
|
|
|
}
|
|
|
|
|
|
|
|
PatternCreationLimiter(const PatternCreationLimiter &other) {
|
|
|
|
this->m_evaluator = other.m_evaluator;
|
2021-10-03 23:07:33 +02:00
|
|
|
|
|
|
|
if (this->m_evaluator == nullptr) return;
|
2021-10-02 15:22:38 +02:00
|
|
|
this->m_evaluator->patternCreated();
|
|
|
|
}
|
|
|
|
|
|
|
|
~PatternCreationLimiter() {
|
2021-10-03 12:32:58 +02:00
|
|
|
if (this->m_evaluator == nullptr) return;
|
|
|
|
|
2021-10-02 15:22:38 +02:00
|
|
|
this->m_evaluator->patternDestroyed();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2021-10-03 23:07:33 +02:00
|
|
|
Evaluator *m_evaluator = nullptr;
|
2021-10-02 15:22:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class PatternData : public PatternCreationLimiter {
|
2020-11-19 11:36:52 +01:00
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternData(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternCreationLimiter(evaluator), m_offset(offset), m_size(size), m_color(color), m_parent(nullptr), m_evaluator(evaluator) {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
constexpr u32 Palette[] = { 0x70b4771f, 0x700e7fff, 0x702ca02c, 0x702827d6, 0x70bd6794, 0x704b568c, 0x70c277e3, 0x707f7f7f, 0x7022bdbc, 0x70cfbe17 };
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
if (color != 0)
|
|
|
|
return;
|
|
|
|
|
2021-01-13 23:08:41 +01:00
|
|
|
this->m_color = Palette[SharedData::patternPaletteOffset++];
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-01-13 23:08:41 +01:00
|
|
|
if (SharedData::patternPaletteOffset >= (sizeof(Palette) / sizeof(u32)))
|
|
|
|
SharedData::patternPaletteOffset = 0;
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
2021-09-06 20:35:38 +02:00
|
|
|
|
|
|
|
PatternData(const PatternData &other) = default;
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
virtual ~PatternData() = default;
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
virtual PatternData* clone() = 0;
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
[[nodiscard]] u64 getOffset() const { return this->m_offset; }
|
2021-09-06 20:35:38 +02:00
|
|
|
virtual void setOffset(u64 offset) { this->m_offset = offset; }
|
2021-04-12 20:49:37 +02:00
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
[[nodiscard]] size_t getSize() const { return this->m_size; }
|
2021-04-12 20:49:37 +02:00
|
|
|
void setSize(size_t size) { this->m_size = size; }
|
2020-11-21 23:00:09 +01:00
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] const std::string& getVariableName() const { return this->m_variableName; }
|
|
|
|
void setVariableName(std::string name) { this->m_variableName = std::move(name); }
|
|
|
|
|
2021-01-21 20:55:10 +01:00
|
|
|
[[nodiscard]] const std::optional<std::string>& getComment() const { return this->m_comment; }
|
|
|
|
void setComment(std::string comment) { this->m_comment = std::move(comment); }
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] const std::string& getTypeName() const { return this->m_typeName; }
|
|
|
|
void setTypeName(std::string name) { this->m_typeName = std::move(name); }
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
[[nodiscard]] u32 getColor() const { return this->m_color; }
|
2021-12-31 11:01:22 +01:00
|
|
|
virtual void setColor(u32 color) { this->m_color = color; }
|
2020-11-19 11:36:52 +01:00
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::endian getEndian() const { return this->m_endian; }
|
|
|
|
void setEndian(std::endian endian) { this->m_endian = endian; }
|
2020-12-06 21:40:57 +01:00
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
[[nodiscard]] PatternData* getParent() const { return this->m_parent; }
|
|
|
|
void setParent(PatternData *parent) { this->m_parent = parent; }
|
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
[[nodiscard]] std::string getDisplayName() const { return this->m_displayName.value_or(this->m_variableName); }
|
|
|
|
void setDisplayName(const std::string &name) { this->m_displayName = name; }
|
|
|
|
|
2021-09-27 18:32:48 +02:00
|
|
|
[[nodiscard]] Evaluator* getEvaluator() const { return this->m_evaluator; }
|
|
|
|
|
|
|
|
[[nodiscard]] const auto& getTransformFunction() const { return this->m_transformFunction; }
|
2021-12-20 20:40:28 +01:00
|
|
|
void setTransformFunction(const ContentRegistry::PatternLanguage::Function &function) { this->m_transformFunction = function; }
|
2021-09-27 18:32:48 +02:00
|
|
|
[[nodiscard]] const auto& getFormatterFunction() const { return this->m_formatterFunction; }
|
2021-12-20 20:40:28 +01:00
|
|
|
void setFormatterFunction(const ContentRegistry::PatternLanguage::Function &function) { this->m_formatterFunction = function; }
|
2021-09-21 21:29:18 +02:00
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
virtual void createEntry(prv::Provider* &provider) = 0;
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] virtual std::string getFormattedName() const = 0;
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
virtual std::optional<u32> highlightBytes(size_t offset) {
|
2021-01-03 02:37:37 +01:00
|
|
|
auto currOffset = this->getOffset();
|
|
|
|
if (offset >= currOffset && offset < (currOffset + this->getSize()))
|
2020-11-19 11:36:52 +01:00
|
|
|
return this->getColor();
|
|
|
|
else
|
|
|
|
return { };
|
|
|
|
}
|
|
|
|
|
2021-01-03 02:37:37 +01:00
|
|
|
virtual std::map<u64, u32> getHighlightedAddresses() {
|
2021-06-17 23:42:43 +02:00
|
|
|
if (this->isHidden()) return { };
|
2021-01-03 02:37:37 +01:00
|
|
|
if (this->m_highlightedAddresses.empty()) {
|
|
|
|
for (u64 i = 0; i < this->getSize(); i++)
|
|
|
|
this->m_highlightedAddresses.insert({ this->getOffset() + i, this->getColor() });
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->m_highlightedAddresses;
|
|
|
|
}
|
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
virtual void clearHighlightedAddresses() {
|
|
|
|
this->m_highlightedAddresses.clear();
|
|
|
|
}
|
|
|
|
|
2020-11-19 21:19:03 +01:00
|
|
|
virtual void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) { }
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-11-04 20:32:34 +01:00
|
|
|
[[nodiscard]]
|
|
|
|
virtual std::string toString(prv::Provider *provider) const {
|
|
|
|
return hex::format("{} {} @ 0x{:X}", this->getTypeName(), this->getVariableName(), this->getOffset());
|
|
|
|
}
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
static bool sortPatternDataTable(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider, pl::PatternData* left, pl::PatternData* right) {
|
2020-11-19 21:19:03 +01:00
|
|
|
if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("name")) {
|
|
|
|
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
2021-09-21 21:29:18 +02:00
|
|
|
return left->getDisplayName() > right->getDisplayName();
|
2020-11-19 21:19:03 +01:00
|
|
|
else
|
2021-09-21 21:29:18 +02:00
|
|
|
return left->getDisplayName() < right->getDisplayName();
|
2020-11-19 21:19:03 +01:00
|
|
|
}
|
2020-11-20 00:16:50 +01:00
|
|
|
else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("offset")) {
|
2020-11-19 21:19:03 +01:00
|
|
|
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
|
|
|
return left->getOffset() > right->getOffset();
|
|
|
|
else
|
|
|
|
return left->getOffset() < right->getOffset();
|
|
|
|
}
|
|
|
|
else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("size")) {
|
|
|
|
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
|
|
|
return left->getSize() > right->getSize();
|
|
|
|
else
|
|
|
|
return left->getSize() < right->getSize();
|
|
|
|
}
|
|
|
|
else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("value")) {
|
|
|
|
size_t biggerSize = std::max(left->getSize(), right->getSize());
|
|
|
|
std::vector<u8> leftBuffer(biggerSize, 0x00), rightBuffer(biggerSize, 0x00);
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(left->getOffset(), leftBuffer.data(), left->getSize());
|
|
|
|
provider->read(right->getOffset(), rightBuffer.data(), right->getSize());
|
2020-11-19 21:19:03 +01:00
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
if (left->m_endian != std::endian::native)
|
2020-11-22 16:22:02 +01:00
|
|
|
std::reverse(leftBuffer.begin(), leftBuffer.end());
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
if (right->m_endian != std::endian::native)
|
2020-11-22 16:22:02 +01:00
|
|
|
std::reverse(rightBuffer.begin(), rightBuffer.end());
|
|
|
|
|
2020-11-19 21:19:03 +01:00
|
|
|
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
|
|
|
return leftBuffer > rightBuffer;
|
|
|
|
else
|
|
|
|
return leftBuffer < rightBuffer;
|
|
|
|
}
|
|
|
|
else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("type")) {
|
|
|
|
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
|
|
|
return left->getTypeName() > right->getTypeName();
|
|
|
|
else
|
|
|
|
return left->getTypeName() < right->getTypeName();
|
|
|
|
}
|
|
|
|
else if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("color")) {
|
|
|
|
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
|
|
|
return left->getColor() > right->getColor();
|
|
|
|
else
|
|
|
|
return left->getColor() < right->getColor();
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-17 23:42:43 +02:00
|
|
|
void draw(prv::Provider *provider) {
|
|
|
|
if (isHidden()) return;
|
|
|
|
|
|
|
|
this->createEntry(provider);
|
|
|
|
}
|
|
|
|
|
2021-01-13 23:08:41 +01:00
|
|
|
static void resetPalette() { SharedData::patternPaletteOffset = 0; }
|
2020-11-19 21:19:03 +01:00
|
|
|
|
2021-06-17 23:42:43 +02:00
|
|
|
void setHidden(bool hidden) {
|
|
|
|
this->m_hidden = hidden;
|
|
|
|
}
|
|
|
|
|
2021-06-20 21:22:31 +02:00
|
|
|
[[nodiscard]] bool isHidden() const {
|
2021-06-17 23:42:43 +02:00
|
|
|
return this->m_hidden;
|
|
|
|
}
|
|
|
|
|
2021-06-20 21:22:31 +02:00
|
|
|
void setLocal(bool local) {
|
|
|
|
this->m_local = local;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool isLocal() const {
|
|
|
|
return this->m_local;
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] virtual bool operator!=(const PatternData &other) const final { return !operator==(other); }
|
|
|
|
[[nodiscard]] virtual bool operator==(const PatternData &other) const = 0;
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
[[nodiscard]] bool areCommonPropertiesEqual(const PatternData &other) const {
|
|
|
|
return
|
|
|
|
typeid(other) == typeid(std::remove_cvref_t<T>) &&
|
|
|
|
this->m_offset == other.m_offset &&
|
|
|
|
this->m_size == other.m_size &&
|
|
|
|
this->m_hidden == other.m_hidden &&
|
|
|
|
this->m_endian == other.m_endian &&
|
|
|
|
this->m_variableName == other.m_variableName &&
|
|
|
|
this->m_typeName == other.m_typeName &&
|
|
|
|
this->m_comment == other.m_comment &&
|
|
|
|
this->m_local == other.m_local;
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
protected:
|
2021-09-21 21:29:18 +02:00
|
|
|
void createDefaultEntry(const std::string &value, const Token::Literal &literal) const {
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextRow();
|
2021-09-21 21:29:18 +02:00
|
|
|
ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2020-11-23 22:14:11 +01:00
|
|
|
if (ImGui::Selectable(("##PatternDataLine"s + std::to_string(this->getOffset())).c_str(), false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap)) {
|
2021-03-27 11:36:36 +01:00
|
|
|
EventManager::post<RequestSelectionChange>(Region { this->getOffset(), this->getSize() });
|
2020-11-23 13:10:14 +01:00
|
|
|
}
|
2021-01-21 20:55:10 +01:00
|
|
|
this->drawCommentTooltip();
|
2020-11-23 13:10:14 +01:00
|
|
|
ImGui::SameLine();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted(this->getDisplayName().c_str());
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
2020-11-23 22:14:11 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:04X}", this->getSize());
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", this->getFormattedName());
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-09-21 21:29:18 +02:00
|
|
|
|
|
|
|
if (!this->m_formatterFunction.has_value())
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted(value.c_str());
|
2021-09-21 21:29:18 +02:00
|
|
|
else {
|
2021-09-27 18:32:48 +02:00
|
|
|
auto result = this->m_formatterFunction->func(this->getEvaluator(), { literal });
|
2021-09-21 21:29:18 +02:00
|
|
|
|
|
|
|
if (result.has_value()) {
|
|
|
|
if (auto displayValue = std::get_if<std::string>(&result.value()); displayValue != nullptr)
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted(displayValue->c_str());
|
2021-09-21 21:29:18 +02:00
|
|
|
} else {
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted("???");
|
2021-09-21 21:29:18 +02:00
|
|
|
}
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
2021-01-21 20:55:10 +01:00
|
|
|
void drawCommentTooltip() const {
|
|
|
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) && this->getComment().has_value()) {
|
|
|
|
ImGui::BeginTooltip();
|
|
|
|
ImGui::TextUnformatted(this->getComment()->c_str());
|
|
|
|
ImGui::EndTooltip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-22 16:22:02 +01:00
|
|
|
protected:
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
std::endian m_endian = std::endian::native;
|
2021-01-03 02:37:37 +01:00
|
|
|
std::map<u64, u32> m_highlightedAddresses;
|
2021-06-17 23:42:43 +02:00
|
|
|
bool m_hidden = false;
|
2020-11-22 16:22:02 +01:00
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
private:
|
|
|
|
u64 m_offset;
|
|
|
|
size_t m_size;
|
|
|
|
|
|
|
|
u32 m_color;
|
2021-09-21 21:29:18 +02:00
|
|
|
std::optional<std::string> m_displayName;
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
std::string m_variableName;
|
2021-01-21 20:55:10 +01:00
|
|
|
std::optional<std::string> m_comment;
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
std::string m_typeName;
|
2021-04-12 20:49:37 +02:00
|
|
|
|
2021-09-27 18:32:48 +02:00
|
|
|
Evaluator *m_evaluator = nullptr;
|
2021-12-20 20:40:28 +01:00
|
|
|
std::optional<ContentRegistry::PatternLanguage::Function> m_formatterFunction;
|
|
|
|
std::optional<ContentRegistry::PatternLanguage::Function> m_transformFunction;
|
2021-09-21 21:29:18 +02:00
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
PatternData *m_parent;
|
2021-06-20 21:22:31 +02:00
|
|
|
bool m_local = false;
|
2020-11-19 11:36:52 +01:00
|
|
|
};
|
|
|
|
|
2020-11-20 21:59:27 +01:00
|
|
|
class PatternDataPadding : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataPadding(u64 offset, size_t size, Evaluator *evaluator) : PatternData(offset, size, evaluator, 0xFF000000) { }
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataPadding(*this);
|
|
|
|
}
|
2020-11-20 21:59:27 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
2020-11-20 21:59:27 +01:00
|
|
|
return "";
|
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2020-11-20 21:59:27 +01:00
|
|
|
};
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2020-11-21 23:00:09 +01:00
|
|
|
class PatternDataPointer : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataPointer(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color), m_pointedAt(nullptr) {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
}
|
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
PatternDataPointer(const PatternDataPointer &other) : PatternData(other) {
|
2021-04-12 20:49:37 +02:00
|
|
|
this->m_pointedAt = other.m_pointedAt->clone();
|
|
|
|
}
|
|
|
|
|
2021-02-19 10:51:30 +01:00
|
|
|
~PatternDataPointer() override {
|
|
|
|
delete this->m_pointedAt;
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataPointer(*this);
|
2020-11-21 23:00:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
u64 data = 0;
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &data, this->getSize());
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
data = hex::changeEndianess(data, this->getSize(), this->getEndian());
|
2020-11-21 23:00:09 +01:00
|
|
|
|
2020-11-23 13:08:24 +01:00
|
|
|
ImGui::TableNextRow();
|
2020-11-21 23:00:09 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-09-21 21:29:18 +02:00
|
|
|
bool open = ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
2021-01-21 20:55:10 +01:00
|
|
|
this->drawCommentTooltip();
|
2020-11-21 23:00:09 +01:00
|
|
|
ImGui::TableNextColumn();
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
2020-11-23 22:14:11 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2020-11-21 23:00:09 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:04X}", this->getSize());
|
2020-11-21 23:00:09 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{}", this->getFormattedName());
|
2020-11-21 23:00:09 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("*(0x{0})", data);
|
2020-11-21 23:00:09 +01:00
|
|
|
|
|
|
|
if (open) {
|
|
|
|
this->m_pointedAt->createEntry(provider);
|
|
|
|
|
|
|
|
ImGui::TreePop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
std::optional<u32> highlightBytes(size_t offset) override {
|
2020-11-21 23:00:09 +01:00
|
|
|
if (offset >= this->getOffset() && offset < (this->getOffset() + this->getSize()))
|
|
|
|
return this->getColor();
|
|
|
|
else if (auto color = this->m_pointedAt->highlightBytes(offset); color.has_value())
|
|
|
|
return color.value();
|
|
|
|
else
|
|
|
|
return { };
|
|
|
|
}
|
|
|
|
|
2021-01-03 02:37:37 +01:00
|
|
|
std::map<u64, u32> getHighlightedAddresses() override {
|
|
|
|
if (this->m_highlightedAddresses.empty()) {
|
|
|
|
auto ownAddresses = PatternData::getHighlightedAddresses();
|
|
|
|
auto pointedToAddresses = this->m_pointedAt->getHighlightedAddresses();
|
|
|
|
|
|
|
|
ownAddresses.merge(pointedToAddresses);
|
|
|
|
this->m_highlightedAddresses = ownAddresses;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->m_highlightedAddresses;
|
|
|
|
}
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
2021-04-16 15:59:13 +02:00
|
|
|
std::string result = this->m_pointedAt->getFormattedName() + "* : ";
|
|
|
|
switch (this->getSize()) {
|
|
|
|
case 1: result += "u8"; break;
|
|
|
|
case 2: result += "u16"; break;
|
|
|
|
case 4: result += "u32"; break;
|
|
|
|
case 8: result += "u64"; break;
|
|
|
|
case 16: result += "u128"; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2020-11-21 23:00:09 +01:00
|
|
|
}
|
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
void setPointedAtPattern(PatternData *pattern) {
|
|
|
|
this->m_pointedAt = pattern;
|
2021-09-27 20:16:23 +02:00
|
|
|
this->m_pointedAt->setVariableName(hex::format("*({})", this->getVariableName()));
|
2021-04-12 20:49:37 +02:00
|
|
|
}
|
|
|
|
|
2021-01-08 20:12:16 +01:00
|
|
|
[[nodiscard]] PatternData* getPointedAtPattern() {
|
|
|
|
return this->m_pointedAt;
|
|
|
|
}
|
|
|
|
|
2021-12-31 11:01:22 +01:00
|
|
|
void setColor(u32 color) override {
|
|
|
|
PatternData::setColor(color);
|
|
|
|
this->m_pointedAt->setColor(color);
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override {
|
|
|
|
return areCommonPropertiesEqual<decltype(*this)>(other) &&
|
|
|
|
*static_cast<const PatternDataPointer*>(&other)->m_pointedAt == *this->m_pointedAt;
|
|
|
|
}
|
|
|
|
|
2021-09-27 18:32:48 +02:00
|
|
|
void rebase(u64 base) {
|
|
|
|
this->m_pointedAt->setOffset((this->m_pointedAt->getOffset() - this->m_pointerBase) + base);
|
|
|
|
this->m_pointerBase = base;
|
|
|
|
}
|
|
|
|
|
2020-11-21 23:00:09 +01:00
|
|
|
private:
|
|
|
|
PatternData *m_pointedAt;
|
2021-09-27 18:32:48 +02:00
|
|
|
u64 m_pointerBase = 0;
|
2020-11-21 23:00:09 +01:00
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
class PatternDataUnsigned : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataUnsigned(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) { }
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataUnsigned(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2021-09-21 21:29:18 +02:00
|
|
|
u128 data = 0;
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &data, this->getSize());
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
data = hex::changeEndianess(data, this->getSize(), this->getEndian());
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
this->createDefaultEntry(hex::format("{:d} (0x{:0{}X})", data, data, this->getSize() * 2), data);
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
2020-11-19 11:36:52 +01:00
|
|
|
switch (this->getSize()) {
|
|
|
|
case 1: return "u8";
|
|
|
|
case 2: return "u16";
|
|
|
|
case 4: return "u32";
|
|
|
|
case 8: return "u64";
|
|
|
|
case 16: return "u128";
|
|
|
|
default: return "Unsigned data";
|
|
|
|
}
|
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2020-11-19 11:36:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class PatternDataSigned : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataSigned(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) { }
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataSigned(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2021-09-21 21:29:18 +02:00
|
|
|
s128 data = 0;
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &data, this->getSize());
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
data = hex::changeEndianess(data, this->getSize(), this->getEndian());
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
data = hex::signExtend(this->getSize() * 8, data);
|
|
|
|
this->createDefaultEntry(hex::format("{:d} (0x{:0{}X})", data, data, 1 * 2), data);
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
2020-11-19 11:36:52 +01:00
|
|
|
switch (this->getSize()) {
|
|
|
|
case 1: return "s8";
|
|
|
|
case 2: return "s16";
|
|
|
|
case 4: return "s32";
|
|
|
|
case 8: return "s64";
|
|
|
|
case 16: return "s128";
|
|
|
|
default: return "Signed data";
|
|
|
|
}
|
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2020-11-19 11:36:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class PatternDataFloat : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataFloat(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) { }
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataFloat(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
if (this->getSize() == 4) {
|
2021-01-08 17:46:31 +01:00
|
|
|
u32 data = 0;
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &data, 4);
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
data = hex::changeEndianess(data, 4, this->getEndian());
|
2020-11-22 16:22:02 +01:00
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
this->createDefaultEntry(hex::format("{:e} (0x{:0{}X})", *reinterpret_cast<float*>(&data), data, this->getSize() * 2), *reinterpret_cast<float*>(&data));
|
2020-11-19 11:36:52 +01:00
|
|
|
} else if (this->getSize() == 8) {
|
2021-01-08 17:46:31 +01:00
|
|
|
u64 data = 0;
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &data, 8);
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
data = hex::changeEndianess(data, 8, this->getEndian());
|
2020-11-22 16:22:02 +01:00
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
this->createDefaultEntry(hex::format("{:e} (0x{:0{}X})", *reinterpret_cast<double*>(&data), data, this->getSize() * 2), *reinterpret_cast<double*>(&data));
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
2020-11-19 11:36:52 +01:00
|
|
|
switch (this->getSize()) {
|
|
|
|
case 4: return "float";
|
|
|
|
case 8: return "double";
|
|
|
|
default: return "Floating point data";
|
|
|
|
}
|
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2020-11-19 11:36:52 +01:00
|
|
|
};
|
|
|
|
|
2021-01-07 17:34:50 +01:00
|
|
|
class PatternDataBoolean : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
explicit PatternDataBoolean(u64 offset, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, 1, evaluator, color) { }
|
2021-01-07 17:34:50 +01:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataBoolean(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
u8 boolean;
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &boolean, 1);
|
2021-01-07 17:34:50 +01:00
|
|
|
|
|
|
|
if (boolean == 0)
|
2021-09-21 21:29:18 +02:00
|
|
|
this->createDefaultEntry("false", false);
|
2021-01-07 17:34:50 +01:00
|
|
|
else if (boolean == 1)
|
2021-09-21 21:29:18 +02:00
|
|
|
this->createDefaultEntry("true", true);
|
2021-01-07 17:34:50 +01:00
|
|
|
else
|
2021-09-21 21:29:18 +02:00
|
|
|
this->createDefaultEntry("true*", true);
|
2021-01-07 17:34:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "bool";
|
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2021-01-07 17:34:50 +01:00
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
class PatternDataCharacter : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
explicit PatternDataCharacter(u64 offset, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, 1, evaluator, color) { }
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataCharacter(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
char character;
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &character, 1);
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
this->createDefaultEntry(hex::format("'{0}'", character), character);
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
2021-01-07 17:34:50 +01:00
|
|
|
return "char";
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2020-11-19 11:36:52 +01:00
|
|
|
};
|
|
|
|
|
2021-05-02 20:13:37 +02:00
|
|
|
class PatternDataCharacter16 : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
explicit PatternDataCharacter16(u64 offset, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, 2, evaluator, color) { }
|
2021-05-02 20:13:37 +02:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataCharacter16(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
char16_t character;
|
|
|
|
provider->read(this->getOffset(), &character, 2);
|
2021-08-29 11:10:48 +02:00
|
|
|
character = hex::changeEndianess(character, this->getEndian());
|
2021-05-02 20:13:37 +02:00
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
u128 literal = character;
|
|
|
|
this->createDefaultEntry(hex::format("'{0}'", std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(character)), literal);
|
2021-05-02 20:13:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "char16";
|
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
2021-11-04 20:32:34 +01:00
|
|
|
[[nodiscard]] std::string toString(prv::Provider *provider) const override {
|
|
|
|
char16_t character;
|
|
|
|
provider->read(this->getOffset(), &character, 2);
|
|
|
|
character = hex::changeEndianess(character, this->getEndian());
|
|
|
|
|
|
|
|
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(character);
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2021-05-02 20:13:37 +02:00
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
class PatternDataString : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataString(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) { }
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataString(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2021-10-11 20:59:14 +02:00
|
|
|
auto size = std::min<size_t>(this->getSize(), 0x7F);
|
2021-11-27 14:02:14 +01:00
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
return;
|
|
|
|
|
2021-10-11 20:59:14 +02:00
|
|
|
std::string buffer(size, 0x00);
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-10-11 20:59:14 +02:00
|
|
|
provider->read(this->getOffset(), buffer.data(), size);
|
|
|
|
|
2021-11-10 14:45:26 +01:00
|
|
|
std::erase_if(buffer, [](auto c){
|
|
|
|
return c == 0x00;
|
|
|
|
});
|
|
|
|
|
2021-10-11 20:59:14 +02:00
|
|
|
this->createDefaultEntry(hex::format("\"{0}\" {1}", makeDisplayable(buffer.data(), this->getSize()), size > this->getSize() ? "(truncated)" : ""), buffer);
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
2020-11-19 11:36:52 +01:00
|
|
|
return "String";
|
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
2021-11-04 20:32:34 +01:00
|
|
|
[[nodiscard]] std::string toString(prv::Provider *provider) const override {
|
|
|
|
std::string buffer(this->getSize(), 0x00);
|
|
|
|
provider->read(this->getOffset(), buffer.data(), buffer.size());
|
|
|
|
|
2021-11-10 14:45:26 +01:00
|
|
|
std::erase_if(buffer, [](auto c){
|
|
|
|
return c == 0x00;
|
|
|
|
});
|
|
|
|
|
2021-11-04 20:32:34 +01:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2020-11-19 11:36:52 +01:00
|
|
|
};
|
|
|
|
|
2021-05-02 20:13:37 +02:00
|
|
|
class PatternDataString16 : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataString16(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) { }
|
2021-05-02 20:13:37 +02:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataString16(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2021-10-11 20:59:14 +02:00
|
|
|
auto size = std::min<size_t>(this->getSize(), 0x100);
|
|
|
|
|
2021-11-27 14:02:14 +01:00
|
|
|
if (size == 0)
|
|
|
|
return;
|
|
|
|
|
2021-11-11 13:24:01 +01:00
|
|
|
std::u16string buffer(this->getSize()/sizeof(char16_t), 0x00);
|
2021-10-11 20:59:14 +02:00
|
|
|
provider->read(this->getOffset(), buffer.data(), size);
|
2021-08-29 11:10:48 +02:00
|
|
|
|
|
|
|
for (auto &c : buffer)
|
|
|
|
c = hex::changeEndianess(c, 2, this->getEndian());
|
2021-05-02 20:13:37 +02:00
|
|
|
|
2021-11-10 14:45:26 +01:00
|
|
|
std::erase_if(buffer, [](auto c){
|
|
|
|
return c == 0x00;
|
|
|
|
});
|
|
|
|
|
2021-05-02 20:13:37 +02:00
|
|
|
auto utf8String = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(buffer);
|
|
|
|
|
2021-10-11 20:59:14 +02:00
|
|
|
this->createDefaultEntry(hex::format("\"{0}\" {1}", utf8String, size > this->getSize() ? "(truncated)" : ""), utf8String);
|
2021-05-02 20:13:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "String16";
|
|
|
|
}
|
2021-09-11 14:41:18 +02:00
|
|
|
|
2021-11-04 20:32:34 +01:00
|
|
|
[[nodiscard]] std::string toString(prv::Provider *provider) const override {
|
2021-11-11 13:24:01 +01:00
|
|
|
std::u16string buffer(this->getSize()/sizeof(char16_t), 0x00);
|
|
|
|
provider->read(this->getOffset(), buffer.data(), this->getSize());
|
2021-11-04 20:32:34 +01:00
|
|
|
|
|
|
|
for (auto &c : buffer)
|
|
|
|
c = hex::changeEndianess(c, 2, this->getEndian());
|
|
|
|
|
2021-11-10 14:45:26 +01:00
|
|
|
std::erase_if(buffer, [](auto c){
|
|
|
|
return c == 0x00;
|
|
|
|
});
|
|
|
|
|
2021-11-04 20:32:34 +01:00
|
|
|
return std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(buffer);
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override { return areCommonPropertiesEqual<decltype(*this)>(other); }
|
2021-05-02 20:13:37 +02:00
|
|
|
};
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
class PatternDataDynamicArray : public PatternData, public Inlinable {
|
2020-11-19 11:36:52 +01:00
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataDynamicArray(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) {
|
2021-03-02 14:23:06 +01:00
|
|
|
}
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
PatternDataDynamicArray(const PatternDataDynamicArray &other) : PatternData(other) {
|
2021-04-12 20:49:37 +02:00
|
|
|
std::vector<PatternData*> entries;
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
for (const auto &entry : other.m_entries)
|
2021-04-12 20:49:37 +02:00
|
|
|
entries.push_back(entry->clone());
|
|
|
|
|
|
|
|
this->setEntries(entries);
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
}
|
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
~PatternDataDynamicArray() override {
|
2021-02-19 10:51:30 +01:00
|
|
|
for (const auto &entry : this->m_entries)
|
|
|
|
delete entry;
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
PatternData* clone() override {
|
2021-09-06 20:35:38 +02:00
|
|
|
return new PatternDataDynamicArray(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setOffset(u64 offset) override {
|
2021-10-08 21:39:30 +02:00
|
|
|
if (!this->isLocal()) {
|
|
|
|
for (auto &entry : this->m_entries) {
|
|
|
|
entry->setOffset(offset + (entry->getOffset() - this->getOffset()));
|
|
|
|
}
|
2021-09-06 20:35:38 +02:00
|
|
|
}
|
|
|
|
|
2021-10-08 21:39:30 +02:00
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
PatternData::setOffset(offset);
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-12-31 11:01:22 +01:00
|
|
|
void setColor(u32 color) override {
|
|
|
|
PatternData::setColor(color);
|
|
|
|
for (auto &entry : this->m_entries)
|
|
|
|
entry->setColor(color);
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2020-12-06 23:15:51 +01:00
|
|
|
if (this->m_entries.empty())
|
|
|
|
return;
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
bool open = true;
|
2021-09-29 20:51:57 +02:00
|
|
|
if (!this->isInlined()) {
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
open = ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth);
|
|
|
|
this->drawCommentTooltip();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:04X}", this->getSize());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{0}", this->m_entries[0]->getTypeName());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::SameLine(0, 0);
|
|
|
|
|
|
|
|
ImGui::TextUnformatted("[");
|
|
|
|
ImGui::SameLine(0, 0);
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormattedColored(ImColor(0xFF00FF00), "{0}", this->m_entries.size());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::SameLine(0, 0);
|
|
|
|
ImGui::TextUnformatted("]");
|
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted("{ ... }");
|
2021-09-27 13:31:10 +02:00
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
if (open) {
|
|
|
|
for (auto &member : this->m_entries)
|
2021-06-17 23:42:43 +02:00
|
|
|
member->draw(provider);
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
if (!this->isInlined())
|
|
|
|
ImGui::TreePop();
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<u32> highlightBytes(size_t offset) override{
|
|
|
|
for (auto &entry : this->m_entries) {
|
|
|
|
if (auto color = entry->highlightBytes(offset); color.has_value())
|
|
|
|
return color.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
return { };
|
|
|
|
}
|
|
|
|
|
2021-01-03 02:37:37 +01:00
|
|
|
std::map<u64, u32> getHighlightedAddresses() override {
|
|
|
|
if (this->m_highlightedAddresses.empty()) {
|
|
|
|
for (auto &entry : this->m_entries) {
|
|
|
|
this->m_highlightedAddresses.merge(entry->getHighlightedAddresses());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->m_highlightedAddresses;
|
|
|
|
}
|
2021-04-12 20:49:37 +02:00
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
void clearHighlightedAddresses() override {
|
|
|
|
for (auto &entry : this->m_entries)
|
|
|
|
entry->clearHighlightedAddresses();
|
|
|
|
PatternData::clearHighlightedAddresses();
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
2020-11-19 11:36:52 +01:00
|
|
|
return this->m_entries[0]->getTypeName() + "[" + std::to_string(this->m_entries.size()) + "]";
|
|
|
|
}
|
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
[[nodiscard]] const std::vector<PatternData*>& getEntries() {
|
|
|
|
return this->m_entries;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setEntries(const std::vector<PatternData*> &entries) {
|
|
|
|
this->m_entries = entries;
|
|
|
|
|
|
|
|
for (auto &entry : this->m_entries) {
|
|
|
|
entry->setColor(this->getColor());
|
|
|
|
entry->setParent(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override {
|
|
|
|
if (!areCommonPropertiesEqual<decltype(*this)>(other))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &otherArray = *static_cast<const PatternDataDynamicArray*>(&other);
|
|
|
|
if (this->m_entries.size() != otherArray.m_entries.size())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (u64 i = 0; i < this->m_entries.size(); i++) {
|
|
|
|
if (*this->m_entries[i] != *otherArray.m_entries[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
private:
|
|
|
|
std::vector<PatternData*> m_entries;
|
|
|
|
};
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
class PatternDataStaticArray : public PatternData, public Inlinable {
|
2021-09-06 20:35:38 +02:00
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataStaticArray(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) {
|
2021-09-06 20:35:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PatternDataStaticArray(const PatternDataStaticArray &other) : PatternData(other) {
|
|
|
|
this->setEntries(other.getTemplate()->clone(), other.getEntryCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
~PatternDataStaticArray() override {
|
|
|
|
delete this->m_template;
|
|
|
|
}
|
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataStaticArray(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
if (this->getEntryCount() == 0)
|
|
|
|
return;
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
bool open = true;
|
|
|
|
|
2021-09-29 20:51:57 +02:00
|
|
|
if (!this->isInlined()) {
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
open = ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth);
|
|
|
|
this->drawCommentTooltip();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:04X}", this->getSize());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormattedColored(ImColor(0xFF9BC64D), "{0}", this->m_template->getTypeName().c_str());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::SameLine(0, 0);
|
|
|
|
|
|
|
|
ImGui::TextUnformatted("[");
|
|
|
|
ImGui::SameLine(0, 0);
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormattedColored(ImColor(0xFF00FF00), "{0}", this->m_entryCount);
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::SameLine(0, 0);
|
|
|
|
ImGui::TextUnformatted("]");
|
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted("{ ... }");
|
2021-09-27 13:31:10 +02:00
|
|
|
}
|
2021-09-06 20:35:38 +02:00
|
|
|
|
|
|
|
if (open) {
|
|
|
|
auto entry = this->m_template->clone();
|
|
|
|
for (u64 index = 0; index < this->m_entryCount; index++) {
|
|
|
|
entry->setVariableName(hex::format("[{0}]", index));
|
|
|
|
entry->setOffset(this->getOffset() + index * this->m_template->getSize());
|
|
|
|
entry->draw(provider);
|
|
|
|
}
|
|
|
|
delete entry;
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
if (!this->isInlined())
|
|
|
|
ImGui::TreePop();
|
2021-09-06 20:35:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<u32> highlightBytes(size_t offset) override{
|
|
|
|
auto entry = this->m_template->clone();
|
2021-09-26 02:23:27 +02:00
|
|
|
ON_SCOPE_EXIT { delete entry; };
|
2021-09-06 20:35:38 +02:00
|
|
|
|
2021-09-26 02:23:27 +02:00
|
|
|
if (offset < this->getOffset() || offset >= this->getOffset() + this->getSize())
|
|
|
|
return { };
|
2021-09-06 20:35:38 +02:00
|
|
|
|
2021-09-26 02:23:27 +02:00
|
|
|
auto index = (offset - this->getOffset()) / this->m_template->getSize();
|
|
|
|
entry->setOffset(this->getOffset() + this->m_template->getSize() * index);
|
|
|
|
if (auto color = entry->highlightBytes(offset); color.has_value())
|
|
|
|
return color.value();
|
|
|
|
else
|
|
|
|
return { };
|
2021-09-06 20:35:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::map<u64, u32> getHighlightedAddresses() override {
|
|
|
|
if (this->m_highlightedAddresses.empty()) {
|
|
|
|
auto entry = this->m_template->clone();
|
|
|
|
|
|
|
|
for (u64 address = this->getOffset(); address < this->getOffset() + this->getSize(); address += this->m_template->getSize()) {
|
|
|
|
entry->setOffset(address);
|
|
|
|
entry->clearHighlightedAddresses();
|
|
|
|
this->m_highlightedAddresses.merge(entry->getHighlightedAddresses());
|
|
|
|
}
|
|
|
|
|
|
|
|
delete entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->m_highlightedAddresses;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clearHighlightedAddresses() override {
|
|
|
|
this->m_template->clearHighlightedAddresses();
|
|
|
|
PatternData::clearHighlightedAddresses();
|
|
|
|
}
|
|
|
|
|
2021-12-31 11:01:22 +01:00
|
|
|
void setColor(u32 color) override {
|
|
|
|
PatternData::setColor(color);
|
|
|
|
this->m_template->setColor(color);
|
|
|
|
}
|
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return this->m_template->getTypeName() + "[" + std::to_string(this->m_entryCount) + "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] PatternData* getTemplate() const {
|
|
|
|
return this->m_template;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] size_t getEntryCount() const {
|
|
|
|
return this->m_entryCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setEntryCount(size_t count) {
|
|
|
|
this->m_entryCount = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setEntries(PatternData* templ, size_t count) {
|
|
|
|
this->m_template = templ;
|
|
|
|
this->m_entryCount = count;
|
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
this->setColor(this->m_template->getColor());
|
|
|
|
this->m_template->setEndian(templ->getEndian());
|
2021-09-06 20:35:38 +02:00
|
|
|
this->m_template->setParent(this);
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override {
|
|
|
|
if (!areCommonPropertiesEqual<decltype(*this)>(other))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &otherArray = *static_cast<const PatternDataStaticArray*>(&other);
|
|
|
|
return *this->m_template == *otherArray.m_template && this->m_entryCount == otherArray.m_entryCount;
|
|
|
|
}
|
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
private:
|
|
|
|
PatternData *m_template;
|
|
|
|
size_t m_entryCount;
|
|
|
|
};
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
class PatternDataStruct : public PatternData, public Inlinable {
|
2020-11-19 11:36:52 +01:00
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataStruct(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color){
|
2021-04-12 20:49:37 +02:00
|
|
|
}
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
PatternDataStruct(const PatternDataStruct &other) : PatternData(other) {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
for (const auto &member : other.m_members)
|
|
|
|
this->m_members.push_back(member->clone());
|
2021-09-06 20:35:38 +02:00
|
|
|
this->m_sortedMembers = this->m_members;
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
}
|
|
|
|
|
2021-02-19 10:51:30 +01:00
|
|
|
~PatternDataStruct() override {
|
|
|
|
for (const auto &member : this->m_members)
|
|
|
|
delete member;
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataStruct(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
void setOffset(u64 offset) override {
|
2021-10-08 21:39:30 +02:00
|
|
|
if (!this->isLocal()) {
|
|
|
|
for (auto &member: this->m_members) {
|
|
|
|
member->setOffset(offset + (member->getOffset() - this->getOffset()));
|
|
|
|
}
|
2021-09-06 20:35:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PatternData::setOffset(offset);
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2021-09-27 13:31:10 +02:00
|
|
|
bool open = true;
|
|
|
|
|
|
|
|
if (!this->isInlined()) {
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
open = ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth);
|
|
|
|
this->drawCommentTooltip();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - (this->getSize() == 0 ? 0 : 1));
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:04X}", this->getSize());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextColored(ImColor(0xFFD69C56), "struct"); ImGui::SameLine(); ImGui::TextUnformatted(this->getTypeName().c_str());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted("{ ... }");
|
2021-09-27 13:31:10 +02:00
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
if (open) {
|
2020-11-19 21:19:03 +01:00
|
|
|
for (auto &member : this->m_sortedMembers)
|
2021-06-17 23:42:43 +02:00
|
|
|
member->draw(provider);
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
if (!this->isInlined())
|
|
|
|
ImGui::TreePop();
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<u32> highlightBytes(size_t offset) override{
|
|
|
|
for (auto &member : this->m_members) {
|
|
|
|
if (auto color = member->highlightBytes(offset); color.has_value())
|
|
|
|
return color.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
return { };
|
|
|
|
}
|
|
|
|
|
2021-01-03 02:37:37 +01:00
|
|
|
std::map<u64, u32> getHighlightedAddresses() override {
|
|
|
|
if (this->m_highlightedAddresses.empty()) {
|
|
|
|
for (auto &member : this->m_members) {
|
|
|
|
this->m_highlightedAddresses.merge(member->getHighlightedAddresses());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->m_highlightedAddresses;
|
|
|
|
}
|
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
void clearHighlightedAddresses() override {
|
|
|
|
for (auto &member : this->m_members)
|
|
|
|
member->clearHighlightedAddresses();
|
|
|
|
PatternData::clearHighlightedAddresses();
|
|
|
|
}
|
|
|
|
|
2021-12-31 11:01:22 +01:00
|
|
|
void setColor(u32 color) override {
|
|
|
|
PatternData::setColor(color);
|
|
|
|
for (auto &member : this->m_members)
|
|
|
|
member->setColor(color);
|
|
|
|
}
|
|
|
|
|
2020-11-19 21:19:03 +01:00
|
|
|
void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) override {
|
|
|
|
this->m_sortedMembers = this->m_members;
|
|
|
|
|
|
|
|
std::sort(this->m_sortedMembers.begin(), this->m_sortedMembers.end(), [&sortSpecs, &provider](PatternData *left, PatternData *right) {
|
|
|
|
return PatternData::sortPatternDataTable(sortSpecs, provider, left, right);
|
|
|
|
});
|
|
|
|
|
|
|
|
for (auto &member : this->m_members)
|
|
|
|
member->sort(sortSpecs, provider);
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "struct " + PatternData::getTypeName();
|
|
|
|
}
|
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
[[nodiscard]] const auto& getMembers() const {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
return this->m_members;
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
void setMembers(const std::vector<PatternData*> & members) {
|
2021-04-13 22:08:02 +02:00
|
|
|
this->m_members.clear();
|
|
|
|
|
2021-04-13 21:50:24 +02:00
|
|
|
for (auto &member : members) {
|
|
|
|
if (member == nullptr) continue;
|
2021-04-12 20:49:37 +02:00
|
|
|
|
2021-04-13 21:50:24 +02:00
|
|
|
this->m_members.push_back(member);
|
2021-04-12 20:49:37 +02:00
|
|
|
member->setParent(this);
|
2021-04-13 21:50:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this->m_sortedMembers = this->m_members;
|
2021-04-12 20:49:37 +02:00
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override {
|
|
|
|
if (!areCommonPropertiesEqual<decltype(*this)>(other))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &otherStruct = *static_cast<const PatternDataStruct*>(&other);
|
|
|
|
if (this->m_members.size() != otherStruct.m_members.size())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (u64 i = 0; i < this->m_members.size(); i++) {
|
|
|
|
if (*this->m_members[i] != *otherStruct.m_members[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
private:
|
|
|
|
std::vector<PatternData*> m_members;
|
|
|
|
std::vector<PatternData*> m_sortedMembers;
|
|
|
|
};
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
class PatternDataUnion : public PatternData, public Inlinable {
|
2020-11-20 21:29:28 +01:00
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataUnion(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) {
|
2021-04-12 20:49:37 +02:00
|
|
|
|
|
|
|
}
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
PatternDataUnion(const PatternDataUnion &other) : PatternData(other) {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
for (const auto &member : other.m_members)
|
|
|
|
this->m_members.push_back(member->clone());
|
2021-09-06 20:35:38 +02:00
|
|
|
this->m_sortedMembers = this->m_members;
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
}
|
|
|
|
|
2021-02-19 10:51:30 +01:00
|
|
|
~PatternDataUnion() override {
|
|
|
|
for (const auto &member : this->m_members)
|
|
|
|
delete member;
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataUnion(*this);
|
|
|
|
}
|
2020-11-20 21:29:28 +01:00
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
void setOffset(u64 offset) override {
|
2021-10-08 21:39:30 +02:00
|
|
|
if (!this->isLocal()) {
|
|
|
|
for (auto &member: this->m_members) {
|
|
|
|
member->setOffset(offset + (member->getOffset() - this->getOffset()));
|
|
|
|
}
|
2021-09-06 20:35:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PatternData::setOffset(offset);
|
|
|
|
}
|
|
|
|
|
2020-11-20 21:29:28 +01:00
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2021-09-27 13:31:10 +02:00
|
|
|
bool open = true;
|
|
|
|
|
2021-09-29 20:51:57 +02:00
|
|
|
if (!this->isInlined()) {
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
open = ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth);
|
|
|
|
this->drawCommentTooltip();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), std::max(this->getOffset() + this->getSize() - (this->getSize() == 0 ? 0 : 1), u64(0)));
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:04X}", this->getSize());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextColored(ImColor(0xFFD69C56), "union"); ImGui::SameLine(); ImGui::TextUnformatted(PatternData::getTypeName().c_str());
|
2021-09-27 13:31:10 +02:00
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted("{ ... }");
|
2021-09-27 13:31:10 +02:00
|
|
|
}
|
2020-11-20 21:29:28 +01:00
|
|
|
|
|
|
|
if (open) {
|
|
|
|
for (auto &member : this->m_sortedMembers)
|
2021-06-17 23:42:43 +02:00
|
|
|
member->draw(provider);
|
2020-11-20 21:29:28 +01:00
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
if (!this->isInlined())
|
2020-11-20 21:29:28 +01:00
|
|
|
ImGui::TreePop();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<u32> highlightBytes(size_t offset) override{
|
|
|
|
for (auto &member : this->m_members) {
|
|
|
|
if (auto color = member->highlightBytes(offset); color.has_value())
|
|
|
|
return color.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
return { };
|
|
|
|
}
|
|
|
|
|
2021-01-03 02:37:37 +01:00
|
|
|
std::map<u64, u32> getHighlightedAddresses() override {
|
|
|
|
if (this->m_highlightedAddresses.empty()) {
|
|
|
|
for (auto &member : this->m_members) {
|
|
|
|
this->m_highlightedAddresses.merge(member->getHighlightedAddresses());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->m_highlightedAddresses;
|
|
|
|
}
|
|
|
|
|
2021-09-06 20:35:38 +02:00
|
|
|
void clearHighlightedAddresses() override {
|
|
|
|
for (auto &member : this->m_members)
|
|
|
|
member->clearHighlightedAddresses();
|
|
|
|
PatternData::clearHighlightedAddresses();
|
|
|
|
}
|
|
|
|
|
2021-12-31 11:01:22 +01:00
|
|
|
void setColor(u32 color) override {
|
|
|
|
PatternData::setColor(color);
|
|
|
|
for (auto &member : this->m_members)
|
|
|
|
member->setColor(color);
|
|
|
|
}
|
|
|
|
|
2020-11-20 21:29:28 +01:00
|
|
|
void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) override {
|
|
|
|
this->m_sortedMembers = this->m_members;
|
|
|
|
|
|
|
|
std::sort(this->m_sortedMembers.begin(), this->m_sortedMembers.end(), [&sortSpecs, &provider](PatternData *left, PatternData *right) {
|
|
|
|
return PatternData::sortPatternDataTable(sortSpecs, provider, left, right);
|
|
|
|
});
|
|
|
|
|
|
|
|
for (auto &member : this->m_members)
|
|
|
|
member->sort(sortSpecs, provider);
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "union " + PatternData::getTypeName();;
|
|
|
|
}
|
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
[[nodiscard]] const auto& getMembers() const {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
return this->m_members;
|
2020-11-20 21:29:28 +01:00
|
|
|
}
|
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
void setMembers(const std::vector<PatternData*> & members) {
|
2021-09-03 10:30:40 +02:00
|
|
|
this->m_members.clear();
|
2021-04-13 21:50:24 +02:00
|
|
|
for (auto &member : members) {
|
|
|
|
if (member == nullptr) continue;
|
2021-04-12 20:49:37 +02:00
|
|
|
|
2021-04-13 21:50:24 +02:00
|
|
|
this->m_members.push_back(member);
|
2021-04-12 20:49:37 +02:00
|
|
|
member->setParent(this);
|
2021-04-13 21:50:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this->m_sortedMembers = this->m_members;
|
2021-04-12 20:49:37 +02:00
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override {
|
|
|
|
if (!areCommonPropertiesEqual<decltype(*this)>(other))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &otherUnion = *static_cast<const PatternDataUnion*>(&other);
|
|
|
|
if (this->m_members.size() != otherUnion.m_members.size())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (u64 i = 0; i < this->m_members.size(); i++) {
|
|
|
|
if (*this->m_members[i] != *otherUnion.m_members[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-20 21:29:28 +01:00
|
|
|
private:
|
|
|
|
std::vector<PatternData*> m_members;
|
|
|
|
std::vector<PatternData*> m_sortedMembers;
|
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
class PatternDataEnum : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataEnum(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) {
|
2021-04-12 20:49:37 +02:00
|
|
|
|
|
|
|
}
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataEnum(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2020-11-19 21:30:12 +01:00
|
|
|
u64 value = 0;
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &value, this->getSize());
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
value = hex::changeEndianess(value, this->getSize(), this->getEndian());
|
2020-11-19 21:30:12 +01:00
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
std::string valueString = PatternData::getTypeName() + "::";
|
2020-11-19 21:30:12 +01:00
|
|
|
|
|
|
|
bool foundValue = false;
|
2021-01-05 14:42:08 +01:00
|
|
|
for (auto &[entryValueLiteral, entryName] : this->m_enumValues) {
|
2021-09-21 21:29:18 +02:00
|
|
|
bool matches = std::visit(overloaded {
|
|
|
|
[&, name = entryName](auto &&entryValue) {
|
|
|
|
if (value == entryValue) {
|
|
|
|
valueString += name;
|
|
|
|
foundValue = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
[](std::string) { return false; },
|
|
|
|
[](PatternData*) { return false; }
|
2021-06-20 21:22:31 +02:00
|
|
|
}, entryValueLiteral);
|
2021-01-05 14:42:08 +01:00
|
|
|
if (matches)
|
2020-11-19 21:30:12 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!foundValue)
|
|
|
|
valueString += "???";
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TableNextRow();
|
2021-09-21 21:29:18 +02:00
|
|
|
ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
2021-01-21 20:55:10 +01:00
|
|
|
this->drawCommentTooltip();
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
if (ImGui::Selectable(("##PatternDataLine"s + std::to_string(this->getOffset())).c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) {
|
2021-03-27 11:36:36 +01:00
|
|
|
EventManager::post<RequestSelectionChange>(Region { this->getOffset(), this->getSize() });
|
2020-11-23 15:22:26 +01:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted(this->getDisplayName().c_str());
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TableNextColumn();
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
2020-11-23 22:14:11 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:04X}", this->getSize());
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextColored(ImColor(0xFFD69C56), "enum"); ImGui::SameLine(); ImGui::TextUnformatted(PatternData::getTypeName().c_str());
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("{} (0x{:0{}X})", valueString.c_str(), value, this->getSize() * 2);
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "enum " + PatternData::getTypeName();
|
|
|
|
}
|
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
[[nodiscard]] const auto& getEnumValues() const {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
return this->m_enumValues;
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
void setEnumValues(const std::vector<std::pair<Token::Literal, std::string>> &enumValues) {
|
2021-04-12 20:49:37 +02:00
|
|
|
this->m_enumValues = enumValues;
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override {
|
|
|
|
if (!areCommonPropertiesEqual<decltype(*this)>(other))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &otherEnum = *static_cast<const PatternDataEnum*>(&other);
|
|
|
|
if (this->m_enumValues.size() != otherEnum.m_enumValues.size())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (u64 i = 0; i < this->m_enumValues.size(); i++) {
|
|
|
|
if (this->m_enumValues[i] != otherEnum.m_enumValues[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
private:
|
2021-09-21 21:29:18 +02:00
|
|
|
std::vector<std::pair<Token::Literal, std::string>> m_enumValues;
|
2020-11-19 11:36:52 +01:00
|
|
|
};
|
|
|
|
|
2021-08-16 23:05:23 +02:00
|
|
|
|
|
|
|
class PatternDataBitfieldField : public PatternData {
|
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataBitfieldField(u64 offset, u8 bitOffset, u8 bitSize, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: m_bitOffset(bitOffset), m_bitSize(bitSize), PatternData(offset, 0, evaluator, color) {
|
2021-08-16 23:05:23 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataBitfieldField(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2021-09-12 13:08:52 +02:00
|
|
|
std::vector<u8> value(this->getParent()->getSize(), 0);
|
|
|
|
provider->read(this->getParent()->getOffset(), &value[0], value.size());
|
2021-08-16 23:05:23 +02:00
|
|
|
|
2021-09-12 13:08:52 +02:00
|
|
|
if (this->getParent()->getEndian() == std::endian::little)
|
2021-08-16 23:05:23 +02:00
|
|
|
std::reverse(value.begin(), value.end());
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextUnformatted(this->getDisplayName().c_str());
|
2021-08-16 23:05:23 +02:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
|
|
|
ImGui::TableNextColumn();
|
2021-09-12 13:08:52 +02:00
|
|
|
if (this->m_bitSize == 1)
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} bit {1}", this->getOffset() + this->m_bitOffset / 8, (this->m_bitOffset + (this->m_bitSize - 1)) % 8);
|
2021-09-12 13:08:52 +02:00
|
|
|
else
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} bits {1} - {2}", this->getOffset() + this->m_bitOffset / 8, this->m_bitOffset % 8, this->m_bitOffset % 8 + (this->m_bitSize - 1) % 8);
|
2021-08-16 23:05:23 +02:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
if (this->m_bitSize == 1)
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("{0} bit", this->m_bitSize);
|
2021-08-16 23:05:23 +02:00
|
|
|
else
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("{0} bits", this->m_bitSize);
|
2021-08-16 23:05:23 +02:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextColored(ImColor(0xFF9BC64D), "bits");
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
{
|
2021-09-12 13:08:52 +02:00
|
|
|
u8 numBytes = (this->m_bitSize / 8) + 1;
|
|
|
|
|
2021-09-12 14:28:13 +02:00
|
|
|
u64 extractedValue = hex::extract(this->m_bitOffset + (this->m_bitSize - 1), this->m_bitOffset, value);
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("{0} (0x{1:X})", extractedValue, extractedValue);
|
2021-08-16 23:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "bits";
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] u8 getBitOffset() const {
|
|
|
|
return this->m_bitOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] u8 getBitSize() const {
|
|
|
|
return this->m_bitSize;
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override {
|
|
|
|
if (!areCommonPropertiesEqual<decltype(*this)>(other))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &otherBitfieldField = *static_cast<const PatternDataBitfieldField*>(&other);
|
|
|
|
return this->m_bitOffset == otherBitfieldField.m_bitOffset && this->m_bitSize == otherBitfieldField.m_bitSize;
|
|
|
|
}
|
|
|
|
|
2021-08-16 23:05:23 +02:00
|
|
|
private:
|
|
|
|
u8 m_bitOffset, m_bitSize;
|
|
|
|
};
|
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
class PatternDataBitfield : public PatternData, public Inlinable {
|
2020-11-20 20:26:19 +01:00
|
|
|
public:
|
2021-10-02 15:22:38 +02:00
|
|
|
PatternDataBitfield(u64 offset, size_t size, Evaluator *evaluator, u32 color = 0)
|
|
|
|
: PatternData(offset, size, evaluator, color) {
|
2021-04-12 20:49:37 +02:00
|
|
|
|
|
|
|
}
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
2021-09-21 21:29:18 +02:00
|
|
|
PatternDataBitfield(const PatternDataBitfield &other) : PatternData(other) {
|
|
|
|
for (auto &field : other.m_fields)
|
|
|
|
this->m_fields.push_back(field->clone());
|
|
|
|
}
|
|
|
|
|
2021-08-16 23:05:23 +02:00
|
|
|
~PatternDataBitfield() override {
|
|
|
|
for (auto field : this->m_fields)
|
|
|
|
delete field;
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataBitfield(*this);
|
|
|
|
}
|
2020-11-20 20:26:19 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
std::vector<u8> value(this->getSize(), 0);
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), &value[0], value.size());
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
|
2021-09-12 13:08:52 +02:00
|
|
|
if (this->m_endian == std::endian::little)
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
std::reverse(value.begin(), value.end());
|
2020-11-20 20:26:19 +01:00
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
bool open = true;
|
2021-09-29 20:51:57 +02:00
|
|
|
if (!this->isInlined()) {
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
open = ImGui::TreeNodeEx(this->getDisplayName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth);
|
|
|
|
this->drawCommentTooltip();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:08X} : 0x{1:08X}", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextFormatted("0x{0:04X}", this->getSize());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
2021-12-31 01:10:06 +01:00
|
|
|
ImGui::TextColored(ImColor(0xFFD69C56), "bitfield"); ImGui::SameLine(); ImGui::TextUnformatted(PatternData::getTypeName().c_str());
|
2021-09-27 13:31:10 +02:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
|
|
|
std::string valueString = "{ ";
|
|
|
|
for (auto i : value)
|
|
|
|
valueString += hex::format("{0:02X} ", i);
|
|
|
|
valueString += "}";
|
|
|
|
|
|
|
|
ImGui::TextUnformatted(valueString.c_str());
|
|
|
|
}
|
2020-11-20 20:26:19 +01:00
|
|
|
|
|
|
|
if (open) {
|
2021-08-16 23:05:23 +02:00
|
|
|
|
|
|
|
for (auto &field : this->m_fields)
|
|
|
|
field->draw(provider);
|
2020-11-20 20:26:19 +01:00
|
|
|
|
2021-09-27 13:31:10 +02:00
|
|
|
if (!this->isInlined())
|
|
|
|
ImGui::TreePop();
|
2020-11-20 20:26:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "bitfield " + PatternData::getTypeName();
|
|
|
|
}
|
|
|
|
|
2021-04-12 20:49:37 +02:00
|
|
|
[[nodiscard]] const auto& getFields() const {
|
Pattern Language rewrite (#111)
* Initial parser rewrite effort
Lexer and Token cleanup, Parser started over
* Greatly improved parser syntax
* Reimplemented using declarations and variable placement parsing
* Added back unions and structs
* Added enums as well as mathematical expressions (+, -, *, /, <<, >>, &, |, ^)
* Code style improvement
* Implemented arrays and fixed memory issues
* Fixed more memory issues in parser, reimplemented validator, evaluator and patterns
* Fixed builtin types, arrays and reimplemented strings
* Improved error messages
* Made character a distinct type, used for chars and strings
* Implemented padding, fixed arrays
* Added bitfields
* Added rvalue parsing, no evaluating yet
* Added .idea folder to gitignore
* Fixed build on MacOS
* Added custom implementation of integral concept if not available
* Rebased onto master
* Fixed array variable decl crash
* Added rvalues and dot syntax
* Lower case all pattern language error messages
* Fixed typo in variable name
* Fixed bug where preprocessor would not ignore commented out directives
* Reimplemented pointers
* Fixed rebase issues
2021-01-02 20:27:11 +01:00
|
|
|
return this->m_fields;
|
2020-11-20 20:26:19 +01:00
|
|
|
}
|
|
|
|
|
2021-08-16 23:05:23 +02:00
|
|
|
void setFields(const std::vector<PatternData*> &fields) {
|
2021-04-12 20:49:37 +02:00
|
|
|
this->m_fields = fields;
|
2021-08-16 23:05:23 +02:00
|
|
|
|
2021-09-12 13:08:52 +02:00
|
|
|
for (auto &field : this->m_fields) {
|
2021-08-16 23:05:23 +02:00
|
|
|
field->setSize(this->getSize());
|
2021-09-12 13:08:52 +02:00
|
|
|
field->setColor(this->getColor());
|
|
|
|
field->setParent(this);
|
|
|
|
}
|
2021-04-12 20:49:37 +02:00
|
|
|
}
|
|
|
|
|
2021-12-31 11:01:22 +01:00
|
|
|
void setColor(u32 color) override {
|
|
|
|
PatternData::setColor(color);
|
|
|
|
for (auto &field : this->m_fields)
|
|
|
|
field->setColor(color);
|
|
|
|
}
|
|
|
|
|
2021-09-11 14:41:18 +02:00
|
|
|
[[nodiscard]] bool operator==(const PatternData &other) const override {
|
|
|
|
if (!areCommonPropertiesEqual<decltype(*this)>(other))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto &otherBitfield = *static_cast<const PatternDataBitfield*>(&other);
|
|
|
|
if (this->m_fields.size() != otherBitfield.m_fields.size())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (u64 i = 0; i < this->m_fields.size(); i++) {
|
2021-09-12 20:27:23 +02:00
|
|
|
if (*this->m_fields[i] != *otherBitfield.m_fields[i])
|
2021-09-11 14:41:18 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-20 20:26:19 +01:00
|
|
|
private:
|
2021-08-16 23:05:23 +02:00
|
|
|
std::vector<PatternData*> m_fields;
|
2020-11-20 20:26:19 +01:00
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
}
|