Compare commits

..

2 Commits

Author SHA1 Message Date
CHatingPython 549af109b9 fix: fix this mess
I am stupid
I am stupid
I am stupid
I can't believe how f- ricking stupid I am
2026-07-19 22:04:50 +02:00
CHatingPython 6dce7016ce test(furvm): introduce an add things test 2026-07-19 21:53:37 +02:00
6 changed files with 33 additions and 9 deletions
+1 -3
View File
@@ -9,15 +9,13 @@ main:
store %0
lenof
push $s32 1
sub
store %1
push $s32 0
loop:
dup
load %1
eq
ge
jnz #end
body:
dup
+2 -2
View File
@@ -7,14 +7,14 @@ main:
array $arr
store %0
push $s32 1
push $s32 2
store %1
push $s32 0
loop:
dup
load %1
eq
ge
jnz #end
body:
dup
+1 -1
View File
@@ -111,7 +111,7 @@ using function_id = std::uint16_t;
/**
* @brief A handle to a furvm function.
*/
using function_h = handle<function, generic_header<function_id>>;
using function_h = handle<function, refcount_header<function_id>>;
// module.hpp
+2 -1
View File
@@ -69,8 +69,9 @@ public:
[[nodiscard]] T* allocate(std::size_t count = 1) {
for (auto it = m_deadThings->begin(); it != m_deadThings->end(); ++it) {
if (it->second != count) continue;
T* data = it->first;
m_deadThings->erase(it);
return it->first;
return data;
}
return m_arena->allocate<T>(count);
}
+1 -1
View File
@@ -101,7 +101,7 @@ thing_h executor::pop_thing() {
if (m_frames.top().stackBase >= m_stack.size()) throw stack_underflow();
thing_h top = std::move(m_stack.top());
m_stack.pop();
return top;
return std::move(top);
}
thing_h executor::thing() const {
+26 -1
View File
@@ -1,3 +1,28 @@
#include "furlang/arena.hpp"
#include "furvm/furvm.hpp"
#include "furvm/thing.hpp"
#include "furvm/thing_allocator.hpp"
#include "gtest/gtest.h" // IWYU pragma: keep
namespace {}
namespace {
// TODO: Basic program tests (e.g. for loops)
TEST(Things, Ops) {
furlang::arena arena;
furvm::thing_allocator<std::byte> alloc{ arena };
furvm::thing lhs{ furvm::thing_type{ furvm::thing_type::U32 }, alloc };
lhs.get<furvm::thing_type::u32>() = 6;
furvm::thing rhs{ furvm::thing_type{ furvm::thing_type::U32 }, alloc };
rhs.get<furvm::thing_type::u32>() = 7;
auto res = lhs.add(rhs);
ASSERT_EQ(res.type().type, furvm::thing_type::U32);
EXPECT_EQ(lhs.get<furvm::thing_type::u32>(), 6);
EXPECT_EQ(rhs.get<furvm::thing_type::u32>(), 7);
EXPECT_EQ(res.get<furvm::thing_type::u32>(), 6 + 7);
}
} // namespace