going to try the queue approach

dev
Brett 2025-05-25 17:47:38 -04:00
parent b91f679915
commit b1a73e1572
3 changed files with 25 additions and 10 deletions

View File

@ -38,6 +38,9 @@ namespace blt::gp
struct type_id : integer_type<u64> struct type_id : integer_type<u64>
{ {
using integer_type::integer_type; using integer_type::integer_type;
// debug helper.
[[nodiscard]] std::string name(gp_program& program) const;
}; };
class type class type

View File

@ -836,7 +836,8 @@ namespace blt::gp
continue; continue;
if (type == other_point_info.argument_types[i]) if (type == other_point_info.argument_types[i])
{ {
BLT_TRACE("Consuming other type {} at index {} ", type, index); BLT_TRACE("Consuming other type {} (aka {}) at index {} replacing {} (aka {})", type, type.name(*tree->m_program), index,
i, storage.our_current_types[i].name(*tree->m_program));
consumed = true; consumed = true;
const auto s1 = storage.other_children[index].size(); const auto s1 = storage.other_children[index].size();
const auto s2 = storage.our_children[i].size(); const auto s2 = storage.our_children[i].size();
@ -869,7 +870,8 @@ namespace blt::gp
continue; continue;
if (type == point_info.argument_types[i]) if (type == point_info.argument_types[i])
{ {
BLT_TRACE("Consuming our type {} at index {} ", type, index); BLT_TRACE("Consuming other type {} (aka {}) at index {} replacing {} (aka {})", type, type.name(*tree->m_program), index,
i, storage.other_current_types[i].name(*tree->m_program));
consumed = true; consumed = true;
const auto s1 = storage.our_children[index].size(); const auto s1 = storage.our_children[index].size();
const auto s2 = storage.other_children[i].size(); const auto s2 = storage.other_children[i].size();
@ -895,10 +897,16 @@ namespace blt::gp
#if BLT_DEBUG_LEVEL >= 1 #if BLT_DEBUG_LEVEL >= 1
for (const auto& [i, a, b] : in_pairs(storage.our_current_types, other_point_info.argument_types).enumerate().take(common_size).flatten()) for (const auto& [i, a, b] : in_pairs(storage.our_current_types, other_point_info.argument_types).enumerate().take(common_size).flatten())
BLT_ASSERT_MSG(a == b, ("[Our] Mismatched types at index " + std::to_string(i) + " expected '" + std::string(tree->m_program->get_typesystem().get_type(a).name()) + "' but found '" + BLT_ASSERT_MSG(
a == b,
("[Our] Mismatched types at index " + std::to_string(i) + " expected '" + std::string(tree->m_program->get_typesystem().get_type(a).
name()) + "' but found '" +
std::string(tree->m_program->get_typesystem().get_type(b).name()) + "'").c_str()); std::string(tree->m_program->get_typesystem().get_type(b).name()) + "'").c_str());
for (const auto& [i, a, b] : in_pairs(storage.other_current_types, point_info.argument_types).enumerate().take(common_size).flatten()) for (const auto& [i, a, b] : in_pairs(storage.other_current_types, point_info.argument_types).enumerate().take(common_size).flatten())
BLT_ASSERT_MSG(a == b, ("[Other] Mismatched types at index " + std::to_string(i) + " expected '" + std::string(tree->m_program->get_typesystem().get_type(a).name()) + "' but found '" + BLT_ASSERT_MSG(
a == b,
("[Other] Mismatched types at index " + std::to_string(i) + " expected '" + std::string(tree->m_program->get_typesystem().get_type(a).
name()) + "' but found '" +
std::string(tree->m_program->get_typesystem().get_type(b).name()) + "'").c_str()); std::string(tree->m_program->get_typesystem().get_type(b).name()) + "'").c_str());
#endif #endif
@ -913,7 +921,7 @@ namespace blt::gp
continue; continue;
if (type == point_info.argument_types[i]) if (type == point_info.argument_types[i])
{ {
// BLT_TRACE("[Our] Consuming type {} at index {} being inserted into {}", type, index, insert_index); BLT_TRACE("[Our] Consuming type {} at index {} being inserted into {}", type, index, insert_index);
storage.temp.clear(*tree->m_program); storage.temp.clear(*tree->m_program);
copy_subtree(storage.our_children[i], storage.temp); copy_subtree(storage.our_children[i], storage.temp);
insert_index = other_tree.manipulate().easy_manipulator().insert_subtree(subtree_point_t{insert_index}, storage.temp); insert_index = other_tree.manipulate().easy_manipulator().insert_subtree(subtree_point_t{insert_index}, storage.temp);
@ -941,7 +949,7 @@ namespace blt::gp
continue; continue;
if (type == other_point_info.argument_types[i]) if (type == other_point_info.argument_types[i])
{ {
// BLT_TRACE("[Other] Consuming type {} at index {} being inserted into {}", type, index, insert_index); BLT_TRACE("[Other] Consuming type {} at index {} being inserted into {}", type, index, insert_index);
storage.temp.clear(*tree->m_program); storage.temp.clear(*tree->m_program);
other_tree.manipulate().easy_manipulator().copy_subtree(storage.other_children[i], storage.temp); other_tree.manipulate().easy_manipulator().copy_subtree(storage.other_children[i], storage.temp);
insert_index = insert_subtree(subtree_point_t{insert_index}, storage.temp); insert_index = insert_subtree(subtree_point_t{insert_index}, storage.temp);

View File

@ -16,8 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include <blt/gp/typesystem.h> #include <blt/gp/typesystem.h>
#include <blt/gp/program.h>
namespace blt::gp namespace blt::gp
{ {
std::string type_id::name(gp_program& program) const
{
return std::string(program.get_typesystem().get_type(id).name());
}
} }