1 | #include "gcpointers.h" |
---|
2 | |
---|
3 | #include "gc.h" |
---|
4 | #include "internal/collector.h" |
---|
5 | #include "internal/object_header.h" |
---|
6 | // #include "internal/state.h" |
---|
7 | |
---|
8 | // void register_ptr(gcpointer_t* this) |
---|
9 | // { |
---|
10 | // if(gcpointer_null(this)) return; |
---|
11 | // |
---|
12 | // _Bool managed = gc_is_managed(this); |
---|
13 | // |
---|
14 | // if(managed) |
---|
15 | // { |
---|
16 | // gc_object_header* obj = gc_get_object_for_ref(gc_get_state(), (void*)this); |
---|
17 | // check(obj); |
---|
18 | // check(gc_obj_is_valide(obj)); |
---|
19 | // check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL); |
---|
20 | // this->next = obj->type_chain; |
---|
21 | // obj->type_chain = this; |
---|
22 | // check(obj->is_valide()); |
---|
23 | // } |
---|
24 | // else |
---|
25 | // { |
---|
26 | // gc_object_header* obj = gc_get_object_ptr((void*)this->ptr); |
---|
27 | // check(obj); |
---|
28 | // check(gc_obj_is_valide(obj)); |
---|
29 | // check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL); |
---|
30 | // this->next = obj->root_chain; |
---|
31 | // obj->root_chain = this; |
---|
32 | // check(gc_obj_is_valide(obj)); |
---|
33 | // } |
---|
34 | // } |
---|
35 | // |
---|
36 | // void unregister_ptr(gcpointer_t* this) |
---|
37 | // { |
---|
38 | // if(gcpointer_null(this)) return; |
---|
39 | // |
---|
40 | // gcpointer_t** prev_next_ptr = gc_find_previous_ref(this); |
---|
41 | // check((*prev_next_ptr) == this); |
---|
42 | // |
---|
43 | // (*prev_next_ptr) = this->next; |
---|
44 | // } |
---|
45 | // |
---|
46 | // void gcpointer_ctor(gcpointer_t* this) |
---|
47 | // { |
---|
48 | // this->ptr = (intptr_t)NULL; |
---|
49 | // this->next = NULL; |
---|
50 | // } |
---|
51 | // |
---|
52 | // void gcpointer_ctor(gcpointer_t* this, void* address) |
---|
53 | // { |
---|
54 | // this->ptr = (intptr_t)address; |
---|
55 | // this->next = NULL; |
---|
56 | // |
---|
57 | // register_ptr(this); |
---|
58 | // } |
---|
59 | // |
---|
60 | // void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other) |
---|
61 | // { |
---|
62 | // this->ptr = other->ptr; |
---|
63 | // this->next = NULL; |
---|
64 | // |
---|
65 | // register_ptr(this); |
---|
66 | // } |
---|
67 | // |
---|
68 | // void gcpointer_dtor(gcpointer_t* this) |
---|
69 | // { |
---|
70 | // unregister_ptr(this); |
---|
71 | // } |
---|
72 | // |
---|
73 | // gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t* rhs) |
---|
74 | // { |
---|
75 | // if(this != rhs) |
---|
76 | // { |
---|
77 | // unregister_ptr(this); |
---|
78 | // |
---|
79 | // this->ptr = rhs->ptr; |
---|
80 | // |
---|
81 | // register_ptr(this); |
---|
82 | // } |
---|
83 | // |
---|
84 | // return this; |
---|
85 | // } |
---|
86 | // |
---|
87 | // //Logical operators |
---|
88 | // int gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs) |
---|
89 | // { |
---|
90 | // return this->ptr == rhs->ptr; |
---|
91 | // } |
---|
92 | // |
---|
93 | // int gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs) |
---|
94 | // { |
---|
95 | // return this->ptr != rhs->ptr; |
---|
96 | // } |
---|
97 | // |
---|
98 | // int gcpointer_null(gcpointer_t* this) |
---|
99 | // { |
---|
100 | // return this->ptr == (intptr_t)NULL; |
---|
101 | // } |
---|