From 59c0d16d509c216c914f7e97c3dc978bfe2add08 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 5 Apr 2021 00:55:31 +0200 Subject: [PATCH] make threads work this means ensuring all required fields are set when creating new threads. as well as respecting the "global" ident flags when an alias is not pushed (in order to erase the UNKNOWN flag for all threads) --- src/cs_ident.cc | 6 +++++- src/cs_state.cc | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cs_ident.cc b/src/cs_ident.cc index 84aa86f..df36e55 100644 --- a/src/cs_ident.cc +++ b/src/cs_ident.cc @@ -144,10 +144,14 @@ void alias_stack::set_arg(alias *a, thread_state &ts, any_value &v) { node->val_s = std::move(v); } -void alias_stack::set_alias(alias *, thread_state &ts, any_value &v) { +void alias_stack::set_alias(alias *a, thread_state &ts, any_value &v) { node->val_s = std::move(v); node->code = bcode_ref{}; flags = ts.ident_flags; + auto *imp = static_cast(a); + if (node == &imp->p_initial) { + imp->p_flags = flags; + } } /* public interface */ diff --git a/src/cs_state.cc b/src/cs_state.cc index 5a08b1b..6ae2f0e 100644 --- a/src/cs_state.cc +++ b/src/cs_state.cc @@ -279,7 +279,9 @@ LIBCUBESCRIPT_EXPORT void state::destroy() { state::state(internal_state *s) { p_tstate = s->create(s); + p_tstate->pstate = this; p_tstate->istate = s; + p_tstate->owner = false; } LIBCUBESCRIPT_EXPORT state state::new_thread() {