From 92186911ad6c1ffd237917ed2e6abdd43e47a1b7 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Fri, 11 May 2018 11:38:10 -0700 Subject: [PATCH] Add type parameters to behavior. --- include/custom.h | 5 +++++ src/custom.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/include/custom.h b/include/custom.h index fc3b103..42c9835 100644 --- a/include/custom.h +++ b/include/custom.h @@ -3,6 +3,7 @@ #include "parsetype.h" #include "tree.h" +#include "ref_trie.h" /** * A function pointer that is called @@ -58,6 +59,10 @@ struct libab_behavior_s { * The type of the function. */ libab_ref type; + /** + * The type parameters for the given behavior. + */ + libab_ref_trie type_params; }; /** * A struct that holds informatiion diff --git a/src/custom.c b/src/custom.c index 32b96f0..cf60dfc 100644 --- a/src/custom.c +++ b/src/custom.c @@ -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); }