mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Repl works, also fixed a few small bugs
This commit is contained in:
@@ -41,6 +41,7 @@ NOTE: you need both font AND background for these to work
|
||||
#define TOY_CC_NOTICE TOY_CC_FONT_GREEN TOY_CC_BACK_BLACK
|
||||
#define TOY_CC_WARN TOY_CC_FONT_YELLOW TOY_CC_BACK_BLACK
|
||||
#define TOY_CC_ERROR TOY_CC_FONT_RED TOY_CC_BACK_BLACK
|
||||
#define TOY_CC_ASSERT TOY_CC_FONT_PURPLE TOY_CC_BACK_BLACK
|
||||
#define TOY_CC_RESET "\033[0m"
|
||||
|
||||
//for unsupported platforms, these become no-ops
|
||||
@@ -72,6 +73,7 @@ NOTE: you need both font AND background for these to work
|
||||
#define TOY_CC_NOTICE TOY_CC_FONT_GREEN TOY_CC_BACK_BLACK
|
||||
#define TOY_CC_WARN TOY_CC_FONT_YELLOW TOY_CC_BACK_BLACK
|
||||
#define TOY_CC_ERROR TOY_CC_FONT_RED TOY_CC_BACK_BLACK
|
||||
#define TOY_CC_ASSERT TOY_CC_FONT_PURPLE TOY_CC_BACK_BLACK
|
||||
#define TOY_CC_RESET
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,10 @@ static inline unsigned int readUnsignedInt(unsigned char** handle) {
|
||||
}
|
||||
|
||||
Toy_Module Toy_parseModule(unsigned char* ptr) {
|
||||
if (ptr == NULL) {
|
||||
return (Toy_Module){ 0 };
|
||||
}
|
||||
|
||||
Toy_Module module;
|
||||
|
||||
module.scopePtr = NULL;
|
||||
|
||||
@@ -982,7 +982,7 @@ void Toy_inheritVM(Toy_VM* vm, Toy_VM* parent) {
|
||||
Toy_resetVM(vm);
|
||||
}
|
||||
|
||||
void Toy_bindVMToModule(Toy_VM* vm, Toy_Module* module) {
|
||||
void Toy_bindVM(Toy_VM* vm, Toy_Module* module) {
|
||||
vm->code = module->code;
|
||||
|
||||
vm->jumpsCount = module->jumpsCount;
|
||||
@@ -1000,6 +1000,11 @@ void Toy_bindVMToModule(Toy_VM* vm, Toy_Module* module) {
|
||||
}
|
||||
|
||||
void Toy_runVM(Toy_VM* vm) {
|
||||
if (vm->codeAddr == 0) {
|
||||
//ignore uninitialized VMs or empty modules
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: read params into scope
|
||||
|
||||
//prep the program counter for execution
|
||||
|
||||
@@ -47,7 +47,7 @@ TOY_API void Toy_resetVM(Toy_VM* vm); //persists memory
|
||||
TOY_API void Toy_initVM(Toy_VM* vm); //creates memory
|
||||
TOY_API void Toy_inheritVM(Toy_VM* vm, Toy_VM* parent); //inherits memory
|
||||
|
||||
TOY_API void Toy_bindVMToModule(Toy_VM* vm, Toy_Module* module);
|
||||
TOY_API void Toy_bindVM(Toy_VM* vm, Toy_Module* module);
|
||||
TOY_API void Toy_runVM(Toy_VM* vm);
|
||||
|
||||
TOY_API void Toy_freeVM(Toy_VM* vm);
|
||||
|
||||
Reference in New Issue
Block a user