forked from nothingelsematters/pseudo-jit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
41 lines (31 loc) · 826 Bytes
/
main.cpp
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
#include <iostream>
#include <vector>
#include <unistd.h>
#include <cerrno>
#include <memory>
#include <string.h>
#include <sys/wait.h>
#include <assert.h>
#include <sys/mman.h>
#include <iomanip>
#include <fstream>
#include "InterpreterJIT.h"
using namespace std;
const size_t TAPE_SIZE = 1000000;
void printUsage() {
cout << "Usage ./os-jit <code file>\n"
" Interpret Brainfuck code with Just-In-Time optimization\n"
" Interpreted program reads symbols from stdin and writes to stdout\n";
}
int main(int argc, char *argv[]) {
InterpreterJIT interpreter(TAPE_SIZE, STDIN_FILENO, STDOUT_FILENO);
if (argc != 2) {
printUsage();
return 0;
}
ifstream codeFile(argv[1]);
char c;
while (codeFile >> c) {
interpreter.applyCommand(c);
}
}