add py_resetallvm

This commit is contained in:
blueloveTH 2025-06-14 18:16:28 +08:00
parent 8f48c7d081
commit f9debd804e
2 changed files with 10 additions and 0 deletions

View File

@ -108,6 +108,8 @@ PK_API int py_currentvm();
PK_API void py_switchvm(int index); PK_API void py_switchvm(int index);
/// Reset the current VM. /// Reset the current VM.
PK_API void py_resetvm(); 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. /// Get the current VM context. This is used for user-defined data.
PK_API void* py_getvmctx(); PK_API void* py_getvmctx();
/// Set the current VM context. This is used for user-defined data. /// Set the current VM context. This is used for user-defined data.

View File

@ -94,6 +94,14 @@ void py_resetvm() {
VM__ctor(vm); VM__ctor(vm);
} }
void py_resetallvm() {
for(int i = 0; i < 16; i++) {
py_switchvm(i);
py_resetvm();
}
py_switchvm(0);
}
int py_currentvm() { int py_currentvm() {
for(int i = 0; i < 16; i++) { for(int i = 0; i < 16; i++) {
if(pk_all_vm[i] == pk_current_vm) return i; if(pk_all_vm[i] == pk_current_vm) return i;