#include "gcpointers.h" #include "gc.h" #include "internal/collector.h" //#include "internal/object_header.h" // #include "internal/state.h" /* void register_ptr(gcpointer_t* this) { // if(gcpointer_null(this)) return; // // _Bool managed = gc_is_managed(this); // // if(managed) // { // gc_object_header* obj = gc_get_object_for_ref(gc_get_state(), (void*)this); // check(obj); // check(gc_obj_is_valide(obj)); // check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL); // this->next = obj->type_chain; // obj->type_chain = this; // check(obj->is_valide()); // } // else // { // gc_object_header* obj = gc_get_object_ptr((void*)this->ptr); // check(obj); // check(gc_obj_is_valide(obj)); // check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL); // this->next = obj->root_chain; // obj->root_chain = this; // check(gc_obj_is_valide(obj)); // } } void unregister_ptr(gcpointer_t* this) { // if(gcpointer_null(this)) return; // // gcpointer_t** prev_next_ptr = gc_find_previous_ref(this); // check((*prev_next_ptr) == this); // // (*prev_next_ptr) = this->next; } void gcpointer_ctor(gcpointer_t* this) { this->ptr = (intptr_t)NULL; this->next = NULL; } void gcpointer_ctor(gcpointer_t* this, void* address) { this->ptr = (intptr_t)address; this->next = NULL; register_ptr(this); } void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other) { this->ptr = other->ptr; this->next = NULL; register_ptr(this); } void gcpointer_dtor(gcpointer_t* this) { unregister_ptr(this); } gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t* rhs) { if(this != rhs) { unregister_ptr(this); this->ptr = rhs->ptr; register_ptr(this); } return this; } //Logical operators int gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs) { return this->ptr == rhs->ptr; } int gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs) { return this->ptr != rhs->ptr; } int gcpointer_null(gcpointer_t* this) { return this->ptr == (intptr_t)NULL; }*/