From 4fb5649e0ecee113537c41861491b9ee54fea321 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sat, 3 Aug 2024 21:26:39 -0400 Subject: [PATCH] yeah there was something wrong now i have no idea --- CMakeLists.txt | 2 +- src/transformers.cpp | 18 ++++++++++++++---- src/tree.cpp | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e15defd..15d23aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.112) +project(blt-gp VERSION 0.0.113) include(CTest) diff --git a/src/transformers.cpp b/src/transformers.cpp index fefe042..676c37f 100644 --- a/src/transformers.cpp +++ b/src/transformers.cpp @@ -194,9 +194,12 @@ namespace blt::gp auto& new_vals_r = new_tree.get_values(); stack_allocator stack_after; - stack_allocator stack_for; transfer_backward(vals_r, stack_after, ops_r.end() - 1, end_itr - 1); - transfer_backward(vals_r, stack_for, end_itr - 1, begin_itr - 1); + for (auto it = end_itr - 1; it != begin_itr - 1; it--) + { + if (it->is_value) + vals_r.pop_bytes(static_cast(stack_allocator::aligned_size(it->type_size))); + } transfer_backward(new_vals_r, vals_r, new_ops_r.end() - 1, new_ops_r.begin() - 1); transfer_forward(stack_after, vals_r, end_itr, ops_r.end()); @@ -206,6 +209,8 @@ namespace blt::gp ops_r.insert(++before, new_ops_r.begin(), new_ops_r.end()); #if BLT_DEBUG_LEVEL >= 2 + BLT_ASSERT(new_vals_r.empty()); + BLT_ASSERT(stack_after.empty()); blt::size_t bytes_expected = 0; auto bytes_size = vals_r.size().total_used_bytes; @@ -227,11 +232,16 @@ namespace blt::gp blt::black_box(result); } catch (...) { - std::cout << "Parent:\n"; + std::cout << "This occurred at point " << begin_point << " ending at (old) " << end_point << "\n"; + std::cout << "our root type is " << ops_r[begin_point].id << " with size " << stack_allocator::aligned_size(ops_r[begin_point].type_size) << "\n"; + std::cout << "now Named: " << (program.get_name(ops_r[begin_point].id) ? *program.get_name(ops_r[begin_point].id) : "Unnamed") << "\n"; + std::cout << "Parent:" << std::endl; p.print(program, std::cout, false, true); - std::cout << "Child:\n"; + std::cout << "Child:" << std::endl; c.print(program, std::cout, false, true); + std::cout << std::endl; c.print(program, std::cout, true, true); + std::cout << std::endl; throw std::exception(); } diff --git a/src/tree.cpp b/src/tree.cpp index d1e7672..f9ac0c5 100644 --- a/src/tree.cpp +++ b/src/tree.cpp @@ -57,11 +57,14 @@ namespace blt::gp if (operation.is_value) { //BLT_DEBUG("Processed Value %ld with size %ld", operation.id, stack_allocator::aligned_size(operation.type_size)); + //BLT_DEBUG("Stack info: %ld %ld", values_process.size().total_used_bytes, value_stack.size().total_used_bytes); + //BLT_DEBUG("In Head: %ld %ld", values_process.bytes_in_head(), value_stack.bytes_in_head()); value_stack.transfer_bytes(values_process, operation.type_size); continue; } //BLT_DEBUG("Processed function %ld with size %ld", operation.id, stack_allocator::aligned_size(operation.type_size)); //BLT_TRACE("Stack info: %ld %ld", values_process.size().total_used_bytes, value_stack.size().total_used_bytes); + //BLT_INFO("In Head: %ld %ld", values_process.bytes_in_head(), value_stack.bytes_in_head()); operation.func(context, values_process, value_stack); operations_stack.emplace_back(empty_callable, operation.type_size, operation.id, true); }