void hklr_scope_pop() { HklScope* scope = hkl_list_pop_back(HKLR.scopes); // decrement all the locals hkl_hash_traverse(scope->locals, hklr_gc_dec_hash, NULL); // dont dec upvals as they arent in our scope // hkl_hash_traverse(scope->upvals, hklr_gc_dec_hash, NULL); hkl_hash_free(scope->locals); hkl_hash_free(scope->upvals); hkl_free_object(scope); }
void hklr_scope_pop() { HklScope* scope = HKLR.scopes; HKLR.scopes = scope->prev; HKLR.scope_level--; // decrement all the locals hkl_hash_traverse(scope->locals, hklr_gc_dec_hash, NULL); // dont dec upvals as they arent in our scope // hkl_hash_traverse(scope->upvals, hklr_gc_dec_hash, NULL); hkl_hash_free(scope->locals); hkl_hash_free(scope->upvals); hkl_free_object(scope); }
void hklr_shutdown() { hklr_scope_pop(); // free globals hkl_hash_traverse(HKLR.globals, hklr_gc_dec_hash, NULL); hkl_hash_free(HKLR.globals); // collect garbage hklr_gc_collect(); hkl_list_free(HKLR.gc_to_free); hklr_object_free(HKLR.gc_roots); hklr_object_free(HKLR.gc_tail); }