@@ -72,7 +72,8 @@ enum Opcode
7272 OP_INIT_PROCEDURE, /* !< Initializes the list of procedure (custom block) arguments. */
7373 OP_CALL_PROCEDURE, /* ! Calls the procedure (custom block) with the index in the argument. */
7474 OP_ADD_ARG, /* !< Adds a procedure (custom block) argument with the value from the last register. */
75- OP_READ_ARG /* !< Reads the procedure (custom block) argument with the index in the argument and stores the value in the last register. */
75+ OP_READ_ARG, /* !< Reads the procedure (custom block) argument with the index in the argument and stores the value in the last register. */
76+ OP_BREAK_ATOMIC /* !< Breaks current frame at the end of the loop. */
7677};
7778
7879}
@@ -108,15 +109,14 @@ class LIBSCRATCHCPP_EXPORT VirtualMachine
108109 void replaceReturnValue (const Value &v, unsigned int offset) { *m_regs[m_regCount - offset] = v; };
109110
110111 unsigned int *run ();
112+ unsigned int *run (unsigned int *pos);
111113
112114 /* ! Returns true if the VM has reached the vm::OP_HALT instruction. */
113115 bool atEnd () const { return m_atEnd; };
114116
115117 private:
116- unsigned int *run (unsigned int *pos);
117-
118118 static inline const unsigned int instruction_arg_count[] = {
119- 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 0
119+ 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 0 , 0
120120 };
121121
122122 typedef struct
@@ -137,6 +137,7 @@ class LIBSCRATCHCPP_EXPORT VirtualMachine
137137 std::vector<std::vector<Value>> m_procedureArgTree;
138138 std::vector<Value> *m_procedureArgs = nullptr ;
139139 std::vector<Value> *m_nextProcedureArgs = nullptr ;
140+ bool m_atomic;
140141
141142 unsigned int **m_procedures = nullptr ;
142143 std::vector<unsigned int *> m_proceduresVector;
0 commit comments