Changeset fd782b2 for src/examples/gc_no_raii/src/gcpointers.c
- Timestamp:
- Sep 15, 2016, 10:55:52 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- aa8f9df
- Parents:
- f006f01 (diff), 1eba452 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/src/gcpointers.c
rf006f01 rfd782b2 14 14 gc_object_header* obj = gc_get_object_for_ref(gc_get_state(), (void*)this); 15 15 check(obj); 16 check( gc_obj_is_valide(obj));17 check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL);16 check(is_valid(obj)); 17 check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || !obj->type_chain); 18 18 this->next = obj->type_chain; 19 19 obj->type_chain = this; 20 check( obj->is_valide());20 check(is_valid(obj)); 21 21 } 22 22 else … … 24 24 gc_object_header* obj = gc_get_object_ptr((void*)this->ptr); 25 25 check(obj); 26 check(gc_obj_is_valide(obj)); 27 check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL); 26 check(is_valid(obj)); 27 check(!obj->root_chain || this->ptr == obj->root_chain->ptr); 28 check(!obj->root_chain || gc_is_managed(this) == gc_is_managed(obj->root_chain)); 28 29 this->next = obj->root_chain; 29 30 obj->root_chain = this; 30 check( gc_obj_is_valide(obj));31 check(is_valid(obj)); 31 32 } 32 33 } … … 69 70 } 70 71 71 gcpointer_t * gcpointer_assign(gcpointer_t* this, gcpointer_t*rhs)72 gcpointer_t ?=?(gcpointer_t* this, gcpointer_t rhs) 72 73 { 73 if(this != rhs)74 {75 unregister_ptr(this);74 unregister_ptr(this); 75 this->ptr = rhs.ptr; 76 register_ptr(this); 76 77 77 this->ptr = rhs->ptr; 78 79 register_ptr(this); 80 } 81 82 return this; 78 return *this; 83 79 } 84 80 85 81 //Logical operators 86 bool gcpointer_equal( gcpointer_t* this,gcpointer_t* rhs)82 bool gcpointer_equal(const gcpointer_t* this, const gcpointer_t* rhs) 87 83 { 88 84 return this->ptr == rhs->ptr; 89 85 } 90 86 91 bool gcpointer_not_equal( gcpointer_t* this,gcpointer_t* rhs)87 bool gcpointer_not_equal(const gcpointer_t* this, const gcpointer_t* rhs) 92 88 { 93 89 return this->ptr != rhs->ptr; 94 90 } 95 91 96 bool gcpointer_null( gcpointer_t* this)92 bool gcpointer_null(const gcpointer_t* this) 97 93 { 98 94 return this->ptr == (intptr_t)NULL; 99 95 } 96 97 #ifndef NDEBUG 98 bool is_valid(const gcpointer_t* this) { 99 if(gcpointer_null(this)) return true; 100 101 gc_object_header* obj = gc_get_object_ptr((void*)this->ptr); 102 check(obj); 103 check(is_valid(obj)); 104 check(!obj->root_chain || this->ptr == obj->root_chain->ptr); 105 106 if( !gc_is_managed(this)) 107 { 108 check( !(this->next) || this->ptr == this->next->ptr ); 109 } 110 111 return true; 112 } 113 #endif 100 114 101 115 forall(otype T) void ?{}(gcpointer(T)* this) { … … 107 121 } 108 122 109 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) *other) {110 (&this->internal) { other ->internal };123 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) other) { 124 (&this->internal) { other.internal }; 111 125 } 112 126 … … 115 129 } 116 130 117 // forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs); 131 forall(otype T) gcpointer(T) ?=?(gcpointer(T)* this, gcpointer(T) rhs) { 132 this->internal = rhs.internal; 133 return *this; 134 } 118 135 // 119 136 // forall(otype T) T *?(gcpointer(T) this); … … 124 141 // 125 142 // //Logical operators 143 forall(otype T) int ?!=?(gcpointer(T) this, int zero) { 144 return this.internal.ptr != 0; 145 } 126 146 // forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs); 127 147 // forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs);
Note: See TracChangeset
for help on using the changeset viewer.