-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBytecode.hpp
More file actions
41 lines (30 loc) · 1.05 KB
/
Bytecode.hpp
File metadata and controls
41 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include "codegen/BytecodeGenerator.hpp"
#include "executable/Function.hpp"
#include "executable/FunctionBlock.hpp"
#include "forward.hpp"
#include <memory>
#include <set>
#include <span>
#include <string>
#include <vector>
class Bytecode : public Function
{
const InstructionVector m_instructions;
public:
Bytecode(size_t register_count,
size_t locals_count,
size_t stack_size,
std::string function_name,
InstructionVector instructions,
std::shared_ptr<Program> program);
auto begin() const { return m_instructions.begin(); }
auto end() const { return m_instructions.end(); }
std::string to_string() const override;
std::vector<uint8_t> serialize() const override;
static std::unique_ptr<Bytecode> deserialize(std::span<const uint8_t> &buffer,
std::shared_ptr<Program> program);
py::PyResult<py::Value> call(VirtualMachine &, Interpreter &) const override;
py::PyResult<py::Value> call_without_setup(VirtualMachine &, Interpreter &) const override;
py::PyResult<py::Value> eval_loop(VirtualMachine &, Interpreter &) const;
};