@@ -19,6 +19,7 @@ enum Opcode
1919 OP_HALT, /* !< The last instruction of every bytecode. */
2020 OP_CONST, /* !< Adds a constant value with the index in the argument to the next register. */
2121 OP_NULL, /* !< Adds a null (zero) value to the next register. */
22+ OP_CHECKPOINT, /* !< A checkpoint for the VirtualMachine::moveToLastCheckpoint() method. */
2223 OP_IF, /* !< Jumps to the next instruction if the last register holds "true". If it's false, jumps to OP_ELSE or OP_ENDIF. */
2324 OP_ELSE, /* !< Jumps to OP_ENDIF. This instruction is typically reached when the if statement condition was "true". */
2425 OP_ENDIF, /* !< Doesn't do anything, but is used by OP_IF and OP_ELSE. */
@@ -113,6 +114,7 @@ class LIBSCRATCHCPP_EXPORT VirtualMachine
113114
114115 void run ();
115116 void reset ();
117+ void moveToLastCheckpoint ();
116118
117119 /* !
118120 * Use this to stop the script from a function.
@@ -156,6 +158,7 @@ class LIBSCRATCHCPP_EXPORT VirtualMachine
156158 Engine *m_engine = nullptr ;
157159 Script *m_script = nullptr ;
158160 unsigned int *m_pos = nullptr ;
161+ unsigned int *m_checkpoint = nullptr ;
159162 bool m_atEnd = false ;
160163 std::vector<Loop> m_loops;
161164 std::vector<unsigned int *> m_callTree;
@@ -168,6 +171,7 @@ class LIBSCRATCHCPP_EXPORT VirtualMachine
168171 bool m_savePos = true ;
169172 bool m_goBack = false ;
170173 unsigned int m_freeExecRegs;
174+ bool m_updatePos = false ;
171175
172176 unsigned int **m_procedures = nullptr ;
173177 BlockFunc *m_functions;
0 commit comments