Changeset 1eeab94
- Timestamp:
- May 25, 2017, 3:39:02 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:
- 41634098, 8712514
- Parents:
- 7f612112 (diff), f851015 (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. - Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/containers/maybe
r7f612112 r1eeab94 8 8 // 9 9 // Author : Andrew Beach 10 // Created On : Wed May 2 514:43:00 201710 // Created On : Wed May 24 14:43:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Apr 25 16:58:00 201712 // Last Modified On : Thr May 25 16:36:00 2017 13 13 // Update Count : 1 14 14 // … … 41 41 42 42 forall(otype T) 43 maybe(T) ?=?(maybe(T) * this, maybe(T) other); 44 45 forall(otype T) 43 46 bool ?!=?(maybe(T) this, zero_t); 44 47 … … 55 58 T get(maybe(T) * this); 56 59 60 forall(otype T) 61 void set(maybe(T) * this, T value); 62 63 forall(otype T) 64 void set_none(maybe(T) * this); 65 57 66 #endif // MAYBE_H -
src/libcfa/containers/maybe.c
r7f612112 r1eeab94 8 8 // 9 9 // Author : Andrew Beach 10 // Created On : Wed May 2 515:40:00 201710 // Created On : Wed May 24 15:40:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 25 17:00:00 201712 // Last Modified On : Thr May 25 15:24:00 2017 13 13 // Update Count : 1 14 14 // … … 26 26 void ?{}(maybe(T) * this, T value) { 27 27 this->has_value = true; 28 this->value = value;28 (&this->value){value}; 29 29 } 30 30 … … 33 33 this->has_value = other.has_value; 34 34 if (other.has_value) { 35 this->value = other.value; 35 (&this->value){other.value}; 36 } 37 } 38 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; 46 } else if (that.has_value) { 47 this->has_value = true; 48 (&this->value){that.value}; 36 49 } 37 50 } … … 46 59 forall(otype T) 47 60 bool ?!=?(maybe(T) this, zero_t) { 48 return !this.has_value;61 return this.has_value; 49 62 } 50 63 … … 69 82 return this->value; 70 83 } 84 85 forall(otype T) 86 void set(maybe(T) * this, T value) { 87 if (this->has_value) { 88 this->value = value; 89 } else { 90 this->has_value = true; 91 (&this->value){value}; 92 } 93 } 94 95 forall(otype T) 96 void set_none(maybe(T) * this) { 97 if (this->has_value) { 98 this->has_value = false; 99 ^(&this->value){}; 100 } 101 } -
src/libcfa/containers/result
r7f612112 r1eeab94 8 8 // 9 9 // Author : Andrew Beach 10 // Created On : Wed May 2 514:45:00 201710 // Created On : Wed May 24 14:45:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 25 16:57:00 201712 // Last Modified On : Thr May 25 16:39:00 2017 13 13 // Update Count : 1 14 14 // … … 50 50 51 51 forall(otype T, otype E) 52 result(T, E) ?=?(result(T, E) * this, result(T, E) other); 53 54 forall(otype T, otype E) 52 55 bool ?!=?(result(T, E) this, zero_t); 53 56 … … 67 70 E get_error(result(T, E) * this); 68 71 72 forall(otype T, otype E) 73 void set(result(T, E) * this, T value); 74 75 forall(otype T, otype E) 76 void set_error(result(T, E) * this, E error); 77 69 78 #endif // RESULT_H -
src/libcfa/containers/result.c
r7f612112 r1eeab94 8 8 // 9 9 // Author : Andrew Beach 10 // Created On : Wed May 2 515:40:00 201710 // Created On : Wed May 24 15:40:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 25 17:02:00 201712 // Last Modified On : Thr May 25 15:27:00 2017 13 13 // Update Count : 1 14 14 // … … 27 27 void ?{}(result(T, E) * this, one_t, T value) { 28 28 this->has_value = true; 29 this->value = value;29 (&this->value){value}; 30 30 } 31 31 … … 33 33 void ?{}(result(T, E) * this, zero_t, E error) { 34 34 this->has_value = false; 35 this->error = error;35 (&this->error){error}; 36 36 } 37 37 … … 40 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 } 46 } 47 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}; 56 } else if (that.has_value) { 57 ^(&this->error){}; 58 this->has_value = true; 59 (&this->value){that.value}; 60 } else { 61 this->error = that.error; 45 62 } 46 63 } … … 86 103 return this->error; 87 104 } 105 106 forall(otype T, otype E) 107 void set(result(T, E) * this, T value) { 108 if (this->has_value) { 109 this->value = value; 110 } else { 111 ^(&this->error){}; 112 this->has_value = true; 113 (&this->value){value}; 114 } 115 } 116 117 forall(otype T, otype E) 118 void set_error(result(T, E) * this, E error) { 119 if (this->has_value) { 120 ^(&this->value){}; 121 this->has_value = false; 122 (&this->error){error}; 123 } else { 124 this->error = error; 125 } 126 } -
src/tests/.expect/32/math.txt
r7f612112 r1eeab94 1 fabs: 1 1 1 1.41421 1.41421356237309505 1.41421356237309505 2 fmod: 1 1 1 1 1 1 3 remainder: -1 -1 -1 4 remquo: 7 0.0999999 7 0.1 7 0.0999999999999999999 5 div: 7 0.0999999 7 0.1 7 0.0999999999999999999 6 fma: -2 -2 -2 7 fdim: 2 2 2 8 nan: nan nan nan 9 exp: 2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i 10 exp2: 2 2 2 11 expm1: 1.71828 1.71828182845905 1.71828182845904524 12 log: 0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i 13 log2: 3 3 3 14 log10: 2 2 2 15 log1p: 0.693147 0.693147180559945 0.693147180559945309 16 ilogb: 0 0 0 17 logb: 3 3 3 18 sqrt: 1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i 19 cbrt: 3 3 3 20 hypot: 1.41421 1.4142135623731 1.41421356237309505 21 pow: 1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i 22 sin: 0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i 23 cos: 0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i 24 tan: 1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i 25 asin: 1.5708 1.5707963267949 1.57079632679489662 0.66624+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i 26 acos: 0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i 27 atan: 0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i 28 atan2: 0.785398 0.785398163397448 0.78539816339744831 atan: 0.785398 0.785398163397448 0.78539816339744831 sinh: 1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i 29 cosh: 1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i 30 tanh: 0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i 31 acosh: 0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i 32 asinh: 0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i 33 atanh: inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i 34 erf: 0.842701 0.842700792949715 0.842700792949714869 35 erfc: 0.157299 0.157299207050285 0.157299207050285131 36 lgamma: 1.79176 1.79175946922805 1.791759469228055 37 lgamma: 1.79176 1 1.79175946922805 1 1.791759469228055 1 38 tgamma: 6 6 6 39 floor: 1 1 1 40 ceil: 2 2 2 41 trunc: 3 3 3 42 rint: 2 2 2 43 rint: 2 2 2 44 rint: 2 2 2 45 lrint: 2 2 2 46 llrint: 2 2 2 47 nearbyint: 4 4 4 48 round: 2 2 2 49 round: 2 2 2 50 round: 2 2 2 51 lround: 2 2 2 52 llround: 2 2 2 53 copysign: -1 -1 -1 54 frexp: 0.5 3 0.5 3 0.5 3 55 ldexp: 8 8 8 56 modf: 2 0.3 2 0.3 2 0.3 nextafter: 2 2 2 57 nexttoward: 2 2 2 58 scalbn: 16 16 16 59 scalbln: 16 16 16 1 fmod:1 1 1 1 1 1 2 remainder:-1 -1 -1 3 remquo:7 0.0999999 7 0.1 7 0.0999999999999999999 4 div:7 0.0999999 7 0.1 7 0.0999999999999999999 5 fma:-2 -2 -2 6 fdim:2 2 2 7 nan:nan nan nan 8 exp:2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i 9 exp2:2 2 2 10 expm1:1.71828 1.71828182845905 1.71828182845904524 11 log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i 12 log2:3 3 3 13 log10:2 2 2 14 log1p:0.693147 0.693147180559945 0.693147180559945309 15 ilogb:0 0 0 16 logb:3 3 3 17 sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i 18 cbrt:3 3 3 19 hypot:1.41421 1.4142135623731 1.41421356237309505 20 pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i 21 sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i 22 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i 23 tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i 24 asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i 25 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i 26 atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i 27 atan2:0.785398 0.785398163397448 0.78539816339744831 atan:0.785398 0.785398163397448 0.78539816339744831 sinh:1.1752 1.1752011936438 1.17520119364380146 0.634964+1.29846i 0.634963914784736+1.29845758141598i 0.634963914784736108+1.29845758141597729i 28 cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i 29 tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i 30 acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i 31 asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i 32 atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i 33 erf:0.842701 0.842700792949715 0.842700792949714869 34 erfc:0.157299 0.157299207050285 0.157299207050285131 35 lgamma:1.79176 1.79175946922805 1.791759469228055 36 lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1 37 tgamma:6 6 6 38 floor:1 1 1 39 ceil:2 2 2 40 trunc:3 3 3 41 rint:2 2 2 42 rint:2 2 2 43 rint:2 2 2 44 lrint:2 2 2 45 llrint:2 2 2 46 nearbyint:4 4 4 47 round:2 2 2 48 round:2 2 2 49 round:2 2 2 50 lround:2 2 2 51 llround:2 2 2 52 copysign:-1 -1 -1 53 frexp:0.5 3 0.5 3 0.5 3 54 ldexp:8 8 8 55 modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2 56 nexttoward:2 2 2 57 scalbn:16 16 16 58 scalbln:16 16 16 -
tools/cfa.nanorc
r7f612112 r1eeab94 12 12 color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto)\>" 13 13 color green "\<(static|const|struct|union|typedef|extern|(un)?signed|inline)\>" 14 color green "\<((s?size)| ((u_?)?int(8|16|32|64|ptr)))_t\>"14 color green "\<((s?size)|one|zero|((u_?)?int(8|16|32|64|ptr)))_t\>" 15 15 16 16 # Declarations … … 39 39 40 40 # Values 41 # Booleans 42 color blue "\<(true|false)\>" 41 43 # Characters 42 44 color brightmagenta "'([^'\]|(\\")|(\\['abfnrtv\\]))'"
Note: See TracChangeset
for help on using the changeset viewer.