patterns: Fixed enums not counting properly
This commit is contained in:
parent
3d15a108af
commit
635f0606e0
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user