2021-07-09 21:56:13 +01:00
|
|
|
#include "model.h"
|
|
|
|
#include "genericClass.h"
|
|
|
|
#include "compat.h"
|
|
|
|
#include "garbageCollector.h"
|
|
|
|
|
|
|
|
void modReference(Variable_t* ref, u8 add) {
|
|
|
|
if (ref == NULL || ref->gcDoNotFree)
|
|
|
|
return;
|
|
|
|
|
2021-07-10 00:12:39 +01:00
|
|
|
if (add) {
|
|
|
|
ref->tagCount++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ref->tagCount--;
|
|
|
|
if (ref->tagCount <= 0) {
|
2021-07-19 11:28:40 +01:00
|
|
|
// TODO: move to parser.c
|
2021-07-10 00:12:39 +01:00
|
|
|
if (ref->variableType == FunctionClass && ref->function.builtIn && ref->function.origin != NULL)
|
|
|
|
modReference(ref->function.origin, 0);
|
|
|
|
|
|
|
|
if (ref->variableType == SolvedArrayReferenceClass)
|
|
|
|
modReference(ref->solvedArray.arrayClassReference, 0);
|
|
|
|
|
|
|
|
freeVariable(&ref);
|
|
|
|
}
|
|
|
|
}
|
2021-07-09 21:56:13 +01:00
|
|
|
}
|