patterns: Fixed enums not counting properly
This commit is contained in:
parent
3d15a108af
commit
635f0606e0
@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
namespace hex::plugin::builtin {
|
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() {
|
void registerPatternLanguageFunctions() {
|
||||||
using namespace hex::pl;
|
using namespace hex::pl;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <bit>
|
#include <bit>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <unordered_map>
|
#include <map>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -381,13 +381,13 @@ namespace hex::pl {
|
|||||||
return new ASTNodeEnum(*this);
|
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 }); }
|
void addEntry(const std::string &name, ASTNode* expression) { this->m_entries.insert({ name, expression }); }
|
||||||
|
|
||||||
[[nodiscard]] ASTNode *getUnderlyingType() { return this->m_underlyingType; }
|
[[nodiscard]] ASTNode *getUnderlyingType() { return this->m_underlyingType; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, ASTNode*> m_entries;
|
std::map<std::string, ASTNode*> m_entries;
|
||||||
ASTNode *m_underlyingType;
|
ASTNode *m_underlyingType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#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::prv { class Provider; }
|
||||||
|
|
||||||
namespace hex::pl {
|
namespace hex::pl {
|
||||||
|
@ -808,7 +808,7 @@ namespace hex::pl {
|
|||||||
if (enumNode->getEntries().empty())
|
if (enumNode->getEntries().empty())
|
||||||
valueExpr = lastEntry = TO_NUMERIC_EXPRESSION(new ASTNodeIntegerLiteral(u8(0)));
|
valueExpr = lastEntry = TO_NUMERIC_EXPRESSION(new ASTNodeIntegerLiteral(u8(0)));
|
||||||
else
|
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);
|
enumNode->addEntry(name, valueExpr);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user