From 0ae2dd84e82c5f3a7077abee7d26af711b988055 Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 21 Jul 2024 13:45:00 -0400 Subject: [PATCH] no --- CMakeLists.txt | 2 +- include/blt/gp/stack.h | 6 +++--- src/transformers.cpp | 15 +++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 521bbd1..e0eb752 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(blt-gp VERSION 0.0.92) +project(blt-gp VERSION 0.0.93) include(CTest) diff --git a/include/blt/gp/stack.h b/include/blt/gp/stack.h index 9121f96..aa00351 100644 --- a/include/blt/gp/stack.h +++ b/include/blt/gp/stack.h @@ -306,12 +306,12 @@ namespace blt::gp if (empty()) throw std::runtime_error("This stack is empty!"); - if (head->used_bytes_in_block() < static_cast(bytes)) + auto type_size = aligned_size(bytes); + if (head->used_bytes_in_block() < static_cast(type_size)) BLT_ABORT(("This stack doesn't contain enough data for this type! " + std::to_string(head->used_bytes_in_block()) + " / " + std::to_string(bytes) + " This is an invalid runtime state!").c_str()); - auto type_size = aligned_size(bytes); - auto ptr = to.allocate_bytes(bytes); + auto ptr = to.allocate_bytes(type_size); to.head->metadata.offset = static_cast(ptr) + type_size; std::memcpy(ptr, head->metadata.offset - type_size, type_size); head->metadata.offset -= type_size; diff --git a/src/transformers.cpp b/src/transformers.cpp index f9f83a2..19c9a13 100644 --- a/src/transformers.cpp +++ b/src/transformers.cpp @@ -165,7 +165,14 @@ namespace blt::gp stack_allocator after_stack; - transfer_backward(vals, after_stack, ops.end() - 1, end_p - 1); + for (auto it = ops.end() - 1; it != end_p - 1; it--) + { + if (it->is_value) + { + vals.transfer_bytes(after_stack, it->type_size); + //after_ops.push_back(*it); + } + } for (auto it = end_p - 1; it != begin_p - 1; it--) { @@ -184,10 +191,10 @@ namespace blt::gp ops.insert(++before, new_ops.begin(), new_ops.end()); - for (const auto& op : new_ops) + for (auto it = new_ops.end() - 1; it != new_ops.begin() - 1; it--) { - if (op.is_value) - new_vals.transfer_bytes(vals, op.type_size); + if (it->is_value) + new_vals.transfer_bytes(vals, it->type_size); } auto new_end_point = point + new_ops.size();