diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h index d7e04ed9..f947927b 100644 --- a/include/pocketpy/pocketpy.h +++ b/include/pocketpy/pocketpy.h @@ -108,6 +108,8 @@ PK_API int py_currentvm(); PK_API void py_switchvm(int index); /// Reset the current VM. PK_API void py_resetvm(); +/// Reset All VMs. +PK_API void py_resetallvm(); /// Get the current VM context. This is used for user-defined data. PK_API void* py_getvmctx(); /// Set the current VM context. This is used for user-defined data. diff --git a/src/public/internal.c b/src/public/internal.c index 2ef00862..8271b546 100644 --- a/src/public/internal.c +++ b/src/public/internal.c @@ -94,6 +94,14 @@ void py_resetvm() { VM__ctor(vm); } +void py_resetallvm() { + for(int i = 0; i < 16; i++) { + py_switchvm(i); + py_resetvm(); + } + py_switchvm(0); +} + int py_currentvm() { for(int i = 0; i < 16; i++) { if(pk_all_vm[i] == pk_current_vm) return i;