main
Brett 2024-03-17 15:15:08 -04:00
parent 6751127608
commit 10fe1e28cf
3 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(lilfbtf5 VERSION 0.1.28)
project(lilfbtf5 VERSION 0.1.29)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)

View File

@ -124,6 +124,7 @@ namespace fb
associative_array<function_id, std::reference_wrapper<const func_t_call_t>> functions;
// function id -> list of type_id for parameters where index 0 = arg 1
associative_array<function_id, std::vector<type_id>, true> function_inputs;
associative_array<function_id, type_id> function_outputs;
associative_array<function_id, arg_c_t> function_argc;
blt::hashmap_t<function_id, std::reference_wrapper<const func_t_init_t>> function_initializer;

View File

@ -179,11 +179,15 @@ namespace fb
detail::node_t* tree_t::allocate_non_terminal_restricted(detail::node_helper_t details, type_id type)
{
const auto& non_terminals = details.types.get_non_terminals(type);
function_id selection = 0;
do {
const auto& non_terminals = details.types.get_non_terminals(type);
selection = details.engine.random_long(0, non_terminals.size() - 1);
auto& sel_v = details.types.get_function_allowed_arguments(selection);
// if it does not accept the type we are
if (std::find(sel_v.begin(), sel_v.end(), type) == sel_v.end())
break;
} while(true);
func_t func(details.types.get_function_argc(selection), details.types.get_function(selection), type, selection);
if (const auto& func_init = details.types.get_function_initializer(selection))