First commit

This commit is contained in:
2024-12-28 14:38:00 -06:00
commit 9c27f339be
56 changed files with 289761 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
#include "CrossLang.hpp"
namespace Tesses::CrossLang
{
GCList::GCList(GC* gc)
{
gc->BarrierBegin();
this->gc = gc;
gc->SetRoot(this);
gc->BarrierEnd();
}
GCList::GCList(GC& gc)
{
gc.BarrierBegin();
this->gc = &gc;
gc.SetRoot(this);
gc.BarrierEnd();
}
GC* GCList::GetGC()
{
return this->gc;
}
void GCList::Remove(TObject obj)
{
if(std::holds_alternative<THeapObjectHolder>(obj))
{
auto _item=std::get<THeapObjectHolder>(obj).obj;
this->gc->BarrierBegin();
for(auto index = this->items.begin();index<this->items.end();index++)
{
if(*index == _item)
{
this->items.erase(index);
continue;
}
}
this->gc->BarrierEnd();
}
}
void GCList::Add(TObject obj)
{
if(std::holds_alternative<THeapObjectHolder>(obj))
{
auto _item=std::get<THeapObjectHolder>(obj).obj;
this->gc->BarrierBegin();
for(auto item : this->items)
{
if(item == _item) {
this->gc->BarrierEnd();
return;
}
}
this->items.push_back(_item);
this->gc->BarrierEnd();
}
}
void GCList::Mark()
{
this->marked=true;
for(auto item : this->items)
{
item->Mark();
}
}
GCList::~GCList()
{
gc->BarrierBegin();
this->gc->UnsetRoot(this);
gc->BarrierEnd();
}
}