Changeset 63a4b92 for libcfa/src


Ignore:
Timestamp:
Apr 29, 2021, 10:25:20 PM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b9dae14c
Parents:
3eb55f98
Message:

Improved support for new arrays subscripting by tuples, --,-,-?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/containers/array.hfa

    r3eb55f98 r63a4b92  
    2525
    2626    Timmed & ?[?]( arpk(Zn, S, Timmed, Tbase) & a, ptrdiff_t i ) {
     27        return (Timmed &) a.strides[i];
     28    }
     29
     30    Timmed & ?[?]( arpk(Zn, S, Timmed, Tbase) & a, int i ) {
     31        return (Timmed &) a.strides[i];
     32    }
     33
     34    Timmed & ?[?]( arpk(Zn, S, Timmed, Tbase) & a, size_t i ) {
    2735        return (Timmed &) a.strides[i];
    2836    }
     
    8088// Core -[[-,-,-]] operator
    8189
     90#ifdef TRY_BROKEN_DESIRED_MD_SUBSCRIPT
     91
    8292// Desired form.  One definition with recursion on IxBC (worked until Jan 2021, see trac #__TODO__)
    83 // forall( TA &, TB &, TC &, IxAB, IxBC ... | { TB & ?[?]( TA &, IxAB ); TC & ?[?]( TB &, IxBC ); } )
    84 // TC & ?[?]( TA & this, IxAB ab, IxBC bc ) {
    85 //     return this[ab][bc];
    86 // }
    8793
    88 // Workaround form.  Listing all possibilities up to 4 dims.
    89 forall( TA &, TB &, IxAB | { TB & ?[?]( TA &, IxAB ); }
    90             , TC &, IxBC | { TC & ?[?]( TB &, IxBC ); } )
     94forall( TA &, TB &, TC &, IxAB, IxBC ... | { TB & ?[?]( TA &, IxAB ); TC & ?[?]( TB &, IxBC ); } )
    9195TC & ?[?]( TA & this, IxAB ab, IxBC bc ) {
    9296    return this[ab][bc];
    9397}
    94 forall( TA &, TB &, IxAB | { TB & ?[?]( TA &, IxAB ); }
    95             , TC &, IxBC | { TC & ?[?]( TB &, IxBC ); }
    96             , TD &, IxCD | { TD & ?[?]( TC &, IxCD ); } )
    97 TD & ?[?]( TA & this, IxAB ab, IxBC bc, IxCD cd ) {
    98     return this[ab][bc][cd];
    99 }
    100 forall( TA &, TB &, IxAB | { TB & ?[?]( TA &, IxAB ); }
    101             , TC &, IxBC | { TC & ?[?]( TB &, IxBC ); }
    102             , TD &, IxCD | { TD & ?[?]( TC &, IxCD ); }
    103             , TE &, IxDE | { TE & ?[?]( TD &, IxDE ); } )
    104 TE & ?[?]( TA & this, IxAB ab, IxBC bc, IxCD cd, IxDE de ) {
    105     return this[ab][bc][cd][de];
     98
     99#else
     100
     101// Workaround form.  Listing all possibilities up to 4 dims.
     102
     103forall( TA &, TB &, TC &, IxAB_0, IxBC | { TB & ?[?]( TA &, IxAB_0 ); TC & ?[?]( TB &, IxBC ); } )
     104TC & ?[?]( TA & this, IxAB_0 ab, IxBC bc ) {
     105    return this[ab][bc];
    106106}
    107107
    108 // Adapters for "indexed by ptrdiff_t" implies "indexed by [this other integral type]"
    109 // Work around restriction that assertions underlying -[[-,-,-]] must match excatly
    110 forall( C &, E & | { E & ?[?]( C &, ptrdiff_t ); } ) {
     108forall( TA &, TB &, TC &, IxAB_0, IxAB_1, IxBC | { TB & ?[?]( TA &, IxAB_0, IxAB_1 ); TC & ?[?]( TB &, IxBC ); } )
     109TC & ?[?]( TA & this, IxAB_0 ab0, IxAB_1 ab1, IxBC bc ) {
     110    return this[[ab0,ab1]][bc];
     111}
    111112
    112     // Targeted to support:  for( i; z(N) ) ... a[[ ..., i, ... ]]
    113     E & ?[?]( C & this, size_t i ) {
    114         return this[ (ptrdiff_t) i ];
    115     }
     113forall( TA &, TB &, TC &, IxAB_0, IxAB_1, IxAB_2, IxBC | { TB & ?[?]( TA &, IxAB_0, IxAB_1, IxAB_2 ); TC & ?[?]( TB &, IxBC ); } )
     114TC & ?[?]( TA & this, IxAB_0 ab0, IxAB_1 ab1, IxAB_2 ab2, IxBC bc ) {
     115    return this[[ab0,ab1,ab2]][bc];
     116}
    116117
    117     // Targeted to support:  for( i; 5 ) ... a[[ ..., i, ... ]]
    118     E & ?[?]( C & this, int i ) {
    119         return this[ (ptrdiff_t) i ];
    120     }
    121 }
     118#endif
    122119
    123120//
Note: See TracChangeset for help on using the changeset viewer.