32 #ifndef _QORE_INTERN_THREADCLOSUREVARIABLESTACK_H
33 #define _QORE_INTERN_THREADCLOSUREVARIABLESTACK_H
35 class ThreadClosureVariableStack :
public ThreadLocalData<ClosureVarValue*> {
37 DLLLOCAL
void instantiateIntern(ClosureVarValue* cvar) {
40 if (curr->pos == QORE_THREAD_STACK_BLOCK) {
44 curr->next =
new Block(curr);
49 curr->var[curr->pos++] = cvar;
56 ThreadClosureVariableStack::iterator i(curr);
59 sdh.
deref(i.get()->finalize());
65 while (curr->prev || curr->pos)
69 DLLLOCAL ClosureVarValue* instantiate(
const char*
id,
const QoreTypeInfo* typeInfo,
QoreValue& nval,
bool assign) {
70 ClosureVarValue* cvar =
new ClosureVarValue(
id, typeInfo, nval, assign);
71 instantiateIntern(cvar);
75 DLLLOCAL
void instantiate(ClosureVarValue* cvar) {
76 instantiateIntern(cvar);
79 DLLLOCAL
void uninstantiateIntern() {
82 printd(0,
"ThreadClosureVariableStack::uninstantiate() this: %p pos: %d %p %s\n",
this, curr->prev->pos - 1, curr->prev->var[curr->prev->pos - 1]->id, curr->prev->var[curr->prev->pos - 1]->id);
84 printd(0,
"ThreadClosureVariableStack::uninstantiate() this: %p pos: %d %p %s\n",
this, curr->pos - 1, curr->var[curr->pos - 1]->id, curr->var[curr->pos - 1]->id);
99 uninstantiateIntern();
100 assert(curr->var[curr->pos]);
101 curr->var[curr->pos]->deref(xsink);
104 DLLLOCAL ClosureVarValue* find(
const char*
id) {
105 printd(5,
"ThreadClosureVariableStack::find() this: %p id: %p\n",
this,
id);
111 ClosureVarValue* rv = w->var[p];
113 if (rv && rv->id ==
id) {
121 printd(0,
"ThreadClosureVariableStack::find() this: %p no closure-bound local variable '%s' (%p) on stack (pgm: %p) p: %d curr->prev: %p\n",
this,
id,
id,
getProgram(), p, curr->prev);
127 ClosureVarValue* cvv = w->var[p];
128 printd(0,
"var p: %d: %s (%p)\n", p, cvv ? cvv->id :
"frame boundary", cvv ? cvv->id :
nullptr);
140 DLLLOCAL cvv_vec_t* getAll()
const {
147 ClosureVarValue* cvv = w->var[p];
153 cv->push_back(cvv->refSelf());
161 DLLLOCAL
void pushFrameBoundary() {
164 instantiateIntern(
nullptr);
167 DLLLOCAL
void popFrameBoundary() {
168 assert(frame_count >= 0);
171 uninstantiateIntern();
172 assert(!curr->var[curr->pos]);
175 DLLLOCAL
int getFrame(
int frame, Block*& w,
int& p);
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
Helps dereference values outside of locks.
Definition: QoreLibIntern.h:543
DLLLOCAL void deref(QoreValue v)
dereferences the value immediately if it cannot throw an exception, or adds it to the list for derefe...
Definition: QoreLibIntern.h:559
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275