Add type parameters to behavior.
This commit is contained in:
		
							parent
							
								
									8253cd1f69
								
							
						
					
					
						commit
						92186911ad
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user