aboutsummaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-23 11:11:39 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-23 11:11:39 +0100
commit3a9f0f747a5356b6ec304867db716f0e3ccb07ae (patch)
tree843e0d35a06ccbdbeab8464ec480457e16a251d2 /vm.c
parent6a701319a47ff5950f4ca918e744cf1fba088869 (diff)
downloadvm.lv2-3a9f0f747a5356b6ec304867db716f0e3ccb07ae.tar.xz
implement vm:opGoto.
* makes branching and looping possible.
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/vm.c b/vm.c
index 83b13c7..ccd83a9 100644
--- a/vm.c
+++ b/vm.c
@@ -308,7 +308,7 @@ run_internal(plughandle_t *handle, uint32_t frames, bool notify,
_stack_clear(&handle->stack);
for(unsigned i = 0; i < ITEMS_MAX; i++)
- {
+loop: {
vm_command_t *cmd = &handle->cmds[i];
bool terminate = false;
@@ -319,7 +319,7 @@ run_internal(plughandle_t *handle, uint32_t frames, bool notify,
const num_t c = cmd->i32;
_stack_push(&handle->stack, c);
} break;
- case COMMAND_INT:
+ case COMMAND_INT:
{
const num_t c = cmd->i32;
_stack_push(&handle->stack, c);
@@ -375,13 +375,17 @@ run_internal(plughandle_t *handle, uint32_t frames, bool notify,
if(a)
terminate = true;
} break;
- /* dangerous
case OP_GOTO:
{
- const int idx = _stack_pop(&handle->stack);
- i = (idx - 1) & ITEMS_MASK;
+ num_t ab [2];
+ _stack_pop_num(&handle->stack, ab, 2);
+ if(ab[0])
+ {
+ const int idx = ab[1];
+ i = idx & ITEMS_MASK;
+ goto loop;
+ }
} break;
- */
case OP_RAND:
{