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>
|
|
|
|
#include <hex/helpers/utils.hpp>
|
|
|
|
#include <hex/lang/token.hpp>
|
|
|
|
#include <hex/views/view.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>
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
namespace hex::lang {
|
|
|
|
|
2020-11-23 13:10:14 +01:00
|
|
|
using namespace ::std::literals::string_literals;
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
std::string makeDisplayable(u8 *data, size_t size) {
|
|
|
|
std::string result;
|
|
|
|
for (u8* c = data; c < (data + size); c++) {
|
|
|
|
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-01-07 21:16:34 +01:00
|
|
|
if (*(data + size - 1) == '\x00')
|
|
|
|
result.pop_back();
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class PatternData {
|
|
|
|
public:
|
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(u64 offset, size_t size, u32 color = 0)
|
2021-04-12 20:49:37 +02:00
|
|
|
: m_offset(offset), m_size(size), m_color(color), m_parent(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
|
|
|
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
|
|
|
}
|
|
|
|
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-04-12 20:49:37 +02:00
|
|
|
void setOffset(u64 offset) { this->m_offset = offset; }
|
|
|
|
|
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; }
|
2020-11-21 20:19:33 +01:00
|
|
|
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; }
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-11-19 21:19:03 +01:00
|
|
|
virtual void sort(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider) { }
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2020-11-19 21:19:03 +01:00
|
|
|
static bool sortPatternDataTable(ImGuiTableSortSpecs *sortSpecs, prv::Provider *provider, lang::PatternData* left, lang::PatternData* right) {
|
|
|
|
if (sortSpecs->Specs->ColumnUserID == ImGui::GetID("name")) {
|
|
|
|
if (sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending)
|
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 left->getVariableName() > right->getVariableName();
|
2020-11-19 21:19:03 +01:00
|
|
|
else
|
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 left->getVariableName() < right->getVariableName();
|
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;
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +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
|
|
|
void createDefaultEntry(std::string_view value) const {
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextRow();
|
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::TreeNodeEx(this->getVariableName().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();
|
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::Text("%s", this->getVariableName().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-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%04llX", this->getSize());
|
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::TextColored(ImColor(0xFF9BC64D), "%s", this->getFormattedName().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::Text("%s", value.data());
|
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;
|
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
|
|
|
|
|
|
|
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-01-20 18:10:40 +01:00
|
|
|
PatternDataPadding(u64 offset, size_t size) : PatternData(offset, size, 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 "";
|
|
|
|
}
|
|
|
|
};
|
2020-11-19 11:36:52 +01:00
|
|
|
|
2020-11-21 23:00:09 +01:00
|
|
|
class PatternDataPointer : public PatternData {
|
|
|
|
public:
|
2021-04-12 20:49:37 +02:00
|
|
|
PatternDataPointer(u64 offset, size_t size, u32 color = 0)
|
|
|
|
: PatternData(offset, size, 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-04-12 20:49:37 +02:00
|
|
|
PatternDataPointer(const PatternDataPointer &other) : PatternData(other.getOffset(), other.getSize(), other.getColor()) {
|
|
|
|
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-01-21 20:55:10 +01:00
|
|
|
bool open = ImGui::TreeNodeEx(this->getVariableName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
|
|
|
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-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2020-11-21 23:00:09 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%04llX", this->getSize());
|
2020-11-21 23:00:09 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-04-16 15:59:13 +02:00
|
|
|
ImGui::TextColored(ImColor(0xFF9BC64D), "%s", this->getFormattedName().c_str());
|
2020-11-21 23:00:09 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("*(0x%llX)", 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-04-16 15:59:13 +02:00
|
|
|
this->m_pointedAt->setVariableName("*" + 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;
|
|
|
|
}
|
|
|
|
|
2020-11-21 23:00:09 +01:00
|
|
|
private:
|
|
|
|
PatternData *m_pointedAt;
|
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
class PatternDataUnsigned : public PatternData {
|
|
|
|
public:
|
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
|
|
|
PatternDataUnsigned(u64 offset, size_t size, u32 color = 0)
|
|
|
|
: PatternData(offset, size, color) { }
|
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataUnsigned(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +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-19 11:36:52 +01:00
|
|
|
|
2021-03-03 19:58:22 +01:00
|
|
|
this->createDefaultEntry(hex::format("{:d} (0x{:0{}X})", data, data, 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 {
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class PatternDataSigned : public PatternData {
|
|
|
|
public:
|
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
|
|
|
PatternDataSigned(u64 offset, size_t size, u32 color = 0)
|
|
|
|
: PatternData(offset, size, color) { }
|
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataSigned(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2021-04-13 22:30:57 +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-04-13 22:30:57 +02:00
|
|
|
switch (this->getSize()) {
|
|
|
|
case 1: {
|
|
|
|
s8 signedData;
|
|
|
|
std::memcpy(&signedData, &data, 1);
|
|
|
|
this->createDefaultEntry(hex::format("{:d} (0x{:0{}X})", signedData, data, 1 * 2));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: {
|
|
|
|
s16 signedData;
|
|
|
|
std::memcpy(&signedData, &data, 2);
|
|
|
|
this->createDefaultEntry(hex::format("{:d} (0x{:0{}X})", signedData, data, 2 * 2));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4: {
|
|
|
|
s32 signedData;
|
|
|
|
std::memcpy(&signedData, &data, 4);
|
|
|
|
this->createDefaultEntry(hex::format("{:d} (0x{:0{}X})", signedData, data, 4 * 2));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 8: {
|
|
|
|
s64 signedData;
|
|
|
|
std::memcpy(&signedData, &data, 8);
|
|
|
|
this->createDefaultEntry(hex::format("{:d} (0x{:0{}X})", signedData, data, 8 * 2));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16: {
|
|
|
|
s128 signedData;
|
|
|
|
std::memcpy(&signedData, &data, 16);
|
|
|
|
this->createDefaultEntry(hex::format("{:d} (0x{:0{}X})", signedData, data, 16 * 2));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class PatternDataFloat : public PatternData {
|
|
|
|
public:
|
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
|
|
|
PatternDataFloat(u64 offset, size_t size, u32 color = 0)
|
|
|
|
: PatternData(offset, size, color) { }
|
|
|
|
|
|
|
|
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-03-03 19:58:22 +01:00
|
|
|
this->createDefaultEntry(hex::format("{:e} (0x{:0{}X})", *reinterpret_cast<float*>(&data), data, this->getSize() * 2));
|
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-03-03 19:58:22 +01:00
|
|
|
this->createDefaultEntry(hex::format("{:e} (0x{:0{}X})", *reinterpret_cast<double*>(&data), data, 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 {
|
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-01-07 17:34:50 +01:00
|
|
|
class PatternDataBoolean : public PatternData {
|
|
|
|
public:
|
|
|
|
explicit PatternDataBoolean(u64 offset, u32 color = 0)
|
|
|
|
: PatternData(offset, 1, color) { }
|
|
|
|
|
|
|
|
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)
|
|
|
|
this->createDefaultEntry("false");
|
|
|
|
else if (boolean == 1)
|
|
|
|
this->createDefaultEntry("true");
|
|
|
|
else
|
|
|
|
this->createDefaultEntry("true*");
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "bool";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
class PatternDataCharacter : public PatternData {
|
|
|
|
public:
|
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
|
|
|
explicit PatternDataCharacter(u64 offset, u32 color = 0)
|
|
|
|
: PatternData(offset, 1, color) { }
|
|
|
|
|
|
|
|
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-03-03 19:58:22 +01:00
|
|
|
this->createDefaultEntry(hex::format("'{0}'", 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-05-02 20:13:37 +02:00
|
|
|
class PatternDataCharacter16 : public PatternData {
|
|
|
|
public:
|
|
|
|
explicit PatternDataCharacter16(u64 offset, u32 color = 0)
|
|
|
|
: PatternData(offset, 2, color) { }
|
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataCharacter16(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
char16_t character;
|
|
|
|
provider->read(this->getOffset(), &character, 2);
|
|
|
|
|
|
|
|
this->createDefaultEntry(hex::format("'{0}'", std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(character)));
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "char16";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
class PatternDataString : public PatternData {
|
|
|
|
public:
|
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
|
|
|
PatternDataString(u64 offset, size_t size, u32 color = 0)
|
|
|
|
: PatternData(offset, size, color) { }
|
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataString(*this);
|
|
|
|
}
|
2020-11-19 11:36:52 +01:00
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
std::vector<u8> buffer(this->getSize() + 1, 0x00);
|
2021-04-16 21:50:15 +02:00
|
|
|
provider->read(this->getOffset(), buffer.data(), this->getSize());
|
2020-11-19 11:36:52 +01:00
|
|
|
buffer[this->getSize()] = '\0';
|
|
|
|
|
2021-03-03 19:58:22 +01:00
|
|
|
this->createDefaultEntry(hex::format("\"{0}\"", makeDisplayable(buffer.data(), this->getSize()).c_str()));
|
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-05-02 20:13:37 +02:00
|
|
|
class PatternDataString16 : public PatternData {
|
|
|
|
public:
|
|
|
|
PatternDataString16(u64 offset, size_t size, u32 color = 0)
|
|
|
|
: PatternData(offset, size, color) { }
|
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataString16(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
std::u16string buffer(this->getSize() + 1, 0x00);
|
|
|
|
provider->read(this->getOffset(), buffer.data(), this->getSize());
|
|
|
|
buffer[this->getSize()] = '\0';
|
|
|
|
|
|
|
|
auto utf8String = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(buffer);
|
|
|
|
|
|
|
|
this->createDefaultEntry(hex::format("\"{0}\"", utf8String)) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "String16";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
class PatternDataArray : public PatternData {
|
|
|
|
public:
|
2021-04-12 20:49:37 +02:00
|
|
|
PatternDataArray(u64 offset, size_t size, u32 color = 0)
|
|
|
|
: PatternData(offset, size, 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
|
|
|
|
|
|
|
PatternDataArray(const PatternDataArray &other) : PatternData(other.getOffset(), other.getSize(), other.getColor()) {
|
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-02-19 10:51:30 +01:00
|
|
|
~PatternDataArray() override {
|
|
|
|
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 {
|
|
|
|
return new PatternDataArray(*this);
|
|
|
|
}
|
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;
|
|
|
|
|
2020-11-23 13:08:24 +01:00
|
|
|
ImGui::TableNextRow();
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-21 20:55:10 +01:00
|
|
|
bool open = ImGui::TreeNodeEx(this->getVariableName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
|
|
|
this->drawCommentTooltip();
|
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-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%04llX", this->getSize());
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TextColored(ImColor(0xFF9BC64D), "%s", this->m_entries[0]->getTypeName().c_str());
|
|
|
|
ImGui::SameLine(0, 0);
|
|
|
|
|
|
|
|
ImGui::TextUnformatted("[");
|
|
|
|
ImGui::SameLine(0, 0);
|
|
|
|
ImGui::TextColored(ImColor(0xFF00FF00), "%llu", this->m_entries.size());
|
|
|
|
ImGui::SameLine(0, 0);
|
|
|
|
ImGui::TextUnformatted("]");
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::Text("%s", "{ ... }");
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
ImGui::TreePop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
private:
|
|
|
|
std::vector<PatternData*> m_entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PatternDataStruct : public PatternData {
|
|
|
|
public:
|
2021-04-12 20:49:37 +02:00
|
|
|
PatternDataStruct(u64 offset, size_t size, u32 color = 0) : PatternData(offset, size, 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
|
|
|
|
|
|
|
PatternDataStruct(const PatternDataStruct &other) : PatternData(other.getOffset(), other.getSize(), other.getColor()) {
|
|
|
|
for (const auto &member : other.m_members)
|
|
|
|
this->m_members.push_back(member->clone());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2020-11-23 13:08:24 +01:00
|
|
|
ImGui::TableNextRow();
|
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
|
|
|
bool open = ImGui::TreeNodeEx(this->getVariableName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth);
|
2021-01-21 20:55:10 +01:00
|
|
|
this->drawCommentTooltip();
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2020-11-23 22:14:11 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - (this->getSize() == 0 ? 0 : 1));
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%04llX", this->getSize());
|
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::TextColored(ImColor(0xFFD69C56), "struct"); ImGui::SameLine(); ImGui::Text("%s", this->getTypeName().c_str());
|
2020-11-19 11:36:52 +01:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::Text("%s", "{ ... }");
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
private:
|
|
|
|
std::vector<PatternData*> m_members;
|
|
|
|
std::vector<PatternData*> m_sortedMembers;
|
|
|
|
};
|
|
|
|
|
2020-11-20 21:29:28 +01:00
|
|
|
class PatternDataUnion : public PatternData {
|
|
|
|
public:
|
2021-04-12 20:49:37 +02:00
|
|
|
PatternDataUnion(u64 offset, size_t size, u32 color = 0) : PatternData(offset, size, 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
|
|
|
|
|
|
|
PatternDataUnion(const PatternDataUnion &other) : PatternData(other.getOffset(), other.getSize(), other.getColor()) {
|
|
|
|
for (const auto &member : other.m_members)
|
|
|
|
this->m_members.push_back(member->clone());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
2020-11-23 13:08:24 +01:00
|
|
|
ImGui::TableNextRow();
|
2020-11-20 21:29:28 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-21 20:55:10 +01:00
|
|
|
bool open = ImGui::TreeNodeEx(this->getVariableName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
|
|
|
this->drawCommentTooltip();
|
2020-11-20 21:29:28 +01:00
|
|
|
ImGui::TableNextColumn();
|
2020-11-23 22:14:11 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), std::max(this->getOffset() + this->getSize() - (this->getSize() == 0 ? 0 : 1), u64(0)));
|
2020-11-20 21:29:28 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%04llX", this->getSize());
|
2020-11-20 21:29:28 +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::TextColored(ImColor(0xFFD69C56), "union"); ImGui::SameLine(); ImGui::Text("%s", PatternData::getTypeName().c_str());
|
2020-11-23 15:22:26 +01:00
|
|
|
|
2020-11-20 21:29:28 +01:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::Text("%s", "{ ... }");
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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-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
|
|
|
}
|
|
|
|
|
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-04-12 20:49:37 +02:00
|
|
|
PatternDataEnum(u64 offset, size_t size, u32 color = 0) : PatternData(offset, size, 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 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) {
|
|
|
|
bool matches = std::visit([&, name = entryName](auto &&entryValue) {
|
|
|
|
if (value == entryValue) {
|
|
|
|
valueString += name;
|
|
|
|
foundValue = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-01-21 20:55:10 +01:00
|
|
|
ImGui::TreeNodeEx(this->getVariableName().c_str(), ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
|
|
|
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();
|
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::Text("%s", this->getVariableName().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-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%04llX", this->getSize());
|
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::TextColored(ImColor(0xFFD69C56), "enum"); ImGui::SameLine(); ImGui::Text("%s", PatternData::getTypeName().c_str());
|
2020-11-23 15:22:26 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-03-03 19:58:22 +01:00
|
|
|
ImGui::Text("%s", hex::format("{} (0x{:0{}X})", valueString.c_str(), value, this->getSize() * 2).c_str());
|
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-04-12 20:49:37 +02:00
|
|
|
void setEnumValues(const std::vector<std::pair<Token::IntegerLiteral, std::string>> &enumValues) {
|
|
|
|
this->m_enumValues = enumValues;
|
|
|
|
}
|
|
|
|
|
2020-11-19 11:36:52 +01:00
|
|
|
private:
|
2021-01-05 14:42:08 +01:00
|
|
|
std::vector<std::pair<Token::IntegerLiteral, 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:
|
|
|
|
PatternDataBitfieldField(u64 offset, u8 bitOffset, u8 bitSize, u32 color = 0)
|
|
|
|
: m_bitOffset(bitOffset), m_bitSize(bitSize), PatternData(offset, 0, color) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PatternData* clone() override {
|
|
|
|
return new PatternDataBitfieldField(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void createEntry(prv::Provider* &provider) override {
|
|
|
|
std::vector<u8> value(this->getSize(), 0);
|
|
|
|
provider->read(this->getOffset(), &value[0], value.size());
|
|
|
|
|
|
|
|
if (this->m_endian != std::endian::native)
|
|
|
|
std::reverse(value.begin(), value.end());
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TreeNodeEx(this->getVariableName().c_str(), ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::Text("%s", this->getVariableName().c_str());
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::ColorButton("color", ImColor(this->getColor()), ImGuiColorEditFlags_NoTooltip, ImVec2(ImGui::GetColumnWidth(), ImGui::GetTextLineHeight()));
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset() + (this->m_bitOffset >> 3), this->getOffset() + ((this->m_bitOffset + this->m_bitSize) >> 3));
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
if (this->m_bitSize == 1)
|
|
|
|
ImGui::Text("%u bit", this->m_bitSize);
|
|
|
|
else
|
|
|
|
ImGui::Text("%u bits", this->m_bitSize);
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::TextColored(ImColor(0xFF9BC64D), "bits");
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
{
|
|
|
|
u128 fieldValue = 0;
|
|
|
|
std::memcpy(&fieldValue, value.data() + (this->m_bitOffset / 8), (this->m_bitSize / 8) + 1);
|
|
|
|
u64 maskedValue = hex::extract((this->m_bitOffset + this->m_bitSize) - 1 - ((this->m_bitOffset / 8) * 8), this->m_bitOffset - ((this->m_bitOffset / 8) * 8), fieldValue);
|
|
|
|
ImGui::Text("%llu (0x%llX)", maskedValue, maskedValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] std::string getFormattedName() const override {
|
|
|
|
return "bits";
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] u8 getBitOffset() const {
|
|
|
|
return this->m_bitOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] u8 getBitSize() const {
|
|
|
|
return this->m_bitSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
u8 m_bitOffset, m_bitSize;
|
|
|
|
};
|
|
|
|
|
2020-11-20 20:26:19 +01:00
|
|
|
class PatternDataBitfield : public PatternData {
|
|
|
|
public:
|
2021-04-12 20:49:37 +02:00
|
|
|
PatternDataBitfield(u64 offset, size_t size, u32 color = 0) : PatternData(offset, size, 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
|
|
|
|
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-08-16 23:05:23 +02:00
|
|
|
if (this->m_endian != std::endian::native)
|
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
|
|
|
|
2020-11-23 13:08:24 +01:00
|
|
|
ImGui::TableNextRow();
|
2020-11-20 20:26:19 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-21 20:55:10 +01:00
|
|
|
bool open = ImGui::TreeNodeEx(this->getVariableName().c_str(), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_AllowItemOverlap);
|
|
|
|
this->drawCommentTooltip();
|
2020-11-20 20:26:19 +01:00
|
|
|
ImGui::TableNextColumn();
|
2020-11-23 22:14:11 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%08llX : 0x%08llX", this->getOffset(), this->getOffset() + this->getSize() - 1);
|
2020-11-20 20:26:19 +01:00
|
|
|
ImGui::TableNextColumn();
|
2021-01-11 09:14:32 +01:00
|
|
|
ImGui::Text("0x%04llX", this->getSize());
|
2020-11-20 20:26:19 +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::TextColored(ImColor(0xFFD69C56), "bitfield"); ImGui::SameLine(); ImGui::Text("%s", PatternData::getTypeName().c_str());
|
2020-11-20 20:26:19 +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
|
|
|
|
|
|
|
std::string valueString = "{ ";
|
2021-04-12 20:49:37 +02:00
|
|
|
for (auto i : value)
|
|
|
|
valueString += hex::format("{0:02X} ", i);
|
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
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
[[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
|
|
|
|
|
|
|
for (auto &field : this->m_fields)
|
|
|
|
field->setSize(this->getSize());
|
2021-04-12 20:49:37 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|