Fixed bitfields behaving like they have no size. Fixes #127
This commit is contained in:
parent
bc4991f915
commit
8f16a733b9
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user