2021-03-24 20:33:20 +01:00
|
|
|
#ifndef LIBCUBESCRIPT_THREAD_HH
|
|
|
|
#define LIBCUBESCRIPT_THREAD_HH
|
|
|
|
|
|
|
|
#include <cubescript/cubescript.hh>
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "cs_std.hh"
|
|
|
|
#include "cs_state.hh"
|
|
|
|
|
|
|
|
namespace cubescript {
|
|
|
|
|
|
|
|
struct codegen_state;
|
|
|
|
|
|
|
|
struct thread_state {
|
|
|
|
/* thread call stack */
|
|
|
|
ident_link *callstack{};
|
|
|
|
/* current codegen state for diagnostics */
|
|
|
|
codegen_state *cstate{};
|
2021-03-24 22:37:53 +01:00
|
|
|
/* value stack for VM */
|
|
|
|
valbuf<any_value> vmstack;
|
2021-03-24 20:33:20 +01:00
|
|
|
/* per-thread storage buffer for error messages */
|
|
|
|
charbuf errbuf;
|
|
|
|
/* we can attach a hook to vm events */
|
|
|
|
hook_func call_hook{};
|
|
|
|
/* loop nesting level */
|
|
|
|
int loop_level = 0;
|
|
|
|
|
2021-03-24 22:37:53 +01:00
|
|
|
thread_state(internal_state *cs);
|
2021-03-24 20:33:20 +01:00
|
|
|
|
2021-03-24 22:37:53 +01:00
|
|
|
hook_func set_hook(hook_func f);
|
2021-03-24 20:33:20 +01:00
|
|
|
|
|
|
|
hook_func &get_hook() { return call_hook; }
|
|
|
|
hook_func const &get_hook() const { return call_hook; }
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace cubescript */
|
|
|
|
|
|
|
|
#endif /* LIBCUBESCRIPT_THREAD_HH */
|