Ignore:
Timestamp:
Jul 12, 2017, 4:40:02 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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
Message:

Convert several library files to use references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/containers/maybe.c

    r469f709 raca65621  
    1919
    2020forall(otype T)
    21 void ?{}(maybe(T) * this) {
    22         this->has_value = false;
     21void ?{}(maybe(T) & this) {
     22        this.has_value = false;
    2323}
    2424
    2525forall(otype T)
    26 void ?{}(maybe(T) * this, T value) {
    27         this->has_value = true;
    28         (&this->value){value};
     26void ?{}(maybe(T) & this, T value) {
     27        this.has_value = true;
     28        (this.value){value};
    2929}
    3030
    3131forall(otype T)
    32 void ?{}(maybe(T) * this, maybe(T) other) {
    33         this->has_value = other.has_value;
     32void ?{}(maybe(T) & this, maybe(T) other) {
     33        this.has_value = other.has_value;
    3434        if (other.has_value) {
    35                 (&this->value){other.value};
     35                (this.value){other.value};
    3636        }
    3737}
    3838
    3939forall(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;
     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;
    4646        } 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};
    4949        }
     50        return this;
    5051}
    5152
    5253forall(otype T)
    53 void ^?{}(maybe(T) * this) {
    54         if (this->has_value) {
    55                 ^(&this->value){};
     54void ^?{}(maybe(T) & this) {
     55        if (this.has_value) {
     56                ^(this.value){};
    5657        }
    5758}
     
    8990        } else {
    9091                this->has_value = true;
    91                 (&this->value){value};
     92                (this->value){value};
    9293        }
    9394}
     
    9798        if (this->has_value) {
    9899                this->has_value = false;
    99                 ^(&this->value){};
     100                ^(this->value){};
    100101        }
    101102}
Note: See TracChangeset for help on using the changeset viewer.