Changes in / [7f612112:1eeab94]


Ignore:
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/maybe

    r7f612112 r1eeab94  
    88//
    99// Author           : Andrew Beach
    10 // Created On       : Wed May 25 14:43:00 2017
     10// Created On       : Wed May 24 14:43:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 25 16:58:00 2017
     12// Last Modified On : Thr May 25 16:36:00 2017
    1313// Update Count     : 1
    1414//
     
    4141
    4242forall(otype T)
     43maybe(T) ?=?(maybe(T) * this, maybe(T) other);
     44
     45forall(otype T)
    4346bool ?!=?(maybe(T) this, zero_t);
    4447
     
    5558T get(maybe(T) * this);
    5659
     60forall(otype T)
     61void set(maybe(T) * this, T value);
     62
     63forall(otype T)
     64void set_none(maybe(T) * this);
     65
    5766#endif // MAYBE_H
  • src/libcfa/containers/maybe.c

    r7f612112 r1eeab94  
    88//
    99// Author           : Andrew Beach
    10 // Created On       : Wed May 25 15:40:00 2017
     10// Created On       : Wed May 24 15:40:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May 25 17:00:00 2017
     12// Last Modified On : Thr May 25 15:24:00 2017
    1313// Update Count     : 1
    1414//
     
    2626void ?{}(maybe(T) * this, T value) {
    2727        this->has_value = true;
    28         this->value = value;
     28        (&this->value){value};
    2929}
    3030
     
    3333        this->has_value = other.has_value;
    3434        if (other.has_value) {
    35                 this->value = other.value;
     35                (&this->value){other.value};
     36        }
     37}
     38
     39forall(otype T)
     40maybe(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};
    3649        }
    3750}
     
    4659forall(otype T)
    4760bool ?!=?(maybe(T) this, zero_t) {
    48         return !this.has_value;
     61        return this.has_value;
    4962}
    5063
     
    6982        return this->value;
    7083}
     84
     85forall(otype T)
     86void 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
     95forall(otype T)
     96void 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  
    88//
    99// Author           : Andrew Beach
    10 // Created On       : Wed May 25 14:45:00 2017
     10// Created On       : Wed May 24 14:45:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May 25 16:57:00 2017
     12// Last Modified On : Thr May 25 16:39:00 2017
    1313// Update Count     : 1
    1414//
     
    5050
    5151forall(otype T, otype E)
     52result(T, E) ?=?(result(T, E) * this, result(T, E) other);
     53
     54forall(otype T, otype E)
    5255bool ?!=?(result(T, E) this, zero_t);
    5356
     
    6770E get_error(result(T, E) * this);
    6871
     72forall(otype T, otype E)
     73void set(result(T, E) * this, T value);
     74
     75forall(otype T, otype E)
     76void set_error(result(T, E) * this, E error);
     77
    6978#endif // RESULT_H
  • src/libcfa/containers/result.c

    r7f612112 r1eeab94  
    88//
    99// Author           : Andrew Beach
    10 // Created On       : Wed May 25 15:40:00 2017
     10// Created On       : Wed May 24 15:40:00 2017
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May 25 17:02:00 2017
     12// Last Modified On : Thr May 25 15:27:00 2017
    1313// Update Count     : 1
    1414//
     
    2727void ?{}(result(T, E) * this, one_t, T value) {
    2828        this->has_value = true;
    29         this->value = value;
     29        (&this->value){value};
    3030}
    3131
     
    3333void ?{}(result(T, E) * this, zero_t, E error) {
    3434        this->has_value = false;
    35         this->error = error;
     35        (&this->error){error};
    3636}
    3737
     
    4040        this->has_value = other.has_value;
    4141        if (other.has_value) {
    42                 this->value = other.value;
     42                (&this->value){other.value};
    4343        } else {
    44                 this->error = other.error;
     44                (&this->error){other.error};
     45        }
     46}
     47
     48forall(otype T, otype E)
     49result(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;
    4562        }
    4663}
     
    86103        return this->error;
    87104}
     105
     106forall(otype T, otype E)
     107void 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
     117forall(otype T, otype E)
     118void 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
     1fmod:1 1 1 1 1 1
     2remainder:-1 -1 -1
     3remquo:7 0.0999999 7 0.1 7 0.0999999999999999999
     4div:7 0.0999999 7 0.1 7 0.0999999999999999999
     5fma:-2 -2 -2
     6fdim:2 2 2
     7nan:nan nan nan
     8exp:2.71828 2.71828182845905 2.71828182845904524 1.46869+2.28736i 1.46869393991589+2.28735528717884i 1.46869393991588516+2.28735528717884239i
     9exp2:2 2 2
     10expm1:1.71828 1.71828182845905 1.71828182845904524
     11log:0 0 0 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
     12log2:3 3 3
     13log10:2 2 2
     14log1p:0.693147 0.693147180559945 0.693147180559945309
     15ilogb:0 0 0
     16logb:3 3 3
     17sqrt:1 1 1 1.09868+0.45509i 1.09868411346781+0.455089860562227i 1.09868411346780997+0.455089860562227341i
     18cbrt:3 3 3
     19hypot:1.41421 1.4142135623731 1.41421356237309505
     20pow:1 1 1 0.273957+0.583701i 0.273957253830121+0.583700758758615i 0.273957253830121071+0.583700758758614628i
     21sin:0.841471 0.841470984807897 0.841470984807896507 1.29846+0.634964i 1.29845758141598+0.634963914784736i 1.29845758141597729+0.634963914784736108i
     22cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
     23tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
     24asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
     25acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
     26atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
     27atan2: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
     28cosh:1.54308 1.54308063481524 1.54308063481524378 0.83373+0.988898i 0.833730025131149+0.988897705762865i 0.833730025131149049+0.988897705762865096i
     29tanh:0.761594 0.761594155955765 0.761594155955764888 1.08392+0.271753i 1.08392332733869+0.271752585319512i 1.08392332733869454+0.271752585319511717i
     30acosh:0 0 0 1.06128+0.904557i 1.06127506190504+0.904556894302381i 1.06127506190503565+0.904556894302381364i
     31asinh:0.881374 0.881373587019543 0.881373587019543025 1.06128+0.666239i 1.06127506190504+0.666239432492515i 1.06127506190503565+0.666239432492515255i
     32atanh:inf inf inf 0.402359+1.01722i 0.402359478108525+1.01722196789785i 0.402359478108525094+1.01722196789785137i
     33erf:0.842701 0.842700792949715 0.842700792949714869
     34erfc:0.157299 0.157299207050285 0.157299207050285131
     35lgamma:1.79176 1.79175946922805 1.791759469228055
     36lgamma:1.79176 1 1.79175946922805 1 1.791759469228055 1
     37tgamma:6 6 6
     38floor:1 1 1
     39ceil:2 2 2
     40trunc:3 3 3
     41rint:2 2 2
     42rint:2 2 2
     43rint:2 2 2
     44lrint:2 2 2
     45llrint:2 2 2
     46nearbyint:4 4 4
     47round:2 2 2
     48round:2 2 2
     49round:2 2 2
     50lround:2 2 2
     51llround:2 2 2
     52copysign:-1 -1 -1
     53frexp:0.5 3 0.5 3 0.5 3
     54ldexp:8 8 8
     55modf:2 0.3 2 0.3 2 0.3 nextafter:2 2 2
     56nexttoward:2 2 2
     57scalbn:16 16 16
     58scalbln:16 16 16
  • tools/cfa.nanorc

    r7f612112 r1eeab94  
    1212color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto)\>"
    1313color green "\<(static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
    14 color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
     14color green "\<((s?size)|one|zero|((u_?)?int(8|16|32|64|ptr)))_t\>"
    1515
    1616# Declarations
     
    3939
    4040# Values
     41# Booleans
     42color blue "\<(true|false)\>"
    4143# Characters
    4244color brightmagenta "'([^'\]|(\\")|(\\['abfnrtv\\]))'"
Note: See TracChangeset for help on using the changeset viewer.