blueloveTH 8 месяцев назад
Родитель
Сommit
f9debd804e
2 измененных файлов с 10 добавлено и 0 удалено
  1. 2 0
      include/pocketpy/pocketpy.h
  2. 8 0
      src/public/internal.c

+ 2 - 0
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.

+ 8 - 0
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;