Almost finished with 1st impl of GC

Co-authored-by: ValterMiari <ValterMiari@users.noreply.github.com>
This commit is contained in:
Victor Olin 2023-02-14 11:47:52 +01:00
parent f42ea42273
commit 7fd324a5b2
5 changed files with 48 additions and 123 deletions

28
src/GC/heap.cpp Normal file
View file

@ -0,0 +1,28 @@
#pragma once
#include <assert.h>
#include <iostream>
#include <setjmp.h>
#include <stdlib.h>
#include <vector>
#include "include/heap.hpp"
namespace GC {
size_t Heap::getSize() {
return m_size;
}
void *Heap::alloc(size_t size) {
auto heap = Heap::the();
assert(heap.getSize() + size <= HEAP_SIZE);
return m_heap + m_size;
}
void Heap::collect() {
// TODO
}
}