Move RPN buffer encoding logic into rpn.cpp

This commit is contained in:
Rangi42
2025-09-03 22:36:00 -04:00
parent c798500563
commit c5c2800f17
4 changed files with 89 additions and 77 deletions

View File

@@ -12,10 +12,12 @@
struct Expression;
struct FileStackNode;
struct Symbol;
enum StateFeature { STATE_EQU, STATE_VAR, STATE_EQUS, STATE_CHAR, STATE_MACRO, NB_STATE_FEATURES };
void out_RegisterNode(std::shared_ptr<FileStackNode> node);
void out_RegisterSymbol(Symbol &sym);
void out_CreatePatch(uint32_t type, Expression const &expr, uint32_t ofs, uint32_t pcShift);
void out_CreateAssert(
AssertionType type, Expression const &expr, std::string const &message, uint32_t ofs

View File

@@ -13,8 +13,10 @@
struct Symbol;
struct RPNValue {
RPNCommand command;
std::variant<std::monostate, uint8_t, uint32_t, std::string> data;
RPNCommand command; // The RPN_* command ID
std::variant<std::monostate, uint8_t, uint32_t, std::string> data; // Data after the ID, if any
void appendEncoded(std::vector<uint8_t> &buffer) const;
};
struct Expression {
@@ -48,6 +50,8 @@ struct Expression {
void addCheckBitIndex(uint8_t mask);
void checkNBit(uint8_t n) const;
void encode(std::vector<uint8_t> &buffer) const;
};
bool checkNBit(int32_t v, uint8_t n, char const *name);