make the garbage collector less terrible

This commit is contained in:
suchmememanyskill
2021-07-10 01:12:39 +02:00
parent 65a28d8ef6
commit 91af9b4437
6 changed files with 42 additions and 1 deletions

View File

@@ -98,23 +98,28 @@ ClassFunction(arraySlice) {
return copyVariableToPtr(refSkip);
}
// TODO: arrayForEach does not like the new garbage collector
ClassFunction(arrayForEach) {
Vector_t* v = &caller->solvedArray.vector;
Callback_SetVar_t setVar = { .isTopLevel = 1, .varName = (*args)->string.value };
Variable_t* iter = NULL;
iter = copyVariableToPtr(newIntVariable(0));
iter->gcDoNotFree = 1;
runtimeVariableEdit(&setVar, iter);
for (int i = 0; i < v->count; i++) {
*iter = arrayClassGetIdx(caller, i);
iter->gcDoNotFree = 1;
Variable_t* res = genericCallDirect(args[1], NULL, 0);
if (res == NULL)
return NULL;
}
iter->reference = 1;
free(iter);
return &emptyClass;
}