Changeset fd54fef for tests


Ignore:
Timestamp:
Jan 19, 2021, 8:44:29 PM (2 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
arm-eh, 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.

Location:
tests
Files:
81 edited

Legend:

Unmodified
Added
Removed
  • tests/avltree/avl-private.cfa

    r2f47ea4 rfd54fef  
    1111// an AVL tree's height is easy to compute
    1212// just follow path with the larger balance
    13 forall(otype K | Comparable(K), otype V)
     13forall(K | Comparable(K), V)
    1414int height(tree(K, V) * t){
    1515  int helper(tree(K, V) * t, int ht){
     
    2727}
    2828
    29 forall(otype K | Comparable(K), otype V)
     29forall(K | Comparable(K), V)
    3030int calcBalance(tree(K, V) * t){
    3131  int l = height(t->left);
     
    3636
    3737// re-establish the link between parent and child
    38 forall(otype K | Comparable(K), otype V)
     38forall(K | Comparable(K), V)
    3939void relinkToParent(tree(K, V) * t){
    4040  tree(K, V) * parent = t->parent; // FIX ME!!
     
    4949
    5050// rotate left from t
    51 forall(otype K | Comparable(K), otype V)
     51forall(K | Comparable(K), V)
    5252tree(K, V) * rotateLeft(tree(K, V) * t){
    5353  tree(K, V) * newRoot = t->right;
     
    6868
    6969// rotate right from t
    70 forall(otype K | Comparable(K), otype V)
     70forall(K | Comparable(K), V)
    7171tree(K, V) * rotateRight(tree(K, V) * t){
    7272  tree(K, V) * newRoot = t->left;
     
    8787
    8888// balances a node that has balance factor -2 or 2
    89 forall(otype K | Comparable(K), otype V)
     89forall(K | Comparable(K), V)
    9090tree(K, V) * fix(tree(K, V) * t){
    9191  // ensure that t's balance factor is one of
     
    113113
    114114// attempt to fix the tree, if necessary
    115 forall(otype K | Comparable(K), otype V)
     115forall(K | Comparable(K), V)
    116116tree(K, V) * tryFix(tree(K, V) * t){
    117117  int b = calcBalance(t);
     
    126126
    127127// sets parent field of c to be p
    128 forall(otype K | Comparable(K), otype V)
     128forall(K | Comparable(K), V)
    129129void setParent(tree(K, V) * c, tree(K, V) * p){
    130130  if (! empty(c)){
  • tests/avltree/avl-private.h

    r2f47ea4 rfd54fef  
    55
    66// attempt to fix the tree, if necessary
    7 forall(otype K | Comparable(K), otype V)
     7forall(K | Comparable(K), V)
    88tree(K, V) * tryFix(tree(K, V) * t);
    99
    1010// sets parent field of c to be p
    11 forall(otype K | Comparable(K), otype V)
     11forall(K | Comparable(K), V)
    1212void setParent(tree(K, V) * c, tree(K, V) * p);
    1313
    14 forall(otype K | Comparable(K), otype V)
     14forall(K | Comparable(K), V)
    1515int height(tree(K, V) * t);
  • tests/avltree/avl.h

    r2f47ea4 rfd54fef  
    99// #include <lib.h>
    1010
    11 trait Comparable(otype T) {
     11trait Comparable(T) {
    1212  int ?<?(T, T);
    1313};
    1414
    15 forall(otype T | Comparable(T))
     15forall(T | Comparable(T))
    1616int ?==?(T t1, T t2);
    1717
    18 forall(otype T | Comparable(T))
     18forall(T | Comparable(T))
    1919int ?>?(T t1, T t2);
    2020
     
    4141
    4242// temporary: need forward decl to get around typedef problem
    43 forall(otype K | Comparable(K), otype V)
     43forall(K | Comparable(K), V)
    4444struct tree;
    4545
    46 forall(otype K | Comparable(K), otype V)
     46forall(K | Comparable(K), V)
    4747struct tree {
    4848  K key;
     
    5454};
    5555
    56 forall(otype K | Comparable(K), otype V)
     56forall(K | Comparable(K), V)
    5757void ?{}(tree(K, V) &t, K key, V value);
    5858
    59 forall(otype K | Comparable(K), otype V)
     59forall(K | Comparable(K), V)
    6060void ^?{}(tree(K, V) & t);
    6161
    62 forall(otype K | Comparable(K), otype V)
     62forall(K | Comparable(K), V)
    6363tree(K, V) * create(K key, V value);
    6464
    65 forall(otype K | Comparable(K), otype V)
     65forall(K | Comparable(K), V)
    6666V * find(tree(K, V) * t, K key);
    6767
    68 forall(otype K | Comparable(K), otype V)
     68forall(K | Comparable(K), V)
    6969int empty(tree(K, V) * t);
    7070
    7171// returns the root of the tree
    72 forall(otype K | Comparable(K), otype V)
     72forall(K | Comparable(K), V)
    7373int insert(tree(K, V) ** t, K key, V value);
    7474
    75 forall(otype K | Comparable(K), otype V)
     75forall(K | Comparable(K), V)
    7676int remove(tree(K, V) ** t, K key);
    7777
    78 forall(otype K | Comparable(K), otype V)
     78forall(K | Comparable(K), V)
    7979void copy(tree(K, V) * src, tree(K, V) ** ret);
    8080
    81 forall(otype K | Comparable(K), otype V)
     81forall(K | Comparable(K), V)
    8282void for_each(tree(K, V) * t, void (*func)(V));
    8383
  • tests/avltree/avl0.cfa

    r2f47ea4 rfd54fef  
    11#include "avl.h"
    22
    3 forall(otype T | Comparable(T))
     3forall(T | Comparable(T))
    44int ?==?(T t1, T t2) {
    55  return !(t1 < t2) && !(t2 < t1);
    66}
    77
    8 forall(otype T | Comparable(T))
     8forall(T | Comparable(T))
    99int ?>?(T t1, T t2) {
    1010  return t2 < t1;
  • tests/avltree/avl1.cfa

    r2f47ea4 rfd54fef  
    33#include <stdlib.hfa>
    44
    5 forall(otype K | Comparable(K), otype V)
     5forall(K | Comparable(K), V)
    66void ?{}(tree(K, V) &t, K key, V value){
    77  (t.key) { key };
     
    1313}
    1414
    15 forall(otype K| Comparable(K), otype V)
     15forall(K| Comparable(K), V)
    1616void ^?{}(tree(K, V) & t){
    1717  delete(t.left);
     
    2121}
    2222
    23 forall(otype K | Comparable(K), otype V)
     23forall(K | Comparable(K), V)
    2424tree(K, V) * create(K key, V value) {
    2525  // infinite loop trying to resolve ... t = malloc();
  • tests/avltree/avl2.cfa

    r2f47ea4 rfd54fef  
    22#include "avl-private.h"
    33
    4 forall(otype K | Comparable(K), otype V)
     4forall(K | Comparable(K), V)
    55V * find(tree(K, V) * t, K key){
    66  if (empty(t)){
     
    1818}
    1919
    20 forall(otype K | Comparable(K), otype V)
     20forall(K | Comparable(K), V)
    2121int empty(tree(K, V) * t){
    2222  return t == NULL;
     
    2424
    2525// returns the root of the tree
    26 forall(otype K | Comparable(K), otype V)
     26forall(K | Comparable(K), V)
    2727int insert(tree(K, V) ** t, K key, V value) {
    2828  // handles a non-empty tree
  • tests/avltree/avl3.cfa

    r2f47ea4 rfd54fef  
    44
    55// swaps the data within two tree nodes
    6 forall(otype K | Comparable(K), otype V)
     6forall(K | Comparable(K), V)
    77void node_swap(tree(K, V) * t, tree(K, V) * t2){
    88        swap( t->key,  t2->key);
     
    1111
    1212// go left as deep as possible from within the right subtree
    13 forall(otype K | Comparable(K), otype V)
     13forall(K | Comparable(K), V)
    1414tree(K, V) * find_successor(tree(K, V) * t){
    1515        tree(K, V) * find_successor_helper(tree(K, V) * t){
     
    2525
    2626// cleanup - don't want to deep delete, so set children to NULL first.
    27 forall(otype K | Comparable(K), otype V)
     27forall(K | Comparable(K), V)
    2828void deleteSingleNode(tree(K, V) * t) {
    2929        t->left = NULL;
     
    3333
    3434// does the actual remove operation once we've found the node in question
    35 forall(otype K | Comparable(K), otype V)
     35forall(K | Comparable(K), V)
    3636tree(K, V) * remove_node(tree(K, V) * t){
    3737        // is the node a leaf?
     
    8585
    8686// finds the node that needs to be removed
    87 forall(otype K | Comparable(K), otype V)
     87forall(K | Comparable(K), V)
    8888tree(K, V) * remove_helper(tree(K, V) * t, K key, int * worked){
    8989        if (empty(t)){
     
    106106}
    107107
    108 forall(otype K | Comparable(K), otype V)
     108forall(K | Comparable(K), V)
    109109int remove(tree(K, V) ** t, K key){
    110110        int worked = 0;
  • tests/avltree/avl4.cfa

    r2f47ea4 rfd54fef  
    44// Perform a shallow copy of src, return the
    55// new tree in ret
    6 forall(otype K | Comparable(K), otype V)
     6forall(K | Comparable(K), V)
    77int copy(tree(K, V) * src, tree(K, V) ** ret){
    88  tree(K, V) * helper(tree(K, V) * t, int * worked){
     
    3535
    3636// Apply func to every value element in t, using an in order traversal
    37 forall(otype K | Comparable(K), otype V)
     37forall(K | Comparable(K), V)
    3838void for_each(tree(K, V) * t, int (*func)(V)) {
    3939  if (t == NULL) {
  • tests/bugs/10.cfa

    r2f47ea4 rfd54fef  
    22// https://cforall.uwaterloo.ca/trac/ticket/10
    33
    4 forall(otype T)
     4forall(T)
    55struct result {
    66      union {
  • tests/bugs/104.cfa

    r2f47ea4 rfd54fef  
    44[ float, float ] modf_( float x );
    55
    6 forall(otype T | { [T, T] modf_(T); })
     6forall(T | { [T, T] modf_(T); })
    77void modf(T);
    88
  • tests/bugs/194.cfa

    r2f47ea4 rfd54fef  
    22// https://cforall.uwaterloo.ca/trac/ticket/194
    33
    4 forall( dtype T | sized(T) ) T * foo( void ) {
     4forall( T & | sized(T) ) T * foo( void ) {
    55      printf( "foo1\n" );
    66        return (T *)0;
    77}
    8 forall( dtype T | sized(T) ) T & foo( void ) {
     8forall( T & | sized(T) ) T & foo( void ) {
    99        printf( "foo2\n" );
    1010        return (T &)*(T *)0;
  • tests/bugs/196.cfa

    r2f47ea4 rfd54fef  
    22// https://cforall.uwaterloo.ca/trac/ticket/196
    33
    4 forall(dtype T)
     4forall(T &)
    55struct link;
    66
    7 forall(dtype T)
     7forall(T &)
    88struct link {
    99        link(T) * next;
     
    1212// -----
    1313
    14 forall(dtype T)
     14forall(T &)
    1515struct foo;
    1616
    17 forall(dtype U)
     17forall(U &)
    1818struct bar {
    1919        foo(U) * data;
    2020};
    2121
    22 forall(dtype T)
     22forall(T &)
    2323struct foo {};
    2424
  • tests/bugs/203-2.cfa

    r2f47ea4 rfd54fef  
    11// Trac ticket: https://cforall.uwaterloo.ca/trac/ticket/203
    22
    3 forall(dtype A)
     3forall(A &)
    44struct empty {
    55        // Nothing.
    66};
    77
    8 forall(dtype C)
     8forall(C &)
    99struct wrap_e {
    1010        empty(C) field;
  • tests/bugs/203-7.cfa

    r2f47ea4 rfd54fef  
    11// Trac ticket: https://cforall.uwaterloo.ca/trac/ticket/203
    22
    3 forall(dtype A)
     3forall(A &)
    44struct empty {
    55        // Nothing.
    66};
    77
    8 forall(dtype C)
     8forall(C &)
    99struct wrap_e {
    1010        empty(C) field;
  • tests/bugs/203-9.cfa

    r2f47ea4 rfd54fef  
    11// Trac ticket: https://cforall.uwaterloo.ca/trac/ticket/203
    22
    3 forall(dtype A)
     3forall(A &)
    44struct empty {
    55        // Nothing.
    66};
    77
    8 forall(dtype C)
     8forall(C &)
    99struct wrap_e {
    1010        empty(C) field;
  • tests/bugs/7.cfa

    r2f47ea4 rfd54fef  
    88
    99// (Bug 1 unresolved as of this test.)
    10 forall(otype T)
     10forall(T)
    1111struct stack_node;
    1212
    13 forall(otype T)
     13forall(T)
    1414struct stack_node {
    1515    stack_node(T) * next;
     
    1717};
    1818
    19 forall(otype T)
     19forall(T)
    2020struct stack {
    2121    stack_node(T) * head;
    2222};
    2323
    24 trait stack_errors(otype T) {
     24trait stack_errors(T) {
    2525    T emptyStackHandler (stack(T) * this);
    2626};
    2727
    28 forall(otype T | stack_errors(T))
     28forall(T | stack_errors(T))
    2929T pop (stack(T) * this) {
    3030    return (T){};
  • tests/castError.cfa

    r2f47ea4 rfd54fef  
    1414//
    1515
    16 forall(otype T) struct S { T p; };
     16forall(T) struct S { T p; };
    1717int f;
    1818S(int) sint;
  • tests/concurrent/examples/boundedBufferEXT.cfa

    r2f47ea4 rfd54fef  
    2424enum { BufferSize = 50 };
    2525
    26 forall( otype T ) {
     26forall( T ) {
    2727        monitor Buffer {
    2828                int front, back, count;
  • tests/concurrent/examples/boundedBufferINT.cfa

    r2f47ea4 rfd54fef  
    2424enum { BufferSize = 50 };
    2525
    26 forall( otype T ) {
     26forall( T ) {
    2727        monitor Buffer {
    2828                condition full, empty;
  • tests/concurrent/examples/quickSort.generic.cfa

    r2f47ea4 rfd54fef  
    2121#include <string.h>                                                                             // strcmp
    2222
    23 forall( otype T | { int ?<?( T, T ); } ) {
     23forall( T | { int ?<?( T, T ); } ) {
    2424        thread Quicksort {
    2525                T * values;                                                                             // communication variables
  • tests/concurrent/multi-monitor.cfa

    r2f47ea4 rfd54fef  
    3838}
    3939
    40 forall(dtype T | sized(T) | { void ^?{}(T & mutex); })
     40forall(T & | sized(T) | { void ^?{}(T & mutex); })
    4141void delete_mutex(T * x) {
    4242        ^(*x){};
  • tests/errors/completeType.cfa

    r2f47ea4 rfd54fef  
    11void foo(int *) {}
    22void bar(void *) {}
    3 forall(otype T) void baz(T *);
    4 forall(dtype T) void qux(T *);
    5 forall(dtype T | sized(T)) void quux(T *);
     3forall(T) void baz(T *);
     4forall(T &) void qux(T *);
     5forall(T & | sized(T)) void quux(T *);
    66
    77struct A;       // incomplete
     
    3939
    4040
    41 forall(otype T)
     41forall(T)
    4242void baz(T * x) {
    4343        // okay
     
    4949}
    5050
    51 forall(dtype T)
     51forall(T &)
    5252void qux(T * y) {
    5353        // okay
     
    6161}
    6262
    63 forall(dtype T | sized(T))
     63forall(T & | sized(T))
    6464void quux(T * z) {
    6565        // okay
  • tests/exceptions/defaults.cfa

    r2f47ea4 rfd54fef  
    5555
    5656void unhandled_test(void) {
    57         forall(dtype T, dtype V | is_exception(T, V))
     57        forall(T &, V & | is_exception(T, V))
    5858        void defaultTerminationHandler(T &) {
    5959                throw (unhandled_exception){};
  • tests/exceptions/polymorphic.cfa

    r2f47ea4 rfd54fef  
    33#include <exception.hfa>
    44
    5 FORALL_TRIVIAL_EXCEPTION(proxy, (otype T), (T));
    6 FORALL_TRIVIAL_INSTANCE(proxy, (otype U), (U))
     5FORALL_TRIVIAL_EXCEPTION(proxy, (T), (T));
     6FORALL_TRIVIAL_INSTANCE(proxy, (U), (U))
    77
    88const char * msg(proxy(int) * this) { return "proxy(int)"; }
     
    3333}
    3434
    35 FORALL_DATA_EXCEPTION(cell, (otype T), (T))(
     35FORALL_DATA_EXCEPTION(cell, (T), (T))(
    3636        T data;
    3737);
    3838
    39 FORALL_DATA_INSTANCE(cell, (otype T), (T))
     39FORALL_DATA_INSTANCE(cell, (T), (T))
    4040
    4141const char * msg(cell(int) * this) { return "cell(int)"; }
  • tests/exceptions/virtual-poly.cfa

    r2f47ea4 rfd54fef  
    1616};
    1717
    18 forall(otype T)
     18forall(T)
    1919struct mono_child_vtable {
    2020        mono_base_vtable const * const parent;
    2121};
    2222
    23 forall(otype T)
     23forall(T)
    2424struct mono_child {
    2525        mono_child_vtable(T) const * virtual_table;
     
    3737}
    3838
    39 forall(otype U)
     39forall(U)
    4040struct poly_base_vtable {
    4141        poly_base_vtable(U) const * const parent;
    4242};
    4343
    44 forall(otype U)
     44forall(U)
    4545struct poly_base {
    4646        poly_base_vtable(U) const * virtual_table;
    4747};
    4848
    49 forall(otype V)
     49forall(V)
    5050struct poly_child_vtable {
    5151        poly_base_vtable(V) const * const parent;
    5252};
    5353
    54 forall(otype V)
     54forall(V)
    5555struct poly_child {
    5656        poly_child_vtable(V) const * virtual_table;
  • tests/forall.cfa

    r2f47ea4 rfd54fef  
    1515
    1616void g1() {
    17         forall( otype T ) T f( T ) {};
     17        forall( T ) T f( T ) {};
    1818        void f( int ) {};
    1919        void h( void (*p)(void) ) {};
     
    3232
    3333void g2() {
    34         forall( otype T ) void f( T, T ) {}
    35         forall( otype T, otype U ) void f( T, U ) {}
     34        forall( T ) void f( T, T ) {}
     35        forall( T, U ) void f( T, U ) {}
    3636
    3737        int x;
     
    4545}
    4646
    47 typedef forall ( otype T ) int (* f)( int );
    48 
    49 forall( otype T )
     47typedef forall ( T ) int (* f)( int );
     48
     49forall( T )
    5050void swap( T left, T right ) {
    5151        T temp = left;
     
    5454}
    5555
    56 trait sumable( otype T ) {
     56trait sumable( T ) {
    5757        void ?{}( T &, zero_t );                                                        // 0 literal constructor
    5858        T ?+?( T, T );                                                                          // assortment of additions
     
    6262}; // sumable
    6363
    64 forall( otype T | sumable( T ) )                                                // use trait
     64forall( T | sumable( T ) )                                              // use trait
    6565T sum( size_t size, T a[] ) {
    6666        T total = 0;                                                                            // initialize by 0 constructor
     
    7070} // sum
    7171
    72 forall( otype T | { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &,T ); } )
     72forall( T | { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &,T ); } )
    7373T twice( T t ) {
    7474        return t + t;
    7575}
    7676
    77 forall( otype T | { int ?<?(T, T); } )
     77forall( T | { int ?<?(T, T); } )
    7878T min( T t1, T t2 ) {
    7979        return t1 < t2 ? t1 : t2;
     
    9191
    9292// Multiple forall
    93 forall( otype T ) forall( otype S ) struct { int i; };
    94 forall( otype T ) struct { int i; } forall( otype S );
    95 struct { int i; } forall( otype T ) forall( otype S );
    96 forall( otype W ) struct { int i; } forall( otype T ) forall( otype S );
     93forall( T ) forall( S ) struct { int i; };
     94forall( T ) struct { int i; } forall( S );
     95struct { int i; } forall( T ) forall( S );
     96forall( W ) struct { int i; } forall( T ) forall( S );
    9797
    9898// Distribution
    9999struct P { int i; };
    100 forall( otype T ) struct Q { T i; };
    101 forall( otype T ) struct { int i; };
     100forall( T ) struct Q { T i; };
     101forall( T ) struct { int i; };
    102102struct KK { int i; };
    103103inline static {
    104104        void RT1() {}
    105105}
    106 forall( otype T ) {
     106forall( T ) {
    107107        T RT2( T ) {
    108108                typedef int TD1;
    109109                struct S1 { T t; };
    110110        }
    111         forall( otype X ) {
     111        forall( X ) {
    112112                typedef int TD2;
    113113                struct S2 {};
     
    117117        }
    118118        extern "C" {
    119                 forall( otype W ) {
     119                forall( W ) {
    120120                        W RT3( W ) {}
    121121                        struct S3 {};
     
    123123        }
    124124        void RT4() {
    125                 forall( otype W ) struct S4 {};
     125                forall( W ) struct S4 {};
    126126                typedef int TD3;
    127127        }
     
    147147
    148148static inline {
    149         forall( otype T ) {
     149        forall( T ) {
    150150                int RT6( T p );
    151151        }
    152         forall( otype T, otype U ) {
     152        forall( T, U ) {
    153153                int RT7( T, U );
    154154        }
    155155}
    156 static forall( otype T ) {
     156static forall( T ) {
    157157        int RT8( T );
    158158}
    159 forall( otype T ) inline static {
     159forall( T ) inline static {
    160160        int RT9( T ) { T t; return 3; }
    161161}
    162162
    163 forall( otype T | { T ?+?( T, T ); } ) {
    164         forall( otype S | { T ?+?( T, S ); } ) {
    165                 forall( otype W ) T bar( T t, S s ) { return t + s; }
    166                 forall( otype W | { W ?+?( T, W ); } ) W baz( T t, S s, W w ) { return t + s + w; }
     163forall( T | { T ?+?( T, T ); } ) {
     164        forall( S | { T ?+?( T, S ); } ) {
     165                forall( W ) T bar( T t, S s ) { return t + s; }
     166                forall( W | { W ?+?( T, W ); } ) W baz( T t, S s, W w ) { return t + s + w; }
    167167                struct W { T t; } (int,int) ww;
    168168                struct P pp;
     
    170170}
    171171
    172 forall( otype T | { T ?+?( T, T ); } ) forall( otype S | { T ?+?( T, S ); } )
     172forall( T | { T ?+?( T, T ); } ) forall( S | { T ?+?( T, S ); } )
    173173struct XW { T t; };
    174174XW(int,int) xww;
    175175
    176 forall( otype T ) struct S { T t; } (int) x, y, z;
    177 forall( otype T ) struct { T t; } (int) a, b, c;
    178 
    179 forall( otype T ) static forall( otype S ) {
    180     forall( otype X ) struct U {
     176forall( T ) struct S { T t; } (int) x, y, z;
     177forall( T ) struct { T t; } (int) a, b, c;
     178
     179forall( T ) static forall( S ) {
     180    forall( X ) struct U {
    181181                T x;
    182182    };
    183183}
    184184
    185 forall( otype T ) {
     185forall( T ) {
    186186        extern "C" {
    187187                struct SS { T t; };
  • 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);
  • tests/genericUnion.cfa

    r2f47ea4 rfd54fef  
    1616#include <limits.hfa>
    1717
    18 forall(otype T)
     18forall(T)
    1919union ByteView {
    2020        T val;
     
    2222};
    2323
    24 forall(otype T)
     24forall(T)
    2525void print(ByteView(T) x) {
    2626        for (int i = 0; i < sizeof(int); i++) {                         // want to change to sizeof(T)
     
    2929}
    3030
    31 forall(otype T)
     31forall(T)
    3232void f(ByteView(T) x, T val) {
    3333        print(x);
  • tests/global-monomorph.cfa

    r2f47ea4 rfd54fef  
    11// Create monomorphic instances of polymorphic types at global scope.
    22
    3 forall(dtype T)
     3forall(T &)
    44void poly0(T &) {}
    55
    6 forall(dtype T | sized(T))
     6forall(T & | sized(T))
    77void poly1(T &) {}
    88
    9 forall(otype T)
     9forall(T)
    1010void poly2(T &) {}
    1111
  • tests/identity.cfa

    r2f47ea4 rfd54fef  
    1616#include <fstream.hfa>
    1717
    18 forall( otype T )
     18forall( T )
    1919T identity( T t ) {
    2020        return t;
  • tests/init1.cfa

    r2f47ea4 rfd54fef  
    120120}
    121121
    122 forall (dtype T, dtype S)
     122forall (T &, S &)
    123123T & anycvt( S & s ) {
    124124    return s;               // mismatched referenced type
    125125}
    126126
    127 forall (dtype T, dtype S)
     127forall (T &, S &)
    128128T * anycvt( S * s ) {
    129129    return s;               // mismatched referenced type
  • tests/nested-types.cfa

    r2f47ea4 rfd54fef  
    1616typedef int N;
    1717struct A {
    18         forall(otype T)
     18        forall(T)
    1919        struct N {
    2020                T x;
  • tests/poly-d-cycle.cfa

    r2f47ea4 rfd54fef  
    11// Check that a cycle of polymorphic dtype structures can be instancated.
    22
    3 forall(dtype T)
     3forall(T &)
    44struct func_table;
    55
    6 forall(dtype U)
     6forall(U &)
    77struct object {
    88        func_table(U) * virtual_table;
    99};
    1010
    11 forall(dtype T)
     11forall(T &)
    1212struct func_table {
    1313        void (*object_func)(object(T) *);
  • tests/poly-o-cycle.cfa

    r2f47ea4 rfd54fef  
    11// Check that a cycle of polymorphic otype structures can be instancated.
    22
    3 forall(otype T)
     3forall(T)
    44struct func_table;
    55
    6 forall(otype U)
     6forall(U)
    77struct object {
    88        func_table(U) * virtual_table;
    99};
    1010
    11 forall(otype T)
     11forall(T)
    1212struct func_table {
    1313        void (*object_func)(object(T) *);
  • tests/poly-selection.cfa

    r2f47ea4 rfd54fef  
    1616
    1717void testSpecializationFromGenericOverBareTyvar() {
    18     forall( dtype T )
     18    forall( T & )
    1919    void friend( T & ) {
    2020        printf("friending generically\n");
    2121    }
    2222
    23     forall(dtype T)
     23    forall(T &)
    2424    struct thing {
    2525        int x;
    2626    };
    2727
    28     forall( dtype T )
     28    forall( T & )
    2929    void friend( thing(T) & ) {
    3030        printf("friending specifically\n");
     
    3737void testSpecializationFromGenericAccessibleWithExtraTyvars() {
    3838
    39     forall( dtype T, dtype U )
     39    forall( T &, U & )
    4040    struct map {};
    4141
    42     forall( dtype T )
     42    forall( T & )
    4343    void f( T & ) {
    4444        printf("f-generic\n");
    4545    }
    4646
    47     forall( dtype T )
     47    forall( T & )
    4848    void f( map(T, T) & ) {
    4949        printf("f-specific\n");
  • tests/polymorphism.cfa

    r2f47ea4 rfd54fef  
    1818#include <fstream.hfa>
    1919
    20 forall(otype T)
     20forall(T)
    2121T f(T x, T y) {
    2222        x = y;
     
    2424}
    2525
    26 forall(otype T) T ident(T x) {
     26forall(T) T ident(T x) {
    2727        return x;
    2828}
    2929
    30 forall( otype T, otype U )
     30forall( T, U )
    3131size_t struct_size( T i, U j ) {
    3232        struct S { T i; U j; };
     
    3434}
    3535
    36 forall( otype T, otype U )
     36forall( T, U )
    3737size_t union_size( T i, U j ) {
    3838        union B { T i; U j; };
     
    4141
    4242// perform some simple operations on aggregates of T and U
    43 forall( otype T | { void print(T); int ?==?(T, T); }, otype U | { void print(U); U ?=?(U&, zero_t); } )
     43forall( T | { void print(T); int ?==?(T, T); }, U | { void print(U); U ?=?(U&, zero_t); } )
    4444U foo(T i, U j) {
    4545        struct S { T i; U j; };
  • tests/raii/ctor-autogen.cfa

    r2f47ea4 rfd54fef  
    3333
    3434// dtype-static generic type is otype
    35 forall(dtype T)
     35forall(T &)
    3636struct DtypeStaticStruct {
    3737  T * data;
     
    3939};
    4040
    41 forall(dtype T)
     41forall(T &)
    4242union DtypeStaticUnion {
    4343  T * data;
     
    4646
    4747// dynamic generic type is otype
    48 forall(otype T)
     48forall(T)
    4949struct DynamicStruct {
    5050        T x;
    5151};
    5252
    53 forall(otype T)
     53forall(T)
    5454union DynamicUnion {
    5555        T x;
     
    8080
    8181
    82 forall(otype T)
     82forall(T)
    8383T identity(T x) { return x; }
    8484
  • tests/simpleGenericTriple.cfa

    r2f47ea4 rfd54fef  
    1414//
    1515
    16 forall(otype T)
     16forall(T)
    1717struct T3 {
    1818        T f0, f1, f2;
    1919};
    2020
    21 forall(otype T | { T ?+?(T, T); })
     21forall(T | { T ?+?(T, T); })
    2222T3(T) ?+?(T3(T) x, T3(T) y) {
    2323        T3(T) z = { x.f0+y.f0, x.f1+y.f1, x.f2+y.f2 };
  • tests/sum.cfa

    r2f47ea4 rfd54fef  
    1818#include <stdlib.hfa>
    1919
    20 trait sumable( otype T ) {
     20trait sumable( T ) {
    2121        void ?{}( T &, zero_t );                                                        // 0 literal constructor
    2222        T ?+?( T, T );                                                                          // assortment of additions
     
    2626}; // sumable
    2727
    28 forall( otype T | sumable( T ) )                                                // use trait
     28forall( T | sumable( T ) )                                              // use trait
    2929T sum( size_t size, T a[] ) {
    3030        T total = 0;                                                                            // initialize by 0 constructor
     
    107107                 | sum( size, (S *)a ) | ", check" | (S)s;
    108108
    109         forall( otype Impl | sumable( Impl ) )
     109        forall( Impl | sumable( Impl ) )
    110110        struct GS {
    111111                Impl * x, * y;
     
    194194                 sum( size, (S *)a ).[i, j], s.[i, j] );
    195195
    196         forall( otype Impl | sumable( Impl ) )
     196        forall( Impl | sumable( Impl ) )
    197197        struct GS {
    198198                Impl * x, * y;
  • tests/tuple/tuplePolymorphism.cfa

    r2f47ea4 rfd54fef  
    2929// ensure that f is a viable candidate for g, even though its parameter structure does not exactly match
    3030[A] f([A, B] x, B y) { printf("%g %c %g %lld %c %lld %lld %c %lld\n", x.0.[x,y,z], x.1.[x,y,z], y.[x,y,z]); return x.0; }
    31 forall(otype T, otype U | { T f(T, U, U); })
     31forall(T, U | { T f(T, U, U); })
    3232void g(T x, U y) { f(x, y, y); }
    3333
    3434// add two triples
    35 forall(otype T | { T ?+?(T, T); })
     35forall(T | { T ?+?(T, T); })
    3636[T, T, T] ?+?([T, T, T] x, [T, T, T] y) {
    3737        return [x.0+y.0, x.1+y.1, x.2+y.2];
     
    6464}
    6565
    66 forall(otype T)
     66forall(T)
    6767[T, T] foo([T, T] y) {
    6868        [T, T] x;
  • tests/tuple/tupleVariadic.cfa

    r2f47ea4 rfd54fef  
    1919        printf("called func(void)\n");
    2020}
    21 forall(otype T, ttype Params | { void process(T); void func(Params); })
     21forall(T, Params... | { void process(T); void func(Params); })
    2222void func(T arg1, Params p) {
    2323        process(arg1);
     
    9292}
    9393
    94 forall(otype T)
     94forall(T)
    9595T * copy(T x) {
    9696        // test calling new inside a polymorphic function
     
    9898}
    9999
    100 forall(ttype T | { void foo(T); }) void bar(T x) {}
     100forall(T... | { void foo(T); }) void bar(T x) {}
    101101void foo(int) {}
    102102
  • tests/zombies/ArrayN.c

    r2f47ea4 rfd54fef  
    66// }
    77
    8 forall(otype index_t)
     8forall(index_t)
    99index_t offset_to_index(unsigned offset, index_t size) {
    1010    return [offset / size.0, offset % size.1];
  • tests/zombies/Members.c

    r2f47ea4 rfd54fef  
    22int ?=?( int*, int );
    33float ?=?( float*, float );
    4 forall( dtype DT ) DT * ?=?( DT**, DT* );
    5 forall(otype T) lvalue T *?( T* );
     4forall( DT & ) DT * ?=?( DT**, DT* );
     5forall(T) lvalue T *?( T* );
    66char *__builtin_memcpy();
    77
  • tests/zombies/Rank2.c

    r2f47ea4 rfd54fef  
    11int ?=?( int &, int );
    2 forall(dtype DT) DT * ?=?( DT *&, DT * );
     2forall(DT &) DT * ?=?( DT *&, DT * );
    33
    44void a() {
    5         forall( otype T ) void f( T );
    6         void g( forall( otype U ) void p( U ) );
     5        forall( T ) void f( T );
     6        void g( forall( U ) void p( U ) );
    77        g( f );
    88}
     
    1010void g() {
    1111        void h( int *null );
    12         forall( otype T ) T id( T );
     12        forall( T ) T id( T );
    1313//      forall( dtype T ) T *0;
    1414//      int 0;
  • tests/zombies/abstype.c

    r2f47ea4 rfd54fef  
    2121}
    2222
    23 forall( otype T ) T *?( T * );
     23forall( T ) T *?( T * );
    2424int ?++( int * );
    2525int ?=?( int *, int );
    26 forall( dtype DT ) DT * ?=?( DT **, DT * );
     26forall( DT & ) DT * ?=?( DT **, DT * );
    2727
    2828otype U = int *;
  • tests/zombies/context.cfa

    r2f47ea4 rfd54fef  
    11// trait declaration
    22
    3 trait has_q( otype T ) {
     3trait has_q( T ) {
    44        T q( T );
    55};
    66
    7 forall( otype z | has_q( z ) ) void f() {
    8         trait has_r( otype T, otype U ) {
     7forall( z | has_q( z ) ) void f() {
     8        trait has_r( T, U ) {
    99                T r( T, T (T,U) );
    1010        };
  • tests/zombies/gc_no_raii/bug-repro/blockers/explicit_cast.c

    r2f47ea4 rfd54fef  
    99};
    1010
    11 forall(otype T)
     11forall(T)
    1212struct gcpointer
    1313{
     
    1515};
    1616
    17 forall(otype T)
     17forall(T)
    1818static inline gcpointer(T) gcmalloc()
    1919{
  • tests/zombies/gc_no_raii/bug-repro/blockers/recursive_realloc.c

    r2f47ea4 rfd54fef  
    33#include <stdlib.hfa>
    44
    5 trait allocator_c(otype T, otype allocator_t)
     5trait allocator_c(T, allocator_t)
    66{
    77        void realloc(allocator_t* const, size_t);
    88};
    99
    10 forall(otype T)
     10forall(T)
    1111struct heap_allocator
    1212{
     
    1515};
    1616
    17 forall(otype T)
     17forall(T)
    1818inline void realloc(heap_allocator(T) *const this, size_t size)
    1919{
  • tests/zombies/gc_no_raii/bug-repro/deref.c

    r2f47ea4 rfd54fef  
    1     forall(otype T)
     1    forall(T)
    22    struct wrap
    33    {
     
    55    };
    66
    7     forall(otype T)
     7    forall(T)
    88    T *? (wrap(T) rhs)
    99    {
  • tests/zombies/gc_no_raii/bug-repro/field.c

    r2f47ea4 rfd54fef  
    88//------------------------------------------------------------------------------
    99//Declaration
    10 trait allocator_c(otype T, otype allocator_t)
     10trait allocator_c(T, allocator_t)
    1111{
    1212        void ctor(allocator_t* const);
     
    1616};
    1717
    18 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     18forall(T, allocator_t | allocator_c(T, allocator_t))
    1919struct vector
    2020{
  • tests/zombies/gc_no_raii/bug-repro/malloc.c

    r2f47ea4 rfd54fef  
    1 forall(otype T)
     1forall(T)
    22struct wrapper
    33{
     
    55};
    66
    7 forall(otype T)
     7forall(T)
    88void ctor(wrapper(T)* this)
    99{
     
    1111}
    1212
    13 forall(otype T)
     13forall(T)
    1414wrapper(T) gcmalloc()
    1515{
     
    1919}
    2020
    21 forall(otype T)
     21forall(T)
    2222wrapper(T)* ?=? (wrapper(T)* lhs, wrapper(T)* rhs)
    2323{
  • tests/zombies/gc_no_raii/bug-repro/oddtype.c

    r2f47ea4 rfd54fef  
    1 forall(dtype T)
     1forall(T &)
    22struct wrap {
    33        int i;
    44};
    55
    6 forall(otype T) void ?{}(wrap(T)* this) {}
    7 forall(otype T) void ?=?(wrap(T)* this) {}
    8 forall(otype T) void ^?{}(wrap(T)* this) {}
     6forall(T) void ?{}(wrap(T)* this) {}
     7forall(T) void ?=?(wrap(T)* this) {}
     8forall(T) void ^?{}(wrap(T)* this) {}
    99
    1010struct List_t {
  • tests/zombies/gc_no_raii/bug-repro/push_back.h

    r2f47ea4 rfd54fef  
    11//------------------------------------------------------------------------------
    22//Declaration
    3 trait allocator_c(otype T, otype allocator_t) {
     3trait allocator_c(T, allocator_t) {
    44        void ctor(allocator_t* const);
    55        void dtor(allocator_t* const);
     
    88};
    99
    10 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     10forall(T, allocator_t | allocator_c(T, allocator_t))
    1111struct vector
    1212{
     
    1717//------------------------------------------------------------------------------
    1818//Initialization
    19 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     19forall(T, allocator_t | allocator_c(T, allocator_t))
    2020void vector_ctor(vector(T, allocator_t) *const this);
    2121
    22 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     22forall(T, allocator_t | allocator_c(T, allocator_t))
    2323void dtor(vector(T, allocator_t) *const this);
    2424
    2525//------------------------------------------------------------------------------
    2626//Allocator
    27 forall(otype T)
     27forall(T)
    2828struct heap_allocator
    2929{
     
    3232};
    3333
    34 forall(otype T)
     34forall(T)
    3535void ctor(heap_allocator(T) *const this);
    3636
    37 forall(otype T)
     37forall(T)
    3838void dtor(heap_allocator(T) *const this);
    3939
    40 forall(otype T)
     40forall(T)
    4141void realloc(heap_allocator(T) *const this, size_t size);
    4242
    43 forall(otype T)
     43forall(T)
    4444inline T* data(heap_allocator(T) *const this)
    4545{
     
    4949//------------------------------------------------------------------------------
    5050//Capacity
    51 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     51forall(T, allocator_t | allocator_c(T, allocator_t))
    5252inline bool empty(vector(T, allocator_t) *const this)
    5353{
     
    5555}
    5656
    57 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     57forall(T, allocator_t | allocator_c(T, allocator_t))
    5858inline bool size(vector(T, allocator_t) *const this)
    5959{
     
    6161}
    6262
    63 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     63forall(T, allocator_t | allocator_c(T, allocator_t))
    6464inline void reserve(vector(T, allocator_t) *const this, size_t size)
    6565{
     
    6969//------------------------------------------------------------------------------
    7070//Modifiers
    71 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     71forall(T, allocator_t | allocator_c(T, allocator_t))
    7272void push_back(vector(T, allocator_t) *const this, T value);
  • tests/zombies/gc_no_raii/bug-repro/realloc.c

    r2f47ea4 rfd54fef  
    11void* realloc(void*, unsigned long int);
    22
    3 forall(otype T)
     3forall(T)
    44struct wrap
    55{
     
    77};
    88
    9 forall(otype T)
     9forall(T)
    1010static inline void realloc(wrap(T) *const this, unsigned long int size)
    1111{
  • tests/zombies/gc_no_raii/bug-repro/return.c

    r2f47ea4 rfd54fef  
    1 forall(otype T)
     1forall(T)
    22struct wrapper
    33{
     
    55};
    66
    7 forall(otype T)
     7forall(T)
    88wrapper(T) create()
    99{
     
    1212}
    1313
    14 forall(otype T)
     14forall(T)
    1515wrapper(T)* ?=?(wrapper(T)* lhs, wrapper(T)* rhs)
    1616{
  • tests/zombies/gc_no_raii/bug-repro/return_template.c

    r2f47ea4 rfd54fef  
    1 forall(otype T)
     1forall(T)
    22struct wrap
    33{
     
    55};
    66
    7 forall(otype T) void ?{}(wrap(T)* this);
    8 forall(otype T) void ?{}(wrap(T)* this, wrap(T)* rhs);
    9 forall(otype T) void ^?{}(wrap(T)* this);
    10 forall(otype T) void ?=?(wrap(T)* this, wrap(T)* rhs);
     7forall(T) void ?{}(wrap(T)* this);
     8forall(T) void ?{}(wrap(T)* this, wrap(T)* rhs);
     9forall(T) void ^?{}(wrap(T)* this);
     10forall(T) void ?=?(wrap(T)* this, wrap(T)* rhs);
    1111
    12 forall(otype T)
     12forall(T)
    1313wrap(T) test()
    1414{
  • tests/zombies/gc_no_raii/bug-repro/slow_malloc.c

    r2f47ea4 rfd54fef  
    11#include <stdlib.hfa>
    22
    3 forall(otype T)
     3forall(T)
    44struct heap_allocator
    55{
  • tests/zombies/gc_no_raii/bug-repro/zero.c

    r2f47ea4 rfd54fef  
    1 forall(otype T)
     1forall(T)
    22struct wrap
    33{
     
    55};
    66
    7 forall(otype T)
     7forall(T)
    88int ?==? (wrap(T) lhs, wrap(T) rhs)
    99{
     
    1414struct wrap(int) 0;
    1515/*/
    16 forall(otype T)
     16forall(T)
    1717struct wrap(T) 0;
    1818//*/
  • tests/zombies/gc_no_raii/src/gc.h

    r2f47ea4 rfd54fef  
    1313// }
    1414
    15 forall(otype T)
     15forall(T)
    1616static inline void gcmalloc(gcpointer(T)* ptr)
    1717{
  • tests/zombies/gc_no_raii/src/gcpointers.c

    r2f47ea4 rfd54fef  
    113113#endif
    114114
    115 forall(otype T) void ?{}(gcpointer(T)* this) {
     115forall(T) void ?{}(gcpointer(T)* this) {
    116116        (&this->internal) {};
    117117}
    118118
    119 forall(otype T) void ?{}(gcpointer(T)* this, void* address) {
     119forall(T) void ?{}(gcpointer(T)* this, void* address) {
    120120        (&this->internal) { address };
    121121}
    122122
    123 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) other) {
     123forall(T) void ?{}(gcpointer(T)* this, gcpointer(T) other) {
    124124        (&this->internal) { other.internal };
    125125}
    126126
    127 forall(otype T) void ^?{}(gcpointer(T)* this) {
     127forall(T) void ^?{}(gcpointer(T)* this) {
    128128        ^?{}(&this->internal);
    129129}
    130130
    131 forall(otype T) gcpointer(T) ?=?(gcpointer(T)* this, gcpointer(T) rhs) {
     131forall(T) gcpointer(T) ?=?(gcpointer(T)* this, gcpointer(T) rhs) {
    132132        this->internal = rhs.internal;
    133133        return *this;
     
    136136// forall(otype T) T *?(gcpointer(T) this);
    137137
    138 forall(otype T) T* get(gcpointer(T)* this) {
     138forall(T) T* get(gcpointer(T)* this) {
    139139        return (T*)this->internal.ptr;
    140140}
    141141//
    142142// //Logical operators
    143 forall(otype T) int ?!=?(gcpointer(T) this, int zero) {
     143forall(T) int ?!=?(gcpointer(T) this, int zero) {
    144144        return this.internal.ptr != 0;
    145145}
  • tests/zombies/gc_no_raii/src/gcpointers.h

    r2f47ea4 rfd54fef  
    44#include <stdint.h>
    55
    6 forall(dtype T)
     6forall(T &)
    77struct gcpointer;
    88
     
    2929#endif
    3030
    31 forall(dtype T)
     31forall(T &)
    3232struct gcpointer
    3333{
     
    3636
    3737//
    38 forall(otype T) void ?{}(gcpointer(T)* this);
    39 forall(otype T) void ?{}(gcpointer(T)* this, void* address);
    40 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) other);
    41 forall(otype T) void ^?{}(gcpointer(T)* this);
    42 forall(otype T) gcpointer(T) ?=?(gcpointer(T)* this, gcpointer(T) rhs);
     38forall(T) void ?{}(gcpointer(T)* this);
     39forall(T) void ?{}(gcpointer(T)* this, void* address);
     40forall(T) void ?{}(gcpointer(T)* this, gcpointer(T) other);
     41forall(T) void ^?{}(gcpointer(T)* this);
     42forall(T) gcpointer(T) ?=?(gcpointer(T)* this, gcpointer(T) rhs);
    4343
    4444
    4545// forall(otype T) T *?(gcpointer(T) this);
    46 forall(otype T) T* get(gcpointer(T)* this);
     46forall(T) T* get(gcpointer(T)* this);
    4747
    4848//Logical operators
    49 forall(otype T) int ?!=?(gcpointer(T) this, int zero);
    50 forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs);
    51 forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs);
     49forall(T) int ?!=?(gcpointer(T) this, int zero);
     50forall(T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs);
     51forall(T) int ?==?(gcpointer(T) this, gcpointer(T) rhs);
  • tests/zombies/gc_no_raii/src/tools.h

    r2f47ea4 rfd54fef  
    1212// }
    1313
    14 trait has_equal(otype T)
     14trait has_equal(T)
    1515{
    1616        signed int ?==?(T a, T b);
    1717};
    1818
    19 trait InputIterator_t(otype T, otype InputIterator)
     19trait InputIterator_t(T, InputIterator)
    2020{
    2121        signed int ?==?(InputIterator a, InputIterator b);
     
    2626};
    2727
    28 forall(otype T | has_equal(T), otype InputIterator | InputIterator_t(T, InputIterator))
     28forall(T | has_equal(T), InputIterator | InputIterator_t(T, InputIterator))
    2929static inline InputIterator find( InputIterator first, const InputIterator* const last, T val)
    3030{
  • tests/zombies/hashtable.cfa

    r2f47ea4 rfd54fef  
    1414
    1515
    16 trait has_hash( otype K ) {
     16trait has_hash( K ) {
    1717    size_t hash(K);
    1818    int ?==?( K, K );
    1919};
    2020
    21 trait hkey( otype K, dtype tN | has_hash(K) ) {
     21trait hkey( K, tN & | has_hash(K) ) {
    2222    K key(tN &);
    2323};
    2424
    25 forall( otype K, dtype tN, dtype tE | $dlistable(tN, tE) | hkey(K, tN) ) {
     25forall( K, tN &, tE & | $dlistable(tN, tE) | hkey(K, tN) ) {
    2626
    2727    struct hashtable {
     
    3939}
    4040
    41 forall( otype K, dtype tN, dtype tE | $dlistable(tN, tE) | hkey(K, tN) | { void defaultResumptionHandler(ht_fill_limit_crossed &); } ) {
     41forall( K, tN &, tE & | $dlistable(tN, tE) | hkey(K, tN) | { void defaultResumptionHandler(ht_fill_limit_crossed &); } ) {
    4242
    4343    void ?{}( hashtable(K, tN, tE) & this, size_t n_buckets, dlist(tN, tE) *buckets ) {
     
    5757}
    5858
    59 forall( otype K, dtype tN, dtype tE | $dlistable(tN, tE) | hkey(K, tN) ) {
     59forall( K, tN &, tE & | $dlistable(tN, tE) | hkey(K, tN) ) {
    6060
    6161    float fill_frac( hashtable(K, tN, tE) & this ) with(this) {
     
    124124
    125125
    126 trait heaped(dtype T) {
     126trait heaped(T &) {
    127127    T * alloc( size_t );
    128128    void free( void * );
     
    133133}
    134134
    135 forall( otype K, dtype tN, dtype tE | $dlistable(tN, tE) | hkey(K, tN) | heaped( dlist(tN, tE) ) ) {
     135forall( K, tN &, tE & | $dlistable(tN, tE) | hkey(K, tN) | heaped( dlist(tN, tE) ) ) {
    136136
    137137    struct hashtable_dynamic {
  • tests/zombies/hashtable2.cfa

    r2f47ea4 rfd54fef  
    6969
    7070
    71 trait pretendsToMatter( dtype TTT ) {
     71trait pretendsToMatter( TTT & ) {
    7272    void actsmart(TTT &);
    7373};
    7474
    75 forall( dtype TTTx )
     75forall( TTTx & )
    7676void actsmart(TTTx &) {}
    7777
     
    8686//   2. shows up in -CFA output as hashtable_rbs(), which is bad C; expecting hashtable_rbs*
    8787
    88 forall( otype Tt_unused | pretendsToMatter(Tt_unused) ) {
     88forall( Tt_unused | pretendsToMatter(Tt_unused) ) {
    8989
    9090    // hashtable of request by source
     
    104104}
    105105
    106 forall( otype Tt_unused | pretendsToMatter(Tt_unused) | { void defaultResumptionHandler(ht_fill_limit_crossed &); } ) {
     106forall( Tt_unused | pretendsToMatter(Tt_unused) | { void defaultResumptionHandler(ht_fill_limit_crossed &); } ) {
    107107
    108108    void ?{}( hashtable_rbs(Tt_unused) & this, size_t n_buckets, dlist(request_in_ht_by_src, request) *buckets,
     
    135135void defaultResumptionHandler( ht_auto_resize_pending & ex );
    136136
    137 forall( otype Tt_unused | pretendsToMatter(Tt_unused) ) {
     137forall( Tt_unused | pretendsToMatter(Tt_unused) ) {
    138138
    139139    float fill_frac( hashtable_rbs(Tt_unused) & this ) with(this) {
     
    221221
    222222
    223 trait heaped(dtype T) {
     223trait heaped(T &) {
    224224    T * alloc( size_t );
    225225    void free( void * );
     
    228228void __dynamic_defaultResumptionHandler(ht_fill_limit_crossed &);
    229229
    230 forall( otype Tt_unused ) {
     230forall( Tt_unused ) {
    231231
    232232    struct hashtable_rbs_dynamic {
     
    263263
    264264
    265 forall( otype Tt_unused | heaped( dlist(request_in_ht_by_src, request) ) ) {
     265forall( Tt_unused | heaped( dlist(request_in_ht_by_src, request) ) ) {
    266266
    267267    void ?{}( hashtable_rbs_dynamic(Tt_unused).resize_policy & this, size_t nbuckets_floor ) {
     
    325325}
    326326
    327 forall( otype Tt_unused ) {
     327forall( Tt_unused ) {
    328328    void rehashToLarger_STEP( hashtable_rbs_dynamic(Tt_unused) & this, size_t new_n_buckets ) with (this) {
    329329        rehashToLarger( this, new_n_buckets );
  • tests/zombies/huge.c

    r2f47ea4 rfd54fef  
    1414//
    1515
    16 int huge( int n, forall( otype T ) T (*f)( T ) ) {
     16int huge( int n, forall( T ) T (*f)( T ) ) {
    1717        if ( n <= 0 )
    1818                return f( 0 );
  • tests/zombies/it_out.c

    r2f47ea4 rfd54fef  
    1616typedef unsigned long streamsize_type;
    1717
    18 trait ostream( dtype os_type ) {
     18trait ostream( os_type & ) {
    1919        os_type *write( os_type *, const char *, streamsize_type );
    2020        int fail( os_type * );
    2121};
    2222
    23 trait writeable( otype T ) {
    24         forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, T );
     23trait writeable( T ) {
     24        forall( os_type & | ostream( os_type ) ) os_type * ?<<?( os_type *, T );
    2525};
    2626
    27 forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, char );
    28 forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, int );
    29 forall( dtype os_type | ostream( os_type ) ) os_type * ?<<?( os_type *, const char * );
     27forall( os_type & | ostream( os_type ) ) os_type * ?<<?( os_type *, char );
     28forall( os_type & | ostream( os_type ) ) os_type * ?<<?( os_type *, int );
     29forall( os_type & | ostream( os_type ) ) os_type * ?<<?( os_type *, const char * );
    3030
    31 trait istream( dtype is_type ) {
     31trait istream( is_type & ) {
    3232        is_type *read( is_type *, char *, streamsize_type );
    3333        is_type *unread( is_type *, char );
     
    3636};
    3737
    38 trait readable( otype T ) {
    39         forall( dtype is_type | istream( is_type ) ) is_type * ?<<?( is_type *, T );
     38trait readable( T ) {
     39        forall( is_type & | istream( is_type ) ) is_type * ?<<?( is_type *, T );
    4040};
    4141
    42 forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, char* );
    43 forall( dtype is_type | istream( is_type ) ) is_type * ?>>?( is_type *, int* );
     42forall( is_type & | istream( is_type ) ) is_type * ?>>?( is_type *, char* );
     43forall( is_type & | istream( is_type ) ) is_type * ?>>?( is_type *, int* );
    4444
    45 trait iterator( otype iterator_type, otype elt_type ) {
     45trait iterator( iterator_type, elt_type ) {
    4646        iterator_type ?++( iterator_type* );
    4747        iterator_type ++?( iterator_type* );
     
    5252};
    5353
    54 forall( otype elt_type | writeable( elt_type ),
    55                 otype iterator_type | iterator( iterator_type, elt_type ),
    56                 dtype os_type | ostream( os_type ) )
     54forall( elt_type | writeable( elt_type ),
     55                iterator_type | iterator( iterator_type, elt_type ),
     56                os_type & | ostream( os_type ) )
    5757void write_all( iterator_type begin, iterator_type end, os_type *os );
    5858
    59 forall( otype elt_type | writeable( elt_type ),
    60                 otype iterator_type | iterator( iterator_type, elt_type ),
    61                 dtype os_type | ostream( os_type ) )
     59forall( elt_type | writeable( elt_type ),
     60                iterator_type | iterator( iterator_type, elt_type ),
     61                os_type & | ostream( os_type ) )
    6262void write_all( elt_type begin, iterator_type end, os_type *os ) {
    6363        os << begin;
  • tests/zombies/new.c

    r2f47ea4 rfd54fef  
    1414//
    1515
    16 forall( otype T )
     16forall( T )
    1717void f( T *t ) {
    1818        t--;
  • tests/zombies/occursError.cfa

    r2f47ea4 rfd54fef  
    1 forall( otype T ) void f( void (*)( T, T * ) );
    2 forall( otype U ) void g( U,  U * );
    3 forall( otype U ) void h( U *, U );
     1forall( T ) void f( void (*)( T, T * ) );
     2forall( U ) void g( U,  U * );
     3forall( U ) void h( U *, U );
    44
    55void test() {
  • tests/zombies/prolog.c

    r2f47ea4 rfd54fef  
    2525void is_integer( int x ) {}
    2626
    27 trait ArithmeticType( otype T ) {
     27trait ArithmeticType( T ) {
    2828        void is_arithmetic( T );
    2929};
    3030
    31 trait IntegralType( otype T | ArithmeticType( T ) ) {
     31trait IntegralType( T | ArithmeticType( T ) ) {
    3232        void is_integer( T );
    3333};
    3434
    35 forall( otype T | IntegralType( T ) | { void printResult( T ); } )
     35forall( T | IntegralType( T ) | { void printResult( T ); } )
    3636void hornclause( T param ) {
    3737        printResult( param );
  • tests/zombies/quad.c

    r2f47ea4 rfd54fef  
    1616#include <fstream.hfa>
    1717
    18 forall( otype T | { T ?*?( T, T ); } )
     18forall( T | { T ?*?( T, T ); } )
    1919T square( T t ) {
    2020        return t * t;
    2121}
    2222
    23 forall( otype U | { U square( U ); } )
     23forall( U | { U square( U ); } )
    2424U quad( U u ) {
    2525        return square( square( u ) );
  • tests/zombies/scope.cfa

    r2f47ea4 rfd54fef  
    2020y p;
    2121
    22 trait has_u( otype z ) {
     22trait has_u( z ) {
    2323        z u(z);
    2424};
    2525
    26 forall( otype t | has_u( t ) )
     26forall( t | has_u( t ) )
    2727y q( t the_t ) {
    2828        t y = u( the_t );
  • tests/zombies/simplePoly.c

    r2f47ea4 rfd54fef  
    1414//
    1515
    16 forall( otype T, otype U | { T f( T, U ); } )
     16forall( T, U | { T f( T, U ); } )
    1717T q( T t, U u ) {
    1818        return f( t, u );
  • tests/zombies/simpler.c

    r2f47ea4 rfd54fef  
    1414//
    1515
    16 forall( otype T ) T id( T, T );
     16forall( T ) T id( T, T );
    1717
    1818int main() {
  • tests/zombies/specialize.c

    r2f47ea4 rfd54fef  
    3939}
    4040
    41 forall( otype T ) T f( T t )
     41forall( T ) T f( T t )
    4242{
    4343        printf( "in f; sizeof T is %d\n", sizeof( T ) );
  • tests/zombies/square.c

    r2f47ea4 rfd54fef  
    1616#include <fstream.hfa>
    1717
    18 forall( otype T | { T ?*?( T, T ); } )
     18forall( T | { T ?*?( T, T ); } )
    1919T square( T t ) {
    2020        return t * t;
  • tests/zombies/structMember.cfa

    r2f47ea4 rfd54fef  
    6666        S.T;
    6767        .S.T;
    68         forall( otype S, otype T ) struct W {
     68        forall( S, T ) struct W {
    6969                struct X {};
    7070        };
  • tests/zombies/subrange.cfa

    r2f47ea4 rfd54fef  
    11// A small context defining the notion of an ordered otype.  (The standard
    22// library should probably contain a context for this purpose.)
    3 trait ordered(otype T) {
     3trait ordered(T) {
    44    int ?<?(T, T), ?<=?(T, T);
    55};
     
    77// A subrange otype resembling an Ada subotype with a base otype and a range
    88// constraint.
    9 otype subrange(otype base_t | ordered(base_t), base_t low = 0, base_t high = 8) = base_t;
     9otype subrange(base_t | ordered(base_t), base_t low = 0, base_t high = 8) = base_t;
    1010
    1111// Note that subrange() can be applied to floating-point and pointer otypes, not
     
    2828
    2929// Convenient access to subrange bounds, for instance for iteration:
    30 forall (otype T, T low, T high)
     30forall (T, T low, T high)
    3131T lbound( subrange(T, low, high) v) {
    3232    return low;
    3333}
    3434
    35 forall (otype T, T low, T high)
     35forall (T, T low, T high)
    3636T hbound( subrange(T, low, high) v) {
    3737    return high;
     
    4444// of exception handling here.  Inlining allows the compiler to eliminate
    4545// bounds checks.
    46 forall (otype T | ordered(T), T low, T high)
     46forall (T | ordered(T), T low, T high)
    4747inline subrange(T, low, high) ?=?(subrange(T, low, high)* target, T source) {
    4848    if (low <= source && source <= high) *((T*)target) = source;
     
    5454// compares range bounds so that the compiler can optimize checks away when the
    5555// ranges are known to overlap.
    56 forall (otype T | ordered(T), T t_low, T t_high, T s_low, T s_high)
     56forall (T | ordered(T), T t_low, T t_high, T s_low, T s_high)
    5757inline subrange(T, t_low, t_high) ?=?(subrange(T, t_low, t_high)* target,
    5858                                      subrange(T, s_low, s_high) source) {
  • tests/zombies/twice.c

    r2f47ea4 rfd54fef  
    1616#include <fstream.hfa>
    1717
    18 forall( otype T | { T ?+?( T, T ); } )
     18forall( T | { T ?+?( T, T ); } )
    1919T twice( const T t ) {
    2020        return t + t;
  • tests/zombies/typeGenerator.cfa

    r2f47ea4 rfd54fef  
    1 context addable( otype T ) {
     1context addable( T ) {
    22        T ?+?( T,T );
    33        T ?=?( T*, T);
    44};
    55
    6 otype List1( otype T | addable( T ) ) = struct { T data; List1( T ) *next; } *;
     6otype List1( T | addable( T ) ) = struct { T data; List1( T ) *next; } *;
    77typedef List1( int ) ListOfIntegers;
    88//List1( int ) li;
     
    1111[int] h( * List1( int ) p );                                                    // new declaration syntax
    1212
    13 struct( otype T ) S2 { T i; };                                                  // actual definition
     13struct( T ) S2 { T i; };                                                        // actual definition
    1414struct( int ) S3 v1, *p;                                                                // expansion and instantiation
    15 struct( otype T )( int ) S24 { T i; } v2;                               // actual definition, expansion and instantiation
    16 struct( otype T )( int ) { T i; } v2;                                   // anonymous actual definition, expansion and instantiation
     15struct( T )( int ) S24 { T i; } v2;                             // actual definition, expansion and instantiation
     16struct( T )( int ) { T i; } v2;                                 // anonymous actual definition, expansion and instantiation
    1717
    18 struct( otype T | addable( T ) ) node { T data; struct( T ) node *next; };
    19 otype List( otype T ) = struct( T ) node *;
     18struct( T | addable( T ) ) node { T data; struct( T ) node *next; };
     19otype List( T ) = struct( T ) node *;
    2020List( int ) my_list;
    2121
  • tests/zombies/withStatement.cfa

    r2f47ea4 rfd54fef  
    5454}
    5555
    56 forall( otype T )
     56forall( T )
    5757struct Box {
    5858        T x;
    5959};
    6060
    61 forall( otype T )
     61forall( T )
    6262void ?{}( Box(T) & this ) with( this ) { // with clause in polymorphic function
    6363        x{};
     
    6666void print( int i ) { sout | i; }
    6767
    68 forall( otype T | { void print( T ); })
     68forall( T | { void print( T ); })
    6969void foo( T t ) {
    7070        Box( T ) b = { t };
  • tests/zombies/wrapper/src/pointer.h

    r2f47ea4 rfd54fef  
    88// type safe malloc / free
    99
    10 forall(otype T)
     10forall(T)
    1111T* new()
    1212{
     
    1616}
    1717
    18 forall(otype T)
     18forall(T)
    1919void delete(T* p)
    2020{
Note: See TracChangeset for help on using the changeset viewer.