1
0
mirror of synced 2025-01-29 19:17:28 +01:00

Fixed bitfields behaving like they have no size. Fixes #127

This commit is contained in:
WerWolv 2021-01-10 13:40:07 +01:00
parent bc4991f915
commit 8f16a733b9
3 changed files with 12 additions and 12 deletions

View File

@ -12,16 +12,15 @@ namespace hex::lang {
class Lexer {
public:
using LexerError = std::pair<u32, std::string>;
Lexer();
std::optional<std::vector<Token>> lex(const std::string& code);
const std::pair<u32, std::string>& getError() { return this->m_error; }
const LexerError& getError() { return this->m_error; }
private:
std::pair<u32, std::string> m_error;
using LexerError = std::pair<u32, std::string>;
LexerError m_error;
[[noreturn]] void throwLexerError(std::string_view error, u32 lineNumber) const {
throw LexerError(lineNumber, "Lexer: " + std::string(error));

View File

@ -16,18 +16,16 @@ namespace hex::lang {
class Parser {
public:
using TokenIter = std::vector<Token>::const_iterator;
using ParseError = std::pair<u32, std::string>;
Parser() = default;
~Parser() = default;
using TokenIter = std::vector<Token>::const_iterator;
std::optional<std::vector<ASTNode*>> parse(const std::vector<Token> &tokens);
const std::pair<u32, std::string>& getError() { return this->m_error; }
const ParseError& getError() { return this->m_error; }
private:
using ParseError = std::pair<u32, std::string>;
ParseError m_error;
TokenIter m_curr;
TokenIter m_originalPosition;

View File

@ -476,7 +476,10 @@ namespace hex::lang {
entryPatterns.emplace_back(name, fieldBits);
}
return new PatternDataBitfield(startOffset, (bits / 8) + 1, entryPatterns);
size_t size = (bits + 7) / 8;
this->m_currOffset += size;
return new PatternDataBitfield(startOffset, size, entryPatterns);
}
PatternData* Evaluator::evaluateType(ASTNodeTypeDecl *node) {