-
Notifications
You must be signed in to change notification settings - Fork 0
/
BrainFVM.h
62 lines (44 loc) · 1.68 KB
/
BrainFVM.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//===-- BrainFVM.h - BrainF interpreter header ----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===--------------------------------------------------------------------===//
#ifndef BRAINF_VM_H
#define BRAINF_VM_H
#include "BrainF.h"
#include "stdint.h"
#include <cstring>
/// opcode_func_t - A function pointer signature for all opcode functions.
typedef void(*opcode_func_t)(size_t pc, uint8_t* data);
/// BytecodeArray - An array of function pointers representing the
/// source program. Indexed by PC address.
extern opcode_func_t *BytecodeArray;
/// JumpMap - An array of on-the-side data used by the interpreter.
/// Indexed by PC address.
extern size_t *JumpMap;
/// Recorder - The trace recording engine.
extern BrainFTraceRecorder *Recorder;
/// op_plus - Implements the '+' instruction.
void op_plus(size_t, uint8_t*);
/// op_minus - Implements the '-' instruction.
void op_minus(size_t, uint8_t*);
// op_left - Implements the '<' instruction.
void op_left(size_t, uint8_t*);
// op_right - Implements the '>' instruction.
void op_right(size_t, uint8_t*);
// op_put - Implements the '.' instruction.
void op_put(size_t, uint8_t*);
// op_get - Implements the ',' instruction.
void op_get(size_t, uint8_t*);
// op_if - Implements the '[' instruction.
void op_if(size_t, uint8_t*);
// op_back - Implements the ']' instruction.
void op_back(size_t, uint8_t*);
// op_set_zero - Implements the '0' synthetic instruction.
void op_set_zero(size_t, uint8_t*);
// op_end - Terminates an execution.
void op_end(size_t, uint8_t*);
#endif