mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-16 07:14:07 +10:00
Getting sleepy
This commit is contained in:
@@ -460,21 +460,21 @@ void initInterpreter(Interpreter* interpreter) {
|
|||||||
|
|
||||||
void freeInterpreter(Interpreter* interpreter) {
|
void freeInterpreter(Interpreter* interpreter) {
|
||||||
//BUGFIX: handle scopes of functions, which refer to the parent scope (leaking memory)
|
//BUGFIX: handle scopes of functions, which refer to the parent scope (leaking memory)
|
||||||
while(inner.scope != NULL) {
|
while(interpreter->scope != NULL) {
|
||||||
for (int i = 0; i < inner.scope->variables.capacity; i++) {
|
for (int i = 0; i < interpreter->scope->variables.capacity; i++) {
|
||||||
//handle keys, just in case
|
//handle keys, just in case
|
||||||
if (IS_FUNCTION(inner.scope->variables.entries[i].key)) {
|
if (IS_FUNCTION(interpreter->scope->variables.entries[i].key)) {
|
||||||
popScope(AS_FUNCTION(inner.scope->variables.entries[i].key).scope);
|
popScope(AS_FUNCTION(interpreter->scope->variables.entries[i].key).scope);
|
||||||
AS_FUNCTION(inner.scope->variables.entries[i].key).scope = NULL;
|
AS_FUNCTION(interpreter->scope->variables.entries[i].key).scope = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_FUNCTION(inner.scope->variables.entries[i].value)) {
|
if (IS_FUNCTION(interpreter->scope->variables.entries[i].value)) {
|
||||||
popScope(AS_FUNCTION(inner.scope->variables.entries[i].value).scope);
|
popScope(AS_FUNCTION(interpreter->scope->variables.entries[i].value).scope);
|
||||||
AS_FUNCTION(inner.scope->variables.entries[i].value).scope = NULL;
|
AS_FUNCTION(interpreter->scope->variables.entries[i].value).scope = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner.scope = popScope(inner.scope);
|
interpreter->scope = popScope(interpreter->scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
freeLiteralArray(&interpreter->literalCache);
|
freeLiteralArray(&interpreter->literalCache);
|
||||||
|
|||||||
Reference in New Issue
Block a user