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;
55 ThreadClosureVariableStack::iterator i(curr);
58 if (n->derefCanThrowException()) {
62 cl->push_back(n.release());
69 while (curr->prev || curr->pos)
73 DLLLOCAL ClosureVarValue* instantiate(
const char*
id,
const QoreTypeInfo* typeInfo,
QoreValue& nval,
bool assign) {
74 ClosureVarValue* cvar =
new ClosureVarValue(
id, typeInfo, nval, assign);
75 instantiateIntern(cvar);
79 DLLLOCAL
void instantiate(ClosureVarValue* cvar) {
80 instantiateIntern(cvar);
83 DLLLOCAL
void uninstantiateIntern() {
86 printd(5,
"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);
88 printd(5,
"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);
103 uninstantiateIntern();
104 assert(curr->var[curr->pos]);
105 curr->var[curr->pos]->deref(xsink);
108 DLLLOCAL ClosureVarValue* find(
const char*
id) {
109 printd(5,
"ThreadClosureVariableStack::find() this: %p id: %p\n",
this,
id);
115 ClosureVarValue* rv = w->var[p];
117 if (rv && rv->id ==
id) {
125 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);
131 ClosureVarValue* cvv = w->var[p];
132 printd(0,
"var p: %d: %s (%p)\n", p, cvv ? cvv->id :
"frame boundary", cvv ? cvv->id :
nullptr);
144 DLLLOCAL cvv_vec_t* getAll()
const {
151 ClosureVarValue* cvv = w->var[p];
157 cv->push_back(cvv->refSelf());
165 DLLLOCAL
void pushFrameBoundary() {
168 instantiateIntern(
nullptr);
171 DLLLOCAL
void popFrameBoundary() {
172 assert(frame_count >= 0);
175 uninstantiateIntern();
176 assert(!curr->var[curr->pos]);
179 DLLLOCAL
int getFrame(
int frame, Block*& w,
int& p);
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:50
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
std::vector< QoreValue > arg_vec_t
vector of value information for default argument lists
Definition: common.h:254
holds an object and dereferences it in the destructor
Definition: QoreValue.h:452