-
Notifications
You must be signed in to change notification settings - Fork 0
/
njvm.h
42 lines (31 loc) · 973 Bytes
/
njvm.h
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
/**
* Basic definitions of the Ninja Virtual Machine.
*
* This header provides version number, start & stop message and the
* machine components.
*/
#include <vector>
#include <stack>
#include "types.h"
namespace NJVM {
/**
* Supported binary version number.
*/
constexpr uint32_t version = 8;
/**
* Default size of stack and heap in kilobytes.
*/
constexpr size_t DEFAULT_HEAP_SIZE = 8192,
DEFAULT_STACK_SIZE = 64;
// Message printed when starting/stopping the machine.
extern const char *MESSAGE_START, *MESSAGE_STOP;
// Use a vector instead of raw memory. This gives us bounds checks for free.
extern std::vector<instruction_t> program;
extern std::vector<ObjRef> static_data;
extern std::vector<stack_slot> stack;
// 32-Bit integers for stack and program registers.
extern int32_t pc, sp, fp;
// Return register holds a reference.
extern ObjRef ret;
}