1
0
mirror of synced 2024-11-28 09:30:51 +01:00

patterns: Fixed enums not counting properly

This commit is contained in:
WerWolv 2021-09-11 23:14:22 +02:00
parent 3d15a108af
commit 635f0606e0
4 changed files with 7 additions and 7 deletions

View File

@ -11,9 +11,6 @@
namespace hex::plugin::builtin {
#define LITERAL_COMPARE(literal, cond) std::visit([&](auto &&literal) { return (cond) != 0; }, literal)
#define AS_TYPE(type, value) ctx.template asType<type>(value)
void registerPatternLanguageFunctions() {
using namespace hex::pl;

View File

@ -4,7 +4,7 @@
#include <bit>
#include <optional>
#include <unordered_map>
#include <map>
#include <variant>
#include <vector>
@ -381,13 +381,13 @@ namespace hex::pl {
return new ASTNodeEnum(*this);
}
[[nodiscard]] const std::unordered_map<std::string, ASTNode*>& getEntries() const { return this->m_entries; }
[[nodiscard]] const std::map<std::string, ASTNode*>& getEntries() const { return this->m_entries; }
void addEntry(const std::string &name, ASTNode* expression) { this->m_entries.insert({ name, expression }); }
[[nodiscard]] ASTNode *getUnderlyingType() { return this->m_underlyingType; }
private:
std::unordered_map<std::string, ASTNode*> m_entries;
std::map<std::string, ASTNode*> m_entries;
ASTNode *m_underlyingType;
};

View File

@ -11,6 +11,9 @@
#include <map>
#include <vector>
#define LITERAL_COMPARE(literal, cond) std::visit([&](auto &&literal) { return (cond) != 0; }, literal)
#define AS_TYPE(type, value) ctx.template asType<type>(value)
namespace hex::prv { class Provider; }
namespace hex::pl {

View File

@ -808,7 +808,7 @@ namespace hex::pl {
if (enumNode->getEntries().empty())
valueExpr = lastEntry = TO_NUMERIC_EXPRESSION(new ASTNodeIntegerLiteral(u8(0)));
else
valueExpr = new ASTNodeNumericExpression(lastEntry->clone(), new ASTNodeIntegerLiteral(s32(1)), Token::Operator::Plus);
valueExpr = lastEntry = new ASTNodeNumericExpression(lastEntry->clone(), new ASTNodeIntegerLiteral(s32(1)), Token::Operator::Plus);
enumNode->addEntry(name, valueExpr);
}