void FunctionManager::destroy_functions_in_set(FunctionSet &function_set)
{
    // We iterate over the set like this because destroy_function() will erase
    // the function from function_set, thereby invalidating any iterator we are
    // holding on to.
    while (!function_set.empty())
    {
        destroy_function(*function_set.begin());
    }
}
Exemple #2
0
void lily_value_destroy(lily_value *v)
{
    int class_id = v->class_id;
    if (class_id == LILY_LIST_ID || class_id == LILY_TUPLE_ID)
        destroy_list(v);
    else if (v->flags & (VAL_IS_INSTANCE | VAL_IS_ENUM))
        destroy_instance(v);
    else if (class_id == LILY_STRING_ID || class_id == LILY_BYTESTRING_ID)
        destroy_string(v);
    else if (class_id == LILY_FUNCTION_ID)
        destroy_function(v);
    else if (class_id == LILY_HASH_ID)
        lily_destroy_hash(v);
    else if (class_id == LILY_DYNAMIC_ID)
        destroy_dynamic(v);
    else if (class_id == LILY_FILE_ID)
        destroy_file(v);
    else if (v->flags & VAL_IS_FOREIGN)
        v->value.foreign->destroy_func(v->value.generic);
}