From 6dfb2922737dd58ad41f5f3768cec3793c40f4fe Mon Sep 17 00:00:00 2001 From: Avril Date: Wed, 17 Mar 2021 15:59:17 +0000 Subject: [PATCH] added slot --- include/state.h | 1 + src/main.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/state.h b/include/state.h index ef03fc9..6879cb8 100644 --- a/include/state.h +++ b/include/state.h @@ -32,6 +32,7 @@ inline sm_yield sm_continue() { return (sm_yield)_sm_noop; } #define SM_VAR_EX(name, init) _sm_var(state, (name), (init)) //TODO: Replace `name' with (__LINE__ % _SM_STACK_SIZE) pseudo-hashmap #define SM_VAR(init) _sm_var<__LINE__, decltype(init)>(state, (init)) +#define SM_SLOT(T) _sm_var<__LINE__, T>(state, {}) #define SM_BEGIN switch(state->current->pc) { case 0: #define SM_END } _sm_pop_stack(state); return sm_end() diff --git a/src/main.cpp b/src/main.cpp index 0340cff..8b1e513 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,12 @@ sm_yield sm_test(sm_state* state) { int* a = SM_VAR(10); + auto c = SM_SLOT(_test); + float* d = SM_SLOT(float); + + *c = { 200, 300 }; + *d = 10.f; + SM_BEGIN; SM_YIELD(sm_continue()); *a = 5;