Changeset aca65621 for src/libcfa/containers
- Timestamp:
- Jul 12, 2017, 4:40:02 PM (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:
- 0698aa1
- Parents:
- 469f709
- Location:
- src/libcfa/containers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/maybe
r469f709 raca65621 29 29 30 30 forall(otype T) 31 void ?{}(maybe(T) *this);31 void ?{}(maybe(T) & this); 32 32 33 33 forall(otype T) 34 void ?{}(maybe(T) *this, T value);34 void ?{}(maybe(T) & this, T value); 35 35 36 36 forall(otype T) 37 void ?{}(maybe(T) *this, maybe(T) other);37 void ?{}(maybe(T) & this, maybe(T) other); 38 38 39 39 forall(otype T) 40 void ^?{}(maybe(T) *this);40 void ^?{}(maybe(T) & this); 41 41 42 42 forall(otype T) 43 maybe(T) ?=?(maybe(T) *this, maybe(T) other);43 maybe(T) ?=?(maybe(T) & this, maybe(T) other); 44 44 45 45 forall(otype T) -
src/libcfa/containers/maybe.c
r469f709 raca65621 19 19 20 20 forall(otype T) 21 void ?{}(maybe(T) *this) {22 this ->has_value = false;21 void ?{}(maybe(T) & this) { 22 this.has_value = false; 23 23 } 24 24 25 25 forall(otype T) 26 void ?{}(maybe(T) *this, T value) {27 this ->has_value = true;28 ( &this->value){value};26 void ?{}(maybe(T) & this, T value) { 27 this.has_value = true; 28 (this.value){value}; 29 29 } 30 30 31 31 forall(otype T) 32 void ?{}(maybe(T) *this, maybe(T) other) {33 this ->has_value = other.has_value;32 void ?{}(maybe(T) & this, maybe(T) other) { 33 this.has_value = other.has_value; 34 34 if (other.has_value) { 35 ( &this->value){other.value};35 (this.value){other.value}; 36 36 } 37 37 } 38 38 39 39 forall(otype T) 40 maybe(T) ?=?(maybe(T) *this, maybe(T) that) {41 if (this ->has_value & that.has_value) {42 this ->value = that.value;43 } else if (this ->has_value) {44 ^( &this->value){};45 this ->has_value = false;40 maybe(T) ?=?(maybe(T) & this, maybe(T) that) { 41 if (this.has_value & that.has_value) { 42 this.value = that.value; 43 } else if (this.has_value) { 44 ^(this.value){}; 45 this.has_value = false; 46 46 } else if (that.has_value) { 47 this ->has_value = true;48 ( &this->value){that.value};47 this.has_value = true; 48 (this.value){that.value}; 49 49 } 50 return this; 50 51 } 51 52 52 53 forall(otype T) 53 void ^?{}(maybe(T) *this) {54 if (this ->has_value) {55 ^( &this->value){};54 void ^?{}(maybe(T) & this) { 55 if (this.has_value) { 56 ^(this.value){}; 56 57 } 57 58 } … … 89 90 } else { 90 91 this->has_value = true; 91 ( &this->value){value};92 (this->value){value}; 92 93 } 93 94 } … … 97 98 if (this->has_value) { 98 99 this->has_value = false; 99 ^( &this->value){};100 ^(this->value){}; 100 101 } 101 102 } -
src/libcfa/containers/vector
r469f709 raca65621 31 31 32 32 forall(otype T) 33 void ?{}(heap_allocator(T) *this);33 void ?{}(heap_allocator(T)& this); 34 34 35 35 forall(otype T) 36 void ?{}(heap_allocator(T) *this, heap_allocator(T) rhs);36 void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs); 37 37 38 38 forall(otype T) 39 heap_allocator(T) ?=?(heap_allocator(T) *this, heap_allocator(T) rhs);39 heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs); 40 40 41 41 forall(otype T) 42 void ^?{}(heap_allocator(T) *this);42 void ^?{}(heap_allocator(T)& this); 43 43 44 44 forall(otype T) … … 65 65 //Initialization 66 66 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 67 void ?{}(vector(T, allocator_t) *this);67 void ?{}(vector(T, allocator_t)& this); 68 68 69 69 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 70 void ?{}(vector(T, allocator_t) *this, vector(T, allocator_t) rhs);70 void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs); 71 71 72 72 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 73 vector(T, allocator_t) ?=?(vector(T, allocator_t) *this, vector(T, allocator_t) rhs);73 vector(T, allocator_t) ?=?(vector(T, allocator_t)& this, vector(T, allocator_t) rhs); 74 74 75 75 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 76 void ^?{}(vector(T, allocator_t) *this);76 void ^?{}(vector(T, allocator_t)& this); 77 77 78 78 forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t)) -
src/libcfa/containers/vector.c
r469f709 raca65621 24 24 //Initialization 25 25 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 26 void ?{}(vector(T, allocator_t) *this)26 void ?{}(vector(T, allocator_t)& this) 27 27 { 28 ( &this->storage){};29 this ->size = 0;28 (this.storage){}; 29 this.size = 0; 30 30 } 31 31 32 32 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 33 void ?{}(vector(T, allocator_t) *this, vector(T, allocator_t) rhs)33 void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs) 34 34 { 35 ( &this->storage){ rhs.storage };36 copy_internal( this, &rhs);35 (this.storage){ rhs.storage }; 36 copy_internal(&this, &rhs); 37 37 } 38 38 … … 46 46 47 47 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 48 void ^?{}(vector(T, allocator_t) *this)48 void ^?{}(vector(T, allocator_t)& this) 49 49 { 50 clear( this);51 ^( &this->storage){};50 clear(&this); 51 ^(this.storage){}; 52 52 } 53 53 … … 66 66 { 67 67 this->size--; 68 ^( &data(&this->storage)[this->size]){};68 ^(data(&this->storage)[this->size]){}; 69 69 } 70 70 … … 74 74 for(size_t i = 0; i < this->size; i++) 75 75 { 76 ^( &data(&this->storage)[this->size]){};76 ^(data(&this->storage)[this->size]){}; 77 77 } 78 78 this->size = 0; … … 87 87 this->size = other->size; 88 88 for(size_t i = 0; i < this->size; i++) { 89 ( &data(&this->storage)[this->size]){ data(&other->storage)[other->size] };89 (data(&this->storage)[this->size]){ data(&other->storage)[other->size] }; 90 90 } 91 91 } … … 94 94 //Allocator 95 95 forall(otype T) 96 void ?{}(heap_allocator(T) *this)96 void ?{}(heap_allocator(T)& this) 97 97 { 98 this ->storage = 0;99 this ->capacity = 0;98 this.storage = 0; 99 this.capacity = 0; 100 100 } 101 101 102 102 forall(otype T) 103 void ?{}(heap_allocator(T) *this, heap_allocator(T) rhs)103 void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs) 104 104 { 105 this ->capacity = rhs.capacity;106 this ->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));105 this.capacity = rhs.capacity; 106 this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T)); 107 107 } 108 108 109 109 forall(otype T) 110 heap_allocator(T) ?=?(heap_allocator(T) *this, heap_allocator(T) rhs)110 heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs) 111 111 { 112 this ->capacity = rhs.capacity;113 this ->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));114 return *this;112 this.capacity = rhs.capacity; 113 this.storage = (T*)realloc((void*)this.storage, this.capacity * sizeof(T)); 114 return this; 115 115 } 116 116 117 117 forall(otype T) 118 void ^?{}(heap_allocator(T) *this)118 void ^?{}(heap_allocator(T)& this) 119 119 { 120 free(this ->storage);120 free(this.storage); 121 121 } 122 122
Note:
See TracChangeset
for help on using the changeset viewer.