Changeset d3e4d6c for src/libcfa/containers
- Timestamp:
- Aug 23, 2017, 6:22:07 PM (9 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, stuck-waitfor-destruct, with_gc
- Children:
- 87e08e24, cb811ac
- Parents:
- 9f07232 (diff), bd37119 (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. - Location:
- src/libcfa/containers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/maybe
r9f07232 rd3e4d6c 27 27 28 28 forall(otype T) 29 void ?{}(maybe(T) *this);29 void ?{}(maybe(T) & this); 30 30 31 31 forall(otype T) 32 void ?{}(maybe(T) *this, T value);32 void ?{}(maybe(T) & this, T value); 33 33 34 34 forall(otype T) 35 void ?{}(maybe(T) *this, maybe(T) other);35 void ?{}(maybe(T) & this, maybe(T) other); 36 36 37 37 forall(otype T) 38 void ^?{}(maybe(T) *this);38 void ^?{}(maybe(T) & this); 39 39 40 40 forall(otype T) 41 maybe(T) ?=?(maybe(T) *this, maybe(T) other);41 maybe(T) ?=?(maybe(T) & this, maybe(T) other); 42 42 43 43 forall(otype T) -
src/libcfa/containers/maybe.c
r9f07232 rd3e4d6c 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/result
r9f07232 rd3e4d6c 33 33 34 34 forall(otype T, otype E) 35 void ?{}(result(T, E) *this);35 void ?{}(result(T, E) & this); 36 36 37 37 forall(otype T, otype E) 38 void ?{}(result(T, E) *this, one_t, T value);38 void ?{}(result(T, E) & this, one_t, T value); 39 39 40 40 forall(otype T, otype E) 41 void ?{}(result(T, E) *this, zero_t, E error);41 void ?{}(result(T, E) & this, zero_t, E error); 42 42 43 43 forall(otype T, otype E) 44 void ?{}(result(T, E) *this, result(T, E) other);44 void ?{}(result(T, E) & this, result(T, E) other); 45 45 46 46 forall(otype T, otype E) 47 void ^?{}(result(T, E) *this);47 void ^?{}(result(T, E) & this); 48 48 49 49 forall(otype T, otype E) 50 result(T, E) ?=?(result(T, E) *this, result(T, E) other);50 result(T, E) ?=?(result(T, E) & this, result(T, E) other); 51 51 52 52 forall(otype T, otype E) -
src/libcfa/containers/result.c
r9f07232 rd3e4d6c 19 19 20 20 forall(otype T, otype E) 21 void ?{}(result(T, E) *this) {22 this ->has_value = false;23 ( &this->error){};21 void ?{}(result(T, E) & this) { 22 this.has_value = false; 23 (this.error){}; 24 24 } 25 25 26 26 forall(otype T, otype E) 27 void ?{}(result(T, E) *this, one_t, T value) {28 this ->has_value = true;29 ( &this->value){value};27 void ?{}(result(T, E) & this, one_t, T value) { 28 this.has_value = true; 29 (this.value){value}; 30 30 } 31 31 32 32 forall(otype T, otype E) 33 void ?{}(result(T, E) *this, zero_t, E error) {34 this ->has_value = false;35 ( &this->error){error};33 void ?{}(result(T, E) & this, zero_t, E error) { 34 this.has_value = false; 35 (this.error){error}; 36 36 } 37 37 38 38 forall(otype T, otype E) 39 void ?{}(result(T, E) *this, result(T, E) other) {40 this ->has_value = other.has_value;39 void ?{}(result(T, E) & this, result(T, E) other) { 40 this.has_value = other.has_value; 41 41 if (other.has_value) { 42 ( &this->value){other.value};42 (this.value){other.value}; 43 43 } else { 44 ( &this->error){other.error};44 (this.error){other.error}; 45 45 } 46 46 } 47 47 48 48 forall(otype T, otype E) 49 result(T, E) ?=?(result(T, E) *this, result(T, E) that) {50 if (this ->has_value & that.has_value) {51 this ->value = that.value;52 } else if (this ->has_value) {53 ^( &this->value){};54 this ->has_value = false;55 ( &this->error){that.error};49 result(T, E) ?=?(result(T, E) & this, result(T, E) that) { 50 if (this.has_value & that.has_value) { 51 this.value = that.value; 52 } else if (this.has_value) { 53 ^(this.value){}; 54 this.has_value = false; 55 (this.error){that.error}; 56 56 } else if (that.has_value) { 57 ^( &this->error){};58 this ->has_value = true;59 ( &this->value){that.value};57 ^(this.error){}; 58 this.has_value = true; 59 (this.value){that.value}; 60 60 } else { 61 this ->error = that.error;61 this.error = that.error; 62 62 } 63 63 } 64 64 65 65 forall(otype T, otype E) 66 void ^?{}(result(T, E) *this) {67 if (this ->has_value) {68 ^( &this->value){};66 void ^?{}(result(T, E) & this) { 67 if (this.has_value) { 68 ^(this.value){}; 69 69 } else { 70 ^( &this->error){};70 ^(this.error){}; 71 71 } 72 72 } … … 109 109 this->value = value; 110 110 } else { 111 ^( &this->error){};111 ^(this->error){}; 112 112 this->has_value = true; 113 ( &this->value){value};113 (this->value){value}; 114 114 } 115 115 } … … 118 118 void set_error(result(T, E) * this, E error) { 119 119 if (this->has_value) { 120 ^( &this->value){};120 ^(this->value){}; 121 121 this->has_value = false; 122 ( &this->error){error};122 (this->error){error}; 123 123 } else { 124 124 this->error = error; -
src/libcfa/containers/vector
r9f07232 rd3e4d6c 30 30 31 31 forall(otype T) 32 void ?{}(heap_allocator(T) *this);32 void ?{}(heap_allocator(T)& this); 33 33 34 34 forall(otype T) 35 void ?{}(heap_allocator(T) *this, heap_allocator(T) rhs);35 void ?{}(heap_allocator(T)& this, heap_allocator(T) rhs); 36 36 37 37 forall(otype T) 38 heap_allocator(T) ?=?(heap_allocator(T) *this, heap_allocator(T) rhs);38 heap_allocator(T) ?=?(heap_allocator(T)& this, heap_allocator(T) rhs); 39 39 40 40 forall(otype T) 41 void ^?{}(heap_allocator(T) *this);41 void ^?{}(heap_allocator(T)& this); 42 42 43 43 forall(otype T) … … 64 64 //Initialization 65 65 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 66 void ?{}(vector(T, allocator_t) *this);66 void ?{}(vector(T, allocator_t)& this); 67 67 68 68 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 69 void ?{}(vector(T, allocator_t) *this, vector(T, allocator_t) rhs);69 void ?{}(vector(T, allocator_t)& this, vector(T, allocator_t) rhs); 70 70 71 71 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 72 vector(T, allocator_t) ?=?(vector(T, allocator_t) *this, vector(T, allocator_t) rhs);72 vector(T, allocator_t) ?=?(vector(T, allocator_t)& this, vector(T, allocator_t) rhs); 73 73 74 74 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 75 void ^?{}(vector(T, allocator_t) *this);75 void ^?{}(vector(T, allocator_t)& this); 76 76 77 77 forall(otype T, otype allocator_t = heap_allocator(T) | allocator_c(T, allocator_t)) -
src/libcfa/containers/vector.c
r9f07232 rd3e4d6c 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.