Add type parameters to behavior.

This commit is contained in:
2018-05-11 11:38:10 -07:00
parent 8253cd1f69
commit 92186911ad
2 changed files with 8 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ void libab_behavior_init_internal(libab_behavior* behavior, libab_ref* type,
behavior->impl.variant = BIMPL_INTERNAL;
behavior->impl.data_u.internal = func;
libab_ref_copy(type, &behavior->type);
libab_ref_trie_init(&behavior->type_params);
}
void libab_behavior_init_tree(libab_behavior* behavior, libab_ref* type,
@@ -12,10 +13,12 @@ void libab_behavior_init_tree(libab_behavior* behavior, libab_ref* type,
behavior->impl.variant = BIMPL_TREE;
behavior->impl.data_u.tree = tree;
libab_ref_copy(type, &behavior->type);
libab_ref_trie_init(&behavior->type_params);
}
void libab_behavior_free(libab_behavior* behavior) {
libab_ref_free(&behavior->type);
libab_ref_trie_free(&behavior->type_params);
if (behavior->impl.variant == BIMPL_TREE) {
libab_tree_free_recursive(behavior->impl.data_u.tree);
}