From 10fe1e28cf0464c6922f3e0a634f58e0e9f8f52c Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 17 Mar 2024 15:15:08 -0400 Subject: [PATCH] test --- CMakeLists.txt | 2 +- include/lilfbtf/type.h | 1 + src/tree.cpp | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab95e26..6d4472e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/include/lilfbtf/type.h b/include/lilfbtf/type.h index 9005563..51ddaba 100644 --- a/include/lilfbtf/type.h +++ b/include/lilfbtf/type.h @@ -124,6 +124,7 @@ namespace fb associative_array> functions; // function id -> list of type_id for parameters where index 0 = arg 1 associative_array, true> function_inputs; + associative_array function_outputs; associative_array function_argc; blt::hashmap_t> function_initializer; diff --git a/src/tree.cpp b/src/tree.cpp index 6fc5901..14a7131 100644 --- a/src/tree.cpp +++ b/src/tree.cpp @@ -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))