Changeset 242a902 for src/libcfa/containers
- Timestamp:
- Jul 18, 2017, 4:35:52 PM (7 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:
- f19339e
- Parents:
- 795d450
- Location:
- src/libcfa/containers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/result
r795d450 r242a902 35 35 36 36 forall(otype T, otype E) 37 void ?{}(result(T, E) *this);37 void ?{}(result(T, E) & this); 38 38 39 39 forall(otype T, otype E) 40 void ?{}(result(T, E) *this, one_t, T value);40 void ?{}(result(T, E) & this, one_t, T value); 41 41 42 42 forall(otype T, otype E) 43 void ?{}(result(T, E) *this, zero_t, E error);43 void ?{}(result(T, E) & this, zero_t, E error); 44 44 45 45 forall(otype T, otype E) 46 void ?{}(result(T, E) *this, result(T, E) other);46 void ?{}(result(T, E) & this, result(T, E) other); 47 47 48 48 forall(otype T, otype E) 49 void ^?{}(result(T, E) *this);49 void ^?{}(result(T, E) & this); 50 50 51 51 forall(otype T, otype E) 52 result(T, E) ?=?(result(T, E) *this, result(T, E) other);52 result(T, E) ?=?(result(T, E) & this, result(T, E) other); 53 53 54 54 forall(otype T, otype E) -
src/libcfa/containers/result.c
r795d450 r242a902 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;
Note: See TracChangeset
for help on using the changeset viewer.