Compare commits
No commits in common. "36fb9b86ccd56699ca18bdff21f6d8f2a8b8c220" and "6700161699559cd0a862c73a83a83b38d2a99835" have entirely different histories.
36fb9b86cc
...
6700161699
|
@ -27,7 +27,7 @@ macro(compile_options target_name)
|
||||||
sanitizers(${target_name})
|
sanitizers(${target_name})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
project(blt-gp VERSION 0.5.25)
|
project(blt-gp VERSION 0.5.23)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
|
|
@ -173,24 +173,8 @@ namespace blt::gp
|
||||||
std::vector<reorder_index_t> p1_reorder_types;
|
std::vector<reorder_index_t> p1_reorder_types;
|
||||||
std::vector<reorder_index_t> p2_reorder_types;
|
std::vector<reorder_index_t> p2_reorder_types;
|
||||||
std::vector<swap_index_t> swap_types;
|
std::vector<swap_index_t> swap_types;
|
||||||
|
std::vector<swap_index_t> p1_to_p2_transfer_types;
|
||||||
void print_missing_types()
|
std::vector<swap_index_t> p2_to_p1_transfer_types;
|
||||||
{
|
|
||||||
for (const auto& [id, v] : missing_p1_types)
|
|
||||||
{
|
|
||||||
BLT_INFO("(P1) For type {} missing indexes:", id);
|
|
||||||
for (const auto idx : v)
|
|
||||||
BLT_INFO("\t{}", idx);
|
|
||||||
BLT_INFO("----");
|
|
||||||
}
|
|
||||||
for (const auto& [id, v] : missing_p2_types)
|
|
||||||
{
|
|
||||||
BLT_INFO("(P2) For type {} missing indexes:", id);
|
|
||||||
for (const auto idx : v)
|
|
||||||
BLT_INFO("\t{}", idx);
|
|
||||||
BLT_INFO("----");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<size_t> get_p1_index(const type_id& id)
|
std::optional<size_t> get_p1_index(const type_id& id)
|
||||||
{
|
{
|
||||||
|
@ -234,6 +218,8 @@ namespace blt::gp
|
||||||
p1_reorder_types.clear();
|
p1_reorder_types.clear();
|
||||||
p2_reorder_types.clear();
|
p2_reorder_types.clear();
|
||||||
swap_types.clear();
|
swap_types.clear();
|
||||||
|
p1_to_p2_transfer_types.clear();
|
||||||
|
p2_to_p1_transfer_types.clear();
|
||||||
for (auto& [id, v] : missing_p1_types)
|
for (auto& [id, v] : missing_p1_types)
|
||||||
v.clear();
|
v.clear();
|
||||||
for (auto& [id, v] : missing_p2_types)
|
for (auto& [id, v] : missing_p2_types)
|
||||||
|
@ -242,10 +228,8 @@ namespace blt::gp
|
||||||
} resolver;
|
} resolver;
|
||||||
resolver.clear();
|
resolver.clear();
|
||||||
|
|
||||||
auto min_size = std::min(p1_info.argument_types.size(), p2_info.argument_types.size());
|
|
||||||
|
|
||||||
// resolve type information
|
// resolve type information
|
||||||
for (size_t i = 0; i < min_size; i++)
|
for (size_t i = 0; i < std::min(p1_info.argument_types.size(), p2_info.argument_types.size()); i++)
|
||||||
{
|
{
|
||||||
if (p1_info.argument_types[i] != p2_info.argument_types[i])
|
if (p1_info.argument_types[i] != p2_info.argument_types[i])
|
||||||
{
|
{
|
||||||
|
@ -255,12 +239,6 @@ namespace blt::gp
|
||||||
resolver.correct_types.insert(i);
|
resolver.correct_types.insert(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = min_size; i < p1_info.argument_types.size(); i++)
|
|
||||||
resolver.missing_p1_types[p1_info.argument_types[i].id].push_back(i);
|
|
||||||
|
|
||||||
for (size_t i = min_size; i < p2_info.argument_types.size(); i++)
|
|
||||||
resolver.missing_p2_types[p2_info.argument_types[i].id].push_back(i);
|
|
||||||
|
|
||||||
// if swaping p1 -> p2 and p2 -> p1, we may already have the types we need just in a different order
|
// if swaping p1 -> p2 and p2 -> p1, we may already have the types we need just in a different order
|
||||||
|
|
||||||
// first, make a list of types which can simply be reordered
|
// first, make a list of types which can simply be reordered
|
||||||
|
@ -274,7 +252,6 @@ namespace blt::gp
|
||||||
resolver.p2_correct_types.insert(i);
|
resolver.p2_correct_types.insert(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < p2_info.argument_types.size(); i++)
|
for (size_t i = 0; i < p2_info.argument_types.size(); i++)
|
||||||
{
|
{
|
||||||
if (resolver.correct_types.contains(i))
|
if (resolver.correct_types.contains(i))
|
||||||
|
@ -285,7 +262,6 @@ namespace blt::gp
|
||||||
resolver.p1_correct_types.insert(i);
|
resolver.p1_correct_types.insert(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// next we need to figure out which types need to be swapped
|
// next we need to figure out which types need to be swapped
|
||||||
for (size_t i = 0; i < p1_info.argument_types.size(); i++)
|
for (size_t i = 0; i < p1_info.argument_types.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -293,17 +269,27 @@ namespace blt::gp
|
||||||
continue;
|
continue;
|
||||||
if (auto index = resolver.get_p1_index(p1_info.argument_types[i].id))
|
if (auto index = resolver.get_p1_index(p1_info.argument_types[i].id))
|
||||||
resolver.swap_types.push_back({*index, i});
|
resolver.swap_types.push_back({*index, i});
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BLT_WARN("Unable to process type {} in p1", p1_info.argument_types[i].id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < p2_info.argument_types.size(); i++)
|
for (size_t i = 0; i < p2_info.argument_types.size(); i++)
|
||||||
{
|
{
|
||||||
if (resolver.handled_p1(i))
|
if (resolver.handled_p1(i))
|
||||||
continue;
|
continue;
|
||||||
if (auto index = resolver.get_p2_index(p2_info.argument_types[i].id))
|
if (auto index = resolver.get_p2_index(p2_info.argument_types[i].id))
|
||||||
resolver.swap_types.push_back({i, *index});
|
resolver.swap_types.push_back({i, *index});
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BLT_WARN("Unable to process type {} in p2", p2_info.argument_types[i].id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we do the swap
|
// now we do the swap
|
||||||
|
|
||||||
p1.find_child_extends(resolver.children_data_p1, point1.pos, p1_info.argument_types.size());
|
p1.find_child_extends(resolver.children_data_p1, point1.pos, p1_info.argument_types.size());
|
||||||
p2.find_child_extends(resolver.children_data_p2, point2.pos, p2_info.argument_types.size());
|
p2.find_child_extends(resolver.children_data_p2, point2.pos, p2_info.argument_types.size());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue