Ignore:
Timestamp:
Sep 13, 2016, 4:21:26 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
4c1403c
Parents:
4ed70597
Message:

many small fixes in garbage collector, mostly RAII related

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/src/gcpointers.c

    r4ed70597 r76af36f  
    2525                check(obj);
    2626                check(is_valid(obj));
    27                 check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || !obj->root_chain);
     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));
    2829                this->next = obj->root_chain;
    2930                obj->root_chain = this;
     
    6970}
    7071
    71 gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t* rhs)
     72gcpointer_t ?=?(gcpointer_t* this, gcpointer_t rhs)
    7273{
    73         if(this != rhs)
    74         {
    75                 unregister_ptr(this);
     74        unregister_ptr(this);
     75        this->ptr = rhs.ptr;
     76        register_ptr(this);
    7677
    77                 this->ptr = rhs->ptr;
    78 
    79                 register_ptr(this);
    80         }
    81 
    82         return this;
     78        return *this;
    8379}
    8480
     
    107103}
    108104
    109 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other) {
    110         (&this->internal) { other->internal };
     105forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) other) {
     106        (&this->internal) { other.internal };
    111107}
    112108
     
    115111}
    116112
    117 // forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs);
     113forall(otype T) gcpointer(T) ?=?(gcpointer(T)* this, gcpointer(T) rhs) {
     114        this->internal = rhs.internal;
     115        return *this;
     116}
    118117//
    119118// forall(otype T) T *?(gcpointer(T) this);
Note: See TracChangeset for help on using the changeset viewer.