Ignore:
Timestamp:
Jan 19, 2021, 8:44:29 PM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
dafbde8
Parents:
2f47ea4
Message:

Converting the project to use the new syntax for otype, dtype and ttytpe.

Changed prelude (gen), libcfa and test suite to use it. Added a simple deprecation rule of the old syntax to the parser; we might wish to support both syntaxes "officially," like with an extra CLI switch, but this measure should serve as a simple reminder for our team to try the new syntax.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/memory.cfa

    r2f47ea4 rfd54fef  
    1818
    1919// Internal data object.
    20 forall(dtype T | sized(T), ttype Args | { void ?{}(T &, Args); })
     20forall(T & | sized(T), Args... | { void ?{}(T &, Args); })
    2121void ?{}(counter_data(T) & this, Args args) {
    2222        (this.counter){1};
     
    2424}
    2525
    26 forall(dtype T | sized(T) | { void ^?{}(T &); })
     26forall(T & | sized(T) | { void ^?{}(T &); })
    2727void ^?{}(counter_data(T) & this) {
    2828        assert(0 == this.counter);
     
    3131
    3232// This is one of many pointers keeping this alive.
    33 forall(dtype T | sized(T))
     33forall(T & | sized(T))
    3434void ?{}(counter_ptr(T) & this) {
    3535        this.data = 0p;
    3636}
    3737
    38 forall(dtype T | sized(T))
     38forall(T & | sized(T))
    3939void ?{}(counter_ptr(T) & this, zero_t) {
    4040        this.data = 0p;
    4141}
    4242
    43 forall(dtype T | sized(T) | { void ^?{}(T &); })
     43forall(T & | sized(T) | { void ^?{}(T &); })
    4444static void internal_decrement(counter_ptr(T) & this) {
    4545        if (this.data && 0 == --this.data->counter) {
     
    4848}
    4949
    50 forall(dtype T | sized(T))
     50forall(T & | sized(T))
    5151static void internal_copy(counter_ptr(T) & this, counter_ptr(T) & that) {
    5252        this.data = that.data;
     
    5656}
    5757
    58 forall(dtype T | sized(T) | { void ^?{}(T &); })
     58forall(T & | sized(T) | { void ^?{}(T &); })
    5959void ?{}(counter_ptr(T) & this, counter_ptr(T) that) {
    6060        // `that` is a copy but it should have neither a constructor
     
    6464}
    6565
    66 forall(dtype T | sized(T), ttype Args | { void ?{}(T&, Args); })
     66forall(T & | sized(T), Args... | { void ?{}(T&, Args); })
    6767void ?{}(counter_ptr(T) & this, Args args) {
    6868        this.data = (counter_data(T)*)new(args);
    6969}
    7070
    71 forall(dtype T | sized(T) | { void ^?{}(T &); })
     71forall(T & | sized(T) | { void ^?{}(T &); })
    7272void ^?{}(counter_ptr(T) & this) {
    7373        internal_decrement(this);
    7474}
    7575
    76 forall(dtype T | sized(T))
     76forall(T & | sized(T))
    7777T & *?(counter_ptr(T) & this) {
    7878        return *((this.data) ? &this.data->object : 0p);
    7979}
    8080
    81 forall(dtype T | sized(T) | { void ^?{}(T &); })
     81forall(T & | sized(T) | { void ^?{}(T &); })
    8282void ?=?(counter_ptr(T) & this, counter_ptr(T) that) {
    8383        if (this.data != that.data) {
     
    8787}
    8888
    89 forall(dtype T | sized(T) | { void ^?{}(T &); })
     89forall(T & | sized(T) | { void ^?{}(T &); })
    9090void ?=?(counter_ptr(T) & this, zero_t) {
    9191        internal_decrement(this);
     
    9393}
    9494
    95 forall(dtype T | sized(T))
     95forall(T & | sized(T))
    9696int ?==?(counter_ptr(T) const & this, counter_ptr(T) const & that) {
    9797        return this.data == that.data;
    9898}
    9999
    100 forall(dtype T | sized(T))
     100forall(T & | sized(T))
    101101int ?!=?(counter_ptr(T) const & this, counter_ptr(T) const & that) {
    102102        return !?==?(this, that);
    103103}
    104104
    105 forall(dtype T | sized(T))
     105forall(T & | sized(T))
    106106int ?==?(counter_ptr(T) const & this, zero_t) {
    107107        return this.data == 0;
    108108}
    109109
    110 forall(dtype T | sized(T))
     110forall(T & | sized(T))
    111111int ?!=?(counter_ptr(T) const & this, zero_t) {
    112112        return !?==?(this, (zero_t)0);
     
    114114
    115115// This is the only pointer that keeps this alive.
    116 forall(dtype T)
     116forall(T &)
    117117void ?{}(unique_ptr(T) & this) {
    118118        this.data = 0p;
    119119}
    120120
    121 forall(dtype T)
     121forall(T &)
    122122void ?{}(unique_ptr(T) & this, zero_t) {
    123123        this.data = 0p;
    124124}
    125125
    126 forall(dtype T | sized(T), ttype Args | { void ?{}(T &, Args); })
     126forall(T & | sized(T), Args... | { void ?{}(T &, Args); })
    127127void ?{}(unique_ptr(T) & this, Args args) {
    128128        this.data = (T *)new(args);
    129129}
    130130
    131 forall(dtype T | { void ^?{}(T &); })
     131forall(T & | { void ^?{}(T &); })
    132132void ^?{}(unique_ptr(T) & this) {
    133133        delete(this.data);
    134134}
    135135
    136 forall(dtype T)
     136forall(T &)
    137137T & *?(unique_ptr(T) & this) {
    138138        return *this.data;
    139139}
    140140
    141 forall(dtype T | { void ^?{}(T &); })
     141forall(T & | { void ^?{}(T &); })
    142142void ?=?(unique_ptr(T) & this, zero_t) {
    143143        delete(this.data);
     
    145145}
    146146
    147 forall(dtype T | { void ^?{}(T &); })
     147forall(T & | { void ^?{}(T &); })
    148148void move(unique_ptr(T) & this, unique_ptr(T) & that) {
    149149        delete(this.data);
     
    152152}
    153153
    154 forall(dtype T)
     154forall(T &)
    155155int ?==?(unique_ptr(T) const & this, unique_ptr(T) const & that) {
    156156        return this.data == that.data;
    157157}
    158158
    159 forall(dtype T)
     159forall(T &)
    160160int ?!=?(unique_ptr(T) const & this, unique_ptr(T) const & that) {
    161161        return !?==?(this, that);
    162162}
    163163
    164 forall(dtype T)
     164forall(T &)
    165165int ?==?(unique_ptr(T) const & this, zero_t) {
    166166        return this.data == 0;
    167167}
    168168
    169 forall(dtype T)
     169forall(T &)
    170170int ?!=?(unique_ptr(T) const & this, zero_t) {
    171171        return !?==?(this, (zero_t)0);
Note: See TracChangeset for help on using the changeset viewer.