ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 99f11dd was
ca26509,
checked in by Peter A. Buhr <pabuhr@…>, 8 years ago
|
relocate and delete example programs under Test directory to test/examples directories
|
-
Property mode set to
100644
|
File size:
1.8 KB
|
Rev | Line | |
---|
[68cd1ce] | 1 | // I Compile-time resolution |
---|
| 2 | // ========================= |
---|
| 3 | // |
---|
| 4 | // 1. an isolated name, where the argument is implicitly determined by the result context |
---|
| 5 | // |
---|
| 6 | // @max |
---|
| 7 | // |
---|
[55ba7339] | 8 | // 2. a direct application to a manifest otype |
---|
[68cd1ce] | 9 | // |
---|
| 10 | // @max( int ) |
---|
| 11 | // |
---|
[55ba7339] | 12 | // 3. constraining a otype variable; the application is implicitly performed at the call site as in (2) |
---|
[68cd1ce] | 13 | // |
---|
[55ba7339] | 14 | // forall( otype T | { T @max( T ); } ) T x( T t ); |
---|
[68cd1ce] | 15 | // |
---|
| 16 | // |
---|
| 17 | // II Run-time resolution |
---|
| 18 | // ====================== |
---|
| 19 | // |
---|
| 20 | // 1. an indirect reference, where the argument is implicitly determined by the result context |
---|
| 21 | // |
---|
| 22 | // attr_var = &@max; |
---|
| 23 | // x = (*attr_var); |
---|
| 24 | // |
---|
[55ba7339] | 25 | // 2. an indirect application to a manifest otype |
---|
[68cd1ce] | 26 | // |
---|
| 27 | // (*attr_var)( int ) |
---|
| 28 | // |
---|
[55ba7339] | 29 | // 3. a direct application to a otype variable |
---|
[68cd1ce] | 30 | // |
---|
| 31 | // @max( T ) |
---|
| 32 | // |
---|
| 33 | // Under what circumstances can this be done at compile/link time? |
---|
| 34 | // |
---|
| 35 | // |
---|
| 36 | // III Declaration forms |
---|
| 37 | // ===================== |
---|
| 38 | // |
---|
| 39 | // 1. monomorphic with implicit argument |
---|
| 40 | // |
---|
| 41 | // int @max; |
---|
| 42 | // |
---|
| 43 | // 2. monomorphic with explicit argument |
---|
| 44 | // |
---|
| 45 | // int @max( int ); |
---|
| 46 | // |
---|
| 47 | // 3. polymorphic |
---|
| 48 | // |
---|
[55ba7339] | 49 | // forall( otype T | constraint( T ) ) int @attr( T ); |
---|
[68cd1ce] | 50 | |
---|
[51b7345] | 51 | int @max = 3; |
---|
| 52 | |
---|
| 53 | int main() { |
---|
| 54 | int x; |
---|
[55ba7339] | 55 | otype @otype(otype t); // compiler intrinsic |
---|
| 56 | otype @widest(otype t); |
---|
| 57 | @otype(x) *y; // gcc: otypeof(x) *y; |
---|
[ca26509] | 58 | // const @widest(double) *w; // gcc: const otypeof(x) *w; |
---|
| 59 | // * @otype(3 + 4) z; // cfa declaration syntax |
---|
[51b7345] | 60 | y = @max; |
---|
| 61 | z = @max(x) + @size(int); |
---|
| 62 | y = @min(3 + 4); |
---|
| 63 | if ( @const(x) ) { } |
---|
| 64 | if ( @volatile(y) ) { } |
---|
| 65 | if ( @extern(y) ) { } |
---|
| 66 | if ( @static(y) ) { } |
---|
| 67 | @max; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | int @foo(int) { |
---|
| 71 | return 7; |
---|
| 72 | } |
---|
[8a95629] | 73 | |
---|
| 74 | int @voon; |
---|
| 75 | double @voon; |
---|
| 76 | |
---|
| 77 | int @bort(int); |
---|
| 78 | int @bort(double); |
---|
| 79 | |
---|
| 80 | void g( int ); |
---|
| 81 | |
---|
| 82 | void f() { |
---|
| 83 | float x; |
---|
| 84 | double x; |
---|
| 85 | @bort(x); |
---|
| 86 | @bort(int); |
---|
| 87 | g( @voon ); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | // Local Variables: // |
---|
| 91 | // tab-width: 4 // |
---|
| 92 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.