Changeset fd54fef for tests/zombies


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.

Location:
tests/zombies
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • 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.