Files
Toy/source/toy_vm.h
Kayne Ruse c518960171 Toy_VM and Toy_Stack are working and tested, read more
At this point, only a minimal number of operations are working, and
after running any kind of source code, the 'result' is simply left on
the VM's stack. Still, it's awesome to see it reach this point.
2024-09-27 15:12:37 +10:00

44 lines
843 B
C

#pragma once
#include "toy_common.h"
#include "toy_stack.h"
typedef struct Toy_VM {
//hold the raw bytecode
unsigned char* bc;
int bcSize;
//raw instructions to be executed
unsigned char* routine;
int routineSize;
int paramCount;
int jumpsCount;
int dataCount;
int subsCount;
int paramAddr;
int codeAddr;
int jumpsAddr;
int dataAddr;
int subsAddr;
int routineCounter;
//scope - block-level key/value pairs
//stack - immediate-level values only
Toy_Stack stack;
} Toy_VM;
TOY_API void Toy_initVM(Toy_VM* vm);
TOY_API void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode, int bytecodeSize); //process the version data
TOY_API void Toy_bindVMToRoutine(Toy_VM* vm, unsigned char* routine); //process the routine only
TOY_API void Toy_runVM(Toy_VM* vm);
TOY_API void Toy_freeVM(Toy_VM* vm);
//TODO: inject extra data