.
This commit is contained in:
@@ -39,7 +39,7 @@ public:
|
|||||||
[[nodiscard]] size_t size() const { return data_.size(); }
|
[[nodiscard]] size_t size() const { return data_.size(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<uint8_t> data_;
|
std::vector<uint8_t> data_ {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class BytecodeParsingError : public std::runtime_error {
|
class BytecodeParsingError : public std::runtime_error {
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ struct BytecodePrototype {
|
|||||||
using Value = std::variant<int32_t, float>;
|
using Value = std::variant<int32_t, float>;
|
||||||
|
|
||||||
struct Function {
|
struct Function {
|
||||||
uint16_t n_pars = 0;
|
uint16_t n_pars;
|
||||||
uint16_t n_locals = 0;
|
uint16_t n_locals;
|
||||||
ByteArray code {};
|
ByteArray code;
|
||||||
|
|
||||||
|
Function(uint16_t n_pars_, uint16_t n_locals_) : n_pars(n_pars_), n_locals(n_locals_), code(ByteArray {}) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<ConstantValue> constants {};
|
std::vector<ConstantValue> constants {};
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ TEST(Bytecode, Code)
|
|||||||
f.code.append_byte(0x68);
|
f.code.append_byte(0x68);
|
||||||
f.code.append_int(42);
|
f.code.append_int(42);
|
||||||
|
|
||||||
f = bp.functions.emplace_back(2, 1);
|
auto& f2 = bp.functions.emplace_back(2, 1);
|
||||||
f.code.append_byte(0x42);
|
f2.code.append_byte(0x42);
|
||||||
|
|
||||||
std::vector<uint8_t> expected = {
|
std::vector<uint8_t> expected = {
|
||||||
// header
|
// header
|
||||||
|
|||||||
Reference in New Issue
Block a user