Removed bytecodeSize parameter

This commit is contained in:
2024-10-05 19:44:46 +10:00
parent d19a90f9bd
commit ad44eeac48
4 changed files with 6 additions and 9 deletions

View File

@@ -210,7 +210,7 @@ int main(int argc, const char* argv[]) {
//run the setup //run the setup
Toy_VM vm; Toy_VM vm;
Toy_bindVM(&vm, bc.ptr, bc.capacity); Toy_bindVM(&vm, bc.ptr);
//run //run
Toy_runVM(&vm); Toy_runVM(&vm);

View File

@@ -289,7 +289,7 @@ static void process(Toy_VM* vm) {
} }
//exposed functions //exposed functions
void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode, unsigned int bytecodeSize) { void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode) {
if (bytecode[0] != TOY_VERSION_MAJOR || bytecode[1] > TOY_VERSION_MINOR) { if (bytecode[0] != TOY_VERSION_MAJOR || bytecode[1] > TOY_VERSION_MINOR) {
fprintf(stderr, TOY_CC_ERROR "ERROR: Wrong bytecode version found: expected %d.%d.%d found %d.%d.%d, exiting\n" TOY_CC_RESET, TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH, bytecode[0], bytecode[1], bytecode[2]); fprintf(stderr, TOY_CC_ERROR "ERROR: Wrong bytecode version found: expected %d.%d.%d found %d.%d.%d, exiting\n" TOY_CC_RESET, TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH, bytecode[0], bytecode[1], bytecode[2]);
exit(-1); exit(-1);
@@ -314,7 +314,6 @@ void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode, unsigned int bytecodeSize)
//cache these //cache these
vm->bc = bytecode; vm->bc = bytecode;
vm->bcSize = bytecodeSize;
} }
void Toy_bindVMToRoutine(Toy_VM* vm, unsigned char* routine) { void Toy_bindVMToRoutine(Toy_VM* vm, unsigned char* routine) {
@@ -376,7 +375,6 @@ void Toy_freeVM(Toy_VM* vm) {
void Toy_resetVM(Toy_VM* vm) { void Toy_resetVM(Toy_VM* vm) {
vm->bc = NULL; vm->bc = NULL;
vm->bcSize = 0;
vm->routine = NULL; vm->routine = NULL;
vm->routineSize = 0; vm->routineSize = 0;

View File

@@ -7,7 +7,6 @@
typedef struct Toy_VM { typedef struct Toy_VM {
//hold the raw bytecode //hold the raw bytecode
unsigned char* bc; unsigned char* bc;
unsigned int bcSize;
//raw instructions to be executed //raw instructions to be executed
unsigned char* routine; unsigned char* routine;
@@ -33,7 +32,7 @@ typedef struct Toy_VM {
Toy_Stack* stack; Toy_Stack* stack;
} Toy_VM; } Toy_VM;
TOY_API void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode, unsigned int bytecodeSize); //process the version data TOY_API void Toy_bindVM(Toy_VM* vm, unsigned char* bytecode); //process the version data
TOY_API void Toy_bindVMToRoutine(Toy_VM* vm, unsigned char* routine); //process the routine only 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_runVM(Toy_VM* vm);

View File

@@ -41,7 +41,7 @@ int test_setup_and_teardown(Toy_Bucket** bucketHandle) {
//run the setup //run the setup
Toy_VM vm; Toy_VM vm;
Toy_bindVM(&vm, bc.ptr, bc.capacity); Toy_bindVM(&vm, bc.ptr);
//check the header size //check the header size
int headerSize = 3 + strlen(TOY_VERSION_BUILD) + 1; int headerSize = 3 + strlen(TOY_VERSION_BUILD) + 1;
@@ -91,7 +91,7 @@ int test_simple_execution(Toy_Bucket** bucketHandle) {
//run the setup //run the setup
Toy_VM vm; Toy_VM vm;
Toy_bindVM(&vm, bc.ptr, bc.capacity); Toy_bindVM(&vm, bc.ptr);
//run //run
Toy_runVM(&vm); Toy_runVM(&vm);
@@ -135,7 +135,7 @@ int test_opcode_not_equal(Toy_Bucket** bucketHandle) {
//run the setup //run the setup
Toy_VM vm; Toy_VM vm;
Toy_bindVM(&vm, bc.ptr, bc.capacity); Toy_bindVM(&vm, bc.ptr);
//run //run
Toy_runVM(&vm); Toy_runVM(&vm);