42 lines
767 B
C
42 lines
767 B
C
#include "test.h"
|
|
#include "debug.h"
|
|
#include "vm.h"
|
|
#include <fcntl.h>
|
|
#include <stdarg.h>
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <sys/types.h>
|
|
#include <sys/uio.h>
|
|
#include <unistd.h>
|
|
#ifdef __EMSCRIPTEN__
|
|
#include <emscripten.h>
|
|
#endif
|
|
|
|
VM vm = {0};
|
|
|
|
void mainloop() {
|
|
if (!step_vm(&vm)) {
|
|
#ifdef __EMSCRIPTEN__
|
|
emscripten_cancel_main_loop(); /* this should "kill" the app. */
|
|
#else
|
|
core_dump(&vm);
|
|
exit(0);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
vm.frames_size = FRAMES_SIZE;
|
|
vm.stack_size = STACK_SIZE;
|
|
vm.memory_size = MEMORY_SIZE;
|
|
vm.frames[vm.fp].allocated.end = test_add_function_compile(vm.memory);
|
|
|
|
#ifdef __EMSCRIPTEN__
|
|
emscripten_set_main_loop(mainloop, 0, 1);
|
|
#else
|
|
while (1) {
|
|
mainloop();
|
|
}
|
|
#endif
|
|
}
|