mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Fixed a 'malformed assignment' issue, read more
I've also added some support for compiler errors in general, but these will get expanded on later. I've also quickly added a valgrind option to the tests and found a few leaks. I'll deal with these later. Summary of changes: * Clarified the lifetime of the bytecode in memory * Erroneous routines exit without compiling * Empty VMs don't run * Added a check for malformed assignments * Renamed "routine" to "module" within the VM * VM no longer tries to free the bytecode - must be done manually * Started experimenting with valgrind, not yet ready
This commit is contained in:
@@ -311,18 +311,19 @@ int repl(const char* filepath) {
|
||||
}
|
||||
|
||||
Toy_Bytecode bc = Toy_compileBytecode(ast);
|
||||
Toy_bindVM(&vm, bc.ptr);
|
||||
Toy_bindVM(&vm, &bc);
|
||||
|
||||
//run
|
||||
Toy_runVM(&vm);
|
||||
|
||||
//free the bytecode, and leave the VM ready for the next loop
|
||||
Toy_resetVM(&vm);
|
||||
Toy_freeBytecode(bc);
|
||||
|
||||
printf("%s> ", prompt); //shows the terminal prompt
|
||||
}
|
||||
|
||||
//cleanp all memory
|
||||
//cleanup all memory
|
||||
Toy_freeVM(&vm);
|
||||
Toy_freeBucket(&bucket);
|
||||
|
||||
@@ -531,7 +532,7 @@ int main(int argc, const char* argv[]) {
|
||||
//run the setup
|
||||
Toy_VM vm;
|
||||
Toy_initVM(&vm);
|
||||
Toy_bindVM(&vm, bc.ptr);
|
||||
Toy_bindVM(&vm, &bc);
|
||||
|
||||
//run
|
||||
Toy_runVM(&vm);
|
||||
@@ -544,6 +545,7 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
//cleanup
|
||||
Toy_freeVM(&vm);
|
||||
Toy_freeBytecode(bc);
|
||||
Toy_freeBucket(&bucket);
|
||||
free(source);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user