void Init_Math(void) { InitVM(Math); }
void Init_Math(void) { id_to_f = rb_intern_const("to_f"); InitVM(Math); }
void ResetVM(VM* vm) { if(vm->pc != -1) { fprintf(stderr, "Attempted to reset a running virtual machine\n"); exit(1); } if(vm->program) free(vm->program); vm->program = NULL; if(vm->functionPcs) free(vm->functionPcs); if(vm->functionNames) { for(int i = 0; i < vm->numFunctions; ++i) free(vm->functionNames[i]); free(vm->functionNames); } if(vm->numberConstants) free(vm->numberConstants); if(vm->stringConstants) { for(int i = 0; i < vm->numStringConstants; ++i) free(vm->stringConstants[i]); free(vm->stringConstants); } if(vm->globalNames) { for(int i = 0; i < vm->numGlobals; ++i) free(vm->globalNames[i]); free(vm->globalNames); } vm->stackSize = 0; vm->numGlobals = 0; vm->numExterns = 0; if(vm->externNames) { for(int i = 0; i < vm->numExterns; ++i) free(vm->externNames[i]); free(vm->externNames); } if(vm->externs) free(vm->externs); CollectGarbage(vm); Object* obj = vm->freeHead; Object* next = NULL; while(obj) { next = obj->next; if(obj->type != OBJ_NULL) free(obj); obj = next; } InitVM(vm); }
void Init_escape(void) { id_accept_charset = rb_intern_const("@@accept_charset"); InitVM(escape); }
VM* NewVM() { VM* vm = emalloc(sizeof(VM)); InitVM(vm); return vm; }