Ignore:
Timestamp:
Jan 19, 2021, 8:44:29 PM (9 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
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
  • tests/function-operator.cfa

    r2f47ea4 rfd54fef  
    2222
    2323// STL-like Algorithms
    24 trait Assignable(dtype T, dtype U) { T ?=?(T &, U); };
    25 trait Copyable(dtype T) { void ?{}(T &, T); };
    26 trait Destructable(dtype T) { void ^?{}(T &); };
     24trait Assignable(T &, U &) { T ?=?(T &, U); };
     25trait Copyable(T &) { void ?{}(T &, T); };
     26trait Destructable(T &) { void ^?{}(T &); };
    2727
    28 trait Iterator(dtype iter | sized(iter) | Copyable(iter) | Destructable(iter), otype T) {
     28trait Iterator(iter & | sized(iter) | Copyable(iter) | Destructable(iter), T) {
    2929        T & *?(iter);
    3030        iter ++?(iter &);
     
    3232};
    3333
    34 forall(otype Tin, dtype Input | Iterator(Input, Tin), otype Tout, dtype Output | Iterator(Output, Tout) | Assignable(Tout, Tin))
     34forall(Tin, Input & | Iterator(Input, Tin), Tout, Output & | Iterator(Output, Tout) | Assignable(Tout, Tin))
    3535Output copy(Input first, Input last, Output result) {
    3636        while (first != last) {
     
    4242
    4343// test ?()(T *, ...) -- ?() with function call-by-pointer
    44 forall(otype Tin, dtype Input | Iterator(Input, Tin), otype Tout, dtype Output | Iterator(Output, Tout), otype FuncRet, dtype Func | { FuncRet ?()(Func *, Tin); } | Assignable(Tout, FuncRet))
     44forall(Tin, Input & | Iterator(Input, Tin), Tout, Output & | Iterator(Output, Tout), FuncRet, Func & | { FuncRet ?()(Func *, Tin); } | Assignable(Tout, FuncRet))
    4545Output transform (Input first, Input last, Output result, Func * op) {
    4646        while (first != last) {
     
    5252
    5353// test ?()(T, ...) -- ?() with function call-by-value
    54 forall(dtype Iter, otype T | Iterator(Iter, T), otype Pred | { int ?()(Pred, T); })
     54forall(Iter &, T | Iterator(Iter, T), Pred | { int ?()(Pred, T); })
    5555Iter find_if (Iter first, Iter last, Pred pred) {
    5656        while (first != last) {
     
    6262
    6363// test ?()(T, ...) -- ?() with function call-by-reference
    64 forall(otype Generator, otype GenRet | { GenRet ?()(Generator &); }, dtype Iter, otype T | Iterator(Iter, T) | Assignable(T, GenRet))
     64forall(Generator, GenRet | { GenRet ?()(Generator &); }, Iter &, T | Iterator(Iter, T) | Assignable(T, GenRet))
    6565void generate(Iter first, Iter last, Generator & gen) {
    6666        int i = 0;
     
    108108}
    109109
    110 forall(otype T | { int ?==?(T, T); })
     110forall(T | { int ?==?(T, T); })
    111111struct Equals {
    112112        T val;
    113113};
    114114
    115 forall(otype T | { int ?==?(T, T); })
     115forall(T | { int ?==?(T, T); })
    116116int ?()(Equals(T) eq, T x) {
    117117        return eq.val == x;
    118118}
    119119
    120 forall(otype T | { T ?*?(T, T); })
     120forall(T | { T ?*?(T, T); })
    121121struct Multiply {
    122122        T val;
    123123};
    124124
    125 forall(otype T | { T ?*?(T, T); })
     125forall(T | { T ?*?(T, T); })
    126126T ?()(Multiply(T) * mult, T x) {
    127127        return mult->val * x;
     
    130130// TODO: generalize to ttype return; doesn't work yet
    131131// like std::function
    132 forall(otype Return, ttype Args)
     132forall(Return, Args...)
    133133struct function {
    134134        Return (*f)(Args);
Note: See TracChangeset for help on using the changeset viewer.